@kirana-ui/solid 0.1.0 → 0.1.1

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 (159) hide show
  1. package/dom/autocomplete.js +2 -0
  2. package/dom/autosize.js +19 -0
  3. package/dom/calendar.js +141 -0
  4. package/dom/carousel.js +83 -0
  5. package/dom/checkbox.js +2 -1
  6. package/dom/combobox.js +281 -0
  7. package/dom/command.js +129 -0
  8. package/dom/context-menu.js +2 -0
  9. package/dom/date-field.js +86 -0
  10. package/dom/date-picker.js +103 -0
  11. package/dom/dialog.js +28 -0
  12. package/dom/drawer.js +2 -0
  13. package/dom/hover-popup.js +17 -2
  14. package/dom/index.js +26 -1
  15. package/dom/input.js +26 -0
  16. package/dom/label.js +18 -0
  17. package/dom/listbox.js +114 -0
  18. package/dom/menu.js +261 -0
  19. package/dom/menubar-context.js +3 -0
  20. package/dom/menubar.js +33 -0
  21. package/dom/message-scroller.js +56 -0
  22. package/dom/navigation-menu.js +150 -0
  23. package/dom/number-field.js +82 -0
  24. package/dom/otp.js +95 -0
  25. package/dom/pagination.js +74 -0
  26. package/dom/popover.js +2 -0
  27. package/dom/qr-code.js +48 -0
  28. package/dom/radio-group.js +2 -1
  29. package/dom/resizable.js +65 -0
  30. package/dom/runtime.js +36 -2
  31. package/dom/scroll-area.js +99 -0
  32. package/dom/select.js +69 -5
  33. package/dom/slider.js +1 -1
  34. package/dom/switch.js +2 -1
  35. package/dom/toast.js +113 -0
  36. package/dom/toggle-group.js +37 -0
  37. package/dom/toggle.js +11 -3
  38. package/dom/toolbar-context.js +5 -0
  39. package/dom/toolbar.js +71 -0
  40. package/llms.txt +1838 -0
  41. package/package.json +220 -2
  42. package/server/autocomplete.js +2 -0
  43. package/server/autosize.js +19 -0
  44. package/server/calendar.js +140 -0
  45. package/server/carousel.js +83 -0
  46. package/server/checkbox.js +2 -1
  47. package/server/combobox.js +281 -0
  48. package/server/command.js +129 -0
  49. package/server/context-menu.js +2 -0
  50. package/server/date-field.js +86 -0
  51. package/server/date-picker.js +103 -0
  52. package/server/dialog.js +28 -0
  53. package/server/drawer.js +2 -0
  54. package/server/hover-popup.js +17 -2
  55. package/server/index.js +26 -1
  56. package/server/input.js +26 -0
  57. package/server/label.js +18 -0
  58. package/server/listbox.js +114 -0
  59. package/server/menu.js +261 -0
  60. package/server/menubar-context.js +3 -0
  61. package/server/menubar.js +33 -0
  62. package/server/message-scroller.js +56 -0
  63. package/server/navigation-menu.js +144 -0
  64. package/server/number-field.js +81 -0
  65. package/server/otp.js +94 -0
  66. package/server/pagination.js +74 -0
  67. package/server/popover.js +2 -0
  68. package/server/qr-code.js +48 -0
  69. package/server/radio-group.js +2 -1
  70. package/server/resizable.js +65 -0
  71. package/server/runtime.js +35 -1
  72. package/server/scroll-area.js +99 -0
  73. package/server/select.js +69 -5
  74. package/server/slider.js +1 -1
  75. package/server/switch.js +2 -1
  76. package/server/toast.js +113 -0
  77. package/server/toggle-group.js +37 -0
  78. package/server/toggle.js +11 -3
  79. package/server/toolbar-context.js +5 -0
  80. package/server/toolbar.js +71 -0
  81. package/src/autocomplete.jsx +2 -0
  82. package/src/autosize.jsx +8 -0
  83. package/src/calendar.jsx +104 -0
  84. package/src/carousel.jsx +51 -0
  85. package/src/checkbox.jsx +2 -0
  86. package/src/combobox.jsx +179 -0
  87. package/src/command.jsx +81 -0
  88. package/src/context-menu.js +2 -0
  89. package/src/date-field.jsx +67 -0
  90. package/src/date-picker.jsx +72 -0
  91. package/src/dialog.jsx +20 -0
  92. package/src/drawer.js +2 -0
  93. package/src/hover-popup.jsx +10 -2
  94. package/src/index.js +26 -1
  95. package/src/input.jsx +17 -0
  96. package/src/label.jsx +9 -0
  97. package/src/listbox.jsx +81 -0
  98. package/src/menu.jsx +164 -0
  99. package/src/menubar-context.js +3 -0
  100. package/src/menubar.jsx +21 -0
  101. package/src/message-scroller.jsx +27 -0
  102. package/src/navigation-menu.jsx +95 -0
  103. package/src/number-field.jsx +75 -0
  104. package/src/otp.jsx +73 -0
  105. package/src/pagination.jsx +60 -0
  106. package/src/popover.jsx +2 -0
  107. package/src/qr-code.jsx +25 -0
  108. package/src/radio-group.jsx +2 -0
  109. package/src/resizable.jsx +46 -0
  110. package/src/runtime.jsx +33 -2
  111. package/src/scroll-area.jsx +53 -0
  112. package/src/select.jsx +49 -5
  113. package/src/slider.jsx +2 -0
  114. package/src/switch.jsx +2 -0
  115. package/src/toast.jsx +58 -0
  116. package/src/toggle-group.jsx +32 -0
  117. package/src/toggle.jsx +8 -2
  118. package/src/toolbar-context.js +5 -0
  119. package/src/toolbar.jsx +43 -0
  120. package/types/autocomplete.d.ts +1 -0
  121. package/types/autosize.d.ts +8 -0
  122. package/types/calendar.d.ts +40 -0
  123. package/types/carousel.d.ts +26 -0
  124. package/types/checkbox.d.ts +1 -0
  125. package/types/combobox.d.ts +106 -0
  126. package/types/command.d.ts +45 -0
  127. package/types/context-menu.d.ts +1 -0
  128. package/types/date-field.d.ts +23 -0
  129. package/types/date-picker.d.ts +49 -0
  130. package/types/dialog.d.ts +21 -0
  131. package/types/drawer.d.ts +1 -0
  132. package/types/hover-card.d.ts +4 -1
  133. package/types/hover-popup.d.ts +4 -1
  134. package/types/index.d.ts +27 -1
  135. package/types/input.d.ts +12 -0
  136. package/types/label.d.ts +4 -0
  137. package/types/listbox.d.ts +38 -0
  138. package/types/menu.d.ts +91 -0
  139. package/types/menubar-context.d.ts +3 -0
  140. package/types/menubar.d.ts +10 -0
  141. package/types/message-scroller.d.ts +16 -0
  142. package/types/navigation-menu.d.ts +44 -0
  143. package/types/number-field.d.ts +15 -0
  144. package/types/otp.d.ts +32 -0
  145. package/types/pagination.d.ts +23 -0
  146. package/types/popover.d.ts +4 -1
  147. package/types/qr-code.d.ts +14 -0
  148. package/types/radio-group.d.ts +1 -0
  149. package/types/resizable.d.ts +24 -0
  150. package/types/runtime.d.ts +18 -0
  151. package/types/scroll-area.d.ts +20 -0
  152. package/types/select.d.ts +25 -1
  153. package/types/switch.d.ts +1 -0
  154. package/types/toast.d.ts +33 -0
  155. package/types/toggle-group.d.ts +14 -0
  156. package/types/toggle.d.ts +2 -0
  157. package/types/toolbar-context.d.ts +6 -0
  158. package/types/toolbar.d.ts +23 -0
  159. package/types/tooltip.d.ts +4 -1
