@kirana-ui/solid 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dom/accordion.js +9 -6
- package/dom/agent.js +3 -0
- package/dom/autocomplete.js +2 -0
- package/dom/autosize.js +19 -0
- package/dom/avatar.js +3 -3
- package/dom/button.js +1 -1
- package/dom/calendar.js +145 -0
- package/dom/carousel.js +83 -0
- package/dom/checkbox.js +5 -4
- package/dom/collapsible.js +3 -3
- package/dom/combobox.js +289 -0
- package/dom/command.js +129 -0
- package/dom/context-menu.js +2 -0
- package/dom/date-field.js +90 -0
- package/dom/date-picker.js +103 -0
- package/dom/dialog.js +32 -1
- package/dom/drawer.js +2 -0
- package/dom/field.js +3 -3
- package/dom/fieldset.js +2 -2
- package/dom/form.js +1 -1
- package/dom/hover-popup.js +19 -4
- package/dom/index.js +26 -1
- package/dom/input.js +26 -0
- package/dom/label.js +18 -0
- package/dom/listbox.js +114 -0
- package/dom/menu.js +261 -0
- package/dom/menubar-context.js +3 -0
- package/dom/menubar.js +33 -0
- package/dom/message-scroller.js +56 -0
- package/dom/navigation-menu.js +147 -0
- package/dom/number-field.js +82 -0
- package/dom/otp.js +95 -0
- package/dom/pagination.js +74 -0
- package/dom/popover.js +22 -7
- package/dom/qr-code.js +48 -0
- package/dom/radio-group.js +6 -5
- package/dom/resizable.js +65 -0
- package/dom/runtime.js +59 -9
- package/dom/scroll-area.js +99 -0
- package/dom/select.js +91 -15
- package/dom/separator.js +1 -1
- package/dom/slider.js +11 -8
- package/dom/switch.js +5 -4
- package/dom/tabs.js +5 -5
- package/dom/testing.js +3 -0
- package/dom/toast.js +150 -0
- package/dom/toggle-group.js +37 -0
- package/dom/toggle.js +12 -4
- package/dom/toolbar-context.js +5 -0
- package/dom/toolbar.js +71 -0
- package/dom/value-bar.js +3 -3
- package/llms.txt +3202 -0
- package/package.json +236 -2
- package/server/accordion.js +9 -6
- package/server/agent.js +3 -0
- package/server/autocomplete.js +2 -0
- package/server/autosize.js +19 -0
- package/server/avatar.js +3 -3
- package/server/button.js +1 -1
- package/server/calendar.js +144 -0
- package/server/carousel.js +83 -0
- package/server/checkbox.js +5 -4
- package/server/collapsible.js +3 -3
- package/server/combobox.js +289 -0
- package/server/command.js +129 -0
- package/server/context-menu.js +2 -0
- package/server/date-field.js +90 -0
- package/server/date-picker.js +103 -0
- package/server/dialog.js +32 -1
- package/server/drawer.js +2 -0
- package/server/field.js +3 -3
- package/server/fieldset.js +2 -2
- package/server/form.js +1 -1
- package/server/hover-popup.js +19 -4
- package/server/index.js +26 -1
- package/server/input.js +26 -0
- package/server/label.js +18 -0
- package/server/listbox.js +114 -0
- package/server/menu.js +261 -0
- package/server/menubar-context.js +3 -0
- package/server/menubar.js +33 -0
- package/server/message-scroller.js +56 -0
- package/server/navigation-menu.js +147 -0
- package/server/number-field.js +81 -0
- package/server/otp.js +94 -0
- package/server/pagination.js +74 -0
- package/server/popover.js +22 -7
- package/server/qr-code.js +48 -0
- package/server/radio-group.js +6 -5
- package/server/resizable.js +65 -0
- package/server/runtime.js +58 -8
- package/server/scroll-area.js +99 -0
- package/server/select.js +91 -15
- package/server/separator.js +1 -1
- package/server/slider.js +11 -8
- package/server/switch.js +5 -4
- package/server/tabs.js +5 -5
- package/server/testing.js +3 -0
- package/server/toast.js +150 -0
- package/server/toggle-group.js +37 -0
- package/server/toggle.js +12 -4
- package/server/toolbar-context.js +5 -0
- package/server/toolbar.js +71 -0
- package/server/value-bar.js +3 -3
- package/skills/kirana-ui-primitives/SKILL.md +142 -0
- package/src/accordion.jsx +10 -7
- package/src/agent.js +3 -0
- package/src/autocomplete.jsx +2 -0
- package/src/autosize.jsx +8 -0
- package/src/avatar.jsx +3 -3
- package/src/button.jsx +1 -1
- package/src/calendar.jsx +108 -0
- package/src/carousel.jsx +51 -0
- package/src/checkbox.jsx +5 -3
- package/src/collapsible.jsx +3 -3
- package/src/combobox.jsx +187 -0
- package/src/command.jsx +81 -0
- package/src/context-menu.js +2 -0
- package/src/date-field.jsx +71 -0
- package/src/date-picker.jsx +72 -0
- package/src/dialog.jsx +27 -1
- package/src/drawer.js +2 -0
- package/src/field.jsx +3 -3
- package/src/fieldset.jsx +2 -2
- package/src/form.jsx +1 -1
- package/src/hover-popup.jsx +12 -4
- package/src/index.js +26 -1
- package/src/input.jsx +17 -0
- package/src/label.jsx +9 -0
- package/src/listbox.jsx +81 -0
- package/src/menu.jsx +164 -0
- package/src/menubar-context.js +3 -0
- package/src/menubar.jsx +21 -0
- package/src/message-scroller.jsx +27 -0
- package/src/navigation-menu.jsx +96 -0
- package/src/number-field.jsx +75 -0
- package/src/otp.jsx +73 -0
- package/src/pagination.jsx +60 -0
- package/src/popover.jsx +22 -4
- package/src/qr-code.jsx +25 -0
- package/src/radio-group.jsx +7 -5
- package/src/resizable.jsx +46 -0
- package/src/runtime.jsx +54 -9
- package/src/scroll-area.jsx +53 -0
- package/src/select.jsx +72 -14
- package/src/separator.jsx +1 -1
- package/src/slider.jsx +13 -8
- package/src/switch.jsx +5 -3
- package/src/tabs.jsx +6 -6
- package/src/testing.js +3 -0
- package/src/toast.jsx +86 -0
- package/src/toggle-group.jsx +32 -0
- package/src/toggle.jsx +9 -3
- package/src/toolbar-context.js +5 -0
- package/src/toolbar.jsx +43 -0
- package/src/value-bar.jsx +3 -3
- package/types/accordion.d.ts +21 -19
- package/types/agent.d.ts +1 -0
- package/types/alert-dialog.d.ts +1 -0
- package/types/autocomplete.d.ts +2 -0
- package/types/autosize.d.ts +11 -0
- package/types/avatar.d.ts +12 -5
- package/types/button.d.ts +4 -2
- package/types/calendar.d.ts +57 -0
- package/types/carousel.d.ts +34 -0
- package/types/checkbox.d.ts +10 -6
- package/types/collapsible.d.ts +11 -7
- package/types/combobox.d.ts +105 -0
- package/types/command.d.ts +55 -0
- package/types/context-menu.d.ts +2 -0
- package/types/date-field.d.ts +34 -0
- package/types/date-picker.d.ts +40 -0
- package/types/dialog.d.ts +52 -20
- package/types/direction.d.ts +1 -0
- package/types/drawer.d.ts +2 -0
- package/types/field.d.ts +19 -11
- package/types/fieldset.d.ts +8 -3
- package/types/form.d.ts +5 -2
- package/types/hover-card.d.ts +16 -7
- package/types/hover-popup.d.ts +23 -10
- package/types/index.d.ts +39 -2
- package/types/input.d.ts +13 -0
- package/types/label.d.ts +7 -0
- package/types/listbox.d.ts +36 -0
- package/types/menu.d.ts +105 -0
- package/types/menubar-context.d.ts +3 -0
- package/types/menubar.d.ts +12 -0
- package/types/message-scroller.d.ts +22 -0
- package/types/meter.d.ts +16 -7
- package/types/navigation-menu.d.ts +50 -0
- package/types/number-field.d.ts +22 -0
- package/types/otp.d.ts +39 -0
- package/types/pagination.d.ts +31 -0
- package/types/popover.d.ts +41 -13
- package/types/progress.d.ts +16 -7
- package/types/qr-code.d.ts +20 -0
- package/types/radio-group.d.ts +15 -16
- package/types/resizable.d.ts +29 -0
- package/types/runtime.d.ts +53 -11
- package/types/scroll-area.d.ts +28 -0
- package/types/select.d.ts +66 -33
- package/types/separator.d.ts +5 -3
- package/types/slider.d.ts +25 -13
- package/types/switch.d.ts +8 -4
- package/types/tabs.d.ts +20 -16
- package/types/testing.d.ts +1 -0
- package/types/toast.d.ts +57 -0
- package/types/toggle-group.d.ts +9 -0
- package/types/toggle.d.ts +6 -3
- package/types/toolbar-context.d.ts +6 -0
- package/types/toolbar.d.ts +28 -0
- package/types/tooltip.d.ts +16 -7
- package/types/value-bar.d.ts +21 -10
|
@@ -0,0 +1,147 @@
|
|
|
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 { createNavigationMenu } from "@kirana-ui/core/navigation-menu";
|
|
6
|
+
import { Show, createContext, createUniqueId, onCleanup, onMount, splitProps, untrack, useContext } from "solid-js";
|
|
7
|
+
import { DirectionContext } from "./direction-context.js";
|
|
8
|
+
import { positioned } from "./popover.js";
|
|
9
|
+
import { Into, Part, Portal as BodyPortal, controller, fromSignal, toSignal } from "./runtime.js";
|
|
10
|
+
const Context = createContext();
|
|
11
|
+
const ItemContext = createContext();
|
|
12
|
+
function useNavigation() {
|
|
13
|
+
const made = useContext(Context);
|
|
14
|
+
if (!made) throw new Error("A NavigationMenu part must be inside <NavigationMenu.Root>");
|
|
15
|
+
return made;
|
|
16
|
+
}
|
|
17
|
+
function useItem() {
|
|
18
|
+
const item = useContext(ItemContext);
|
|
19
|
+
if (!item) throw new Error("A NavigationMenu part must be inside <NavigationMenu.Item>");
|
|
20
|
+
return item;
|
|
21
|
+
}
|
|
22
|
+
function Root(props) {
|
|
23
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "delay", "closeDelay", "orientation", "id"]);
|
|
24
|
+
const generated = createUniqueId();
|
|
25
|
+
const direction = useContext(DirectionContext);
|
|
26
|
+
const made = controller(within(createNavigationMenu, {
|
|
27
|
+
direction
|
|
28
|
+
}), () => ({
|
|
29
|
+
id: local.id ?? generated,
|
|
30
|
+
value: local.value,
|
|
31
|
+
defaultValue: local.defaultValue,
|
|
32
|
+
delay: local.delay,
|
|
33
|
+
closeDelay: local.closeDelay,
|
|
34
|
+
orientation: local.orientation,
|
|
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 of() {
|
|
42
|
+
return made.root;
|
|
43
|
+
},
|
|
44
|
+
tag: "nav"
|
|
45
|
+
}, rest));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** `value` tells this item from the others; an item that is given none makes its own. */
|
|
50
|
+
function Item(props) {
|
|
51
|
+
const [local, rest] = splitProps(props, ["value"]);
|
|
52
|
+
const made = useNavigation();
|
|
53
|
+
const generated = createUniqueId();
|
|
54
|
+
const value = untrack(() => local.value);
|
|
55
|
+
const item = made.item(value === undefined ? generated : value);
|
|
56
|
+
onMount(() => onCleanup(item.mount()));
|
|
57
|
+
return _$createComponent(ItemContext.Provider, {
|
|
58
|
+
value: item,
|
|
59
|
+
get children() {
|
|
60
|
+
return _$createComponent(Part, _$mergeProps({
|
|
61
|
+
get of() {
|
|
62
|
+
return made.itemPart;
|
|
63
|
+
},
|
|
64
|
+
tag: "li"
|
|
65
|
+
}, rest));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** An item's content: drawn in `<NavigationMenu.Viewport>`, while it is shown. */
|
|
70
|
+
function Content(props) {
|
|
71
|
+
const item = useItem();
|
|
72
|
+
const mounted = fromSignal(item.mounted);
|
|
73
|
+
const viewport = fromSignal(useNavigation().viewportElement);
|
|
74
|
+
return _$createComponent(Show, {
|
|
75
|
+
get when() {
|
|
76
|
+
return _$memo(() => !!mounted())() ? viewport() : undefined;
|
|
77
|
+
},
|
|
78
|
+
children: target => _$createComponent(Into, {
|
|
79
|
+
get target() {
|
|
80
|
+
return target();
|
|
81
|
+
},
|
|
82
|
+
get children() {
|
|
83
|
+
return _$createComponent(Part, _$mergeProps({
|
|
84
|
+
get of() {
|
|
85
|
+
return item.content;
|
|
86
|
+
},
|
|
87
|
+
tag: "div"
|
|
88
|
+
}, props));
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function Link(props) {
|
|
94
|
+
const [local, rest] = splitProps(props, ["active", "closeOnClick"]);
|
|
95
|
+
const options = toSignal(() => ({
|
|
96
|
+
...local
|
|
97
|
+
}));
|
|
98
|
+
const part = useNavigation().link(() => defined(options.get()));
|
|
99
|
+
return _$createComponent(Part, _$mergeProps({
|
|
100
|
+
of: part,
|
|
101
|
+
tag: "a"
|
|
102
|
+
}, rest));
|
|
103
|
+
}
|
|
104
|
+
const Portal = props => _$createComponent(BodyPortal, {
|
|
105
|
+
get mounted() {
|
|
106
|
+
return useNavigation().mounted;
|
|
107
|
+
},
|
|
108
|
+
get children() {
|
|
109
|
+
return props.children;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
function Positioner(props) {
|
|
113
|
+
const made = useNavigation();
|
|
114
|
+
return _$createComponent(Part, _$mergeProps({
|
|
115
|
+
get of() {
|
|
116
|
+
return made.positioner;
|
|
117
|
+
},
|
|
118
|
+
tag: "div"
|
|
119
|
+
}, () => positioned(props, made.positioning)));
|
|
120
|
+
}
|
|
121
|
+
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
122
|
+
get of() {
|
|
123
|
+
return useNavigation()[name];
|
|
124
|
+
},
|
|
125
|
+
tag: tag
|
|
126
|
+
}, props));
|
|
127
|
+
const itemPart = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
128
|
+
get of() {
|
|
129
|
+
return useItem()[name];
|
|
130
|
+
},
|
|
131
|
+
tag: tag
|
|
132
|
+
}, props));
|
|
133
|
+
export const NavigationMenu = {
|
|
134
|
+
Root,
|
|
135
|
+
List: part("list", "ul"),
|
|
136
|
+
Item,
|
|
137
|
+
Trigger: itemPart("trigger", "button"),
|
|
138
|
+
Icon: itemPart("icon", "span"),
|
|
139
|
+
Content,
|
|
140
|
+
Link,
|
|
141
|
+
Portal,
|
|
142
|
+
Positioner,
|
|
143
|
+
Popup: part("popup", "div"),
|
|
144
|
+
Viewport: part("viewport", "div"),
|
|
145
|
+
Arrow: part("arrow", "div"),
|
|
146
|
+
Backdrop: part("backdrop", "div")
|
|
147
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
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 { createNumberField } from "@kirana-ui/core/number-field";
|
|
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 useNumberField() {
|
|
11
|
+
const made = useContext(Context);
|
|
12
|
+
if (!made) throw new Error("A NumberField part must be inside <NumberField.Root>");
|
|
13
|
+
return made;
|
|
14
|
+
}
|
|
15
|
+
function Root(props) {
|
|
16
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "onValueCommitted", "min", "max", "step", "smallStep", "largeStep", "snapOnStep", "allowWheelScrub", "format", "locale", "disabled", "readOnly", "required", "name", "form", "id", "children"]);
|
|
17
|
+
const generated = createUniqueId();
|
|
18
|
+
const made = controller(within(createNumberField, {
|
|
19
|
+
field: useContext(FieldContext)
|
|
20
|
+
}), () => ({
|
|
21
|
+
id: local.id ?? generated,
|
|
22
|
+
value: local.value,
|
|
23
|
+
defaultValue: local.defaultValue,
|
|
24
|
+
min: local.min,
|
|
25
|
+
max: local.max,
|
|
26
|
+
step: local.step,
|
|
27
|
+
smallStep: local.smallStep,
|
|
28
|
+
largeStep: local.largeStep,
|
|
29
|
+
snapOnStep: local.snapOnStep,
|
|
30
|
+
allowWheelScrub: local.allowWheelScrub,
|
|
31
|
+
format: local.format,
|
|
32
|
+
locale: local.locale,
|
|
33
|
+
disabled: local.disabled,
|
|
34
|
+
readOnly: local.readOnly,
|
|
35
|
+
required: local.required,
|
|
36
|
+
name: local.name,
|
|
37
|
+
form: local.form,
|
|
38
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
39
|
+
onValueCommitted: (value, details) => local.onValueCommitted?.(value, details)
|
|
40
|
+
}));
|
|
41
|
+
const named = fromSignal(made.named);
|
|
42
|
+
return _$createComponent(Context.Provider, {
|
|
43
|
+
value: made,
|
|
44
|
+
get children() {
|
|
45
|
+
return _$createComponent(Part, _$mergeProps({
|
|
46
|
+
get of() {
|
|
47
|
+
return made.root;
|
|
48
|
+
},
|
|
49
|
+
tag: "div"
|
|
50
|
+
}, rest, {
|
|
51
|
+
get children() {
|
|
52
|
+
return [_$memo(() => local.children), _$createComponent(Show, {
|
|
53
|
+
get when() {
|
|
54
|
+
return named();
|
|
55
|
+
},
|
|
56
|
+
get children() {
|
|
57
|
+
return _$createComponent(Part, {
|
|
58
|
+
get of() {
|
|
59
|
+
return made.hidden;
|
|
60
|
+
},
|
|
61
|
+
tag: "input"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
})];
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
71
|
+
get of() {
|
|
72
|
+
return useNumberField()[name];
|
|
73
|
+
},
|
|
74
|
+
tag: tag
|
|
75
|
+
}, props));
|
|
76
|
+
export const NumberField = {
|
|
77
|
+
Root,
|
|
78
|
+
Group: part("group", "div"),
|
|
79
|
+
Input: part("input", "input"),
|
|
80
|
+
Increment: part("increment", "button"),
|
|
81
|
+
Decrement: part("decrement", "button")
|
|
82
|
+
};
|
package/dom/otp.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
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 { createOtp } from "@kirana-ui/core/otp";
|
|
5
|
+
import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
|
|
6
|
+
import { Part, controller, fromSignal } from "./runtime.js";
|
|
7
|
+
const Context = createContext();
|
|
8
|
+
const SlotContext = createContext();
|
|
9
|
+
function useOtp() {
|
|
10
|
+
const made = useContext(Context);
|
|
11
|
+
if (!made) throw new Error("An Otp part must be inside <Otp.Root>");
|
|
12
|
+
return made;
|
|
13
|
+
}
|
|
14
|
+
function Root(props) {
|
|
15
|
+
const [local, rest] = splitProps(props, ["length", "value", "defaultValue", "onValueChange", "onComplete", "mode", "disabled", "name", "form", "id"]);
|
|
16
|
+
const generated = createUniqueId();
|
|
17
|
+
const made = controller(createOtp, () => ({
|
|
18
|
+
id: local.id ?? generated,
|
|
19
|
+
length: local.length,
|
|
20
|
+
value: local.value,
|
|
21
|
+
defaultValue: local.defaultValue,
|
|
22
|
+
mode: local.mode,
|
|
23
|
+
disabled: local.disabled,
|
|
24
|
+
name: local.name,
|
|
25
|
+
form: local.form,
|
|
26
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
27
|
+
onComplete: value => local.onComplete?.(value)
|
|
28
|
+
}));
|
|
29
|
+
return _$createComponent(Context.Provider, {
|
|
30
|
+
value: made,
|
|
31
|
+
get children() {
|
|
32
|
+
return _$createComponent(Part, _$mergeProps({
|
|
33
|
+
get of() {
|
|
34
|
+
return made.root;
|
|
35
|
+
},
|
|
36
|
+
tag: "div"
|
|
37
|
+
}, rest));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** One cell: it shows its character, then whatever it is given (a caret). */
|
|
42
|
+
function Slot(props) {
|
|
43
|
+
const [local, rest] = splitProps(props, ["index", "children"]);
|
|
44
|
+
const slot = useOtp().slot(untrack(() => local.index));
|
|
45
|
+
const char = fromSignal(slot.char);
|
|
46
|
+
return _$createComponent(SlotContext.Provider, {
|
|
47
|
+
value: slot,
|
|
48
|
+
get children() {
|
|
49
|
+
return _$createComponent(Part, _$mergeProps({
|
|
50
|
+
get of() {
|
|
51
|
+
return slot.part;
|
|
52
|
+
},
|
|
53
|
+
tag: "div"
|
|
54
|
+
}, rest, {
|
|
55
|
+
get children() {
|
|
56
|
+
return [_$memo(() => char()), _$memo(() => local.children)];
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** Drawn in its cell while the cell is the active one and empty. */
|
|
63
|
+
function Caret(props) {
|
|
64
|
+
const made = useOtp();
|
|
65
|
+
const slot = useContext(SlotContext);
|
|
66
|
+
if (!slot) throw new Error("An Otp.Caret must be inside <Otp.Slot>");
|
|
67
|
+
const shown = fromSignal(slot.caret);
|
|
68
|
+
return _$createComponent(Show, {
|
|
69
|
+
get when() {
|
|
70
|
+
return shown();
|
|
71
|
+
},
|
|
72
|
+
get children() {
|
|
73
|
+
return _$createComponent(Part, _$mergeProps({
|
|
74
|
+
get of() {
|
|
75
|
+
return made.caretPart;
|
|
76
|
+
},
|
|
77
|
+
tag: "div"
|
|
78
|
+
}, props));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
83
|
+
get of() {
|
|
84
|
+
return useOtp()[name];
|
|
85
|
+
},
|
|
86
|
+
tag: tag
|
|
87
|
+
}, props));
|
|
88
|
+
export const Otp = {
|
|
89
|
+
Root,
|
|
90
|
+
Input: part("input", "input"),
|
|
91
|
+
Group: part("group", "div"),
|
|
92
|
+
Slot,
|
|
93
|
+
Separator: part("separator", "div"),
|
|
94
|
+
Caret
|
|
95
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { createPagination } from "@kirana-ui/core/pagination";
|
|
4
|
+
import { For, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
5
|
+
import { Part, controller, fromSignal } from "./runtime.js";
|
|
6
|
+
const Context = createContext();
|
|
7
|
+
function usePagination() {
|
|
8
|
+
const made = useContext(Context);
|
|
9
|
+
if (!made) throw new Error("A Pagination part must be inside <Pagination.Root>");
|
|
10
|
+
return made;
|
|
11
|
+
}
|
|
12
|
+
function Root(props) {
|
|
13
|
+
const [local, rest] = splitProps(props, ["page", "defaultPage", "onPageChange", "count", "pageSize", "siblingCount", "boundaryCount", "disabled", "id"]);
|
|
14
|
+
const generated = createUniqueId();
|
|
15
|
+
const made = controller(createPagination, () => ({
|
|
16
|
+
id: local.id ?? generated,
|
|
17
|
+
page: local.page,
|
|
18
|
+
defaultPage: local.defaultPage,
|
|
19
|
+
count: local.count,
|
|
20
|
+
pageSize: local.pageSize,
|
|
21
|
+
siblingCount: local.siblingCount,
|
|
22
|
+
boundaryCount: local.boundaryCount,
|
|
23
|
+
disabled: local.disabled,
|
|
24
|
+
onPageChange: (page, details) => local.onPageChange?.(page, details)
|
|
25
|
+
}));
|
|
26
|
+
return _$createComponent(Context.Provider, {
|
|
27
|
+
value: made,
|
|
28
|
+
get children() {
|
|
29
|
+
return _$createComponent(Part, _$mergeProps({
|
|
30
|
+
get of() {
|
|
31
|
+
return made.root;
|
|
32
|
+
},
|
|
33
|
+
tag: "nav"
|
|
34
|
+
}, rest));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/** Draws its child once for each piece of the row: a page, or the mark for pages left out. */
|
|
39
|
+
function Items(props) {
|
|
40
|
+
const entries = fromSignal(usePagination().entries);
|
|
41
|
+
// By key: a page that stays in the row keeps its element.
|
|
42
|
+
const keys = () => entries().map(each => each.key);
|
|
43
|
+
const of = key => entries().find(each => each.key === key);
|
|
44
|
+
return _$createComponent(For, {
|
|
45
|
+
get each() {
|
|
46
|
+
return keys();
|
|
47
|
+
},
|
|
48
|
+
children: key => props.children(of(key))
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function Item(props) {
|
|
52
|
+
const [local, rest] = splitProps(props, ["page"]);
|
|
53
|
+
const made = usePagination();
|
|
54
|
+
return _$createComponent(Part, _$mergeProps({
|
|
55
|
+
get of() {
|
|
56
|
+
return made.item(local.page);
|
|
57
|
+
},
|
|
58
|
+
tag: "button"
|
|
59
|
+
}, rest));
|
|
60
|
+
}
|
|
61
|
+
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
62
|
+
get of() {
|
|
63
|
+
return usePagination()[name];
|
|
64
|
+
},
|
|
65
|
+
tag: tag
|
|
66
|
+
}, props));
|
|
67
|
+
export const Pagination = {
|
|
68
|
+
Root,
|
|
69
|
+
Items,
|
|
70
|
+
Item,
|
|
71
|
+
Ellipsis: part("ellipsis", "span"),
|
|
72
|
+
Previous: part("previous", "button"),
|
|
73
|
+
Next: part("next", "button")
|
|
74
|
+
};
|
package/dom/popover.js
CHANGED
|
@@ -4,7 +4,13 @@ import { defined } from "@kirana-ui/core";
|
|
|
4
4
|
import { createPopover } from "@kirana-ui/core/popover";
|
|
5
5
|
import { createComputed, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
6
6
|
import { Part, Portal as BodyPortal, controller } from "./runtime.js";
|
|
7
|
+
/**
|
|
8
|
+
* The popover its parts are inside. Exported for a component that is made of one (a date picker
|
|
9
|
+
* provides its own to the popover's parts).
|
|
10
|
+
*/
|
|
7
11
|
const Context = createContext();
|
|
12
|
+
/** For a component made of this one's parts: a date picker. */
|
|
13
|
+
export { Context as PopoverContext };
|
|
8
14
|
function usePopover() {
|
|
9
15
|
const made = useContext(Context);
|
|
10
16
|
if (!made) throw new Error("A Popover part must be inside <Popover.Root>");
|
|
@@ -33,25 +39,34 @@ const Portal = props => _$createComponent(BodyPortal, {
|
|
|
33
39
|
return props.children;
|
|
34
40
|
}
|
|
35
41
|
});
|
|
36
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* A positioner's own props, written where its placement reads them, before its element
|
|
44
|
+
* attaches: the one place they are named. Gives back what is left, for the part's element.
|
|
45
|
+
*/
|
|
37
46
|
export function positioned(props, positioning) {
|
|
38
|
-
const [local, rest] = splitProps(props, ["side", "align", "sideOffset", "alignOffset", "collisionPadding"]);
|
|
39
|
-
createComputed(() =>
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
const [local, rest] = splitProps(props, ["side", "align", "sideOffset", "alignOffset", "collisionPadding", "anchor"]);
|
|
48
|
+
createComputed(() => {
|
|
49
|
+
const anchor = local.anchor;
|
|
50
|
+
positioning.set(defined({
|
|
51
|
+
...local,
|
|
52
|
+
// A function is asked here, so a change of the signal it reads is followed; and given
|
|
53
|
+
// whole while it has nothing, to be asked again as the popup is placed.
|
|
54
|
+
anchor: typeof anchor === "function" ? anchor() ?? anchor : anchor
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
42
57
|
return rest;
|
|
43
58
|
}
|
|
44
59
|
function Positioner(props) {
|
|
45
60
|
const made = usePopover();
|
|
46
61
|
return _$createComponent(Part, _$mergeProps({
|
|
47
|
-
get
|
|
62
|
+
get of() {
|
|
48
63
|
return made.positioner;
|
|
49
64
|
},
|
|
50
65
|
tag: "div"
|
|
51
66
|
}, () => positioned(props, made.positioning)));
|
|
52
67
|
}
|
|
53
68
|
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
54
|
-
get
|
|
69
|
+
get of() {
|
|
55
70
|
return usePopover()[name];
|
|
56
71
|
},
|
|
57
72
|
tag: tag
|
package/dom/qr-code.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { createQrCode } from "@kirana-ui/core/qr-code";
|
|
4
|
+
import { createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
5
|
+
import { Part, controller } from "./runtime.js";
|
|
6
|
+
const Context = createContext();
|
|
7
|
+
function useQrCode() {
|
|
8
|
+
const made = useContext(Context);
|
|
9
|
+
if (!made) throw new Error("A QrCode part must be inside <QrCode.Root>");
|
|
10
|
+
return made;
|
|
11
|
+
}
|
|
12
|
+
function Root(props) {
|
|
13
|
+
const [local, rest] = splitProps(props, ["value", "correction", "id"]);
|
|
14
|
+
const generated = createUniqueId();
|
|
15
|
+
const made = controller(createQrCode, () => ({
|
|
16
|
+
id: local.id ?? generated,
|
|
17
|
+
value: local.value,
|
|
18
|
+
correction: local.correction
|
|
19
|
+
}));
|
|
20
|
+
return _$createComponent(Context.Provider, {
|
|
21
|
+
value: made,
|
|
22
|
+
get children() {
|
|
23
|
+
return _$createComponent(Part, _$mergeProps({
|
|
24
|
+
get of() {
|
|
25
|
+
return made.root;
|
|
26
|
+
},
|
|
27
|
+
tag: "div"
|
|
28
|
+
}, rest));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const Frame = props => _$createComponent(Part, _$mergeProps({
|
|
33
|
+
get of() {
|
|
34
|
+
return useQrCode().frame;
|
|
35
|
+
},
|
|
36
|
+
tag: "svg"
|
|
37
|
+
}, props));
|
|
38
|
+
const Pattern = props => _$createComponent(Part, _$mergeProps({
|
|
39
|
+
get of() {
|
|
40
|
+
return useQrCode().pattern;
|
|
41
|
+
},
|
|
42
|
+
tag: "path"
|
|
43
|
+
}, props));
|
|
44
|
+
export const QrCode = {
|
|
45
|
+
Root,
|
|
46
|
+
Frame,
|
|
47
|
+
Pattern
|
|
48
|
+
};
|
package/dom/radio-group.js
CHANGED
|
@@ -15,7 +15,7 @@ function useRadioGroup() {
|
|
|
15
15
|
return made;
|
|
16
16
|
}
|
|
17
17
|
function Root(props) {
|
|
18
|
-
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "disabled", "readOnly", "required", "name", "id"]);
|
|
18
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "disabled", "readOnly", "required", "name", "form", "id"]);
|
|
19
19
|
const generated = createUniqueId();
|
|
20
20
|
const field = useContext(FieldContext);
|
|
21
21
|
const made = controller(within(createRadioGroup, {
|
|
@@ -29,13 +29,14 @@ function Root(props) {
|
|
|
29
29
|
readOnly: local.readOnly,
|
|
30
30
|
required: local.required,
|
|
31
31
|
name: local.name,
|
|
32
|
+
form: local.form,
|
|
32
33
|
onValueChange: (value, details) => local.onValueChange?.(value, details)
|
|
33
34
|
}));
|
|
34
35
|
return _$createComponent(Context.Provider, {
|
|
35
36
|
value: made,
|
|
36
37
|
get children() {
|
|
37
38
|
return _$createComponent(Part, _$mergeProps({
|
|
38
|
-
get
|
|
39
|
+
get of() {
|
|
39
40
|
return made.root;
|
|
40
41
|
},
|
|
41
42
|
tag: "div"
|
|
@@ -56,14 +57,14 @@ function Item(props) {
|
|
|
56
57
|
value: value,
|
|
57
58
|
get children() {
|
|
58
59
|
return _$createComponent(Part, _$mergeProps({
|
|
59
|
-
get
|
|
60
|
+
get of() {
|
|
60
61
|
return group.item(value, read);
|
|
61
62
|
},
|
|
62
63
|
tag: "span"
|
|
63
64
|
}, rest, {
|
|
64
65
|
get children() {
|
|
65
66
|
return [_$memo(() => local.children), _$createComponent(Part, {
|
|
66
|
-
get
|
|
67
|
+
get of() {
|
|
67
68
|
return group.itemInput(value, read);
|
|
68
69
|
},
|
|
69
70
|
tag: "input"
|
|
@@ -85,7 +86,7 @@ function Indicator(props) {
|
|
|
85
86
|
},
|
|
86
87
|
get children() {
|
|
87
88
|
return _$createComponent(Part, _$mergeProps({
|
|
88
|
-
get
|
|
89
|
+
get of() {
|
|
89
90
|
return indicator.part;
|
|
90
91
|
},
|
|
91
92
|
tag: "span"
|
package/dom/resizable.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { defined, within } from "@kirana-ui/core";
|
|
4
|
+
import { createResizable } from "@kirana-ui/core/resizable";
|
|
5
|
+
import { createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
6
|
+
import { DirectionContext } from "./direction-context.js";
|
|
7
|
+
import { Part, controller, toSignal } from "./runtime.js";
|
|
8
|
+
const Context = createContext();
|
|
9
|
+
function useResizable() {
|
|
10
|
+
const made = useContext(Context);
|
|
11
|
+
if (!made) throw new Error("A Resizable part must be inside <Resizable.Group>");
|
|
12
|
+
return made;
|
|
13
|
+
}
|
|
14
|
+
function Group(props) {
|
|
15
|
+
const [local, rest] = splitProps(props, ["orientation", "onSizesChange", "keyboardStep", "disabled", "id"]);
|
|
16
|
+
const generated = createUniqueId();
|
|
17
|
+
const direction = useContext(DirectionContext);
|
|
18
|
+
const made = controller(within(createResizable, {
|
|
19
|
+
direction
|
|
20
|
+
}), () => ({
|
|
21
|
+
id: local.id ?? generated,
|
|
22
|
+
orientation: local.orientation,
|
|
23
|
+
keyboardStep: local.keyboardStep,
|
|
24
|
+
disabled: local.disabled,
|
|
25
|
+
onSizesChange: (sizes, details) => local.onSizesChange?.(sizes, details)
|
|
26
|
+
}));
|
|
27
|
+
return _$createComponent(Context.Provider, {
|
|
28
|
+
value: made,
|
|
29
|
+
get children() {
|
|
30
|
+
return _$createComponent(Part, _$mergeProps({
|
|
31
|
+
get of() {
|
|
32
|
+
return made.group;
|
|
33
|
+
},
|
|
34
|
+
tag: "div"
|
|
35
|
+
}, rest));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function Panel(props) {
|
|
40
|
+
const [local, rest] = splitProps(props, ["defaultSize", "minSize", "maxSize"]);
|
|
41
|
+
const options = toSignal(() => ({
|
|
42
|
+
...local
|
|
43
|
+
}));
|
|
44
|
+
const part = useResizable().panel(() => defined(options.get()));
|
|
45
|
+
return _$createComponent(Part, _$mergeProps({
|
|
46
|
+
of: part,
|
|
47
|
+
tag: "div"
|
|
48
|
+
}, rest));
|
|
49
|
+
}
|
|
50
|
+
function Handle(props) {
|
|
51
|
+
const [local, rest] = splitProps(props, ["disabled"]);
|
|
52
|
+
const options = toSignal(() => ({
|
|
53
|
+
disabled: local.disabled
|
|
54
|
+
}));
|
|
55
|
+
const part = useResizable().handle(() => defined(options.get()));
|
|
56
|
+
return _$createComponent(Part, _$mergeProps({
|
|
57
|
+
of: part,
|
|
58
|
+
tag: "div"
|
|
59
|
+
}, rest));
|
|
60
|
+
}
|
|
61
|
+
export const Resizable = {
|
|
62
|
+
Group,
|
|
63
|
+
Panel,
|
|
64
|
+
Handle
|
|
65
|
+
};
|