This commit is contained in:
eewing
2026-02-17 14:10:16 -06:00
parent 2bca5834c5
commit cf73cd3b4c
11246 changed files with 1690552 additions and 0 deletions
@@ -0,0 +1,10 @@
<script lang="ts">
import { RatingGroupHiddenInputState } from "../rating-group.svelte.js";
import HiddenInput from "../../utilities/hidden-input.svelte";
const inputState = RatingGroupHiddenInputState.create();
</script>
{#if inputState.shouldRender}
<HiddenInput {...inputState.props} />
{/if}
@@ -0,0 +1,18 @@
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
$$bindings?: Bindings;
} & Exports;
(internal: unknown, props: {
$$events?: Events;
$$slots?: Slots;
}): Exports & {
$set?: any;
$on?: any;
};
z_$$bindings?: Bindings;
}
declare const RatingGroupInput: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
[evt: string]: CustomEvent<any>;
}, {}, {}, string>;
type RatingGroupInput = InstanceType<typeof RatingGroupInput>;
export default RatingGroupInput;
@@ -0,0 +1,38 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { RatingGroupItemProps } from "../types.js";
import { RatingGroupItemState } from "../rating-group.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
disabled = false,
index,
children,
child,
ref = $bindable(null),
id = createId(uid),
...restProps
}: RatingGroupItemProps = $props();
const itemState = RatingGroupItemState.create({
disabled: boxWith(() => Boolean(disabled)),
index: boxWith(() => index),
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, itemState.props));
</script>
{#if child}
{@render child({ props: mergedProps, ...itemState.snippetProps })}
{:else}
<div {...mergedProps}>
{@render children?.(itemState.snippetProps)}
</div>
{/if}
@@ -0,0 +1,4 @@
import type { RatingGroupItemProps } from "../types.js";
declare const RatingGroupItem: import("svelte").Component<RatingGroupItemProps, {}, "ref">;
type RatingGroupItem = ReturnType<typeof RatingGroupItem>;
export default RatingGroupItem;
@@ -0,0 +1,80 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { RatingGroupRootProps } from "../types.js";
import { RatingGroupRootState } from "../rating-group.svelte.js";
import RatingGroupInput from "./rating-group-input.svelte";
import { createId } from "../../../internal/create-id.js";
import { noop } from "../../../internal/noop.js";
const uid = $props.id();
let {
disabled = false,
children,
child,
value = $bindable(0),
ref = $bindable(null),
orientation = "horizontal",
name = undefined,
required = false,
min = 0,
max = 5,
allowHalf = false,
readonly = false,
id = createId(uid),
onValueChange = noop,
"aria-label": ariaLabel,
"aria-valuetext": ariaValuetextProp,
hoverPreview = true,
...restProps
}: RatingGroupRootProps = $props();
if (value < min || value > max) {
value = Math.max(min, Math.min(max, value));
}
const ariaValuetext: NonNullable<RatingGroupRootProps["aria-valuetext"]> = $derived.by(() => {
if (ariaValuetextProp) return ariaValuetextProp;
return (value: number, max: number) => `${value} out of ${max}`;
});
const rootState = RatingGroupRootState.create({
orientation: boxWith(() => orientation),
disabled: boxWith(() => disabled),
name: boxWith(() => name),
required: boxWith(() => required),
min: boxWith(() => min),
max: boxWith(() => max),
allowHalf: boxWith(() => allowHalf),
readonly: boxWith(() => readonly),
id: boxWith(() => id),
value: boxWith(
() => value,
(v) => {
if (v === value) return;
value = v;
onValueChange?.(v);
}
),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
ariaValuetext: boxWith(() => ariaValuetext),
hoverPreview: boxWith(() => hoverPreview),
});
const mergedProps = $derived(
mergeProps(restProps, rootState.props, { "aria-label": ariaLabel })
);
</script>
{#if child}
{@render child({ props: mergedProps, ...rootState.snippetProps })}
{:else}
<div {...mergedProps}>
{@render children?.(rootState.snippetProps)}
</div>
{/if}
<RatingGroupInput />
@@ -0,0 +1,4 @@
import type { RatingGroupRootProps } from "../types.js";
declare const RatingGroup: import("svelte").Component<RatingGroupRootProps, {}, "value" | "ref">;
type RatingGroup = ReturnType<typeof RatingGroup>;
export default RatingGroup;