@kirana-ui/solid 0.1.1 → 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 (208) hide show
  1. package/dom/accordion.js +9 -6
  2. package/dom/agent.js +3 -0
  3. package/dom/autosize.js +1 -1
  4. package/dom/avatar.js +39 -14
  5. package/dom/button.js +1 -1
  6. package/dom/calendar.js +78 -19
  7. package/dom/carousel.js +6 -6
  8. package/dom/checkbox-group-context.js +3 -0
  9. package/dom/checkbox-group.js +38 -0
  10. package/dom/checkbox.js +9 -5
  11. package/dom/collapsible.js +3 -3
  12. package/dom/combobox.js +72 -14
  13. package/dom/command.js +10 -9
  14. package/dom/date-field.js +7 -3
  15. package/dom/date-picker.js +9 -3
  16. package/dom/dialog.js +13 -3
  17. package/dom/field.js +3 -3
  18. package/dom/fieldset.js +2 -2
  19. package/dom/form.js +1 -1
  20. package/dom/hover-popup.js +3 -3
  21. package/dom/index.js +1 -0
  22. package/dom/input.js +1 -1
  23. package/dom/label.js +1 -1
  24. package/dom/listbox.js +5 -5
  25. package/dom/menu.js +11 -11
  26. package/dom/menubar.js +1 -1
  27. package/dom/message-scroller.js +4 -4
  28. package/dom/navigation-menu.js +18 -21
  29. package/dom/number-field.js +39 -6
  30. package/dom/otp.js +6 -5
  31. package/dom/pagination.js +3 -3
  32. package/dom/popover.js +37 -8
  33. package/dom/primitive.js +92 -0
  34. package/dom/qr-code.js +3 -3
  35. package/dom/radio-group.js +7 -6
  36. package/dom/resizable.js +3 -3
  37. package/dom/runtime.js +23 -7
  38. package/dom/scroll-area.js +5 -5
  39. package/dom/select.js +26 -13
  40. package/dom/separator.js +1 -1
  41. package/dom/slider.js +11 -8
  42. package/dom/switch.js +3 -3
  43. package/dom/tabs.js +5 -5
  44. package/dom/testing.js +3 -0
  45. package/dom/toast.js +57 -20
  46. package/dom/toggle-group.js +1 -1
  47. package/dom/toggle.js +1 -1
  48. package/dom/toolbar.js +4 -4
  49. package/dom/value-bar.js +3 -3
  50. package/llms.txt +1846 -252
  51. package/package.json +34 -2
  52. package/server/accordion.js +9 -6
  53. package/server/agent.js +3 -0
  54. package/server/autosize.js +1 -1
  55. package/server/avatar.js +39 -14
  56. package/server/button.js +1 -1
  57. package/server/calendar.js +78 -19
  58. package/server/carousel.js +6 -6
  59. package/server/checkbox-group-context.js +3 -0
  60. package/server/checkbox-group.js +38 -0
  61. package/server/checkbox.js +9 -5
  62. package/server/collapsible.js +3 -3
  63. package/server/combobox.js +72 -14
  64. package/server/command.js +10 -9
  65. package/server/date-field.js +7 -3
  66. package/server/date-picker.js +9 -3
  67. package/server/dialog.js +13 -3
  68. package/server/field.js +3 -3
  69. package/server/fieldset.js +2 -2
  70. package/server/form.js +1 -1
  71. package/server/hover-popup.js +3 -3
  72. package/server/index.js +1 -0
  73. package/server/input.js +1 -1
  74. package/server/label.js +1 -1
  75. package/server/listbox.js +5 -5
  76. package/server/menu.js +11 -11
  77. package/server/menubar.js +1 -1
  78. package/server/message-scroller.js +4 -4
  79. package/server/navigation-menu.js +18 -15
  80. package/server/number-field.js +39 -6
  81. package/server/otp.js +6 -5
  82. package/server/pagination.js +3 -3
  83. package/server/popover.js +37 -8
  84. package/server/primitive.js +92 -0
  85. package/server/qr-code.js +3 -3
  86. package/server/radio-group.js +7 -6
  87. package/server/resizable.js +3 -3
  88. package/server/runtime.js +23 -7
  89. package/server/scroll-area.js +5 -5
  90. package/server/select.js +26 -13
  91. package/server/separator.js +1 -1
  92. package/server/slider.js +11 -8
  93. package/server/switch.js +3 -3
  94. package/server/tabs.js +5 -5
  95. package/server/testing.js +3 -0
  96. package/server/toast.js +57 -20
  97. package/server/toggle-group.js +1 -1
  98. package/server/toggle.js +1 -1
  99. package/server/toolbar.js +4 -4
  100. package/server/value-bar.js +3 -3
  101. package/skills/kirana-ui-primitives/SKILL.md +163 -0
  102. package/src/accordion.jsx +10 -7
  103. package/src/agent.js +3 -0
  104. package/src/autosize.jsx +1 -1
  105. package/src/avatar.jsx +17 -10
  106. package/src/button.jsx +1 -1
  107. package/src/calendar.jsx +72 -16
  108. package/src/carousel.jsx +6 -6
  109. package/src/checkbox-group-context.js +3 -0
  110. package/src/checkbox-group.jsx +33 -0
  111. package/src/checkbox.jsx +8 -4
  112. package/src/collapsible.jsx +3 -3
  113. package/src/combobox.jsx +70 -13
  114. package/src/command.jsx +10 -8
  115. package/src/date-field.jsx +7 -3
  116. package/src/date-picker.jsx +8 -2
  117. package/src/dialog.jsx +12 -2
  118. package/src/field.jsx +3 -3
  119. package/src/fieldset.jsx +2 -2
  120. package/src/form.jsx +1 -1
  121. package/src/hover-popup.jsx +3 -3
  122. package/src/index.js +1 -0
  123. package/src/input.jsx +1 -1
  124. package/src/label.jsx +1 -1
  125. package/src/listbox.jsx +6 -6
  126. package/src/menu.jsx +11 -11
  127. package/src/menubar.jsx +1 -1
  128. package/src/message-scroller.jsx +4 -4
  129. package/src/navigation-menu.jsx +14 -13
  130. package/src/number-field.jsx +26 -6
  131. package/src/otp.jsx +6 -4
  132. package/src/pagination.jsx +3 -3
  133. package/src/popover.jsx +35 -5
  134. package/src/primitive.jsx +81 -0
  135. package/src/qr-code.jsx +3 -3
  136. package/src/radio-group.jsx +7 -7
  137. package/src/resizable.jsx +3 -3
  138. package/src/runtime.jsx +21 -7
  139. package/src/scroll-area.jsx +5 -5
  140. package/src/select.jsx +29 -14
  141. package/src/separator.jsx +1 -1
  142. package/src/slider.jsx +12 -8
  143. package/src/switch.jsx +3 -3
  144. package/src/tabs.jsx +6 -6
  145. package/src/testing.js +3 -0
  146. package/src/toast.jsx +38 -10
  147. package/src/toggle-group.jsx +2 -2
  148. package/src/toggle.jsx +1 -1
  149. package/src/toolbar.jsx +4 -4
  150. package/src/value-bar.jsx +3 -3
  151. package/types/accordion.d.ts +21 -19
  152. package/types/agent.d.ts +1 -0
  153. package/types/alert-dialog.d.ts +1 -0
  154. package/types/autocomplete.d.ts +1 -0
  155. package/types/autosize.d.ts +4 -1
  156. package/types/avatar.d.ts +14 -6
  157. package/types/button.d.ts +4 -2
  158. package/types/calendar.d.ts +48 -19
  159. package/types/carousel.d.ts +18 -10
  160. package/types/checkbox-group-context.d.ts +3 -0
  161. package/types/checkbox-group.d.ts +13 -0
  162. package/types/checkbox.d.ts +10 -6
  163. package/types/collapsible.d.ts +11 -7
  164. package/types/combobox.d.ts +102 -64
  165. package/types/command.d.ts +29 -17
  166. package/types/context-menu.d.ts +1 -0
  167. package/types/date-field.d.ts +20 -9
  168. package/types/date-picker.d.ts +26 -34
  169. package/types/dialog.d.ts +47 -31
  170. package/types/direction.d.ts +1 -0
  171. package/types/drawer.d.ts +1 -0
  172. package/types/field.d.ts +19 -11
  173. package/types/fieldset.d.ts +8 -3
  174. package/types/form.d.ts +5 -2
  175. package/types/hover-card.d.ts +16 -10
  176. package/types/hover-popup.d.ts +23 -13
  177. package/types/index.d.ts +15 -1
  178. package/types/input.d.ts +4 -3
  179. package/types/label.d.ts +4 -1
  180. package/types/listbox.d.ts +18 -20
  181. package/types/menu.d.ts +56 -42
  182. package/types/menubar.d.ts +6 -4
  183. package/types/message-scroller.d.ts +12 -6
  184. package/types/meter.d.ts +16 -7
  185. package/types/navigation-menu.d.ts +35 -29
  186. package/types/number-field.d.ts +22 -7
  187. package/types/otp.d.ts +18 -10
  188. package/types/pagination.d.ts +18 -10
  189. package/types/popover.d.ts +52 -13
  190. package/types/primitive.d.ts +50 -0
  191. package/types/progress.d.ts +16 -7
  192. package/types/qr-code.d.ts +10 -4
  193. package/types/radio-group.d.ts +18 -17
  194. package/types/resizable.d.ts +12 -7
  195. package/types/runtime.d.ts +36 -12
  196. package/types/scroll-area.d.ts +17 -9
  197. package/types/select.d.ts +55 -46
  198. package/types/separator.d.ts +5 -3
  199. package/types/slider.d.ts +25 -13
  200. package/types/switch.d.ts +7 -4
  201. package/types/tabs.d.ts +20 -16
  202. package/types/testing.d.ts +1 -0
  203. package/types/toast.d.ts +40 -16
  204. package/types/toggle-group.d.ts +6 -11
  205. package/types/toggle.d.ts +4 -3
  206. package/types/toolbar.d.ts +19 -14
  207. package/types/tooltip.d.ts +16 -10
  208. package/types/value-bar.d.ts +21 -10