package/server/select.js CHANGED
@@ -3,7 +3,7 @@ import { mergeProps as _$mergeProps } from "solid-js/web";
3
3
  import { createComponent as _$createComponent } from "solid-js/web";
4
4
  import { defined, within } from "@kirana-ui/core";
5
5
  import { createSelect } from "@kirana-ui/core/select";
6
- import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
6
+ import { Show, createComputed, createContext, createUniqueId, onCleanup, onMount, splitProps, untrack, useContext } from "solid-js";
7
7
  import { positioned } from "./popover.js";
8
8
  import { FieldContext } from "./field-context.js";
9
9
  import { Part, Portal as BodyPortal, controller, fromSignal, toSignal } from "./runtime.js";
@@ -28,7 +28,9 @@ function Root(props) {
28
28
  disabled: props.disabled,
29
29
  required: props.required,
30
30
  name: props.name,
31
+ form: props.form,
31
32
  items: props.items,
33
+ virtualized: props.virtualized,
32
34
  onValueChange: (value, details) => props.onValueChange?.(value, details),
33
35
  onOpenChange: (open, details) => props.onOpenChange?.(open, details)
34
36
  }));
@@ -60,14 +62,20 @@ const Portal = props => _$createComponent(BodyPortal, {
60
62
  return props.children;
61
63
  }
62
64
  });
