@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
@@ -0,0 +1,179 @@
1
+ import { within } from "@kirana-ui/core";
2
+ import { createAutocomplete } from "@kirana-ui/core/autocomplete";
3
+ import { createCombobox } from "@kirana-ui/core/combobox";
4
+ import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
5
+ import { FieldContext } from "./field-context.js";
6
+ import { positioned } from "./popover.jsx";
7
+ import { Part, Portal as BodyPortal, controller, fromSignal, toSignal } from "./runtime.jsx";
8
+ const Context = createContext();
9
+ const ItemContext = createContext();
10
+ function useCombobox() {
11
+ const made = useContext(Context);
12
+ if (!made)
13
+ throw new Error("A Combobox part must be inside <Combobox.Root>");
14
+ return made;
15
+ }
16
+ function Root(props) {
17
+ const generated = createUniqueId();
18
+ const field = useContext(FieldContext);
19
+ const made = controller(within(createCombobox, { field }), () => ({
20
+ id: props.id ?? generated,
21
+ value: props.value,
22
+ defaultValue: props.defaultValue,
23
+ inputValue: props.inputValue,
24
+ defaultInputValue: props.defaultInputValue,
25
+ open: props.open,
26
+ defaultOpen: props.defaultOpen,
27
+ disabled: props.disabled,
28
+ required: props.required,
29
+ multiple: props.multiple,
30
+ values: props.values,
31
+ defaultValues: props.defaultValues,
32
+ onValuesChange: (values, details) => props.onValuesChange?.(values, details),
33
+ inline: props.inline,
34
+ virtualized: props.virtualized,
35
+ name: props.name,
36
+ form: props.form,
37
+ items: props.items,
38
+ filter: props.filter,
39
+ onValueChange: (value, details) => props.onValueChange?.(value, details),
40
+ onInputValueChange: (value, details) => props.onInputValueChange?.(value, details),
41
+ onOpenChange: (open, details) => props.onOpenChange?.(open, details),
42
+ }));
43
+ const named = fromSignal(made.named);
44
+ return (<Context.Provider value={made}>
45
+ {props.children}
46
+ <Show when={named()}>
47
+ <Part part={made.hidden} tag="input"/>
48
+ </Show>
49
+ </Context.Provider>);
50
+ }
51
+ const Portal = (props) => (<BodyPortal mounted={useCombobox().mounted}>{props.children}</BodyPortal>);
52
+ function Positioner(props) {
53
+ const made = useCombobox();
54
+ return <Part part={made.positioner} tag="div" {...positioned(props, made.positioning)}/>;
55
+ }
56
+ /** `label` is what is filtered and what the input shows; the item's text when left out. */
57
+ function Item(props) {
58
+ const [local, rest] = splitProps(props, ["value", "disabled", "label", "id", "index"]);
59
+ // An item is its value for as long as it is in the page.
60
+ const value = untrack(() => local.value);
61
+ const generated = createUniqueId();
62
+ const options = toSignal(() => ({
63
+ disabled: local.disabled,
64
+ label: local.label,
65
+ index: local.index,
66
+ id: local.id ?? generated,
67
+ }));
68
+ const part = useCombobox().item(value, () => options.get(), useContext(GroupContext));
69
+ return (<ItemContext.Provider value={value}>
70
+ <Part part={part} tag="div" {...rest}/>
71
+ </ItemContext.Provider>);
72
+ }
73
+ function ItemIndicator(props) {
74
+ const [local, rest] = splitProps(props, ["keepMounted"]);
75
+ const made = useCombobox();
76
+ const value = useContext(ItemContext);
77
+ const selected = fromSignal(made.selected(value));
78
+ return (<Show when={selected() || local.keepMounted}>
79
+ <Part part={made.itemIndicator(value)} tag="span" {...rest}/>
80
+ </Show>);
81
+ }
82
+ /** A button that empties the input and the value. Drawn while there is something to clear. */
83
+ function Clear(props) {
84
+ const [local, rest] = splitProps(props, ["keepMounted"]);
85
+ const made = useCombobox();
86
+ const clearable = fromSignal(made.clearable);
87
+ return (<Show when={clearable() || local.keepMounted}>
88
+ <Part part={made.clear} tag="button" {...rest}/>
89
+ </Show>);
90
+ }
91
+ const ChipContext = createContext();
92
+ /** With `multiple`: one chosen value. Its `value` is what its remove button takes away. */
93
+ function Chip(props) {
94
+ const [local, rest] = splitProps(props, ["value"]);
95
+ // A chip is its value for as long as it is in the page.
96
+ const value = untrack(() => local.value);
97
+ return (<ChipContext.Provider value={value}>
98
+ <Part part={useCombobox().chip(value)} tag="span" {...rest}/>
99
+ </ChipContext.Provider>);
100
+ }
101
+ const ChipRemove = (props) => (<Part part={useCombobox().chipRemove(useContext(ChipContext))} tag="button" {...props}/>);
102
+ /** Drawn while no item is shown for what was typed. */
103
+ function Empty(props) {
104
+ const made = useCombobox();
105
+ const empty = fromSignal(made.empty);
106
+ return (<Show when={empty()}>
107
+ <Part part={made.emptyPart} tag="div" {...props}/>
108
+ </Show>);
109
+ }
110
+ const GroupContext = createContext();
111
+ /** Items that belong together, named by their `GroupLabel`. Hidden while none is shown. */
112
+ function Group(props) {
113
+ const [local, rest] = splitProps(props, ["id"]);
114
+ const generated = createUniqueId();
115
+ const group = useCombobox().group(untrack(() => local.id) ?? generated);
116
+ return (<GroupContext.Provider value={group}>
117
+ <Part part={group.root} tag="div" {...rest}/>
118
+ </GroupContext.Provider>);
119
+ }
120
+ /** 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
+ /** A combobox whose text is the value: the list only suggests. */
124
+ function AutocompleteRoot(props) {
125
+ const generated = createUniqueId();
126
+ const field = useContext(FieldContext);
127
+ const made = controller(within(createAutocomplete, { field }), () => ({
128
+ id: props.id ?? generated,
129
+ value: props.value,
130
+ defaultValue: props.defaultValue,
131
+ open: props.open,
132
+ defaultOpen: props.defaultOpen,
133
+ mode: props.mode,
134
+ filter: props.filter,
135
+ openOnInputClick: props.openOnInputClick,
136
+ disabled: props.disabled,
137
+ required: props.required,
138
+ name: props.name,
139
+ form: props.form,
140
+ virtualized: props.virtualized,
141
+ onValueChange: (value, details) => props.onValueChange?.(value, details),
142
+ onOpenChange: (open, details) => props.onOpenChange?.(open, details),
143
+ }));
144
+ return <Context.Provider value={made}>{props.children}</Context.Provider>;
145
+ }
146
+ export const Combobox = {
147
+ Root,
148
+ Input: part("input", "input"),
149
+ Trigger: part("trigger", "button"),
150
+ Clear,
151
+ /** With `multiple`: what holds the chips and the input. */
152
+ Chips: part("chips", "div"),
153
+ Chip,
154
+ ChipRemove,
155
+ Portal,
156
+ Positioner,
157
+ Popup: part("popup", "div"),
158
+ Group,
159
+ GroupLabel,
160
+ /** A line between groups. */
161
+ Separator: part("separator", "div"),
162
+ Item,
163
+ ItemIndicator,
164
+ Empty,
165
+ };
166
+ export const Autocomplete = {
167
+ Root: AutocompleteRoot,
168
+ Input: Combobox.Input,
169
+ Trigger: Combobox.Trigger,
170
+ Clear: Combobox.Clear,
171
+ Portal: Combobox.Portal,
172
+ Positioner: Combobox.Positioner,
173
+ Popup: Combobox.Popup,
174
+ Group: Combobox.Group,
175
+ GroupLabel: Combobox.GroupLabel,
176
+ Separator: Combobox.Separator,
177
+ Item: Combobox.Item,
178
+ Empty: Combobox.Empty,
179
+ };
@@ -0,0 +1,81 @@
1
+ import { createCommand } from "@kirana-ui/core/command";
2
+ import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
3
+ import { Part, controller, fromSignal, toSignal } from "./runtime.jsx";
4
+ const Context = createContext();
5
+ const GroupContext = createContext();
6
+ function useCommand() {
7
+ const made = useContext(Context);
8
+ if (!made)
9
+ throw new Error("A Command part must be inside <Command.Root>");
10
+ return made;
11
+ }
12
+ function Root(props) {
13
+ const [local, rest] = splitProps(props, [
14
+ "inputValue",
15
+ "defaultInputValue",
16
+ "onInputValueChange",
17
+ "onSelect",
18
+ "filter",
19
+ "loop",
20
+ "disabled",
21
+ "id",
22
+ ]);
23
+ const generated = createUniqueId();
24
+ const made = controller(createCommand, () => ({
25
+ id: local.id ?? generated,
26
+ inputValue: local.inputValue,
27
+ defaultInputValue: local.defaultInputValue,
28
+ filter: local.filter,
29
+ loop: local.loop,
30
+ disabled: local.disabled,
31
+ onInputValueChange: (value, details) => local.onInputValueChange?.(value, details),
32
+ onSelect: (value, details) => local.onSelect?.(value, details),
33
+ }));
34
+ return (<Context.Provider value={made}>
35
+ <Part part={made.root} tag="div" {...rest}/>
36
+ </Context.Provider>);
37
+ }
38
+ const Input = (props) => (<Part part={useCommand().input} tag="input" {...props}/>);
39
+ const List = (props) => <Part part={useCommand().list} tag="div" {...props}/>;
40
+ /** Drawn while no item is shown for what was typed. */
41
+ function Empty(props) {
42
+ const made = useCommand();
43
+ const empty = fromSignal(made.empty);
44
+ return (<Show when={empty()}>
45
+ <Part part={made.emptyPart} tag="div" {...props}/>
46
+ </Show>);
47
+ }
48
+ /** Items under a `<Command.GroupHeading>`. Hidden while none of them is shown. */
49
+ function Group(props) {
50
+ const [local, rest] = splitProps(props, ["id"]);
51
+ const generated = createUniqueId();
52
+ const group = useCommand().group(untrack(() => local.id) ?? generated);
53
+ return (<GroupContext.Provider value={group}>
54
+ <Part part={group.part} tag="div" {...rest}/>
55
+ </GroupContext.Provider>);
56
+ }
57
+ function GroupHeading(props) {
58
+ const part = useContext(GroupContext)?.heading ?? useCommand().heading;
59
+ return <Part part={part} tag="div" {...props}/>;
60
+ }
61
+ /** `label` is what is filtered, the item's text when left out; `keywords` are other words for it. */
62
+ function Item(props) {
63
+ const [local, rest] = splitProps(props, ["value", "disabled", "label", "keywords", "id"]);
64
+ const generated = createUniqueId();
65
+ const options = toSignal(() => ({
66
+ disabled: local.disabled,
67
+ label: local.label,
68
+ keywords: local.keywords,
69
+ id: local.id ?? generated,
70
+ }));
71
+ const part = useCommand().item(untrack(() => local.value), () => options.get(), useContext(GroupContext));
72
+ return <Part part={part} tag="div" {...rest}/>;
73
+ }
74
+ /** A line between groups: gone while something is typed, unless `alwaysRender`. */
75
+ function Separator(props) {
76
+ const [local, rest] = splitProps(props, ["alwaysRender"]);
77
+ const options = toSignal(() => ({ alwaysRender: local.alwaysRender }));
78
+ const part = useCommand().separator(() => options.get().alwaysRender);
79
+ return <Part part={part} tag="div" {...rest}/>;
80
+ }
81
+ export const Command = { Root, Input, List, Empty, Group, GroupHeading, Item, Separator };
@@ -0,0 +1,2 @@
1
+ // A context menu's parts are a menu's, but for its root and its trigger: an area, not a button.
2
+ export { ContextMenu } from "./menu.jsx";
@@ -0,0 +1,67 @@
1
+ import { within } from "@kirana-ui/core";
2
+ import { createDateField } from "@kirana-ui/core/date-field";
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 DateFieldContext };
9
+ function useDateField() {
10
+ const made = useContext(Context);
11
+ if (!made)
12
+ throw new Error("A DateField part must be inside <DateField.Root>");
13
+ return made;
14
+ }
15
+ function Root(props) {
16
+ const [local, rest] = splitProps(props, [
17
+ "value",
18
+ "defaultValue",
19
+ "onValueChange",
20
+ "locale",
21
+ "min",
22
+ "max",
23
+ "placeholders",
24
+ "disabled",
25
+ "readOnly",
26
+ "required",
27
+ "name",
28
+ "form",
29
+ "id",
30
+ ]);
31
+ const generated = createUniqueId();
32
+ const direction = useContext(DirectionContext);
33
+ const made = controller(within(createDateField, { direction }), () => ({
34
+ id: local.id ?? generated,
35
+ value: local.value,
36
+ defaultValue: local.defaultValue,
37
+ locale: local.locale,
38
+ min: local.min,
39
+ max: local.max,
40
+ placeholders: local.placeholders,
41
+ disabled: local.disabled,
42
+ readOnly: local.readOnly,
43
+ required: local.required,
44
+ name: local.name,
45
+ form: local.form,
46
+ onValueChange: (value, details) => local.onValueChange?.(value, details),
47
+ }));
48
+ return (<Context.Provider value={made}>
49
+ <Part part={made.root} tag="div" {...rest}/>
50
+ </Context.Provider>);
51
+ }
52
+ /** Draws its child once for each piece of the date, in the locale's order. */
53
+ function Segments(props) {
54
+ const segments = fromSignal(useDateField().segments);
55
+ return <For each={segments()}>{(segment) => props.children(segment)}</For>;
56
+ }
57
+ /** One piece: a part that is typed, or what stands between two. It writes its own text. */
58
+ function Segment(props) {
59
+ const [local, rest] = splitProps(props, ["segment"]);
60
+ const made = useDateField().segment(local.segment);
61
+ const shown = fromSignal(made.text);
62
+ return (<Part part={made.part} tag="span" {...rest}>
63
+ {shown()}
64
+ </Part>);
65
+ }
66
+ const Input = (props) => (<Part part={useDateField().input} tag="input" {...props}/>);
67
+ export const DateField = { Root, Segments, Segment, Input };
@@ -0,0 +1,72 @@
1
+ import { within } from "@kirana-ui/core";
2
+ import { createDatePicker } from "@kirana-ui/core/date-picker";
3
+ import { createContext, createUniqueId, useContext } from "solid-js";
4
+ import { Calendar, CalendarContext } from "./calendar.jsx";
5
+ import { DateField, DateFieldContext } from "./date-field.jsx";
6
+ import { DirectionContext } from "./direction-context.js";
7
+ import { Popover, PopoverContext } from "./popover.jsx";
8
+ import { Part, controller } from "./runtime.jsx";
9
+ const Context = createContext();
10
+ function useDatePicker() {
11
+ const made = useContext(Context);
12
+ if (!made)
13
+ throw new Error("A DatePicker part must be inside <DatePicker.Root>");
14
+ return made;
15
+ }
16
+ /** A date field, and a calendar in a popover, with one value between them. It draws nothing. */
17
+ function Root(props) {
18
+ const generated = createUniqueId();
19
+ const made = controller(within(createDatePicker, { direction: useContext(DirectionContext) }), () => ({
20
+ id: props.id ?? generated,
21
+ value: props.value,
22
+ defaultValue: props.defaultValue,
23
+ open: props.open,
24
+ defaultOpen: props.defaultOpen,
25
+ locale: props.locale,
26
+ min: props.min,
27
+ max: props.max,
28
+ isDateUnavailable: props.isDateUnavailable,
29
+ calendarSystem: props.calendarSystem,
30
+ fixedWeeks: props.fixedWeeks,
31
+ placeholders: props.placeholders,
32
+ disabled: props.disabled,
33
+ readOnly: props.readOnly,
34
+ required: props.required,
35
+ name: props.name,
36
+ form: props.form,
37
+ onValueChange: (value, details) => props.onValueChange?.(value, details),
38
+ onOpenChange: (open, details) => props.onOpenChange?.(open, details),
39
+ }));
40
+ return (<Context.Provider value={made}>
41
+ <DateFieldContext.Provider value={made.field}>
42
+ <PopoverContext.Provider value={made.popover}>
43
+ <CalendarContext.Provider value={made.calendar}>
44
+ {props.children}
45
+ </CalendarContext.Provider>
46
+ </PopoverContext.Provider>
47
+ </DateFieldContext.Provider>
48
+ </Context.Provider>);
49
+ }
50
+ export const DatePicker = {
51
+ Root,
52
+ /** The typed date: what holds its segments and its hidden input. */
53
+ Field: (props) => (<Part part={useDatePicker().field.root} tag="div" {...props}/>),
54
+ Segments: DateField.Segments,
55
+ Segment: DateField.Segment,
56
+ Input: DateField.Input,
57
+ Trigger: Popover.Trigger,
58
+ Portal: Popover.Portal,
59
+ Positioner: Popover.Positioner,
60
+ Popup: Popover.Popup,
61
+ /** The calendar: what holds its heading, its buttons and its grid. */
62
+ Calendar: (props) => (<Part part={useDatePicker().calendar.root} tag="div" {...props}/>),
63
+ Heading: Calendar.Heading,
64
+ Previous: Calendar.Previous,
65
+ Next: Calendar.Next,
66
+ Grid: Calendar.Grid,
67
+ Weekdays: Calendar.Weekdays,
68
+ HeadCell: Calendar.HeadCell,
69
+ Weeks: Calendar.Weeks,
70
+ Cell: Calendar.Cell,
71
+ Day: Calendar.Day,
72
+ };
package/src/dialog.jsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createAlertDialog } from "@kirana-ui/core/alert-dialog";
2
2
  import { createDialog } from "@kirana-ui/core/dialog";
