@kirana-ui/solid 0.0.0 → 0.1.1
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/LICENSE +1 -1
- package/dom/accordion.js +106 -0
- package/dom/alert-dialog.js +2 -0
- package/dom/autocomplete.js +2 -0
- package/dom/autosize.js +19 -0
- package/dom/avatar.js +68 -0
- package/dom/button.js +18 -0
- package/dom/calendar.js +141 -0
- package/dom/carousel.js +83 -0
- package/dom/checkbox.js +77 -0
- package/dom/collapsible.js +64 -0
- package/dom/combobox.js +281 -0
- package/dom/command.js +129 -0
- package/dom/context-menu.js +2 -0
- package/dom/date-field.js +86 -0
- package/dom/date-picker.js +103 -0
- package/dom/dialog.js +101 -0
- package/dom/direction-context.js +3 -0
- package/dom/direction.js +27 -0
- package/dom/drawer.js +2 -0
- package/dom/field-context.js +3 -0
- package/dom/field.js +88 -0
- package/dom/fieldset.js +41 -0
- package/dom/form.js +29 -0
- package/dom/hover-card.js +3 -0
- package/dom/hover-popup.js +78 -0
- package/dom/index.js +47 -0
- 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/meter.js +3 -0
- package/dom/navigation-menu.js +150 -0
- package/dom/number-field.js +82 -0
- package/dom/otp.js +95 -0
- package/dom/pagination.js +74 -0
- package/dom/popover.js +70 -0
- package/dom/progress.js +3 -0
- package/dom/qr-code.js +48 -0
- package/dom/radio-group.js +101 -0
- package/dom/resizable.js +65 -0
- package/dom/runtime.js +133 -0
- package/dom/scroll-area.js +99 -0
- package/dom/select.js +213 -0
- package/dom/separator.js +17 -0
- package/dom/slider.js +93 -0
- package/dom/switch.js +63 -0
- package/dom/tabs.js +97 -0
- package/dom/toast.js +113 -0
- package/dom/toggle-group.js +37 -0
- package/dom/toggle.js +28 -0
- package/dom/toolbar-context.js +5 -0
- package/dom/toolbar.js +71 -0
- package/dom/tooltip.js +3 -0
- package/dom/value-bar.js +62 -0
- package/llms.txt +1838 -0
- package/package.json +437 -6
- package/server/accordion.js +106 -0
- package/server/alert-dialog.js +2 -0
- package/server/autocomplete.js +2 -0
- package/server/autosize.js +19 -0
- package/server/avatar.js +68 -0
- package/server/button.js +18 -0
- package/server/calendar.js +140 -0
- package/server/carousel.js +83 -0
- package/server/checkbox.js +77 -0
- package/server/collapsible.js +64 -0
- package/server/combobox.js +281 -0
- package/server/command.js +129 -0
- package/server/context-menu.js +2 -0
- package/server/date-field.js +86 -0
- package/server/date-picker.js +103 -0
- package/server/dialog.js +101 -0
- package/server/direction-context.js +3 -0
- package/server/direction.js +27 -0
- package/server/drawer.js +2 -0
- package/server/field-context.js +3 -0
- package/server/field.js +87 -0
- package/server/fieldset.js +41 -0
- package/server/form.js +29 -0
- package/server/hover-card.js +3 -0
- package/server/hover-popup.js +78 -0
- package/server/index.js +47 -0
- 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/meter.js +3 -0
- package/server/navigation-menu.js +144 -0
- package/server/number-field.js +81 -0
- package/server/otp.js +94 -0
- package/server/pagination.js +74 -0
- package/server/popover.js +70 -0
- package/server/progress.js +3 -0
- package/server/qr-code.js +48 -0
- package/server/radio-group.js +101 -0
- package/server/resizable.js +65 -0
- package/server/runtime.js +132 -0
- package/server/scroll-area.js +99 -0
- package/server/select.js +213 -0
- package/server/separator.js +17 -0
- package/server/slider.js +92 -0
- package/server/switch.js +62 -0
- package/server/tabs.js +97 -0
- package/server/toast.js +113 -0
- package/server/toggle-group.js +37 -0
- package/server/toggle.js +28 -0
- package/server/toolbar-context.js +5 -0
- package/server/toolbar.js +71 -0
- package/server/tooltip.js +3 -0
- package/server/value-bar.js +61 -0
- package/src/accordion.jsx +68 -0
- package/src/alert-dialog.js +2 -0
- package/src/autocomplete.jsx +2 -0
- package/src/autosize.jsx +8 -0
- package/src/avatar.jsx +35 -0
- package/src/button.jsx +9 -0
- package/src/calendar.jsx +104 -0
- package/src/carousel.jsx +51 -0
- package/src/checkbox.jsx +59 -0
- package/src/collapsible.jsx +35 -0
- package/src/combobox.jsx +179 -0
- package/src/command.jsx +81 -0
- package/src/context-menu.js +2 -0
- package/src/date-field.jsx +67 -0
- package/src/date-picker.jsx +72 -0
- package/src/dialog.jsx +67 -0
- package/src/direction-context.js +3 -0
- package/src/direction.jsx +17 -0
- package/src/drawer.js +2 -0
- package/src/field-context.js +3 -0
- package/src/field.jsx +64 -0
- package/src/fieldset.jsx +24 -0
- package/src/form.jsx +26 -0
- package/src/hover-card.jsx +3 -0
- package/src/hover-popup.jsx +48 -0
- package/src/index.js +47 -0
- 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/meter.jsx +3 -0
- package/src/navigation-menu.jsx +95 -0
- package/src/number-field.jsx +75 -0
- package/src/otp.jsx +73 -0
- package/src/pagination.jsx +60 -0
- package/src/popover.jsx +51 -0
- package/src/progress.jsx +3 -0
- package/src/qr-code.jsx +25 -0
- package/src/radio-group.jsx +68 -0
- package/src/resizable.jsx +46 -0
- package/src/runtime.jsx +119 -0
- package/src/scroll-area.jsx +53 -0
- package/src/select.jsx +129 -0
- package/src/separator.jsx +8 -0
- package/src/slider.jsx +76 -0
- package/src/switch.jsx +49 -0
- package/src/tabs.jsx +58 -0
- package/src/toast.jsx +58 -0
- package/src/toggle-group.jsx +32 -0
- package/src/toggle.jsx +24 -0
- package/src/toolbar-context.js +5 -0
- package/src/toolbar.jsx +43 -0
- package/src/tooltip.jsx +3 -0
- package/src/value-bar.jsx +45 -0
- package/types/accordion.d.ts +30 -0
- package/types/alert-dialog.d.ts +1 -0
- package/types/autocomplete.d.ts +1 -0
- package/types/autosize.d.ts +8 -0
- package/types/avatar.d.ts +15 -0
- package/types/button.d.ts +9 -0
- package/types/calendar.d.ts +40 -0
- package/types/carousel.d.ts +26 -0
- package/types/checkbox.d.ts +26 -0
- package/types/collapsible.d.ts +21 -0
- package/types/combobox.d.ts +106 -0
- package/types/command.d.ts +45 -0
- package/types/context-menu.d.ts +1 -0
- package/types/date-field.d.ts +23 -0
- package/types/date-picker.d.ts +49 -0
- package/types/dialog.d.ts +61 -0
- package/types/direction-context.d.ts +3 -0
- package/types/direction.d.ts +14 -0
- package/types/drawer.d.ts +1 -0
- package/types/field-context.d.ts +3 -0
- package/types/field.d.ts +28 -0
- package/types/fieldset.d.ts +14 -0
- package/types/form.d.ts +7 -0
- package/types/hover-card.d.ts +13 -0
- package/types/hover-popup.d.ts +29 -0
- package/types/index.d.ts +50 -0
- package/types/input.d.ts +12 -0
- package/types/label.d.ts +4 -0
- package/types/listbox.d.ts +38 -0
- package/types/menu.d.ts +91 -0
- package/types/menubar-context.d.ts +3 -0
- package/types/menubar.d.ts +10 -0
- package/types/message-scroller.d.ts +16 -0
- package/types/meter.d.ts +9 -0
- package/types/navigation-menu.d.ts +44 -0
- package/types/number-field.d.ts +15 -0
- package/types/otp.d.ts +32 -0
- package/types/pagination.d.ts +23 -0
- package/types/popover.d.ts +31 -0
- package/types/progress.d.ts +9 -0
- package/types/qr-code.d.ts +14 -0
- package/types/radio-group.d.ts +29 -0
- package/types/resizable.d.ts +24 -0
- package/types/runtime.d.ts +49 -0
- package/types/scroll-area.d.ts +20 -0
- package/types/select.d.ts +74 -0
- package/types/separator.d.ts +6 -0
- package/types/slider.d.ts +24 -0
- package/types/switch.d.ts +21 -0
- package/types/tabs.d.ts +32 -0
- package/types/toast.d.ts +33 -0
- package/types/toggle-group.d.ts +14 -0
- package/types/toggle.d.ts +12 -0
- package/types/toolbar-context.d.ts +6 -0
- package/types/toolbar.d.ts +23 -0
- package/types/tooltip.d.ts +13 -0
- package/types/value-bar.d.ts +17 -0
- package/README.md +0 -7
- package/index.js +0 -5
package/dom/direction.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { signal } from "@kirana-ui/core";
|
|
3
|
+
import { createDirection } from "@kirana-ui/core/direction";
|
|
4
|
+
import { useContext } from "solid-js";
|
|
5
|
+
import { DirectionContext } from "./direction-context.js";
|
|
6
|
+
import { controller, fromSignal } from "./runtime.js";
|
|
7
|
+
/**
|
|
8
|
+
* States the reading direction for the components inside. It draws nothing: set the page's own
|
|
9
|
+
* `dir` attribute with it.
|
|
10
|
+
*/
|
|
11
|
+
export function DirectionProvider(props) {
|
|
12
|
+
const made = controller(createDirection, () => ({
|
|
13
|
+
direction: props.direction
|
|
14
|
+
}));
|
|
15
|
+
return _$createComponent(DirectionContext.Provider, {
|
|
16
|
+
get value() {
|
|
17
|
+
return made.direction;
|
|
18
|
+
},
|
|
19
|
+
get children() {
|
|
20
|
+
return props.children;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/** The direction the nearest provider states; `ltr` outside one. */
|
|
25
|
+
export function useDirection() {
|
|
26
|
+
return fromSignal(useContext(DirectionContext) ?? signal("ltr"));
|
|
27
|
+
}
|
package/dom/drawer.js
ADDED
package/dom/field.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { memo as _$memo } from "solid-js/web";
|
|
2
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
3
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
4
|
+
import { createField } from "@kirana-ui/core/field";
|
|
5
|
+
import { Show, createUniqueId, onCleanup, onMount, splitProps, useContext } from "solid-js";
|
|
6
|
+
import { FieldContext } from "./field-context.js";
|
|
7
|
+
import { FieldsetContext } from "./fieldset.js";
|
|
8
|
+
import { FormContext } from "./form.js";
|
|
9
|
+
import { Part, controller, fromSignal, toSignal } from "./runtime.js";
|
|
10
|
+
function useField() {
|
|
11
|
+
const made = useContext(FieldContext);
|
|
12
|
+
if (!made) throw new Error("A Field part must be inside <Field.Root>");
|
|
13
|
+
return made;
|
|
14
|
+
}
|
|
15
|
+
function Root(props) {
|
|
16
|
+
const [local, rest] = splitProps(props, ["name", "disabled", "invalid", "validate", "validationMode", "validationDebounceTime", "id"]);
|
|
17
|
+
const generated = createUniqueId();
|
|
18
|
+
const around = {
|
|
19
|
+
form: useContext(FormContext),
|
|
20
|
+
fieldset: useContext(FieldsetContext)
|
|
21
|
+
};
|
|
22
|
+
const made = controller(source => createField(source, around), () => ({
|
|
23
|
+
...local,
|
|
24
|
+
id: local.id ?? generated,
|
|
25
|
+
validate: value => local.validate?.(value) ?? null
|
|
26
|
+
}));
|
|
27
|
+
return _$createComponent(FieldContext.Provider, {
|
|
28
|
+
value: made,
|
|
29
|
+
get children() {
|
|
30
|
+
return _$createComponent(Part, _$mergeProps({
|
|
31
|
+
get part() {
|
|
32
|
+
return made.root;
|
|
33
|
+
},
|
|
34
|
+
tag: "div"
|
|
35
|
+
}, rest));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* What is wrong, or its children in its place. In the page while it applies. `match` is one of
|
|
41
|
+
* the browser's findings (`"valueMissing"`) to show for only that, or `true` to show always.
|
|
42
|
+
*/
|
|
43
|
+
function FieldError(props) {
|
|
44
|
+
const [local, rest] = splitProps(props, ["match", "children"]);
|
|
45
|
+
const options = toSignal(() => ({
|
|
46
|
+
match: local.match
|
|
47
|
+
}));
|
|
48
|
+
const error = useField().error(() => options.get().match);
|
|
49
|
+
onMount(() => onCleanup(error.mount()));
|
|
50
|
+
const mounted = fromSignal(error.mounted);
|
|
51
|
+
const text = fromSignal(error.text);
|
|
52
|
+
return _$createComponent(Show, {
|
|
53
|
+
get when() {
|
|
54
|
+
return mounted();
|
|
55
|
+
},
|
|
56
|
+
get children() {
|
|
57
|
+
return _$createComponent(Part, _$mergeProps({
|
|
58
|
+
get part() {
|
|
59
|
+
return error.part;
|
|
60
|
+
},
|
|
61
|
+
tag: "div"
|
|
62
|
+
}, rest, {
|
|
63
|
+
get children() {
|
|
64
|
+
return local.children ?? text();
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/** Draws nothing itself: its child, a function, is given the field's validity. */
|
|
71
|
+
function Validity(props) {
|
|
72
|
+
return props.children(fromSignal(useField().validity));
|
|
73
|
+
}
|
|
74
|
+
const part = (key, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
75
|
+
get part() {
|
|
76
|
+
return useField()[key];
|
|
77
|
+
},
|
|
78
|
+
tag: tag
|
|
79
|
+
}, props));
|
|
80
|
+
export const Field = {
|
|
81
|
+
Root,
|
|
82
|
+
Label: part("label", "label"),
|
|
83
|
+
/** An `<input>`; `as="textarea"` or `as="select"` for another. */
|
|
84
|
+
Control: part("control", "input"),
|
|
85
|
+
Description: part("description", "p"),
|
|
86
|
+
Error: FieldError,
|
|
87
|
+
Validity
|
|
88
|
+
};
|
package/dom/fieldset.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { createFieldset } from "@kirana-ui/core/fieldset";
|
|
4
|
+
import { createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
5
|
+
import { Part, controller } from "./runtime.js";
|
|
6
|
+
/** The fieldset a field is in, if it is in one. */
|
|
7
|
+
export const FieldsetContext = createContext();
|
|
8
|
+
function useFieldset() {
|
|
9
|
+
const made = useContext(FieldsetContext);
|
|
10
|
+
if (!made) throw new Error("A Fieldset part must be inside <Fieldset.Root>");
|
|
11
|
+
return made;
|
|
12
|
+
}
|
|
13
|
+
function Root(props) {
|
|
14
|
+
const [local, rest] = splitProps(props, ["disabled", "id"]);
|
|
15
|
+
const generated = createUniqueId();
|
|
16
|
+
const made = controller(createFieldset, () => ({
|
|
17
|
+
id: local.id ?? generated,
|
|
18
|
+
disabled: local.disabled
|
|
19
|
+
}));
|
|
20
|
+
return _$createComponent(FieldsetContext.Provider, {
|
|
21
|
+
value: made,
|
|
22
|
+
get children() {
|
|
23
|
+
return _$createComponent(Part, _$mergeProps({
|
|
24
|
+
get part() {
|
|
25
|
+
return made.root;
|
|
26
|
+
},
|
|
27
|
+
tag: "fieldset"
|
|
28
|
+
}, rest));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const Legend = props => _$createComponent(Part, _$mergeProps({
|
|
33
|
+
get part() {
|
|
34
|
+
return useFieldset().legend;
|
|
35
|
+
},
|
|
36
|
+
tag: "div"
|
|
37
|
+
}, props));
|
|
38
|
+
export const Fieldset = {
|
|
39
|
+
Root,
|
|
40
|
+
Legend
|
|
41
|
+
};
|
package/dom/form.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { createForm } from "@kirana-ui/core/form";
|
|
4
|
+
import { createContext, splitProps } from "solid-js";
|
|
5
|
+
import { Part, controller } from "./runtime.js";
|
|
6
|
+
/** The form a field is in, if it is in one. */
|
|
7
|
+
export const FormContext = createContext();
|
|
8
|
+
/** A `<form>` whose fields say what is wrong; `onFormSubmit` takes the values once all are valid. */
|
|
9
|
+
export function Form(props) {
|
|
10
|
+
const [local, rest] = splitProps(props, ["errors", "onClearErrors", "onFormSubmit", "validationMode"]);
|
|
11
|
+
const made = controller(createForm, () => ({
|
|
12
|
+
errors: local.errors,
|
|
13
|
+
validationMode: local.validationMode,
|
|
14
|
+
// Only when the caller takes the values: without it the form submits as a form does.
|
|
15
|
+
onFormSubmit: local.onFormSubmit ? (values, details) => local.onFormSubmit?.(values, details) : undefined,
|
|
16
|
+
onClearErrors: errors => local.onClearErrors?.(errors)
|
|
17
|
+
}));
|
|
18
|
+
return _$createComponent(FormContext.Provider, {
|
|
19
|
+
value: made,
|
|
20
|
+
get children() {
|
|
21
|
+
return _$createComponent(Part, _$mergeProps({
|
|
22
|
+
get part() {
|
|
23
|
+
return made.root;
|
|
24
|
+
},
|
|
25
|
+
tag: "form"
|
|
26
|
+
}, rest));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
2
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
3
|
+
import { defined } from "@kirana-ui/core";
|
|
4
|
+
import { createComputed, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
5
|
+
import { positioned } from "./popover.js";
|
|
6
|
+
import { Part, Portal as BodyPortal, controller } from "./runtime.js";
|
|
7
|
+
/** The parts of a popup the pointer opens: a tooltip's, a hover card's. */
|
|
8
|
+
export function hoverPopup(name, create, triggerTag) {
|
|
9
|
+
const Context = createContext();
|
|
10
|
+
function use() {
|
|
11
|
+
const made = useContext(Context);
|
|
12
|
+
if (!made) throw new Error(`A ${name} part must be inside <${name}.Root>`);
|
|
13
|
+
return made;
|
|
14
|
+
}
|
|
15
|
+
function Root(props) {
|
|
16
|
+
const generated = createUniqueId();
|
|
17
|
+
const made = controller(create, () => ({
|
|
18
|
+
id: props.id ?? generated,
|
|
19
|
+
open: props.open,
|
|
20
|
+
defaultOpen: props.defaultOpen,
|
|
21
|
+
delay: props.delay,
|
|
22
|
+
closeDelay: props.closeDelay,
|
|
23
|
+
disabled: props.disabled,
|
|
24
|
+
onOpenChange: (open, details) => props.onOpenChange?.(open, details)
|
|
25
|
+
}));
|
|
26
|
+
return _$createComponent(Context.Provider, {
|
|
27
|
+
value: made,
|
|
28
|
+
get children() {
|
|
29
|
+
return props.children;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const Portal = props => _$createComponent(BodyPortal, {
|
|
34
|
+
get mounted() {
|
|
35
|
+
return use().mounted;
|
|
36
|
+
},
|
|
37
|
+
get children() {
|
|
38
|
+
return props.children;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
function Positioner(props) {
|
|
42
|
+
const made = use();
|
|
43
|
+
return _$createComponent(Part, _$mergeProps({
|
|
44
|
+
get part() {
|
|
45
|
+
return made.positioner;
|
|
46
|
+
},
|
|
47
|
+
tag: "div"
|
|
48
|
+
}, () => positioned(props, made.positioning)));
|
|
49
|
+
}
|
|
50
|
+
const part = (key, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
51
|
+
get part() {
|
|
52
|
+
return use()[key];
|
|
53
|
+
},
|
|
54
|
+
tag: tag
|
|
55
|
+
}, props));
|
|
56
|
+
/** `delay` and `closeDelay` here come before the root's. */
|
|
57
|
+
function Trigger(props) {
|
|
58
|
+
const [local, rest] = splitProps(props, ["delay", "closeDelay"]);
|
|
59
|
+
const made = use();
|
|
60
|
+
createComputed(() => made.timing.set(defined({
|
|
61
|
+
...local
|
|
62
|
+
})));
|
|
63
|
+
return _$createComponent(Part, _$mergeProps({
|
|
64
|
+
get part() {
|
|
65
|
+
return made.trigger;
|
|
66
|
+
},
|
|
67
|
+
tag: triggerTag
|
|
68
|
+
}, rest));
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
Root,
|
|
72
|
+
Portal,
|
|
73
|
+
Positioner,
|
|
74
|
+
Trigger,
|
|
75
|
+
Popup: part("popup", "div"),
|
|
76
|
+
Arrow: part("arrow", "div")
|
|
77
|
+
};
|
|
78
|
+
}
|
package/dom/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export { Accordion } from "./accordion.js";
|
|
2
|
+
export { Checkbox } from "./checkbox.js";
|
|
3
|
+
export { Collapsible } from "./collapsible.js";
|
|
4
|
+
export { AlertDialog, Dialog, Drawer } from "./dialog.js";
|
|
5
|
+
export { MessageScroller } from "./message-scroller.js";
|
|
6
|
+
export { HoverCard } from "./hover-card.js";
|
|
7
|
+
export { Combobox } from "./combobox.js";
|
|
8
|
+
export { Listbox } from "./listbox.js";
|
|
9
|
+
export { ContextMenu, Menu } from "./menu.js";
|
|
10
|
+
export { Menubar } from "./menubar.js";
|
|
11
|
+
export { NavigationMenu } from "./navigation-menu.js";
|
|
12
|
+
export { Otp } from "./otp.js";
|
|
13
|
+
export { DateField } from "./date-field.js";
|
|
14
|
+
export { Input } from "./input.js";
|
|
15
|
+
export { Label } from "./label.js";
|
|
16
|
+
export { Command } from "./command.js";
|
|
17
|
+
export { NumberField } from "./number-field.js";
|
|
18
|
+
export { Autocomplete } from "./autocomplete.js";
|
|
19
|
+
export { Pagination } from "./pagination.js";
|
|
20
|
+
export { DatePicker } from "./date-picker.js";
|
|
21
|
+
export { Calendar } from "./calendar.js";
|
|
22
|
+
export { QrCode } from "./qr-code.js";
|
|
23
|
+
export { Autosize } from "./autosize.js";
|
|
24
|
+
export { Carousel } from "./carousel.js";
|
|
25
|
+
export { Toast, createToaster } from "./toast.js";
|
|
26
|
+
export { Resizable } from "./resizable.js";
|
|
27
|
+
export { Popover } from "./popover.js";
|
|
28
|
+
export { RadioGroup } from "./radio-group.js";
|
|
29
|
+
export { Select } from "./select.js";
|
|
30
|
+
export { Switch } from "./switch.js";
|
|
31
|
+
export { Tabs } from "./tabs.js";
|
|
32
|
+
export { Tooltip } from "./tooltip.js";
|
|
33
|
+
export { Avatar } from "./avatar.js";
|
|
34
|
+
export { Button } from "./button.js";
|
|
35
|
+
export { Meter } from "./meter.js";
|
|
36
|
+
export { Progress } from "./progress.js";
|
|
37
|
+
export { Separator } from "./separator.js";
|
|
38
|
+
export { Toggle } from "./toggle.js";
|
|
39
|
+
export { ToggleGroup } from "./toggle-group.js";
|
|
40
|
+
export { Toolbar } from "./toolbar.js";
|
|
41
|
+
export { ScrollArea } from "./scroll-area.js";
|
|
42
|
+
export { Slider } from "./slider.js";
|
|
43
|
+
export { Field } from "./field.js";
|
|
44
|
+
export { Fieldset } from "./fieldset.js";
|
|
45
|
+
export { Form } from "./form.js";
|
|
46
|
+
export { DirectionProvider, useDirection } from "./direction.js";
|
|
47
|
+
export { PortalProvider } from "./runtime.js";
|
package/dom/input.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { within } from "@kirana-ui/core";
|
|
4
|
+
import { createInput } from "@kirana-ui/core/input";
|
|
5
|
+
import { splitProps, useContext } from "solid-js";
|
|
6
|
+
import { FieldContext } from "./field-context.js";
|
|
7
|
+
import { Part, controller } from "./runtime.js";
|
|
8
|
+
/**
|
|
9
|
+
* An `<input>`; `as="textarea"` for a text area. It takes what an `<input>` takes, and inside
|
|
10
|
+
* a `<Field.Root>` it is the field's control.
|
|
11
|
+
*/
|
|
12
|
+
export function Input(props) {
|
|
13
|
+
const [local, rest] = splitProps(props, ["disabled", "onValueChange"]);
|
|
14
|
+
const made = controller(within(createInput, {
|
|
15
|
+
field: useContext(FieldContext)
|
|
16
|
+
}), () => ({
|
|
17
|
+
disabled: local.disabled,
|
|
18
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details)
|
|
19
|
+
}));
|
|
20
|
+
return _$createComponent(Part, _$mergeProps({
|
|
21
|
+
get part() {
|
|
22
|
+
return made.input;
|
|
23
|
+
},
|
|
24
|
+
tag: "input"
|
|
25
|
+
}, rest));
|
|
26
|
+
}
|
package/dom/label.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { createLabel } from "@kirana-ui/core/label";
|
|
4
|
+
import { useContext } from "solid-js";
|
|
5
|
+
import { FieldContext } from "./field-context.js";
|
|
6
|
+
import { Part } from "./runtime.js";
|
|
7
|
+
/** A `<label>`. Inside a `<Field.Root>` it is the field's label. */
|
|
8
|
+
export function Label(props) {
|
|
9
|
+
const made = createLabel({
|
|
10
|
+
field: useContext(FieldContext)
|
|
11
|
+
});
|
|
12
|
+
return _$createComponent(Part, _$mergeProps({
|
|
13
|
+
get part() {
|
|
14
|
+
return made.label;
|
|
15
|
+
},
|
|
16
|
+
tag: "label"
|
|
17
|
+
}, props));
|
|
18
|
+
}
|
package/dom/listbox.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { memo as _$memo } from "solid-js/web";
|
|
2
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
3
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
4
|
+
import { defined } from "@kirana-ui/core";
|
|
5
|
+
import { createListbox } from "@kirana-ui/core/listbox";
|
|
6
|
+
import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
|
|
7
|
+
import { Part, controller, fromSignal, toSignal } from "./runtime.js";
|
|
8
|
+
const Context = createContext();
|
|
9
|
+
const ItemContext = createContext();
|
|
10
|
+
const GroupContext = createContext();
|
|
11
|
+
function useListbox() {
|
|
12
|
+
const made = useContext(Context);
|
|
13
|
+
if (!made) throw new Error("A Listbox part must be inside <Listbox.Root>");
|
|
14
|
+
return made;
|
|
15
|
+
}
|
|
16
|
+
function Root(props) {
|
|
17
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "multiple", "disabled", "loop", "name", "form", "virtualized", "id"]);
|
|
18
|
+
const generated = createUniqueId();
|
|
19
|
+
const made = controller(createListbox, () => ({
|
|
20
|
+
id: local.id ?? generated,
|
|
21
|
+
value: local.value,
|
|
22
|
+
defaultValue: local.defaultValue,
|
|
23
|
+
multiple: local.multiple,
|
|
24
|
+
disabled: local.disabled,
|
|
25
|
+
loop: local.loop,
|
|
26
|
+
name: local.name,
|
|
27
|
+
form: local.form,
|
|
28
|
+
virtualized: local.virtualized,
|
|
29
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details)
|
|
30
|
+
}));
|
|
31
|
+
return _$createComponent(Context.Provider, {
|
|
32
|
+
value: made,
|
|
33
|
+
get children() {
|
|
34
|
+
return _$createComponent(Part, _$mergeProps({
|
|
35
|
+
get part() {
|
|
36
|
+
return made.root;
|
|
37
|
+
},
|
|
38
|
+
tag: "div"
|
|
39
|
+
}, rest));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function Item(props) {
|
|
44
|
+
const [local, rest] = splitProps(props, ["value", "disabled", "label", "index"]);
|
|
45
|
+
// An item is its value for as long as it is in the page.
|
|
46
|
+
const value = untrack(() => local.value);
|
|
47
|
+
const options = toSignal(() => ({
|
|
48
|
+
disabled: local.disabled,
|
|
49
|
+
label: local.label,
|
|
50
|
+
index: local.index
|
|
51
|
+
}));
|
|
52
|
+
const part = useListbox().item(value, () => defined(options.get()));
|
|
53
|
+
return _$createComponent(ItemContext.Provider, {
|
|
54
|
+
value: value,
|
|
55
|
+
get children() {
|
|
56
|
+
return _$createComponent(Part, _$mergeProps({
|
|
57
|
+
part: part,
|
|
58
|
+
tag: "div"
|
|
59
|
+
}, rest));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function ItemIndicator(props) {
|
|
64
|
+
const [local, rest] = splitProps(props, ["keepMounted"]);
|
|
65
|
+
const made = useListbox();
|
|
66
|
+
const value = useContext(ItemContext);
|
|
67
|
+
const selected = fromSignal(made.selected(value));
|
|
68
|
+
return _$createComponent(Show, {
|
|
69
|
+
get when() {
|
|
70
|
+
return selected() || local.keepMounted;
|
|
71
|
+
},
|
|
72
|
+
get children() {
|
|
73
|
+
return _$createComponent(Part, _$mergeProps({
|
|
74
|
+
get part() {
|
|
75
|
+
return made.indicator(value);
|
|
76
|
+
},
|
|
77
|
+
tag: "span"
|
|
78
|
+
}, rest));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function Group(props) {
|
|
83
|
+
const [local, rest] = splitProps(props, ["id"]);
|
|
84
|
+
const generated = createUniqueId();
|
|
85
|
+
const group = useListbox().group(untrack(() => local.id) ?? generated);
|
|
86
|
+
return _$createComponent(GroupContext.Provider, {
|
|
87
|
+
value: group,
|
|
88
|
+
get children() {
|
|
89
|
+
return _$createComponent(Part, _$mergeProps({
|
|
90
|
+
get part() {
|
|
91
|
+
return group.root;
|
|
92
|
+
},
|
|
93
|
+
tag: "div"
|
|
94
|
+
}, rest));
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function GroupLabel(props) {
|
|
99
|
+
const group = useContext(GroupContext);
|
|
100
|
+
if (!group) throw new Error("A Listbox.GroupLabel must be inside <Listbox.Group>");
|
|
101
|
+
return _$createComponent(Part, _$mergeProps({
|
|
102
|
+
get part() {
|
|
103
|
+
return group.label;
|
|
104
|
+
},
|
|
105
|
+
tag: "div"
|
|
106
|
+
}, props));
|
|
107
|
+
}
|
|
108
|
+
export const Listbox = {
|
|
109
|
+
Root,
|
|
110
|
+
Item,
|
|
111
|
+
ItemIndicator,
|
|
112
|
+
Group,
|
|
113
|
+
GroupLabel
|
|
114
|
+
};
|