@kirana-ui/solid 0.1.1 → 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/dom/accordion.js +9 -6
- package/dom/agent.js +3 -0
- package/dom/autosize.js +1 -1
- package/dom/avatar.js +39 -14
- package/dom/button.js +1 -1
- package/dom/calendar.js +78 -19
- package/dom/carousel.js +6 -6
- package/dom/checkbox-group-context.js +3 -0
- package/dom/checkbox-group.js +38 -0
- package/dom/checkbox.js +9 -5
- package/dom/collapsible.js +3 -3
- package/dom/combobox.js +72 -14
- package/dom/command.js +10 -9
- package/dom/date-field.js +7 -3
- package/dom/date-picker.js +9 -3
- package/dom/dialog.js +13 -3
- package/dom/field.js +3 -3
- package/dom/fieldset.js +2 -2
- package/dom/form.js +1 -1
- package/dom/hover-popup.js +3 -3
- package/dom/index.js +1 -0
- package/dom/input.js +1 -1
- package/dom/label.js +1 -1
- package/dom/listbox.js +5 -5
- package/dom/menu.js +11 -11
- package/dom/menubar.js +1 -1
- package/dom/message-scroller.js +4 -4
- package/dom/navigation-menu.js +18 -21
- package/dom/number-field.js +39 -6
- package/dom/otp.js +6 -5
- package/dom/pagination.js +3 -3
- package/dom/popover.js +37 -8
- package/dom/primitive.js +92 -0
- package/dom/qr-code.js +3 -3
- package/dom/radio-group.js +7 -6
- package/dom/resizable.js +3 -3
- package/dom/runtime.js +23 -7
- package/dom/scroll-area.js +5 -5
- package/dom/select.js +26 -13
- package/dom/separator.js +1 -1
- package/dom/slider.js +11 -8
- package/dom/switch.js +3 -3
- package/dom/tabs.js +5 -5
- package/dom/testing.js +3 -0
- package/dom/toast.js +57 -20
- package/dom/toggle-group.js +1 -1
- package/dom/toggle.js +1 -1
- package/dom/toolbar.js +4 -4
- package/dom/value-bar.js +3 -3
- package/llms.txt +1846 -252
- package/package.json +34 -2
- package/server/accordion.js +9 -6
- package/server/agent.js +3 -0
- package/server/autosize.js +1 -1
- package/server/avatar.js +39 -14
- package/server/button.js +1 -1
- package/server/calendar.js +78 -19
- package/server/carousel.js +6 -6
- package/server/checkbox-group-context.js +3 -0
- package/server/checkbox-group.js +38 -0
- package/server/checkbox.js +9 -5
- package/server/collapsible.js +3 -3
- package/server/combobox.js +72 -14
- package/server/command.js +10 -9
- package/server/date-field.js +7 -3
- package/server/date-picker.js +9 -3
- package/server/dialog.js +13 -3
- package/server/field.js +3 -3
- package/server/fieldset.js +2 -2
- package/server/form.js +1 -1
- package/server/hover-popup.js +3 -3
- package/server/index.js +1 -0
- package/server/input.js +1 -1
- package/server/label.js +1 -1
- package/server/listbox.js +5 -5
- package/server/menu.js +11 -11
- package/server/menubar.js +1 -1
- package/server/message-scroller.js +4 -4
- package/server/navigation-menu.js +18 -15
- package/server/number-field.js +39 -6
- package/server/otp.js +6 -5
- package/server/pagination.js +3 -3
- package/server/popover.js +37 -8
- package/server/primitive.js +92 -0
- package/server/qr-code.js +3 -3
- package/server/radio-group.js +7 -6
- package/server/resizable.js +3 -3
- package/server/runtime.js +23 -7
- package/server/scroll-area.js +5 -5
- package/server/select.js +26 -13
- package/server/separator.js +1 -1
- package/server/slider.js +11 -8
- package/server/switch.js +3 -3
- package/server/tabs.js +5 -5
- package/server/testing.js +3 -0
- package/server/toast.js +57 -20
- package/server/toggle-group.js +1 -1
- package/server/toggle.js +1 -1
- package/server/toolbar.js +4 -4
- package/server/value-bar.js +3 -3
- package/skills/kirana-ui-primitives/SKILL.md +163 -0
- package/src/accordion.jsx +10 -7
- package/src/agent.js +3 -0
- package/src/autosize.jsx +1 -1
- package/src/avatar.jsx +17 -10
- package/src/button.jsx +1 -1
- package/src/calendar.jsx +72 -16
- package/src/carousel.jsx +6 -6
- package/src/checkbox-group-context.js +3 -0
- package/src/checkbox-group.jsx +33 -0
- package/src/checkbox.jsx +8 -4
- package/src/collapsible.jsx +3 -3
- package/src/combobox.jsx +70 -13
- package/src/command.jsx +10 -8
- package/src/date-field.jsx +7 -3
- package/src/date-picker.jsx +8 -2
- package/src/dialog.jsx +12 -2
- package/src/field.jsx +3 -3
- package/src/fieldset.jsx +2 -2
- package/src/form.jsx +1 -1
- package/src/hover-popup.jsx +3 -3
- package/src/index.js +1 -0
- package/src/input.jsx +1 -1
- package/src/label.jsx +1 -1
- package/src/listbox.jsx +6 -6
- package/src/menu.jsx +11 -11
- package/src/menubar.jsx +1 -1
- package/src/message-scroller.jsx +4 -4
- package/src/navigation-menu.jsx +14 -13
- package/src/number-field.jsx +26 -6
- package/src/otp.jsx +6 -4
- package/src/pagination.jsx +3 -3
- package/src/popover.jsx +35 -5
- package/src/primitive.jsx +81 -0
- package/src/qr-code.jsx +3 -3
- package/src/radio-group.jsx +7 -7
- package/src/resizable.jsx +3 -3
- package/src/runtime.jsx +21 -7
- package/src/scroll-area.jsx +5 -5
- package/src/select.jsx +29 -14
- package/src/separator.jsx +1 -1
- package/src/slider.jsx +12 -8
- package/src/switch.jsx +3 -3
- package/src/tabs.jsx +6 -6
- package/src/testing.js +3 -0
- package/src/toast.jsx +38 -10
- package/src/toggle-group.jsx +2 -2
- package/src/toggle.jsx +1 -1
- package/src/toolbar.jsx +4 -4
- 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 +1 -0
- package/types/autosize.d.ts +4 -1
- package/types/avatar.d.ts +14 -6
- package/types/button.d.ts +4 -2
- package/types/calendar.d.ts +48 -19
- package/types/carousel.d.ts +18 -10
- package/types/checkbox-group-context.d.ts +3 -0
- package/types/checkbox-group.d.ts +13 -0
- package/types/checkbox.d.ts +10 -6
- package/types/collapsible.d.ts +11 -7
- package/types/combobox.d.ts +102 -64
- package/types/command.d.ts +29 -17
- package/types/context-menu.d.ts +1 -0
- package/types/date-field.d.ts +20 -9
- package/types/date-picker.d.ts +26 -34
- package/types/dialog.d.ts +47 -31
- package/types/direction.d.ts +1 -0
- package/types/drawer.d.ts +1 -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 -10
- package/types/hover-popup.d.ts +23 -13
- package/types/index.d.ts +15 -1
- package/types/input.d.ts +4 -3
- package/types/label.d.ts +4 -1
- package/types/listbox.d.ts +18 -20
- package/types/menu.d.ts +56 -42
- package/types/menubar.d.ts +6 -4
- package/types/message-scroller.d.ts +12 -6
- package/types/meter.d.ts +16 -7
- package/types/navigation-menu.d.ts +35 -29
- package/types/number-field.d.ts +22 -7
- package/types/otp.d.ts +18 -10
- package/types/pagination.d.ts +18 -10
- package/types/popover.d.ts +52 -13
- package/types/primitive.d.ts +50 -0
- package/types/progress.d.ts +16 -7
- package/types/qr-code.d.ts +10 -4
- package/types/radio-group.d.ts +18 -17
- package/types/resizable.d.ts +12 -7
- package/types/runtime.d.ts +36 -12
- package/types/scroll-area.d.ts +17 -9
- package/types/select.d.ts +55 -46
- package/types/separator.d.ts +5 -3
- package/types/slider.d.ts +25 -13
- package/types/switch.d.ts +7 -4
- package/types/tabs.d.ts +20 -16
- package/types/testing.d.ts +1 -0
- package/types/toast.d.ts +40 -16
- package/types/toggle-group.d.ts +6 -11
- package/types/toggle.d.ts +4 -3
- package/types/toolbar.d.ts +19 -14
- package/types/tooltip.d.ts +16 -10
- package/types/value-bar.d.ts +21 -10
package/src/command.jsx
CHANGED
|
@@ -17,6 +17,7 @@ function Root(props) {
|
|
|
17
17
|
"onSelect",
|
|
18
18
|
"filter",
|
|
19
19
|
"loop",
|
|
20
|
+
"autoHighlight",
|
|
20
21
|
"disabled",
|
|
21
22
|
"id",
|
|
22
23
|
]);
|
|
@@ -27,22 +28,23 @@ function Root(props) {
|
|
|
27
28
|
defaultInputValue: local.defaultInputValue,
|
|
28
29
|
filter: local.filter,
|
|
29
30
|
loop: local.loop,
|
|
31
|
+
autoHighlight: local.autoHighlight,
|
|
30
32
|
disabled: local.disabled,
|
|
31
33
|
onInputValueChange: (value, details) => local.onInputValueChange?.(value, details),
|
|
32
34
|
onSelect: (value, details) => local.onSelect?.(value, details),
|
|
33
35
|
}));
|
|
34
36
|
return (<Context.Provider value={made}>
|
|
35
|
-
<Part
|
|
37
|
+
<Part of={made.root} tag="div" {...rest}/>
|
|
36
38
|
</Context.Provider>);
|
|
37
39
|
}
|
|
38
|
-
const Input = (props) =>
|
|
39
|
-
const List = (props) => <Part
|
|
40
|
+
const Input = (props) => <Part of={useCommand().input} tag="input" {...props}/>;
|
|
41
|
+
const List = (props) => <Part of={useCommand().list} tag="div" {...props}/>;
|
|
40
42
|
/** Drawn while no item is shown for what was typed. */
|
|
41
43
|
function Empty(props) {
|
|
42
44
|
const made = useCommand();
|
|
43
45
|
const empty = fromSignal(made.empty);
|
|
44
46
|
return (<Show when={empty()}>
|
|
45
|
-
<Part
|
|
47
|
+
<Part of={made.emptyPart} tag="div" {...props}/>
|
|
46
48
|
</Show>);
|
|
47
49
|
}
|
|
48
50
|
/** Items under a `<Command.GroupHeading>`. Hidden while none of them is shown. */
|
|
@@ -51,12 +53,12 @@ function Group(props) {
|
|
|
51
53
|
const generated = createUniqueId();
|
|
52
54
|
const group = useCommand().group(untrack(() => local.id) ?? generated);
|
|
53
55
|
return (<GroupContext.Provider value={group}>
|
|
54
|
-
<Part
|
|
56
|
+
<Part of={group.part} tag="div" {...rest}/>
|
|
55
57
|
</GroupContext.Provider>);
|
|
56
58
|
}
|
|
57
59
|
function GroupHeading(props) {
|
|
58
60
|
const part = useContext(GroupContext)?.heading ?? useCommand().heading;
|
|
59
|
-
return <Part
|
|
61
|
+
return <Part of={part} tag="div" {...props}/>;
|
|
60
62
|
}
|
|
61
63
|
/** `label` is what is filtered, the item's text when left out; `keywords` are other words for it. */
|
|
62
64
|
function Item(props) {
|
|
@@ -69,13 +71,13 @@ function Item(props) {
|
|
|
69
71
|
id: local.id ?? generated,
|
|
70
72
|
}));
|
|
71
73
|
const part = useCommand().item(untrack(() => local.value), () => options.get(), useContext(GroupContext));
|
|
72
|
-
return <Part
|
|
74
|
+
return <Part of={part} tag="div" {...rest}/>;
|
|
73
75
|
}
|
|
74
76
|
/** A line between groups: gone while something is typed, unless `alwaysRender`. */
|
|
75
77
|
function Separator(props) {
|
|
76
78
|
const [local, rest] = splitProps(props, ["alwaysRender"]);
|
|
77
79
|
const options = toSignal(() => ({ alwaysRender: local.alwaysRender }));
|
|
78
80
|
const part = useCommand().separator(() => options.get().alwaysRender);
|
|
79
|
-
return <Part
|
|
81
|
+
return <Part of={part} tag="div" {...rest}/>;
|
|
80
82
|
}
|
|
81
83
|
export const Command = { Root, Input, List, Empty, Group, GroupHeading, Item, Separator };
|
package/src/date-field.jsx
CHANGED
|
@@ -3,6 +3,10 @@ import { createDateField } from "@kirana-ui/core/date-field";
|
|
|
3
3
|
import { For, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
4
4
|
import { DirectionContext } from "./direction-context.js";
|
|
5
5
|
import { Part, controller, fromSignal } from "./runtime.jsx";
|
|
6
|
+
/**
|
|
7
|
+
* The date field its parts are inside. Exported for a component that is made of one (a date picker
|
|
8
|
+
* provides its own to the date field's parts).
|
|
9
|
+
*/
|
|
6
10
|
const Context = createContext();
|
|
7
11
|
/** For a component made of this one's parts: a date picker. */
|
|
8
12
|
export { Context as DateFieldContext };
|
|
@@ -46,7 +50,7 @@ function Root(props) {
|
|
|
46
50
|
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
47
51
|
}));
|
|
48
52
|
return (<Context.Provider value={made}>
|
|
49
|
-
<Part
|
|
53
|
+
<Part of={made.root} tag="div" {...rest}/>
|
|
50
54
|
</Context.Provider>);
|
|
51
55
|
}
|
|
52
56
|
/** Draws its child once for each piece of the date, in the locale's order. */
|
|
@@ -59,9 +63,9 @@ function Segment(props) {
|
|
|
59
63
|
const [local, rest] = splitProps(props, ["segment"]);
|
|
60
64
|
const made = useDateField().segment(local.segment);
|
|
61
65
|
const shown = fromSignal(made.text);
|
|
62
|
-
return (<Part
|
|
66
|
+
return (<Part of={made.part} tag="span" {...rest}>
|
|
63
67
|
{shown()}
|
|
64
68
|
</Part>);
|
|
65
69
|
}
|
|
66
|
-
const Input = (props) =>
|
|
70
|
+
const Input = (props) => <Part of={useDateField().input} tag="input" {...props}/>;
|
|
67
71
|
export const DateField = { Root, Segments, Segment, Input };
|
package/src/date-picker.jsx
CHANGED
|
@@ -28,6 +28,10 @@ function Root(props) {
|
|
|
28
28
|
isDateUnavailable: props.isDateUnavailable,
|
|
29
29
|
calendarSystem: props.calendarSystem,
|
|
30
30
|
fixedWeeks: props.fixedWeeks,
|
|
31
|
+
months: props.months,
|
|
32
|
+
pagedNavigation: props.pagedNavigation,
|
|
33
|
+
month: props.month,
|
|
34
|
+
defaultMonth: props.defaultMonth,
|
|
31
35
|
placeholders: props.placeholders,
|
|
32
36
|
disabled: props.disabled,
|
|
33
37
|
readOnly: props.readOnly,
|
|
@@ -36,6 +40,7 @@ function Root(props) {
|
|
|
36
40
|
form: props.form,
|
|
37
41
|
onValueChange: (value, details) => props.onValueChange?.(value, details),
|
|
38
42
|
onOpenChange: (open, details) => props.onOpenChange?.(open, details),
|
|
43
|
+
onMonthChange: (month, details) => props.onMonthChange?.(month, details),
|
|
39
44
|
}));
|
|
40
45
|
return (<Context.Provider value={made}>
|
|
41
46
|
<DateFieldContext.Provider value={made.field}>
|
|
@@ -50,7 +55,7 @@ function Root(props) {
|
|
|
50
55
|
export const DatePicker = {
|
|
51
56
|
Root,
|
|
52
57
|
/** The typed date: what holds its segments and its hidden input. */
|
|
53
|
-
Field: (props) =>
|
|
58
|
+
Field: (props) => <Part of={useDatePicker().field.root} tag="div" {...props}/>,
|
|
54
59
|
Segments: DateField.Segments,
|
|
55
60
|
Segment: DateField.Segment,
|
|
56
61
|
Input: DateField.Input,
|
|
@@ -59,10 +64,11 @@ export const DatePicker = {
|
|
|
59
64
|
Positioner: Popover.Positioner,
|
|
60
65
|
Popup: Popover.Popup,
|
|
61
66
|
/** The calendar: what holds its heading, its buttons and its grid. */
|
|
62
|
-
Calendar: (props) => (<Part
|
|
67
|
+
Calendar: (props) => (<Part of={useDatePicker().calendar.root} tag="div" {...props}/>),
|
|
63
68
|
Heading: Calendar.Heading,
|
|
64
69
|
Previous: Calendar.Previous,
|
|
65
70
|
Next: Calendar.Next,
|
|
71
|
+
Months: Calendar.Months,
|
|
66
72
|
Grid: Calendar.Grid,
|
|
67
73
|
Weekdays: Calendar.Weekdays,
|
|
68
74
|
HeadCell: Calendar.HeadCell,
|
package/src/dialog.jsx
CHANGED
|
@@ -23,7 +23,7 @@ function Root(props) {
|
|
|
23
23
|
return <Context.Provider value={made}>{props.children}</Context.Provider>;
|
|
24
24
|
}
|
|
25
25
|
const Portal = (props) => (<BodyPortal mounted={useDialog().mounted}>{props.children}</BodyPortal>);
|
|
26
|
-
const part = (name, tag) => (props) => <Part
|
|
26
|
+
const part = (name, tag) => (props) => <Part of={useDialog()[name]} tag={tag} {...props}/>;
|
|
27
27
|
function AlertRoot(props) {
|
|
28
28
|
const generated = createUniqueId();
|
|
29
29
|
const made = controller(createAlertDialog, () => ({
|
|
@@ -39,6 +39,8 @@ export const Dialog = {
|
|
|
39
39
|
Portal,
|
|
40
40
|
Trigger: part("trigger", "button"),
|
|
41
41
|
Backdrop: part("backdrop", "div"),
|
|
42
|
+
/** What a long dialog scrolls in, around its popup: it may be left out. */
|
|
43
|
+
Viewport: part("viewport", "div"),
|
|
42
44
|
Popup: part("popup", "div"),
|
|
43
45
|
Title: part("title", "h2"),
|
|
44
46
|
Description: part("description", "p"),
|
|
@@ -63,5 +65,13 @@ function DrawerRoot(props) {
|
|
|
63
65
|
}));
|
|
64
66
|
return <Context.Provider value={made}>{props.children}</Context.Provider>;
|
|
65
67
|
}
|
|
68
|
+
// A drawer has no viewport: it lies at an edge of the page, and what scrolls is inside it.
|
|
69
|
+
const { Viewport: _, ...shared } = Dialog;
|
|
66
70
|
/** A dialog that comes from an edge and is dragged back to it. Its parts are a dialog's. */
|
|
67
|
-
export const Drawer = {
|
|
71
|
+
export const Drawer = {
|
|
72
|
+
...shared,
|
|
73
|
+
Root: DrawerRoot,
|
|
74
|
+
// The same components: only what `render` reads of their state is a drawer's.
|
|
75
|
+
Backdrop: Dialog.Backdrop,
|
|
76
|
+
Popup: Dialog.Popup,
|
|
77
|
+
};
|
package/src/field.jsx
CHANGED
|
@@ -28,7 +28,7 @@ function Root(props) {
|
|
|
28
28
|
validate: (value) => local.validate?.(value) ?? null,
|
|
29
29
|
}));
|
|
30
30
|
return (<FieldContext.Provider value={made}>
|
|
31
|
-
<Part
|
|
31
|
+
<Part of={made.root} tag="div" {...rest}/>
|
|
32
32
|
</FieldContext.Provider>);
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
@@ -43,7 +43,7 @@ function FieldError(props) {
|
|
|
43
43
|
const mounted = fromSignal(error.mounted);
|
|
44
44
|
const text = fromSignal(error.text);
|
|
45
45
|
return (<Show when={mounted()}>
|
|
46
|
-
<Part
|
|
46
|
+
<Part of={error.part} tag="div" {...rest}>
|
|
47
47
|
{local.children ?? text()}
|
|
48
48
|
</Part>
|
|
49
49
|
</Show>);
|
|
@@ -52,7 +52,7 @@ function FieldError(props) {
|
|
|
52
52
|
function Validity(props) {
|
|
53
53
|
return props.children(fromSignal(useField().validity));
|
|
54
54
|
}
|
|
55
|
-
const part = (key, tag) => (props) =>
|
|
55
|
+
const part = (key, tag) => (props) => <Part of={useField()[key]} tag={tag} {...props}/>;
|
|
56
56
|
export const Field = {
|
|
57
57
|
Root,
|
|
58
58
|
Label: part("label", "label"),
|
package/src/fieldset.jsx
CHANGED
|
@@ -17,8 +17,8 @@ function Root(props) {
|
|
|
17
17
|
disabled: local.disabled,
|
|
18
18
|
}));
|
|
19
19
|
return (<FieldsetContext.Provider value={made}>
|
|
20
|
-
<Part
|
|
20
|
+
<Part of={made.root} tag="fieldset" {...rest}/>
|
|
21
21
|
</FieldsetContext.Provider>);
|
|
22
22
|
}
|
|
23
|
-
const Legend = (props) =>
|
|
23
|
+
const Legend = (props) => <Part of={useFieldset().legend} tag="div" {...props}/>;
|
|
24
24
|
export const Fieldset = { Root, Legend };
|
package/src/form.jsx
CHANGED
|
@@ -21,6 +21,6 @@ export function Form(props) {
|
|
|
21
21
|
onClearErrors: (errors) => local.onClearErrors?.(errors),
|
|
22
22
|
}));
|
|
23
23
|
return (<FormContext.Provider value={made}>
|
|
24
|
-
<Part
|
|
24
|
+
<Part of={made.root} tag="form" {...rest}/>
|
|
25
25
|
</FormContext.Provider>);
|
|
26
26
|
}
|
package/src/hover-popup.jsx
CHANGED
|
@@ -27,15 +27,15 @@ export function hoverPopup(name, create, triggerTag) {
|
|
|
27
27
|
const Portal = (props) => (<BodyPortal mounted={use().mounted}>{props.children}</BodyPortal>);
|
|
28
28
|
function Positioner(props) {
|
|
29
29
|
const made = use();
|
|
30
|
-
return <Part
|
|
30
|
+
return <Part of={made.positioner} tag="div" {...positioned(props, made.positioning)}/>;
|
|
31
31
|
}
|
|
32
|
-
const part = (key, tag) => (props) =>
|
|
32
|
+
const part = (key, tag) => (props) => <Part of={use()[key]} tag={tag} {...props}/>;
|
|
33
33
|
/** `delay` and `closeDelay` here come before the root's. */
|
|
34
34
|
function Trigger(props) {
|
|
35
35
|
const [local, rest] = splitProps(props, ["delay", "closeDelay"]);
|
|
36
36
|
const made = use();
|
|
37
37
|
createComputed(() => made.timing.set(defined({ ...local })));
|
|
38
|
-
return <Part
|
|
38
|
+
return <Part of={made.trigger} tag={triggerTag} {...rest}/>;
|
|
39
39
|
}
|
|
40
40
|
return {
|
|
41
41
|
Root,
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Accordion } from "./accordion.jsx";
|
|
2
2
|
export { Checkbox } from "./checkbox.jsx";
|
|
3
|
+
export { CheckboxGroup } from "./checkbox-group.jsx";
|
|
3
4
|
export { Collapsible } from "./collapsible.jsx";
|
|
4
5
|
export { AlertDialog, Dialog, Drawer } from "./dialog.jsx";
|
|
5
6
|
export { MessageScroller } from "./message-scroller.jsx";
|
package/src/input.jsx
CHANGED
package/src/label.jsx
CHANGED
|
@@ -5,5 +5,5 @@ import { Part } from "./runtime.jsx";
|
|
|
5
5
|
/** A `<label>`. Inside a `<Field.Root>` it is the field's label. */
|
|
6
6
|
export function Label(props) {
|
|
7
7
|
const made = createLabel({ field: useContext(FieldContext) });
|
|
8
|
-
return <Part
|
|
8
|
+
return <Part of={made.label} tag="label" {...props}/>;
|
|
9
9
|
}
|
package/src/listbox.jsx
CHANGED
|
@@ -25,7 +25,7 @@ function Root(props) {
|
|
|
25
25
|
"id",
|
|
26
26
|
]);
|
|
27
27
|
const generated = createUniqueId();
|
|
28
|
-
const made = controller(createListbox, () => ({
|
|
28
|
+
const made = controller((createListbox), () => ({
|
|
29
29
|
id: local.id ?? generated,
|
|
30
30
|
value: local.value,
|
|
31
31
|
defaultValue: local.defaultValue,
|
|
@@ -38,7 +38,7 @@ function Root(props) {
|
|
|
38
38
|
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
39
39
|
}));
|
|
40
40
|
return (<Context.Provider value={made}>
|
|
41
|
-
<Part
|
|
41
|
+
<Part of={made.root} tag="div" {...rest}/>
|
|
42
42
|
</Context.Provider>);
|
|
43
43
|
}
|
|
44
44
|
function Item(props) {
|
|
@@ -52,7 +52,7 @@ function Item(props) {
|
|
|
52
52
|
}));
|
|
53
53
|
const part = useListbox().item(value, () => defined(options.get()));
|
|
54
54
|
return (<ItemContext.Provider value={value}>
|
|
55
|
-
<Part
|
|
55
|
+
<Part of={part} tag="div" {...rest}/>
|
|
56
56
|
</ItemContext.Provider>);
|
|
57
57
|
}
|
|
58
58
|
function ItemIndicator(props) {
|
|
@@ -61,7 +61,7 @@ function ItemIndicator(props) {
|
|
|
61
61
|
const value = useContext(ItemContext);
|
|
62
62
|
const selected = fromSignal(made.selected(value));
|
|
63
63
|
return (<Show when={selected() || local.keepMounted}>
|
|
64
|
-
<Part
|
|
64
|
+
<Part of={made.indicator(value)} tag="span" {...rest}/>
|
|
65
65
|
</Show>);
|
|
66
66
|
}
|
|
67
67
|
function Group(props) {
|
|
@@ -69,13 +69,13 @@ function Group(props) {
|
|
|
69
69
|
const generated = createUniqueId();
|
|
70
70
|
const group = useListbox().group(untrack(() => local.id) ?? generated);
|
|
71
71
|
return (<GroupContext.Provider value={group}>
|
|
72
|
-
<Part
|
|
72
|
+
<Part of={group.root} tag="div" {...rest}/>
|
|
73
73
|
</GroupContext.Provider>);
|
|
74
74
|
}
|
|
75
75
|
function GroupLabel(props) {
|
|
76
76
|
const group = useContext(GroupContext);
|
|
77
77
|
if (!group)
|
|
78
78
|
throw new Error("A Listbox.GroupLabel must be inside <Listbox.Group>");
|
|
79
|
-
return <Part
|
|
79
|
+
return <Part of={group.label} tag="div" {...props}/>;
|
|
80
80
|
}
|
|
81
81
|
export const Listbox = { Root, Item, ItemIndicator, Group, GroupLabel };
|
package/src/menu.jsx
CHANGED
|
@@ -52,32 +52,32 @@ const SubmenuRoot = (props) => make(props, "submenu");
|
|
|
52
52
|
const Portal = (props) => (<BodyPortal mounted={useMenu().mounted}>{props.children}</BodyPortal>);
|
|
53
53
|
function Positioner(props) {
|
|
54
54
|
const made = useMenu();
|
|
55
|
-
return <Part
|
|
55
|
+
return <Part of={made.positioner} tag="div" {...positioned(props, made.positioning)}/>;
|
|
56
56
|
}
|
|
57
57
|
const ITEM = ["disabled", "label", "closeOnClick"];
|
|
58
58
|
function Item(props) {
|
|
59
59
|
const [local, rest] = splitProps(props, ITEM);
|
|
60
60
|
const options = toSignal(() => ({ ...local }));
|
|
61
61
|
const part = useMenu().item(() => defined(options.get()));
|
|
62
|
-
return <Part
|
|
62
|
+
return <Part of={part} tag="div" {...rest}/>;
|
|
63
63
|
}
|
|
64
64
|
/** An item that is a link: `href` and the rest go to its `<a>`. */
|
|
65
65
|
function LinkItem(props) {
|
|
66
66
|
const [local, rest] = splitProps(props, ITEM);
|
|
67
67
|
const options = toSignal(() => ({ ...local }));
|
|
68
68
|
const part = useMenu().item(() => defined(options.get()));
|
|
69
|
-
return <Part
|
|
69
|
+
return <Part of={part} tag="a" {...rest}/>;
|
|
70
70
|
}
|
|
71
71
|
function Group(props) {
|
|
72
72
|
const [local, rest] = splitProps(props, ["id"]);
|
|
73
73
|
const generated = createUniqueId();
|
|
74
74
|
const group = useMenu().group(untrack(() => local.id) ?? generated);
|
|
75
75
|
return (<GroupContext.Provider value={group}>
|
|
76
|
-
<Part
|
|
76
|
+
<Part of={group.root} tag="div" {...rest}/>
|
|
77
77
|
</GroupContext.Provider>);
|
|
78
78
|
}
|
|
79
79
|
/** Names the group it is in. With no group around it, it is plain text. */
|
|
80
|
-
const GroupLabel = (props) => (<Part
|
|
80
|
+
const GroupLabel = (props) => (<Part of={useContext(GroupContext)?.label ?? useMenu().label} tag="div" {...props}/>);
|
|
81
81
|
function CheckboxItem(props) {
|
|
82
82
|
const [local, rest] = splitProps(props, [...ITEM, "checked", "defaultChecked", "onCheckedChange"]);
|
|
83
83
|
const item = controller(useMenu().checkboxItem, () => ({
|
|
@@ -89,7 +89,7 @@ function CheckboxItem(props) {
|
|
|
89
89
|
onCheckedChange: (checked, details) => local.onCheckedChange?.(checked, details),
|
|
90
90
|
}));
|
|
91
91
|
return (<CheckboxContext.Provider value={item}>
|
|
92
|
-
<Part
|
|
92
|
+
<Part of={item.part} tag="div" {...rest}/>
|
|
93
93
|
</CheckboxContext.Provider>);
|
|
94
94
|
}
|
|
95
95
|
function CheckboxItemIndicator(props) {
|
|
@@ -97,7 +97,7 @@ function CheckboxItemIndicator(props) {
|
|
|
97
97
|
const item = inside(useContext(CheckboxContext), "CheckboxItem");
|
|
98
98
|
const checked = fromSignal(item.checked);
|
|
99
99
|
return (<Show when={checked() || local.keepMounted}>
|
|
100
|
-
<Part
|
|
100
|
+
<Part of={item.indicator} tag="span" {...rest}/>
|
|
101
101
|
</Show>);
|
|
102
102
|
}
|
|
103
103
|
function RadioGroup(props) {
|
|
@@ -109,7 +109,7 @@ function RadioGroup(props) {
|
|
|
109
109
|
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
110
110
|
}));
|
|
111
111
|
return (<RadioGroupContext.Provider value={group}>
|
|
112
|
-
<Part
|
|
112
|
+
<Part of={group.root} tag="div" {...rest}/>
|
|
113
113
|
</RadioGroupContext.Provider>);
|
|
114
114
|
}
|
|
115
115
|
function RadioItem(props) {
|
|
@@ -123,7 +123,7 @@ function RadioItem(props) {
|
|
|
123
123
|
}));
|
|
124
124
|
const part = inside(useContext(RadioGroupContext), "RadioGroup").item(value, () => defined(options.get()));
|
|
125
125
|
return (<RadioItemContext.Provider value={value}>
|
|
126
|
-
<Part
|
|
126
|
+
<Part of={part} tag="div" {...rest}/>
|
|
127
127
|
</RadioItemContext.Provider>);
|
|
128
128
|
}
|
|
129
129
|
function RadioItemIndicator(props) {
|
|
@@ -132,10 +132,10 @@ function RadioItemIndicator(props) {
|
|
|
132
132
|
const value = useContext(RadioItemContext);
|
|
133
133
|
const checked = fromSignal(group.checked(value));
|
|
134
134
|
return (<Show when={checked() || local.keepMounted}>
|
|
135
|
-
<Part
|
|
135
|
+
<Part of={group.indicator(value)} tag="span" {...rest}/>
|
|
136
136
|
</Show>);
|
|
137
137
|
}
|
|
138
|
-
const part = (name, tag) => (props) => <Part
|
|
138
|
+
const part = (name, tag) => (props) => <Part of={useMenu()[name]} tag={tag} {...props}/>;
|
|
139
139
|
export const Menu = {
|
|
140
140
|
Root,
|
|
141
141
|
Portal,
|
package/src/menubar.jsx
CHANGED
package/src/message-scroller.jsx
CHANGED
|
@@ -18,10 +18,10 @@ function Root(props) {
|
|
|
18
18
|
onAtBottomChange: (atBottom, details) => local.onAtBottomChange?.(atBottom, details),
|
|
19
19
|
}));
|
|
20
20
|
return (<Context.Provider value={made}>
|
|
21
|
-
<Part
|
|
21
|
+
<Part of={made.root} tag="div" {...rest}/>
|
|
22
22
|
</Context.Provider>);
|
|
23
23
|
}
|
|
24
|
-
const Viewport = (props) =>
|
|
25
|
-
const Content = (props) =>
|
|
26
|
-
const Button = (props) =>
|
|
24
|
+
const Viewport = (props) => <Part of={useScroller().viewport} tag="div" {...props}/>;
|
|
25
|
+
const Content = (props) => <Part of={useScroller().content} tag="div" {...props}/>;
|
|
26
|
+
const Button = (props) => <Part of={useScroller().button} tag="button" {...props}/>;
|
|
27
27
|
export const MessageScroller = { Root, Viewport, Content, Button };
|
package/src/navigation-menu.jsx
CHANGED
|
@@ -30,7 +30,7 @@ function Root(props) {
|
|
|
30
30
|
]);
|
|
31
31
|
const generated = createUniqueId();
|
|
32
32
|
const direction = useContext(DirectionContext);
|
|
33
|
-
const made = controller(within(createNavigationMenu, { direction }), () => ({
|
|
33
|
+
const made = controller(within((createNavigationMenu), { direction }), () => ({
|
|
34
34
|
id: local.id ?? generated,
|
|
35
35
|
value: local.value,
|
|
36
36
|
defaultValue: local.defaultValue,
|
|
@@ -40,18 +40,19 @@ function Root(props) {
|
|
|
40
40
|
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
41
41
|
}));
|
|
42
42
|
return (<Context.Provider value={made}>
|
|
43
|
-
<Part
|
|
43
|
+
<Part of={made.root} tag="nav" {...rest}/>
|
|
44
44
|
</Context.Provider>);
|
|
45
45
|
}
|
|
46
|
-
/** `value` tells this item from the others; an item that is
|
|
46
|
+
/** `value` tells this item from the others; an item that is given none makes its own. */
|
|
47
47
|
function Item(props) {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
48
|
+
const [local, rest] = splitProps(props, ["value"]);
|
|
49
|
+
const made = useNavigation();
|
|
50
|
+
const generated = createUniqueId();
|
|
51
|
+
const value = untrack(() => local.value);
|
|
52
|
+
const item = made.item(value === undefined ? generated : value);
|
|
52
53
|
onMount(() => onCleanup(item.mount()));
|
|
53
54
|
return (<ItemContext.Provider value={item}>
|
|
54
|
-
<
|
|
55
|
+
<Part of={made.itemPart} tag="li" {...rest}/>
|
|
55
56
|
</ItemContext.Provider>);
|
|
56
57
|
}
|
|
57
58
|
/** An item's content: drawn in `<NavigationMenu.Viewport>`, while it is shown. */
|
|
@@ -61,7 +62,7 @@ function Content(props) {
|
|
|
61
62
|
const viewport = fromSignal(useNavigation().viewportElement);
|
|
62
63
|
return (<Show when={mounted() ? viewport() : undefined}>
|
|
63
64
|
{(target) => (<Into target={target()}>
|
|
64
|
-
<Part
|
|
65
|
+
<Part of={item.content} tag="div" {...props}/>
|
|
65
66
|
</Into>)}
|
|
66
67
|
</Show>);
|
|
67
68
|
}
|
|
@@ -69,15 +70,15 @@ function Link(props) {
|
|
|
69
70
|
const [local, rest] = splitProps(props, ["active", "closeOnClick"]);
|
|
70
71
|
const options = toSignal(() => ({ ...local }));
|
|
71
72
|
const part = useNavigation().link(() => defined(options.get()));
|
|
72
|
-
return <Part
|
|
73
|
+
return <Part of={part} tag="a" {...rest}/>;
|
|
73
74
|
}
|
|
74
75
|
const Portal = (props) => (<BodyPortal mounted={useNavigation().mounted}>{props.children}</BodyPortal>);
|
|
75
76
|
function Positioner(props) {
|
|
76
77
|
const made = useNavigation();
|
|
77
|
-
return <Part
|
|
78
|
+
return <Part of={made.positioner} tag="div" {...positioned(props, made.positioning)}/>;
|
|
78
79
|
}
|
|
79
|
-
const part = (name, tag) => (props) => <Part
|
|
80
|
-
const itemPart = (name, tag) => (props) =>
|
|
80
|
+
const part = (name, tag) => (props) => <Part of={useNavigation()[name]} tag={tag} {...props}/>;
|
|
81
|
+
const itemPart = (name, tag) => (props) => <Part of={useItem()[name]} tag={tag} {...props}/>;
|
|
81
82
|
export const NavigationMenu = {
|
|
82
83
|
Root,
|
|
83
84
|
List: part("list", "ul"),
|
package/src/number-field.jsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { within } from "@kirana-ui/core";
|
|
1
|
+
import { defined, within } from "@kirana-ui/core";
|
|
2
2
|
import { createNumberField } from "@kirana-ui/core/number-field";
|
|
3
|
-
import { Show, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
3
|
+
import { Show, createComputed, createContext, createUniqueId, splitProps, useContext, } from "solid-js";
|
|
4
4
|
import { FieldContext } from "./field-context.js";
|
|
5
|
-
import { Part, controller, fromSignal } from "./runtime.jsx";
|
|
5
|
+
import { Part, Portal, controller, fromSignal } from "./runtime.jsx";
|
|
6
6
|
const Context = createContext();
|
|
7
7
|
function useNumberField() {
|
|
8
8
|
const made = useContext(Context);
|
|
@@ -57,17 +57,37 @@ function Root(props) {
|
|
|
57
57
|
}));
|
|
58
58
|
const named = fromSignal(made.named);
|
|
59
59
|
return (<Context.Provider value={made}>
|
|
60
|
-
<Part
|
|
60
|
+
<Part of={made.root} tag="div" {...rest}>
|
|
61
61
|
{local.children}
|
|
62
62
|
<Show when={named()}>
|
|
63
|
-
<Part
|
|
63
|
+
<Part of={made.hidden} tag="input"/>
|
|
64
64
|
</Show>
|
|
65
65
|
</Part>
|
|
66
66
|
</Context.Provider>);
|
|
67
67
|
}
|
|
68
|
-
const part = (name, tag) => (props) => <Part
|
|
68
|
+
const part = (name, tag) => (props) => <Part of={useNumberField()[name]} tag={tag} {...props}/>;
|
|
69
|
+
/** Pressed and dragged to change the number; `direction`, `pixelSensitivity`, `teleportDistance`. */
|
|
70
|
+
function ScrubArea(props) {
|
|
71
|
+
const [local, rest] = splitProps(props, [
|
|
72
|
+
"direction",
|
|
73
|
+
"pixelSensitivity",
|
|
74
|
+
"teleportDistance",
|
|
75
|
+
]);
|
|
76
|
+
const made = useNumberField();
|
|
77
|
+
createComputed(() => made.scrub.set(defined({ ...local })));
|
|
78
|
+
return <Part of={made.scrubArea} tag="span" {...rest}/>;
|
|
79
|
+
}
|
|
80
|
+
/** Drawn in place of the pointer while it is locked for a drag, at the end of `<body>`. */
|
|
81
|
+
function ScrubAreaCursor(props) {
|
|
82
|
+
const made = useNumberField();
|
|
83
|
+
return (<Portal mounted={made.scrubAreaCursor.mounted}>
|
|
84
|
+
<Part of={made.scrubAreaCursor.part} tag="span" {...props}/>
|
|
85
|
+
</Portal>);
|
|
86
|
+
}
|
|
69
87
|
export const NumberField = {
|
|
70
88
|
Root,
|
|
89
|
+
ScrubArea,
|
|
90
|
+
ScrubAreaCursor,
|
|
71
91
|
Group: part("group", "div"),
|
|
72
92
|
Input: part("input", "input"),
|
|
73
93
|
Increment: part("increment", "button"),
|
package/src/otp.jsx
CHANGED
|
@@ -17,6 +17,7 @@ function Root(props) {
|
|
|
17
17
|
"onValueChange",
|
|
18
18
|
"onComplete",
|
|
19
19
|
"mode",
|
|
20
|
+
"pattern",
|
|
20
21
|
"disabled",
|
|
21
22
|
"name",
|
|
22
23
|
"form",
|
|
@@ -29,6 +30,7 @@ function Root(props) {
|
|
|
29
30
|
value: local.value,
|
|
30
31
|
defaultValue: local.defaultValue,
|
|
31
32
|
mode: local.mode,
|
|
33
|
+
pattern: local.pattern,
|
|
32
34
|
disabled: local.disabled,
|
|
33
35
|
name: local.name,
|
|
34
36
|
form: local.form,
|
|
@@ -36,7 +38,7 @@ function Root(props) {
|
|
|
36
38
|
onComplete: (value) => local.onComplete?.(value),
|
|
37
39
|
}));
|
|
38
40
|
return (<Context.Provider value={made}>
|
|
39
|
-
<Part
|
|
41
|
+
<Part of={made.root} tag="div" {...rest}/>
|
|
40
42
|
</Context.Provider>);
|
|
41
43
|
}
|
|
42
44
|
/** One cell: it shows its character, then whatever it is given (a caret). */
|
|
@@ -45,7 +47,7 @@ function Slot(props) {
|
|
|
45
47
|
const slot = useOtp().slot(untrack(() => local.index));
|
|
46
48
|
const char = fromSignal(slot.char);
|
|
47
49
|
return (<SlotContext.Provider value={slot}>
|
|
48
|
-
<Part
|
|
50
|
+
<Part of={slot.part} tag="div" {...rest}>
|
|
49
51
|
{char()}
|
|
50
52
|
{local.children}
|
|
51
53
|
</Part>
|
|
@@ -59,10 +61,10 @@ function Caret(props) {
|
|
|
59
61
|
throw new Error("An Otp.Caret must be inside <Otp.Slot>");
|
|
60
62
|
const shown = fromSignal(slot.caret);
|
|
61
63
|
return (<Show when={shown()}>
|
|
62
|
-
<Part
|
|
64
|
+
<Part of={made.caretPart} tag="div" {...props}/>
|
|
63
65
|
</Show>);
|
|
64
66
|
}
|
|
65
|
-
const part = (name, tag) => (props) =>
|
|
67
|
+
const part = (name, tag) => (props) => <Part of={useOtp()[name]} tag={tag} {...props}/>;
|
|
66
68
|
export const Otp = {
|
|
67
69
|
Root,
|
|
68
70
|
Input: part("input", "input"),
|
package/src/pagination.jsx
CHANGED
|
@@ -33,7 +33,7 @@ function Root(props) {
|
|
|
33
33
|
onPageChange: (page, details) => local.onPageChange?.(page, details),
|
|
34
34
|
}));
|
|
35
35
|
return (<Context.Provider value={made}>
|
|
36
|
-
<Part
|
|
36
|
+
<Part of={made.root} tag="nav" {...rest}/>
|
|
37
37
|
</Context.Provider>);
|
|
38
38
|
}
|
|
39
39
|
/** Draws its child once for each piece of the row: a page, or the mark for pages left out. */
|
|
@@ -47,9 +47,9 @@ function Items(props) {
|
|
|
47
47
|
function Item(props) {
|
|
48
48
|
const [local, rest] = splitProps(props, ["page"]);
|
|
49
49
|
const made = usePagination();
|
|
50
|
-
return <Part
|
|
50
|
+
return <Part of={made.item(local.page)} tag="button" {...rest}/>;
|
|
51
51
|
}
|
|
52
|
-
const part = (name, tag) => (props) =>
|
|
52
|
+
const part = (name, tag) => (props) => <Part of={usePagination()[name]} tag={tag} {...props}/>;
|
|
53
53
|
export const Pagination = {
|
|
54
54
|
Root,
|
|
55
55
|
Items,
|