65
+ /**
66
+ * `alignItemWithTrigger`: the list opens over its trigger, the chosen item's text on the
67
+ * trigger's own, where there is room and unless a finger opened it.
68
+ */
63
69
  function Positioner(props) {
64
70
  const made = useSelect();
71
+ const [local, rest] = splitProps(props, ["alignItemWithTrigger"]);
72
+ createComputed(() => made.alignItemWithTrigger.set(Boolean(local.alignItemWithTrigger)));
65
73
  return _$createComponent(Part, _$mergeProps({
66
74
  get part() {
67
75
  return made.positioner;
68
76
  },
69
77
  tag: "div"
70
- }, () => positioned(props, made.positioning)));
78
+ }, () => positioned(rest, made.positioning)));
71
79
  }
72
80
  /** Shows the chosen value's label, or `placeholder` while nothing is chosen. */
73
81
  function Value(props) {
@@ -87,12 +95,13 @@ function Value(props) {
87
95
  }
88
96
  /** `label` is what typeahead matches and the trigger shows; the item's text when left out. */
89
97
  function Item(props) {
90
- const [local, rest] = splitProps(props, ["value", "disabled", "label"]);
98
+ const [local, rest] = splitProps(props, ["value", "disabled", "label", "index"]);
91
99
  // An item is its value for as long as it is in the page.
92
100
  const value = untrack(() => local.value);
93
101
  const options = toSignal(() => ({
94
102
  disabled: local.disabled,
95
- label: local.label
103
+ label: local.label,
104
+ index: local.index
96
105
  }));
97
106
  const part = useSelect().item(value, () => defined(options.get()));
98
107
  return _$createComponent(ItemContext.Provider, {
@@ -130,6 +139,51 @@ function ItemIndicator(props) {
130
139
  }
131
140
  });
132
141
  }
142
+ const GroupContext = createContext();
143
+ /** Items that belong together, named by their `<Select.GroupLabel>`. */
144
+ function Group(props) {
145
+ const [local, rest] = splitProps(props, ["id"]);
146
+ const generated = createUniqueId();
147
+ const group = useSelect().group(untrack(() => local.id) ?? generated);
148
+ return _$createComponent(GroupContext.Provider, {
149
+ value: group,
150
+ get children() {
151
+ return _$createComponent(Part, _$mergeProps({
152
+ get part() {
153
+ return group.root;
154
+ },
155
+ tag: "div"
156
+ }, rest));
157
+ }
158
+ });
159
+ }
160
+ /** Names the group it is in. With no group around it, it is plain text. */
161
+ const GroupLabel = props => _$createComponent(Part, _$mergeProps({
162
+ get part() {
163
+ return useContext(GroupContext)?.label ?? useSelect().groupLabel;
164
+ },
165
+ tag: "div"
166
+ }, props));
167
+ function scrollArrow(direction) {
168
+ return props => {
169
+ const arrow = useSelect().scrollArrow(direction);
170
+ onMount(() => onCleanup(arrow.mount()));
171
+ const mounted = fromSignal(arrow.mounted);
172
+ return _$createComponent(Show, {
173
+ get when() {
174
+ return mounted();
175
+ },
176
+ get children() {
177
+ return _$createComponent(Part, _$mergeProps({
178
+ get part() {
179
+ return arrow.part;
180
+ },
181
+ tag: "div"
182
+ }, props));
183
+ }
184
+ });
185
+ };
186
+ }
133
187
  const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
134
188
  get part() {
135
189
  return useSelect()[name];
@@ -145,5 +199,15 @@ export const Select = {
145
199
  ItemText,
146
200
  ItemIndicator,
147
201
  Trigger: part("trigger", "button"),
148
- Popup: part("popup", "div")
202
+ Popup: part("popup", "div"),
203
+ /** The items' own box inside the popup, when the popup also holds scroll arrows. */
204
+ List: part("list", "div"),
205
+ /** In the page while there is more of the list above: it scrolls it under a moving pointer. */
206
+ ScrollUpArrow: scrollArrow("up"),
207
+ /** In the page while there is more of the list below. */
208
+ ScrollDownArrow: scrollArrow("down"),
209
+ Group,
210
+ GroupLabel,
211
+ /** A line between groups. */
212
+ Separator: part("separator", "div")
149
213
  };
package/server/slider.js CHANGED
@@ -13,7 +13,7 @@ function useSlider() {
13
13
  return made;
14
14
  }
15
15
  function Root(props) {
16
- const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "onValueCommitted", "min", "max", "step", "largeStep", "minStepsBetweenValues", "orientation", "disabled", "name", "format", "locale", "getAriaValueText", "id"]);
16
+ const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "onValueCommitted", "min", "max", "step", "largeStep", "minStepsBetweenValues", "thumbAlignment", "orientation", "disabled", "name", "form", "format", "locale", "getAriaValueText", "id"]);
17
17
  const generated = createUniqueId();