3
+ import { createDrawer } from "@kirana-ui/core/drawer";
3
4
  import { createContext, createUniqueId, useContext } from "solid-js";
4
5
  import { Part, Portal as BodyPortal, controller } from "./runtime.jsx";
5
6
  const Context = createContext();
@@ -45,3 +46,22 @@ export const Dialog = {
45
46
  };
46
47
  /** A dialog that asks for an answer: a press outside it does not close it. Its parts are a dialog's. */
47
48
  export const AlertDialog = { ...Dialog, Root: AlertRoot };
49
+ function DrawerRoot(props) {
50
+ const generated = createUniqueId();
51
+ const made = controller(createDrawer, () => ({
52
+ id: props.id ?? generated,
53
+ open: props.open,
54
+ defaultOpen: props.defaultOpen,
55
+ modal: props.modal,
56
+ dismissible: props.dismissible,
57
+ swipeDirection: props.swipeDirection,
58
+ snapPoints: props.snapPoints,
59
+ snapPoint: props.snapPoint,
60
+ defaultSnapPoint: props.defaultSnapPoint,
61
+ onSnapPointChange: (snapPoint, details) => props.onSnapPointChange?.(snapPoint, details),
62
+ onOpenChange: (open, details) => props.onOpenChange?.(open, details),
63
+ }));
64
+ return <Context.Provider value={made}>{props.children}</Context.Provider>;
65
+ }
66
+ /** A dialog that comes from an edge and is dragged back to it. Its parts are a dialog's. */
67
+ export const Drawer = { ...Dialog, Root: DrawerRoot };
package/src/drawer.js ADDED
@@ -0,0 +1,2 @@
1
+ // A drawer is a dialog that is dragged: its parts are a dialog's.
2
+ export { Drawer } from "./dialog.jsx";
@@ -1,4 +1,5 @@
1
- import { createContext, createUniqueId, useContext } from "solid-js";
1
+ import { defined } from "@kirana-ui/core";
2
+ import { createComputed, createContext, createUniqueId, splitProps, useContext } from "solid-js";
2
3
  import { positioned } from "./popover.jsx";
