@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/LICENSE
CHANGED
package/dom/accordion.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
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, within } from "@kirana-ui/core";
|
|
5
|
+
import { createAccordion } from "@kirana-ui/core/accordion";
|
|
6
|
+
import { Show, createContext, createUniqueId, onCleanup, onMount, splitProps, untrack, useContext } from "solid-js";
|
|
7
|
+
import { DirectionContext } from "./direction-context.js";
|
|
8
|
+
import { Part, controller, fromSignal, toSignal } from "./runtime.js";
|
|
9
|
+
const Context = createContext();
|
|
10
|
+
const ItemContext = createContext();
|
|
11
|
+
function useAccordion() {
|
|
12
|
+
const made = useContext(Context);
|
|
13
|
+
if (!made) throw new Error("An Accordion part must be inside <Accordion.Root>");
|
|
14
|
+
return made;
|
|
15
|
+
}
|
|
16
|
+
function useItem() {
|
|
17
|
+
const item = useContext(ItemContext);
|
|
18
|
+
if (!item) throw new Error("An Accordion part must be inside <Accordion.Item>");
|
|
19
|
+
return item;
|
|
20
|
+
}
|
|
21
|
+
function Root(props) {
|
|
22
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "multiple", "disabled", "orientation", "loop", "id"]);
|
|
23
|
+
const generated = createUniqueId();
|
|
24
|
+
const direction = useContext(DirectionContext);
|
|
25
|
+
const made = controller(within(createAccordion, {
|
|
26
|
+
direction
|
|
27
|
+
}), () => ({
|
|
28
|
+
id: local.id ?? generated,
|
|
29
|
+
value: local.value,
|
|
30
|
+
defaultValue: local.defaultValue,
|
|
31
|
+
multiple: local.multiple,
|
|
32
|
+
disabled: local.disabled,
|
|
33
|
+
orientation: local.orientation,
|
|
34
|
+
loop: local.loop,
|
|
35
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details)
|
|
36
|
+
}));
|
|
37
|
+
return _$createComponent(Context.Provider, {
|
|
38
|
+
value: made,
|
|
39
|
+
get children() {
|
|
40
|
+
return _$createComponent(Part, _$mergeProps({
|
|
41
|
+
get part() {
|
|
42
|
+
return made.root;
|
|
43
|
+
},
|
|
44
|
+
tag: "div"
|
|
45
|
+
}, rest));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function Item(props) {
|
|
50
|
+
const [local, rest] = splitProps(props, ["value", "disabled"]);
|
|
51
|
+
const options = toSignal(() => ({
|
|
52
|
+
disabled: local.disabled
|
|
53
|
+
}));
|
|
54
|
+
// An item is its value for as long as it is in the page.
|
|
55
|
+
const item = useAccordion().item(untrack(() => local.value), () => defined(options.get()));
|
|
56
|
+
onMount(() => onCleanup(item.mount()));
|
|
57
|
+
return _$createComponent(ItemContext.Provider, {
|
|
58
|
+
value: item,
|
|
59
|
+
get children() {
|
|
60
|
+
return _$createComponent(Part, _$mergeProps({
|
|
61
|
+
get part() {
|
|
62
|
+
return item.root;
|
|
63
|
+
},
|
|
64
|
+
tag: "div"
|
|
65
|
+
}, rest));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const Header = props => _$createComponent(Part, _$mergeProps({
|
|
70
|
+
get part() {
|
|
71
|
+
return useItem().header;
|
|
72
|
+
},
|
|
73
|
+
tag: "h3"
|
|
74
|
+
}, props));
|
|
75
|
+
const Trigger = props => _$createComponent(Part, _$mergeProps({
|
|
76
|
+
get part() {
|
|
77
|
+
return useItem().trigger;
|
|
78
|
+
},
|
|
79
|
+
tag: "button"
|
|
80
|
+
}, props));
|
|
81
|
+
/** `keepMounted` keeps the closed panel in the page, `hidden`. */
|
|
82
|
+
function Panel(props) {
|
|
83
|
+
const [local, rest] = splitProps(props, ["keepMounted"]);
|
|
84
|
+
const item = useItem();
|
|
85
|
+
const mounted = fromSignal(item.mounted);
|
|
86
|
+
return _$createComponent(Show, {
|
|
87
|
+
get when() {
|
|
88
|
+
return mounted() || local.keepMounted;
|
|
89
|
+
},
|
|
90
|
+
get children() {
|
|
91
|
+
return _$createComponent(Part, _$mergeProps({
|
|
92
|
+
get part() {
|
|
93
|
+
return item.panel;
|
|
94
|
+
},
|
|
95
|
+
tag: "div"
|
|
96
|
+
}, rest));
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export const Accordion = {
|
|
101
|
+
Root,
|
|
102
|
+
Item,
|
|
103
|
+
Header,
|
|
104
|
+
Trigger,
|
|
105
|
+
Panel
|
|
106
|
+
};
|
package/dom/autosize.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { createAutosize } from "@kirana-ui/core/autosize";
|
|
4
|
+
import { Part, controller } from "./runtime.js";
|
|
5
|
+
/** A `<textarea>` as tall as its text. It takes what a `<textarea>` takes. */
|
|
6
|
+
function Textarea(props) {
|
|
7
|
+
const made = controller(createAutosize, () => ({
|
|
8
|
+
value: props.value
|
|
9
|
+
}));
|
|
10
|
+
return _$createComponent(Part, _$mergeProps({
|
|
11
|
+
get part() {
|
|
12
|
+
return made.textarea;
|
|
13
|
+
},
|
|
14
|
+
tag: "textarea"
|
|
15
|
+
}, props));
|
|
16
|
+
}
|
|
17
|
+
export const Autosize = {
|
|
18
|
+
Textarea
|
|
19
|
+
};
|
package/dom/avatar.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { createAvatar } from "@kirana-ui/core/avatar";
|
|
4
|
+
import { Show, createComputed, createContext, splitProps, useContext } from "solid-js";
|
|
5
|
+
import { Part, controller, fromSignal } from "./runtime.js";
|
|
6
|
+
const Context = createContext();
|
|
7
|
+
function useAvatar() {
|
|
8
|
+
const made = useContext(Context);
|
|
9
|
+
if (!made) throw new Error("An Avatar part must be inside <Avatar.Root>");
|
|
10
|
+
return made;
|
|
11
|
+
}
|
|
12
|
+
function Root(props) {
|
|
13
|
+
const made = controller(createAvatar, () => ({}));
|
|
14
|
+
return _$createComponent(Context.Provider, {
|
|
15
|
+
value: made,
|
|
16
|
+
get children() {
|
|
17
|
+
return _$createComponent(Part, _$mergeProps({
|
|
18
|
+
get part() {
|
|
19
|
+
return made.root;
|
|
20
|
+
},
|
|
21
|
+
tag: "span"
|
|
22
|
+
}, props));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** The picture: in the page once `src` has loaded. */
|
|
27
|
+
function Image(props) {
|
|
28
|
+
const [local, rest] = splitProps(props, ["src"]);
|
|
29
|
+
const made = useAvatar();
|
|
30
|
+
createComputed(() => made.source.set(local.src));
|
|
31
|
+
const status = fromSignal(made.status);
|
|
32
|
+
return _$createComponent(Show, {
|
|
33
|
+
get when() {
|
|
34
|
+
return status() === "loaded";
|
|
35
|
+
},
|
|
36
|
+
get children() {
|
|
37
|
+
return _$createComponent(Part, _$mergeProps({
|
|
38
|
+
get part() {
|
|
39
|
+
return made.image;
|
|
40
|
+
},
|
|
41
|
+
tag: "img"
|
|
42
|
+
}, rest));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** What shows until the picture has loaded, or when it cannot. */
|
|
47
|
+
function Fallback(props) {
|
|
48
|
+
const made = useAvatar();
|
|
49
|
+
const status = fromSignal(made.status);
|
|
50
|
+
return _$createComponent(Show, {
|
|
51
|
+
get when() {
|
|
52
|
+
return status() !== "loaded";
|
|
53
|
+
},
|
|
54
|
+
get children() {
|
|
55
|
+
return _$createComponent(Part, _$mergeProps({
|
|
56
|
+
get part() {
|
|
57
|
+
return made.fallback;
|
|
58
|
+
},
|
|
59
|
+
tag: "span"
|
|
60
|
+
}, props));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export const Avatar = {
|
|
65
|
+
Root,
|
|
66
|
+
Image,
|
|
67
|
+
Fallback
|
|
68
|
+
};
|
package/dom/button.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 { createButton } from "@kirana-ui/core/button";
|
|
4
|
+
import { splitProps } from "solid-js";
|
|
5
|
+
import { Part, controller } from "./runtime.js";
|
|
6
|
+
/** A `<button>`, or with `as` and `nativeButton={false}` another element that acts as one. */
|
|
7
|
+
export function Button(props) {
|
|
8
|
+
const [local, rest] = splitProps(props, ["disabled", "focusableWhenDisabled", "nativeButton"]);
|
|
9
|
+
const made = controller(createButton, () => ({
|
|
10
|
+
...local
|
|
11
|
+
}));
|
|
12
|
+
return _$createComponent(Part, _$mergeProps({
|
|
13
|
+
get part() {
|
|
14
|
+
return made.root;
|
|
15
|
+
},
|
|
16
|
+
tag: "button"
|
|
17
|
+
}, rest));
|
|
18
|
+
}
|
package/dom/calendar.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
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 { within } from "@kirana-ui/core";
|
|
5
|
+
import { createCalendar } from "@kirana-ui/core/calendar";
|
|
6
|
+
import { For, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
7
|
+
import { DirectionContext } from "./direction-context.js";
|
|
8
|
+
import { Part, controller, fromSignal } from "./runtime.js";
|
|
9
|
+
const Context = createContext();
|
|
10
|
+
/** For a component made of this one's parts: a date picker. */
|
|
11
|
+
export { Context as CalendarContext };
|
|
12
|
+
function useCalendar() {
|
|
13
|
+
const made = useContext(Context);
|
|
14
|
+
if (!made) throw new Error("A Calendar part must be inside <Calendar.Root>");
|
|
15
|
+
return made;
|
|
16
|
+
}
|
|
17
|
+
function Root(props) {
|
|
18
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "mode", "defaultFocusedValue", "onMonthChange", "locale", "calendarSystem", "min", "max", "isDateUnavailable", "disabled", "readOnly", "fixedWeeks", "id"]);
|
|
19
|
+
const generated = createUniqueId();
|
|
20
|
+
const direction = useContext(DirectionContext);
|
|
21
|
+
const made = controller(within(createCalendar, {
|
|
22
|
+
direction
|
|
23
|
+
}), () => ({
|
|
24
|
+
id: local.id ?? generated,
|
|
25
|
+
value: local.value,
|
|
26
|
+
defaultValue: local.defaultValue,
|
|
27
|
+
mode: local.mode,
|
|
28
|
+
defaultFocusedValue: local.defaultFocusedValue,
|
|
29
|
+
locale: local.locale,
|
|
30
|
+
calendarSystem: local.calendarSystem,
|
|
31
|
+
min: local.min,
|
|
32
|
+
max: local.max,
|
|
33
|
+
isDateUnavailable: local.isDateUnavailable,
|
|
34
|
+
disabled: local.disabled,
|
|
35
|
+
readOnly: local.readOnly,
|
|
36
|
+
fixedWeeks: local.fixedWeeks,
|
|
37
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
38
|
+
onMonthChange: month => local.onMonthChange?.(month)
|
|
39
|
+
}));
|
|
40
|
+
return _$createComponent(Context.Provider, {
|
|
41
|
+
value: made,
|
|
42
|
+
get children() {
|
|
43
|
+
return _$createComponent(Part, _$mergeProps({
|
|
44
|
+
get part() {
|
|
45
|
+
return made.root;
|
|
46
|
+
},
|
|
47
|
+
tag: "div"
|
|
48
|
+
}, rest));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** Names the month shown, unless it is given something else to say. */
|
|
53
|
+
function Heading(props) {
|
|
54
|
+
const made = useCalendar();
|
|
55
|
+
const title = fromSignal(made.title);
|
|
56
|
+
return _$createComponent(Part, _$mergeProps({
|
|
57
|
+
get part() {
|
|
58
|
+
return made.heading;
|
|
59
|
+
},
|
|
60
|
+
tag: "div"
|
|
61
|
+
}, props, {
|
|
62
|
+
get children() {
|
|
63
|
+
return props.children ?? title();
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
const Previous = props => _$createComponent(Part, _$mergeProps({
|
|
68
|
+
get part() {
|
|
69
|
+
return useCalendar().previous;
|
|
70
|
+
},
|
|
71
|
+
tag: "button"
|
|
72
|
+
}, props));
|
|
73
|
+
const Next = props => _$createComponent(Part, _$mergeProps({
|
|
74
|
+
get part() {
|
|
75
|
+
return useCalendar().next;
|
|
76
|
+
},
|
|
77
|
+
tag: "button"
|
|
78
|
+
}, props));
|
|
79
|
+
const Grid = props => _$createComponent(Part, _$mergeProps({
|
|
80
|
+
get part() {
|
|
81
|
+
return useCalendar().grid;
|
|
82
|
+
},
|
|
83
|
+
tag: "table"
|
|
84
|
+
}, props));
|
|
85
|
+
/** Draws its child once for each day of the week, in the locale's order. */
|
|
86
|
+
function Weekdays(props) {
|
|
87
|
+
const weekdays = fromSignal(useCalendar().weekdays);
|
|
88
|
+
return _$createComponent(For, {
|
|
89
|
+
get each() {
|
|
90
|
+
return weekdays();
|
|
91
|
+
},
|
|
92
|
+
children: weekday => props.children(weekday)
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/** Draws its child once for each week of the month shown. */
|
|
96
|
+
function Weeks(props) {
|
|
97
|
+
const weeks = fromSignal(useCalendar().weeks);
|
|
98
|
+
return _$createComponent(For, {
|
|
99
|
+
get each() {
|
|
100
|
+
return weeks();
|
|
101
|
+
},
|
|
102
|
+
children: week => props.children(week)
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function HeadCell(props) {
|
|
106
|
+
const [local, rest] = splitProps(props, ["weekday"]);
|
|
107
|
+
const part = useCalendar().headCell(local.weekday);
|
|
108
|
+
return _$createComponent(Part, _$mergeProps({
|
|
109
|
+
part: part,
|
|
110
|
+
tag: "th"
|
|
111
|
+
}, rest));
|
|
112
|
+
}
|
|
113
|
+
function Cell(props) {
|
|
114
|
+
const [local, rest] = splitProps(props, ["date"]);
|
|
115
|
+
// A cell is its day for as long as it is in the page.
|
|
116
|
+
const part = useCalendar().cell(local.date);
|
|
117
|
+
return _$createComponent(Part, _$mergeProps({
|
|
118
|
+
part: part,
|
|
119
|
+
tag: "td"
|
|
120
|
+
}, rest));
|
|
121
|
+
}
|
|
122
|
+
function Day(props) {
|
|
123
|
+
const [local, rest] = splitProps(props, ["date"]);
|
|
124
|
+
const part = useCalendar().day(local.date);
|
|
125
|
+
return _$createComponent(Part, _$mergeProps({
|
|
126
|
+
part: part,
|
|
127
|
+
tag: "button"
|
|
128
|
+
}, rest));
|
|
129
|
+
}
|
|
130
|
+
export const Calendar = {
|
|
131
|
+
Root,
|
|
132
|
+
Heading,
|
|
133
|
+
Previous,
|
|
134
|
+
Next,
|
|
135
|
+
Grid,
|
|
136
|
+
Weekdays,
|
|
137
|
+
HeadCell,
|
|
138
|
+
Weeks,
|
|
139
|
+
Cell,
|
|
140
|
+
Day
|
|
141
|
+
};
|
package/dom/carousel.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
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 { createCarousel } from "@kirana-ui/core/carousel";
|
|
5
|
+
import { createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
6
|
+
import { DirectionContext } from "./direction-context.js";
|
|
7
|
+
import { Part, controller } from "./runtime.js";
|
|
8
|
+
const Context = createContext();
|
|
9
|
+
function useCarousel() {
|
|
10
|
+
const made = useContext(Context);
|
|
11
|
+
if (!made) throw new Error("A Carousel part must be inside <Carousel.Root>");
|
|
12
|
+
return made;
|
|
13
|
+
}
|
|
14
|
+
function Root(props) {
|
|
15
|
+
const [local, rest] = splitProps(props, ["index", "defaultIndex", "onIndexChange", "orientation", "loop", "id"]);
|
|
16
|
+
const generated = createUniqueId();
|
|
17
|
+
const direction = useContext(DirectionContext);
|
|
18
|
+
const made = controller(within(createCarousel, {
|
|
19
|
+
direction
|
|
20
|
+
}), () => ({
|
|
21
|
+
id: local.id ?? generated,
|
|
22
|
+
index: local.index,
|
|
23
|
+
defaultIndex: local.defaultIndex,
|
|
24
|
+
orientation: local.orientation,
|
|
25
|
+
loop: local.loop,
|
|
26
|
+
onIndexChange: (index, details) => local.onIndexChange?.(index, details)
|
|
27
|
+
}));
|
|
28
|
+
return _$createComponent(Context.Provider, {
|
|
29
|
+
value: made,
|
|
30
|
+
get children() {
|
|
31
|
+
return _$createComponent(Part, _$mergeProps({
|
|
32
|
+
get part() {
|
|
33
|
+
return made.root;
|
|
34
|
+
},
|
|
35
|
+
tag: "div"
|
|
36
|
+
}, rest));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const Viewport = props => _$createComponent(Part, _$mergeProps({
|
|
41
|
+
get part() {
|
|
42
|
+
return useCarousel().viewport;
|
|
43
|
+
},
|
|
44
|
+
tag: "div"
|
|
45
|
+
}, props));
|
|
46
|
+
function Item(props) {
|
|
47
|
+
const [local, rest] = splitProps(props, ["index"]);
|
|
48
|
+
// A slide is its place for as long as it is in the page.
|
|
49
|
+
const part = useCarousel().item(local.index);
|
|
50
|
+
return _$createComponent(Part, _$mergeProps({
|
|
51
|
+
part: part,
|
|
52
|
+
tag: "div"
|
|
53
|
+
}, rest));
|
|
54
|
+
}
|
|
55
|
+
const Previous = props => _$createComponent(Part, _$mergeProps({
|
|
56
|
+
get part() {
|
|
57
|
+
return useCarousel().previous;
|
|
58
|
+
},
|
|
59
|
+
tag: "button"
|
|
60
|
+
}, props));
|
|
61
|
+
const Next = props => _$createComponent(Part, _$mergeProps({
|
|
62
|
+
get part() {
|
|
63
|
+
return useCarousel().next;
|
|
64
|
+
},
|
|
65
|
+
tag: "button"
|
|
66
|
+
}, props));
|
|
67
|
+
function Indicator(props) {
|
|
68
|
+
const [local, rest] = splitProps(props, ["index"]);
|
|
69
|
+
// A button is its slide for as long as it is in the page.
|
|
70
|
+
const part = useCarousel().indicator(local.index);
|
|
71
|
+
return _$createComponent(Part, _$mergeProps({
|
|
72
|
+
part: part,
|
|
73
|
+
tag: "button"
|
|
74
|
+
}, rest));
|
|
75
|
+
}
|
|
76
|
+
export const Carousel = {
|
|
77
|
+
Root,
|
|
78
|
+
Viewport,
|
|
79
|
+
Item,
|
|
80
|
+
Previous,
|
|
81
|
+
Next,
|
|
82
|
+
Indicator
|
|
83
|
+
};
|
package/dom/checkbox.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
2
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
3
|
+
import { memo as _$memo } from "solid-js/web";
|
|
4
|
+
import { within } from "@kirana-ui/core";
|
|
5
|
+
import { createCheckbox } from "@kirana-ui/core/checkbox";
|
|
6
|
+
import { Show, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
7
|
+
import { FieldContext } from "./field-context.js";
|
|
8
|
+
import { Part, controller, fromSignal } from "./runtime.js";
|
|
9
|
+
const Context = createContext();
|
|
10
|
+
function useCheckbox() {
|
|
11
|
+
const made = useContext(Context);
|
|
12
|
+
if (!made) throw new Error("A Checkbox part must be inside <Checkbox.Root>");
|
|
13
|
+
return made;
|
|
14
|
+
}
|
|
15
|
+
function Root(props) {
|
|
16
|
+
const [local, rest] = splitProps(props, ["checked", "defaultChecked", "onCheckedChange", "indeterminate", "disabled", "readOnly", "required", "name", "form", "value", "id", "children"]);
|
|
17
|
+
const generated = createUniqueId();
|
|
18
|
+
const field = useContext(FieldContext);
|
|
19
|
+
const made = controller(within(createCheckbox, {
|
|
20
|
+
field
|
|
21
|
+
}), () => ({
|
|
22
|
+
id: local.id ?? generated,
|
|
23
|
+
checked: local.checked,
|
|
24
|
+
defaultChecked: local.defaultChecked,
|
|
25
|
+
indeterminate: local.indeterminate,
|
|
26
|
+
disabled: local.disabled,
|
|
27
|
+
readOnly: local.readOnly,
|
|
28
|
+
required: local.required,
|
|
29
|
+
name: local.name,
|
|
30
|
+
form: local.form,
|
|
31
|
+
value: local.value,
|
|
32
|
+
onCheckedChange: (checked, details) => local.onCheckedChange?.(checked, details)
|
|
33
|
+
}));
|
|
34
|
+
return _$createComponent(Context.Provider, {
|
|
35
|
+
value: made,
|
|
36
|
+
get children() {
|
|
37
|
+
return _$createComponent(Part, _$mergeProps({
|
|
38
|
+
get part() {
|
|
39
|
+
return made.root;
|
|
40
|
+
},
|
|
41
|
+
tag: "span"
|
|
42
|
+
}, rest, {
|
|
43
|
+
get children() {
|
|
44
|
+
return [_$memo(() => local.children), _$createComponent(Part, {
|
|
45
|
+
get part() {
|
|
46
|
+
return made.input;
|
|
47
|
+
},
|
|
48
|
+
tag: "input"
|
|
49
|
+
})];
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** `keepMounted` keeps the mark in the page while the box is unchecked. */
|
|
56
|
+
function Indicator(props) {
|
|
57
|
+
const [local, rest] = splitProps(props, ["keepMounted"]);
|
|
58
|
+
const made = useCheckbox();
|
|
59
|
+
const mounted = fromSignal(made.indicatorMounted);
|
|
60
|
+
return _$createComponent(Show, {
|
|
61
|
+
get when() {
|
|
62
|
+
return mounted() || local.keepMounted;
|
|
63
|
+
},
|
|
64
|
+
get children() {
|
|
65
|
+
return _$createComponent(Part, _$mergeProps({
|
|
66
|
+
get part() {
|
|
67
|
+
return made.indicator;
|
|
68
|
+
},
|
|
69
|
+
tag: "span"
|
|
70
|
+
}, rest));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export const Checkbox = {
|
|
75
|
+
Root,
|
|
76
|
+
Indicator
|
|
77
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { createCollapsible } from "@kirana-ui/core/collapsible";
|
|
5
|
+
import { Show, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
6
|
+
import { Part, controller, fromSignal } from "./runtime.js";
|
|
7
|
+
const Context = createContext();
|
|
8
|
+
function useCollapsible() {
|
|
9
|
+
const made = useContext(Context);
|
|
10
|
+
if (!made) throw new Error("A Collapsible part must be inside <Collapsible.Root>");
|
|
11
|
+
return made;
|
|
12
|
+
}
|
|
13
|
+
function Root(props) {
|
|
14
|
+
const [local, rest] = splitProps(props, ["open", "defaultOpen", "onOpenChange", "disabled", "id"]);
|
|
15
|
+
const generated = createUniqueId();
|
|
16
|
+
const made = controller(createCollapsible, () => ({
|
|
17
|
+
id: local.id ?? generated,
|
|
18
|
+
open: local.open,
|
|
19
|
+
defaultOpen: local.defaultOpen,
|
|
20
|
+
disabled: local.disabled,
|
|
21
|
+
onOpenChange: (open, details) => local.onOpenChange?.(open, details)
|
|
22
|
+
}));
|
|
23
|
+
return _$createComponent(Context.Provider, {
|
|
24
|
+
value: made,
|
|
25
|
+
get children() {
|
|
26
|
+
return _$createComponent(Part, _$mergeProps({
|
|
27
|
+
get part() {
|
|
28
|
+
return made.root;
|
|
29
|
+
},
|
|
30
|
+
tag: "div"
|
|
31
|
+
}, rest));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const Trigger = props => _$createComponent(Part, _$mergeProps({
|
|
36
|
+
get part() {
|
|
37
|
+
return useCollapsible().trigger;
|
|
38
|
+
},
|
|
39
|
+
tag: "button"
|
|
40
|
+
}, props));
|
|
41
|
+
/** `keepMounted` keeps the closed panel in the page, `hidden`. */
|
|
42
|
+
function Panel(props) {
|
|
43
|
+
const [local, rest] = splitProps(props, ["keepMounted"]);
|
|
44
|
+
const made = useCollapsible();
|
|
45
|
+
const mounted = fromSignal(made.mounted);
|
|
46
|
+
return _$createComponent(Show, {
|
|
47
|
+
get when() {
|
|
48
|
+
return mounted() || local.keepMounted;
|
|
49
|
+
},
|
|
50
|
+
get children() {
|
|
51
|
+
return _$createComponent(Part, _$mergeProps({
|
|
52
|
+
get part() {
|
|
53
|
+
return made.panel;
|
|
54
|
+
},
|
|
55
|
+
tag: "div"
|
|
56
|
+
}, rest));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export const Collapsible = {
|
|
61
|
+
Root,
|
|
62
|
+
Trigger,
|
|
63
|
+
Panel
|
|
64
|
+
};
|