kumo-svelte 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/component-registry.json +126 -11
- package/ai/component-registry.md +9 -1
- package/dist/components/button/Button.svelte +52 -15
- package/dist/components/button/Button.svelte.d.ts +6 -6
- package/dist/components/chart/ChartLegend.svelte +46 -3
- package/dist/components/chart/ChartLegend.svelte.d.ts +5 -0
- package/dist/components/chart/TimeseriesChart.svelte +22 -1
- package/dist/components/chart/TimeseriesChart.svelte.d.ts +4 -1
- package/dist/components/dialog/Dialog.svelte +1 -1
- package/dist/components/radio/Radio.svelte +1 -1
- package/dist/components/radio/Radio.svelte.d.ts +1 -1
- package/dist/components/radio/RadioGroup.svelte +38 -9
- package/dist/components/radio/RadioGroup.svelte.d.ts +27 -6
- package/dist/components/radio/RadioItem.svelte +7 -5
- package/dist/components/radio/RadioItem.svelte.d.ts +25 -4
- package/dist/components/radio/RadioTypedValueTestHost.svelte +14 -0
- package/dist/components/radio/RadioTypedValueTestHost.svelte.d.ts +3 -0
- package/dist/components/radio/index.d.ts +2 -0
- package/dist/components/radio/radio.test.d.ts +1 -0
- package/dist/components/radio/radio.test.js +11 -0
- package/dist/components/sidebar/SidebarContent.svelte +1 -1
- package/dist/components/sidebar/SidebarGroupLabel.svelte +1 -1
- package/dist/components/toolbar/Toolbar.svelte +68 -0
- package/dist/components/toolbar/Toolbar.svelte.d.ts +12 -0
- package/dist/components/toolbar/ToolbarButton.svelte +46 -0
- package/dist/components/toolbar/ToolbarButton.svelte.d.ts +14 -0
- package/dist/components/toolbar/ToolbarInput.svelte +18 -0
- package/dist/components/toolbar/ToolbarInput.svelte.d.ts +9 -0
- package/dist/components/toolbar/ToolbarInputGroup.svelte +20 -0
- package/dist/components/toolbar/ToolbarInputGroup.svelte.d.ts +9 -0
- package/dist/components/toolbar/ToolbarTestHost.svelte +36 -0
- package/dist/components/toolbar/ToolbarTestHost.svelte.d.ts +18 -0
- package/dist/components/toolbar/context.d.ts +30 -0
- package/dist/components/toolbar/context.js +35 -0
- package/dist/components/toolbar/index.d.ts +16 -0
- package/dist/components/toolbar/index.js +12 -0
- package/dist/components/toolbar/toolbar.test.d.ts +1 -0
- package/dist/components/toolbar/toolbar.test.js +58 -0
- package/dist/docs/HomeGrid.svelte +28 -0
- package/dist/docs/MdxPage.svelte +7 -3
- package/dist/docs/PropsTable.svelte +3 -1
- package/dist/docs/PropsTable.svelte.d.ts +1 -0
- package/dist/docs/demo-snippets/BadgeColorVariantsDemo.svelte +1 -0
- package/dist/docs/demo-snippets/CategoricalColorsDemo.svelte +4 -4
- package/dist/docs/demo-snippets/CategoricalCvdDemo.svelte +4 -4
- package/dist/docs/demo-snippets/ChartColorSystemsDemo.svelte +2 -2
- package/dist/docs/demo-snippets/DialogMaxWidthDemo.svelte +14 -0
- package/dist/docs/demo-snippets/DialogMaxWidthDemo.svelte.d.ts +18 -0
- package/dist/docs/demo-snippets/DialogWithSelectDemo.svelte +21 -5
- package/dist/docs/demo-snippets/LegendHighlightDemo.svelte +105 -0
- package/dist/docs/demo-snippets/LegendHighlightDemo.svelte.d.ts +3 -0
- package/dist/docs/demo-snippets/LegendOnClickDemo.svelte +118 -0
- package/dist/docs/demo-snippets/LegendOnClickDemo.svelte.d.ts +3 -0
- package/dist/docs/demo-snippets/RadioTypedValueDemo.svelte +26 -0
- package/dist/docs/demo-snippets/RadioTypedValueDemo.svelte.d.ts +3 -0
- package/dist/docs/demo-snippets/SemanticColorsDemo.svelte +4 -4
- package/dist/docs/demo-snippets/SequentialColorsDemo.svelte +3 -3
- package/dist/docs/demo-snippets/ToolbarActionsDemo.svelte +9 -0
- package/dist/docs/demo-snippets/ToolbarActionsDemo.svelte.d.ts +18 -0
- package/dist/docs/demo-snippets/ToolbarDemo.svelte +15 -0
- package/dist/docs/demo-snippets/ToolbarDemo.svelte.d.ts +18 -0
- package/dist/docs/demo-snippets/ToolbarInputGroupDemo.svelte +11 -0
- package/dist/docs/demo-snippets/ToolbarInputGroupDemo.svelte.d.ts +18 -0
- package/dist/docs/demo-snippets/ToolbarLabelsDemo.svelte +9 -0
- package/dist/docs/demo-snippets/ToolbarLabelsDemo.svelte.d.ts +18 -0
- package/dist/docs/demo-snippets/ToolbarMixedControlsDemo.svelte +10 -0
- package/dist/docs/demo-snippets/ToolbarMixedControlsDemo.svelte.d.ts +18 -0
- package/dist/docs/demo-snippets/ToolbarSizesDemo.svelte +17 -0
- package/dist/docs/demo-snippets/ToolbarSizesDemo.svelte.d.ts +18 -0
- package/dist/docs/nav.js +1 -0
- package/dist/docs/props-data/ChartLegend.js +50 -26
- package/dist/docs/props-data/Radio.js +1 -1
- package/dist/docs/props-data/Radio__Group.js +3 -3
- package/dist/docs/props-data/Radio__Item.js +1 -1
- package/dist/docs/props-data/TimeseriesChart.js +106 -99
- package/dist/docs/props-data/Toolbar.d.ts +20 -0
- package/dist/docs/props-data/Toolbar.js +19 -0
- package/dist/docs/props-data/Toolbar__Button.d.ts +6 -0
- package/dist/docs/props-data/Toolbar__Button.js +27 -0
- package/dist/docs/props-data/Toolbar__Input.d.ts +6 -0
- package/dist/docs/props-data/Toolbar__Input.js +17 -0
- package/dist/docs/props-data/Toolbar__InputGroup.d.ts +12 -0
- package/dist/docs/props-data/Toolbar__InputGroup.js +13 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/styles.css +2 -2
- package/package.json +16 -16
- package/src/lib/components/button/Button.svelte +52 -15
- package/src/lib/components/chart/ChartLegend.svelte +46 -3
- package/src/lib/components/chart/TimeseriesChart.svelte +22 -1
- package/src/lib/components/dialog/Dialog.svelte +1 -1
- package/src/lib/components/radio/Radio.svelte +1 -1
- package/src/lib/components/radio/RadioGroup.svelte +38 -9
- package/src/lib/components/radio/RadioItem.svelte +7 -5
- package/src/lib/components/radio/RadioTypedValueTestHost.svelte +14 -0
- package/src/lib/components/radio/index.ts +7 -1
- package/src/lib/components/radio/radio.test.ts +14 -0
- package/src/lib/components/sidebar/SidebarContent.svelte +1 -1
- package/src/lib/components/sidebar/SidebarGroupLabel.svelte +1 -1
- package/src/lib/components/toolbar/Toolbar.svelte +68 -0
- package/src/lib/components/toolbar/ToolbarButton.svelte +46 -0
- package/src/lib/components/toolbar/ToolbarInput.svelte +18 -0
- package/src/lib/components/toolbar/ToolbarInputGroup.svelte +20 -0
- package/src/lib/components/toolbar/ToolbarTestHost.svelte +36 -0
- package/src/lib/components/toolbar/context.ts +54 -0
- package/src/lib/components/toolbar/index.ts +34 -0
- package/src/lib/components/toolbar/toolbar.test.ts +80 -0
- package/src/lib/docs/HomeGrid.svelte +28 -0
- package/src/lib/docs/MdxPage.svelte +7 -3
- package/src/lib/docs/PropsTable.svelte +3 -1
- package/src/lib/docs/demo-snippets/BadgeColorVariantsDemo.svelte +1 -0
- package/src/lib/docs/demo-snippets/CategoricalColorsDemo.svelte +4 -4
- package/src/lib/docs/demo-snippets/CategoricalCvdDemo.svelte +4 -4
- package/src/lib/docs/demo-snippets/ChartColorSystemsDemo.svelte +2 -2
- package/src/lib/docs/demo-snippets/DialogMaxWidthDemo.svelte +14 -0
- package/src/lib/docs/demo-snippets/DialogWithSelectDemo.svelte +21 -5
- package/src/lib/docs/demo-snippets/LegendHighlightDemo.svelte +105 -0
- package/src/lib/docs/demo-snippets/LegendOnClickDemo.svelte +118 -0
- package/src/lib/docs/demo-snippets/RadioTypedValueDemo.svelte +26 -0
- package/src/lib/docs/demo-snippets/SemanticColorsDemo.svelte +4 -4
- package/src/lib/docs/demo-snippets/SequentialColorsDemo.svelte +3 -3
- package/src/lib/docs/demo-snippets/ToolbarActionsDemo.svelte +9 -0
- package/src/lib/docs/demo-snippets/ToolbarDemo.svelte +15 -0
- package/src/lib/docs/demo-snippets/ToolbarInputGroupDemo.svelte +11 -0
- package/src/lib/docs/demo-snippets/ToolbarLabelsDemo.svelte +9 -0
- package/src/lib/docs/demo-snippets/ToolbarMixedControlsDemo.svelte +10 -0
- package/src/lib/docs/demo-snippets/ToolbarSizesDemo.svelte +17 -0
- package/src/lib/docs/nav.ts +1 -0
- package/src/lib/docs/props-data/ChartLegend.ts +55 -26
- package/src/lib/docs/props-data/Radio.ts +1 -1
- package/src/lib/docs/props-data/Radio__Group.ts +3 -3
- package/src/lib/docs/props-data/Radio__Item.ts +1 -1
- package/src/lib/docs/props-data/TimeseriesChart.ts +118 -99
- package/src/lib/docs/props-data/Toolbar.ts +19 -0
- package/src/lib/docs/props-data/Toolbar__Button.ts +27 -0
- package/src/lib/docs/props-data/Toolbar__Input.ts +17 -0
- package/src/lib/docs/props-data/Toolbar__InputGroup.ts +13 -0
- package/src/lib/index.ts +97 -14
- package/src/lib/styles.css +9 -5
- package/src/routes/charts/colors/+page.md +1 -0
- package/src/routes/charts/timeseries/+page.md +43 -21
- package/src/routes/components/dialog/+page.md +6 -0
- package/src/routes/components/radio/+page.md +7 -0
- package/src/routes/components/toolbar/+page.md +133 -0
- package/src/blocks/delete-resource/delete-resource.svelte.d.ts +0 -32
- package/src/blocks/delete-resource/index.d.ts +0 -2
- package/src/blocks/page-header/index.d.ts +0 -2
- package/src/blocks/page-header/page-header.svelte.d.ts +0 -46
- package/src/blocks/resource-list/index.d.ts +0 -1
- package/src/blocks/resource-list/resource-list.svelte.d.ts +0 -13
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts" generics="Value = string">
|
|
2
2
|
import { RadioGroup as RadioGroupPrimitive } from 'bits-ui';
|
|
3
3
|
import { setContext } from 'svelte';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
import { cn } from '../../utils/cn';
|
|
6
6
|
import type { RadioAppearance, RadioControlPosition } from './Radio.svelte';
|
|
7
7
|
|
|
8
|
-
interface Props {
|
|
8
|
+
export interface Props<Value = string> {
|
|
9
9
|
children?: Snippet;
|
|
10
10
|
legend?: string;
|
|
11
11
|
orientation?: 'vertical' | 'horizontal';
|
|
12
12
|
appearance?: RadioAppearance;
|
|
13
13
|
error?: string;
|
|
14
14
|
description?: string | Snippet;
|
|
15
|
-
value?:
|
|
16
|
-
defaultValue?:
|
|
15
|
+
value?: Value;
|
|
16
|
+
defaultValue?: Value;
|
|
17
17
|
disabled?: boolean;
|
|
18
18
|
required?: boolean;
|
|
19
19
|
controlPosition?: RadioControlPosition;
|
|
20
20
|
name?: string;
|
|
21
21
|
class?: string;
|
|
22
|
-
onValueChange?: (value:
|
|
22
|
+
onValueChange?: (value: Value, eventDetails?: unknown) => void;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
let {
|
|
@@ -30,14 +30,16 @@
|
|
|
30
30
|
error,
|
|
31
31
|
description,
|
|
32
32
|
defaultValue,
|
|
33
|
-
value = $bindable(defaultValue
|
|
33
|
+
value = $bindable(defaultValue),
|
|
34
34
|
disabled = false,
|
|
35
35
|
required,
|
|
36
36
|
controlPosition,
|
|
37
37
|
name,
|
|
38
38
|
class: className,
|
|
39
39
|
onValueChange
|
|
40
|
-
}: Props = $props();
|
|
40
|
+
}: Props<Value> = $props();
|
|
41
|
+
|
|
42
|
+
const serializedValues = new Map<string, unknown>();
|
|
41
43
|
|
|
42
44
|
$effect(() => {
|
|
43
45
|
if (value === undefined && defaultValue !== undefined) {
|
|
@@ -45,17 +47,44 @@
|
|
|
45
47
|
}
|
|
46
48
|
});
|
|
47
49
|
|
|
50
|
+
function serializeValue(itemValue: unknown) {
|
|
51
|
+
if (typeof itemValue === 'string') return itemValue;
|
|
52
|
+
|
|
53
|
+
const serialized = `kumo-radio:${typeof itemValue}:${String(itemValue)}`;
|
|
54
|
+
serializedValues.set(serialized, itemValue);
|
|
55
|
+
return serialized;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function deserializeValue(serializedValue: string) {
|
|
59
|
+
return serializedValues.has(serializedValue) ? serializedValues.get(serializedValue) : serializedValue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const primitiveValue = $derived(value === undefined ? undefined : serializeValue(value));
|
|
63
|
+
function handleValueChange(nextValue: string, eventDetails?: unknown) {
|
|
64
|
+
const deserializedValue = deserializeValue(nextValue) as Value;
|
|
65
|
+
value = deserializedValue;
|
|
66
|
+
onValueChange?.(deserializedValue, eventDetails);
|
|
67
|
+
}
|
|
68
|
+
|
|
48
69
|
setContext('kumo-radio-group', {
|
|
49
70
|
get controlPosition() {
|
|
50
71
|
return controlPosition;
|
|
51
72
|
},
|
|
52
73
|
get appearance() {
|
|
53
74
|
return appearance;
|
|
54
|
-
}
|
|
75
|
+
},
|
|
76
|
+
serializeValue
|
|
55
77
|
});
|
|
56
78
|
</script>
|
|
57
79
|
|
|
58
|
-
<RadioGroupPrimitive.Root
|
|
80
|
+
<RadioGroupPrimitive.Root
|
|
81
|
+
value={primitiveValue}
|
|
82
|
+
{orientation}
|
|
83
|
+
{disabled}
|
|
84
|
+
{required}
|
|
85
|
+
{name}
|
|
86
|
+
onValueChange={handleValueChange}
|
|
87
|
+
>
|
|
59
88
|
<fieldset class={cn('flex flex-col gap-4', className)} {disabled}>
|
|
60
89
|
{#if legend}
|
|
61
90
|
<legend class="text-base font-medium text-kumo-default">
|
|
@@ -1,21 +1,42 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { RadioAppearance, RadioControlPosition } from './Radio.svelte';
|
|
3
|
-
interface Props {
|
|
3
|
+
export interface Props<Value = string> {
|
|
4
4
|
children?: Snippet;
|
|
5
5
|
legend?: string;
|
|
6
6
|
orientation?: 'vertical' | 'horizontal';
|
|
7
7
|
appearance?: RadioAppearance;
|
|
8
8
|
error?: string;
|
|
9
9
|
description?: string | Snippet;
|
|
10
|
-
value?:
|
|
11
|
-
defaultValue?:
|
|
10
|
+
value?: Value;
|
|
11
|
+
defaultValue?: Value;
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
required?: boolean;
|
|
14
14
|
controlPosition?: RadioControlPosition;
|
|
15
15
|
name?: string;
|
|
16
16
|
class?: string;
|
|
17
|
-
onValueChange?: (value:
|
|
17
|
+
onValueChange?: (value: Value, eventDetails?: unknown) => void;
|
|
18
18
|
}
|
|
19
|
-
declare
|
|
20
|
-
|
|
19
|
+
declare function $$render<Value = string>(): {
|
|
20
|
+
props: Props<Value>;
|
|
21
|
+
exports: {};
|
|
22
|
+
bindings: "value";
|
|
23
|
+
slots: {};
|
|
24
|
+
events: {};
|
|
25
|
+
};
|
|
26
|
+
declare class __sveltets_Render<Value = string> {
|
|
27
|
+
props(): ReturnType<typeof $$render<Value>>['props'];
|
|
28
|
+
events(): ReturnType<typeof $$render<Value>>['events'];
|
|
29
|
+
slots(): ReturnType<typeof $$render<Value>>['slots'];
|
|
30
|
+
bindings(): "value";
|
|
31
|
+
exports(): {};
|
|
32
|
+
}
|
|
33
|
+
interface $$IsomorphicComponent {
|
|
34
|
+
new <Value = string>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Value>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Value>['props']>, ReturnType<__sveltets_Render<Value>['events']>, ReturnType<__sveltets_Render<Value>['slots']>> & {
|
|
35
|
+
$$bindings?: ReturnType<__sveltets_Render<Value>['bindings']>;
|
|
36
|
+
} & ReturnType<__sveltets_Render<Value>['exports']>;
|
|
37
|
+
<Value = string>(internal: unknown, props: ReturnType<__sveltets_Render<Value>['props']> & {}): ReturnType<__sveltets_Render<Value>['exports']>;
|
|
38
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
39
|
+
}
|
|
40
|
+
declare const RadioGroup: $$IsomorphicComponent;
|
|
41
|
+
type RadioGroup<Value = string> = InstanceType<typeof RadioGroup<Value>>;
|
|
21
42
|
export default RadioGroup;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts" generics="Value = unknown">
|
|
2
2
|
import { RadioGroup as RadioGroupPrimitive } from 'bits-ui';
|
|
3
3
|
import { getContext } from 'svelte';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
interface RadioGroupContext {
|
|
9
9
|
readonly controlPosition: RadioControlPosition | undefined;
|
|
10
10
|
readonly appearance: RadioAppearance;
|
|
11
|
+
serializeValue: (value: unknown) => string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
interface Props {
|
|
14
|
+
export interface Props<Value = unknown> {
|
|
14
15
|
children?: Snippet;
|
|
15
16
|
class?: string;
|
|
16
17
|
disabled?: boolean;
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
appearance?: RadioAppearance;
|
|
19
20
|
label: string | Snippet;
|
|
20
21
|
description?: string | Snippet;
|
|
21
|
-
value:
|
|
22
|
+
value: Value;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
let {
|
|
@@ -30,18 +31,19 @@
|
|
|
30
31
|
label,
|
|
31
32
|
description,
|
|
32
33
|
value
|
|
33
|
-
}: Props = $props();
|
|
34
|
+
}: Props<Value> = $props();
|
|
34
35
|
|
|
35
36
|
const group = getContext<RadioGroupContext | undefined>('kumo-radio-group');
|
|
36
37
|
const appearance = $derived(appearanceProp ?? group?.appearance ?? 'default');
|
|
37
38
|
const isCard = $derived(appearance === 'card');
|
|
38
39
|
const effectiveControlPosition = $derived(group?.controlPosition ?? (isCard ? 'end' : 'start'));
|
|
39
40
|
const controlAtStart = $derived(effectiveControlPosition === 'start');
|
|
41
|
+
const primitiveValue = $derived(group?.serializeValue(value) ?? (typeof value === 'string' ? value : String(value)));
|
|
40
42
|
</script>
|
|
41
43
|
|
|
42
44
|
{#snippet control()}
|
|
43
45
|
<RadioGroupPrimitive.Item
|
|
44
|
-
{
|
|
46
|
+
value={primitiveValue}
|
|
45
47
|
{disabled}
|
|
46
48
|
data-kumo-component="Radio"
|
|
47
49
|
data-kumo-part="item"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { RadioAppearance, RadioVariant } from './Radio.svelte';
|
|
3
|
-
interface Props {
|
|
3
|
+
export interface Props<Value = unknown> {
|
|
4
4
|
children?: Snippet;
|
|
5
5
|
class?: string;
|
|
6
6
|
disabled?: boolean;
|
|
@@ -8,8 +8,29 @@ interface Props {
|
|
|
8
8
|
appearance?: RadioAppearance;
|
|
9
9
|
label: string | Snippet;
|
|
10
10
|
description?: string | Snippet;
|
|
11
|
-
value:
|
|
11
|
+
value: Value;
|
|
12
12
|
}
|
|
13
|
-
declare
|
|
14
|
-
|
|
13
|
+
declare function $$render<Value = unknown>(): {
|
|
14
|
+
props: Props<Value>;
|
|
15
|
+
exports: {};
|
|
16
|
+
bindings: "";
|
|
17
|
+
slots: {};
|
|
18
|
+
events: {};
|
|
19
|
+
};
|
|
20
|
+
declare class __sveltets_Render<Value = unknown> {
|
|
21
|
+
props(): ReturnType<typeof $$render<Value>>['props'];
|
|
22
|
+
events(): ReturnType<typeof $$render<Value>>['events'];
|
|
23
|
+
slots(): ReturnType<typeof $$render<Value>>['slots'];
|
|
24
|
+
bindings(): "";
|
|
25
|
+
exports(): {};
|
|
26
|
+
}
|
|
27
|
+
interface $$IsomorphicComponent {
|
|
28
|
+
new <Value = unknown>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Value>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Value>['props']>, ReturnType<__sveltets_Render<Value>['events']>, ReturnType<__sveltets_Render<Value>['slots']>> & {
|
|
29
|
+
$$bindings?: ReturnType<__sveltets_Render<Value>['bindings']>;
|
|
30
|
+
} & ReturnType<__sveltets_Render<Value>['exports']>;
|
|
31
|
+
<Value = unknown>(internal: unknown, props: ReturnType<__sveltets_Render<Value>['props']> & {}): ReturnType<__sveltets_Render<Value>['exports']>;
|
|
32
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
33
|
+
}
|
|
34
|
+
declare const RadioItem: $$IsomorphicComponent;
|
|
35
|
+
type RadioItem<Value = unknown> = InstanceType<typeof RadioItem<Value>>;
|
|
15
36
|
export default RadioItem;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import RadioGroup from './RadioGroup.svelte';
|
|
3
|
+
import RadioItem from './RadioItem.svelte';
|
|
4
|
+
|
|
5
|
+
let pageSize = $state<number>(10);
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<RadioGroup legend="Items per page" bind:value={pageSize}>
|
|
9
|
+
<RadioItem label="10" value={10} />
|
|
10
|
+
<RadioItem label="25" value={25} />
|
|
11
|
+
<RadioItem label="50" value={50} />
|
|
12
|
+
</RadioGroup>
|
|
13
|
+
|
|
14
|
+
<output aria-label="Selected page size">{pageSize}</output>
|
|
@@ -9,3 +9,5 @@ export declare const Radio: typeof RadioRoot & {
|
|
|
9
9
|
};
|
|
10
10
|
export { RadioGroup, RadioItem, RadioLegend };
|
|
11
11
|
export type { RadioAppearance, RadioControlPosition, RadioVariant } from './Radio.svelte';
|
|
12
|
+
export type { Props as RadioGroupProps } from './RadioGroup.svelte';
|
|
13
|
+
export type { Props as RadioItemProps } from './RadioItem.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/svelte';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import RadioTypedValueTestHost from './RadioTypedValueTestHost.svelte';
|
|
5
|
+
describe('Radio', () => {
|
|
6
|
+
it('round-trips non-string values through the radio group', async () => {
|
|
7
|
+
render(RadioTypedValueTestHost);
|
|
8
|
+
await fireEvent.click(screen.getByLabelText('25'));
|
|
9
|
+
expect(screen.getByLabelText('Selected page size').textContent).toBe('25');
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<div
|
|
9
9
|
data-sidebar="content"
|
|
10
10
|
class={cn(
|
|
11
|
-
'relative min-w-0 flex-1 overflow-y-auto overflow-x-hidden px-[11px] py-3 transition-[padding] duration-(--sidebar-animation-duration) group-not-data-[state=collapsed]/sidebar:px-3.5
|
|
11
|
+
'relative min-w-0 flex-1 overflow-y-auto overflow-x-hidden! px-[11px] py-3 transition-[padding] duration-(--sidebar-animation-duration) group-not-data-[state=collapsed]/sidebar:px-3.5',
|
|
12
12
|
'group-data-[mobile=true]/sidebar:px-3.5',
|
|
13
13
|
className
|
|
14
14
|
)}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
{...rest}
|
|
16
16
|
>
|
|
17
17
|
<div class="min-h-0 min-w-0">
|
|
18
|
-
<div class="truncate px-3 mt-
|
|
18
|
+
<div class="truncate px-3 mt-4 mb-2 text-sm font-medium text-kumo-subtle [[data-sidebar=group]:first-child_&]:mt-2">
|
|
19
19
|
{@render children?.()}
|
|
20
20
|
</div>
|
|
21
21
|
</div>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export {
|
|
3
|
+
KUMO_TOOLBAR_DEFAULT_VARIANTS,
|
|
4
|
+
KUMO_TOOLBAR_VARIANTS,
|
|
5
|
+
type ToolbarSize
|
|
6
|
+
} from './context';
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import type { Snippet } from 'svelte';
|
|
11
|
+
import { cn } from '../../utils/cn';
|
|
12
|
+
import {
|
|
13
|
+
KUMO_TOOLBAR_DEFAULT_VARIANTS,
|
|
14
|
+
KUMO_TOOLBAR_VARIANTS,
|
|
15
|
+
setToolbarContext,
|
|
16
|
+
type ToolbarSize
|
|
17
|
+
} from './context';
|
|
18
|
+
|
|
19
|
+
export interface Props {
|
|
20
|
+
children?: Snippet;
|
|
21
|
+
class?: string;
|
|
22
|
+
size?: ToolbarSize;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let {
|
|
27
|
+
children,
|
|
28
|
+
class: className,
|
|
29
|
+
size = KUMO_TOOLBAR_DEFAULT_VARIANTS.size,
|
|
30
|
+
...rest
|
|
31
|
+
}: Props = $props();
|
|
32
|
+
|
|
33
|
+
setToolbarContext({
|
|
34
|
+
get size() {
|
|
35
|
+
return size;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
40
|
+
if (event.key !== 'ArrowRight' && event.key !== 'ArrowLeft') return;
|
|
41
|
+
const root = event.currentTarget as HTMLElement;
|
|
42
|
+
const controls = Array.from(
|
|
43
|
+
root.querySelectorAll<HTMLElement>(
|
|
44
|
+
'button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
45
|
+
)
|
|
46
|
+
).filter((element) => !element.hasAttribute('aria-hidden'));
|
|
47
|
+
const index = controls.indexOf(event.target as HTMLElement);
|
|
48
|
+
if (index === -1) return;
|
|
49
|
+
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
const direction = event.key === 'ArrowRight' ? 1 : -1;
|
|
52
|
+
controls[(index + direction + controls.length) % controls.length]?.focus();
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<div
|
|
57
|
+
data-kumo-component="Toolbar"
|
|
58
|
+
role="toolbar"
|
|
59
|
+
class={cn(
|
|
60
|
+
'inline-flex w-fit items-stretch rounded-lg bg-kumo-control shadow-xs ring ring-kumo-line',
|
|
61
|
+
KUMO_TOOLBAR_VARIANTS.size[size].classes,
|
|
62
|
+
className
|
|
63
|
+
)}
|
|
64
|
+
onkeydown={handleKeydown}
|
|
65
|
+
{...rest}
|
|
66
|
+
>
|
|
67
|
+
{@render children?.()}
|
|
68
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { KUMO_TOOLBAR_DEFAULT_VARIANTS, KUMO_TOOLBAR_VARIANTS, type ToolbarSize } from './context';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { type ToolbarSize } from './context';
|
|
4
|
+
export interface Props {
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
class?: string;
|
|
7
|
+
size?: ToolbarSize;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
declare const Toolbar: import("svelte").Component<Props, {}, "">;
|
|
11
|
+
type Toolbar = ReturnType<typeof Toolbar>;
|
|
12
|
+
export default Toolbar;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
|
+
import Button from '../button/Button.svelte';
|
|
4
|
+
import { getToolbarContext, toolbarControlClassName } from './context';
|
|
5
|
+
|
|
6
|
+
export interface Props {
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
class?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
icon?: Component;
|
|
12
|
+
shape?: 'base' | 'square' | 'circle';
|
|
13
|
+
type?: 'button' | 'submit' | 'reset';
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
children,
|
|
19
|
+
class: className,
|
|
20
|
+
disabled = false,
|
|
21
|
+
loading = false,
|
|
22
|
+
icon,
|
|
23
|
+
shape,
|
|
24
|
+
type = 'button',
|
|
25
|
+
...rest
|
|
26
|
+
}: Props = $props();
|
|
27
|
+
|
|
28
|
+
const toolbar = getToolbarContext();
|
|
29
|
+
const size = $derived(toolbar?.size ?? 'base');
|
|
30
|
+
const resolvedShape = $derived(shape ?? (!children && icon ? 'square' : 'base'));
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<Button
|
|
34
|
+
class={toolbarControlClassName(className)}
|
|
35
|
+
{disabled}
|
|
36
|
+
{icon}
|
|
37
|
+
{loading}
|
|
38
|
+
shape={resolvedShape}
|
|
39
|
+
{size}
|
|
40
|
+
{type}
|
|
41
|
+
variant="ghost"
|
|
42
|
+
componentName="Toolbar.Button"
|
|
43
|
+
{...rest}
|
|
44
|
+
>
|
|
45
|
+
{@render children?.()}
|
|
46
|
+
</Button>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Component, Snippet } from 'svelte';
|
|
2
|
+
export interface Props {
|
|
3
|
+
children?: Snippet;
|
|
4
|
+
class?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
icon?: Component;
|
|
8
|
+
shape?: 'base' | 'square' | 'circle';
|
|
9
|
+
type?: 'button' | 'submit' | 'reset';
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
declare const ToolbarButton: Component<Props, {}, "">;
|
|
13
|
+
type ToolbarButton = ReturnType<typeof ToolbarButton>;
|
|
14
|
+
export default ToolbarButton;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Input from '../input/Input.svelte';
|
|
3
|
+
import { getToolbarContext, toolbarControlClassName } from './context';
|
|
4
|
+
|
|
5
|
+
export interface Props {
|
|
6
|
+
class?: string;
|
|
7
|
+
value?: string | number;
|
|
8
|
+
onValueChange?: (value: string) => void;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { class: className, value = $bindable(''), onValueChange, ...rest }: Props = $props();
|
|
13
|
+
|
|
14
|
+
const toolbar = getToolbarContext();
|
|
15
|
+
const size = $derived(toolbar?.size ?? 'base');
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<Input bind:value {onValueChange} class={toolbarControlClassName(className)} {size} {...rest} />
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface Props {
|
|
2
|
+
class?: string;
|
|
3
|
+
value?: string | number;
|
|
4
|
+
onValueChange?: (value: string) => void;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
declare const ToolbarInput: import("svelte").Component<Props, {}, "value">;
|
|
8
|
+
type ToolbarInput = ReturnType<typeof ToolbarInput>;
|
|
9
|
+
export default ToolbarInput;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { InputGroup } from '../input-group';
|
|
4
|
+
import { getToolbarContext, toolbarControlClassName } from './context';
|
|
5
|
+
|
|
6
|
+
export interface Props {
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
class?: string;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { children, class: className, ...rest }: Props = $props();
|
|
13
|
+
|
|
14
|
+
const toolbar = getToolbarContext();
|
|
15
|
+
const size = $derived(toolbar?.size ?? 'base');
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<InputGroup class={toolbarControlClassName(className)} {size} {...rest}>
|
|
19
|
+
{@render children?.()}
|
|
20
|
+
</InputGroup>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface Props {
|
|
3
|
+
children?: Snippet;
|
|
4
|
+
class?: string;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
declare const ToolbarInputGroup: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type ToolbarInputGroup = ReturnType<typeof ToolbarInputGroup>;
|
|
9
|
+
export default ToolbarInputGroup;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Input } from '../input';
|
|
3
|
+
import { InputGroup } from '../input-group';
|
|
4
|
+
import { Toolbar } from './index';
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<Toolbar size="sm">
|
|
8
|
+
<Toolbar.Input aria-label="Toolbar input" />
|
|
9
|
+
<Input aria-label="Direct input" size="lg" />
|
|
10
|
+
</Toolbar>
|
|
11
|
+
|
|
12
|
+
<Toolbar size="sm">
|
|
13
|
+
<Toolbar.InputGroup aria-label="Hostname">
|
|
14
|
+
<InputGroup.Input placeholder="example" aria-label="Hostname" />
|
|
15
|
+
<InputGroup.Suffix>.workers.dev</InputGroup.Suffix>
|
|
16
|
+
</Toolbar.InputGroup>
|
|
17
|
+
<InputGroup>
|
|
18
|
+
<InputGroup.Input placeholder="plain" aria-label="Plain" />
|
|
19
|
+
</InputGroup>
|
|
20
|
+
</Toolbar>
|
|
21
|
+
|
|
22
|
+
<Toolbar>
|
|
23
|
+
<Toolbar.InputGroup aria-label="Search DNS records">
|
|
24
|
+
<InputGroup.Input placeholder="Search DNS records" />
|
|
25
|
+
</Toolbar.InputGroup>
|
|
26
|
+
<Toolbar.Button aria-label="Filter">Filter</Toolbar.Button>
|
|
27
|
+
<Toolbar.Button aria-label="Settings">Settings</Toolbar.Button>
|
|
28
|
+
</Toolbar>
|
|
29
|
+
|
|
30
|
+
<Toolbar>
|
|
31
|
+
<Toolbar.InputGroup aria-label="Worker subdomain">
|
|
32
|
+
<InputGroup.Input placeholder="my-worker" />
|
|
33
|
+
<InputGroup.Suffix>.workers.dev</InputGroup.Suffix>
|
|
34
|
+
</Toolbar.InputGroup>
|
|
35
|
+
<Toolbar.Button>Visit</Toolbar.Button>
|
|
36
|
+
</Toolbar>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
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> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const ToolbarTestHost: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type ToolbarTestHost = InstanceType<typeof ToolbarTestHost>;
|
|
18
|
+
export default ToolbarTestHost;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const KUMO_TOOLBAR_VARIANTS: {
|
|
2
|
+
readonly size: {
|
|
3
|
+
readonly xs: {
|
|
4
|
+
readonly classes: "text-xs";
|
|
5
|
+
readonly description: "Extra small toolbar for compact UIs";
|
|
6
|
+
};
|
|
7
|
+
readonly sm: {
|
|
8
|
+
readonly classes: "text-xs";
|
|
9
|
+
readonly description: "Small toolbar for secondary controls";
|
|
10
|
+
};
|
|
11
|
+
readonly base: {
|
|
12
|
+
readonly classes: "text-base";
|
|
13
|
+
readonly description: "Default toolbar size";
|
|
14
|
+
};
|
|
15
|
+
readonly lg: {
|
|
16
|
+
readonly classes: "text-base";
|
|
17
|
+
readonly description: "Large toolbar for prominent controls";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const KUMO_TOOLBAR_DEFAULT_VARIANTS: {
|
|
22
|
+
readonly size: "base";
|
|
23
|
+
};
|
|
24
|
+
export type ToolbarSize = keyof typeof KUMO_TOOLBAR_VARIANTS.size;
|
|
25
|
+
export interface ToolbarContextValue {
|
|
26
|
+
size: ToolbarSize;
|
|
27
|
+
}
|
|
28
|
+
export declare function setToolbarContext(context: ToolbarContextValue): void;
|
|
29
|
+
export declare function getToolbarContext(): ToolbarContextValue | undefined;
|
|
30
|
+
export declare function toolbarControlClassName(className?: string): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
export const KUMO_TOOLBAR_VARIANTS = {
|
|
4
|
+
size: {
|
|
5
|
+
xs: {
|
|
6
|
+
classes: 'text-xs',
|
|
7
|
+
description: 'Extra small toolbar for compact UIs'
|
|
8
|
+
},
|
|
9
|
+
sm: {
|
|
10
|
+
classes: 'text-xs',
|
|
11
|
+
description: 'Small toolbar for secondary controls'
|
|
12
|
+
},
|
|
13
|
+
base: {
|
|
14
|
+
classes: 'text-base',
|
|
15
|
+
description: 'Default toolbar size'
|
|
16
|
+
},
|
|
17
|
+
lg: {
|
|
18
|
+
classes: 'text-base',
|
|
19
|
+
description: 'Large toolbar for prominent controls'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export const KUMO_TOOLBAR_DEFAULT_VARIANTS = {
|
|
24
|
+
size: 'base'
|
|
25
|
+
};
|
|
26
|
+
const TOOLBAR_CONTEXT = 'kumo-toolbar';
|
|
27
|
+
export function setToolbarContext(context) {
|
|
28
|
+
setContext(TOOLBAR_CONTEXT, context);
|
|
29
|
+
}
|
|
30
|
+
export function getToolbarContext() {
|
|
31
|
+
return getContext(TOOLBAR_CONTEXT);
|
|
32
|
+
}
|
|
33
|
+
export function toolbarControlClassName(className) {
|
|
34
|
+
return cn('relative min-w-0 border-0 bg-transparent shadow-none ring-0 focus:z-2 focus-within:z-2 focus-visible:z-2', 'rounded-none first:rounded-l-lg last:rounded-r-lg only:rounded-lg', 'not-first:border-l not-first:border-kumo-line', 'focus:ring-kumo-focus/50 focus:ring-[1.5px] focus-visible:ring-2 focus-visible:ring-kumo-brand', 'focus-within:ring-kumo-focus/50 focus-within:ring-[1.5px]', className);
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Root from './Toolbar.svelte';
|
|
2
|
+
import Button from './ToolbarButton.svelte';
|
|
3
|
+
import Input from './ToolbarInput.svelte';
|
|
4
|
+
import InputGroup from './ToolbarInputGroup.svelte';
|
|
5
|
+
declare const Toolbar: typeof Root & {
|
|
6
|
+
Root: typeof Root;
|
|
7
|
+
Button: typeof Button;
|
|
8
|
+
Input: typeof Input;
|
|
9
|
+
InputGroup: typeof InputGroup;
|
|
10
|
+
};
|
|
11
|
+
export { Toolbar, Root as ToolbarRoot, Button as ToolbarButton, Input as ToolbarInput, InputGroup as ToolbarInputGroup };
|
|
12
|
+
export { KUMO_TOOLBAR_DEFAULT_VARIANTS, KUMO_TOOLBAR_VARIANTS, type ToolbarSize } from './context';
|
|
13
|
+
export type { Props as ToolbarProps } from './Toolbar.svelte';
|
|
14
|
+
export type { Props as ToolbarButtonProps } from './ToolbarButton.svelte';
|
|
15
|
+
export type { Props as ToolbarInputProps } from './ToolbarInput.svelte';
|
|
16
|
+
export type { Props as ToolbarInputGroupProps } from './ToolbarInputGroup.svelte';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Root from './Toolbar.svelte';
|
|
2
|
+
import Button from './ToolbarButton.svelte';
|
|
3
|
+
import Input from './ToolbarInput.svelte';
|
|
4
|
+
import InputGroup from './ToolbarInputGroup.svelte';
|
|
5
|
+
const Toolbar = Object.assign(Root, {
|
|
6
|
+
Root,
|
|
7
|
+
Button,
|
|
8
|
+
Input,
|
|
9
|
+
InputGroup
|
|
10
|
+
});
|
|
11
|
+
export { Toolbar, Root as ToolbarRoot, Button as ToolbarButton, Input as ToolbarInput, InputGroup as ToolbarInputGroup };
|
|
12
|
+
export { KUMO_TOOLBAR_DEFAULT_VARIANTS, KUMO_TOOLBAR_VARIANTS } from './context';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|