@kirana-ui/solid 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/dom/accordion.js +9 -6
  2. package/dom/agent.js +3 -0
  3. package/dom/autocomplete.js +2 -0
  4. package/dom/autosize.js +19 -0
  5. package/dom/avatar.js +3 -3
  6. package/dom/button.js +1 -1
  7. package/dom/calendar.js +145 -0
  8. package/dom/carousel.js +83 -0
  9. package/dom/checkbox.js +5 -4
  10. package/dom/collapsible.js +3 -3
  11. package/dom/combobox.js +289 -0
  12. package/dom/command.js +129 -0
  13. package/dom/context-menu.js +2 -0
  14. package/dom/date-field.js +90 -0
  15. package/dom/date-picker.js +103 -0
  16. package/dom/dialog.js +32 -1
  17. package/dom/drawer.js +2 -0
  18. package/dom/field.js +3 -3
  19. package/dom/fieldset.js +2 -2
  20. package/dom/form.js +1 -1
  21. package/dom/hover-popup.js +19 -4
  22. package/dom/index.js +26 -1
  23. package/dom/input.js +26 -0
  24. package/dom/label.js +18 -0
  25. package/dom/listbox.js +114 -0
  26. package/dom/menu.js +261 -0
  27. package/dom/menubar-context.js +3 -0
  28. package/dom/menubar.js +33 -0
  29. package/dom/message-scroller.js +56 -0
  30. package/dom/navigation-menu.js +147 -0
  31. package/dom/number-field.js +82 -0
  32. package/dom/otp.js +95 -0
  33. package/dom/pagination.js +74 -0
  34. package/dom/popover.js +22 -7
  35. package/dom/qr-code.js +48 -0
  36. package/dom/radio-group.js +6 -5
  37. package/dom/resizable.js +65 -0
  38. package/dom/runtime.js +59 -9
  39. package/dom/scroll-area.js +99 -0
  40. package/dom/select.js +91 -15
  41. package/dom/separator.js +1 -1
  42. package/dom/slider.js +11 -8
  43. package/dom/switch.js +5 -4
  44. package/dom/tabs.js +5 -5
  45. package/dom/testing.js +3 -0
  46. package/dom/toast.js +150 -0
  47. package/dom/toggle-group.js +37 -0
  48. package/dom/toggle.js +12 -4
  49. package/dom/toolbar-context.js +5 -0
  50. package/dom/toolbar.js +71 -0
  51. package/dom/value-bar.js +3 -3
  52. package/llms.txt +3202 -0
  53. package/package.json +236 -2
  54. package/server/accordion.js +9 -6
  55. package/server/agent.js +3 -0
  56. package/server/autocomplete.js +2 -0
  57. package/server/autosize.js +19 -0
  58. package/server/avatar.js +3 -3
  59. package/server/button.js +1 -1
  60. package/server/calendar.js +144 -0
  61. package/server/carousel.js +83 -0
  62. package/server/checkbox.js +5 -4
  63. package/server/collapsible.js +3 -3
  64. package/server/combobox.js +289 -0
  65. package/server/command.js +129 -0
  66. package/server/context-menu.js +2 -0
  67. package/server/date-field.js +90 -0
  68. package/server/date-picker.js +103 -0
  69. package/server/dialog.js +32 -1
  70. package/server/drawer.js +2 -0
  71. package/server/field.js +3 -3
  72. package/server/fieldset.js +2 -2
  73. package/server/form.js +1 -1
  74. package/server/hover-popup.js +19 -4
  75. package/server/index.js +26 -1
  76. package/server/input.js +26 -0
  77. package/server/label.js +18 -0
  78. package/server/listbox.js +114 -0
  79. package/server/menu.js +261 -0
  80. package/server/menubar-context.js +3 -0
  81. package/server/menubar.js +33 -0
  82. package/server/message-scroller.js +56 -0
  83. package/server/navigation-menu.js +147 -0
  84. package/server/number-field.js +81 -0
  85. package/server/otp.js +94 -0
  86. package/server/pagination.js +74 -0
  87. package/server/popover.js +22 -7
  88. package/server/qr-code.js +48 -0
  89. package/server/radio-group.js +6 -5
  90. package/server/resizable.js +65 -0
  91. package/server/runtime.js +58 -8
  92. package/server/scroll-area.js +99 -0
  93. package/server/select.js +91 -15
  94. package/server/separator.js +1 -1
  95. package/server/slider.js +11 -8
  96. package/server/switch.js +5 -4
  97. package/server/tabs.js +5 -5
  98. package/server/testing.js +3 -0
  99. package/server/toast.js +150 -0
  100. package/server/toggle-group.js +37 -0
  101. package/server/toggle.js +12 -4
  102. package/server/toolbar-context.js +5 -0
  103. package/server/toolbar.js +71 -0
  104. package/server/value-bar.js +3 -3
  105. package/skills/kirana-ui-primitives/SKILL.md +142 -0
  106. package/src/accordion.jsx +10 -7
  107. package/src/agent.js +3 -0
  108. package/src/autocomplete.jsx +2 -0
  109. package/src/autosize.jsx +8 -0
  110. package/src/avatar.jsx +3 -3
  111. package/src/button.jsx +1 -1
  112. package/src/calendar.jsx +108 -0
  113. package/src/carousel.jsx +51 -0
  114. package/src/checkbox.jsx +5 -3
  115. package/src/collapsible.jsx +3 -3
  116. package/src/combobox.jsx +187 -0
  117. package/src/command.jsx +81 -0
  118. package/src/context-menu.js +2 -0
  119. package/src/date-field.jsx +71 -0
  120. package/src/date-picker.jsx +72 -0
  121. package/src/dialog.jsx +27 -1
  122. package/src/drawer.js +2 -0
  123. package/src/field.jsx +3 -3
  124. package/src/fieldset.jsx +2 -2
  125. package/src/form.jsx +1 -1
  126. package/src/hover-popup.jsx +12 -4
  127. package/src/index.js +26 -1
  128. package/src/input.jsx +17 -0
  129. package/src/label.jsx +9 -0
  130. package/src/listbox.jsx +81 -0
  131. package/src/menu.jsx +164 -0
  132. package/src/menubar-context.js +3 -0
  133. package/src/menubar.jsx +21 -0
  134. package/src/message-scroller.jsx +27 -0
  135. package/src/navigation-menu.jsx +96 -0
  136. package/src/number-field.jsx +75 -0
  137. package/src/otp.jsx +73 -0
  138. package/src/pagination.jsx +60 -0
  139. package/src/popover.jsx +22 -4
  140. package/src/qr-code.jsx +25 -0
  141. package/src/radio-group.jsx +7 -5
  142. package/src/resizable.jsx +46 -0
  143. package/src/runtime.jsx +54 -9
  144. package/src/scroll-area.jsx +53 -0
  145. package/src/select.jsx +72 -14
  146. package/src/separator.jsx +1 -1
  147. package/src/slider.jsx +13 -8
  148. package/src/switch.jsx +5 -3
  149. package/src/tabs.jsx +6 -6
  150. package/src/testing.js +3 -0
  151. package/src/toast.jsx +86 -0
  152. package/src/toggle-group.jsx +32 -0
  153. package/src/toggle.jsx +9 -3
  154. package/src/toolbar-context.js +5 -0
  155. package/src/toolbar.jsx +43 -0
  156. package/src/value-bar.jsx +3 -3
  157. package/types/accordion.d.ts +21 -19
  158. package/types/agent.d.ts +1 -0
  159. package/types/alert-dialog.d.ts +1 -0
  160. package/types/autocomplete.d.ts +2 -0
  161. package/types/autosize.d.ts +11 -0
  162. package/types/avatar.d.ts +12 -5
  163. package/types/button.d.ts +4 -2
  164. package/types/calendar.d.ts +57 -0
  165. package/types/carousel.d.ts +34 -0
  166. package/types/checkbox.d.ts +10 -6
  167. package/types/collapsible.d.ts +11 -7
  168. package/types/combobox.d.ts +105 -0
  169. package/types/command.d.ts +55 -0
  170. package/types/context-menu.d.ts +2 -0
  171. package/types/date-field.d.ts +34 -0
  172. package/types/date-picker.d.ts +40 -0
  173. package/types/dialog.d.ts +52 -20
  174. package/types/direction.d.ts +1 -0
  175. package/types/drawer.d.ts +2 -0
  176. package/types/field.d.ts +19 -11
  177. package/types/fieldset.d.ts +8 -3
  178. package/types/form.d.ts +5 -2
  179. package/types/hover-card.d.ts +16 -7
  180. package/types/hover-popup.d.ts +23 -10
  181. package/types/index.d.ts +39 -2
  182. package/types/input.d.ts +13 -0
  183. package/types/label.d.ts +7 -0
  184. package/types/listbox.d.ts +36 -0
  185. package/types/menu.d.ts +105 -0
  186. package/types/menubar-context.d.ts +3 -0
  187. package/types/menubar.d.ts +12 -0
  188. package/types/message-scroller.d.ts +22 -0
  189. package/types/meter.d.ts +16 -7
  190. package/types/navigation-menu.d.ts +50 -0
  191. package/types/number-field.d.ts +22 -0
  192. package/types/otp.d.ts +39 -0
  193. package/types/pagination.d.ts +31 -0
  194. package/types/popover.d.ts +41 -13
  195. package/types/progress.d.ts +16 -7
  196. package/types/qr-code.d.ts +20 -0
  197. package/types/radio-group.d.ts +15 -16
  198. package/types/resizable.d.ts +29 -0
  199. package/types/runtime.d.ts +53 -11
  200. package/types/scroll-area.d.ts +28 -0
  201. package/types/select.d.ts +66 -33
  202. package/types/separator.d.ts +5 -3
  203. package/types/slider.d.ts +25 -13
  204. package/types/switch.d.ts +8 -4
  205. package/types/tabs.d.ts +20 -16
  206. package/types/testing.d.ts +1 -0
  207. package/types/toast.d.ts +57 -0
  208. package/types/toggle-group.d.ts +9 -0
  209. package/types/toggle.d.ts +6 -3
  210. package/types/toolbar-context.d.ts +6 -0
  211. package/types/toolbar.d.ts +28 -0
  212. package/types/tooltip.d.ts +16 -7
  213. package/types/value-bar.d.ts +21 -10