3
4
  import { Part, Portal as BodyPortal, controller } from "./runtime.jsx";
4
5
  /** The parts of a popup the pointer opens: a tooltip's, a hover card's. */
@@ -29,11 +30,18 @@ export function hoverPopup(name, create, triggerTag) {
29
30
  return <Part part={made.positioner} tag="div" {...positioned(props, made.positioning)}/>;
30
31
  }
31
32
  const part = (key, tag) => (props) => (<Part part={use()[key]} tag={tag} {...props}/>);
33
+ /** `delay` and `closeDelay` here come before the root's. */
34
+ function Trigger(props) {
35
+ const [local, rest] = splitProps(props, ["delay", "closeDelay"]);
36
+ const made = use();
37
+ createComputed(() => made.timing.set(defined({ ...local })));
38
+ return <Part part={made.trigger} tag={triggerTag} {...rest}/>;
39
+ }
32
40
  return {
33
41
  Root,
34
42
  Portal,
35
43
  Positioner,
36
- Trigger: part("trigger", triggerTag),
44
+ Trigger,
37
45
  Popup: part("popup", "div"),
38
46
  Arrow: part("arrow", "div"),
39
47
  };
package/src/index.js CHANGED
@@ -1,8 +1,29 @@
1
1
  export { Accordion } from "./accordion.jsx";
