@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.
Files changed (71) hide show
  1. package/dom/avatar.js +36 -11
  2. package/dom/calendar.js +66 -11
  3. package/dom/checkbox-group-context.js +3 -0
  4. package/dom/checkbox-group.js +38 -0
  5. package/dom/checkbox.js +6 -2
  6. package/dom/combobox.js +53 -3
  7. package/dom/command.js +2 -1
  8. package/dom/date-picker.js +7 -1
  9. package/dom/dialog.js +8 -1
  10. package/dom/index.js +1 -0
  11. package/dom/number-field.js +36 -3
  12. package/dom/otp.js +2 -1
  13. package/dom/popover.js +18 -2
  14. package/dom/primitive.js +92 -0
  15. package/dom/radio-group.js +3 -2
  16. package/dom/select.js +1 -0
  17. package/dom/slider.js +1 -1
  18. package/llms.txt +312 -82
  19. package/package.json +18 -2
  20. package/server/avatar.js +36 -11
  21. package/server/calendar.js +66 -11
  22. package/server/checkbox-group-context.js +3 -0
  23. package/server/checkbox-group.js +38 -0
  24. package/server/checkbox.js +6 -2
  25. package/server/combobox.js +53 -3
  26. package/server/command.js +2 -1
  27. package/server/date-picker.js +7 -1
  28. package/server/dialog.js +8 -1
  29. package/server/index.js +1 -0
  30. package/server/number-field.js +36 -3
  31. package/server/otp.js +2 -1
  32. package/server/popover.js +18 -2
  33. package/server/primitive.js +92 -0
  34. package/server/radio-group.js +3 -2
  35. package/server/select.js +1 -0
  36. package/server/slider.js +1 -1
  37. package/skills/kirana-ui-primitives/SKILL.md +29 -8
  38. package/src/avatar.jsx +16 -9
  39. package/src/calendar.jsx +62 -10
  40. package/src/checkbox-group-context.js +3 -0
  41. package/src/checkbox-group.jsx +33 -0
  42. package/src/checkbox.jsx +5 -1
  43. package/src/combobox.jsx +50 -1
  44. package/src/command.jsx +2 -0
  45. package/src/date-picker.jsx +6 -0
  46. package/src/dialog.jsx +5 -1
  47. package/src/index.js +1 -0
  48. package/src/number-field.jsx +23 -3
  49. package/src/otp.jsx +2 -0
  50. package/src/popover.jsx +15 -1
  51. package/src/primitive.jsx +81 -0
  52. package/src/radio-group.jsx +2 -2
  53. package/src/select.jsx +1 -0
  54. package/src/slider.jsx +1 -0
  55. package/types/alert-dialog.d.ts +1 -1
  56. package/types/autocomplete.d.ts +1 -1
  57. package/types/avatar.d.ts +5 -4
  58. package/types/calendar.d.ts +15 -3
  59. package/types/checkbox-group-context.d.ts +3 -0
  60. package/types/checkbox-group.d.ts +13 -0
  61. package/types/checkbox.d.ts +1 -0
  62. package/types/combobox.d.ts +41 -2
  63. package/types/command.d.ts +2 -0
  64. package/types/date-picker.d.ts +2 -1
  65. package/types/dialog.d.ts +5 -0
  66. package/types/index.d.ts +5 -2
  67. package/types/number-field.d.ts +9 -1
  68. package/types/otp.d.ts +1 -0
  69. package/types/popover.d.ts +17 -3
  70. package/types/primitive.d.ts +50 -0
  71. package/types/radio-group.d.ts +3 -0