@@ -0,0 +1,147 @@
1
+ import { memo as _$memo } from "solid-js/web";
2
+ import { createComponent as _$createComponent } from "solid-js/web";
3
+ import { mergeProps as _$mergeProps } from "solid-js/web";
4
+ import { defined, within } from "@kirana-ui/core";
5
+ import { createNavigationMenu } from "@kirana-ui/core/navigation-menu";
6
+ import { Show, createContext, createUniqueId, onCleanup, onMount, splitProps, untrack, useContext } from "solid-js";
7
+ import { DirectionContext } from "./direction-context.js";
8
+ import { positioned } from "./popover.js";
9
+ import { Into, Part, Portal as BodyPortal, controller, fromSignal, toSignal } from "./runtime.js";
10
+ const Context = createContext();
11
+ const ItemContext = createContext();
12
+ function useNavigation() {
13
+ const made = useContext(Context);
14
+ if (!made) throw new Error("A NavigationMenu part must be inside <NavigationMenu.Root>");
15
+ return made;
16
+ }
17
+ function useItem() {
18
+ const item = useContext(ItemContext);
19
+ if (!item) throw new Error("A NavigationMenu part must be inside <NavigationMenu.Item>");
20
+ return item;
21
+ }
22
+ function Root(props) {
23
+ const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "delay", "closeDelay", "orientation", "id"]);
24
+ const generated = createUniqueId();
25
+ const direction = useContext(DirectionContext);
26
+ const made = controller(within(createNavigationMenu, {
27
+ direction
28
+ }), () => ({
29
+ id: local.id ?? generated,
30
+ value: local.value,
31
+ defaultValue: local.defaultValue,
32
+ delay: local.delay,
33
+ closeDelay: local.closeDelay,
34
+ orientation: local.orientation,
35
+ onValueChange: (value, details) => local.onValueChange?.(value, details)
36
+ }));
37
+ return _$createComponent(Context.Provider, {
38
+ value: made,
39
+ get children() {
40
+ return _$createComponent(Part, _$mergeProps({
41
+ get of() {
42
+ return made.root;
43
+ },
44
+ tag: "nav"
45
+ }, rest));
46
+ }
47
+ });
48
+ }
49
+ /** `value` tells this item from the others; an item that is given none makes its own. */
50
+ function Item(props) {
51
+ const [local, rest] = splitProps(props, ["value"]);
52
+ const made = useNavigation();
53
+ const generated = createUniqueId();
54
+ const value = untrack(() => local.value);
55
+ const item = made.item(value === undefined ? generated : value);
56
+ onMount(() => onCleanup(item.mount()));
57
+ return _$createComponent(ItemContext.Provider, {
58
+ value: item,
59
+ get children() {
60
+ return _$createComponent(Part, _$mergeProps({
61
+ get of() {
62
+ return made.itemPart;
63
+ },
64
+ tag: "li"
65
+ }, rest));
66
+ }
67
+ });
68
+ }
69
+ /** An item's content: drawn in `<NavigationMenu.Viewport>`, while it is shown. */
70
+ function Content(props) {
71
+ const item = useItem();
72
+ const mounted = fromSignal(item.mounted);
73
+ const viewport = fromSignal(useNavigation().viewportElement);
74
+ return _$createComponent(Show, {
75
+ get when() {
76
+ return _$memo(() => !!mounted())() ? viewport() : undefined;
77
+ },
78
+ children: target => _$createComponent(Into, {
79
+ get target() {
80
+ return target();
81
+ },
82
+ get children() {
83
+ return _$createComponent(Part, _$mergeProps({
84
+ get of() {
85
+ return item.content;
86
+ },
87
+ tag: "div"
88
+ }, props));
89
+ }
90
+ })
91
+ });
92
+ }
93
+ function Link(props) {
94
+ const [local, rest] = splitProps(props, ["active", "closeOnClick"]);
95
+ const options = toSignal(() => ({
96
+ ...local
97
+ }));
98
+ const part = useNavigation().link(() => defined(options.get()));
99
+ return _$createComponent(Part, _$mergeProps({
100
+ of: part,
101
+ tag: "a"
102
+ }, rest));
103
+ }
104
+ const Portal = props => _$createComponent(BodyPortal, {
105
+ get mounted() {
106
+ return useNavigation().mounted;
107
+ },
108
+ get children() {
109
+ return props.children;
110
+ }
111
+ });
112
+ function Positioner(props) {
113
+ const made = useNavigation();
114
+ return _$createComponent(Part, _$mergeProps({
115
+ get of() {
116
+ return made.positioner;
117
+ },
118
+ tag: "div"
119
+ }, () => positioned(props, made.positioning)));
120
+ }
121
+ const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
122
+ get of() {
123
+ return useNavigation()[name];
124
+ },
125
+ tag: tag
126
+ }, props));
127
+ const itemPart = (name, tag) => props => _$createComponent(Part, _$mergeProps({
128
+ get of() {
129
+ return useItem()[name];
130
+ },
131
+ tag: tag
132
+ }, props));
133
+ export const NavigationMenu = {
134
+ Root,
135
+ List: part("list", "ul"),
136
+ Item,
137
+ Trigger: itemPart("trigger", "button"),
138
+ Icon: itemPart("icon", "span"),
139
+ Content,
140
+ Link,
141
+ Portal,
142
+ Positioner,
143
+ Popup: part("popup", "div"),
144
+ Viewport: part("viewport", "div"),
145
+ Arrow: part("arrow", "div"),
146
+ Backdrop: part("backdrop", "div")
147
+ };
@@ -0,0 +1,82 @@
1
+ import { mergeProps as _$mergeProps } from "solid-js/web";
2
+ import { createComponent as _$createComponent } from "solid-js/web";
3
+ import { memo as _$memo } from "solid-js/web";
4
+ import { within } from "@kirana-ui/core";
5
+ import { createNumberField } from "@kirana-ui/core/number-field";
6
+ import { Show, createContext, createUniqueId, splitProps, useContext } from "solid-js";
7
+ import { FieldContext } from "./field-context.js";
8
+ import { Part, controller, fromSignal } from "./runtime.js";
9
+ const Context = createContext();
10
+ function useNumberField() {
11
+ const made = useContext(Context);
12
+ if (!made) throw new Error("A NumberField part must be inside <NumberField.Root>");
13
+ return made;
14
+ }
15
+ function Root(props) {
16
+ const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "onValueCommitted", "min", "max", "step", "smallStep", "largeStep", "snapOnStep", "allowWheelScrub", "format", "locale", "disabled", "readOnly", "required", "name", "form", "id", "children"]);
17
+ const generated = createUniqueId();
18
+ const made = controller(within(createNumberField, {
19
+ field: useContext(FieldContext)
20
+ }), () => ({
21
+ id: local.id ?? generated,
22
+ value: local.value,
23
+ defaultValue: local.defaultValue,
24
+ min: local.min,
25
+ max: local.max,
26
+ step: local.step,
27
+ smallStep: local.smallStep,
28
+ largeStep: local.largeStep,
29
+ snapOnStep: local.snapOnStep,
30
+ allowWheelScrub: local.allowWheelScrub,
31
+ format: local.format,
32
+ locale: local.locale,
33
+ disabled: local.disabled,
34
+ readOnly: local.readOnly,
35
+ required: local.required,
36
+ name: local.name,
37
+ form: local.form,
38
+ onValueChange: (value, details) => local.onValueChange?.(value, details),
39
+ onValueCommitted: (value, details) => local.onValueCommitted?.(value, details)
40
+ }));
41
+ const named = fromSignal(made.named);
42
+ return _$createComponent(Context.Provider, {
43
+ value: made,
44
+ get children() {
45
+ return _$createComponent(Part, _$mergeProps({
46
+ get of() {
47
+ return made.root;
48
+ },
49
+ tag: "div"
50
+ }, rest, {
51
+ get children() {
52
+ return [_$memo(() => local.children), _$createComponent(Show, {
53
+ get when() {
54
+ return named();
55
+ },
56
+ get children() {
57
+ return _$createComponent(Part, {
58
+ get of() {
59
+ return made.hidden;
60
+ },
61
+ tag: "input"
62
+ });
63
+ }
64
+ })];
65
+ }
66
+ }));
67
+ }
68
+ });
69
+ }
70
+ const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
71
+ get of() {
72
+ return useNumberField()[name];
73
+ },
74
+ tag: tag
75
+ }, props));
76
+ export const NumberField = {
77
+ Root,
78
+ Group: part("group", "div"),
79
+ Input: part("input", "input"),
80
+ Increment: part("increment", "button"),
81
+ Decrement: part("decrement", "button")
82
+ };
package/dom/otp.js ADDED
@@ -0,0 +1,95 @@
1
+ import { memo as _$memo } from "solid-js/web";
2
+ import { createComponent as _$createComponent } from "solid-js/web";
3
+ import { mergeProps as _$mergeProps } from "solid-js/web";
4
+ import { createOtp } from "@kirana-ui/core/otp";
5
+ import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
6
+ import { Part, controller, fromSignal } from "./runtime.js";
7
+ const Context = createContext();
8
+ const SlotContext = createContext();
9
+ function useOtp() {
10
+ const made = useContext(Context);
11
+ if (!made) throw new Error("An Otp part must be inside <Otp.Root>");
12
+ return made;
13
+ }
14
+ function Root(props) {
15
+ const [local, rest] = splitProps(props, ["length", "value", "defaultValue", "onValueChange", "onComplete", "mode", "disabled", "name", "form", "id"]);
16
+ const generated = createUniqueId();
17
+ const made = controller(createOtp, () => ({
18
+ id: local.id ?? generated,
19
+ length: local.length,
20
+ value: local.value,
21
+ defaultValue: local.defaultValue,
22
+ mode: local.mode,
23
+ disabled: local.disabled,
24
+ name: local.name,
25
+ form: local.form,
26
+ onValueChange: (value, details) => local.onValueChange?.(value, details),
27
+ onComplete: value => local.onComplete?.(value)
28
+ }));
29
+ return _$createComponent(Context.Provider, {
30
+ value: made,
31
+ get children() {
32
+ return _$createComponent(Part, _$mergeProps({
33
+ get of() {
34
+ return made.root;
35
+ },
36
+ tag: "div"
37
+ }, rest));
38
+ }
39
+ });
40
+ }
41
+ /** One cell: it shows its character, then whatever it is given (a caret). */
42
+ function Slot(props) {
43
+ const [local, rest] = splitProps(props, ["index", "children"]);
44
+ const slot = useOtp().slot(untrack(() => local.index));
45
+ const char = fromSignal(slot.char);
46
+ return _$createComponent(SlotContext.Provider, {
47
+ value: slot,
48
+ get children() {
49
+ return _$createComponent(Part, _$mergeProps({
50
+ get of() {
51
+ return slot.part;
52
+ },
53
+ tag: "div"
54
+ }, rest, {
55
+ get children() {
56
+ return [_$memo(() => char()), _$memo(() => local.children)];
57
+ }
58
+ }));
59
+ }
60
+ });
61
+ }
62
+ /** Drawn in its cell while the cell is the active one and empty. */
63
+ function Caret(props) {
64
+ const made = useOtp();
65
+ const slot = useContext(SlotContext);
66
+ if (!slot) throw new Error("An Otp.Caret must be inside <Otp.Slot>");
67
+ const shown = fromSignal(slot.caret);
68
+ return _$createComponent(Show, {
69
+ get when() {
70
+ return shown();
71
+ },
72
+ get children() {
73
+ return _$createComponent(Part, _$mergeProps({
74
+ get of() {
75
+ return made.caretPart;
76
+ },
77
+ tag: "div"
78
+ }, props));
79
+ }
80
+ });
81
+ }
82
+ const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
83
+ get of() {
84
+ return useOtp()[name];
85
+ },
86
+ tag: tag
87
+ }, props));
88
+ export const Otp = {
89
+ Root,
90
+ Input: part("input", "input"),
91
+ Group: part("group", "div"),
92
+ Slot,
93
+ Separator: part("separator", "div"),
94
+ Caret
95
+ };
@@ -0,0 +1,74 @@
1
+ import { createComponent as _$createComponent } from "solid-js/web";
2
+ import { mergeProps as _$mergeProps } from "solid-js/web";
3
+ import { createPagination } from "@kirana-ui/core/pagination";
4
+ import { For, createContext, createUniqueId, splitProps, useContext } from "solid-js";
5
+ import { Part, controller, fromSignal } from "./runtime.js";
6
+ const Context = createContext();
7
+ function usePagination() {
8
+ const made = useContext(Context);
9
+ if (!made) throw new Error("A Pagination part must be inside <Pagination.Root>");
10
+ return made;
11
+ }
12
+ function Root(props) {
13
+ const [local, rest] = splitProps(props, ["page", "defaultPage", "onPageChange", "count", "pageSize", "siblingCount", "boundaryCount", "disabled", "id"]);
14
+ const generated = createUniqueId();
15
+ const made = controller(createPagination, () => ({
16
+ id: local.id ?? generated,
17
+ page: local.page,
18
+ defaultPage: local.defaultPage,
19
+ count: local.count,
20
+ pageSize: local.pageSize,
21
+ siblingCount: local.siblingCount,
22
+ boundaryCount: local.boundaryCount,
23
+ disabled: local.disabled,
24
+ onPageChange: (page, details) => local.onPageChange?.(page, details)
25
+ }));
26
+ return _$createComponent(Context.Provider, {
27
+ value: made,
28
+ get children() {
29
+ return _$createComponent(Part, _$mergeProps({
30
+ get of() {
31
+ return made.root;
32
+ },
33
+ tag: "nav"
34
+ }, rest));
35
+ }
36
+ });
37
+ }
38
+ /** Draws its child once for each piece of the row: a page, or the mark for pages left out. */
39
+ function Items(props) {
40
+ const entries = fromSignal(usePagination().entries);
41
+ // By key: a page that stays in the row keeps its element.
42
+ const keys = () => entries().map(each => each.key);
43
+ const of = key => entries().find(each => each.key === key);
44
+ return _$createComponent(For, {
45
+ get each() {
46
+ return keys();
47
+ },
48
+ children: key => props.children(of(key))
49
+ });
50
+ }
51
+ function Item(props) {
52
+ const [local, rest] = splitProps(props, ["page"]);
53
+ const made = usePagination();
54
+ return _$createComponent(Part, _$mergeProps({
55
+ get of() {
56
+ return made.item(local.page);
57
+ },
58
+ tag: "button"
59
+ }, rest));
60
+ }
61
+ const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
62
+ get of() {
63
+ return usePagination()[name];
64
+ },
65
+ tag: tag
66
+ }, props));
67
+ export const Pagination = {
68
+ Root,
69
+ Items,
70
+ Item,
71
+ Ellipsis: part("ellipsis", "span"),
72
+ Previous: part("previous", "button"),
73
+ Next: part("next", "button")
74
+ };
package/dom/popover.js CHANGED
@@ -4,7 +4,13 @@ import { defined } from "@kirana-ui/core";
4
4
  import { createPopover } from "@kirana-ui/core/popover";
