@kirana-ui/solid 0.1.0 → 0.2.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/dom/accordion.js +9 -6
- package/dom/agent.js +3 -0
- package/dom/autocomplete.js +2 -0
- package/dom/autosize.js +19 -0
- package/dom/avatar.js +3 -3
- package/dom/button.js +1 -1
- package/dom/calendar.js +145 -0
- package/dom/carousel.js +83 -0
- package/dom/checkbox.js +5 -4
- package/dom/collapsible.js +3 -3
- package/dom/combobox.js +289 -0
- package/dom/command.js +129 -0
- package/dom/context-menu.js +2 -0
- package/dom/date-field.js +90 -0
- package/dom/date-picker.js +103 -0
- package/dom/dialog.js +32 -1
- package/dom/drawer.js +2 -0
- package/dom/field.js +3 -3
- package/dom/fieldset.js +2 -2
- package/dom/form.js +1 -1
- package/dom/hover-popup.js +19 -4
- package/dom/index.js +26 -1
- package/dom/input.js +26 -0
- package/dom/label.js +18 -0
- package/dom/listbox.js +114 -0
- package/dom/menu.js +261 -0
- package/dom/menubar-context.js +3 -0
- package/dom/menubar.js +33 -0
- package/dom/message-scroller.js +56 -0
- package/dom/navigation-menu.js +147 -0
- package/dom/number-field.js +82 -0
- package/dom/otp.js +95 -0
- package/dom/pagination.js +74 -0
- package/dom/popover.js +22 -7
- package/dom/qr-code.js +48 -0
- package/dom/radio-group.js +6 -5
- package/dom/resizable.js +65 -0
- package/dom/runtime.js +59 -9
- package/dom/scroll-area.js +99 -0
- package/dom/select.js +91 -15
- package/dom/separator.js +1 -1
- package/dom/slider.js +11 -8
- package/dom/switch.js +5 -4
- package/dom/tabs.js +5 -5
- package/dom/testing.js +3 -0
- package/dom/toast.js +150 -0
- package/dom/toggle-group.js +37 -0
- package/dom/toggle.js +12 -4
- package/dom/toolbar-context.js +5 -0
- package/dom/toolbar.js +71 -0
- package/dom/value-bar.js +3 -3
- package/llms.txt +3202 -0
- package/package.json +236 -2
- package/server/accordion.js +9 -6
- package/server/agent.js +3 -0
- package/server/autocomplete.js +2 -0
- package/server/autosize.js +19 -0
- package/server/avatar.js +3 -3
- package/server/button.js +1 -1
- package/server/calendar.js +144 -0
- package/server/carousel.js +83 -0
- package/server/checkbox.js +5 -4
- package/server/collapsible.js +3 -3
- package/server/combobox.js +289 -0
- package/server/command.js +129 -0
- package/server/context-menu.js +2 -0
- package/server/date-field.js +90 -0
- package/server/date-picker.js +103 -0
- package/server/dialog.js +32 -1
- package/server/drawer.js +2 -0
- package/server/field.js +3 -3
- package/server/fieldset.js +2 -2
- package/server/form.js +1 -1
- package/server/hover-popup.js +19 -4
- package/server/index.js +26 -1
- package/server/input.js +26 -0
- package/server/label.js +18 -0
- package/server/listbox.js +114 -0
- package/server/menu.js +261 -0
- package/server/menubar-context.js +3 -0
- package/server/menubar.js +33 -0
- package/server/message-scroller.js +56 -0
- package/server/navigation-menu.js +147 -0
- package/server/number-field.js +81 -0
- package/server/otp.js +94 -0
- package/server/pagination.js +74 -0
- package/server/popover.js +22 -7
- package/server/qr-code.js +48 -0
- package/server/radio-group.js +6 -5
- package/server/resizable.js +65 -0
- package/server/runtime.js +58 -8
- package/server/scroll-area.js +99 -0
- package/server/select.js +91 -15
- package/server/separator.js +1 -1
- package/server/slider.js +11 -8
- package/server/switch.js +5 -4
- package/server/tabs.js +5 -5
- package/server/testing.js +3 -0
- package/server/toast.js +150 -0
- package/server/toggle-group.js +37 -0
- package/server/toggle.js +12 -4
- package/server/toolbar-context.js +5 -0
- package/server/toolbar.js +71 -0
- package/server/value-bar.js +3 -3
- package/skills/kirana-ui-primitives/SKILL.md +142 -0
- package/src/accordion.jsx +10 -7
- package/src/agent.js +3 -0
- package/src/autocomplete.jsx +2 -0
- package/src/autosize.jsx +8 -0
- package/src/avatar.jsx +3 -3
- package/src/button.jsx +1 -1
- package/src/calendar.jsx +108 -0
- package/src/carousel.jsx +51 -0
- package/src/checkbox.jsx +5 -3
- package/src/collapsible.jsx +3 -3
- package/src/combobox.jsx +187 -0
- package/src/command.jsx +81 -0
- package/src/context-menu.js +2 -0
- package/src/date-field.jsx +71 -0
- package/src/date-picker.jsx +72 -0
- package/src/dialog.jsx +27 -1
- package/src/drawer.js +2 -0
- package/src/field.jsx +3 -3
- package/src/fieldset.jsx +2 -2
- package/src/form.jsx +1 -1
- package/src/hover-popup.jsx +12 -4
- package/src/index.js +26 -1
- package/src/input.jsx +17 -0
- package/src/label.jsx +9 -0
- package/src/listbox.jsx +81 -0
- package/src/menu.jsx +164 -0
- package/src/menubar-context.js +3 -0
- package/src/menubar.jsx +21 -0
- package/src/message-scroller.jsx +27 -0
- package/src/navigation-menu.jsx +96 -0
- package/src/number-field.jsx +75 -0
- package/src/otp.jsx +73 -0
- package/src/pagination.jsx +60 -0
- package/src/popover.jsx +22 -4
- package/src/qr-code.jsx +25 -0
- package/src/radio-group.jsx +7 -5
- package/src/resizable.jsx +46 -0
- package/src/runtime.jsx +54 -9
- package/src/scroll-area.jsx +53 -0
- package/src/select.jsx +72 -14
- package/src/separator.jsx +1 -1
- package/src/slider.jsx +13 -8
- package/src/switch.jsx +5 -3
- package/src/tabs.jsx +6 -6
- package/src/testing.js +3 -0
- package/src/toast.jsx +86 -0
- package/src/toggle-group.jsx +32 -0
- package/src/toggle.jsx +9 -3
- package/src/toolbar-context.js +5 -0
- package/src/toolbar.jsx +43 -0
- package/src/value-bar.jsx +3 -3
- package/types/accordion.d.ts +21 -19
- package/types/agent.d.ts +1 -0
- package/types/alert-dialog.d.ts +1 -0
- package/types/autocomplete.d.ts +2 -0
- package/types/autosize.d.ts +11 -0
- package/types/avatar.d.ts +12 -5
- package/types/button.d.ts +4 -2
- package/types/calendar.d.ts +57 -0
- package/types/carousel.d.ts +34 -0
- package/types/checkbox.d.ts +10 -6
- package/types/collapsible.d.ts +11 -7
- package/types/combobox.d.ts +105 -0
- package/types/command.d.ts +55 -0
- package/types/context-menu.d.ts +2 -0
- package/types/date-field.d.ts +34 -0
- package/types/date-picker.d.ts +40 -0
- package/types/dialog.d.ts +52 -20
- package/types/direction.d.ts +1 -0
- package/types/drawer.d.ts +2 -0
- package/types/field.d.ts +19 -11
- package/types/fieldset.d.ts +8 -3
- package/types/form.d.ts +5 -2
- package/types/hover-card.d.ts +16 -7
- package/types/hover-popup.d.ts +23 -10
- package/types/index.d.ts +39 -2
- package/types/input.d.ts +13 -0
- package/types/label.d.ts +7 -0
- package/types/listbox.d.ts +36 -0
- package/types/menu.d.ts +105 -0
- package/types/menubar-context.d.ts +3 -0
- package/types/menubar.d.ts +12 -0
- package/types/message-scroller.d.ts +22 -0
- package/types/meter.d.ts +16 -7
- package/types/navigation-menu.d.ts +50 -0
- package/types/number-field.d.ts +22 -0
- package/types/otp.d.ts +39 -0
- package/types/pagination.d.ts +31 -0
- package/types/popover.d.ts +41 -13
- package/types/progress.d.ts +16 -7
- package/types/qr-code.d.ts +20 -0
- package/types/radio-group.d.ts +15 -16
- package/types/resizable.d.ts +29 -0
- package/types/runtime.d.ts +53 -11
- package/types/scroll-area.d.ts +28 -0
- package/types/select.d.ts +66 -33
- package/types/separator.d.ts +5 -3
- package/types/slider.d.ts +25 -13
- package/types/switch.d.ts +8 -4
- package/types/tabs.d.ts +20 -16
- package/types/testing.d.ts +1 -0
- package/types/toast.d.ts +57 -0
- package/types/toggle-group.d.ts +9 -0
- package/types/toggle.d.ts +6 -3
- package/types/toolbar-context.d.ts +6 -0
- package/types/toolbar.d.ts +28 -0
- package/types/tooltip.d.ts +16 -7
- package/types/value-bar.d.ts +21 -10
package/src/slider.jsx
CHANGED
|
@@ -11,6 +11,7 @@ function useSlider() {
|
|
|
11
11
|
throw new Error("A Slider part must be inside <Slider.Root>");
|
|
12
12
|
return made;
|
|
13
13
|
}
|
|
14
|
+
// Given neither `value` nor `defaultValue`, a slider has one thumb: its value is a number.
|
|
14
15
|
function Root(props) {
|
|
15
16
|
const [local, rest] = splitProps(props, [
|
|
16
17
|
"value",
|
|
@@ -22,9 +23,11 @@ function Root(props) {
|
|
|
22
23
|
"step",
|
|
23
24
|
"largeStep",
|
|
24
25
|
"minStepsBetweenValues",
|
|
26
|
+
"thumbAlignment",
|
|
25
27
|
"orientation",
|
|
26
28
|
"disabled",
|
|
27
29
|
"name",
|
|
30
|
+
"form",
|
|
28
31
|
"format",
|
|
29
32
|
"locale",
|
|
30
33
|
"getAriaValueText",
|
|
@@ -32,25 +35,27 @@ function Root(props) {
|
|
|
32
35
|
]);
|
|
33
36
|
const generated = createUniqueId();
|
|
34
37
|
const field = useContext(FieldContext);
|
|
35
|
-
const made = controller(within(createSlider, { field, direction: useContext(DirectionContext) }), () => ({
|
|
38
|
+
const made = controller(within((createSlider), { field, direction: useContext(DirectionContext) }), () => ({
|
|
36
39
|
...local,
|
|
37
40
|
id: local.id ?? generated,
|
|
38
41
|
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
39
42
|
onValueCommitted: (value, details) => local.onValueCommitted?.(value, details),
|
|
40
43
|
}));
|
|
41
44
|
return (<Context.Provider value={made}>
|
|
42
|
-
<Part
|
|
45
|
+
<Part of={made.root} tag="div" {...rest}/>
|
|
43
46
|
</Context.Provider>);
|
|
44
47
|
}
|
|
45
48
|
/** `index` is which value of a range the thumb is, from 0. */
|
|
46
49
|
function Thumb(props) {
|
|
47
50
|
const [local, rest] = splitProps(props, ["index", "children"]);
|
|
48
|
-
// A thumb is its index for as long as it is in the page.
|
|
49
|
-
|
|
51
|
+
// A thumb is its index for as long as it is in the page. Given none, it takes its place
|
|
52
|
+
// among the slider's thumbs, in the order they are written.
|
|
53
|
+
const generated = createUniqueId();
|
|
54
|
+
const index = untrack(() => local.index ?? generated);
|
|
50
55
|
const slider = useSlider();
|
|
51
|
-
return (<Part
|
|
56
|
+
return (<Part of={slider.thumb(index)} tag="div" {...rest}>
|
|
52
57
|
{local.children}
|
|
53
|
-
<Part
|
|
58
|
+
<Part of={slider.thumbInput(index)} tag="input"/>
|
|
54
59
|
</Part>);
|
|
55
60
|
}
|
|
56
61
|
/** The written value, or what its child, a function, makes of it and of the values. */
|
|
@@ -59,11 +64,11 @@ function Value(props) {
|
|
|
59
64
|
const made = useSlider();
|
|
60
65
|
const text = fromSignal(made.text);
|
|
61
66
|
const values = fromSignal(made.values);
|
|
62
|
-
return (<Part
|
|
67
|
+
return (<Part of={made.value} tag="output" {...rest}>
|
|
63
68
|
{local.children ? local.children(text, values) : text()}
|
|
64
69
|
</Part>);
|
|
65
70
|
}
|
|
66
|
-
const part = (key) => (props) =>
|
|
71
|
+
const part = (key) => (props) => <Part of={useSlider()[key]} tag="div" {...props}/>;
|
|
67
72
|
export const Slider = {
|
|
68
73
|
Root,
|
|
69
74
|
Value,
|
package/src/switch.jsx
CHANGED
|
@@ -19,6 +19,7 @@ function Root(props) {
|
|
|
19
19
|
"readOnly",
|
|
20
20
|
"required",
|
|
21
21
|
"name",
|
|
22
|
+
"form",
|
|
22
23
|
"value",
|
|
23
24
|
"id",
|
|
24
25
|
"children",
|
|
@@ -33,15 +34,16 @@ function Root(props) {
|
|
|
33
34
|
readOnly: local.readOnly,
|
|
34
35
|
required: local.required,
|
|
35
36
|
name: local.name,
|
|
37
|
+
form: local.form,
|
|
36
38
|
value: local.value,
|
|
37
39
|
onCheckedChange: (checked, details) => local.onCheckedChange?.(checked, details),
|
|
38
40
|
}));
|
|
39
41
|
return (<Context.Provider value={made}>
|
|
40
|
-
<Part
|
|
42
|
+
<Part of={made.root} tag="span" {...rest}>
|
|
41
43
|
{local.children}
|
|
42
|
-
<Part
|
|
44
|
+
<Part of={made.input} tag="input"/>
|
|
43
45
|
</Part>
|
|
44
46
|
</Context.Provider>);
|
|
45
47
|
}
|
|
46
|
-
const Thumb = (props) => <Part
|
|
48
|
+
const Thumb = (props) => <Part of={useSwitch().thumb} tag="span" {...props}/>;
|
|
47
49
|
export const Switch = { Root, Thumb };
|
package/src/tabs.jsx
CHANGED
|
@@ -20,7 +20,7 @@ function Root(props) {
|
|
|
20
20
|
]);
|
|
21
21
|
const generated = createUniqueId();
|
|
22
22
|
const direction = useContext(DirectionContext);
|
|
23
|
-
const made = controller(within(createTabs, { direction }), () => ({
|
|
23
|
+
const made = controller(within((createTabs), { direction }), () => ({
|
|
24
24
|
id: local.id ?? generated,
|
|
25
25
|
value: local.value,
|
|
26
26
|
defaultValue: local.defaultValue,
|
|
@@ -28,23 +28,23 @@ function Root(props) {
|
|
|
28
28
|
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
29
29
|
}));
|
|
30
30
|
return (<Context.Provider value={made}>
|
|
31
|
-
<Part
|
|
31
|
+
<Part of={made.root} tag="div" {...rest}/>
|
|
32
32
|
</Context.Provider>);
|
|
33
33
|
}
|
|
34
34
|
function List(props) {
|
|
35
35
|
const [local, rest] = splitProps(props, ["activateOnFocus", "loop"]);
|
|
36
36
|
const made = useTabs();
|
|
37
37
|
createComputed(() => made.listOptions.set(defined({ ...local })));
|
|
38
|
-
return <Part
|
|
38
|
+
return <Part of={made.list} tag="div" {...rest}/>;
|
|
39
39
|
}
|
|
40
40
|
function Tab(props) {
|
|
41
41
|
const [local, rest] = splitProps(props, ["value", "disabled"]);
|
|
42
42
|
const options = toSignal(() => ({ disabled: local.disabled }));
|
|
43
43
|
// A tab is its value for as long as it is in the page.
|
|
44
44
|
const part = useTabs().tab(untrack(() => local.value), () => defined(options.get()));
|
|
45
|
-
return <Part
|
|
45
|
+
return <Part of={part} tag="button" {...rest}/>;
|
|
46
46
|
}
|
|
47
|
-
const Indicator = (props) =>
|
|
47
|
+
const Indicator = (props) => <Part of={useTabs().indicator} tag="span" {...props}/>;
|
|
48
48
|
/** `keepMounted` keeps the panel in the page, `hidden`, while its tab is not the active one. */
|
|
49
49
|
function Panel(props) {
|
|
50
50
|
const [local, rest] = splitProps(props, ["value", "keepMounted"]);
|
|
@@ -52,7 +52,7 @@ function Panel(props) {
|
|
|
52
52
|
onMount(() => onCleanup(panel.mount()));
|
|
53
53
|
const mounted = fromSignal(panel.mounted);
|
|
54
54
|
return (<Show when={mounted() || local.keepMounted}>
|
|
55
|
-
<Part
|
|
55
|
+
<Part of={panel.part} tag="div" {...rest}/>
|
|
56
56
|
</Show>);
|
|
57
57
|
}
|
|
58
58
|
export const Tabs = { Root, List, Tab, Indicator, Panel };
|
package/src/testing.js
ADDED
package/src/toast.jsx
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createToast, createToaster as createCoreToaster } from "@kirana-ui/core/toast";
|
|
2
|
+
import { For, Show, createContext, createMemo, createUniqueId, splitProps, useContext, } from "solid-js";
|
|
3
|
+
import { Part, controller, fromSignal } from "./runtime.jsx";
|
|
4
|
+
/**
|
|
5
|
+
* The toasts of a page, made once, in a module: `toaster.add({ title })` from anywhere. A
|
|
6
|
+
* title, a description and an action's label are anything Solid draws, unless `Content` says
|
|
7
|
+
* otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export const createToaster = createCoreToaster;
|
|
10
|
+
const Context = createContext();
|
|
11
|
+
const ToastContext = createContext();
|
|
12
|
+
function useToast() {
|
|
13
|
+
const made = useContext(Context);
|
|
14
|
+
if (!made)
|
|
15
|
+
throw new Error("A Toast part must be inside <Toast.Viewport>");
|
|
16
|
+
return made;
|
|
17
|
+
}
|
|
18
|
+
function useParts() {
|
|
19
|
+
const parts = useContext(ToastContext);
|
|
20
|
+
if (!parts)
|
|
21
|
+
throw new Error("A toast's part must be inside <Toast.Root>");
|
|
22
|
+
return parts;
|
|
23
|
+
}
|
|
24
|
+
/** Where a toaster's toasts are drawn. Always in the page: put it once, near the root. */
|
|
25
|
+
function Viewport(props) {
|
|
26
|
+
const [local, rest] = splitProps(props, ["toaster", "label", "hotkey", "swipeDirection", "id"]);
|
|
27
|
+
const generated = createUniqueId();
|
|
28
|
+
const made = controller(createToast, () => ({
|
|
29
|
+
id: local.id ?? generated,
|
|
30
|
+
toaster: local.toaster,
|
|
31
|
+
label: local.label,
|
|
32
|
+
hotkey: local.hotkey,
|
|
33
|
+
swipeDirection: local.swipeDirection,
|
|
34
|
+
}));
|
|
35
|
+
return (<Context.Provider value={made}>
|
|
36
|
+
<Part of={made.viewport} tag="div" {...rest}/>
|
|
37
|
+
</Context.Provider>);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Draws its child once for each toast, the newest first. The child is given the toast as an
|
|
41
|
+
* accessor: one that changes is the same toast, drawn again where it stands.
|
|
42
|
+
*/
|
|
43
|
+
function List(props) {
|
|
44
|
+
const toasts = fromSignal(useToast().toasts);
|
|
45
|
+
const ids = createMemo(() => toasts().map((each) => each.id), undefined, {
|
|
46
|
+
equals: (a, b) => a.length === b.length && a.every((each, at) => each === b[at]),
|
|
47
|
+
});
|
|
48
|
+
return (<For each={ids()}>{(id) => props.children(() => toasts().find((each) => each.id === id))}</For>);
|
|
49
|
+
}
|
|
50
|
+
function Root(props) {
|
|
51
|
+
const [local, rest] = splitProps(props, ["toast"]);
|
|
52
|
+
// A root is its toast for as long as it is in the page.
|
|
53
|
+
const parts = useToast().toast(local.toast.id);
|
|
54
|
+
return (<ToastContext.Provider value={parts}>
|
|
55
|
+
<Part of={parts.root} tag="div" {...rest}/>
|
|
56
|
+
</ToastContext.Provider>);
|
|
57
|
+
}
|
|
58
|
+
const Content = (props) => <Part of={useParts().content} tag="div" {...props}/>;
|
|
59
|
+
/**
|
|
60
|
+
* A part that says something of the toast's: the caller's children when it has any, what the
|
|
61
|
+
* toast was added with otherwise, and nothing in the page when there is neither.
|
|
62
|
+
*/
|
|
63
|
+
function Said(props) {
|
|
64
|
+
const [local, rest] = splitProps(props, ["said", "tag", "children"]);
|
|
65
|
+
const parts = useParts();
|
|
66
|
+
const toast = fromSignal(parts.record);
|
|
67
|
+
const children = createMemo(() => local.children ?? (local.said === "action" ? toast()?.action?.label : toast()?.[local.said]));
|
|
68
|
+
return (
|
|
69
|
+
// A `render` draws what it likes; without one, an element with nothing to say is not drawn.
|
|
70
|
+
<Show when={children() != null || rest.render}>
|
|
71
|
+
<Part of={parts[local.said]} tag={local.tag} {...rest}>
|
|
72
|
+
{children()}
|
|
73
|
+
</Part>
|
|
74
|
+
</Show>);
|
|
75
|
+
}
|
|
76
|
+
/** The toast's title, unless it is given children of its own. */
|
|
77
|
+
const Title = (props) => <Said said="title" tag="div" {...props}/>;
|
|
78
|
+
/** The toast's description, unless it is given children of its own. */
|
|
79
|
+
const Description = (props) => <Said said="description" tag="div" {...props}/>;
|
|
80
|
+
const Close = (props) => <Part of={useParts().close} tag="button" {...props}/>;
|
|
81
|
+
/**
|
|
82
|
+
* The toast's action, its label unless it is given children of its own. A press tells the
|
|
83
|
+
* action (`onAction`), then closes the toast unless the action called `details.cancel()`.
|
|
84
|
+
*/
|
|
85
|
+
const Action = (props) => <Said said="action" tag="button" {...props}/>;
|
|
86
|
+
export const Toast = { Viewport, List, Root, Content, Title, Description, Close, Action };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { within } from "@kirana-ui/core";
|
|
2
|
+
import { createToggleGroup } from "@kirana-ui/core/toggle-group";
|
|
3
|
+
import { splitProps, useContext } from "solid-js";
|
|
4
|
+
import { DirectionContext } from "./direction-context.js";
|
|
5
|
+
import { Part, controller } from "./runtime.jsx";
|
|
6
|
+
import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
|
|
7
|
+
/** Toggles that are one control. Each `<Toggle value>` inside it is one of its toggles. */
|
|
8
|
+
export function ToggleGroup(props) {
|
|
9
|
+
const [local, rest] = splitProps(props, [
|
|
10
|
+
"value",
|
|
11
|
+
"defaultValue",
|
|
12
|
+
"onValueChange",
|
|
13
|
+
"multiple",
|
|
14
|
+
"disabled",
|
|
15
|
+
"orientation",
|
|
16
|
+
"loop",
|
|
17
|
+
]);
|
|
18
|
+
const direction = useContext(DirectionContext);
|
|
19
|
+
const toolbar = useContext(ToolbarContext) ?? undefined;
|
|
20
|
+
const made = controller(within((createToggleGroup), { direction, toolbar }), () => ({
|
|
21
|
+
value: local.value,
|
|
22
|
+
defaultValue: local.defaultValue,
|
|
23
|
+
multiple: local.multiple,
|
|
24
|
+
disabled: local.disabled,
|
|
25
|
+
orientation: local.orientation,
|
|
26
|
+
loop: local.loop,
|
|
27
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
28
|
+
}));
|
|
29
|
+
return (<ToggleGroupContext.Provider value={made}>
|
|
30
|
+
<Part of={made.root} tag="div" {...rest}/>
|
|
31
|
+
</ToggleGroupContext.Provider>);
|
|
32
|
+
}
|
package/src/toggle.jsx
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
+
import { within } from "@kirana-ui/core";
|
|
1
2
|
import { createToggle } from "@kirana-ui/core/toggle";
|
|
2
|
-
import { splitProps } from "solid-js";
|
|
3
|
+
import { splitProps, useContext } from "solid-js";
|
|
3
4
|
import { Part, controller } from "./runtime.jsx";
|
|
5
|
+
import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
|
|
4
6
|
export function Toggle(props) {
|
|
5
7
|
const [local, rest] = splitProps(props, [
|
|
6
8
|
"pressed",
|
|
7
9
|
"defaultPressed",
|
|
8
10
|
"onPressedChange",
|
|
9
11
|
"disabled",
|
|
12
|
+
"value",
|
|
10
13
|
]);
|
|
11
|
-
const
|
|
14
|
+
const group = useContext(ToggleGroupContext) ?? undefined;
|
|
15
|
+
const toolbar = useContext(ToolbarContext) ?? undefined;
|
|
16
|
+
const made = controller(within(createToggle, { group, toolbar }), () => ({
|
|
12
17
|
pressed: local.pressed,
|
|
13
18
|
defaultPressed: local.defaultPressed,
|
|
14
19
|
disabled: local.disabled,
|
|
20
|
+
value: local.value,
|
|
15
21
|
onPressedChange: (pressed, details) => local.onPressedChange?.(pressed, details),
|
|
16
22
|
}));
|
|
17
|
-
return <Part
|
|
23
|
+
return <Part of={made.root} tag="button" {...rest}/>;
|
|
18
24
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createContext } from "solid-js";
|
|
2
|
+
/** The toolbar a control is an item of, if it is in one. */
|
|
3
|
+
export const ToolbarContext = createContext(null);
|
|
4
|
+
/** The group a toggle is one of the toggles of, if it is in one. */
|
|
5
|
+
export const ToggleGroupContext = createContext(null);
|
package/src/toolbar.jsx
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defined, within } from "@kirana-ui/core";
|
|
2
|
+
import { createToolbar } from "@kirana-ui/core/toolbar";
|
|
3
|
+
import { splitProps, useContext } from "solid-js";
|
|
4
|
+
import { DirectionContext } from "./direction-context.js";
|
|
5
|
+
import { Part, controller, toSignal } from "./runtime.jsx";
|
|
6
|
+
import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
|
|
7
|
+
function useToolbar() {
|
|
8
|
+
const made = useContext(ToolbarContext);
|
|
9
|
+
if (!made)
|
|
10
|
+
throw new Error("A Toolbar part must be inside <Toolbar.Root>");
|
|
11
|
+
return made;
|
|
12
|
+
}
|
|
13
|
+
function Root(props) {
|
|
14
|
+
const [local, rest] = splitProps(props, ["orientation", "loop", "disabled"]);
|
|
15
|
+
const direction = useContext(DirectionContext);
|
|
16
|
+
const made = controller(within(createToolbar, { direction }), () => ({
|
|
17
|
+
orientation: local.orientation,
|
|
18
|
+
loop: local.loop,
|
|
19
|
+
disabled: local.disabled,
|
|
20
|
+
}));
|
|
21
|
+
return (<ToolbarContext.Provider value={made}>
|
|
22
|
+
{/* A toggle group around the toolbar is not the group of the toolbar's toggles. */}
|
|
23
|
+
<ToggleGroupContext.Provider value={null}>
|
|
24
|
+
<Part of={made.root} tag="div" {...rest}/>
|
|
25
|
+
</ToggleGroupContext.Provider>
|
|
26
|
+
</ToolbarContext.Provider>);
|
|
27
|
+
}
|
|
28
|
+
const item = (name, tag) => (props) => {
|
|
29
|
+
const [local, rest] = splitProps(props, ["disabled"]);
|
|
30
|
+
const options = toSignal(() => ({ disabled: local.disabled }));
|
|
31
|
+
const part = useToolbar()[name](() => defined(options.get()));
|
|
32
|
+
return <Part of={part} tag={tag} {...rest}/>;
|
|
33
|
+
};
|
|
34
|
+
const Link = (props) => <Part of={useToolbar().link()} tag="a" {...props}/>;
|
|
35
|
+
const Separator = (props) => (<Part of={useToolbar().separator} tag="div" {...props}/>);
|
|
36
|
+
export const Toolbar = {
|
|
37
|
+
Root,
|
|
38
|
+
Button: item("button", "button"),
|
|
39
|
+
Link,
|
|
40
|
+
Input: item("input", "input"),
|
|
41
|
+
Group: item("group", "div"),
|
|
42
|
+
Separator,
|
|
43
|
+
};
|
package/src/value-bar.jsx
CHANGED
|
@@ -22,7 +22,7 @@ export function valueBar(name, create) {
|
|
|
22
22
|
const generated = createUniqueId();
|
|
23
23
|
const made = controller(create, () => ({ ...local, id: local.id ?? generated }));
|
|
24
24
|
return (<Context.Provider value={made}>
|
|
25
|
-
<Part
|
|
25
|
+
<Part of={made.root} tag="div" {...rest}/>
|
|
26
26
|
</Context.Provider>);
|
|
27
27
|
}
|
|
28
28
|
/** The written value, or what its child, a function, makes of it. */
|
|
@@ -30,11 +30,11 @@ export function valueBar(name, create) {
|
|
|
30
30
|
const [local, rest] = splitProps(props, ["children"]);
|
|
31
31
|
const made = use();
|
|
32
32
|
const text = fromSignal(made.text);
|
|
33
|
-
return (<Part
|
|
33
|
+
return (<Part of={made.value} tag="span" {...rest}>
|
|
34
34
|
{local.children ? local.children(text) : text()}
|
|
35
35
|
</Part>);
|
|
36
36
|
}
|
|
37
|
-
const part = (key, tag) => (props) =>
|
|
37
|
+
const part = (key, tag) => (props) => <Part of={use()[key]} tag={tag} {...props}/>;
|
|
38
38
|
return {
|
|
39
39
|
Root,
|
|
40
40
|
Value,
|
package/types/accordion.d.ts
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StateOf } from "@kirana-ui/core";
|
|
2
|
+
import type { AccordionProps } from "@kirana-ui/core/accordion";
|
|
3
|
+
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
2
4
|
import type { JSX } from "solid-js";
|
|
3
5
|
import type { PartComponentProps } from "./runtime.tsx";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
onValueChange?: (value: unknown[], details: ChangeDetails) => void;
|
|
8
|
-
multiple?: boolean;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
orientation?: Orientation;
|
|
11
|
-
loop?: boolean;
|
|
6
|
+
type Parts = Vocabulary["accordion"];
|
|
7
|
+
/** `Value` is what tells an item from the others: what the items' `value` and the root's hold. */
|
|
8
|
+
export type RootProps<Value = unknown> = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<AccordionProps<Value>, "id"> & {
|
|
12
9
|
id?: string;
|
|
13
|
-
}
|
|
14
|
-
declare function Root(props: RootProps): JSX.Element;
|
|
15
|
-
|
|
16
|
-
value
|
|
10
|
+
}>;
|
|
11
|
+
declare function Root<Value = unknown>(props: RootProps<Value>): JSX.Element;
|
|
12
|
+
export type ItemProps = PartComponentProps<"div", StateOf<Parts["item"]>, {
|
|
13
|
+
value?: unknown;
|
|
17
14
|
disabled?: boolean;
|
|
18
|
-
}
|
|
19
|
-
/** `
|
|
20
|
-
declare function
|
|
15
|
+
}>;
|
|
16
|
+
/** `value` tells this item from the others; an item that is given none makes its own. */
|
|
17
|
+
declare function Item(props: ItemProps): JSX.Element;
|
|
18
|
+
export type HeaderProps = PartComponentProps<"h3", StateOf<Parts["header"]>>;
|
|
19
|
+
export type TriggerProps = PartComponentProps<"button", StateOf<Parts["trigger"]>>;
|
|
20
|
+
export type PanelProps = PartComponentProps<"div", StateOf<Parts["panel"]>, {
|
|
21
21
|
keepMounted?: boolean;
|
|
22
|
-
}
|
|
22
|
+
}>;
|
|
23
|
+
/** `keepMounted` keeps the closed panel in the page, `hidden`. */
|
|
24
|
+
declare function Panel(props: PanelProps): JSX.Element;
|
|
23
25
|
export declare const Accordion: {
|
|
24
26
|
Root: typeof Root;
|
|
25
27
|
Item: typeof Item;
|
|
26
|
-
Header: (props:
|
|
27
|
-
Trigger: (props:
|
|
28
|
+
Header: (props: HeaderProps) => JSX.Element;
|
|
29
|
+
Trigger: (props: TriggerProps) => JSX.Element;
|
|
28
30
|
Panel: typeof Panel;
|
|
29
31
|
};
|
|
30
32
|
export {};
|
package/types/agent.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@kirana-ui/core/agent";
|
package/types/alert-dialog.d.ts
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { Autocomplete } from "./combobox.tsx";
|
|
2
|
+
export type { AutocompleteRootProps as RootProps, ClearProps, EmptyProps, GroupLabelProps, GroupProps, InputProps, ItemProps, ListProps, PopupProps, PortalProps, PositionerProps, SeparatorProps, TriggerProps, } from "./combobox.tsx";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StateOf } from "@kirana-ui/core";
|
|
2
|
+
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
3
|
+
import type { JSX } from "solid-js";
|
|
4
|
+
import type { PartComponentProps } from "./runtime.tsx";
|
|
5
|
+
export type TextareaProps = PartComponentProps<"textarea", StateOf<Vocabulary["autosize"]["textarea"]>>;
|
|
6
|
+
/** A `<textarea>` as tall as its text. It takes what a `<textarea>` takes. */
|
|
7
|
+
declare function Textarea(props: TextareaProps): JSX.Element;
|
|
8
|
+
export declare const Autosize: {
|
|
9
|
+
Textarea: typeof Textarea;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
package/types/avatar.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import type { StateOf } from "@kirana-ui/core";
|
|
2
|
+
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
1
3
|
import type { JSX } from "solid-js";
|
|
2
4
|
import type { PartComponentProps } from "./runtime.tsx";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare function
|
|
5
|
+
type Parts = Vocabulary["avatar"];
|
|
6
|
+
export type RootProps = PartComponentProps<"span", StateOf<Parts["root"]>>;
|
|
7
|
+
declare function Root(props: RootProps): JSX.Element;
|
|
8
|
+
export type ImageProps = PartComponentProps<"img", StateOf<Parts["image"]>, {
|
|
9
|
+
/** The picture's address: the element is in the page once it has loaded. */
|
|
6
10
|
src?: string;
|
|
7
|
-
}
|
|
11
|
+
}>;
|
|
12
|
+
/** The picture: in the page once `src` has loaded. */
|
|
13
|
+
declare function Image(props: ImageProps): JSX.Element;
|
|
14
|
+
export type FallbackProps = PartComponentProps<"span", StateOf<Parts["fallback"]>>;
|
|
8
15
|
/** What shows until the picture has loaded, or when it cannot. */
|
|
9
|
-
declare function Fallback(props:
|
|
16
|
+
declare function Fallback(props: FallbackProps): JSX.Element;
|
|
10
17
|
export declare const Avatar: {
|
|
11
18
|
Root: typeof Root;
|
|
12
19
|
Image: typeof Image;
|
package/types/button.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { StateOf } from "@kirana-ui/core";
|
|
2
|
+
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
1
3
|
import type { JSX } from "solid-js";
|
|
2
4
|
import type { PartComponentProps } from "./runtime.tsx";
|
|
3
|
-
export type ButtonProps = PartComponentProps
|
|
5
|
+
export type ButtonProps = PartComponentProps<"button", StateOf<Vocabulary["button"]["root"]>, {
|
|
4
6
|
disabled?: boolean;
|
|
5
7
|
focusableWhenDisabled?: boolean;
|
|
6
8
|
nativeButton?: boolean;
|
|
7
|
-
}
|
|
9
|
+
}>;
|
|
8
10
|
/** A `<button>`, or with `as` and `nativeButton={false}` another element that acts as one. */
|
|
9
11
|
export declare function Button(props: ButtonProps): JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { StateOf } from "@kirana-ui/core";
|
|
2
|
+
import type { Calendar as Controller, CalendarDay, CalendarProps, CalendarWeekday } from "@kirana-ui/core/calendar";
|
|
3
|
+
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
4
|
+
import type { JSX } from "solid-js";
|
|
5
|
+
import type { PartComponentProps } from "./runtime.tsx";
|
|
6
|
+
type Parts = Vocabulary["calendar"];
|
|
7
|
+
/**
|
|
8
|
+
* The calendar its parts are inside. Exported for a component that is made of one (a date picker
|
|
9
|
+
* provides its own to the calendar's parts).
|
|
10
|
+
*/
|
|
11
|
+
declare const Context: import("solid-js").Context<Controller | undefined>;
|
|
12
|
+
/** For a component made of this one's parts: a date picker. */
|
|
13
|
+
export { Context as CalendarContext };
|
|
14
|
+
export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<CalendarProps, "id"> & {
|
|
15
|
+
id?: string;
|
|
16
|
+
}>;
|
|
17
|
+
declare function Root(props: RootProps): JSX.Element;
|
|
18
|
+
export type HeadingProps = PartComponentProps<"div", StateOf<Parts["heading"]>>;
|
|
19
|
+
/** Names the month shown, unless it is given something else to say. */
|
|
20
|
+
declare function Heading(props: HeadingProps): JSX.Element;
|
|
21
|
+
export type PreviousProps = PartComponentProps<"button", StateOf<Parts["previous"]>>;
|
|
22
|
+
export type NextProps = PartComponentProps<"button", StateOf<Parts["next"]>>;
|
|
23
|
+
export type GridProps = PartComponentProps<"table", StateOf<Parts["grid"]>>;
|
|
24
|
+
export type WeekdaysProps = {
|
|
25
|
+
children: (weekday: CalendarWeekday) => JSX.Element;
|
|
26
|
+
};
|
|
27
|
+
/** Draws its child once for each day of the week, in the locale's order. */
|
|
28
|
+
declare function Weekdays(props: WeekdaysProps): JSX.Element;
|
|
29
|
+
export type WeeksProps = {
|
|
30
|
+
children: (week: readonly CalendarDay[]) => JSX.Element;
|
|
31
|
+
};
|
|
32
|
+
/** Draws its child once for each week of the month shown. */
|
|
33
|
+
declare function Weeks(props: WeeksProps): JSX.Element;
|
|
34
|
+
export type HeadCellProps = PartComponentProps<"th", StateOf<Parts["headCell"]>, {
|
|
35
|
+
weekday: CalendarWeekday;
|
|
36
|
+
}>;
|
|
37
|
+
declare function HeadCell(props: HeadCellProps): JSX.Element;
|
|
38
|
+
export type CellProps = PartComponentProps<"td", StateOf<Parts["cell"]>, {
|
|
39
|
+
date: string;
|
|
40
|
+
}>;
|
|
41
|
+
declare function Cell(props: CellProps): JSX.Element;
|
|
42
|
+
export type DayProps = PartComponentProps<"button", StateOf<Parts["day"]>, {
|
|
43
|
+
date: string;
|
|
44
|
+
}>;
|
|
45
|
+
declare function Day(props: DayProps): JSX.Element;
|
|
46
|
+
export declare const Calendar: {
|
|
47
|
+
Root: typeof Root;
|
|
48
|
+
Heading: typeof Heading;
|
|
49
|
+
Previous: (props: PreviousProps) => JSX.Element;
|
|
50
|
+
Next: (props: NextProps) => JSX.Element;
|
|
51
|
+
Grid: (props: GridProps) => JSX.Element;
|
|
52
|
+
Weekdays: typeof Weekdays;
|
|
53
|
+
HeadCell: typeof HeadCell;
|
|
54
|
+
Weeks: typeof Weeks;
|
|
55
|
+
Cell: typeof Cell;
|
|
56
|
+
Day: typeof Day;
|
|
57
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ChangeDetails, Orientation, StateOf } from "@kirana-ui/core";
|
|
2
|
+
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
3
|
+
import type { JSX } from "solid-js";
|
|
4
|
+
import type { PartComponentProps } from "./runtime.tsx";
|
|
5
|
+
type Parts = Vocabulary["carousel"];
|
|
6
|
+
export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, {
|
|
7
|
+
index?: number;
|
|
8
|
+
defaultIndex?: number;
|
|
9
|
+
onIndexChange?: (index: number, details: ChangeDetails) => void;
|
|
10
|
+
orientation?: Orientation;
|
|
11
|
+
loop?: boolean;
|
|
12
|
+
id?: string;
|
|
13
|
+
}>;
|
|
14
|
+
declare function Root(props: RootProps): JSX.Element;
|
|
15
|
+
export type ViewportProps = PartComponentProps<"div", StateOf<Parts["viewport"]>>;
|
|
16
|
+
export type ItemProps = PartComponentProps<"div", StateOf<Parts["item"]>, {
|
|
17
|
+
index: number;
|
|
18
|
+
}>;
|
|
19
|
+
export type PreviousProps = PartComponentProps<"button", StateOf<Parts["previous"]>>;
|
|
20
|
+
export type NextProps = PartComponentProps<"button", StateOf<Parts["next"]>>;
|
|
21
|
+
export type IndicatorProps = PartComponentProps<"button", StateOf<Parts["indicator"]>, {
|
|
22
|
+
index: number;
|
|
23
|
+
}>;
|
|
24
|
+
declare function Item(props: ItemProps): JSX.Element;
|
|
25
|
+
declare function Indicator(props: IndicatorProps): JSX.Element;
|
|
26
|
+
export declare const Carousel: {
|
|
27
|
+
Root: typeof Root;
|
|
28
|
+
Viewport: (props: ViewportProps) => JSX.Element;
|
|
29
|
+
Item: typeof Item;
|
|
30
|
+
Previous: (props: PreviousProps) => JSX.Element;
|
|
31
|
+
Next: (props: NextProps) => JSX.Element;
|
|
32
|
+
Indicator: typeof Indicator;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
package/types/checkbox.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { ChangeDetails } from "@kirana-ui/core";
|
|
1
|
+
import type { ChangeDetails, StateOf } from "@kirana-ui/core";
|
|
2
|
+
import type { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
2
3
|
import type { JSX } from "solid-js";
|
|
3
4
|
import type { PartComponentProps } from "./runtime.tsx";
|
|
4
|
-
|
|
5
|
+
type Parts = Vocabulary["checkbox"];
|
|
6
|
+
export type RootProps = PartComponentProps<"span", StateOf<Parts["root"]>, {
|
|
5
7
|
checked?: boolean;
|
|
6
8
|
defaultChecked?: boolean;
|
|
7
9
|
onCheckedChange?: (checked: boolean, details: ChangeDetails) => void;
|
|
@@ -10,14 +12,16 @@ export type RootProps = PartComponentProps & {
|
|
|
10
12
|
readOnly?: boolean;
|
|
11
13
|
required?: boolean;
|
|
12
14
|
name?: string;
|
|
15
|
+
form?: string;
|
|
13
16
|
value?: string;
|
|
14
17
|
id?: string;
|
|
15
|
-
}
|
|
18
|
+
}>;
|
|
16
19
|
declare function Root(props: RootProps): JSX.Element;
|
|
17
|
-
|
|
18
|
-
declare function Indicator(props: PartComponentProps & {
|
|
20
|
+
export type IndicatorProps = PartComponentProps<"span", StateOf<Parts["indicator"]>, {
|
|
19
21
|
keepMounted?: boolean;
|
|
20
|
-
}
|
|
22
|
+
}>;
|
|
23
|
+
/** `keepMounted` keeps the mark in the page while the box is unchecked. */
|
|
24
|
+
declare function Indicator(props: IndicatorProps): JSX.Element;
|
|
21
25
|
export declare const Checkbox: {
|
|
22
26
|
Root: typeof Root;
|
|
23
27
|
Indicator: typeof Indicator;
|