@@ -0,0 +1,92 @@
1
+ import { mergeProps as _$mergeProps } from "solid-js/web";
2
+ import { memo as _$memo } from "solid-js/web";
3
+ import { createComponent as _$createComponent } from "solid-js/web";
4
+ import { mergeProps as layer, stateAttributes } from "@kirana-ui/core";
5
+ import { Show, children, createMemo, splitProps } from "solid-js";
6
+ import { Dynamic } from "solid-js/web";
7
+ /**
8
+ * A plain element of one's own (a badge, a breadcrumb's link) with the composition a part has:
9
+ * `as` for another tag (a `div` unless said), or `render` for the caller's own element, given the
10
+ * props to spread and the state. `state` is written as `data-*` attributes under the attributes
11
+ * given. Merge the component's own props with its caller's through `mergeProps`, as a part's
12
+ * are merged.
13
+ */
14
+ export function Primitive(props) {
15
+ const [local, rest] = splitProps(props, ["as", "render", "state", "children"]);
16
+ const marks = () => stateAttributes(local.state ?? {});
17
+ return _$createComponent(Show, {
18
+ get when() {
19
+ return local.render;
20
+ },
21
+ get fallback() {
22
+ return _$createComponent(Dynamic, _$mergeProps({
23
+ get component() {
24
+ return local.as ?? "div";
25
+ }
26
+ }, marks, rest, {
27
+ get children() {
28
+ return local.children;
29
+ }
30
+ }));
31
+ },
32
+ children: render => {
33
+ // Resolved once, as a part's are: a change of the props hands the same nodes over again.
34
+ const held = children(() => local.children);
35
+ const handed = createMemo(() => {
36
+ const given = {
37
+ ...marks()
38
+ };
39
+ for (const key of Object.keys(rest)) given[key] = rest[key];
40
+ return {
41
+ ...given,
42
+ children: held()
43
+ };
44
+ });
45
+ return render()(handed, () => local.state ?? {});
46
+ }
47
+ });
48
+ }
49
+ /** One key of several sets, by a part's rule. */
50
+ function mergedValue(sets, key) {
51
+ if (key === "ref") {
52
+ // Solid hands a component a function whatever was written: each set's gets the element.
53
+ const refs = sets.map(set => set?.ref).filter(ref => typeof ref === "function");
54
+ if (refs.length < 2) return refs[0];
55
+ return element => {
56
+ for (const ref of refs) ref(element);
57
+ };
58
+ }
59
+ let merged = {};
60
+ for (const set of sets) if (set && key in set) merged = layer(merged, {
61
+ [key]: set[key]
62
+ });
63
+ return merged[key];
64
+ }
65
+ /**
66
+ * Several sets of props as one, for a component's own props and its caller's: a later set
67
+ * wins an attribute it gives (one it leaves `undefined` stays), classes join, styles are
68
+ * merged property by property, the handlers of an event run in order until one calls
69
+ * `event.preventKiranaHandler()`, which stops those after it, and every `ref` gets the
70
+ * element. It reads its sets when a prop is read, so a component's props stay reactive: spread
71
+ * it (`<Primitive {...mergeProps({ class: "badge" }, props)} />`). Not solid-js's
72
+ * `mergeProps`, where a later class replaces an earlier one: import one under another name
73
+ * where both are used.
74
+ */
75
+ export function mergeProps(...sets) {
76
+ const keys = () => {
77
+ const all = new Set();
78
+ for (const set of sets) if (set) for (const key of Object.keys(set)) all.add(key);
79
+ return [...all];
80
+ };
81
+ const given = sets;
82
+ return new Proxy({}, {
83
+ get: (_, key) => typeof key === "string" ? mergedValue(given, key) : undefined,
84
+ has: (_, key) => typeof key === "string" && keys().includes(key),
85
+ ownKeys: () => keys(),
86
+ getOwnPropertyDescriptor: (_, key) => typeof key === "string" && keys().includes(key) ? {
87
+ configurable: true,
88
+ enumerable: true,
89
+ get: () => mergedValue(given, key)
90
+ } : undefined
91
+ });
92
+ }
@@ -45,11 +45,12 @@ function Root(props) {
45
45
  });
46
46
  }
47
47
  function Item(props) {
48
- const [local, rest] = splitProps(props, ["value", "disabled", "children"]);
48
+ const [local, rest] = splitProps(props, ["value", "disabled", "id", "children"]);
49
49
  // An item is its value for as long as it is in the page.
50
50
  const value = untrack(() => local.value);
51
51
  const options = toSignal(() => ({
52
- disabled: local.disabled
52
+ disabled: local.disabled,
53
+ id: local.id
53
54
  }));
54
55
  const read = () => defined(options.get());
55
56
  const group = useRadioGroup();
package/server/select.js CHANGED
@@ -26,6 +26,7 @@ function Root(props) {
26
26
  open: props.open,
27
27
  defaultOpen: props.defaultOpen,
28
28
  disabled: props.disabled,
29
+ readOnly: props.readOnly,
29
30
  required: props.required,
30
31
  name: props.name,
31
32
  form: props.form,
package/server/slider.js CHANGED
@@ -14,7 +14,7 @@ function useSlider() {
14
14
  }
15
15
  // Given neither `value` nor `defaultValue`, a slider has one thumb: its value is a number.
16
16
  function Root(props) {
17
- const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "onValueCommitted", "min", "max", "step", "largeStep", "minStepsBetweenValues", "thumbAlignment", "orientation", "disabled", "name", "form", "format", "locale", "getAriaValueText", "id"]);
17
+ const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "onValueCommitted", "min", "max", "step", "largeStep", "minStepsBetweenValues", "thumbAlignment", "orientation", "disabled", "readOnly", "name", "form", "format", "locale", "getAriaValueText", "id"]);
18
18
  const generated = createUniqueId();
