@kirana-ui/solid 0.2.0 → 0.3.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/avatar.js +36 -11
- package/dom/calendar.js +66 -11
- package/dom/checkbox-group-context.js +3 -0
- package/dom/checkbox-group.js +38 -0
- package/dom/checkbox.js +6 -2
- package/dom/combobox.js +53 -3
- package/dom/command.js +2 -1
- package/dom/date-picker.js +7 -1
- package/dom/dialog.js +8 -1
- package/dom/index.js +1 -0
- package/dom/number-field.js +36 -3
- package/dom/otp.js +2 -1
- package/dom/popover.js +18 -2
- package/dom/primitive.js +92 -0
- package/dom/radio-group.js +3 -2
- package/dom/select.js +1 -0
- package/dom/slider.js +1 -1
- package/llms.txt +312 -82
- package/package.json +18 -2
- package/server/avatar.js +36 -11
- package/server/calendar.js +66 -11
- package/server/checkbox-group-context.js +3 -0
- package/server/checkbox-group.js +38 -0
- package/server/checkbox.js +6 -2
- package/server/combobox.js +53 -3
- package/server/command.js +2 -1
- package/server/date-picker.js +7 -1
- package/server/dialog.js +8 -1
- package/server/index.js +1 -0
- package/server/number-field.js +36 -3
- package/server/otp.js +2 -1
- package/server/popover.js +18 -2
- package/server/primitive.js +92 -0
- package/server/radio-group.js +3 -2
- package/server/select.js +1 -0
- package/server/slider.js +1 -1
- package/skills/kirana-ui-primitives/SKILL.md +29 -8
- package/src/avatar.jsx +16 -9
- package/src/calendar.jsx +62 -10
- package/src/checkbox-group-context.js +3 -0
- package/src/checkbox-group.jsx +33 -0
- package/src/checkbox.jsx +5 -1
- package/src/combobox.jsx +50 -1
- package/src/command.jsx +2 -0
- package/src/date-picker.jsx +6 -0
- package/src/dialog.jsx +5 -1
- package/src/index.js +1 -0
- package/src/number-field.jsx +23 -3
- package/src/otp.jsx +2 -0
- package/src/popover.jsx +15 -1
- package/src/primitive.jsx +81 -0
- package/src/radio-group.jsx +2 -2
- package/src/select.jsx +1 -0
- package/src/slider.jsx +1 -0
- package/types/alert-dialog.d.ts +1 -1
- package/types/autocomplete.d.ts +1 -1
- package/types/avatar.d.ts +5 -4
- package/types/calendar.d.ts +15 -3
- package/types/checkbox-group-context.d.ts +3 -0
- package/types/checkbox-group.d.ts +13 -0
- package/types/checkbox.d.ts +1 -0
- package/types/combobox.d.ts +41 -2
- package/types/command.d.ts +2 -0
- package/types/date-picker.d.ts +2 -1
- package/types/dialog.d.ts +5 -0
- package/types/index.d.ts +5 -2
- package/types/number-field.d.ts +9 -1
- package/types/otp.d.ts +1 -0
- package/types/popover.d.ts +17 -3
- package/types/primitive.d.ts +50 -0
- package/types/radio-group.d.ts +3 -0
package/dom/avatar.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "solid-js/web";
|
|
2
2
|
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
3
3
|
import { createAvatar } from "@kirana-ui/core/avatar";
|
|
4
|
-
import { Show, createComputed, createContext, splitProps, useContext } from "solid-js";
|
|
4
|
+
import { Show, createComputed, createContext, onCleanup, onMount, splitProps, untrack, useContext } from "solid-js";
|
|
5
5
|
import { Part, controller, fromSignal } from "./runtime.js";
|
|
6
6
|
const Context = createContext();
|
|
7
7
|
function useAvatar() {
|
|
@@ -23,33 +23,58 @@ function Root(props) {
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
/** The picture: in the page once `src` has loaded
|
|
26
|
+
/** The picture: in the page once `src` has loaded, or all along with `keepMounted`. */
|
|
27
27
|
function Image(props) {
|
|
28
|
-
const [local, rest] = splitProps(props, ["src"]);
|
|
28
|
+
const [local, rest] = splitProps(props, ["src", "onLoadingStatusChange", "keepMounted"]);
|
|
29
29
|
const made = useAvatar();
|
|
30
30
|
createComputed(() => made.source.set(local.src));
|
|
31
|
+
const report = made.statusReport(() => local.onLoadingStatusChange);
|
|
32
|
+
onMount(() => onCleanup(report.mount()));
|
|
31
33
|
const status = fromSignal(made.status);
|
|
32
34
|
return _$createComponent(Show, {
|
|
33
35
|
get when() {
|
|
34
|
-
return
|
|
36
|
+
return !local.keepMounted;
|
|
35
37
|
},
|
|
36
|
-
get
|
|
38
|
+
get fallback() {
|
|
37
39
|
return _$createComponent(Part, _$mergeProps({
|
|
38
40
|
get of() {
|
|
39
|
-
return made.
|
|
41
|
+
return made.keptImage;
|
|
40
42
|
},
|
|
41
|
-
tag: "img"
|
|
43
|
+
tag: "img",
|
|
44
|
+
get src() {
|
|
45
|
+
return local.src;
|
|
46
|
+
}
|
|
42
47
|
}, rest));
|
|
48
|
+
},
|
|
49
|
+
get children() {
|
|
50
|
+
return _$createComponent(Show, {
|
|
51
|
+
get when() {
|
|
52
|
+
return status() === "loaded";
|
|
53
|
+
},
|
|
54
|
+
get children() {
|
|
55
|
+
return _$createComponent(Part, _$mergeProps({
|
|
56
|
+
get of() {
|
|
57
|
+
return made.image;
|
|
58
|
+
},
|
|
59
|
+
tag: "img"
|
|
60
|
+
}, rest));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
43
63
|
}
|
|
44
64
|
});
|
|
45
65
|
}
|
|
46
|
-
/** What shows until the picture has loaded, or when it cannot. */
|
|
66
|
+
/** What shows until the picture has loaded, or when it cannot; after `delay`, when given one. */
|
|
47
67
|
function Fallback(props) {
|
|
68
|
+
const [local, rest] = splitProps(props, ["delay"]);
|
|
48
69
|
const made = useAvatar();
|
|
49
|
-
const
|
|
70
|
+
const presence = made.fallbackPresence({
|
|
71
|
+
delay: untrack(() => local.delay)
|
|
72
|
+
});
|
|
73
|
+
onMount(() => onCleanup(presence.mount()));
|
|
74
|
+
const shown = fromSignal(presence.shown);
|
|
50
75
|
return _$createComponent(Show, {
|
|
51
76
|
get when() {
|
|
52
|
-
return
|
|
77
|
+
return shown();
|
|
53
78
|
},
|
|
54
79
|
get children() {
|
|
55
80
|
return _$createComponent(Part, _$mergeProps({
|
|
@@ -57,7 +82,7 @@ function Fallback(props) {
|
|
|
57
82
|
return made.fallback;
|
|
58
83
|
},
|
|
59
84
|
tag: "span"
|
|
60
|
-
},
|
|
85
|
+
}, rest));
|
|
61
86
|
}
|
|
62
87
|
});
|
|
63
88
|
}
|
package/dom/calendar.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createComponent as _$createComponent } from "solid-js/web";
|
|
|
3
3
|
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
4
4
|
import { within } from "@kirana-ui/core";
|
|
5
5
|
import { createCalendar } from "@kirana-ui/core/calendar";
|
|
6
|
-
import { For, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
6
|
+
import { For, Index, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
7
7
|
import { DirectionContext } from "./direction-context.js";
|
|
8
8
|
import { Part, controller, fromSignal } from "./runtime.js";
|
|
9
9
|
/**
|
|
@@ -18,17 +18,28 @@ function useCalendar() {
|
|
|
18
18
|
if (!made) throw new Error("A Calendar part must be inside <Calendar.Root>");
|
|
19
19
|
return made;
|
|
20
20
|
}
|
|
21
|
+
/** The place of the month its parts are drawn in, inside `Calendar.Months`. */
|
|
22
|
+
const MonthContext = createContext();
|
|
23
|
+
/** The month a part is drawn in: the one `Calendar.Months` gave, or the first. */
|
|
24
|
+
const useMonth = () => useCalendar().monthAt(useContext(MonthContext) ?? 0);
|
|
21
25
|
function Root(props) {
|
|
22
|
-
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "mode", "
|
|
26
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "mode", "minDays", "maxDays", "months", "pagedNavigation", "month", "defaultMonth", "onMonthChange", "defaultFocusedValue", "locale", "calendarSystem", "min", "max", "isDateUnavailable", "disabled", "readOnly", "fixedWeeks", "name", "form", "id"]);
|
|
23
27
|
const generated = createUniqueId();
|
|
24
28
|
const direction = useContext(DirectionContext);
|
|
25
29
|
const made = controller(within(createCalendar, {
|
|
26
30
|
direction
|
|
27
31
|
}), () => ({
|
|
28
32
|
id: local.id ?? generated,
|
|
33
|
+
// The core holds any mode's value; the caller's is its mode's.
|
|
29
34
|
value: local.value,
|
|
30
35
|
defaultValue: local.defaultValue,
|
|
31
36
|
mode: local.mode,
|
|
37
|
+
minDays: local.minDays,
|
|
38
|
+
maxDays: local.maxDays,
|
|
39
|
+
months: local.months,
|
|
40
|
+
pagedNavigation: local.pagedNavigation,
|
|
41
|
+
month: local.month,
|
|
42
|
+
defaultMonth: local.defaultMonth,
|
|
32
43
|
defaultFocusedValue: local.defaultFocusedValue,
|
|
33
44
|
locale: local.locale,
|
|
34
45
|
calendarSystem: local.calendarSystem,
|
|
@@ -38,8 +49,10 @@ function Root(props) {
|
|
|
38
49
|
disabled: local.disabled,
|
|
39
50
|
readOnly: local.readOnly,
|
|
40
51
|
fixedWeeks: local.fixedWeeks,
|
|
52
|
+
name: local.name,
|
|
53
|
+
form: local.form,
|
|
41
54
|
onValueChange: (value, details) => local.onValueChange?.(value, details),
|
|
42
|
-
onMonthChange: month => local.onMonthChange?.(month)
|
|
55
|
+
onMonthChange: (month, details) => local.onMonthChange?.(month, details)
|
|
43
56
|
}));
|
|
44
57
|
return _$createComponent(Context.Provider, {
|
|
45
58
|
value: made,
|
|
@@ -55,11 +68,11 @@ function Root(props) {
|
|
|
55
68
|
}
|
|
56
69
|
/** Names the month shown, unless it is given something else to say. */
|
|
57
70
|
function Heading(props) {
|
|
58
|
-
const
|
|
59
|
-
const title = fromSignal(
|
|
71
|
+
const month = useMonth();
|
|
72
|
+
const title = fromSignal(month.title);
|
|
60
73
|
return _$createComponent(Part, _$mergeProps({
|
|
61
74
|
get of() {
|
|
62
|
-
return
|
|
75
|
+
return month.heading;
|
|
63
76
|
},
|
|
64
77
|
tag: "div"
|
|
65
78
|
}, props, {
|
|
@@ -82,10 +95,43 @@ const Next = props => _$createComponent(Part, _$mergeProps({
|
|
|
82
95
|
}, props));
|
|
83
96
|
const Grid = props => _$createComponent(Part, _$mergeProps({
|
|
84
97
|
get of() {
|
|
85
|
-
return
|
|
98
|
+
return useMonth().grid;
|
|
86
99
|
},
|
|
87
100
|
tag: "table"
|
|
88
101
|
}, props));
|
|
102
|
+
/**
|
|
103
|
+
* Draws its child once for each month shown (`months` on the root), side by side: the parts
|
|
104
|
+
* inside each are that month's. Left out for one month.
|
|
105
|
+
*/
|
|
106
|
+
function Months(props) {
|
|
107
|
+
const months = fromSignal(useCalendar().months);
|
|
108
|
+
// Kept by place: the month given reads the one now there, as props do.
|
|
109
|
+
return _$createComponent(Index, {
|
|
110
|
+
get each() {
|
|
111
|
+
return months();
|
|
112
|
+
},
|
|
113
|
+
children: (month, index) => _$createComponent(MonthContext.Provider, {
|
|
114
|
+
value: index,
|
|
115
|
+
get children() {
|
|
116
|
+
return props.children({
|
|
117
|
+
index,
|
|
118
|
+
get month() {
|
|
119
|
+
return month().month;
|
|
120
|
+
},
|
|
121
|
+
get title() {
|
|
122
|
+
return month().title;
|
|
123
|
+
},
|
|
124
|
+
get weekdays() {
|
|
125
|
+
return month().weekdays;
|
|
126
|
+
},
|
|
127
|
+
get weeks() {
|
|
128
|
+
return month().weeks;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
}
|
|
89
135
|
/** Draws its child once for each day of the week, in the locale's order. */
|
|
90
136
|
function Weekdays(props) {
|
|
91
137
|
const weekdays = fromSignal(useCalendar().weekdays);
|
|
@@ -98,7 +144,7 @@ function Weekdays(props) {
|
|
|
98
144
|
}
|
|
99
145
|
/** Draws its child once for each week of the month shown. */
|
|
100
146
|
function Weeks(props) {
|
|
101
|
-
const weeks = fromSignal(
|
|
147
|
+
const weeks = fromSignal(useMonth().weeks);
|
|
102
148
|
return _$createComponent(For, {
|
|
103
149
|
get each() {
|
|
104
150
|
return weeks();
|
|
@@ -117,7 +163,7 @@ function HeadCell(props) {
|
|
|
117
163
|
function Cell(props) {
|
|
118
164
|
const [local, rest] = splitProps(props, ["date"]);
|
|
119
165
|
// A cell is its day for as long as it is in the page.
|
|
120
|
-
const part = useCalendar().cell(local.date);
|
|
166
|
+
const part = useCalendar().cell(local.date, useContext(MonthContext));
|
|
121
167
|
return _$createComponent(Part, _$mergeProps({
|
|
122
168
|
of: part,
|
|
123
169
|
tag: "td"
|
|
@@ -125,21 +171,30 @@ function Cell(props) {
|
|
|
125
171
|
}
|
|
126
172
|
function Day(props) {
|
|
127
173
|
const [local, rest] = splitProps(props, ["date"]);
|
|
128
|
-
const part = useCalendar().day(local.date);
|
|
174
|
+
const part = useCalendar().day(local.date, useContext(MonthContext));
|
|
129
175
|
return _$createComponent(Part, _$mergeProps({
|
|
130
176
|
of: part,
|
|
131
177
|
tag: "button"
|
|
132
178
|
}, rest));
|
|
133
179
|
}
|
|
180
|
+
/** The hidden input the value is submitted by, when the root has a `name`. */
|
|
181
|
+
const Input = props => _$createComponent(Part, _$mergeProps({
|
|
182
|
+
get of() {
|
|
183
|
+
return useCalendar().input;
|
|
184
|
+
},
|
|
185
|
+
tag: "input"
|
|
186
|
+
}, props));
|
|
134
187
|
export const Calendar = {
|
|
135
188
|
Root,
|
|
136
189
|
Heading,
|
|
137
190
|
Previous,
|
|
138
191
|
Next,
|
|
192
|
+
Months,
|
|
139
193
|
Grid,
|
|
140
194
|
Weekdays,
|
|
141
195
|
HeadCell,
|
|
142
196
|
Weeks,
|
|
143
197
|
Cell,
|
|
144
|
-
Day
|
|
198
|
+
Day,
|
|
199
|
+
Input
|
|
145
200
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { createCheckboxGroup } from "@kirana-ui/core/checkbox-group";
|
|
5
|
+
import { createUniqueId, splitProps, useContext } from "solid-js";
|
|
6
|
+
import { CheckboxGroupContext } from "./checkbox-group-context.js";
|
|
7
|
+
import { FieldContext } from "./field-context.js";
|
|
8
|
+
import { Part, controller } from "./runtime.js";
|
|
9
|
+
/**
|
|
10
|
+
* Checkboxes that hold one list of values. Each `<Checkbox.Root value>` inside it is checked
|
|
11
|
+
* while the list has its value; with `allValues`, a `<Checkbox.Root parent>` stands for them all.
|
|
12
|
+
*/
|
|
13
|
+
export function CheckboxGroup(props) {
|
|
14
|
+
const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "allValues", "disabled", "id"]);
|
|
15
|
+
const generated = createUniqueId();
|
|
16
|
+
const field = useContext(FieldContext);
|
|
17
|
+
const made = controller(within(createCheckboxGroup, {
|
|
18
|
+
field
|
|
19
|
+
}), () => ({
|
|
20
|
+
id: local.id ?? generated,
|
|
21
|
+
value: local.value,
|
|
22
|
+
defaultValue: local.defaultValue,
|
|
23
|
+
allValues: local.allValues,
|
|
24
|
+
disabled: local.disabled,
|
|
25
|
+
onValueChange: (value, details) => local.onValueChange?.(value, details)
|
|
26
|
+
}));
|
|
27
|
+
return _$createComponent(CheckboxGroupContext.Provider, {
|
|
28
|
+
value: made,
|
|
29
|
+
get children() {
|
|
30
|
+
return _$createComponent(Part, _$mergeProps({
|
|
31
|
+
get of() {
|
|
32
|
+
return made.root;
|
|
33
|
+
},
|
|
34
|
+
tag: "div"
|
|
35
|
+
}, rest));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
package/dom/checkbox.js
CHANGED
|
@@ -4,6 +4,7 @@ import { memo as _$memo } from "solid-js/web";
|
|
|
4
4
|
import { within } from "@kirana-ui/core";
|
|
5
5
|
import { createCheckbox } from "@kirana-ui/core/checkbox";
|
|
6
6
|
import { Show, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
7
|
+
import { CheckboxGroupContext } from "./checkbox-group-context.js";
|
|
7
8
|
import { FieldContext } from "./field-context.js";
|
|
8
9
|
import { Part, controller, fromSignal } from "./runtime.js";
|
|
9
10
|
const Context = createContext();
|
|
@@ -13,16 +14,19 @@ function useCheckbox() {
|
|
|
13
14
|
return made;
|
|
14
15
|
}
|
|
15
16
|
function Root(props) {
|
|
16
|
-
const [local, rest] = splitProps(props, ["checked", "defaultChecked", "onCheckedChange", "indeterminate", "disabled", "readOnly", "required", "name", "form", "value", "id", "children"]);
|
|
17
|
+
const [local, rest] = splitProps(props, ["checked", "defaultChecked", "onCheckedChange", "indeterminate", "parent", "disabled", "readOnly", "required", "name", "form", "value", "id", "children"]);
|
|
17
18
|
const generated = createUniqueId();
|
|
18
19
|
const field = useContext(FieldContext);
|
|
20
|
+
const group = useContext(CheckboxGroupContext) ?? undefined;
|
|
19
21
|
const made = controller(within(createCheckbox, {
|
|
20
|
-
field
|
|
22
|
+
field,
|
|
23
|
+
group
|
|
21
24
|
}), () => ({
|
|
22
25
|
id: local.id ?? generated,
|
|
23
26
|
checked: local.checked,
|
|
24
27
|
defaultChecked: local.defaultChecked,
|
|
25
28
|
indeterminate: local.indeterminate,
|
|
29
|
+
parent: local.parent,
|
|
26
30
|
disabled: local.disabled,
|
|
27
31
|
readOnly: local.readOnly,
|
|
28
32
|
required: local.required,
|
package/dom/combobox.js
CHANGED
|
@@ -4,7 +4,7 @@ import { memo as _$memo } from "solid-js/web";
|
|
|
4
4
|
import { within } from "@kirana-ui/core";
|
|
5
5
|
import { createAutocomplete } from "@kirana-ui/core/autocomplete";
|
|
6
6
|
import { createCombobox } from "@kirana-ui/core/combobox";
|
|
7
|
-
import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
|
|
7
|
+
import { For, Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
|
|
8
8
|
import { FieldContext } from "./field-context.js";
|
|
9
9
|
import { positioned } from "./popover.js";
|
|
10
10
|
import { Part, Portal as BodyPortal, controller, fromSignal, toSignal } from "./runtime.js";
|
|
@@ -29,6 +29,7 @@ function Root(props) {
|
|
|
29
29
|
open: props.open,
|
|
30
30
|
defaultOpen: props.defaultOpen,
|
|
31
31
|
disabled: props.disabled,
|
|
32
|
+
readOnly: props.readOnly,
|
|
32
33
|
required: props.required,
|
|
33
34
|
multiple: props.multiple,
|
|
34
35
|
values: props.values,
|
|
@@ -210,6 +211,43 @@ const GroupLabel = props => _$createComponent(Part, _$mergeProps({
|
|
|
210
211
|
},
|
|
211
212
|
tag: "div"
|
|
212
213
|
}, props));
|
|
214
|
+
/**
|
|
215
|
+
* The chosen value's label, or `placeholder` while nothing is chosen; with `multiple`, the
|
|
216
|
+
* chosen labels with commas between. For a button that is the combobox, its input inside the
|
|
217
|
+
* popup. It draws no element.
|
|
218
|
+
*/
|
|
219
|
+
function Value(props) {
|
|
220
|
+
const made = useCombobox();
|
|
221
|
+
const shown = fromSignal(made.shown);
|
|
222
|
+
return _$memo(() => {
|
|
223
|
+
const given = props.children;
|
|
224
|
+
// A function that takes nothing is an element of Solid's own, drawn as it is.
|
|
225
|
+
if (typeof given !== "function" || given.length === 0) {
|
|
226
|
+
return given ?? shown().label ?? props.placeholder;
|
|
227
|
+
}
|
|
228
|
+
const draw = given;
|
|
229
|
+
return made.multiple ? draw(() => shown().values, () => shown().labels) : draw(() => shown().value, () => shown().label);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Draws the list from the root's `items`: its child once for each item left for what was
|
|
234
|
+
* typed, or for each group that has items left; with `of`, for each of that group's. The root
|
|
235
|
+
* then filters, and no item hides itself. It draws no element.
|
|
236
|
+
*/
|
|
237
|
+
function Collection(props) {
|
|
238
|
+
const made = useCombobox();
|
|
239
|
+
// A group is known by its key, which is its own for as long as it is drawn.
|
|
240
|
+
const entries = fromSignal(made.entries(untrack(() => props.of)));
|
|
241
|
+
// By key: an item that is left keeps its element.
|
|
242
|
+
const keys = () => entries().map(each => each.key);
|
|
243
|
+
const of = key => entries().find(each => each.key === key);
|
|
244
|
+
return _$createComponent(For, {
|
|
245
|
+
get each() {
|
|
246
|
+
return keys();
|
|
247
|
+
},
|
|
248
|
+
children: key => props.children(untrack(() => of(key)))
|
|
249
|
+
});
|
|
250
|
+
}
|
|
213
251
|
const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
214
252
|
get of() {
|
|
215
253
|
return useCombobox()[name];
|
|
@@ -232,6 +270,8 @@ function AutocompleteRoot(props) {
|
|
|
232
270
|
filter: props.filter,
|
|
233
271
|
openOnInputClick: props.openOnInputClick,
|
|
234
272
|
disabled: props.disabled,
|
|
273
|
+
readOnly: props.readOnly,
|
|
274
|
+
items: props.items,
|
|
235
275
|
required: props.required,
|
|
236
276
|
name: props.name,
|
|
237
277
|
form: props.form,
|
|
@@ -251,6 +291,7 @@ export const Combobox = {
|
|
|
251
291
|
Root,
|
|
252
292
|
Input: part("input", "input"),
|
|
253
293
|
Trigger: part("trigger", "button"),
|
|
294
|
+
Value,
|
|
254
295
|
Clear,
|
|
255
296
|
/** With `multiple`: what holds the chips and the input. */
|
|
256
297
|
Chips: part("chips", "div"),
|
|
@@ -264,13 +305,20 @@ export const Combobox = {
|
|
|
264
305
|
* is then the listbox.
|
|
265
306
|
*/
|
|
266
307
|
List: part("list", "div"),
|
|
308
|
+
Collection,
|
|
267
309
|
Group,
|
|
268
310
|
GroupLabel,
|
|
269
311
|
/** A line between groups. */
|
|
270
312
|
Separator: part("separator", "div"),
|
|
271
313
|
Item,
|
|
272
314
|
ItemIndicator,
|
|
273
|
-
Empty
|
|
315
|
+
Empty,
|
|
316
|
+
/**
|
|
317
|
+
* Says how the list stands ("3 results", "Loading") to software that reads the page, as its
|
|
318
|
+
* text changes. Keep it in the page and change what it holds: inside the popup, or beside
|
|
319
|
+
* the input.
|
|
320
|
+
*/
|
|
321
|
+
Status: part("status", "div")
|
|
274
322
|
};
|
|
275
323
|
export const Autocomplete = {
|
|
276
324
|
Root: AutocompleteRoot,
|
|
@@ -281,9 +329,11 @@ export const Autocomplete = {
|
|
|
281
329
|
Positioner: Combobox.Positioner,
|
|
282
330
|
Popup: Combobox.Popup,
|
|
283
331
|
List: Combobox.List,
|
|
332
|
+
Collection: Combobox.Collection,
|
|
284
333
|
Group: Combobox.Group,
|
|
285
334
|
GroupLabel: Combobox.GroupLabel,
|
|
286
335
|
Separator: Combobox.Separator,
|
|
287
336
|
Item: Combobox.Item,
|
|
288
|
-
Empty: Combobox.Empty
|
|
337
|
+
Empty: Combobox.Empty,
|
|
338
|
+
Status: Combobox.Status
|
|
289
339
|
};
|
package/dom/command.js
CHANGED
|
@@ -11,7 +11,7 @@ function useCommand() {
|
|
|
11
11
|
return made;
|
|
12
12
|
}
|
|
13
13
|
function Root(props) {
|
|
14
|
-
const [local, rest] = splitProps(props, ["inputValue", "defaultInputValue", "onInputValueChange", "onSelect", "filter", "loop", "disabled", "id"]);
|
|
14
|
+
const [local, rest] = splitProps(props, ["inputValue", "defaultInputValue", "onInputValueChange", "onSelect", "filter", "loop", "autoHighlight", "disabled", "id"]);
|
|
15
15
|
const generated = createUniqueId();
|
|
16
16
|
const made = controller(createCommand, () => ({
|
|
17
17
|
id: local.id ?? generated,
|
|
@@ -19,6 +19,7 @@ function Root(props) {
|
|
|
19
19
|
defaultInputValue: local.defaultInputValue,
|
|
20
20
|
filter: local.filter,
|
|
21
21
|
loop: local.loop,
|
|
22
|
+
autoHighlight: local.autoHighlight,
|
|
22
23
|
disabled: local.disabled,
|
|
23
24
|
onInputValueChange: (value, details) => local.onInputValueChange?.(value, details),
|
|
24
25
|
onSelect: (value, details) => local.onSelect?.(value, details)
|
package/dom/date-picker.js
CHANGED
|
@@ -31,6 +31,10 @@ function Root(props) {
|
|
|
31
31
|
isDateUnavailable: props.isDateUnavailable,
|
|
32
32
|
calendarSystem: props.calendarSystem,
|
|
33
33
|
fixedWeeks: props.fixedWeeks,
|
|
34
|
+
months: props.months,
|
|
35
|
+
pagedNavigation: props.pagedNavigation,
|
|
36
|
+
month: props.month,
|
|
37
|
+
defaultMonth: props.defaultMonth,
|
|
34
38
|
placeholders: props.placeholders,
|
|
35
39
|
disabled: props.disabled,
|
|
36
40
|
readOnly: props.readOnly,
|
|
@@ -38,7 +42,8 @@ function Root(props) {
|
|
|
38
42
|
name: props.name,
|
|
39
43
|
form: props.form,
|
|
40
44
|
onValueChange: (value, details) => props.onValueChange?.(value, details),
|
|
41
|
-
onOpenChange: (open, details) => props.onOpenChange?.(open, details)
|
|
45
|
+
onOpenChange: (open, details) => props.onOpenChange?.(open, details),
|
|
46
|
+
onMonthChange: (month, details) => props.onMonthChange?.(month, details)
|
|
42
47
|
}));
|
|
43
48
|
return _$createComponent(Context.Provider, {
|
|
44
49
|
value: made,
|
|
@@ -94,6 +99,7 @@ export const DatePicker = {
|
|
|
94
99
|
Heading: Calendar.Heading,
|
|
95
100
|
Previous: Calendar.Previous,
|
|
96
101
|
Next: Calendar.Next,
|
|
102
|
+
Months: Calendar.Months,
|
|
97
103
|
Grid: Calendar.Grid,
|
|
98
104
|
Weekdays: Calendar.Weekdays,
|
|
99
105
|
HeadCell: Calendar.HeadCell,
|
package/dom/dialog.js
CHANGED
|
@@ -62,6 +62,8 @@ export const Dialog = {
|
|
|
62
62
|
Portal,
|
|
63
63
|
Trigger: part("trigger", "button"),
|
|
64
64
|
Backdrop: part("backdrop", "div"),
|
|
65
|
+
/** What a long dialog scrolls in, around its popup: it may be left out. */
|
|
66
|
+
Viewport: part("viewport", "div"),
|
|
65
67
|
Popup: part("popup", "div"),
|
|
66
68
|
Title: part("title", "h2"),
|
|
67
69
|
Description: part("description", "p"),
|
|
@@ -94,9 +96,14 @@ function DrawerRoot(props) {
|
|
|
94
96
|
}
|
|
95
97
|
});
|
|
96
98
|
}
|
|
99
|
+
// A drawer has no viewport: it lies at an edge of the page, and what scrolls is inside it.
|
|
100
|
+
const {
|
|
101
|
+
Viewport: _,
|
|
102
|
+
...shared
|
|
103
|
+
} = Dialog;
|
|
97
104
|
/** A dialog that comes from an edge and is dragged back to it. Its parts are a dialog's. */
|
|
98
105
|
export const Drawer = {
|
|
99
|
-
...
|
|
106
|
+
...shared,
|
|
100
107
|
Root: DrawerRoot,
|
|
101
108
|
// The same components: only what `render` reads of their state is a drawer's.
|
|
102
109
|
Backdrop: Dialog.Backdrop,
|
package/dom/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Accordion } from "./accordion.js";
|
|
2
2
|
export { Checkbox } from "./checkbox.js";
|
|
3
|
+
export { CheckboxGroup } from "./checkbox-group.js";
|
|
3
4
|
export { Collapsible } from "./collapsible.js";
|
|
4
5
|
export { AlertDialog, Dialog, Drawer } from "./dialog.js";
|
|
5
6
|
export { MessageScroller } from "./message-scroller.js";
|
package/dom/number-field.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
2
2
|
import { createComponent as _$createComponent } from "solid-js/web";
|
|
3
3
|
import { memo as _$memo } from "solid-js/web";
|
|
4
|
-
import { within } from "@kirana-ui/core";
|
|
4
|
+
import { defined, within } from "@kirana-ui/core";
|
|
5
5
|
import { createNumberField } from "@kirana-ui/core/number-field";
|
|
6
|
-
import { Show, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
6
|
+
import { Show, createComputed, createContext, createUniqueId, splitProps, useContext } from "solid-js";
|
|
7
7
|
import { FieldContext } from "./field-context.js";
|
|
8
|
-
import { Part, controller, fromSignal } from "./runtime.js";
|
|
8
|
+
import { Part, Portal, controller, fromSignal } from "./runtime.js";
|
|
9
9
|
const Context = createContext();
|
|
10
10
|
function useNumberField() {
|
|
11
11
|
const made = useContext(Context);
|
|
@@ -73,8 +73,41 @@ const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
|
73
73
|
},
|
|
74
74
|
tag: tag
|
|
75
75
|
}, props));
|
|
76
|
+
/** Pressed and dragged to change the number; `direction`, `pixelSensitivity`, `teleportDistance`. */
|
|
77
|
+
function ScrubArea(props) {
|
|
78
|
+
const [local, rest] = splitProps(props, ["direction", "pixelSensitivity", "teleportDistance"]);
|
|
79
|
+
const made = useNumberField();
|
|
80
|
+
createComputed(() => made.scrub.set(defined({
|
|
81
|
+
...local
|
|
82
|
+
})));
|
|
83
|
+
return _$createComponent(Part, _$mergeProps({
|
|
84
|
+
get of() {
|
|
85
|
+
return made.scrubArea;
|
|
86
|
+
},
|
|
87
|
+
tag: "span"
|
|
88
|
+
}, rest));
|
|
89
|
+
}
|
|
90
|
+
/** Drawn in place of the pointer while it is locked for a drag, at the end of `<body>`. */
|
|
91
|
+
function ScrubAreaCursor(props) {
|
|
92
|
+
const made = useNumberField();
|
|
93
|
+
return _$createComponent(Portal, {
|
|
94
|
+
get mounted() {
|
|
95
|
+
return made.scrubAreaCursor.mounted;
|
|
96
|
+
},
|
|
97
|
+
get children() {
|
|
98
|
+
return _$createComponent(Part, _$mergeProps({
|
|
99
|
+
get of() {
|
|
100
|
+
return made.scrubAreaCursor.part;
|
|
101
|
+
},
|
|
102
|
+
tag: "span"
|
|
103
|
+
}, props));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
76
107
|
export const NumberField = {
|
|
77
108
|
Root,
|
|
109
|
+
ScrubArea,
|
|
110
|
+
ScrubAreaCursor,
|
|
78
111
|
Group: part("group", "div"),
|
|
79
112
|
Input: part("input", "input"),
|
|
80
113
|
Increment: part("increment", "button"),
|
package/dom/otp.js
CHANGED
|
@@ -12,7 +12,7 @@ function useOtp() {
|
|
|
12
12
|
return made;
|
|
13
13
|
}
|
|
14
14
|
function Root(props) {
|
|
15
|
-
const [local, rest] = splitProps(props, ["length", "value", "defaultValue", "onValueChange", "onComplete", "mode", "disabled", "name", "form", "id"]);
|
|
15
|
+
const [local, rest] = splitProps(props, ["length", "value", "defaultValue", "onValueChange", "onComplete", "mode", "pattern", "disabled", "name", "form", "id"]);
|
|
16
16
|
const generated = createUniqueId();
|
|
17
17
|
const made = controller(createOtp, () => ({
|
|
18
18
|
id: local.id ?? generated,
|
|
@@ -20,6 +20,7 @@ function Root(props) {
|
|
|
20
20
|
value: local.value,
|
|
21
21
|
defaultValue: local.defaultValue,
|
|
22
22
|
mode: local.mode,
|
|
23
|
+
pattern: local.pattern,
|
|
23
24
|
disabled: local.disabled,
|
|
24
25
|
name: local.name,
|
|
25
26
|
form: local.form,
|
package/dom/popover.js
CHANGED
|
@@ -21,6 +21,7 @@ function Root(props) {
|
|
|
21
21
|
const made = controller(createPopover, () => ({
|
|
22
22
|
id: props.id ?? generated,
|
|
23
23
|
open: props.open,
|
|
24
|
+
modal: props.modal,
|
|
24
25
|
defaultOpen: props.defaultOpen,
|
|
25
26
|
onOpenChange: (open, details) => props.onOpenChange?.(open, details)
|
|
26
27
|
}));
|
|
@@ -44,7 +45,7 @@ const Portal = props => _$createComponent(BodyPortal, {
|
|
|
44
45
|
* attaches: the one place they are named. Gives back what is left, for the part's element.
|
|
45
46
|
*/
|
|
46
47
|
export function positioned(props, positioning) {
|
|
47
|
-
const [local, rest] = splitProps(props, ["side", "align", "sideOffset", "alignOffset", "collisionPadding", "anchor"]);
|
|
48
|
+
const [local, rest] = splitProps(props, ["side", "align", "sideOffset", "alignOffset", "collisionPadding", "collisionBoundary", "collisionAvoidance", "sticky", "arrowPadding", "positionMethod", "anchor"]);
|
|
48
49
|
createComputed(() => {
|
|
49
50
|
const anchor = local.anchor;
|
|
50
51
|
positioning.set(defined({
|
|
@@ -71,12 +72,27 @@ const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
|
|
|
71
72
|
},
|
|
72
73
|
tag: tag
|
|
73
74
|
}, props));
|
|
75
|
+
function Trigger(props) {
|
|
76
|
+
const [local, rest] = splitProps(props, ["openOnHover", "delay", "closeDelay"]);
|
|
77
|
+
const made = usePopover();
|
|
78
|
+
createComputed(() => made.hovering.set(defined({
|
|
79
|
+
...local
|
|
80
|
+
})));
|
|
81
|
+
return _$createComponent(Part, _$mergeProps({
|
|
82
|
+
get of() {
|
|
83
|
+
return made.trigger;
|
|
84
|
+
},
|
|
85
|
+
tag: "button"
|
|
86
|
+
}, rest));
|
|
87
|
+
}
|
|
74
88
|
export const Popover = {
|
|
75
89
|
Root,
|
|
76
90
|
Portal,
|
|
91
|
+
Backdrop: part("backdrop", "div"),
|
|
77
92
|
Positioner,
|
|
78
|
-
Trigger
|
|
93
|
+
Trigger,
|
|
79
94
|
Popup: part("popup", "div"),
|
|
95
|
+
Arrow: part("arrow", "div"),
|
|
80
96
|
Title: part("title", "h2"),
|
|
81
97
|
Description: part("description", "p"),
|
|
82
98
|
Close: part("close", "button")
|