5
5
  import { createComputed, createContext, createUniqueId, splitProps, useContext } from "solid-js";
6
6
  import { Part, Portal as BodyPortal, controller } from "./runtime.js";
7
+ /**
8
+ * The popover its parts are inside. Exported for a component that is made of one (a date picker
9
+ * provides its own to the popover's parts).
10
+ */
7
11
  const Context = createContext();
12
+ /** For a component made of this one's parts: a date picker. */
13
+ export { Context as PopoverContext };
8
14
  function usePopover() {
9
15
  const made = useContext(Context);
10
16
  if (!made) throw new Error("A Popover part must be inside <Popover.Root>");
@@ -33,25 +39,34 @@ const Portal = props => _$createComponent(BodyPortal, {
33
39
  return props.children;
34
40
  }
35
41
  });
36
- /** A positioner's own props, written where its placement reads them, before its element attaches. */
42
+ /**
43
+ * A positioner's own props, written where its placement reads them, before its element
44
+ * attaches: the one place they are named. Gives back what is left, for the part's element.
45
+ */
37
46
  export function positioned(props, positioning) {
38
- const [local, rest] = splitProps(props, ["side", "align", "sideOffset", "alignOffset", "collisionPadding"]);
39
- createComputed(() => positioning.set(defined({
40
- ...local
41
- })));
47
+ const [local, rest] = splitProps(props, ["side", "align", "sideOffset", "alignOffset", "collisionPadding", "anchor"]);
48
+ createComputed(() => {
49
+ const anchor = local.anchor;
50
+ positioning.set(defined({
51
+ ...local,
52
+ // A function is asked here, so a change of the signal it reads is followed; and given
53
+ // whole while it has nothing, to be asked again as the popup is placed.
54
+ anchor: typeof anchor === "function" ? anchor() ?? anchor : anchor
55
+ }));
56
+ });
42
57
  return rest;
43
58
  }