19
19
  const field = useContext(FieldContext);
20
20
  const made = controller(within(createSlider, {
@@ -33,10 +33,16 @@ from one core. The package for a framework is all a project installs.
33
33
  A popup that is placed against its trigger (a popover, a menu, a select, a combobox, a
34
34
  tooltip, a hover card) is `Portal > Positioner > Popup`: the `Positioner` takes `side`
35
35
  (also `inline-start` and `inline-end`, which turn with the reading direction, and which
36
- `data-side` then says), `align`, `sideOffset`, `alignOffset`, `collisionPadding`, and
36
+ `data-side` then says), `align`, `sideOffset` and `alignOffset` (a number, or a function
37
+ of the anchor's and the positioner's sizes), `collisionPadding` (a number, or one a side),
38
+ `collisionBoundary`, `collisionAvoidance`, `sticky`, `arrowPadding`, `positionMethod`, and
37
39
  `anchor` for another element than its trigger to be placed against (an element, the
38
- framework's own ref to one, or a function that gives one). A dialog, an alert dialog and a
39
- drawer have no positioner: `Portal > Backdrop` and `Popup`, placed by the design.
40
+ framework's own ref to one, or a function that gives one). A popup that holds an `Arrow`
41
+ is given `position: relative`, so the arrow is placed in it through its entrance and
42
+ after. A popover may have a `Backdrop` in its portal, is `modal` (`true`: the page is
43
+ inert and does not scroll; `"trap-focus"`: only Tab is kept inside), and its trigger's
44
+ `openOnHover` lets the pointer open it too. A dialog, an alert dialog and a drawer have
45
+ no positioner: `Portal > Backdrop` and `Popup`, placed by the design.
40
46
  3. Style by attributes and variables, never by guessing class names:
41
47
  - a boolean state is present or absent: `[data-open]`, never `[data-open="true"]`;
42
48
  - an entrance starts from `[data-starting-style]`, an exit ends at
@@ -55,8 +61,8 @@ from one core. The package for a framework is all a project installs.
55
61
  Per framework: React takes `render` for another element; Vue takes `as` / `as-child`, binds
56
62
  with `v-model:value` and names props in kebab case; Svelte takes a `child` snippet and
57
63
  `bind:value`; Solid takes `as` and `render`; Angular's parts are directives on your own
58
- elements (`<button kuiDialogTrigger>`), bound with `[(value)]`, with `[kuiId]` for an id, and
59
- a part that comes and goes is structural (`*kuiDialogPortal`, `*kuiTabsPanel`: the list is in
64
+ elements (`<button kpDialogTrigger>`), bound with `[(value)]`, with `[kpId]` for an id, and
65
+ a part that comes and goes is structural (`*kpDialogPortal`, `*kpTabsPanel`: the list is in
60
66
  `llms.txt`); custom elements name each part with `kui-part` inside `<kui-dialog>`.
61
67
 
62
68
  Composing a part with another element: with React's `render={<a … />}` and Vue's `as-child`
@@ -72,9 +78,24 @@ the text a part writes (`Meter.Value`, `Select.Value`) stay inside it on React a
72
78
  `props().children` on Solid, and are given to a Svelte `child` snippet to render
73
79
  (`{ props, state, input }`, `{ props, state, text }`). A handler given to a part is typed
74
80
  with `preventKiranaHandler()` (`PartEvent`, exported by each package). For an element of the
75
- design system's own that takes `render` or `as-child`, use `useRender` and `mergeProps` from
76
- `@kirana-ui/react/use-render`, or `Primitive` from `@kirana-ui/vue/primitive`; never write
77
- another merge.
81
+ design system's own composed as a part is, use `useRender` and `mergeProps` from
82
+ `@kirana-ui/react/use-render`, `Primitive` from `@kirana-ui/vue/primitive`, or `Primitive`
83
+ and `mergeProps` from `@kirana-ui/solid/primitive` and `@kirana-ui/svelte/primitive` (Solid's
84
+ `as` and `render`, Svelte's `as` and `child`, a `state` written as `data-*`); never write
85
+ another merge. On Angular such an element is a directive of your own with host bindings, and
86
+ custom elements need nothing: the page writes its own element.
87
+
88
+ A design system on Angular hosts each primitive in a directive of its own
89
+ (`hostDirectives: [{ directive: KpDialog, inputs: [...], outputs: [...] }]`), exposing what
90
+ its callers set; gives the primitive the rest with `hostInputs(KpTooltip, { delay: () => 0 })`
91
+ in its constructor (each value a function read like a signal, so `computed` values follow;
92
+ an input the element binds wins), never a subclass of the primitive; draws a structural part
93
+ (`kpDialogPortal`) in a component's template around `<ng-content />` (a part given to it finds
94
+ its root where it is written); and names its own directives as it likes, `kui…` included:
95
+ the primitives are `kp…` so that no design system's selector is theirs (two directives with
96
+ one selector both match, silently, and a component whose selector is its host's recurses).
97
+ Tooltips need no provider on any
98
+ framework: a design system passes `delay` on its own tooltip root (`hostInputs` on Angular).
78
99
 
79
100
  ## When something is wrong
80
101
 
package/src/avatar.jsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createAvatar } from "@kirana-ui/core/avatar";
2
- import { Show, createComputed, createContext, splitProps, useContext } from "solid-js";
2
+ import { Show, createComputed, createContext, onCleanup, onMount, splitProps, untrack, useContext, } from "solid-js";
3
3
  import { Part, controller, fromSignal } from "./runtime.jsx";
4
4
  const Context = createContext();
5
5
  function useAvatar() {
@@ -14,22 +14,29 @@ function Root(props) {
14
14
  <Part of={made.root} tag="span" {...props}/>
15
15
  </Context.Provider>);
16
16
  }
17
- /** The picture: in the page once `src` has loaded. */
17
+ /** The picture: in the page once `src` has loaded, or all along with `keepMounted`. */
18
18
  function Image(props) {
19
- const [local, rest] = splitProps(props, ["src"]);
19
+ const [local, rest] = splitProps(props, ["src", "onLoadingStatusChange", "keepMounted"]);
20
20
  const made = useAvatar();
21
21
  createComputed(() => made.source.set(local.src));
22
+ const report = made.statusReport(() => local.onLoadingStatusChange);
23
+ onMount(() => onCleanup(report.mount()));
22
24
  const status = fromSignal(made.status);
23
- return (<Show when={status() === "loaded"}>
24
- <Part of={made.image} tag="img" {...rest}/>
25
+ return (<Show when={!local.keepMounted} fallback={<Part of={made.keptImage} tag="img" src={local.src} {...rest}/>}>
26
+ <Show when={status() === "loaded"}>
27
+ <Part of={made.image} tag="img" {...rest}/>
28
+ </Show>
25
29
  </Show>);
26
30
  }
27
- /** What shows until the picture has loaded, or when it cannot. */
31
+ /** What shows until the picture has loaded, or when it cannot; after `delay`, when given one. */
28
32
  function Fallback(props) {
33
+ const [local, rest] = splitProps(props, ["delay"]);
29
34
  const made = useAvatar();
30
- const status = fromSignal(made.status);
31
- return (<Show when={status() !== "loaded"}>
32
- <Part of={made.fallback} tag="span" {...props}/>
35
+ const presence = made.fallbackPresence({ delay: untrack(() => local.delay) });
36
+ onMount(() => onCleanup(presence.mount()));
37
+ const shown = fromSignal(presence.shown);
38
+ return (<Show when={shown()}>
39
+ <Part of={made.fallback} tag="span" {...rest}/>
33
40
  </Show>);
34
41
  }
35
42
  export const Avatar = { Root, Image, Fallback };
package/src/calendar.jsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { within } from "@kirana-ui/core";
2
2
  import { createCalendar } from "@kirana-ui/core/calendar";
3
- import { For, createContext, createUniqueId, splitProps, useContext } from "solid-js";
3
+ import { For, Index, createContext, createUniqueId, splitProps, useContext } from "solid-js";
4
4
  import { DirectionContext } from "./direction-context.js";
5
5
  import { Part, controller, fromSignal } from "./runtime.jsx";
6
6
  /**
@@ -16,14 +16,24 @@ function useCalendar() {
16
16
  throw new Error("A Calendar part must be inside <Calendar.Root>");
17
17
  return made;
18
18
  }
19
+ /** The place of the month its parts are drawn in, inside `Calendar.Months`. */
20
+ const MonthContext = createContext();
21
+ /** The month a part is drawn in: the one `Calendar.Months` gave, or the first. */
22
+ const useMonth = () => useCalendar().monthAt(useContext(MonthContext) ?? 0);
19
23
  function Root(props) {
20
24
  const [local, rest] = splitProps(props, [
21
25
  "value",
22
26
  "defaultValue",
23
27
  "onValueChange",
24
28
  "mode",
25
- "defaultFocusedValue",
29
+ "minDays",
30
+ "maxDays",
31
+ "months",
32
+ "pagedNavigation",
33
+ "month",
34
+ "defaultMonth",
26
35
  "onMonthChange",
36
+ "defaultFocusedValue",
27
37
  "locale",
28
38
  "calendarSystem",
29
39
  "min",
@@ -32,15 +42,24 @@ function Root(props) {
32
42
  "disabled",
33
43
  "readOnly",
34
44
  "fixedWeeks",
45
+ "name",
46
+ "form",
35
47
  "id",
36
48
  ]);
37
49
  const generated = createUniqueId();
38
50
  const direction = useContext(DirectionContext);
39
51
  const made = controller(within(createCalendar, { direction }), () => ({
40
52
  id: local.id ?? generated,
53
+ // The core holds any mode's value; the caller's is its mode's.
41
54
  value: local.value,
42
55
  defaultValue: local.defaultValue,
43
56
  mode: local.mode,
57
+ minDays: local.minDays,
58
+ maxDays: local.maxDays,
59
+ months: local.months,
60
+ pagedNavigation: local.pagedNavigation,
61
+ month: local.month,
62
+ defaultMonth: local.defaultMonth,
44
63
  defaultFocusedValue: local.defaultFocusedValue,
45
64
  locale: local.locale,
46
65
  calendarSystem: local.calendarSystem,
@@ -50,8 +69,10 @@ function Root(props) {
50
69
  disabled: local.disabled,
51
70
  readOnly: local.readOnly,
52
71
  fixedWeeks: local.fixedWeeks,
72
+ name: local.name,
73
+ form: local.form,
53
74
  onValueChange: (value, details) => local.onValueChange?.(value, details),
54
- onMonthChange: (month) => local.onMonthChange?.(month),
75
+ onMonthChange: (month, details) => local.onMonthChange?.(month, details),
55
76
  }));
56
77
  return (<Context.Provider value={made}>
57
78
  <Part of={made.root} tag="div" {...rest}/>
@@ -59,15 +80,42 @@ function Root(props) {
59
80
  }
60
81
  /** Names the month shown, unless it is given something else to say. */
61
82
  function Heading(props) {
62
- const made = useCalendar();
63
- const title = fromSignal(made.title);
64
- return (<Part of={made.heading} tag="div" {...props}>
83
+ const month = useMonth();
84
+ const title = fromSignal(month.title);
85
+ return (<Part of={month.heading} tag="div" {...props}>
65
86
  {props.children ?? title()}
66
87
  </Part>);
67
88
  }
68
89
  const Previous = (props) => (<Part of={useCalendar().previous} tag="button" {...props}/>);
69
90
  const Next = (props) => <Part of={useCalendar().next} tag="button" {...props}/>;
70
- const Grid = (props) => <Part of={useCalendar().grid} tag="table" {...props}/>;
91
+ const Grid = (props) => <Part of={useMonth().grid} tag="table" {...props}/>;
92
+ /**
93
+ * Draws its child once for each month shown (`months` on the root), side by side: the parts
94
+ * inside each are that month's. Left out for one month.
95
+ */
96
+ function Months(props) {
97
+ const months = fromSignal(useCalendar().months);
98
+ // Kept by place: the month given reads the one now there, as props do.
99
+ return (<Index each={months()}>
100
+ {(month, index) => (<MonthContext.Provider value={index}>
101
+ {props.children({
102
+ index,
103
+ get month() {
104
+ return month().month;
105
+ },
106
+ get title() {
107
+ return month().title;
108
+ },
109
+ get weekdays() {
110
+ return month().weekdays;
111
+ },
112
+ get weeks() {
113
+ return month().weeks;
114
+ },
115
+ })}
116
+ </MonthContext.Provider>)}
117
+ </Index>);
118
+ }
71
119
  /** Draws its child once for each day of the week, in the locale's order. */
72
120
  function Weekdays(props) {
73
121
  const weekdays = fromSignal(useCalendar().weekdays);
@@ -75,7 +123,7 @@ function Weekdays(props) {
75
123
  }
76
124
  /** Draws its child once for each week of the month shown. */
77
125
  function Weeks(props) {
78
- const weeks = fromSignal(useCalendar().weeks);
126
+ const weeks = fromSignal(useMonth().weeks);
79
127
  return <For each={weeks()}>{(week) => props.children(week)}</For>;
80
128
  }
81
129
  function HeadCell(props) {
@@ -86,23 +134,27 @@ function HeadCell(props) {
86
134
  function Cell(props) {
87
135
  const [local, rest] = splitProps(props, ["date"]);
88
136
  // A cell is its day for as long as it is in the page.
89
- const part = useCalendar().cell(local.date);
137
+ const part = useCalendar().cell(local.date, useContext(MonthContext));
90
138
  return <Part of={part} tag="td" {...rest}/>;
91
139
  }
92
140
  function Day(props) {
93
141
  const [local, rest] = splitProps(props, ["date"]);
94
- const part = useCalendar().day(local.date);
142
+ const part = useCalendar().day(local.date, useContext(MonthContext));
95
143
  return <Part of={part} tag="button" {...rest}/>;
96
144
  }
145
+ /** The hidden input the value is submitted by, when the root has a `name`. */
146
+ const Input = (props) => <Part of={useCalendar().input} tag="input" {...props}/>;
97
147
  export const Calendar = {
98
148
  Root,
99
149
  Heading,
100
150
  Previous,
101
151
  Next,
152
+ Months,
102
153
  Grid,
103
154
  Weekdays,
104
155
  HeadCell,
105
156
  Weeks,
106
157
  Cell,
107
158
  Day,
159
+ Input,
108
160
  };
@@ -0,0 +1,3 @@
1
+ import { createContext } from "solid-js";
2
+ /** The group a checkbox is one of the boxes of, if it is in one. */
3
+ export const CheckboxGroupContext = createContext(null);
@@ -0,0 +1,33 @@
1
+ import { within } from "@kirana-ui/core";
2
+ import { createCheckboxGroup } from "@kirana-ui/core/checkbox-group";
3
+ import { createUniqueId, splitProps, useContext } from "solid-js";
4
+ import { CheckboxGroupContext } from "./checkbox-group-context.js";
5
+ import { FieldContext } from "./field-context.js";
6
+ import { Part, controller } from "./runtime.jsx";
7
+ /**
8
+ * Checkboxes that hold one list of values. Each `<Checkbox.Root value>` inside it is checked
9
+ * while the list has its value; with `allValues`, a `<Checkbox.Root parent>` stands for them all.
10
+ */
11
+ export function CheckboxGroup(props) {
12
+ const [local, rest] = splitProps(props, [
13
+ "value",
14
+ "defaultValue",
15
+ "onValueChange",
16
+ "allValues",
17
+ "disabled",
18
+ "id",
19
+ ]);
20
+ const generated = createUniqueId();
21
+ const field = useContext(FieldContext);
22
+ const made = controller(within(createCheckboxGroup, { field }), () => ({
23
+ id: local.id ?? generated,
24
+ value: local.value,
25
+ defaultValue: local.defaultValue,
26
+ allValues: local.allValues,
27
+ disabled: local.disabled,
28
+ onValueChange: (value, details) => local.onValueChange?.(value, details),
29
+ }));
30
+ return (<CheckboxGroupContext.Provider value={made}>
31
+ <Part of={made.root} tag="div" {...rest}/>
32
+ </CheckboxGroupContext.Provider>);
33
+ }
package/src/checkbox.jsx CHANGED
@@ -1,6 +1,7 @@
1
1
  import { within } from "@kirana-ui/core";
2
2
  import { createCheckbox } from "@kirana-ui/core/checkbox";
3
3
  import { Show, createContext, createUniqueId, splitProps, useContext } from "solid-js";
4
+ import { CheckboxGroupContext } from "./checkbox-group-context.js";
4
5
  import { FieldContext } from "./field-context.js";
5
6
  import { Part, controller, fromSignal } from "./runtime.jsx";
6
7
  const Context = createContext();
@@ -16,6 +17,7 @@ function Root(props) {
16
17
  "defaultChecked",
17
18
  "onCheckedChange",
18
19
  "indeterminate",
20
+ "parent",
19
21
  "disabled",
20
22
  "readOnly",
21
23
  "required",
@@ -27,11 +29,13 @@ function Root(props) {
27
29
  ]);
28
30
  const generated = createUniqueId();
29
31
  const field = useContext(FieldContext);
30
- const made = controller(within(createCheckbox, { field }), () => ({
32
+ const group = useContext(CheckboxGroupContext) ?? undefined;
33
+ const made = controller(within(createCheckbox, { field, group }), () => ({
31
34
  id: local.id ?? generated,
32
35
  checked: local.checked,
33
36
  defaultChecked: local.defaultChecked,
34
37
  indeterminate: local.indeterminate,
38
+ parent: local.parent,
35
39
  disabled: local.disabled,
36
40
  readOnly: local.readOnly,
37
41
  required: local.required,
package/src/combobox.jsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import { within } from "@kirana-ui/core";
2
2
  import { createAutocomplete } from "@kirana-ui/core/autocomplete";
3
3
  import { createCombobox } from "@kirana-ui/core/combobox";
4
- import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
4
+ import { For, Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
5
5
  import { FieldContext } from "./field-context.js";
6
6
  import { positioned } from "./popover.jsx";
7
7
  import { Part, Portal as BodyPortal, controller, fromSignal, toSignal } from "./runtime.jsx";
@@ -25,6 +25,7 @@ function Root(props) {
25
25
  open: props.open,
26
26
  defaultOpen: props.defaultOpen,
27
27
  disabled: props.disabled,
28
+ readOnly: props.readOnly,
28
29
  required: props.required,
29
30
  multiple: props.multiple,
30
31
  values: props.values,
@@ -120,6 +121,42 @@ function Group(props) {
120
121
  }
121
122
  /** Names the group it is in. With no group around it, it is plain text. */
122
123
  const GroupLabel = (props) => (<Part of={useContext(GroupContext)?.label ?? useCombobox().groupLabel} tag="div" {...props}/>);
124
+ /**
125
+ * The chosen value's label, or `placeholder` while nothing is chosen; with `multiple`, the
126
+ * chosen labels with commas between. For a button that is the combobox, its input inside the
127
+ * popup. It draws no element.
128
+ */
129
+ function Value(props) {
130
+ const made = useCombobox();
131
+ const shown = fromSignal(made.shown);
132
+ return (<>
133
+ {(() => {
134
+ const given = props.children;
135
+ // A function that takes nothing is an element of Solid's own, drawn as it is.
136
+ if (typeof given !== "function" || given.length === 0) {
137
+ return given ?? shown().label ?? props.placeholder;
138
+ }
139
+ const draw = given;
140
+ return made.multiple
141
+ ? draw(() => shown().values, () => shown().labels)
142
+ : draw(() => shown().value, () => shown().label);
143
+ })()}
144
+ </>);
145
+ }
146
+ /**
147
+ * Draws the list from the root's `items`: its child once for each item left for what was
148
+ * typed, or for each group that has items left; with `of`, for each of that group's. The root
149
+ * then filters, and no item hides itself. It draws no element.
150
+ */
151
+ function Collection(props) {
152
+ const made = useCombobox();
153
+ // A group is known by its key, which is its own for as long as it is drawn.
154
+ const entries = fromSignal(made.entries(untrack(() => props.of)));
155
+ // By key: an item that is left keeps its element.
156
+ const keys = () => entries().map((each) => each.key);
157
+ const of = (key) => entries().find((each) => each.key === key);
158
+ return <For each={keys()}>{(key) => props.children(untrack(() => of(key)))}</For>;
159
+ }
123
160
  const part = (name, tag) => (props) => <Part of={useCombobox()[name]} tag={tag} {...props}/>;
124
161
  /** A combobox whose text is the value: the list only suggests. */
125
162
  function AutocompleteRoot(props) {
@@ -135,6 +172,8 @@ function AutocompleteRoot(props) {
135
172
  filter: props.filter,
136
173
  openOnInputClick: props.openOnInputClick,
137
174
  disabled: props.disabled,
175
+ readOnly: props.readOnly,
176
+ items: props.items,
138
177
  required: props.required,
139
178
  name: props.name,
140
179
  form: props.form,
@@ -149,6 +188,7 @@ export const Combobox = {
149
188
  Root,
150
189
  Input: part("input", "input"),
151
190
  Trigger: part("trigger", "button"),
191
+ Value,
152
192
  Clear,
153
193
  /** With `multiple`: what holds the chips and the input. */
154
194
  Chips: part("chips", "div"),
@@ -162,6 +202,7 @@ export const Combobox = {
162
202
  * is then the listbox.
163
203
  */
164
204
  List: part("list", "div"),
205
+ Collection,
165
206
  Group,
166
207
  GroupLabel,
167
208
  /** A line between groups. */
@@ -169,6 +210,12 @@ export const Combobox = {
169
210
  Item,
170
211
  ItemIndicator,
171
212
  Empty,
213
+ /**
214
+ * Says how the list stands ("3 results", "Loading") to software that reads the page, as its
215
+ * text changes. Keep it in the page and change what it holds: inside the popup, or beside
216
+ * the input.
217
+ */
218
+ Status: part("status", "div"),
172
219
  };
173
220
  export const Autocomplete = {
174
221
  Root: AutocompleteRoot,
@@ -179,9 +226,11 @@ export const Autocomplete = {
179
226
  Positioner: Combobox.Positioner,
180
227
  Popup: Combobox.Popup,
181
228
  List: Combobox.List,
229
+ Collection: Combobox.Collection,
182
230
  Group: Combobox.Group,
183
231
  GroupLabel: Combobox.GroupLabel,
184
232
  Separator: Combobox.Separator,
185
233
  Item: Combobox.Item,
186
234
  Empty: Combobox.Empty,
235
+ Status: Combobox.Status,
187
236
  };
package/src/command.jsx CHANGED
@@ -17,6 +17,7 @@ function Root(props) {
17
17
  "onSelect",
18
18
  "filter",
19
19
  "loop",
20
+ "autoHighlight",
20
21
  "disabled",
21
22
  "id",
22
23
  ]);
@@ -27,6 +28,7 @@ function Root(props) {
27
28
  defaultInputValue: local.defaultInputValue,
28
29
  filter: local.filter,
29
30
  loop: local.loop,
31
+ autoHighlight: local.autoHighlight,
30
32
  disabled: local.disabled,
31
33
  onInputValueChange: (value, details) => local.onInputValueChange?.(value, details),
32
34
  onSelect: (value, details) => local.onSelect?.(value, details),
@@ -28,6 +28,10 @@ function Root(props) {
28
28
  isDateUnavailable: props.isDateUnavailable,
29
29
  calendarSystem: props.calendarSystem,
30
30
  fixedWeeks: props.fixedWeeks,
31
+ months: props.months,
32
+ pagedNavigation: props.pagedNavigation,
33
+ month: props.month,
34
+ defaultMonth: props.defaultMonth,
31
35
  placeholders: props.placeholders,
32
36
  disabled: props.disabled,
33
37
  readOnly: props.readOnly,
@@ -36,6 +40,7 @@ function Root(props) {
36
40
  form: props.form,
37
41
  onValueChange: (value, details) => props.onValueChange?.(value, details),
38
42
  onOpenChange: (open, details) => props.onOpenChange?.(open, details),
43
+ onMonthChange: (month, details) => props.onMonthChange?.(month, details),
39
44
  }));
40
45
  return (<Context.Provider value={made}>
41
46
  <DateFieldContext.Provider value={made.field}>
@@ -63,6 +68,7 @@ export const DatePicker = {
63
68
  Heading: Calendar.Heading,
64
69
  Previous: Calendar.Previous,
65
70
  Next: Calendar.Next,
71
+ Months: Calendar.Months,
66
72
  Grid: Calendar.Grid,
67
73
  Weekdays: Calendar.Weekdays,
68
74
  HeadCell: Calendar.HeadCell,
package/src/dialog.jsx CHANGED
@@ -39,6 +39,8 @@ export const Dialog = {
39
39
  Portal,
40
40
  Trigger: part("trigger", "button"),
41
41
  Backdrop: part("backdrop", "div"),
42
+ /** What a long dialog scrolls in, around its popup: it may be left out. */
43
+ Viewport: part("viewport", "div"),
42
44
  Popup: part("popup", "div"),
43
45
  Title: part("title", "h2"),
44
46
  Description: part("description", "p"),
@@ -63,9 +65,11 @@ function DrawerRoot(props) {
63
65
  }));
64
66
  return <Context.Provider value={made}>{props.children}</Context.Provider>;
65
67
  }
68
+ // A drawer has no viewport: it lies at an edge of the page, and what scrolls is inside it.
69
+ const { Viewport: _, ...shared } = Dialog;
66
70
  /** A dialog that comes from an edge and is dragged back to it. Its parts are a dialog's. */
67
71
  export const Drawer = {
68
- ...Dialog,
72
+ ...shared,
69
73
  Root: DrawerRoot,
70
74
  // The same components: only what `render` reads of their state is a drawer's.
71
75
  Backdrop: Dialog.Backdrop,
package/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { Accordion } from "./accordion.jsx";
2
2
  export { Checkbox } from "./checkbox.jsx";
3
+ export { CheckboxGroup } from "./checkbox-group.jsx";
3
4
  export { Collapsible } from "./collapsible.jsx";
4
5
  export { AlertDialog, Dialog, Drawer } from "./dialog.jsx";
5
6
  export { MessageScroller } from "./message-scroller.jsx";