18
18
  const field = useContext(FieldContext);
19
19
  const made = controller(within(createSlider, {
package/server/switch.js CHANGED
@@ -12,7 +12,7 @@ function useSwitch() {
12
12
  return made;
13
13
  }
14
14
  function Root(props) {
15
- const [local, rest] = splitProps(props, ["checked", "defaultChecked", "onCheckedChange", "disabled", "readOnly", "required", "name", "value", "id", "children"]);
15
+ const [local, rest] = splitProps(props, ["checked", "defaultChecked", "onCheckedChange", "disabled", "readOnly", "required", "name", "form", "value", "id", "children"]);
16
16
  const generated = createUniqueId();
17
17
  const field = useContext(FieldContext);
18
18
  const made = controller(within(createSwitch, {
@@ -25,6 +25,7 @@ function Root(props) {
25
25
  readOnly: local.readOnly,
26
26
  required: local.required,
27
27
  name: local.name,
28
+ form: local.form,
28
29
  value: local.value,
29
30
  onCheckedChange: (checked, details) => local.onCheckedChange?.(checked, details)
30
31
  }));
@@ -0,0 +1,113 @@
1
+ import { createComponent as _$createComponent } from "solid-js/web";
2
+ import { mergeProps as _$mergeProps } from "solid-js/web";
3
+ import { createToast } from "@kirana-ui/core/toast";
4
+ import { For, createContext, createMemo, createUniqueId, splitProps, useContext } from "solid-js";
5
+ import { Part, controller, fromSignal } from "./runtime.js";
6
+ const Context = createContext();
7
+ const ToastContext = createContext();
8
+ function useToast() {
9
+ const made = useContext(Context);
10
+ if (!made) throw new Error("A Toast part must be inside <Toast.Viewport>");
11
+ return made;
12
+ }
13
+ function useParts() {
14
+ const parts = useContext(ToastContext);
15
+ if (!parts) throw new Error("A toast's part must be inside <Toast.Root>");
16
+ return parts;
17
+ }
18
+ /** Where a toaster's toasts are drawn. Always in the page: put it once, near the root. */
19
+ function Viewport(props) {
20
+ const [local, rest] = splitProps(props, ["toaster", "label", "hotkey", "swipeDirection", "id"]);
21
+ const generated = createUniqueId();
22
+ const made = controller(createToast, () => ({
23
+ id: local.id ?? generated,
24
+ toaster: local.toaster,
25
+ label: local.label,
26
+ hotkey: local.hotkey,
27
+ swipeDirection: local.swipeDirection
28
+ }));
29
+ return _$createComponent(Context.Provider, {
30
+ value: made,
31
+ get children() {
32
+ return _$createComponent(Part, _$mergeProps({
33
+ get part() {
34
+ return made.viewport;
35
+ },
36
+ tag: "div"
37
+ }, rest));
38
+ }
39
+ });
40
+ }
41
+ /**
42
+ * Draws its child once for each toast, the newest first. The child is given the toast as an
43
+ * accessor: one that changes is the same toast, drawn again where it stands.
44
+ */
45
+ function List(props) {
46
+ const toasts = fromSignal(useToast().toasts);
47
+ const ids = createMemo(() => toasts().map(each => each.id), undefined, {
48
+ equals: (a, b) => a.length === b.length && a.every((each, at) => each === b[at])
49
+ });
50
+ return _$createComponent(For, {
51
+ get each() {
52
+ return ids();
53
+ },
54
+ children: id => props.children(() => toasts().find(each => each.id === id))
55
+ });
56
+ }
57
+ function Root(props) {
58
+ const [local, rest] = splitProps(props, ["toast"]);
59
+ // A root is its toast for as long as it is in the page.
60
+ const parts = useToast().toast(local.toast.id);
61
+ return _$createComponent(ToastContext.Provider, {
62
+ value: parts,
63
+ get children() {
64
+ return _$createComponent(Part, _$mergeProps({
65
+ get part() {
66
+ return parts.root;
67
+ },
68
+ tag: "div"
69
+ }, rest));
70
+ }
71
+ });
72
+ }
73
+ const Content = props => _$createComponent(Part, _$mergeProps({
74
+ get part() {
75
+ return useParts().content;
76
+ },
77
+ tag: "div"
78
+ }, props));
79
+ const Title = props => _$createComponent(Part, _$mergeProps({
80
+ get part() {
81
+ return useParts().title;
82
+ },
83
+ tag: "div"
84
+ }, props));
85
+ const Description = props => _$createComponent(Part, _$mergeProps({
86
+ get part() {
87
+ return useParts().description;
88
+ },
89
+ tag: "div"
90
+ }, props));
91
+ const Close = props => _$createComponent(Part, _$mergeProps({
92
+ get part() {
93
+ return useParts().close;
94
+ },
95
+ tag: "button"
96
+ }, props));
97
+ const Action = props => _$createComponent(Part, _$mergeProps({
98
+ get part() {
99
+ return useParts().action;
100
+ },
101
+ tag: "button"
102
+ }, props));
103
+ export const Toast = {
104
+ Viewport,
105
+ List,
106
+ Root,
107
+ Content,
108
+ Title,
109
+ Description,
110
+ Close,
111
+ Action
112
+ };
113
+ export { createToaster } from "@kirana-ui/core/toast";
@@ -0,0 +1,37 @@
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 { createToggleGroup } from "@kirana-ui/core/toggle-group";
5
+ import { splitProps, useContext } from "solid-js";
6
+ import { DirectionContext } from "./direction-context.js";
7
+ import { Part, controller } from "./runtime.js";
8
+ import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
9
+ /** Toggles that are one control. Each `<Toggle value>` inside it is one of its toggles. */
10
+ export function ToggleGroup(props) {
11
+ const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "multiple", "disabled", "orientation", "loop"]);
12
+ const direction = useContext(DirectionContext);
13
+ const toolbar = useContext(ToolbarContext) ?? undefined;
14
+ const made = controller(within(createToggleGroup, {
15
+ direction,
16
+ toolbar
17
+ }), () => ({
18
+ value: local.value,
19
+ defaultValue: local.defaultValue,
20
+ multiple: local.multiple,
21
+ disabled: local.disabled,
22
+ orientation: local.orientation,
23
+ loop: local.loop,
24
+ onValueChange: (value, details) => local.onValueChange?.(value, details)
25
+ }));
26
+ return _$createComponent(ToggleGroupContext.Provider, {
27
+ value: made,
28
+ get children() {
29
+ return _$createComponent(Part, _$mergeProps({
30
+ get part() {
31
+ return made.root;
32
+ },
33
+ tag: "div"
34
+ }, rest));
35
+ }
36
+ });
37
+ }
package/server/toggle.js CHANGED
@@ -1,14 +1,22 @@
1
1
  import { createComponent as _$createComponent } from "solid-js/web";
2
2
  import { mergeProps as _$mergeProps } from "solid-js/web";
3
+ import { within } from "@kirana-ui/core";
3
4
  import { createToggle } from "@kirana-ui/core/toggle";
4
- import { splitProps } from "solid-js";
5
+ import { splitProps, useContext } from "solid-js";
5
6
  import { Part, controller } from "./runtime.js";
7
+ import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
6
8
  export function Toggle(props) {
7
- const [local, rest] = splitProps(props, ["pressed", "defaultPressed", "onPressedChange", "disabled"]);
8
- const made = controller(createToggle, () => ({
9
+ const [local, rest] = splitProps(props, ["pressed", "defaultPressed", "onPressedChange", "disabled", "value"]);
10
+ const group = useContext(ToggleGroupContext) ?? undefined;
11
+ const toolbar = useContext(ToolbarContext) ?? undefined;
12
+ const made = controller(within(createToggle, {
13
+ group,
14
+ toolbar
15
+ }), () => ({
9
16
  pressed: local.pressed,
10
17
  defaultPressed: local.defaultPressed,
11
18
  disabled: local.disabled,
19
+ value: local.value,
12
20
  onPressedChange: (pressed, details) => local.onPressedChange?.(pressed, details)
13
21
  }));
14
22
  return _$createComponent(Part, _$mergeProps({
@@ -0,0 +1,5 @@
1
+ import { createContext } from "solid-js";
2
+ /** The toolbar a control is an item of, if it is in one. */
3
+ export const ToolbarContext = createContext(null);
4
+ /** The group a toggle is one of the toggles of, if it is in one. */
5
+ export const ToggleGroupContext = createContext(null);
@@ -0,0 +1,71 @@
1
+ import { createComponent as _$createComponent } from "solid-js/web";
2
+ import { mergeProps as _$mergeProps } from "solid-js/web";
3
+ import { defined, within } from "@kirana-ui/core";
4
+ import { createToolbar } from "@kirana-ui/core/toolbar";
5
+ import { splitProps, useContext } from "solid-js";
6
+ import { DirectionContext } from "./direction-context.js";
7
+ import { Part, controller, toSignal } from "./runtime.js";
8
+ import { ToggleGroupContext, ToolbarContext } from "./toolbar-context.js";
9
+ function useToolbar() {
10
+ const made = useContext(ToolbarContext);
11
+ if (!made) throw new Error("A Toolbar part must be inside <Toolbar.Root>");
12
+ return made;
13
+ }
14
+ function Root(props) {
15
+ const [local, rest] = splitProps(props, ["orientation", "loop", "disabled"]);
16
+ const direction = useContext(DirectionContext);
17
+ const made = controller(within(createToolbar, {
18
+ direction
19
+ }), () => ({
20
+ orientation: local.orientation,
21
+ loop: local.loop,
22
+ disabled: local.disabled
23
+ }));
24
+ return _$createComponent(ToolbarContext.Provider, {
25
+ value: made,
26
+ get children() {
27
+ return _$createComponent(ToggleGroupContext.Provider, {
28
+ value: null,
29
+ get children() {
30
+ return _$createComponent(Part, _$mergeProps({
31
+ get part() {
32
+ return made.root;
33
+ },
34
+ tag: "div"
35
+ }, rest));
36
+ }
37
+ });
38
+ }
39
+ });
40
+ }
41
+ const item = (name, tag) => props => {
42
+ const [local, rest] = splitProps(props, ["disabled"]);
43
+ const options = toSignal(() => ({
44
+ disabled: local.disabled
45
+ }));
46
+ const part = useToolbar()[name](() => defined(options.get()));
47
+ return _$createComponent(Part, _$mergeProps({
48
+ part: part,
49
+ tag: tag
50
+ }, rest));
51
+ };
52
+ const Link = props => _$createComponent(Part, _$mergeProps({
53
+ get part() {
54
+ return useToolbar().link();
55
+ },
56
+ tag: "a"
57
+ }, props));
58
+ const Separator = props => _$createComponent(Part, _$mergeProps({
59
+ get part() {
60
+ return useToolbar().separator;
61
+ },
62
+ tag: "div"
63
+ }, props));
64
+ export const Toolbar = {
65
+ Root,
66
+ Button: item("button", "button"),
67
+ Link,
68
+ Input: item("input", "input"),
69
+ Group: item("group", "div"),
70
+ Separator
71
+ };
@@ -0,0 +1,2 @@
1
+ // An autocomplete is a combobox whose text is the value: its parts are a combobox's.
2
+ export { Autocomplete } from "./combobox.jsx";
@@ -0,0 +1,8 @@
1
+ import { createAutosize } from "@kirana-ui/core/autosize";
2
+ import { Part, controller } from "./runtime.jsx";
3
+ /** A `<textarea>` as tall as its text. It takes what a `<textarea>` takes. */
4
+ function Textarea(props) {
5
+ const made = controller(createAutosize, () => ({ value: props.value }));
6
+ return <Part part={made.textarea} tag="textarea" {...props}/>;
7
+ }
8
+ export const Autosize = { Textarea };
@@ -0,0 +1,104 @@
1
+ import { within } from "@kirana-ui/core";
2
+ import { createCalendar } from "@kirana-ui/core/calendar";
3
+ import { For, createContext, createUniqueId, splitProps, useContext } from "solid-js";
4
+ import { DirectionContext } from "./direction-context.js";
5
+ import { Part, controller, fromSignal } from "./runtime.jsx";
6
+ const Context = createContext();
7
+ /** For a component made of this one's parts: a date picker. */
8
+ export { Context as CalendarContext };
9
+ function useCalendar() {
10
+ const made = useContext(Context);
11
+ if (!made)
12
+ throw new Error("A Calendar part must be inside <Calendar.Root>");
13
+ return made;
14
+ }
15
+ function Root(props) {
16
+ const [local, rest] = splitProps(props, [
17
+ "value",
18
+ "defaultValue",
19
+ "onValueChange",
20
+ "mode",
21
+ "defaultFocusedValue",
22
+ "onMonthChange",
23
+ "locale",
24
+ "calendarSystem",
25
+ "min",
26
+ "max",
27
+ "isDateUnavailable",
28
+ "disabled",
29
+ "readOnly",
30
+ "fixedWeeks",
31
+ "id",
32
+ ]);
33
+ const generated = createUniqueId();
34
+ const direction = useContext(DirectionContext);
35
+ const made = controller(within(createCalendar, { direction }), () => ({
36
+ id: local.id ?? generated,
37
+ value: local.value,
38
+ defaultValue: local.defaultValue,
39
+ mode: local.mode,
40
+ defaultFocusedValue: local.defaultFocusedValue,
41
+ locale: local.locale,
42
+ calendarSystem: local.calendarSystem,
43
+ min: local.min,
44
+ max: local.max,
45
+ isDateUnavailable: local.isDateUnavailable,
46
+ disabled: local.disabled,
47
+ readOnly: local.readOnly,
48
+ fixedWeeks: local.fixedWeeks,
49
+ onValueChange: (value, details) => local.onValueChange?.(value, details),
50
+ onMonthChange: (month) => local.onMonthChange?.(month),
51
+ }));
52
+ return (<Context.Provider value={made}>
53
+ <Part part={made.root} tag="div" {...rest}/>
54
+ </Context.Provider>);
55
+ }
56
+ /** Names the month shown, unless it is given something else to say. */
57
+ function Heading(props) {
58
+ const made = useCalendar();
59
+ const title = fromSignal(made.title);
60
+ return (<Part part={made.heading} tag="div" {...props}>
61
+ {props.children ?? title()}
62
+ </Part>);
63
+ }
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}/>);
67
+ /** Draws its child once for each day of the week, in the locale's order. */
68
+ function Weekdays(props) {
69
+ const weekdays = fromSignal(useCalendar().weekdays);
70
+ return <For each={weekdays()}>{(weekday) => props.children(weekday)}</For>;
71
+ }
72
+ /** Draws its child once for each week of the month shown. */
73
+ function Weeks(props) {
74
+ const weeks = fromSignal(useCalendar().weeks);
75
+ return <For each={weeks()}>{(week) => props.children(week)}</For>;
76
+ }
77
+ function HeadCell(props) {
78
+ const [local, rest] = splitProps(props, ["weekday"]);
79
+ const part = useCalendar().headCell(local.weekday);
80
+ return <Part part={part} tag="th" {...rest}/>;
81
+ }
82
+ function Cell(props) {
83
+ const [local, rest] = splitProps(props, ["date"]);
84
+ // 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}/>;
87
+ }
88
+ function Day(props) {
89
+ const [local, rest] = splitProps(props, ["date"]);
90
+ const part = useCalendar().day(local.date);
91
+ return <Part part={part} tag="button" {...rest}/>;
92
+ }
93
+ export const Calendar = {
94
+ Root,
95
+ Heading,
96
+ Previous,
97
+ Next,
98
+ Grid,
99
+ Weekdays,
100
+ HeadCell,
101
+ Weeks,
102
+ Cell,
103
+ Day,
104
+ };
@@ -0,0 +1,51 @@
1
+ import { within } from "@kirana-ui/core";
2
+ import { createCarousel } from "@kirana-ui/core/carousel";
3
+ import { createContext, createUniqueId, splitProps, useContext } from "solid-js";
4
+ import { DirectionContext } from "./direction-context.js";
5
+ import { Part, controller } from "./runtime.jsx";
6
+ const Context = createContext();
7
+ function useCarousel() {
8
+ const made = useContext(Context);
9
+ if (!made)
10
+ throw new Error("A Carousel part must be inside <Carousel.Root>");
11
+ return made;
12
+ }
13
+ function Root(props) {
14
+ const [local, rest] = splitProps(props, [
15
+ "index",
16
+ "defaultIndex",
17
+ "onIndexChange",
18
+ "orientation",
19
+ "loop",
20
+ "id",
21
+ ]);
22
+ const generated = createUniqueId();
23
+ const direction = useContext(DirectionContext);
24
+ const made = controller(within(createCarousel, { direction }), () => ({
25
+ id: local.id ?? generated,
26
+ index: local.index,
27
+ defaultIndex: local.defaultIndex,
28
+ orientation: local.orientation,
29
+ loop: local.loop,
30
+ onIndexChange: (index, details) => local.onIndexChange?.(index, details),
31
+ }));
32
+ return (<Context.Provider value={made}>
33
+ <Part part={made.root} tag="div" {...rest}/>
34
+ </Context.Provider>);
35
+ }
36
+ const Viewport = (props) => (<Part part={useCarousel().viewport} tag="div" {...props}/>);
37
+ function Item(props) {
38
+ const [local, rest] = splitProps(props, ["index"]);
39
+ // A slide is its place for as long as it is in the page.
40
+ const part = useCarousel().item(local.index);
41
+ return <Part part={part} tag="div" {...rest}/>;
42
+ }
43
+ const Previous = (props) => (<Part part={useCarousel().previous} tag="button" {...props}/>);
44
+ const Next = (props) => (<Part part={useCarousel().next} tag="button" {...props}/>);
45
+ function Indicator(props) {
46
+ const [local, rest] = splitProps(props, ["index"]);
47
+ // A button is its slide for as long as it is in the page.
48
+ const part = useCarousel().indicator(local.index);
49
+ return <Part part={part} tag="button" {...rest}/>;
50
+ }
51
+ export const Carousel = { Root, Viewport, Item, Previous, Next, Indicator };
package/src/checkbox.jsx CHANGED
@@ -20,6 +20,7 @@ function Root(props) {
20
20
  "readOnly",
21
21
  "required",
22
22
  "name",
23
+ "form",
23
24
  "value",
24
25
  "id",
25
26
  "children",
@@ -35,6 +36,7 @@ function Root(props) {
35
36
  readOnly: local.readOnly,
36
37
  required: local.required,
37
38
  name: local.name,
39
+ form: local.form,
38
40
  value: local.value,
39
41
  onCheckedChange: (checked, details) => local.onCheckedChange?.(checked, details),
40
42
  }));