@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,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/dom/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>");
|
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 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/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,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, {
|
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 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/dom/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,16 +80,50 @@ 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, {
|
|
92
|
-
|
|
123
|
+
get mount() {
|
|
124
|
+
return container?.() ?? undefined;
|
|
125
|
+
},
|
|
126
|
+
ref: outlet => outlet.setAttribute("data-kirana-portal", ""),
|
|
93
127
|
get children() {
|
|
94
128
|
return props.children;
|
|
95
129
|
}
|
|
@@ -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
|
+
};
|
package/dom/select.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createComponent as _$createComponent } from "solid-js/web";
|
|
|
3
3
|
import { memo as _$memo } from "solid-js/web";
|
|
4
4
|
import { defined, within } from "@kirana-ui/core";
|
|
5
5
|
import { createSelect } from "@kirana-ui/core/select";
|
|
6
|
-
import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
|
|
6
|
+
import { Show, createComputed, createContext, createUniqueId, onCleanup, onMount, splitProps, untrack, useContext } from "solid-js";
|
|
7
7
|
import { positioned } from "./popover.js";
|
|
8
8
|
import { FieldContext } from "./field-context.js";
|
|
9
9
|
import { Part, Portal as BodyPortal, controller, fromSignal, toSignal } from "./runtime.js";
|
|
@@ -28,7 +28,9 @@ function Root(props) {
|
|
|
28
28
|
disabled: props.disabled,
|
|
29
29
|
required: props.required,
|
|
30
30
|
name: props.name,
|
|
31
|
+
form: props.form,
|
|
31
32
|
items: props.items,
|
|
33
|
+
virtualized: props.virtualized,
|
|
32
34
|
onValueChange: (value, details) => props.onValueChange?.(value, details),
|
|
33
35
|
onOpenChange: (open, details) => props.onOpenChange?.(open, details)
|
|
34
36
|
}));
|
|
@@ -60,14 +62,20 @@ const Portal = props => _$createComponent(BodyPortal, {
|
|
|
60
62
|
return props.children;
|
|
61
63
|
}
|
|
62
64
|
});
|
|
65
|
+
/**
|
|
66
|
+
* `alignItemWithTrigger`: the list opens over its trigger, the chosen item's text on the
|
|
67
|
+
* trigger's own, where there is room and unless a finger opened it.
|
|
68
|
+
*/
|
|
63
69
|
function Positioner(props) {
|
|
64
70
|
const made = useSelect();
|
|
71
|
+
const [local, rest] = splitProps(props, ["alignItemWithTrigger"]);
|
|
72
|
+
createComputed(() => made.alignItemWithTrigger.set(Boolean(local.alignItemWithTrigger)));
|
|
65
73
|
return _$createComponent(Part, _$mergeProps({
|
|
66
74
|
get part() {
|
|
67
75
|
return made.positioner;
|
|
68
76
|
},
|
|
69
77
|
tag: "div"
|
|
70
|
-
}, () => positioned(
|
|
78
|
+
}, () => positioned(rest, made.positioning)));
|
|
71
79
|
}
|
|
72
80
|
/** Shows the chosen value's label, or `placeholder` while nothing is chosen. */
|
|
73
81
|
function Value(props) {
|
|
@@ -87,12 +95,13 @@ function Value(props) {
|
|
|
87
95
|
}
|
|
88
96
|
/** `label` is what typeahead matches and the trigger shows; the item's text when left out. */
|
|
89
97
|
function Item(props) {
|
|
90
|
-
const [local, rest] = splitProps(props, ["value", "disabled", "label"]);
|
|
98
|
+
const [local, rest] = splitProps(props, ["value", "disabled", "label", "index"]);
|
|
91
99
|
// An item is its value for as long as it is in the page.
|
|
92
100
|
const value = untrack(() => local.value);
|
|
93
101
|
const options = toSignal(() => ({
|
|
94
102
|
disabled: local.disabled,
|
|
95
|
-
label: local.label
|
|
103
|
+
label: local.label,
|
|
104
|
+
index: local.index
|
|
96
105
|
}));
|
|
97
106
|
const part = useSelect().item(value, () => defined(options.get()));
|
|
98
107
|
return _$createComponent(ItemContext.Provider, {
|
|
@@ -130,6 +139,51 @@ function ItemIndicator(props) {
|
|
|
130
139
|
}
|
|
131
140
|
});
|
|
132
141
|
}
|
|
142
|
+
const GroupContext = createContext();
|
|
143
|
+
/** Items that belong together, named by their `<Select.GroupLabel>`. */
|
|
144
|
+
function Group(props) {
|
|
145
|
+
const [local, rest] = splitProps(props, ["id"]);
|
|
146
|
+
const generated = createUniqueId();
|
|
147
|
+
const group = useSelect().group(untrack(() => local.id) ?? generated);
|
|
148
|
+
return _$createComponent(GroupContext.Provider, {
|
|
149
|
+
value: group,
|
|
150
|
+
get children() {
|
|
151
|
+
return _$createComponent(Part, _$mergeProps({
|
|
152
|
+
get part() {
|
|
153
|
+
return group.root;
|
|
154
|
+
},
|
|
155
|
+
tag: "div"
|
|
156
|
+
}, rest));
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/** Names the group it is in. With no group around it, it is plain text. */
|
|
161
|
+
const GroupLabel = props => _$createComponent(Part, _$mergeProps({
|
|
162
|
+
get part() {
|
|
163
|
+
return useContext(GroupContext)?.label ?? useSelect().groupLabel;
|
|
164
|
+
},
|
|
165
|
+
tag: "div"
|
|
166
|
+
}, props));
|
|
167
|
+
function scrollArrow(direction) {
|
|
168
|
+
return props => {
|
|
169
|
+
const arrow = useSelect().scrollArrow(direction);
|
|
170
|
+
onMount(() => onCleanup(arrow.mount()));
|
|
171
|
+
const mounted = fromSignal(arrow.mounted);
|
|
172
|
+
return _$createComponent(Show, {
|
|
173
|
+
get when() {
|
|
174
|
+
return mounted();
|
|
175
|
+
},
|
|
176
|
+
get children() {
|
|
177
|
+
return _$createComponent(Part, _$mergeProps({
|
|
178
|
+
get part() {
|
|
179
|
+
return arrow.part;
|
|
180
|
+
},
|
|
181
|
+
tag: "div"
|
|
182
|
+
}, props));
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
}
|
|
133
187
|
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
134
188
|
get part() {
|
|
135
189
|
return useSelect()[name];
|
|
@@ -145,5 +199,15 @@ export const Select = {
|
|
|
145
199
|
ItemText,
|
|
146
200
|
ItemIndicator,
|
|
147
201
|
Trigger: part("trigger", "button"),
|
|
148
|
-
Popup: part("popup", "div")
|
|
202
|
+
Popup: part("popup", "div"),
|
|
203
|
+
/** The items' own box inside the popup, when the popup also holds scroll arrows. */
|
|
204
|
+
List: part("list", "div"),
|
|
205
|
+
/** In the page while there is more of the list above: it scrolls it under a moving pointer. */
|
|
206
|
+
ScrollUpArrow: scrollArrow("up"),
|
|
207
|
+
/** In the page while there is more of the list below. */
|
|
208
|
+
ScrollDownArrow: scrollArrow("down"),
|
|
209
|
+
Group,
|
|
210
|
+
GroupLabel,
|
|
211
|
+
/** A line between groups. */
|
|
212
|
+
Separator: part("separator", "div")
|
|
149
213
|
};
|
package/dom/slider.js
CHANGED
|
@@ -14,7 +14,7 @@ function useSlider() {
|
|
|
14
14
|
return made;
|
|
15
15
|
}
|
|
16
16
|
function Root(props) {
|
|
17
|
-
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "onValueCommitted", "min", "max", "step", "largeStep", "minStepsBetweenValues", "orientation", "disabled", "name", "format", "locale", "getAriaValueText", "id"]);
|
|
17
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "onValueCommitted", "min", "max", "step", "largeStep", "minStepsBetweenValues", "thumbAlignment", "orientation", "disabled", "name", "form", "format", "locale", "getAriaValueText", "id"]);
|
|
18
18
|
const generated = createUniqueId();
|
|
19
19
|
const field = useContext(FieldContext);
|
|
20
20
|
const made = controller(within(createSlider, {
|
package/dom/switch.js
CHANGED
|
@@ -13,7 +13,7 @@ function useSwitch() {
|
|
|
13
13
|
return made;
|
|
14
14
|
}
|
|
15
15
|
function Root(props) {
|
|
16
|
-
const [local, rest] = splitProps(props, ["checked", "defaultChecked", "onCheckedChange", "disabled", "readOnly", "required", "name", "value", "id", "children"]);
|
|
16
|
+
const [local, rest] = splitProps(props, ["checked", "defaultChecked", "onCheckedChange", "disabled", "readOnly", "required", "name", "form", "value", "id", "children"]);
|
|
17
17
|
const generated = createUniqueId();
|
|
18
18
|
const field = useContext(FieldContext);
|
|
19
19
|
const made = controller(within(createSwitch, {
|
|
@@ -26,6 +26,7 @@ function Root(props) {
|
|
|
26
26
|
readOnly: local.readOnly,
|
|
27
27
|
required: local.required,
|
|
28
28
|
name: local.name,
|
|
29
|
+
form: local.form,
|
|
29
30
|
value: local.value,
|
|
30
31
|
onCheckedChange: (checked, details) => local.onCheckedChange?.(checked, details)
|
|
31
32
|
}));
|
package/dom/toast.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { createToast } from "@kirana-ui/core/toast";
|
|
4
|
+
import { For, createContext, createMemo, createUniqueId, splitProps, useContext } from "solid-js";
|
|
5
|
+
import { Part, controller, fromSignal } from "./runtime.js";
|
|
6
|
+
const Context = createContext();
|
|
7
|
+
const ToastContext = createContext();
|
|
8
|
+
function useToast() {
|
|
9
|
+
const made = useContext(Context);
|
|
10
|
+
if (!made) throw new Error("A Toast part must be inside <Toast.Viewport>");
|
|
11
|
+
return made;
|
|
12
|
+
}
|
|
13
|
+
function useParts() {
|
|
14
|
+
const parts = useContext(ToastContext);
|
|
15
|
+
if (!parts) throw new Error("A toast's part must be inside <Toast.Root>");
|
|
16
|
+
return parts;
|
|
17
|
+
}
|
|
18
|
+
/** Where a toaster's toasts are drawn. Always in the page: put it once, near the root. */
|
|
19
|
+
function Viewport(props) {
|
|
20
|
+
const [local, rest] = splitProps(props, ["toaster", "label", "hotkey", "swipeDirection", "id"]);
|
|
21
|
+
const generated = createUniqueId();
|
|
22
|
+
const made = controller(createToast, () => ({
|
|
23
|
+
id: local.id ?? generated,
|
|
24
|
+
toaster: local.toaster,
|
|
25
|
+
label: local.label,
|
|
26
|
+
hotkey: local.hotkey,
|
|
27
|
+
swipeDirection: local.swipeDirection
|
|
28
|
+
}));
|
|
29
|
+
return _$createComponent(Context.Provider, {
|
|
30
|
+
value: made,
|
|
31
|
+
get children() {
|
|
32
|
+
return _$createComponent(Part, _$mergeProps({
|
|
33
|
+
get part() {
|
|
34
|
+
return made.viewport;
|
|
35
|
+
},
|
|
36
|
+
tag: "div"
|
|
37
|
+
}, rest));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Draws its child once for each toast, the newest first. The child is given the toast as an
|
|
43
|
+
* accessor: one that changes is the same toast, drawn again where it stands.
|
|
44
|
+
*/
|
|
45
|
+
function List(props) {
|
|
46
|
+
const toasts = fromSignal(useToast().toasts);
|
|
47
|
+
const ids = createMemo(() => toasts().map(each => each.id), undefined, {
|
|
48
|
+
equals: (a, b) => a.length === b.length && a.every((each, at) => each === b[at])
|
|
49
|
+
});
|
|
50
|
+
return _$createComponent(For, {
|
|
51
|
+
get each() {
|
|
52
|
+
return ids();
|
|
53
|
+
},
|
|
54
|
+
children: id => props.children(() => toasts().find(each => each.id === id))
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function Root(props) {
|
|
58
|
+
const [local, rest] = splitProps(props, ["toast"]);
|
|
59
|
+
// A root is its toast for as long as it is in the page.
|
|
60
|
+
const parts = useToast().toast(local.toast.id);
|
|
61
|
+
return _$createComponent(ToastContext.Provider, {
|
|
62
|
+
value: parts,
|
|
63
|
+
get children() {
|
|
64
|
+
return _$createComponent(Part, _$mergeProps({
|
|
65
|
+
get part() {
|
|
66
|
+
return parts.root;
|
|
67
|
+
},
|
|
68
|
+
tag: "div"
|
|
69
|
+
}, rest));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const Content = props => _$createComponent(Part, _$mergeProps({
|
|
74
|
+
get part() {
|
|
75
|
+
return useParts().content;
|
|
76
|
+
},
|
|
77
|
+
tag: "div"
|
|
78
|
+
}, props));
|
|
79
|
+
const Title = props => _$createComponent(Part, _$mergeProps({
|
|
80
|
+
get part() {
|
|
81
|
+
return useParts().title;
|
|
82
|
+
},
|
|
83
|
+
tag: "div"
|
|
84
|
+
}, props));
|
|
85
|
+
const Description = props => _$createComponent(Part, _$mergeProps({
|
|
86
|
+
get part() {
|
|
87
|
+
return useParts().description;
|
|
88
|
+
},
|
|
89
|
+
tag: "div"
|
|
90
|
+
}, props));
|
|
91
|
+
const Close = props => _$createComponent(Part, _$mergeProps({
|
|
92
|
+
get part() {
|
|
93
|
+
return useParts().close;
|
|
94
|
+
},
|
|
95
|
+
tag: "button"
|
|
96
|
+
}, props));
|
|
97
|
+
const Action = props => _$createComponent(Part, _$mergeProps({
|
|
98
|
+
get part() {
|
|
99
|
+
return useParts().action;
|
|
100
|
+
},
|
|
101
|
+
tag: "button"
|
|
102
|
+
}, props));
|
|
103
|
+
export const Toast = {
|
|
104
|
+
Viewport,
|
|
105
|
+
List,
|
|
106
|
+
Root,
|
|
107
|
+
Content,
|
|
108
|
+
Title,
|
|
109
|
+
Description,
|
|
110
|
+
Close,
|
|
111
|
+
Action
|
|
112
|
+
};
|
|
113
|
+
export { createToaster } from "@kirana-ui/core/toast";
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { createToggleGroup } from "@kirana-ui/core/toggle-group";
|
|
5
|
+
import { splitProps, useContext } from "solid-js";
|
|
6
|
+
import { DirectionContext } from "./direction-context.js";
|
|
7
|
+
import { Part, controller } from "./runtime.js";
|
|
8
|
+
import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
|
|
9
|
+
/** Toggles that are one control. Each `<Toggle value>` inside it is one of its toggles. */
|
|
10
|
+
export function ToggleGroup(props) {
|
|
11
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "multiple", "disabled", "orientation", "loop"]);
|
|
12
|
+
const direction = useContext(DirectionContext);
|
|
13
|
+
const toolbar = useContext(ToolbarContext) ?? undefined;
|
|
14
|
+
const made = controller(within(createToggleGroup, {
|
|
15
|
+
direction,
|
|
16
|
+
toolbar
|
|
17
|
+
}), () => ({
|
|
18
|
+
value: local.value,
|
|
19
|
+
defaultValue: local.defaultValue,
|
|
20
|
+
multiple: local.multiple,
|
|
21
|
+
disabled: local.disabled,
|
|
22
|
+
orientation: local.orientation,
|
|
23
|
+
loop: local.loop,
|
|
24
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details)
|
|
25
|
+
}));
|
|
26
|
+
return _$createComponent(ToggleGroupContext.Provider, {
|
|
27
|
+
value: made,
|
|
28
|
+
get children() {
|
|
29
|
+
return _$createComponent(Part, _$mergeProps({
|
|
30
|
+
get part() {
|
|
31
|
+
return made.root;
|
|
32
|
+
},
|
|
33
|
+
tag: "div"
|
|
34
|
+
}, rest));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|