@kirana-ui/solid 0.1.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/dom/autocomplete.js +2 -0
- package/dom/autosize.js +19 -0
- package/dom/calendar.js +141 -0
- package/dom/carousel.js +83 -0
- package/dom/checkbox.js +2 -1
- 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 +28 -0
- package/dom/drawer.js +2 -0
- package/dom/hover-popup.js +17 -2
- 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 +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 +2 -0
- package/dom/qr-code.js +48 -0
- package/dom/radio-group.js +2 -1
- package/dom/resizable.js +65 -0
- package/dom/runtime.js +36 -2
- package/dom/scroll-area.js +99 -0
- package/dom/select.js +69 -5
- package/dom/slider.js +1 -1
- package/dom/switch.js +2 -1
- package/dom/toast.js +113 -0
- package/dom/toggle-group.js +37 -0
- package/dom/toggle.js +11 -3
- package/dom/toolbar-context.js +5 -0
- package/dom/toolbar.js +71 -0
- package/llms.txt +1838 -0
- package/package.json +220 -2
- package/server/autocomplete.js +2 -0
- package/server/autosize.js +19 -0
- package/server/calendar.js +140 -0
- package/server/carousel.js +83 -0
- package/server/checkbox.js +2 -1
- 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 +28 -0
- package/server/drawer.js +2 -0
- package/server/hover-popup.js +17 -2
- 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 +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 +2 -0
- package/server/qr-code.js +48 -0
- package/server/radio-group.js +2 -1
- package/server/resizable.js +65 -0
- package/server/runtime.js +35 -1
- package/server/scroll-area.js +99 -0
- package/server/select.js +69 -5
- package/server/slider.js +1 -1
- package/server/switch.js +2 -1
- package/server/toast.js +113 -0
- package/server/toggle-group.js +37 -0
- package/server/toggle.js +11 -3
- package/server/toolbar-context.js +5 -0
- package/server/toolbar.js +71 -0
- package/src/autocomplete.jsx +2 -0
- package/src/autosize.jsx +8 -0
- package/src/calendar.jsx +104 -0
- package/src/carousel.jsx +51 -0
- package/src/checkbox.jsx +2 -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 +20 -0
- package/src/drawer.js +2 -0
- package/src/hover-popup.jsx +10 -2
- 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 +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 +2 -0
- package/src/qr-code.jsx +25 -0
- package/src/radio-group.jsx +2 -0
- package/src/resizable.jsx +46 -0
- package/src/runtime.jsx +33 -2
- package/src/scroll-area.jsx +53 -0
- package/src/select.jsx +49 -5
- package/src/slider.jsx +2 -0
- package/src/switch.jsx +2 -0
- package/src/toast.jsx +58 -0
- package/src/toggle-group.jsx +32 -0
- package/src/toggle.jsx +8 -2
- package/src/toolbar-context.js +5 -0
- package/src/toolbar.jsx +43 -0
- package/types/autocomplete.d.ts +1 -0
- package/types/autosize.d.ts +8 -0
- package/types/calendar.d.ts +40 -0
- package/types/carousel.d.ts +26 -0
- package/types/checkbox.d.ts +1 -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 +21 -0
- package/types/drawer.d.ts +1 -0
- package/types/hover-card.d.ts +4 -1
- package/types/hover-popup.d.ts +4 -1
- package/types/index.d.ts +27 -1
- 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/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 +4 -1
- package/types/qr-code.d.ts +14 -0
- package/types/radio-group.d.ts +1 -0
- package/types/resizable.d.ts +24 -0
- package/types/runtime.d.ts +18 -0
- package/types/scroll-area.d.ts +20 -0
- package/types/select.d.ts +25 -1
- package/types/switch.d.ts +1 -0
- package/types/toast.d.ts +33 -0
- package/types/toggle-group.d.ts +14 -0
- package/types/toggle.d.ts +2 -0
- package/types/toolbar-context.d.ts +6 -0
- package/types/toolbar.d.ts +23 -0
- package/types/tooltip.d.ts +4 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { memo as _$memo } from "solid-js/web";
|
|
2
|
+
import { ssr as _$ssr } from "solid-js/web";
|
|
3
|
+
import { escape as _$escape } from "solid-js/web";
|
|
4
|
+
import { ssrHydrationKey as _$ssrHydrationKey } from "solid-js/web";
|
|
5
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
6
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
7
|
+
var _tmpl$ = ["<li", ">", "</li>"];
|
|
8
|
+
import { defined, within } from "@kirana-ui/core";
|
|
9
|
+
import { createNavigationMenu } from "@kirana-ui/core/navigation-menu";
|
|
10
|
+
import { Show, createContext, createUniqueId, onCleanup, onMount, splitProps, untrack, useContext } from "solid-js";
|
|
11
|
+
import { DirectionContext } from "./direction-context.js";
|
|
12
|
+
import { positioned } from "./popover.js";
|
|
13
|
+
import { Into, Part, Portal as BodyPortal, controller, fromSignal, toSignal } from "./runtime.js";
|
|
14
|
+
const Context = createContext();
|
|
15
|
+
const ItemContext = createContext();
|
|
16
|
+
function useNavigation() {
|
|
17
|
+
const made = useContext(Context);
|
|
18
|
+
if (!made) throw new Error("A NavigationMenu part must be inside <NavigationMenu.Root>");
|
|
19
|
+
return made;
|
|
20
|
+
}
|
|
21
|
+
function useItem() {
|
|
22
|
+
const item = useContext(ItemContext);
|
|
23
|
+
if (!item) throw new Error("A NavigationMenu part must be inside <NavigationMenu.Item>");
|
|
24
|
+
return item;
|
|
25
|
+
}
|
|
26
|
+
function Root(props) {
|
|
27
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "delay", "closeDelay", "orientation", "id"]);
|
|
28
|
+
const generated = createUniqueId();
|
|
29
|
+
const direction = useContext(DirectionContext);
|
|
30
|
+
const made = controller(within(createNavigationMenu, {
|
|
31
|
+
direction
|
|
32
|
+
}), () => ({
|
|
33
|
+
id: local.id ?? generated,
|
|
34
|
+
value: local.value,
|
|
35
|
+
defaultValue: local.defaultValue,
|
|
36
|
+
delay: local.delay,
|
|
37
|
+
closeDelay: local.closeDelay,
|
|
38
|
+
orientation: local.orientation,
|
|
39
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details)
|
|
40
|
+
}));
|
|
41
|
+
return _$createComponent(Context.Provider, {
|
|
42
|
+
value: made,
|
|
43
|
+
get children() {
|
|
44
|
+
return _$createComponent(Part, _$mergeProps({
|
|
45
|
+
get part() {
|
|
46
|
+
return made.root;
|
|
47
|
+
},
|
|
48
|
+
tag: "nav"
|
|
49
|
+
}, rest));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** `value` tells this item from the others; an item that is only a link needs none. */
|
|
54
|
+
function Item(props) {
|
|
55
|
+
const value = untrack(() => props.value);
|
|
56
|
+
if (value === undefined) return _$ssr(_tmpl$, _$ssrHydrationKey(), _$escape(props.children));
|
|
57
|
+
const item = useNavigation().item(value);
|
|
58
|
+
onMount(() => onCleanup(item.mount()));
|
|
59
|
+
return _$createComponent(ItemContext.Provider, {
|
|
60
|
+
value: item,
|
|
61
|
+
get children() {
|
|
62
|
+
return _$ssr(_tmpl$, _$ssrHydrationKey(), _$escape(props.children));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/** An item's content: drawn in `<NavigationMenu.Viewport>`, while it is shown. */
|
|
67
|
+
function Content(props) {
|
|
68
|
+
const item = useItem();
|
|
69
|
+
const mounted = fromSignal(item.mounted);
|
|
70
|
+
const viewport = fromSignal(useNavigation().viewportElement);
|
|
71
|
+
return _$createComponent(Show, {
|
|
72
|
+
get when() {
|
|
73
|
+
return _$memo(() => !!mounted())() ? viewport() : undefined;
|
|
74
|
+
},
|
|
75
|
+
children: target => _$createComponent(Into, {
|
|
76
|
+
get target() {
|
|
77
|
+
return target();
|
|
78
|
+
},
|
|
79
|
+
get children() {
|
|
80
|
+
return _$createComponent(Part, _$mergeProps({
|
|
81
|
+
get part() {
|
|
82
|
+
return item.content;
|
|
83
|
+
},
|
|
84
|
+
tag: "div"
|
|
85
|
+
}, props));
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function Link(props) {
|
|
91
|
+
const [local, rest] = splitProps(props, ["active", "closeOnClick"]);
|
|
92
|
+
const options = toSignal(() => ({
|
|
93
|
+
...local
|
|
94
|
+
}));
|
|
95
|
+
const part = useNavigation().link(() => defined(options.get()));
|
|
96
|
+
return _$createComponent(Part, _$mergeProps({
|
|
97
|
+
part: part,
|
|
98
|
+
tag: "a"
|
|
99
|
+
}, rest));
|
|
100
|
+
}
|
|
101
|
+
const Portal = props => _$createComponent(BodyPortal, {
|
|
102
|
+
get mounted() {
|
|
103
|
+
return useNavigation().mounted;
|
|
104
|
+
},
|
|
105
|
+
get children() {
|
|
106
|
+
return props.children;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
function Positioner(props) {
|
|
110
|
+
const made = useNavigation();
|
|
111
|
+
return _$createComponent(Part, _$mergeProps({
|
|
112
|
+
get part() {
|
|
113
|
+
return made.positioner;
|
|
114
|
+
},
|
|
115
|
+
tag: "div"
|
|
116
|
+
}, () => positioned(props, made.positioning)));
|
|
117
|
+
}
|
|
118
|
+
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
119
|
+
get part() {
|
|
120
|
+
return useNavigation()[name];
|
|
121
|
+
},
|
|
122
|
+
tag: tag
|
|
123
|
+
}, props));
|
|
124
|
+
const itemPart = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
125
|
+
get part() {
|
|
126
|
+
return useItem()[name];
|
|
127
|
+
},
|
|
128
|
+
tag: tag
|
|
129
|
+
}, props));
|
|
130
|
+
export const NavigationMenu = {
|
|
131
|
+
Root,
|
|
132
|
+
List: part("list", "ul"),
|
|
133
|
+
Item,
|
|
134
|
+
Trigger: itemPart("trigger", "button"),
|
|
135
|
+
Icon: itemPart("icon", "span"),
|
|
136
|
+
Content,
|
|
137
|
+
Link,
|
|
138
|
+
Portal,
|
|
139
|
+
Positioner,
|
|
140
|
+
Popup: part("popup", "div"),
|
|
141
|
+
Viewport: part("viewport", "div"),
|
|
142
|
+
Arrow: part("arrow", "div"),
|
|
143
|
+
Backdrop: part("backdrop", "div")
|
|
144
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
2
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
3
|
+
import { within } from "@kirana-ui/core";
|
|
4
|
+
import { createNumberField } from "@kirana-ui/core/number-field";
|
|
5
|
+
import { Show, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
6
|
+
import { FieldContext } from "./field-context.js";
|
|
7
|
+
import { Part, controller, fromSignal } from "./runtime.js";
|
|
8
|
+
const Context = createContext();
|
|
9
|
+
function useNumberField() {
|
|
10
|
+
const made = useContext(Context);
|
|
11
|
+
if (!made) throw new Error("A NumberField part must be inside <NumberField.Root>");
|
|
12
|
+
return made;
|
|
13
|
+
}
|
|
14
|
+
function Root(props) {
|
|
15
|
+
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"]);
|
|
16
|
+
const generated = createUniqueId();
|
|
17
|
+
const made = controller(within(createNumberField, {
|
|
18
|
+
field: useContext(FieldContext)
|
|
19
|
+
}), () => ({
|
|
20
|
+
id: local.id ?? generated,
|
|
21
|
+
value: local.value,
|
|
22
|
+
defaultValue: local.defaultValue,
|
|
23
|
+
min: local.min,
|
|
24
|
+
max: local.max,
|
|
25
|
+
step: local.step,
|
|
26
|
+
smallStep: local.smallStep,
|
|
27
|
+
largeStep: local.largeStep,
|
|
28
|
+
snapOnStep: local.snapOnStep,
|
|
29
|
+
allowWheelScrub: local.allowWheelScrub,
|
|
30
|
+
format: local.format,
|
|
31
|
+
locale: local.locale,
|
|
32
|
+
disabled: local.disabled,
|
|
33
|
+
readOnly: local.readOnly,
|
|
34
|
+
required: local.required,
|
|
35
|
+
name: local.name,
|
|
36
|
+
form: local.form,
|
|
37
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
38
|
+
onValueCommitted: (value, details) => local.onValueCommitted?.(value, details)
|
|
39
|
+
}));
|
|
40
|
+
const named = fromSignal(made.named);
|
|
41
|
+
return _$createComponent(Context.Provider, {
|
|
42
|
+
value: made,
|
|
43
|
+
get children() {
|
|
44
|
+
return _$createComponent(Part, _$mergeProps({
|
|
45
|
+
get part() {
|
|
46
|
+
return made.root;
|
|
47
|
+
},
|
|
48
|
+
tag: "div"
|
|
49
|
+
}, rest, {
|
|
50
|
+
get children() {
|
|
51
|
+
return [local.children, _$createComponent(Show, {
|
|
52
|
+
get when() {
|
|
53
|
+
return named();
|
|
54
|
+
},
|
|
55
|
+
get children() {
|
|
56
|
+
return _$createComponent(Part, {
|
|
57
|
+
get part() {
|
|
58
|
+
return made.hidden;
|
|
59
|
+
},
|
|
60
|
+
tag: "input"
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
})];
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
70
|
+
get part() {
|
|
71
|
+
return useNumberField()[name];
|
|
72
|
+
},
|
|
73
|
+
tag: tag
|
|
74
|
+
}, props));
|
|
75
|
+
export const NumberField = {
|
|
76
|
+
Root,
|
|
77
|
+
Group: part("group", "div"),
|
|
78
|
+
Input: part("input", "input"),
|
|
79
|
+
Increment: part("increment", "button"),
|
|
80
|
+
Decrement: part("decrement", "button")
|
|
81
|
+
};
|
package/server/otp.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { createOtp } from "@kirana-ui/core/otp";
|
|
4
|
+
import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
|
|
5
|
+
import { Part, controller, fromSignal } from "./runtime.js";
|
|
6
|
+
const Context = createContext();
|
|
7
|
+
const SlotContext = createContext();
|
|
8
|
+
function useOtp() {
|
|
9
|
+
const made = useContext(Context);
|
|
10
|
+
if (!made) throw new Error("An Otp part must be inside <Otp.Root>");
|
|
11
|
+
return made;
|
|
12
|
+
}
|
|
13
|
+
function Root(props) {
|
|
14
|
+
const [local, rest] = splitProps(props, ["length", "value", "defaultValue", "onValueChange", "onComplete", "mode", "disabled", "name", "form", "id"]);
|
|
15
|
+
const generated = createUniqueId();
|
|
16
|
+
const made = controller(createOtp, () => ({
|
|
17
|
+
id: local.id ?? generated,
|
|
18
|
+
length: local.length,
|
|
19
|
+
value: local.value,
|
|
20
|
+
defaultValue: local.defaultValue,
|
|
21
|
+
mode: local.mode,
|
|
22
|
+
disabled: local.disabled,
|
|
23
|
+
name: local.name,
|
|
24
|
+
form: local.form,
|
|
25
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
26
|
+
onComplete: value => local.onComplete?.(value)
|
|
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
|
+
/** One cell: it shows its character, then whatever it is given (a caret). */
|
|
41
|
+
function Slot(props) {
|
|
42
|
+
const [local, rest] = splitProps(props, ["index", "children"]);
|
|
43
|
+
const slot = useOtp().slot(untrack(() => local.index));
|
|
44
|
+
const char = fromSignal(slot.char);
|
|
45
|
+
return _$createComponent(SlotContext.Provider, {
|
|
46
|
+
value: slot,
|
|
47
|
+
get children() {
|
|
48
|
+
return _$createComponent(Part, _$mergeProps({
|
|
49
|
+
get part() {
|
|
50
|
+
return slot.part;
|
|
51
|
+
},
|
|
52
|
+
tag: "div"
|
|
53
|
+
}, rest, {
|
|
54
|
+
get children() {
|
|
55
|
+
return [char(), local.children];
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** Drawn in its cell while the cell is the active one and empty. */
|
|
62
|
+
function Caret(props) {
|
|
63
|
+
const made = useOtp();
|
|
64
|
+
const slot = useContext(SlotContext);
|
|
65
|
+
if (!slot) throw new Error("An Otp.Caret must be inside <Otp.Slot>");
|
|
66
|
+
const shown = fromSignal(slot.caret);
|
|
67
|
+
return _$createComponent(Show, {
|
|
68
|
+
get when() {
|
|
69
|
+
return shown();
|
|
70
|
+
},
|
|
71
|
+
get children() {
|
|
72
|
+
return _$createComponent(Part, _$mergeProps({
|
|
73
|
+
get part() {
|
|
74
|
+
return made.caretPart;
|
|
75
|
+
},
|
|
76
|
+
tag: "div"
|
|
77
|
+
}, props));
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
82
|
+
get part() {
|
|
83
|
+
return useOtp()[name];
|
|
84
|
+
},
|
|
85
|
+
tag: tag
|
|
86
|
+
}, props));
|
|
87
|
+
export const Otp = {
|
|
88
|
+
Root,
|
|
89
|
+
Input: part("input", "input"),
|
|
90
|
+
Group: part("group", "div"),
|
|
91
|
+
Slot,
|
|
92
|
+
Separator: part("separator", "div"),
|
|
93
|
+
Caret
|
|
94
|
+
};
|
|
@@ -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 part() {
|
|
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 part() {
|
|
56
|
+
return made.item(local.page);
|
|
57
|
+
},
|
|
58
|
+
tag: "button"
|
|
59
|
+
}, rest));
|
|
60
|
+
}
|
|
61
|
+
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
62
|
+
get part() {
|
|
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/server/popover.js
CHANGED
|
@@ -5,6 +5,8 @@ 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
7
|
const Context = createContext();
|
|
8
|
+
/** For a component made of this one's parts: a date picker. */
|
|
9
|
+
export { Context as PopoverContext };
|
|
8
10
|
function usePopover() {
|
|
9
11
|
const made = useContext(Context);
|
|
10
12
|
if (!made) throw new Error("A Popover part must be inside <Popover.Root>");
|
|
@@ -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 part() {
|
|
25
|
+
return made.root;
|
|
26
|
+
},
|
|
27
|
+
tag: "div"
|
|
28
|
+
}, rest));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const Frame = props => _$createComponent(Part, _$mergeProps({
|
|
33
|
+
get part() {
|
|
34
|
+
return useQrCode().frame;
|
|
35
|
+
},
|
|
36
|
+
tag: "svg"
|
|
37
|
+
}, props));
|
|
38
|
+
const Pattern = props => _$createComponent(Part, _$mergeProps({
|
|
39
|
+
get part() {
|
|
40
|
+
return useQrCode().pattern;
|
|
41
|
+
},
|
|
42
|
+
tag: "path"
|
|
43
|
+
}, props));
|
|
44
|
+
export const QrCode = {
|
|
45
|
+
Root,
|
|
46
|
+
Frame,
|
|
47
|
+
Pattern
|
|
48
|
+
};
|
package/server/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,6 +29,7 @@ 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, {
|
|
@@ -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 part() {
|
|
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
|
+
part: 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
|
+
part: part,
|
|
58
|
+
tag: "div"
|
|
59
|
+
}, rest));
|
|
60
|
+
}
|
|
61
|
+
export const Resizable = {
|
|
62
|
+
Group,
|
|
63
|
+
Panel,
|
|
64
|
+
Handle
|
|
65
|
+
};
|
package/server/runtime.js
CHANGED
|
@@ -2,7 +2,7 @@ import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
|
2
2
|
import { memo as _$memo } from "solid-js/web";
|
|
3
3
|
import { createComponent as _$createComponent } from "solid-js/web";
|
|
4
4
|
import { mergeProps, sameProps, signal } from "@kirana-ui/core";
|
|
5
|
-
import { Show, createComputed, createMemo, createSignal, getOwner, onCleanup, onMount, runWithOwner, splitProps, untrack } from "solid-js";
|
|
5
|
+
import { Show, children, createComputed, createContext, createRenderEffect, createMemo, createSignal, getOwner, onCleanup, onMount, runWithOwner, splitProps, untrack, useContext } from "solid-js";
|
|
6
6
|
import { Dynamic, Portal as SolidPortal, isServer } from "solid-js/web";
|
|
7
7
|
/** A core signal as a Solid accessor: tracked by whatever calls it. */
|
|
8
8
|
export function fromSignal(source) {
|
|
@@ -80,15 +80,49 @@ export function Part(props) {
|
|
|
80
80
|
children: render => render()(merged)
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Its children as children of `target`, an element drawn elsewhere: with no element of its own
|
|
85
|
+
* around them (Solid's `Portal` adds one), so the page is the same as on the other adapters.
|
|
86
|
+
*/
|
|
87
|
+
export function Into(props) {
|
|
88
|
+
const resolved = children(() => props.children);
|
|
89
|
+
// Before any mount work of the children: their elements are in the page by then.
|
|
90
|
+
createRenderEffect(() => {
|
|
91
|
+
const target = props.target;
|
|
92
|
+
const nodes = resolved.toArray().filter(each => each instanceof Node);
|
|
93
|
+
for (const node of nodes) target.appendChild(node);
|
|
94
|
+
onCleanup(() => {
|
|
95
|
+
for (const node of nodes) if (node.parentNode === target) target.removeChild(node);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const PortalContainer = createContext();
|
|
101
|
+
/**
|
|
102
|
+
* Says where every popup inside it is drawn, the popups those open included: an element of
|
|
103
|
+
* the page (a shadow root's host, a full-screen element) in place of `<body>`.
|
|
104
|
+
*/
|
|
105
|
+
export function PortalProvider(props) {
|
|
106
|
+
return _$createComponent(PortalContainer.Provider, {
|
|
107
|
+
value: () => props.container,
|
|
108
|
+
get children() {
|
|
109
|
+
return props.children;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
83
113
|
/** Its children in a container at the end of the page, while `mounted`. */
|
|
84
114
|
export function Portal(props) {
|
|
85
115
|
const shown = fromSignal(untrack(() => props.mounted));
|
|
116
|
+
const container = useContext(PortalContainer);
|
|
86
117
|
return _$createComponent(Show, {
|
|
87
118
|
get when() {
|
|
88
119
|
return shown();
|
|
89
120
|
},
|
|
90
121
|
get children() {
|
|
91
122
|
return _$createComponent(SolidPortal, {
|
|
123
|
+
get mount() {
|
|
124
|
+
return container?.() ?? undefined;
|
|
125
|
+
},
|
|
92
126
|
get children() {
|
|
93
127
|
return props.children;
|
|
94
128
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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 { createScrollArea } from "@kirana-ui/core/scroll-area";
|
|
6
|
+
import { Show, createContext, splitProps, untrack, useContext } from "solid-js";
|
|
7
|
+
import { DirectionContext } from "./direction-context.js";
|
|
8
|
+
import { Part, controller, fromSignal } from "./runtime.js";
|
|
9
|
+
const Context = createContext();
|
|
10
|
+
const ScrollbarContext = createContext();
|
|
11
|
+
function useScrollArea() {
|
|
12
|
+
const made = useContext(Context);
|
|
13
|
+
if (!made) throw new Error("A ScrollArea part must be inside <ScrollArea.Root>");
|
|
14
|
+
return made;
|
|
15
|
+
}
|
|
16
|
+
function Root(props) {
|
|
17
|
+
const direction = useContext(DirectionContext);
|
|
18
|
+
const made = controller(within(createScrollArea, {
|
|
19
|
+
direction
|
|
20
|
+
}), () => ({}));
|
|
21
|
+
return _$createComponent(Context.Provider, {
|
|
22
|
+
value: made,
|
|
23
|
+
get children() {
|
|
24
|
+
return _$createComponent(Part, _$mergeProps({
|
|
25
|
+
get part() {
|
|
26
|
+
return made.root;
|
|
27
|
+
},
|
|
28
|
+
tag: "div"
|
|
29
|
+
}, props));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** `orientation` is which way it scrolls (`vertical` by default). */
|
|
34
|
+
function Scrollbar(props) {
|
|
35
|
+
const [local, rest] = splitProps(props, ["orientation", "keepMounted"]);
|
|
36
|
+
const bar = useScrollArea().scrollbar(untrack(() => local.orientation) ?? "vertical");
|
|
37
|
+
const shown = fromSignal(bar.shown);
|
|
38
|
+
return _$createComponent(ScrollbarContext.Provider, {
|
|
39
|
+
value: bar,
|
|
40
|
+
get children() {
|
|
41
|
+
return _$createComponent(Show, {
|
|
42
|
+
get when() {
|
|
43
|
+
return shown() || local.keepMounted;
|
|
44
|
+
},
|
|
45
|
+
get children() {
|
|
46
|
+
return _$createComponent(Part, _$mergeProps({
|
|
47
|
+
get part() {
|
|
48
|
+
return bar.part;
|
|
49
|
+
},
|
|
50
|
+
tag: "div"
|
|
51
|
+
}, rest));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function Thumb(props) {
|
|
58
|
+
const bar = useContext(ScrollbarContext);
|
|
59
|
+
if (!bar) throw new Error("A ScrollArea.Thumb must be inside <ScrollArea.Scrollbar>");
|
|
60
|
+
return _$createComponent(Part, _$mergeProps({
|
|
61
|
+
get part() {
|
|
62
|
+
return bar.thumb;
|
|
63
|
+
},
|
|
64
|
+
tag: "div"
|
|
65
|
+
}, props));
|
|
66
|
+
}
|
|
67
|
+
function Corner(props) {
|
|
68
|
+
const {
|
|
69
|
+
corner
|
|
70
|
+
} = useScrollArea();
|
|
71
|
+
const shown = fromSignal(corner.shown);
|
|
72
|
+
return _$createComponent(Show, {
|
|
73
|
+
get when() {
|
|
74
|
+
return shown();
|
|
75
|
+
},
|
|
76
|
+
get children() {
|
|
77
|
+
return _$createComponent(Part, _$mergeProps({
|
|
78
|
+
get part() {
|
|
79
|
+
return corner.part;
|
|
80
|
+
},
|
|
81
|
+
tag: "div"
|
|
82
|
+
}, props));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const part = name => props => _$createComponent(Part, _$mergeProps({
|
|
87
|
+
get part() {
|
|
88
|
+
return useScrollArea()[name];
|
|
89
|
+
},
|
|
90
|
+
tag: "div"
|
|
91
|
+
}, props));
|
|
92
|
+
export const ScrollArea = {
|
|
93
|
+
Root,
|
|
94
|
+
Viewport: part("viewport"),
|
|
95
|
+
Content: part("content"),
|
|
96
|
+
Scrollbar,
|
|
97
|
+
Thumb,
|
|
98
|
+
Corner
|
|
99
|
+
};
|