@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
package/dom/runtime.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
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
|
-
import { mergeProps, sameProps, signal } from "@kirana-ui/core";
|
|
5
|
-
import { Show, createComputed, createMemo, createSignal, getOwner, onCleanup, onMount, runWithOwner, splitProps, untrack } from "solid-js";
|
|
4
|
+
import { mergeProps, sameProps, signal, stateOf } from "@kirana-ui/core";
|
|
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) {
|
|
@@ -36,12 +36,15 @@ function toSolid(props) {
|
|
|
36
36
|
return out;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
* part's and the part's DOM work attached once the element is in the page.
|
|
39
|
+
* The element of a part (`of`), or the caller's through `render`, with the caller's props merged under the
|
|
40
|
+
* part's and the part's DOM work attached once the element is in the page. What the part holds
|
|
41
|
+
* is its children here: with `as` they are the element's, and with `render` they are handed to
|
|
42
|
+
* the caller's function as the `children` of its props, so a control drawn as another element
|
|
43
|
+
* keeps the native input a form and a label reach.
|
|
41
44
|
*/
|
|
42
45
|
export function Part(props) {
|
|
43
|
-
const [local, caller] = splitProps(props, ["
|
|
44
|
-
const own = fromSignal(untrack(() => local.
|
|
46
|
+
const [local, caller] = splitProps(props, ["of", "tag", "as", "render", "children"]);
|
|
47
|
+
const own = fromSignal(untrack(() => local.of).props);
|
|
45
48
|
// Solid hands over an element before it is in the page: the part's DOM work (focus, measures,
|
|
46
49
|
// the starting style) waits for the mount that follows. It belongs to this component, not to
|
|
47
50
|
// the effect that spreads the props (which hands the ref over again, and is torn down, each time
|
|
@@ -51,8 +54,11 @@ export function Part(props) {
|
|
|
51
54
|
const attach = element => {
|
|
52
55
|
if (element === attached) return;
|
|
53
56
|
attached = element;
|
|
54
|
-
const part = untrack(() => local.
|
|
57
|
+
const part = untrack(() => local.of);
|
|
55
58
|
runWithOwner(owner, () => onMount(() => onCleanup(part.attach(element))));
|
|
59
|
+
// The caller's own `ref` (Solid hands a component a function, whatever was written).
|
|
60
|
+
const theirs = untrack(() => caller.ref);
|
|
61
|
+
if (typeof theirs === "function") theirs(element);
|
|
56
62
|
};
|
|
57
63
|
const merged = createMemo(() => {
|
|
58
64
|
const theirs = {};
|
|
@@ -62,6 +68,7 @@ export function Part(props) {
|
|
|
62
68
|
ref: attach
|
|
63
69
|
};
|
|
64
70
|
});
|
|
71
|
+
const state = () => stateOf(own());
|
|
65
72
|
return _$createComponent(Show, {
|
|
66
73
|
get when() {
|
|
67
74
|
return local.render;
|
|
@@ -77,19 +84,62 @@ export function Part(props) {
|
|
|
77
84
|
}
|
|
78
85
|
}));
|
|
79
86
|
},
|
|
80
|
-
children: render =>
|
|
87
|
+
children: render => {
|
|
88
|
+
// Resolved once: a change of the part's props hands the same nodes over again, and
|
|
89
|
+
// the element keeps them.
|
|
90
|
+
const held = children(() => local.children);
|
|
91
|
+
const handed = createMemo(() => ({
|
|
92
|
+
...merged(),
|
|
93
|
+
children: held()
|
|
94
|
+
}));
|
|
95
|
+
return render()(handed, state);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Its children as children of `target`, an element drawn elsewhere: with no element of its own
|
|
101
|
+
* around them (Solid's `Portal` adds one), so the page is the same as on the other adapters.
|
|
102
|
+
*/
|
|
103
|
+
export function Into(props) {
|
|
104
|
+
const resolved = children(() => props.children);
|
|
105
|
+
// Before any mount work of the children: their elements are in the page by then.
|
|
106
|
+
createRenderEffect(() => {
|
|
107
|
+
const target = props.target;
|
|
108
|
+
const nodes = resolved.toArray().filter(each => each instanceof Node);
|
|
109
|
+
for (const node of nodes) target.appendChild(node);
|
|
110
|
+
onCleanup(() => {
|
|
111
|
+
for (const node of nodes) if (node.parentNode === target) target.removeChild(node);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
const PortalContainer = createContext();
|
|
117
|
+
/**
|
|
118
|
+
* Says where every popup inside it is drawn, the popups those open included: an element of
|
|
119
|
+
* the page (a shadow root's host, a full-screen element) in place of `<body>`.
|
|
120
|
+
*/
|
|
121
|
+
export function PortalProvider(props) {
|
|
122
|
+
return _$createComponent(PortalContainer.Provider, {
|
|
123
|
+
value: () => props.container,
|
|
124
|
+
get children() {
|
|
125
|
+
return props.children;
|
|
126
|
+
}
|
|
81
127
|
});
|
|
82
128
|
}
|
|
83
129
|
/** Its children in a container at the end of the page, while `mounted`. */
|
|
84
130
|
export function Portal(props) {
|
|
85
131
|
const shown = fromSignal(untrack(() => props.mounted));
|
|
132
|
+
const container = useContext(PortalContainer);
|
|
86
133
|
return _$createComponent(Show, {
|
|
87
134
|
get when() {
|
|
88
135
|
return shown();
|
|
89
136
|
},
|
|
90
137
|
get children() {
|
|
91
138
|
return _$createComponent(SolidPortal, {
|
|
92
|
-
|
|
139
|
+
get mount() {
|
|
140
|
+
return container?.() ?? undefined;
|
|
141
|
+
},
|
|
142
|
+
ref: outlet => outlet.setAttribute("data-kirana-portal", ""),
|
|
93
143
|
get children() {
|
|
94
144
|
return props.children;
|
|
95
145
|
}
|
|
@@ -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 of() {
|
|
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 of() {
|
|
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 of() {
|
|
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 of() {
|
|
79
|
+
return corner.part;
|
|
80
|
+
},
|
|
81
|
+
tag: "div"
|
|
82
|
+
}, props));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const part = name => props => _$createComponent(Part, _$mergeProps({
|
|
87
|
+
get of() {
|
|
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,8 +28,14 @@ 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
|
+
multiple: props.multiple,
|
|
34
|
+
values: props.values,
|
|
35
|
+
defaultValues: props.defaultValues,
|
|
36
|
+
virtualized: props.virtualized,
|
|
32
37
|
onValueChange: (value, details) => props.onValueChange?.(value, details),
|
|
38
|
+
onValuesChange: (values, details) => props.onValuesChange?.(values, details),
|
|
33
39
|
onOpenChange: (open, details) => props.onOpenChange?.(open, details)
|
|
34
40
|
}));
|
|
35
41
|
const named = fromSignal(made.named);
|
|
@@ -42,7 +48,7 @@ function Root(props) {
|
|
|
42
48
|
},
|
|
43
49
|
get children() {
|
|
44
50
|
return _$createComponent(Part, {
|
|
45
|
-
get
|
|
51
|
+
get of() {
|
|
46
52
|
return made.input;
|
|
47
53
|
},
|
|
48
54
|
tag: "input"
|
|
@@ -60,53 +66,68 @@ const Portal = props => _$createComponent(BodyPortal, {
|
|
|
60
66
|
return props.children;
|
|
61
67
|
}
|
|
62
68
|
});
|
|
69
|
+
/**
|
|
70
|
+
* `alignItemWithTrigger`: the list opens over its trigger, the chosen item's text on the
|
|
71
|
+
* trigger's own, where there is room and unless a finger opened it.
|
|
72
|
+
*/
|
|
63
73
|
function Positioner(props) {
|
|
64
74
|
const made = useSelect();
|
|
75
|
+
const [local, rest] = splitProps(props, ["alignItemWithTrigger"]);
|
|
76
|
+
createComputed(() => made.alignItemWithTrigger.set(Boolean(local.alignItemWithTrigger)));
|
|
65
77
|
return _$createComponent(Part, _$mergeProps({
|
|
66
|
-
get
|
|
78
|
+
get of() {
|
|
67
79
|
return made.positioner;
|
|
68
80
|
},
|
|
69
81
|
tag: "div"
|
|
70
|
-
}, () => positioned(
|
|
82
|
+
}, () => positioned(rest, made.positioning)));
|
|
71
83
|
}
|
|
72
|
-
/** Shows the chosen value's label, or `placeholder` while nothing is chosen. */
|
|
73
84
|
function Value(props) {
|
|
74
85
|
const [local, rest] = splitProps(props, ["placeholder", "children"]);
|
|
75
86
|
const made = useSelect();
|
|
76
|
-
const
|
|
87
|
+
const shown = fromSignal(made.shown);
|
|
88
|
+
const drawn = () => {
|
|
89
|
+
const given = local.children;
|
|
90
|
+
// A function that takes nothing is an element of Solid's own, drawn as it is.
|
|
91
|
+
if (typeof given !== "function" || given.length === 0) {
|
|
92
|
+
return given ?? shown().label ?? local.placeholder;
|
|
93
|
+
}
|
|
94
|
+
const draw = given;
|
|
95
|
+
return made.multiple ? draw(() => shown().values, () => shown().labels) : draw(() => shown().value, () => shown().label);
|
|
96
|
+
};
|
|
77
97
|
return _$createComponent(Part, _$mergeProps({
|
|
78
|
-
get
|
|
98
|
+
get of() {
|
|
79
99
|
return made.valuePart;
|
|
80
100
|
},
|
|
81
101
|
tag: "span"
|
|
82
102
|
}, rest, {
|
|
83
103
|
get children() {
|
|
84
|
-
return
|
|
104
|
+
return drawn();
|
|
85
105
|
}
|
|
86
106
|
}));
|
|
87
107
|
}
|
|
88
108
|
/** `label` is what typeahead matches and the trigger shows; the item's text when left out. */
|
|
89
109
|
function Item(props) {
|
|
90
|
-
const [local, rest] = splitProps(props, ["value", "disabled", "label"]);
|
|
110
|
+
const [local, rest] = splitProps(props, ["value", "disabled", "label", "index"]);
|
|
91
111
|
// An item is its value for as long as it is in the page.
|
|
92
112
|
const value = untrack(() => local.value);
|
|
93
113
|
const options = toSignal(() => ({
|
|
94
114
|
disabled: local.disabled,
|
|
95
|
-
label: local.label
|
|
115
|
+
label: local.label,
|
|
116
|
+
index: local.index
|
|
96
117
|
}));
|
|
97
118
|
const part = useSelect().item(value, () => defined(options.get()));
|
|
98
119
|
return _$createComponent(ItemContext.Provider, {
|
|
99
120
|
value: value,
|
|
100
121
|
get children() {
|
|
101
122
|
return _$createComponent(Part, _$mergeProps({
|
|
102
|
-
|
|
123
|
+
of: part,
|
|
103
124
|
tag: "div"
|
|
104
125
|
}, rest));
|
|
105
126
|
}
|
|
106
127
|
});
|
|
107
128
|
}
|
|
108
129
|
const ItemText = props => _$createComponent(Part, _$mergeProps({
|
|
109
|
-
get
|
|
130
|
+
get of() {
|
|
110
131
|
return useSelect().itemText(useContext(ItemContext));
|
|
111
132
|
},
|
|
112
133
|
tag: "span"
|
|
@@ -122,7 +143,7 @@ function ItemIndicator(props) {
|
|
|
122
143
|
},
|
|
123
144
|
get children() {
|
|
124
145
|
return _$createComponent(Part, _$mergeProps({
|
|
125
|
-
get
|
|
146
|
+
get of() {
|
|
126
147
|
return made.itemIndicator(value);
|
|
127
148
|
},
|
|
128
149
|
tag: "span"
|
|
@@ -130,8 +151,53 @@ function ItemIndicator(props) {
|
|
|
130
151
|
}
|
|
131
152
|
});
|
|
132
153
|
}
|
|
154
|
+
const GroupContext = createContext();
|
|
155
|
+
/** Items that belong together, named by their `<Select.GroupLabel>`. */
|
|
156
|
+
function Group(props) {
|
|
157
|
+
const [local, rest] = splitProps(props, ["id"]);
|
|
158
|
+
const generated = createUniqueId();
|
|
159
|
+
const group = useSelect().group(untrack(() => local.id) ?? generated);
|
|
160
|
+
return _$createComponent(GroupContext.Provider, {
|
|
161
|
+
value: group,
|
|
162
|
+
get children() {
|
|
163
|
+
return _$createComponent(Part, _$mergeProps({
|
|
164
|
+
get of() {
|
|
165
|
+
return group.root;
|
|
166
|
+
},
|
|
167
|
+
tag: "div"
|
|
168
|
+
}, rest));
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/** Names the group it is in. With no group around it, it is plain text. */
|
|
173
|
+
const GroupLabel = props => _$createComponent(Part, _$mergeProps({
|
|
174
|
+
get of() {
|
|
175
|
+
return useContext(GroupContext)?.label ?? useSelect().groupLabel;
|
|
176
|
+
},
|
|
177
|
+
tag: "div"
|
|
178
|
+
}, props));
|
|
179
|
+
function scrollArrow(direction) {
|
|
180
|
+
return props => {
|
|
181
|
+
const arrow = useSelect().scrollArrow(direction);
|
|
182
|
+
onMount(() => onCleanup(arrow.mount()));
|
|
183
|
+
const mounted = fromSignal(arrow.mounted);
|
|
184
|
+
return _$createComponent(Show, {
|
|
185
|
+
get when() {
|
|
186
|
+
return mounted();
|
|
187
|
+
},
|
|
188
|
+
get children() {
|
|
189
|
+
return _$createComponent(Part, _$mergeProps({
|
|
190
|
+
get of() {
|
|
191
|
+
return arrow.part;
|
|
192
|
+
},
|
|
193
|
+
tag: "div"
|
|
194
|
+
}, props));
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
}
|
|
133
199
|
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
134
|
-
get
|
|
200
|
+
get of() {
|
|
135
201
|
return useSelect()[name];
|
|
136
202
|
},
|
|
137
203
|
tag: tag
|
|
@@ -145,5 +211,15 @@ export const Select = {
|
|
|
145
211
|
ItemText,
|
|
146
212
|
ItemIndicator,
|
|
147
213
|
Trigger: part("trigger", "button"),
|
|
148
|
-
Popup: part("popup", "div")
|
|
214
|
+
Popup: part("popup", "div"),
|
|
215
|
+
/** The items' own box inside the popup, when the popup also holds scroll arrows. */
|
|
216
|
+
List: part("list", "div"),
|
|
217
|
+
/** In the page while there is more of the list above: it scrolls it under a moving pointer. */
|
|
218
|
+
ScrollUpArrow: scrollArrow("up"),
|
|
219
|
+
/** In the page while there is more of the list below. */
|
|
220
|
+
ScrollDownArrow: scrollArrow("down"),
|
|
221
|
+
Group,
|
|
222
|
+
GroupLabel,
|
|
223
|
+
/** A line between groups. */
|
|
224
|
+
Separator: part("separator", "div")
|
|
149
225
|
};
|
package/dom/separator.js
CHANGED
package/dom/slider.js
CHANGED
|
@@ -13,8 +13,9 @@ function useSlider() {
|
|
|
13
13
|
if (!made) throw new Error("A Slider part must be inside <Slider.Root>");
|
|
14
14
|
return made;
|
|
15
15
|
}
|
|
16
|
+
// Given neither `value` nor `defaultValue`, a slider has one thumb: its value is a number.
|
|
16
17
|
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"]);
|
|
18
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "onValueCommitted", "min", "max", "step", "largeStep", "minStepsBetweenValues", "thumbAlignment", "orientation", "disabled", "name", "form", "format", "locale", "getAriaValueText", "id"]);
|
|
18
19
|
const generated = createUniqueId();
|
|
19
20
|
const field = useContext(FieldContext);
|
|
20
21
|
const made = controller(within(createSlider, {
|
|
@@ -30,7 +31,7 @@ function Root(props) {
|
|
|
30
31
|
value: made,
|
|
31
32
|
get children() {
|
|
32
33
|
return _$createComponent(Part, _$mergeProps({
|
|
33
|
-
get
|
|
34
|
+
get of() {
|
|
34
35
|
return made.root;
|
|
35
36
|
},
|
|
36
37
|
tag: "div"
|
|
@@ -41,18 +42,20 @@ function Root(props) {
|
|
|
41
42
|
/** `index` is which value of a range the thumb is, from 0. */
|
|
42
43
|
function Thumb(props) {
|
|
43
44
|
const [local, rest] = splitProps(props, ["index", "children"]);
|
|
44
|
-
// A thumb is its index for as long as it is in the page.
|
|
45
|
-
|
|
45
|
+
// A thumb is its index for as long as it is in the page. Given none, it takes its place
|
|
46
|
+
// among the slider's thumbs, in the order they are written.
|
|
47
|
+
const generated = createUniqueId();
|
|
48
|
+
const index = untrack(() => local.index ?? generated);
|
|
46
49
|
const slider = useSlider();
|
|
47
50
|
return _$createComponent(Part, _$mergeProps({
|
|
48
|
-
get
|
|
51
|
+
get of() {
|
|
49
52
|
return slider.thumb(index);
|
|
50
53
|
},
|
|
51
54
|
tag: "div"
|
|
52
55
|
}, rest, {
|
|
53
56
|
get children() {
|
|
54
57
|
return [_$memo(() => local.children), _$createComponent(Part, {
|
|
55
|
-
get
|
|
58
|
+
get of() {
|
|
56
59
|
return slider.thumbInput(index);
|
|
57
60
|
},
|
|
58
61
|
tag: "input"
|
|
@@ -67,7 +70,7 @@ function Value(props) {
|
|
|
67
70
|
const text = fromSignal(made.text);
|
|
68
71
|
const values = fromSignal(made.values);
|
|
69
72
|
return _$createComponent(Part, _$mergeProps({
|
|
70
|
-
get
|
|
73
|
+
get of() {
|
|
71
74
|
return made.value;
|
|
72
75
|
},
|
|
73
76
|
tag: "output"
|
|
@@ -78,7 +81,7 @@ function Value(props) {
|
|
|
78
81
|
}));
|
|
79
82
|
}
|
|
80
83
|
const part = key => props => _$createComponent(Part, _$mergeProps({
|
|
81
|
-
get
|
|
84
|
+
get of() {
|
|
82
85
|
return useSlider()[key];
|
|
83
86
|
},
|
|
84
87
|
tag: "div"
|
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
|
}));
|
|
@@ -33,14 +34,14 @@ function Root(props) {
|
|
|
33
34
|
value: made,
|
|
34
35
|
get children() {
|
|
35
36
|
return _$createComponent(Part, _$mergeProps({
|
|
36
|
-
get
|
|
37
|
+
get of() {
|
|
37
38
|
return made.root;
|
|
38
39
|
},
|
|
39
40
|
tag: "span"
|
|
40
41
|
}, rest, {
|
|
41
42
|
get children() {
|
|
42
43
|
return [_$memo(() => local.children), _$createComponent(Part, {
|
|
43
|
-
get
|
|
44
|
+
get of() {
|
|
44
45
|
return made.input;
|
|
45
46
|
},
|
|
46
47
|
tag: "input"
|
|
@@ -51,7 +52,7 @@ function Root(props) {
|
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
const Thumb = props => _$createComponent(Part, _$mergeProps({
|
|
54
|
-
get
|
|
55
|
+
get of() {
|
|
55
56
|
return useSwitch().thumb;
|
|
56
57
|
},
|
|
57
58
|
tag: "span"
|
package/dom/tabs.js
CHANGED
|
@@ -29,7 +29,7 @@ function Root(props) {
|
|
|
29
29
|
value: made,
|
|
30
30
|
get children() {
|
|
31
31
|
return _$createComponent(Part, _$mergeProps({
|
|
32
|
-
get
|
|
32
|
+
get of() {
|
|
33
33
|
return made.root;
|
|
34
34
|
},
|
|
35
35
|
tag: "div"
|
|
@@ -44,7 +44,7 @@ function List(props) {
|
|
|
44
44
|
...local
|
|
45
45
|
})));
|
|
46
46
|
return _$createComponent(Part, _$mergeProps({
|
|
47
|
-
get
|
|
47
|
+
get of() {
|
|
48
48
|
return made.list;
|
|
49
49
|
},
|
|
50
50
|
tag: "div"
|
|
@@ -58,12 +58,12 @@ function Tab(props) {
|
|
|
58
58
|
// A tab is its value for as long as it is in the page.
|
|
59
59
|
const part = useTabs().tab(untrack(() => local.value), () => defined(options.get()));
|
|
60
60
|
return _$createComponent(Part, _$mergeProps({
|
|
61
|
-
|
|
61
|
+
of: part,
|
|
62
62
|
tag: "button"
|
|
63
63
|
}, rest));
|
|
64
64
|
}
|
|
65
65
|
const Indicator = props => _$createComponent(Part, _$mergeProps({
|
|
66
|
-
get
|
|
66
|
+
get of() {
|
|
67
67
|
return useTabs().indicator;
|
|
68
68
|
},
|
|
69
69
|
tag: "span"
|
|
@@ -80,7 +80,7 @@ function Panel(props) {
|
|
|
80
80
|
},
|
|
81
81
|
get children() {
|
|
82
82
|
return _$createComponent(Part, _$mergeProps({
|
|
83
|
-
get
|
|
83
|
+
get of() {
|
|
84
84
|
return panel.part;
|
|
85
85
|
},
|
|
86
86
|
tag: "div"
|
package/dom/testing.js
ADDED