2
2
  export { Checkbox } from "./checkbox.jsx";
3
3
  export { Collapsible } from "./collapsible.jsx";
4
- export { AlertDialog, Dialog } from "./dialog.jsx";
4
+ export { AlertDialog, Dialog, Drawer } from "./dialog.jsx";
5
+ export { MessageScroller } from "./message-scroller.jsx";
5
6
  export { HoverCard } from "./hover-card.jsx";
7
+ export { Combobox } from "./combobox.jsx";
8
+ export { Listbox } from "./listbox.jsx";
9
+ export { ContextMenu, Menu } from "./menu.jsx";
10
+ export { Menubar } from "./menubar.jsx";
11
+ export { NavigationMenu } from "./navigation-menu.jsx";
12
+ export { Otp } from "./otp.jsx";
13
+ export { DateField } from "./date-field.jsx";
14
+ export { Input } from "./input.jsx";
15
+ export { Label } from "./label.jsx";
16
+ export { Command } from "./command.jsx";
17
+ export { NumberField } from "./number-field.jsx";
18
+ export { Autocomplete } from "./autocomplete.jsx";
19
+ export { Pagination } from "./pagination.jsx";
20
+ export { DatePicker } from "./date-picker.jsx";
21
+ export { Calendar } from "./calendar.jsx";
22
+ export { QrCode } from "./qr-code.jsx";
23
+ export { Autosize } from "./autosize.jsx";
24
+ export { Carousel } from "./carousel.jsx";
25
+ export { Toast, createToaster } from "./toast.jsx";
26
+ export { Resizable } from "./resizable.jsx";
6
27
  export { Popover } from "./popover.jsx";
