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
+40
View File
@@ -0,0 +1,40 @@
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { MeterRootProps } from "../types.js";
import { MeterRootState } from "../meter.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
child,
children,
value = 0,
max = 100,
min = 0,
id = createId(uid),
ref = $bindable(null),
...restProps
}: MeterRootProps = $props();
const rootState = MeterRootState.create({
value: boxWith(() => value),
max: boxWith(() => max),
min: boxWith(() => min),
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, rootState.props));
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<div {...mergedProps}>
{@render children?.()}
</div>
{/if}
+4
View File
@@ -0,0 +1,4 @@
import type { MeterRootProps } from "../types.js";
declare const Meter: import("svelte").Component<MeterRootProps, {}, "ref">;
type Meter = ReturnType<typeof Meter>;
export default Meter;
+2
View File
@@ -0,0 +1,2 @@
export { default as Root } from "./components/meter.svelte";
export type { MeterRootProps as RootProps } from "./types.js";
+1
View File
@@ -0,0 +1 @@
export { default as Root } from "./components/meter.svelte";
+1
View File
@@ -0,0 +1 @@
export * as Meter from "./exports.js";
+1
View File
@@ -0,0 +1 @@
export * as Meter from "./exports.js";
+25
View File
@@ -0,0 +1,25 @@
import { type ReadableBoxedValues } from "svelte-toolbelt";
import type { RefAttachment, WithRefOpts } from "../../internal/types.js";
interface MeterRootStateOpts extends WithRefOpts, ReadableBoxedValues<{
value: number;
max: number;
min: number;
}> {
}
export declare class MeterRootState {
static create(opts: MeterRootStateOpts): MeterRootState;
readonly opts: MeterRootStateOpts;
readonly attachment: RefAttachment;
constructor(opts: MeterRootStateOpts);
readonly props: {
readonly role: "meter";
readonly value: number;
readonly "aria-valuemin": number;
readonly "aria-valuemax": number;
readonly "aria-valuenow": number;
readonly "data-value": number;
readonly "data-max": number;
readonly "data-min": number;
};
}
export {};
+29
View File
@@ -0,0 +1,29 @@
import { attachRef } from "svelte-toolbelt";
import { createBitsAttrs } from "../../internal/attrs.js";
const meterAttrs = createBitsAttrs({
component: "meter",
parts: ["root"],
});
export class MeterRootState {
static create(opts) {
return new MeterRootState(opts);
}
opts;
attachment;
constructor(opts) {
this.opts = opts;
this.attachment = attachRef(this.opts.ref);
}
props = $derived.by(() => ({
role: "meter",
value: this.opts.value.current,
"aria-valuemin": this.opts.min.current,
"aria-valuemax": this.opts.max.current,
"aria-valuenow": this.opts.value.current,
"data-value": this.opts.value.current,
"data-max": this.opts.max.current,
"data-min": this.opts.min.current,
[meterAttrs.root]: "",
...this.attachment,
}));
}
+23
View File
@@ -0,0 +1,23 @@
import type { WithChild, Without } from "../../internal/types.js";
import type { BitsPrimitiveDivAttributes } from "../../shared/attributes.js";
export type MeterRootPropsWithoutHTML = WithChild<{
/**
* The current value of the meter.
*
* @default 0
*/
value?: number;
/**
* The maximum value of the meter.
*
* @default 100
*/
max?: number;
/**
* The minimum value of the meter.
*
* @default 0
*/
min?: number;
}>;
export type MeterRootProps = MeterRootPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, MeterRootPropsWithoutHTML>;
+1
View File
@@ -0,0 +1 @@
export {};