@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/server/collapsible.js
CHANGED
|
@@ -24,7 +24,7 @@ function Root(props) {
|
|
|
24
24
|
value: made,
|
|
25
25
|
get children() {
|
|
26
26
|
return _$createComponent(Part, _$mergeProps({
|
|
27
|
-
get
|
|
27
|
+
get of() {
|
|
28
28
|
return made.root;
|
|
29
29
|
},
|
|
30
30
|
tag: "div"
|
|
@@ -33,7 +33,7 @@ function Root(props) {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
const Trigger = props => _$createComponent(Part, _$mergeProps({
|
|
36
|
-
get
|
|
36
|
+
get of() {
|
|
37
37
|
return useCollapsible().trigger;
|
|
38
38
|
},
|
|
39
39
|
tag: "button"
|
|
@@ -49,7 +49,7 @@ function Panel(props) {
|
|
|
49
49
|
},
|
|
50
50
|
get children() {
|
|
51
51
|
return _$createComponent(Part, _$mergeProps({
|
|
52
|
-
get
|
|
52
|
+
get of() {
|
|
53
53
|
return made.panel;
|
|
54
54
|
},
|
|
55
55
|
tag: "div"
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { memo as _$memo } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
4
|
+
import { within } from "@kirana-ui/core";
|
|
5
|
+
import { createAutocomplete } from "@kirana-ui/core/autocomplete";
|
|
6
|
+
import { createCombobox } from "@kirana-ui/core/combobox";
|
|
7
|
+
import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
|
|
8
|
+
import { FieldContext } from "./field-context.js";
|
|
9
|
+
import { positioned } from "./popover.js";
|
|
10
|
+
import { Part, Portal as BodyPortal, controller, fromSignal, toSignal } from "./runtime.js";
|
|
11
|
+
const Context = createContext();
|
|
12
|
+
const ItemContext = createContext();
|
|
13
|
+
function useCombobox() {
|
|
14
|
+
const made = useContext(Context);
|
|
15
|
+
if (!made) throw new Error("A Combobox part must be inside <Combobox.Root>");
|
|
16
|
+
return made;
|
|
17
|
+
}
|
|
18
|
+
function Root(props) {
|
|
19
|
+
const generated = createUniqueId();
|
|
20
|
+
const field = useContext(FieldContext);
|
|
21
|
+
const made = controller(within(createCombobox, {
|
|
22
|
+
field
|
|
23
|
+
}), () => ({
|
|
24
|
+
id: props.id ?? generated,
|
|
25
|
+
value: props.value,
|
|
26
|
+
defaultValue: props.defaultValue,
|
|
27
|
+
inputValue: props.inputValue,
|
|
28
|
+
defaultInputValue: props.defaultInputValue,
|
|
29
|
+
open: props.open,
|
|
30
|
+
defaultOpen: props.defaultOpen,
|
|
31
|
+
disabled: props.disabled,
|
|
32
|
+
required: props.required,
|
|
33
|
+
multiple: props.multiple,
|
|
34
|
+
values: props.values,
|
|
35
|
+
defaultValues: props.defaultValues,
|
|
36
|
+
onValuesChange: (values, details) => props.onValuesChange?.(values, details),
|
|
37
|
+
inline: props.inline,
|
|
38
|
+
virtualized: props.virtualized,
|
|
39
|
+
autoHighlight: props.autoHighlight,
|
|
40
|
+
name: props.name,
|
|
41
|
+
form: props.form,
|
|
42
|
+
items: props.items,
|
|
43
|
+
filter: props.filter,
|
|
44
|
+
onValueChange: (value, details) => props.onValueChange?.(value, details),
|
|
45
|
+
onInputValueChange: (value, details) => props.onInputValueChange?.(value, details),
|
|
46
|
+
onOpenChange: (open, details) => props.onOpenChange?.(open, details)
|
|
47
|
+
}));
|
|
48
|
+
const named = fromSignal(made.named);
|
|
49
|
+
return _$createComponent(Context.Provider, {
|
|
50
|
+
value: made,
|
|
51
|
+
get children() {
|
|
52
|
+
return [props.children, _$createComponent(Show, {
|
|
53
|
+
get when() {
|
|
54
|
+
return named();
|
|
55
|
+
},
|
|
56
|
+
get children() {
|
|
57
|
+
return _$createComponent(Part, {
|
|
58
|
+
get of() {
|
|
59
|
+
return made.hidden;
|
|
60
|
+
},
|
|
61
|
+
tag: "input"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
})];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const Portal = props => _$createComponent(BodyPortal, {
|
|
69
|
+
get mounted() {
|
|
70
|
+
return useCombobox().mounted;
|
|
71
|
+
},
|
|
72
|
+
get children() {
|
|
73
|
+
return props.children;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
function Positioner(props) {
|
|
77
|
+
const made = useCombobox();
|
|
78
|
+
return _$createComponent(Part, _$mergeProps({
|
|
79
|
+
get of() {
|
|
80
|
+
return made.positioner;
|
|
81
|
+
},
|
|
82
|
+
tag: "div"
|
|
83
|
+
}, () => positioned(props, made.positioning)));
|
|
84
|
+
}
|
|
85
|
+
/** `label` is what is filtered and what the input shows; the item's text when left out. */
|
|
86
|
+
function Item(props) {
|
|
87
|
+
const [local, rest] = splitProps(props, ["value", "disabled", "label", "id", "index"]);
|
|
88
|
+
// An item is its value for as long as it is in the page.
|
|
89
|
+
const value = untrack(() => local.value);
|
|
90
|
+
const generated = createUniqueId();
|
|
91
|
+
const options = toSignal(() => ({
|
|
92
|
+
disabled: local.disabled,
|
|
93
|
+
label: local.label,
|
|
94
|
+
index: local.index,
|
|
95
|
+
id: local.id ?? generated
|
|
96
|
+
}));
|
|
97
|
+
const part = useCombobox().item(value, () => options.get(), useContext(GroupContext));
|
|
98
|
+
return _$createComponent(ItemContext.Provider, {
|
|
99
|
+
value: value,
|
|
100
|
+
get children() {
|
|
101
|
+
return _$createComponent(Part, _$mergeProps({
|
|
102
|
+
of: part,
|
|
103
|
+
tag: "div"
|
|
104
|
+
}, rest));
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function ItemIndicator(props) {
|
|
109
|
+
const [local, rest] = splitProps(props, ["keepMounted"]);
|
|
110
|
+
const made = useCombobox();
|
|
111
|
+
const value = useContext(ItemContext);
|
|
112
|
+
const selected = fromSignal(made.selected(value));
|
|
113
|
+
return _$createComponent(Show, {
|
|
114
|
+
get when() {
|
|
115
|
+
return selected() || local.keepMounted;
|
|
116
|
+
},
|
|
117
|
+
get children() {
|
|
118
|
+
return _$createComponent(Part, _$mergeProps({
|
|
119
|
+
get of() {
|
|
120
|
+
return made.itemIndicator(value);
|
|
121
|
+
},
|
|
122
|
+
tag: "span"
|
|
123
|
+
}, rest));
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/** A button that empties the input and the value. Drawn while there is something to clear. */
|
|
128
|
+
function Clear(props) {
|
|
129
|
+
const [local, rest] = splitProps(props, ["keepMounted"]);
|
|
130
|
+
const made = useCombobox();
|
|
131
|
+
const clearable = fromSignal(made.clearable);
|
|
132
|
+
return _$createComponent(Show, {
|
|
133
|
+
get when() {
|
|
134
|
+
return clearable() || local.keepMounted;
|
|
135
|
+
},
|
|
136
|
+
get children() {
|
|
137
|
+
return _$createComponent(Part, _$mergeProps({
|
|
138
|
+
get of() {
|
|
139
|
+
return made.clear;
|
|
140
|
+
},
|
|
141
|
+
tag: "button"
|
|
142
|
+
}, rest));
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
const ChipContext = createContext();
|
|
147
|
+
/** With `multiple`: one chosen value. Its `value` is what its remove button takes away. */
|
|
148
|
+
function Chip(props) {
|
|
149
|
+
const [local, rest] = splitProps(props, ["value"]);
|
|
150
|
+
// A chip is its value for as long as it is in the page.
|
|
151
|
+
const value = untrack(() => local.value);
|
|
152
|
+
return _$createComponent(ChipContext.Provider, {
|
|
153
|
+
value: value,
|
|
154
|
+
get children() {
|
|
155
|
+
return _$createComponent(Part, _$mergeProps({
|
|
156
|
+
get of() {
|
|
157
|
+
return useCombobox().chip(value);
|
|
158
|
+
},
|
|
159
|
+
tag: "span"
|
|
160
|
+
}, rest));
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
const ChipRemove = props => _$createComponent(Part, _$mergeProps({
|
|
165
|
+
get of() {
|
|
166
|
+
return useCombobox().chipRemove(useContext(ChipContext));
|
|
167
|
+
},
|
|
168
|
+
tag: "button"
|
|
169
|
+
}, props));
|
|
170
|
+
/** Drawn while no item is shown for what was typed. */
|
|
171
|
+
function Empty(props) {
|
|
172
|
+
const made = useCombobox();
|
|
173
|
+
const empty = fromSignal(made.empty);
|
|
174
|
+
return _$createComponent(Show, {
|
|
175
|
+
get when() {
|
|
176
|
+
return empty();
|
|
177
|
+
},
|
|
178
|
+
get children() {
|
|
179
|
+
return _$createComponent(Part, _$mergeProps({
|
|
180
|
+
get of() {
|
|
181
|
+
return made.emptyPart;
|
|
182
|
+
},
|
|
183
|
+
tag: "div"
|
|
184
|
+
}, props));
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const GroupContext = createContext();
|
|
189
|
+
/** Items that belong together, named by their `GroupLabel`. Hidden while none is shown. */
|
|
190
|
+
function Group(props) {
|
|
191
|
+
const [local, rest] = splitProps(props, ["id"]);
|
|
192
|
+
const generated = createUniqueId();
|
|
193
|
+
const group = useCombobox().group(untrack(() => local.id) ?? generated);
|
|
194
|
+
return _$createComponent(GroupContext.Provider, {
|
|
195
|
+
value: group,
|
|
196
|
+
get children() {
|
|
197
|
+
return _$createComponent(Part, _$mergeProps({
|
|
198
|
+
get of() {
|
|
199
|
+
return group.root;
|
|
200
|
+
},
|
|
201
|
+
tag: "div"
|
|
202
|
+
}, rest));
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/** Names the group it is in. With no group around it, it is plain text. */
|
|
207
|
+
const GroupLabel = props => _$createComponent(Part, _$mergeProps({
|
|
208
|
+
get of() {
|
|
209
|
+
return useContext(GroupContext)?.label ?? useCombobox().groupLabel;
|
|
210
|
+
},
|
|
211
|
+
tag: "div"
|
|
212
|
+
}, props));
|
|
213
|
+
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
214
|
+
get of() {
|
|
215
|
+
return useCombobox()[name];
|
|
216
|
+
},
|
|
217
|
+
tag: tag
|
|
218
|
+
}, props));
|
|
219
|
+
/** A combobox whose text is the value: the list only suggests. */
|
|
220
|
+
function AutocompleteRoot(props) {
|
|
221
|
+
const generated = createUniqueId();
|
|
222
|
+
const field = useContext(FieldContext);
|
|
223
|
+
const made = controller(within(createAutocomplete, {
|
|
224
|
+
field
|
|
225
|
+
}), () => ({
|
|
226
|
+
id: props.id ?? generated,
|
|
227
|
+
value: props.value,
|
|
228
|
+
defaultValue: props.defaultValue,
|
|
229
|
+
open: props.open,
|
|
230
|
+
defaultOpen: props.defaultOpen,
|
|
231
|
+
mode: props.mode,
|
|
232
|
+
filter: props.filter,
|
|
233
|
+
openOnInputClick: props.openOnInputClick,
|
|
234
|
+
disabled: props.disabled,
|
|
235
|
+
required: props.required,
|
|
236
|
+
name: props.name,
|
|
237
|
+
form: props.form,
|
|
238
|
+
virtualized: props.virtualized,
|
|
239
|
+
autoHighlight: props.autoHighlight,
|
|
240
|
+
onValueChange: (value, details) => props.onValueChange?.(value, details),
|
|
241
|
+
onOpenChange: (open, details) => props.onOpenChange?.(open, details)
|
|
242
|
+
}));
|
|
243
|
+
return _$createComponent(Context.Provider, {
|
|
244
|
+
value: made,
|
|
245
|
+
get children() {
|
|
246
|
+
return props.children;
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
export const Combobox = {
|
|
251
|
+
Root,
|
|
252
|
+
Input: part("input", "input"),
|
|
253
|
+
Trigger: part("trigger", "button"),
|
|
254
|
+
Clear,
|
|
255
|
+
/** With `multiple`: what holds the chips and the input. */
|
|
256
|
+
Chips: part("chips", "div"),
|
|
257
|
+
Chip,
|
|
258
|
+
ChipRemove,
|
|
259
|
+
Portal,
|
|
260
|
+
Positioner,
|
|
261
|
+
Popup: part("popup", "div"),
|
|
262
|
+
/**
|
|
263
|
+
* The items' own box inside the popup, when the popup holds more than items (an input): it
|
|
264
|
+
* is then the listbox.
|
|
265
|
+
*/
|
|
266
|
+
List: part("list", "div"),
|
|
267
|
+
Group,
|
|
268
|
+
GroupLabel,
|
|
269
|
+
/** A line between groups. */
|
|
270
|
+
Separator: part("separator", "div"),
|
|
271
|
+
Item,
|
|
272
|
+
ItemIndicator,
|
|
273
|
+
Empty
|
|
274
|
+
};
|
|
275
|
+
export const Autocomplete = {
|
|
276
|
+
Root: AutocompleteRoot,
|
|
277
|
+
Input: Combobox.Input,
|
|
278
|
+
Trigger: Combobox.Trigger,
|
|
279
|
+
Clear: Combobox.Clear,
|
|
280
|
+
Portal: Combobox.Portal,
|
|
281
|
+
Positioner: Combobox.Positioner,
|
|
282
|
+
Popup: Combobox.Popup,
|
|
283
|
+
List: Combobox.List,
|
|
284
|
+
Group: Combobox.Group,
|
|
285
|
+
GroupLabel: Combobox.GroupLabel,
|
|
286
|
+
Separator: Combobox.Separator,
|
|
287
|
+
Item: Combobox.Item,
|
|
288
|
+
Empty: Combobox.Empty
|
|
289
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
|
+
import { createCommand } from "@kirana-ui/core/command";
|
|
4
|
+
import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
|
|
5
|
+
import { Part, controller, fromSignal, toSignal } from "./runtime.js";
|
|
6
|
+
const Context = createContext();
|
|
7
|
+
const GroupContext = createContext();
|
|
8
|
+
function useCommand() {
|
|
9
|
+
const made = useContext(Context);
|
|
10
|
+
if (!made) throw new Error("A Command part must be inside <Command.Root>");
|
|
11
|
+
return made;
|
|
12
|
+
}
|
|
13
|
+
function Root(props) {
|
|
14
|
+
const [local, rest] = splitProps(props, ["inputValue", "defaultInputValue", "onInputValueChange", "onSelect", "filter", "loop", "disabled", "id"]);
|
|
15
|
+
const generated = createUniqueId();
|
|
16
|
+
const made = controller(createCommand, () => ({
|
|
17
|
+
id: local.id ?? generated,
|
|
18
|
+
inputValue: local.inputValue,
|
|
19
|
+
defaultInputValue: local.defaultInputValue,
|
|
20
|
+
filter: local.filter,
|
|
21
|
+
loop: local.loop,
|
|
22
|
+
disabled: local.disabled,
|
|
23
|
+
onInputValueChange: (value, details) => local.onInputValueChange?.(value, details),
|
|
24
|
+
onSelect: (value, details) => local.onSelect?.(value, details)
|
|
25
|
+
}));
|
|
26
|
+
return _$createComponent(Context.Provider, {
|
|
27
|
+
value: made,
|
|
28
|
+
get children() {
|
|
29
|
+
return _$createComponent(Part, _$mergeProps({
|
|
30
|
+
get of() {
|
|
31
|
+
return made.root;
|
|
32
|
+
},
|
|
33
|
+
tag: "div"
|
|
34
|
+
}, rest));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const Input = props => _$createComponent(Part, _$mergeProps({
|
|
39
|
+
get of() {
|
|
40
|
+
return useCommand().input;
|
|
41
|
+
},
|
|
42
|
+
tag: "input"
|
|
43
|
+
}, props));
|
|
44
|
+
const List = props => _$createComponent(Part, _$mergeProps({
|
|
45
|
+
get of() {
|
|
46
|
+
return useCommand().list;
|
|
47
|
+
},
|
|
48
|
+
tag: "div"
|
|
49
|
+
}, props));
|
|
50
|
+
/** Drawn while no item is shown for what was typed. */
|
|
51
|
+
function Empty(props) {
|
|
52
|
+
const made = useCommand();
|
|
53
|
+
const empty = fromSignal(made.empty);
|
|
54
|
+
return _$createComponent(Show, {
|
|
55
|
+
get when() {
|
|
56
|
+
return empty();
|
|
57
|
+
},
|
|
58
|
+
get children() {
|
|
59
|
+
return _$createComponent(Part, _$mergeProps({
|
|
60
|
+
get of() {
|
|
61
|
+
return made.emptyPart;
|
|
62
|
+
},
|
|
63
|
+
tag: "div"
|
|
64
|
+
}, props));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Items under a `<Command.GroupHeading>`. Hidden while none of them is shown. */
|
|
69
|
+
function Group(props) {
|
|
70
|
+
const [local, rest] = splitProps(props, ["id"]);
|
|
71
|
+
const generated = createUniqueId();
|
|
72
|
+
const group = useCommand().group(untrack(() => local.id) ?? generated);
|
|
73
|
+
return _$createComponent(GroupContext.Provider, {
|
|
74
|
+
value: group,
|
|
75
|
+
get children() {
|
|
76
|
+
return _$createComponent(Part, _$mergeProps({
|
|
77
|
+
get of() {
|
|
78
|
+
return group.part;
|
|
79
|
+
},
|
|
80
|
+
tag: "div"
|
|
81
|
+
}, rest));
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function GroupHeading(props) {
|
|
86
|
+
const part = useContext(GroupContext)?.heading ?? useCommand().heading;
|
|
87
|
+
return _$createComponent(Part, _$mergeProps({
|
|
88
|
+
of: part,
|
|
89
|
+
tag: "div"
|
|
90
|
+
}, props));
|
|
91
|
+
}
|
|
92
|
+
/** `label` is what is filtered, the item's text when left out; `keywords` are other words for it. */
|
|
93
|
+
function Item(props) {
|
|
94
|
+
const [local, rest] = splitProps(props, ["value", "disabled", "label", "keywords", "id"]);
|
|
95
|
+
const generated = createUniqueId();
|
|
96
|
+
const options = toSignal(() => ({
|
|
97
|
+
disabled: local.disabled,
|
|
98
|
+
label: local.label,
|
|
99
|
+
keywords: local.keywords,
|
|
100
|
+
id: local.id ?? generated
|
|
101
|
+
}));
|
|
102
|
+
const part = useCommand().item(untrack(() => local.value), () => options.get(), useContext(GroupContext));
|
|
103
|
+
return _$createComponent(Part, _$mergeProps({
|
|
104
|
+
of: part,
|
|
105
|
+
tag: "div"
|
|
106
|
+
}, rest));
|
|
107
|
+
}
|
|
108
|
+
/** A line between groups: gone while something is typed, unless `alwaysRender`. */
|
|
109
|
+
function Separator(props) {
|
|
110
|
+
const [local, rest] = splitProps(props, ["alwaysRender"]);
|
|
111
|
+
const options = toSignal(() => ({
|
|
112
|
+
alwaysRender: local.alwaysRender
|
|
113
|
+
}));
|
|
114
|
+
const part = useCommand().separator(() => options.get().alwaysRender);
|
|
115
|
+
return _$createComponent(Part, _$mergeProps({
|
|
116
|
+
of: part,
|
|
117
|
+
tag: "div"
|
|
118
|
+
}, rest));
|
|
119
|
+
}
|
|
120
|
+
export const Command = {
|
|
121
|
+
Root,
|
|
122
|
+
Input,
|
|
123
|
+
List,
|
|
124
|
+
Empty,
|
|
125
|
+
Group,
|
|
126
|
+
GroupHeading,
|
|
127
|
+
Item,
|
|
128
|
+
Separator
|
|
129
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
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 { createDateField } from "@kirana-ui/core/date-field";
|
|
5
|
+
import { For, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
6
|
+
import { DirectionContext } from "./direction-context.js";
|
|
7
|
+
import { Part, controller, fromSignal } from "./runtime.js";
|
|
8
|
+
/**
|
|
9
|
+
* The date field its parts are inside. Exported for a component that is made of one (a date picker
|
|
10
|
+
* provides its own to the date field's parts).
|
|
11
|
+
*/
|
|
12
|
+
const Context = createContext();
|
|
13
|
+
/** For a component made of this one's parts: a date picker. */
|
|
14
|
+
export { Context as DateFieldContext };
|
|
15
|
+
function useDateField() {
|
|
16
|
+
const made = useContext(Context);
|
|
17
|
+
if (!made) throw new Error("A DateField part must be inside <DateField.Root>");
|
|
18
|
+
return made;
|
|
19
|
+
}
|
|
20
|
+
function Root(props) {
|
|
21
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "locale", "min", "max", "placeholders", "disabled", "readOnly", "required", "name", "form", "id"]);
|
|
22
|
+
const generated = createUniqueId();
|
|
23
|
+
const direction = useContext(DirectionContext);
|
|
24
|
+
const made = controller(within(createDateField, {
|
|
25
|
+
direction
|
|
26
|
+
}), () => ({
|
|
27
|
+
id: local.id ?? generated,
|
|
28
|
+
value: local.value,
|
|
29
|
+
defaultValue: local.defaultValue,
|
|
30
|
+
locale: local.locale,
|
|
31
|
+
min: local.min,
|
|
32
|
+
max: local.max,
|
|
33
|
+
placeholders: local.placeholders,
|
|
34
|
+
disabled: local.disabled,
|
|
35
|
+
readOnly: local.readOnly,
|
|
36
|
+
required: local.required,
|
|
37
|
+
name: local.name,
|
|
38
|
+
form: local.form,
|
|
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 of() {
|
|
46
|
+
return made.root;
|
|
47
|
+
},
|
|
48
|
+
tag: "div"
|
|
49
|
+
}, rest));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** Draws its child once for each piece of the date, in the locale's order. */
|
|
54
|
+
function Segments(props) {
|
|
55
|
+
const segments = fromSignal(useDateField().segments);
|
|
56
|
+
return _$createComponent(For, {
|
|
57
|
+
get each() {
|
|
58
|
+
return segments();
|
|
59
|
+
},
|
|
60
|
+
children: segment => props.children(segment)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** One piece: a part that is typed, or what stands between two. It writes its own text. */
|
|
64
|
+
function Segment(props) {
|
|
65
|
+
const [local, rest] = splitProps(props, ["segment"]);
|
|
66
|
+
const made = useDateField().segment(local.segment);
|
|
67
|
+
const shown = fromSignal(made.text);
|
|
68
|
+
return _$createComponent(Part, _$mergeProps({
|
|
69
|
+
get of() {
|
|
70
|
+
return made.part;
|
|
71
|
+
},
|
|
72
|
+
tag: "span"
|
|
73
|
+
}, rest, {
|
|
74
|
+
get children() {
|
|
75
|
+
return shown();
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
const Input = props => _$createComponent(Part, _$mergeProps({
|
|
80
|
+
get of() {
|
|
81
|
+
return useDateField().input;
|
|
82
|
+
},
|
|
83
|
+
tag: "input"
|
|
84
|
+
}, props));
|
|
85
|
+
export const DateField = {
|
|
86
|
+
Root,
|
|
87
|
+
Segments,
|
|
88
|
+
Segment,
|
|
89
|
+
Input
|
|
90
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
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 { createDatePicker } from "@kirana-ui/core/date-picker";
|
|
5
|
+
import { createContext, createUniqueId, useContext } from "solid-js";
|
|
6
|
+
import { Calendar, CalendarContext } from "./calendar.js";
|
|
7
|
+
import { DateField, DateFieldContext } from "./date-field.js";
|
|
8
|
+
import { DirectionContext } from "./direction-context.js";
|
|
9
|
+
import { Popover, PopoverContext } from "./popover.js";
|
|
10
|
+
import { Part, controller } from "./runtime.js";
|
|
11
|
+
const Context = createContext();
|
|
12
|
+
function useDatePicker() {
|
|
13
|
+
const made = useContext(Context);
|
|
14
|
+
if (!made) throw new Error("A DatePicker part must be inside <DatePicker.Root>");
|
|
15
|
+
return made;
|
|
16
|
+
}
|
|
17
|
+
/** A date field, and a calendar in a popover, with one value between them. It draws nothing. */
|
|
18
|
+
function Root(props) {
|
|
19
|
+
const generated = createUniqueId();
|
|
20
|
+
const made = controller(within(createDatePicker, {
|
|
21
|
+
direction: useContext(DirectionContext)
|
|
22
|
+
}), () => ({
|
|
23
|
+
id: props.id ?? generated,
|
|
24
|
+
value: props.value,
|
|
25
|
+
defaultValue: props.defaultValue,
|
|
26
|
+
open: props.open,
|
|
27
|
+
defaultOpen: props.defaultOpen,
|
|
28
|
+
locale: props.locale,
|
|
29
|
+
min: props.min,
|
|
30
|
+
max: props.max,
|
|
31
|
+
isDateUnavailable: props.isDateUnavailable,
|
|
32
|
+
calendarSystem: props.calendarSystem,
|
|
33
|
+
fixedWeeks: props.fixedWeeks,
|
|
34
|
+
placeholders: props.placeholders,
|
|
35
|
+
disabled: props.disabled,
|
|
36
|
+
readOnly: props.readOnly,
|
|
37
|
+
required: props.required,
|
|
38
|
+
name: props.name,
|
|
39
|
+
form: props.form,
|
|
40
|
+
onValueChange: (value, details) => props.onValueChange?.(value, details),
|
|
41
|
+
onOpenChange: (open, details) => props.onOpenChange?.(open, details)
|
|
42
|
+
}));
|
|
43
|
+
return _$createComponent(Context.Provider, {
|
|
44
|
+
value: made,
|
|
45
|
+
get children() {
|
|
46
|
+
return _$createComponent(DateFieldContext.Provider, {
|
|
47
|
+
get value() {
|
|
48
|
+
return made.field;
|
|
49
|
+
},
|
|
50
|
+
get children() {
|
|
51
|
+
return _$createComponent(PopoverContext.Provider, {
|
|
52
|
+
get value() {
|
|
53
|
+
return made.popover;
|
|
54
|
+
},
|
|
55
|
+
get children() {
|
|
56
|
+
return _$createComponent(CalendarContext.Provider, {
|
|
57
|
+
get value() {
|
|
58
|
+
return made.calendar;
|
|
59
|
+
},
|
|
60
|
+
get children() {
|
|
61
|
+
return props.children;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export const DatePicker = {
|
|
72
|
+
Root,
|
|
73
|
+
/** The typed date: what holds its segments and its hidden input. */
|
|
74
|
+
Field: props => _$createComponent(Part, _$mergeProps({
|
|
75
|
+
get of() {
|
|
76
|
+
return useDatePicker().field.root;
|
|
77
|
+
},
|
|
78
|
+
tag: "div"
|
|
79
|
+
}, props)),
|
|
80
|
+
Segments: DateField.Segments,
|
|
81
|
+
Segment: DateField.Segment,
|
|
82
|
+
Input: DateField.Input,
|
|
83
|
+
Trigger: Popover.Trigger,
|
|
84
|
+
Portal: Popover.Portal,
|
|
85
|
+
Positioner: Popover.Positioner,
|
|
86
|
+
Popup: Popover.Popup,
|
|
87
|
+
/** The calendar: what holds its heading, its buttons and its grid. */
|
|
88
|
+
Calendar: props => _$createComponent(Part, _$mergeProps({
|
|
89
|
+
get of() {
|
|
90
|
+
return useDatePicker().calendar.root;
|
|
91
|
+
},
|
|
92
|
+
tag: "div"
|
|
93
|
+
}, props)),
|
|
94
|
+
Heading: Calendar.Heading,
|
|
95
|
+
Previous: Calendar.Previous,
|
|
96
|
+
Next: Calendar.Next,
|
|
97
|
+
Grid: Calendar.Grid,
|
|
98
|
+
Weekdays: Calendar.Weekdays,
|
|
99
|
+
HeadCell: Calendar.HeadCell,
|
|
100
|
+
Weeks: Calendar.Weeks,
|
|
101
|
+
Cell: Calendar.Cell,
|
|
102
|
+
Day: Calendar.Day
|
|
103
|
+
};
|
package/server/dialog.js
CHANGED
|
@@ -2,6 +2,7 @@ import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
|
2
2
|
import { createComponent as _$createComponent } from "solid-js/web";
|
|
3
3
|
import { createAlertDialog } from "@kirana-ui/core/alert-dialog";
|
|
4
4
|
import { createDialog } from "@kirana-ui/core/dialog";
|
|
5
|
+
import { createDrawer } from "@kirana-ui/core/drawer";
|
|
5
6
|
import { createContext, createUniqueId, useContext } from "solid-js";
|
|
6
7
|
import { Part, Portal as BodyPortal, controller } from "./runtime.js";
|
|
7
8
|
const Context = createContext();
|
|
@@ -36,7 +37,7 @@ const Portal = props => _$createComponent(BodyPortal, {
|
|
|
36
37
|
}
|
|
37
38
|
});
|
|
38
39
|
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
39
|
-
get
|
|
40
|
+
get of() {
|
|
40
41
|
return useDialog()[name];
|
|
41
42
|
},
|
|
42
43
|
tag: tag
|
|
@@ -70,4 +71,34 @@ export const Dialog = {
|
|
|
70
71
|
export const AlertDialog = {
|
|
71
72
|
...Dialog,
|
|
72
73
|
Root: AlertRoot
|
|
74
|
+
};
|
|
75
|
+
function DrawerRoot(props) {
|
|
76
|
+
const generated = createUniqueId();
|
|
77
|
+
const made = controller(createDrawer, () => ({
|
|
78
|
+
id: props.id ?? generated,
|
|
79
|
+
open: props.open,
|
|
80
|
+
defaultOpen: props.defaultOpen,
|
|
81
|
+
modal: props.modal,
|
|
82
|
+
dismissible: props.dismissible,
|
|
83
|
+
swipeDirection: props.swipeDirection,
|
|
84
|
+
snapPoints: props.snapPoints,
|
|
85
|
+
snapPoint: props.snapPoint,
|
|
86
|
+
defaultSnapPoint: props.defaultSnapPoint,
|
|
87
|
+
onSnapPointChange: (snapPoint, details) => props.onSnapPointChange?.(snapPoint, details),
|
|
88
|
+
onOpenChange: (open, details) => props.onOpenChange?.(open, details)
|
|
89
|
+
}));
|
|
90
|
+
return _$createComponent(Context.Provider, {
|
|
91
|
+
value: made,
|
|
92
|
+
get children() {
|
|
93
|
+
return props.children;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/** A dialog that comes from an edge and is dragged back to it. Its parts are a dialog's. */
|
|
98
|
+
export const Drawer = {
|
|
99
|
+
...Dialog,
|
|
100
|
+
Root: DrawerRoot,
|
|
101
|
+
// The same components: only what `render` reads of their state is a drawer's.
|
|
102
|
+
Backdrop: Dialog.Backdrop,
|
|
103
|
+
Popup: Dialog.Popup
|
|
73
104
|
};
|
package/server/drawer.js
ADDED