7
28
  export { RadioGroup } from "./radio-group.jsx";
8
29
  export { Select } from "./select.jsx";
@@ -15,8 +36,12 @@ export { Meter } from "./meter.jsx";
15
36
  export { Progress } from "./progress.jsx";
16
37
  export { Separator } from "./separator.jsx";
17
38
  export { Toggle } from "./toggle.jsx";
39
+ export { ToggleGroup } from "./toggle-group.jsx";
40
+ export { Toolbar } from "./toolbar.jsx";
41
+ export { ScrollArea } from "./scroll-area.jsx";
18
42
  export { Slider } from "./slider.jsx";
19
43
  export { Field } from "./field.jsx";
20
44
  export { Fieldset } from "./fieldset.jsx";
21
45
  export { Form } from "./form.jsx";
22
46
  export { DirectionProvider, useDirection } from "./direction.jsx";
47
+ export { PortalProvider } from "./runtime.jsx";
package/src/input.jsx ADDED
@@ -0,0 +1,17 @@
1
+ import { within } from "@kirana-ui/core";
2
+ import { createInput } from "@kirana-ui/core/input";
3
+ import { splitProps, useContext } from "solid-js";
4
+ import { FieldContext } from "./field-context.js";
5
+ import { Part, controller } from "./runtime.jsx";
6
+ /**
7
+ * An `<input>`; `as="textarea"` for a text area. It takes what an `<input>` takes, and inside
8
+ * a `<Field.Root>` it is the field's control.
9
+ */
10
+ export function Input(props) {
11
+ const [local, rest] = splitProps(props, ["disabled", "onValueChange"]);
12
+ const made = controller(within(createInput, { field: useContext(FieldContext) }), () => ({
13
+ disabled: local.disabled,
14
+ onValueChange: (value, details) => local.onValueChange?.(value, details),
15
+ }));
16
+ return <Part part={made.input} tag="input" {...rest}/>;
17
+ }
package/src/label.jsx ADDED
@@ -0,0 +1,9 @@
1
+ import { createLabel } from "@kirana-ui/core/label";
2
+ import { useContext } from "solid-js";
3
+ import { FieldContext } from "./field-context.js";
4
+ import { Part } from "./runtime.jsx";
5
+ /** A `<label>`. Inside a `<Field.Root>` it is the field's label. */
6
+ export function Label(props) {
7
+ const made = createLabel({ field: useContext(FieldContext) });
8
+ return <Part part={made.label} tag="label" {...props}/>;
9
+ }
@@ -0,0 +1,81 @@
1
+ import { defined } from "@kirana-ui/core";
2
+ import { createListbox } from "@kirana-ui/core/listbox";
3
+ import { Show, createContext, createUniqueId, splitProps, untrack, useContext } from "solid-js";
4
+ import { Part, controller, fromSignal, toSignal } from "./runtime.jsx";
5
+ const Context = createContext();
6
+ const ItemContext = createContext();
7
+ const GroupContext = createContext();
8
+ function useListbox() {
9
+ const made = useContext(Context);
10
+ if (!made)
11
+ throw new Error("A Listbox part must be inside <Listbox.Root>");
12
+ return made;
13
+ }
14
+ function Root(props) {
15
+ const [local, rest] = splitProps(props, [
16
+ "value",
17
+ "defaultValue",
18
+ "onValueChange",
19
+ "multiple",
20
+ "disabled",
21
+ "loop",
22
+ "name",
23
+ "form",
24
+ "virtualized",
25
+ "id",
26
+ ]);
27
+ const generated = createUniqueId();
28
+ const made = controller(createListbox, () => ({
29
+ id: local.id ?? generated,
30
+ value: local.value,
31
+ defaultValue: local.defaultValue,
32
+ multiple: local.multiple,
33
+ disabled: local.disabled,
34
+ loop: local.loop,
35
+ name: local.name,
36
+ form: local.form,
37
+ virtualized: local.virtualized,
38
+ onValueChange: (value, details) => local.onValueChange?.(value, details),
39
+ }));
40
+ return (<Context.Provider value={made}>
41
+ <Part part={made.root} tag="div" {...rest}/>
42
+ </Context.Provider>);
43
+ }
44
+ function Item(props) {
45
+ const [local, rest] = splitProps(props, ["value", "disabled", "label", "index"]);
46
+ // An item is its value for as long as it is in the page.
47
+ const value = untrack(() => local.value);
48
+ const options = toSignal(() => ({
49
+ disabled: local.disabled,
50
+ label: local.label,
51
+ index: local.index,
52
+ }));
53
+ const part = useListbox().item(value, () => defined(options.get()));
54
+ return (<ItemContext.Provider value={value}>
55
+ <Part part={part} tag="div" {...rest}/>
56
+ </ItemContext.Provider>);
57
+ }
58
+ function ItemIndicator(props) {
59
+ const [local, rest] = splitProps(props, ["keepMounted"]);
60
+ const made = useListbox();
61
+ const value = useContext(ItemContext);
62
+ const selected = fromSignal(made.selected(value));
63
+ return (<Show when={selected() || local.keepMounted}>
64
+ <Part part={made.indicator(value)} tag="span" {...rest}/>
65
+ </Show>);
66
+ }
67
+ function Group(props) {
68
+ const [local, rest] = splitProps(props, ["id"]);
69
+ const generated = createUniqueId();
70
+ const group = useListbox().group(untrack(() => local.id) ?? generated);
71
+ return (<GroupContext.Provider value={group}>
72
+ <Part part={group.root} tag="div" {...rest}/>
73
+ </GroupContext.Provider>);
74
+ }
75
+ function GroupLabel(props) {
76
+ const group = useContext(GroupContext);
77
+ if (!group)
78
+ throw new Error("A Listbox.GroupLabel must be inside <Listbox.Group>");
79
+ return <Part part={group.label} tag="div" {...props}/>;
80
+ }
81
+ export const Listbox = { Root, Item, ItemIndicator, Group, GroupLabel };