package/src/accordion.jsx CHANGED
@@ -30,7 +30,7 @@ function Root(props) {
30
30
  ]);
31
31
  const generated = createUniqueId();
32
32
  const direction = useContext(DirectionContext);
33
- const made = controller(within(createAccordion, { direction }), () => ({
33
+ const made = controller(within((createAccordion), { direction }), () => ({
34
34
  id: local.id ?? generated,
35
35
  value: local.value,
36
36
  defaultValue: local.defaultValue,
@@ -41,28 +41,31 @@ function Root(props) {
41
41
  onValueChange: (value, details) => local.onValueChange?.(value, details),
42
42
  }));
43
43
  return (<Context.Provider value={made}>
44
- <Part part={made.root} tag="div" {...rest}/>
44
+ <Part of={made.root} tag="div" {...rest}/>
45
45
  </Context.Provider>);
46
46
  }
47
+ /** `value` tells this item from the others; an item that is given none makes its own. */
47
48
  function Item(props) {
48
49
  const [local, rest] = splitProps(props, ["value", "disabled"]);
49
50
  const options = toSignal(() => ({ disabled: local.disabled }));
51
+ const generated = createUniqueId();
50
52
  // An item is its value for as long as it is in the page.
51
- const item = useAccordion().item(untrack(() => local.value), () => defined(options.get()));
53
+ const value = untrack(() => local.value);
54
+ const item = useAccordion().item(value === undefined ? generated : value, () => defined(options.get()));
52
55
  onMount(() => onCleanup(item.mount()));
53
56
  return (<ItemContext.Provider value={item}>
54
- <Part part={item.root} tag="div" {...rest}/>
57
+ <Part of={item.root} tag="div" {...rest}/>
55
58
  </ItemContext.Provider>);
56
59
  }
57
- const Header = (props) => <Part part={useItem().header} tag="h3" {...props}/>;
58
- const Trigger = (props) => (<Part part={useItem().trigger} tag="button" {...props}/>);
60
+ const Header = (props) => <Part of={useItem().header} tag="h3" {...props}/>;
61
+ const Trigger = (props) => <Part of={useItem().trigger} tag="button" {...props}/>;
59
62
  /** `keepMounted` keeps the closed panel in the page, `hidden`. */
60
63
  function Panel(props) {
61
64
  const [local, rest] = splitProps(props, ["keepMounted"]);
62
65
  const item = useItem();
63
66
  const mounted = fromSignal(item.mounted);
64
67
  return (<Show when={mounted() || local.keepMounted}>
65
- <Part part={item.panel} tag="div" {...rest}/>
68
+ <Part of={item.panel} tag="div" {...rest}/>
66
69
  </Show>);
67
70
  }
68
71
  export const Accordion = { Root, Item, Header, Trigger, Panel };
package/src/agent.js ADDED
@@ -0,0 +1,3 @@
1
+ // The agent bridge is the core's, and the same on every framework: it is an entry here too,
2
+ // so an application imports it from the one package it installed.
3
+ export * from "@kirana-ui/core/agent";
package/src/autosize.jsx CHANGED
@@ -3,6 +3,6 @@ import { Part, controller } from "./runtime.jsx";
3
3
  /** A `<textarea>` as tall as its text. It takes what a `<textarea>` takes. */
4
4
  function Textarea(props) {
5
5
  const made = controller(createAutosize, () => ({ value: props.value }));
6
- return <Part part={made.textarea} tag="textarea" {...props}/>;
6
+ return <Part of={made.textarea} tag="textarea" {...props}/>;
7
7
  }
8
8
  export const Autosize = { Textarea };
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() {
@@ -11,25 +11,32 @@ function useAvatar() {
11
11
  function Root(props) {
12
12
  const made = controller(createAvatar, () => ({}));
13
13
  return (<Context.Provider value={made}>
14
- <Part part={made.root} tag="span" {...props}/>
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 part={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 part={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/button.jsx CHANGED
@@ -5,5 +5,5 @@ import { Part, controller } from "./runtime.jsx";
5
5
  export function Button(props) {
6
6
  const [local, rest] = splitProps(props, ["disabled", "focusableWhenDisabled", "nativeButton"]);
7
7
  const made = controller(createButton, () => ({ ...local }));
8
- return <Part part={made.root} tag="button" {...rest}/>;
8
+ return <Part of={made.root} tag="button" {...rest}/>;
9
9
  }
package/src/calendar.jsx CHANGED
@@ -1,8 +1,12 @@
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
+ /**
7
+ * The calendar its parts are inside. Exported for a component that is made of one (a date picker
8
+ * provides its own to the calendar's parts).
9
+ */
6
10
  const Context = createContext();
7
11
  /** For a component made of this one's parts: a date picker. */
8
12
  export { Context as CalendarContext };
@@ -12,14 +16,24 @@ function useCalendar() {
12
16
  throw new Error("A Calendar part must be inside <Calendar.Root>");
13
17
  return made;
14
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);
15
23
  function Root(props) {
16
24
  const [local, rest] = splitProps(props, [
17
25
  "value",
18
26
  "defaultValue",
19
27
  "onValueChange",
20
28
  "mode",
21
- "defaultFocusedValue",
29
+ "minDays",
30
+ "maxDays",
31
+ "months",
32
+ "pagedNavigation",
33
+ "month",
34
+ "defaultMonth",
22
35
  "onMonthChange",
36
+ "defaultFocusedValue",
23
37
  "locale",
24
38
  "calendarSystem",
25
39
  "min",
@@ -28,15 +42,24 @@ function Root(props) {
28
42
  "disabled",
29
43
  "readOnly",
30
44
  "fixedWeeks",
45
+ "name",
46
+ "form",
31
47
  "id",
32
48
  ]);
33
49
  const generated = createUniqueId();
34
50
  const direction = useContext(DirectionContext);
35
51
  const made = controller(within(createCalendar, { direction }), () => ({
36
52
  id: local.id ?? generated,
53
+ // The core holds any mode's value; the caller's is its mode's.
37
54
  value: local.value,
38
55
  defaultValue: local.defaultValue,
39
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,
40
63
  defaultFocusedValue: local.defaultFocusedValue,
41
64
  locale: local.locale,
42
65
  calendarSystem: local.calendarSystem,
@@ -46,24 +69,53 @@ function Root(props) {
46
69
  disabled: local.disabled,
47
70
  readOnly: local.readOnly,
48
71
  fixedWeeks: local.fixedWeeks,
72
+ name: local.name,
73
+ form: local.form,
49
74
  onValueChange: (value, details) => local.onValueChange?.(value, details),
50
- onMonthChange: (month) => local.onMonthChange?.(month),
75
+ onMonthChange: (month, details) => local.onMonthChange?.(month, details),
51
76
  }));
52
77
  return (<Context.Provider value={made}>
53
- <Part part={made.root} tag="div" {...rest}/>
78
+ <Part of={made.root} tag="div" {...rest}/>
54
79
  </Context.Provider>);
55
80
  }
56
81
  /** Names the month shown, unless it is given something else to say. */
57
82
  function Heading(props) {
58
- const made = useCalendar();
59
- const title = fromSignal(made.title);
60
- return (<Part part={made.heading} tag="div" {...props}>
83
+ const month = useMonth();
84
+ const title = fromSignal(month.title);
85
+ return (<Part of={month.heading} tag="div" {...props}>
61
86
  {props.children ?? title()}
62
87
  </Part>);
63
88
  }
64
- const Previous = (props) => (<Part part={useCalendar().previous} tag="button" {...props}/>);
65
- const Next = (props) => (<Part part={useCalendar().next} tag="button" {...props}/>);
66
- const Grid = (props) => (<Part part={useCalendar().grid} tag="table" {...props}/>);
89
+ const Previous = (props) => (<Part of={useCalendar().previous} tag="button" {...props}/>);
90
+ const Next = (props) => <Part of={useCalendar().next} tag="button" {...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
+ }
67
119
  /** Draws its child once for each day of the week, in the locale's order. */
68
120
  function Weekdays(props) {
69
121
  const weekdays = fromSignal(useCalendar().weekdays);
@@ -71,34 +123,38 @@ function Weekdays(props) {
71
123
  }
72
124
  /** Draws its child once for each week of the month shown. */
73
125
  function Weeks(props) {
74
- const weeks = fromSignal(useCalendar().weeks);
126
+ const weeks = fromSignal(useMonth().weeks);
75
127
  return <For each={weeks()}>{(week) => props.children(week)}</For>;
76
128
  }
77
129
  function HeadCell(props) {
78
130
  const [local, rest] = splitProps(props, ["weekday"]);
79
131
  const part = useCalendar().headCell(local.weekday);
80
- return <Part part={part} tag="th" {...rest}/>;
132
+ return <Part of={part} tag="th" {...rest}/>;
81
133
  }
82
134
  function Cell(props) {
83
135
  const [local, rest] = splitProps(props, ["date"]);
84
136
  // A cell is its day for as long as it is in the page.
85
- const part = useCalendar().cell(local.date);
86
- return <Part part={part} tag="td" {...rest}/>;
137
+ const part = useCalendar().cell(local.date, useContext(MonthContext));
138
+ return <Part of={part} tag="td" {...rest}/>;
87
139
  }
88
140
  function Day(props) {
89
141
  const [local, rest] = splitProps(props, ["date"]);
90
- const part = useCalendar().day(local.date);
91
- return <Part part={part} tag="button" {...rest}/>;
142
+ const part = useCalendar().day(local.date, useContext(MonthContext));
143
+ return <Part of={part} tag="button" {...rest}/>;
92
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}/>;
93
147
  export const Calendar = {
94
148
  Root,
95
149
  Heading,
96
150
  Previous,
97
151
  Next,
152
+ Months,
98
153
  Grid,
99
154
  Weekdays,
100
155
  HeadCell,
101
156
  Weeks,
102
157
  Cell,
103
158
  Day,
159
+ Input,
104
160
  };
package/src/carousel.jsx CHANGED
@@ -30,22 +30,22 @@ function Root(props) {
30
30
  onIndexChange: (index, details) => local.onIndexChange?.(index, details),
31
31
  }));
32
32
  return (<Context.Provider value={made}>
33
- <Part part={made.root} tag="div" {...rest}/>
33
+ <Part of={made.root} tag="div" {...rest}/>
34
34
  </Context.Provider>);
35
35
  }
36
- const Viewport = (props) => (<Part part={useCarousel().viewport} tag="div" {...props}/>);
36
+ const Viewport = (props) => <Part of={useCarousel().viewport} tag="div" {...props}/>;
37
37
  function Item(props) {
38
38
  const [local, rest] = splitProps(props, ["index"]);
39
39
  // A slide is its place for as long as it is in the page.
40
40
  const part = useCarousel().item(local.index);
41
- return <Part part={part} tag="div" {...rest}/>;
41
+ return <Part of={part} tag="div" {...rest}/>;
42
42
  }
43
- const Previous = (props) => (<Part part={useCarousel().previous} tag="button" {...props}/>);
44
- const Next = (props) => (<Part part={useCarousel().next} tag="button" {...props}/>);
43
+ const Previous = (props) => (<Part of={useCarousel().previous} tag="button" {...props}/>);
44
+ const Next = (props) => <Part of={useCarousel().next} tag="button" {...props}/>;
45
45
  function Indicator(props) {
46
46
  const [local, rest] = splitProps(props, ["index"]);
47
47
  // A button is its slide for as long as it is in the page.
48
48
  const part = useCarousel().indicator(local.index);
49
- return <Part part={part} tag="button" {...rest}/>;
49
+ return <Part of={part} tag="button" {...rest}/>;
50
50
  }
51
51
  export const Carousel = { Root, Viewport, Item, Previous, Next, Indicator };
@@ -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,
@@ -41,9 +45,9 @@ function Root(props) {
41
45
  onCheckedChange: (checked, details) => local.onCheckedChange?.(checked, details),
42
46
  }));
43
47
  return (<Context.Provider value={made}>
44
- <Part part={made.root} tag="span" {...rest}>
48
+ <Part of={made.root} tag="span" {...rest}>
45
49
  {local.children}
46
- <Part part={made.input} tag="input"/>
50
+ <Part of={made.input} tag="input"/>
47
51
  </Part>
48
52
  </Context.Provider>);
49
53
  }
@@ -53,7 +57,7 @@ function Indicator(props) {
53
57
  const made = useCheckbox();
54
58
  const mounted = fromSignal(made.indicatorMounted);
55
59
  return (<Show when={mounted() || local.keepMounted}>
56
- <Part part={made.indicator} tag="span" {...rest}/>
60
+ <Part of={made.indicator} tag="span" {...rest}/>
57
61
  </Show>);
58
62
  }
59
63
  export const Checkbox = { Root, Indicator };
@@ -19,17 +19,17 @@ function Root(props) {
19
19
  onOpenChange: (open, details) => local.onOpenChange?.(open, details),
20
20
  }));
21
21
  return (<Context.Provider value={made}>
22
- <Part part={made.root} tag="div" {...rest}/>
22
+ <Part of={made.root} tag="div" {...rest}/>
23
23
  </Context.Provider>);
24
24
  }
25
- const Trigger = (props) => (<Part part={useCollapsible().trigger} tag="button" {...props}/>);
25
+ const Trigger = (props) => (<Part of={useCollapsible().trigger} tag="button" {...props}/>);
26
26
  /** `keepMounted` keeps the closed panel in the page, `hidden`. */
27
27
  function Panel(props) {
28
28
  const [local, rest] = splitProps(props, ["keepMounted"]);
29
29
  const made = useCollapsible();
30
30
  const mounted = fromSignal(made.mounted);
31
31
  return (<Show when={mounted() || local.keepMounted}>
32
- <Part part={made.panel} tag="div" {...rest}/>
32
+ <Part of={made.panel} tag="div" {...rest}/>
33
33
  </Show>);
34
34
  }
35
35
  export const Collapsible = { Root, Trigger, Panel };
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";
@@ -16,7 +16,7 @@ function useCombobox() {
16
16
  function Root(props) {
17
17
  const generated = createUniqueId();
18
18
  const field = useContext(FieldContext);
19
- const made = controller(within(createCombobox, { field }), () => ({
19
+ const made = controller(within((createCombobox), { field }), () => ({
20
20
  id: props.id ?? generated,
21
21
  value: props.value,
22
22
  defaultValue: props.defaultValue,
@@ -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,
@@ -32,6 +33,7 @@ function Root(props) {
32
33
  onValuesChange: (values, details) => props.onValuesChange?.(values, details),
33
34
  inline: props.inline,
34
35
  virtualized: props.virtualized,
36
+ autoHighlight: props.autoHighlight,
35
37
  name: props.name,
36
38
  form: props.form,
37
39
  items: props.items,
@@ -44,14 +46,14 @@ function Root(props) {
44
46
  return (<Context.Provider value={made}>
45
47
  {props.children}
46
48
  <Show when={named()}>
47
- <Part part={made.hidden} tag="input"/>
49
+ <Part of={made.hidden} tag="input"/>
48
50
  </Show>
49
51
  </Context.Provider>);
50
52
  }
51
53
  const Portal = (props) => (<BodyPortal mounted={useCombobox().mounted}>{props.children}</BodyPortal>);
52
54
  function Positioner(props) {
53
55
  const made = useCombobox();
54
- return <Part part={made.positioner} tag="div" {...positioned(props, made.positioning)}/>;
56
+ return <Part of={made.positioner} tag="div" {...positioned(props, made.positioning)}/>;
55
57
  }
56
58
  /** `label` is what is filtered and what the input shows; the item's text when left out. */
57
59
  function Item(props) {
@@ -67,7 +69,7 @@ function Item(props) {
67
69
  }));
68
70
  const part = useCombobox().item(value, () => options.get(), useContext(GroupContext));
69
71
  return (<ItemContext.Provider value={value}>
70
- <Part part={part} tag="div" {...rest}/>
72
+ <Part of={part} tag="div" {...rest}/>
71
73
  </ItemContext.Provider>);
72
74
  }
73
75
  function ItemIndicator(props) {
@@ -76,7 +78,7 @@ function ItemIndicator(props) {
76
78
  const value = useContext(ItemContext);
77
79
  const selected = fromSignal(made.selected(value));
78
80
  return (<Show when={selected() || local.keepMounted}>
79
- <Part part={made.itemIndicator(value)} tag="span" {...rest}/>
81
+ <Part of={made.itemIndicator(value)} tag="span" {...rest}/>
80
82
  </Show>);
81
83
  }
82
84
  /** A button that empties the input and the value. Drawn while there is something to clear. */
@@ -85,7 +87,7 @@ function Clear(props) {
85
87
  const made = useCombobox();
86
88
  const clearable = fromSignal(made.clearable);
87
89
  return (<Show when={clearable() || local.keepMounted}>
88
- <Part part={made.clear} tag="button" {...rest}/>
90
+ <Part of={made.clear} tag="button" {...rest}/>
89
91
  </Show>);
90
92
  }
91
93
  const ChipContext = createContext();
@@ -95,16 +97,16 @@ function Chip(props) {
95
97
  // A chip is its value for as long as it is in the page.
96
98
  const value = untrack(() => local.value);
97
99
  return (<ChipContext.Provider value={value}>
98
- <Part part={useCombobox().chip(value)} tag="span" {...rest}/>
100
+ <Part of={useCombobox().chip(value)} tag="span" {...rest}/>
99
101
  </ChipContext.Provider>);
100
102
  }
101
- const ChipRemove = (props) => (<Part part={useCombobox().chipRemove(useContext(ChipContext))} tag="button" {...props}/>);
103
+ const ChipRemove = (props) => (<Part of={useCombobox().chipRemove(useContext(ChipContext))} tag="button" {...props}/>);
102
104
  /** Drawn while no item is shown for what was typed. */
103
105
  function Empty(props) {
104
106
  const made = useCombobox();
105
107
  const empty = fromSignal(made.empty);
106
108
  return (<Show when={empty()}>
107
- <Part part={made.emptyPart} tag="div" {...props}/>
109
+ <Part of={made.emptyPart} tag="div" {...props}/>
108
110
  </Show>);
109
111
  }
110
112
  const GroupContext = createContext();
@@ -114,12 +116,48 @@ function Group(props) {
114
116
  const generated = createUniqueId();
115
117
  const group = useCombobox().group(untrack(() => local.id) ?? generated);
116
118
  return (<GroupContext.Provider value={group}>
117
- <Part part={group.root} tag="div" {...rest}/>
119
+ <Part of={group.root} tag="div" {...rest}/>
118
120
  </GroupContext.Provider>);
119
121
  }
120
122
  /** Names the group it is in. With no group around it, it is plain text. */
121
- const GroupLabel = (props) => (<Part part={useContext(GroupContext)?.label ?? useCombobox().groupLabel} tag="div" {...props}/>);
122
- const part = (name, tag) => (props) => <Part part={useCombobox()[name]} tag={tag} {...props}/>;
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
+ }
160
+ const part = (name, tag) => (props) => <Part of={useCombobox()[name]} tag={tag} {...props}/>;
123
161
  /** A combobox whose text is the value: the list only suggests. */
124
162
  function AutocompleteRoot(props) {
125
163
  const generated = createUniqueId();
@@ -134,10 +172,13 @@ function AutocompleteRoot(props) {
134
172
  filter: props.filter,
135
173
  openOnInputClick: props.openOnInputClick,
136
174
  disabled: props.disabled,
175
+ readOnly: props.readOnly,
176
+ items: props.items,
137
177
  required: props.required,
138
178
  name: props.name,
139
179
  form: props.form,
140
180
  virtualized: props.virtualized,
181
+ autoHighlight: props.autoHighlight,
141
182
  onValueChange: (value, details) => props.onValueChange?.(value, details),
142
183
  onOpenChange: (open, details) => props.onOpenChange?.(open, details),
143
184
  }));
@@ -147,6 +188,7 @@ export const Combobox = {
147
188
  Root,
148
189
  Input: part("input", "input"),
149
190
  Trigger: part("trigger", "button"),
191
+ Value,
150
192
  Clear,
151
193
  /** With `multiple`: what holds the chips and the input. */
152
194
  Chips: part("chips", "div"),
@@ -155,6 +197,12 @@ export const Combobox = {
155
197
  Portal,
156
198
  Positioner,
157
199
  Popup: part("popup", "div"),
200
+ /**
201
+ * The items' own box inside the popup, when the popup holds more than items (an input): it
202
+ * is then the listbox.
203
+ */
204
+ List: part("list", "div"),
205
+ Collection,
158
206
  Group,
159
207
  GroupLabel,
160
208
  /** A line between groups. */
@@ -162,6 +210,12 @@ export const Combobox = {
162
210
  Item,
163
211
  ItemIndicator,
164
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"),
165
219
  };
166
220
  export const Autocomplete = {
167
221
  Root: AutocompleteRoot,
@@ -171,9 +225,12 @@ export const Autocomplete = {
171
225
  Portal: Combobox.Portal,
172
226
  Positioner: Combobox.Positioner,
173
227
  Popup: Combobox.Popup,
228
+ List: Combobox.List,
229
+ Collection: Combobox.Collection,
174
230
  Group: Combobox.Group,
175
231
  GroupLabel: Combobox.GroupLabel,
176
232
  Separator: Combobox.Separator,
177
233
  Item: Combobox.Item,
178
234
  Empty: Combobox.Empty,
235
+ Status: Combobox.Status,
179
236
  };