44
59
  function Positioner(props) {
45
60
  const made = usePopover();
46
61
  return _$createComponent(Part, _$mergeProps({
47
- get part() {
62
+ get of() {
48
63
  return made.positioner;
49
64
  },
50
65
  tag: "div"
51
66
  }, () => positioned(props, made.positioning)));
52
67
  }
53
68
  const part = (name, tag) => props => _$createComponent(Part, _$mergeProps({
54
- get part() {
69
+ get of() {
55
70
  return usePopover()[name];
56
71
  },
57
72
  tag: tag
package/dom/qr-code.js ADDED
@@ -0,0 +1,48 @@
1
+ import { createComponent as _$createComponent } from "solid-js/web";
2
+ import { mergeProps as _$mergeProps } from "solid-js/web";
3
+ import { createQrCode } from "@kirana-ui/core/qr-code";
4
+ import { createContext, createUniqueId, splitProps, useContext } from "solid-js";
5
+ import { Part, controller } from "./runtime.js";
6
+ const Context = createContext();
7
+ function useQrCode() {
8
+ const made = useContext(Context);
9
+ if (!made) throw new Error("A QrCode part must be inside <QrCode.Root>");
10
+ return made;
11
+ }
12
+ function Root(props) {
13
+ const [local, rest] = splitProps(props, ["value", "correction", "id"]);
14
+ const generated = createUniqueId();
15
+ const made = controller(createQrCode, () => ({
16
+ id: local.id ?? generated,
17
+ value: local.value,
18
+ correction: local.correction
19
+ }));
20
+ return _$createComponent(Context.Provider, {
21
+ value: made,
22
+ get children() {
23
+ return _$createComponent(Part, _$mergeProps({
24
+ get of() {
25
+ return made.root;
26
+ },
27
+ tag: "div"
28
+ }, rest));
29
+ }
30
+ });
31
+ }
32
+ const Frame = props => _$createComponent(Part, _$mergeProps({
33
+ get of() {
34
+ return useQrCode().frame;
35
+ },
36
+ tag: "svg"
37
+ }, props));
38
+ const Pattern = props => _$createComponent(Part, _$mergeProps({
39
+ get of() {
40
+ return useQrCode().pattern;
41
+ },
42
+ tag: "path"
43
+ }, props));
44
+ export const QrCode = {
45
+ Root,
46
+ Frame,
47
+ Pattern
48
+ };
@@ -15,7 +15,7 @@ function useRadioGroup() {
15
15
  return made;
16
16
  }
17
17
  function Root(props) {
18
- const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "disabled", "readOnly", "required", "name", "id"]);
18
+ const [local, rest] = splitProps(props, ["value", "defaultValue", "onValueChange", "disabled", "readOnly", "required", "name", "form", "id"]);
19
19
  const generated = createUniqueId();
20
20
  const field = useContext(FieldContext);
21
21
  const made = controller(within(createRadioGroup, {
@@ -29,13 +29,14 @@ function Root(props) {
29
29
  readOnly: local.readOnly,
30
30
  required: local.required,
31
31
  name: local.name,
32
+ form: local.form,
32
33
  onValueChange: (value, details) => local.onValueChange?.(value, details)
33
34
  }));
34
35
  return _$createComponent(Context.Provider, {
35
36
  value: made,
36
37
  get children() {
37
38
  return _$createComponent(Part, _$mergeProps({
38
- get part() {
39
+ get of() {
39
40
  return made.root;
40
41
  },
41
42
  tag: "div"
@@ -56,14 +57,14 @@ function Item(props) {
56
57
  value: value,
57
58
  get children() {
58
59
  return _$createComponent(Part, _$mergeProps({
59
- get part() {
60
+ get of() {
60
61
  return group.item(value, read);
61
62
  },
62
63
  tag: "span"
63
64
  }, rest, {
64
65
  get children() {
65
66
  return [_$memo(() => local.children), _$createComponent(Part, {
66
- get part() {
67
+ get of() {
67
68
  return group.itemInput(value, read);
68
69
  },
69
70
  tag: "input"
@@ -85,7 +86,7 @@ function Indicator(props) {
85
86
  },
86
87
  get children() {
87
88
  return _$createComponent(Part, _$mergeProps({
88
- get part() {
89
+ get of() {
89
90
  return indicator.part;
90
91
  },
91
92
  tag: "span"
@@ -0,0 +1,65 @@
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 { createResizable } from "@kirana-ui/core/resizable";
5
+ import { createContext, createUniqueId, splitProps, useContext } from "solid-js";
6
+ import { DirectionContext } from "./direction-context.js";
7
+ import { Part, controller, toSignal } from "./runtime.js";
8
+ const Context = createContext();
9
+ function useResizable() {
10
+ const made = useContext(Context);
11
+ if (!made) throw new Error("A Resizable part must be inside <Resizable.Group>");
12
+ return made;
13
+ }
14
+ function Group(props) {
15
+ const [local, rest] = splitProps(props, ["orientation", "onSizesChange", "keyboardStep", "disabled", "id"]);
16
+ const generated = createUniqueId();
17
+ const direction = useContext(DirectionContext);
18
+ const made = controller(within(createResizable, {
19
+ direction
20
+ }), () => ({
21
+ id: local.id ?? generated,
22
+ orientation: local.orientation,
23
+ keyboardStep: local.keyboardStep,
24
+ disabled: local.disabled,
25
+ onSizesChange: (sizes, details) => local.onSizesChange?.(sizes, details)
26
+ }));
27
+ return _$createComponent(Context.Provider, {
28
+ value: made,
29
+ get children() {
30
+ return _$createComponent(Part, _$mergeProps({
31
+ get of() {
32
+ return made.group;
33
+ },
34
+ tag: "div"
35
+ }, rest));
36
+ }
37
+ });
38
+ }
39
+ function Panel(props) {
40
+ const [local, rest] = splitProps(props, ["defaultSize", "minSize", "maxSize"]);
41
+ const options = toSignal(() => ({
42
+ ...local
43
+ }));
44
+ const part = useResizable().panel(() => defined(options.get()));
45
+ return _$createComponent(Part, _$mergeProps({
46
+ of: part,
47
+ tag: "div"
48
+ }, rest));
49
+ }
50
+ function Handle(props) {
51
+ const [local, rest] = splitProps(props, ["disabled"]);
52
+ const options = toSignal(() => ({
53
+ disabled: local.disabled
54
+ }));
55
+ const part = useResizable().handle(() => defined(options.get()));
56
+ return _$createComponent(Part, _$mergeProps({
57
+ of: part,
58
+ tag: "div"
59
+ }, rest));
60
+ }
61
+ export const Resizable = {
62
+ Group,
63
+ Panel,
64
+ Handle
65
+ };