@proyecto-viviana/solidaria-components 0.2.9 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +39 -272
  2. package/dist/ActionBar.d.ts +21 -13
  3. package/dist/ActionBar.d.ts.map +1 -1
  4. package/dist/ActionGroup.d.ts +8 -8
  5. package/dist/ActionGroup.d.ts.map +1 -1
  6. package/dist/Alert.d.ts +5 -5
  7. package/dist/Alert.d.ts.map +1 -1
  8. package/dist/Autocomplete.d.ts +5 -5
  9. package/dist/Autocomplete.d.ts.map +1 -1
  10. package/dist/Breadcrumbs.d.ts +18 -7
  11. package/dist/Breadcrumbs.d.ts.map +1 -1
  12. package/dist/Button.d.ts +24 -5
  13. package/dist/Button.d.ts.map +1 -1
  14. package/dist/Calendar.d.ts +38 -7
  15. package/dist/Calendar.d.ts.map +1 -1
  16. package/dist/Checkbox.d.ts +32 -7
  17. package/dist/Checkbox.d.ts.map +1 -1
  18. package/dist/Collection.d.ts +19 -14
  19. package/dist/Collection.d.ts.map +1 -1
  20. package/dist/Color.d.ts +103 -14
  21. package/dist/Color.d.ts.map +1 -1
  22. package/dist/ColorEditor.d.ts +6 -6
  23. package/dist/ColorEditor.d.ts.map +1 -1
  24. package/dist/ComboBox.d.ts +85 -19
  25. package/dist/ComboBox.d.ts.map +1 -1
  26. package/dist/ContextualHelpTrigger.d.ts +2 -2
  27. package/dist/ContextualHelpTrigger.d.ts.map +1 -1
  28. package/dist/DateField.d.ts +8 -6
  29. package/dist/DateField.d.ts.map +1 -1
  30. package/dist/DatePicker.d.ts +53 -22
  31. package/dist/DatePicker.d.ts.map +1 -1
  32. package/dist/DateRangePickerContext.d.ts +30 -0
  33. package/dist/DateRangePickerContext.d.ts.map +1 -0
  34. package/dist/Dialog.d.ts +5 -5
  35. package/dist/Dialog.d.ts.map +1 -1
  36. package/dist/Disclosure.d.ts +23 -5
  37. package/dist/Disclosure.d.ts.map +1 -1
  38. package/dist/DragAndDrop.d.ts +6 -6
  39. package/dist/DragAndDrop.d.ts.map +1 -1
  40. package/dist/DragPreview.d.ts +2 -2
  41. package/dist/DragPreview.d.ts.map +1 -1
  42. package/dist/DropZone.d.ts +4 -4
  43. package/dist/DropZone.d.ts.map +1 -1
  44. package/dist/FieldError.d.ts +9 -5
  45. package/dist/FieldError.d.ts.map +1 -1
  46. package/dist/FileTrigger.d.ts +3 -3
  47. package/dist/FileTrigger.d.ts.map +1 -1
  48. package/dist/Focusable.d.ts +2 -2
  49. package/dist/Focusable.d.ts.map +1 -1
  50. package/dist/Form.d.ts +18 -4
  51. package/dist/Form.d.ts.map +1 -1
  52. package/dist/GridList.d.ts +32 -12
  53. package/dist/GridList.d.ts.map +1 -1
  54. package/dist/HiddenDateInput.d.ts +26 -0
  55. package/dist/HiddenDateInput.d.ts.map +1 -0
  56. package/dist/HiddenTimeInput.d.ts +25 -0
  57. package/dist/HiddenTimeInput.d.ts.map +1 -0
  58. package/dist/Icon.d.ts +5 -5
  59. package/dist/Icon.d.ts.map +1 -1
  60. package/dist/Keyboard.d.ts +1 -1
  61. package/dist/Landmark.d.ts +3 -3
  62. package/dist/Landmark.d.ts.map +1 -1
  63. package/dist/Link.d.ts +10 -4
  64. package/dist/Link.d.ts.map +1 -1
  65. package/dist/ListBox.d.ts +32 -12
  66. package/dist/ListBox.d.ts.map +1 -1
  67. package/dist/ListDropTargetDelegate.d.ts +6 -6
  68. package/dist/ListDropTargetDelegate.d.ts.map +1 -1
  69. package/dist/Menu.d.ts +65 -14
  70. package/dist/Menu.d.ts.map +1 -1
  71. package/dist/Meter.d.ts +3 -3
  72. package/dist/Meter.d.ts.map +1 -1
  73. package/dist/Modal.d.ts +5 -5
  74. package/dist/Modal.d.ts.map +1 -1
  75. package/dist/NumberField.d.ts +8 -12
  76. package/dist/NumberField.d.ts.map +1 -1
  77. package/dist/Popover.d.ts +28 -5
  78. package/dist/Popover.d.ts.map +1 -1
  79. package/dist/Pressable.d.ts +2 -2
  80. package/dist/Pressable.d.ts.map +1 -1
  81. package/dist/ProgressBar.d.ts +5 -3
  82. package/dist/ProgressBar.d.ts.map +1 -1
  83. package/dist/RadioGroup.d.ts +43 -9
  84. package/dist/RadioGroup.d.ts.map +1 -1
  85. package/dist/RangeCalendar.d.ts +34 -7
  86. package/dist/RangeCalendar.d.ts.map +1 -1
  87. package/dist/RouterProvider.d.ts +2 -2
  88. package/dist/RouterProvider.d.ts.map +1 -1
  89. package/dist/SearchField.d.ts +23 -20
  90. package/dist/SearchField.d.ts.map +1 -1
  91. package/dist/Select.d.ts +41 -11
  92. package/dist/Select.d.ts.map +1 -1
  93. package/dist/SelectionIndicator.d.ts +3 -3
  94. package/dist/SelectionIndicator.d.ts.map +1 -1
  95. package/dist/Separator.d.ts +9 -3
  96. package/dist/Separator.d.ts.map +1 -1
  97. package/dist/SharedElementTransition.d.ts +6 -4
  98. package/dist/SharedElementTransition.d.ts.map +1 -1
  99. package/dist/Slider.d.ts +12 -8
  100. package/dist/Slider.d.ts.map +1 -1
  101. package/dist/StepList.d.ts +90 -0
  102. package/dist/StepList.d.ts.map +1 -0
  103. package/dist/Switch.d.ts +11 -5
  104. package/dist/Switch.d.ts.map +1 -1
  105. package/dist/Table.d.ts +187 -23
  106. package/dist/Table.d.ts.map +1 -1
  107. package/dist/Tabs.d.ts +45 -9
  108. package/dist/Tabs.d.ts.map +1 -1
  109. package/dist/TagGroup.d.ts +12 -10
  110. package/dist/TagGroup.d.ts.map +1 -1
  111. package/dist/Text.d.ts +2 -2
  112. package/dist/TextField.d.ts +15 -11
  113. package/dist/TextField.d.ts.map +1 -1
  114. package/dist/TimeField.d.ts +6 -6
  115. package/dist/TimeField.d.ts.map +1 -1
  116. package/dist/Toast.d.ts +29 -14
  117. package/dist/Toast.d.ts.map +1 -1
  118. package/dist/ToggleButton.d.ts +11 -5
  119. package/dist/ToggleButton.d.ts.map +1 -1
  120. package/dist/ToggleButtonGroup.d.ts +7 -7
  121. package/dist/ToggleButtonGroup.d.ts.map +1 -1
  122. package/dist/Toolbar.d.ts +7 -3
  123. package/dist/Toolbar.d.ts.map +1 -1
  124. package/dist/Tooltip.d.ts +50 -8
  125. package/dist/Tooltip.d.ts.map +1 -1
  126. package/dist/Tree.d.ts +66 -17
  127. package/dist/Tree.d.ts.map +1 -1
  128. package/dist/Virtualizer.d.ts +12 -12
  129. package/dist/Virtualizer.d.ts.map +1 -1
  130. package/dist/VirtualizerLayouts.d.ts +2 -2
  131. package/dist/VirtualizerLayouts.d.ts.map +1 -1
  132. package/dist/VisuallyHidden.d.ts +1 -1
  133. package/dist/VisuallyHidden.d.ts.map +1 -1
  134. package/dist/contexts.d.ts +5 -1
  135. package/dist/contexts.d.ts.map +1 -1
  136. package/dist/index.d.ts +73 -71
  137. package/dist/index.d.ts.map +1 -1
  138. package/dist/index.js +23247 -18564
  139. package/dist/index.js.map +1 -1
  140. package/dist/index.jsx +18110 -0
  141. package/dist/index.jsx.map +1 -0
  142. package/dist/useDragAndDrop.d.ts +13 -13
  143. package/dist/useDragAndDrop.d.ts.map +1 -1
  144. package/dist/utils.d.ts +2 -2
  145. package/dist/utils.d.ts.map +1 -1
  146. package/dist/virtualizer/Layout.d.ts +1 -1
  147. package/dist/virtualizer/Layout.d.ts.map +1 -1
  148. package/package.json +31 -32
  149. package/src/ActionBar.tsx +75 -72
  150. package/src/ActionGroup.tsx +53 -61
  151. package/src/Alert.tsx +17 -42
  152. package/src/Autocomplete.tsx +39 -44
  153. package/src/Breadcrumbs.tsx +149 -80
  154. package/src/Button.tsx +267 -70
  155. package/src/Calendar.tsx +218 -138
  156. package/src/Checkbox.tsx +413 -121
  157. package/src/Collection.tsx +67 -58
  158. package/src/Color.tsx +803 -380
  159. package/src/ColorEditor.tsx +131 -149
  160. package/src/ComboBox.tsx +414 -249
  161. package/src/ContextualHelpTrigger.tsx +86 -74
  162. package/src/DateField.tsx +185 -91
  163. package/src/DatePicker.tsx +524 -213
  164. package/src/DateRangePickerContext.tsx +44 -0
  165. package/src/Dialog.tsx +156 -118
  166. package/src/Disclosure.tsx +127 -80
  167. package/src/DragAndDrop.tsx +60 -54
  168. package/src/DragPreview.tsx +13 -11
  169. package/src/DropZone.tsx +42 -22
  170. package/src/FieldError.tsx +45 -23
  171. package/src/FileTrigger.tsx +19 -19
  172. package/src/Focusable.tsx +21 -24
  173. package/src/Form.tsx +71 -16
  174. package/src/GridList.tsx +273 -197
  175. package/src/HiddenDateInput.tsx +153 -0
  176. package/src/HiddenTimeInput.tsx +133 -0
  177. package/src/Icon.tsx +22 -43
  178. package/src/Keyboard.tsx +3 -3
  179. package/src/Landmark.tsx +37 -63
  180. package/src/Link.tsx +125 -75
  181. package/src/ListBox.tsx +332 -233
  182. package/src/ListDropTargetDelegate.ts +81 -80
  183. package/src/Menu.tsx +1023 -274
  184. package/src/Meter.tsx +38 -56
  185. package/src/Modal.tsx +243 -175
  186. package/src/NumberField.tsx +139 -143
  187. package/src/Popover.tsx +386 -233
  188. package/src/Pressable.tsx +21 -21
  189. package/src/ProgressBar.tsx +48 -57
  190. package/src/RadioGroup.tsx +524 -122
  191. package/src/RangeCalendar.tsx +157 -90
  192. package/src/RouterProvider.tsx +30 -47
  193. package/src/SearchField.tsx +362 -143
  194. package/src/Select.tsx +656 -233
  195. package/src/SelectionIndicator.tsx +18 -15
  196. package/src/Separator.tsx +47 -49
  197. package/src/SharedElementTransition.tsx +103 -97
  198. package/src/Slider.tsx +138 -98
  199. package/src/StepList.tsx +272 -0
  200. package/src/Switch.tsx +93 -46
  201. package/src/Table.tsx +1308 -342
  202. package/src/Tabs.tsx +324 -103
  203. package/src/TagGroup.tsx +139 -126
  204. package/src/Text.tsx +3 -3
  205. package/src/TextField.tsx +389 -79
  206. package/src/TimeField.tsx +136 -76
  207. package/src/Toast.tsx +209 -157
  208. package/src/ToggleButton.tsx +47 -37
  209. package/src/ToggleButtonGroup.tsx +39 -34
  210. package/src/Toolbar.tsx +54 -69
  211. package/src/Tooltip.tsx +387 -119
  212. package/src/Tree.tsx +651 -368
  213. package/src/Virtualizer.tsx +208 -180
  214. package/src/VirtualizerLayouts.ts +45 -30
  215. package/src/VisuallyHidden.tsx +19 -19
  216. package/src/contexts.ts +29 -37
  217. package/src/index.ts +110 -195
  218. package/src/useDragAndDrop.ts +87 -71
  219. package/src/utils.tsx +40 -55
  220. package/src/virtualizer/Layout.ts +14 -22
  221. package/dist/index.ssr.js +0 -16996
  222. package/dist/index.ssr.js.map +0 -1
@@ -18,33 +18,29 @@ import {
18
18
  splitProps,
19
19
  useContext,
20
20
  For,
21
- } from 'solid-js';
21
+ } from "solid-js";
22
22
  import {
23
23
  createActionGroup,
24
24
  createActionGroupItem,
25
25
  type AriaActionGroupProps,
26
- } from '@proyecto-viviana/solidaria';
26
+ } from "@proyecto-viviana/solidaria";
27
27
  import {
28
28
  createListState,
29
29
  type ListState,
30
30
  type Key,
31
31
  type SelectionMode,
32
- } from '@proyecto-viviana/solid-stately';
32
+ } from "@proyecto-viviana/solid-stately";
33
33
  import {
34
34
  type ClassNameOrFunction,
35
35
  type StyleOrFunction,
36
36
  type SlotProps,
37
37
  useRenderProps,
38
38
  filterDOMProps,
39
- } from './utils';
40
-
41
- // ============================================
42
- // TYPES
43
- // ============================================
39
+ } from "./utils";
44
40
 
45
41
  export interface ActionGroupRenderProps {
46
42
  /** The orientation of the action group. */
47
- orientation: 'horizontal' | 'vertical';
43
+ orientation: "horizontal" | "vertical";
48
44
  /** Whether the entire group is disabled. */
49
45
  isDisabled: boolean;
50
46
  /** The selection mode. */
@@ -67,26 +63,25 @@ export interface ActionGroupItem {
67
63
  [key: string]: unknown;
68
64
  }
69
65
 
70
- export interface ActionGroupProps<T extends ActionGroupItem = ActionGroupItem>
71
- extends SlotProps {
66
+ export interface ActionGroupProps<T extends ActionGroupItem = ActionGroupItem> extends SlotProps {
72
67
  /** The items in the action group. */
73
68
  items: T[];
74
69
  /** The selection mode. @default 'none' */
75
70
  selectionMode?: SelectionMode;
76
71
  /** Orientation of the group. @default 'horizontal' */
77
- orientation?: 'horizontal' | 'vertical';
72
+ orientation?: "horizontal" | "vertical";
78
73
  /** Whether the entire group is disabled. */
79
74
  isDisabled?: boolean;
80
75
  /** Accessible label. */
81
- 'aria-label'?: string;
76
+ "aria-label"?: string;
82
77
  /** Labelled-by id. */
83
- 'aria-labelledby'?: string;
78
+ "aria-labelledby"?: string;
84
79
  /** Currently selected keys (controlled). */
85
80
  selectedKeys?: Iterable<Key>;
86
81
  /** Default selected keys (uncontrolled). */
87
82
  defaultSelectedKeys?: Iterable<Key>;
88
83
  /** Handler called when selection changes. */
89
- onSelectionChange?: (keys: 'all' | Set<Key>) => void;
84
+ onSelectionChange?: (keys: "all" | Set<Key>) => void;
90
85
  /** Handler called when an item action is triggered. */
91
86
  onAction?: (key: Key) => void;
92
87
  /** Keys of disabled items. */
@@ -99,10 +94,6 @@ export interface ActionGroupProps<T extends ActionGroupItem = ActionGroupItem>
99
94
  style?: StyleOrFunction<ActionGroupRenderProps>;
100
95
  }
101
96
 
102
- // ============================================
103
- // CONTEXT
104
- // ============================================
105
-
106
97
  export interface ActionGroupContextValue<T extends ActionGroupItem = ActionGroupItem> {
107
98
  state: ListState<T>;
108
99
  }
@@ -110,31 +101,27 @@ export interface ActionGroupContextValue<T extends ActionGroupItem = ActionGroup
110
101
  export const ActionGroupContext = createContext<ActionGroupContextValue | null>(null);
111
102
  export const ActionGroupStateContext = createContext<ListState<ActionGroupItem> | null>(null);
112
103
 
113
- // ============================================
114
- // ACTIONGROUP COMPONENT
115
- // ============================================
116
-
117
104
  export function ActionGroup<T extends ActionGroupItem = ActionGroupItem>(
118
- props: ActionGroupProps<T>
105
+ props: ActionGroupProps<T>,
119
106
  ): JSX.Element {
120
107
  const [local, ariaGroupProps, domProps] = splitProps(
121
108
  props,
122
109
  [
123
- 'items',
124
- 'selectionMode',
125
- 'orientation',
126
- 'isDisabled',
127
- 'selectedKeys',
128
- 'defaultSelectedKeys',
129
- 'onSelectionChange',
130
- 'onAction',
131
- 'disabledKeys',
132
- 'children',
133
- 'class',
134
- 'style',
135
- 'slot',
110
+ "items",
111
+ "selectionMode",
112
+ "orientation",
113
+ "isDisabled",
114
+ "selectedKeys",
115
+ "defaultSelectedKeys",
116
+ "onSelectionChange",
117
+ "onAction",
118
+ "disabledKeys",
119
+ "children",
120
+ "class",
121
+ "style",
122
+ "slot",
136
123
  ],
137
- ['aria-label', 'aria-labelledby']
124
+ ["aria-label", "aria-labelledby"],
138
125
  );
139
126
 
140
127
  const state = createListState<T>({
@@ -142,7 +129,7 @@ export function ActionGroup<T extends ActionGroupItem = ActionGroupItem>(
142
129
  return local.items;
143
130
  },
144
131
  get selectionMode() {
145
- return local.selectionMode ?? 'none';
132
+ return local.selectionMode ?? "none";
146
133
  },
147
134
  get selectedKeys() {
148
135
  return local.selectedKeys;
@@ -171,11 +158,11 @@ export function ActionGroup<T extends ActionGroupItem = ActionGroupItem>(
171
158
  get orientation() {
172
159
  return local.orientation;
173
160
  },
174
- get 'aria-label'() {
175
- return ariaGroupProps['aria-label'];
161
+ get "aria-label"() {
162
+ return ariaGroupProps["aria-label"];
176
163
  },
177
- get 'aria-labelledby'() {
178
- return ariaGroupProps['aria-labelledby'];
164
+ get "aria-labelledby"() {
165
+ return ariaGroupProps["aria-labelledby"];
179
166
  },
180
167
  get onAction() {
181
168
  return local.onAction;
@@ -184,23 +171,25 @@ export function ActionGroup<T extends ActionGroupItem = ActionGroupItem>(
184
171
 
185
172
  const { actionGroupProps } = createActionGroup(groupAriaProps, state as ListState<T>);
186
173
 
187
- const orientation = () => local.orientation ?? 'horizontal';
174
+ const orientation = () => local.orientation ?? "horizontal";
188
175
 
189
176
  const renderProps = useRenderProps(
190
177
  {
191
178
  children: undefined,
192
179
  class: local.class,
193
180
  style: local.style,
194
- defaultClassName: 'solidaria-ActionGroup',
181
+ defaultClassName: "solidaria-ActionGroup",
195
182
  },
196
183
  () => ({
197
184
  orientation: orientation(),
198
185
  isDisabled: !!local.isDisabled,
199
- selectionMode: (local.selectionMode ?? 'none') as SelectionMode,
200
- })
186
+ selectionMode: (local.selectionMode ?? "none") as SelectionMode,
187
+ }),
201
188
  );
202
189
 
203
- const filteredDOMProps = createMemo(() => filterDOMProps(domProps as Record<string, unknown>, { global: true }));
190
+ const filteredDOMProps = createMemo(() =>
191
+ filterDOMProps(domProps as Record<string, unknown>, { global: true }),
192
+ );
204
193
 
205
194
  return (
206
195
  <ActionGroupContext.Provider value={{ state: state as ListState<ActionGroupItem> }}>
@@ -223,7 +212,12 @@ export function ActionGroup<T extends ActionGroupItem = ActionGroupItem>(
223
212
  <ActionGroupItemWrapper
224
213
  item={item}
225
214
  state={state as ListState<ActionGroupItem>}
226
- renderChild={local.children as (item: ActionGroupItem, rp: ActionGroupItemRenderProps) => JSX.Element}
215
+ renderChild={
216
+ local.children as (
217
+ item: ActionGroupItem,
218
+ rp: ActionGroupItemRenderProps,
219
+ ) => JSX.Element
220
+ }
227
221
  />
228
222
  )}
229
223
  </For>
@@ -233,10 +227,6 @@ export function ActionGroup<T extends ActionGroupItem = ActionGroupItem>(
233
227
  );
234
228
  }
235
229
 
236
- // ============================================
237
- // INTERNAL ITEM WRAPPER
238
- // ============================================
239
-
240
230
  interface ActionGroupItemWrapperProps {
241
231
  item: ActionGroupItem;
242
232
  state: ListState<ActionGroupItem>;
@@ -245,14 +235,18 @@ interface ActionGroupItemWrapperProps {
245
235
 
246
236
  function ActionGroupItemWrapper(props: ActionGroupItemWrapperProps): JSX.Element {
247
237
  const { buttonProps } = createActionGroupItem(
248
- { get key() { return props.item.id; } },
249
- props.state
238
+ {
239
+ get key() {
240
+ return props.item.id;
241
+ },
242
+ },
243
+ props.state,
250
244
  );
251
245
 
252
246
  const isFocused = () => props.state.focusedKey() === props.item.id;
253
247
  const isSelected = () => {
254
248
  const keys = props.state.selectedKeys();
255
- return keys === 'all' || (keys instanceof Set && keys.has(props.item.id));
249
+ return keys === "all" || (keys instanceof Set && keys.has(props.item.id));
256
250
  };
257
251
  const isDisabled = () => props.state.isDisabled(props.item.id);
258
252
 
@@ -262,7 +256,9 @@ function ActionGroupItemWrapper(props: ActionGroupItemWrapperProps): JSX.Element
262
256
  isFocused: isFocused(),
263
257
  }));
264
258
 
265
- const { ref: _ref, ...restButtonProps } = buttonProps as Record<string, unknown> & { ref?: unknown };
259
+ const { ref: _ref, ...restButtonProps } = buttonProps as Record<string, unknown> & {
260
+ ref?: unknown;
261
+ };
266
262
 
267
263
  return (
268
264
  <button
@@ -276,10 +272,6 @@ function ActionGroupItemWrapper(props: ActionGroupItemWrapperProps): JSX.Element
276
272
  );
277
273
  }
278
274
 
279
- // ============================================
280
- // HOOKS
281
- // ============================================
282
-
283
275
  export function useActionGroupContext(): ActionGroupContextValue | null {
284
276
  return useContext(ActionGroupContext);
285
277
  }
package/src/Alert.tsx CHANGED
@@ -6,27 +6,17 @@
6
6
  * for styling/composition only.
7
7
  */
8
8
 
9
- import {
10
- type JSX,
11
- createContext,
12
- createMemo,
13
- splitProps,
14
- useContext,
15
- } from 'solid-js';
9
+ import { type JSX, createContext, createMemo, splitProps, useContext } from "solid-js";
16
10
  import {
17
11
  type RenderChildren,
18
12
  type ClassNameOrFunction,
19
13
  type StyleOrFunction,
20
14
  type SlotProps,
21
15
  filterDOMProps,
22
- } from './utils';
23
- import { Button, type ButtonProps } from './Button';
24
-
25
- // ============================================
26
- // TYPES
27
- // ============================================
16
+ } from "./utils";
17
+ import { Button, type ButtonProps } from "./Button";
28
18
 
29
- export type AlertVariant = 'info' | 'success' | 'warning' | 'error';
19
+ export type AlertVariant = "info" | "success" | "warning" | "error";
30
20
 
31
21
  export interface AlertRenderProps {
32
22
  /** The variant of the alert. */
@@ -52,10 +42,6 @@ export interface AlertProps extends SlotProps {
52
42
  id?: string;
53
43
  }
54
44
 
55
- // ============================================
56
- // CONTEXT
57
- // ============================================
58
-
59
45
  export interface AlertContextValue {
60
46
  variant: () => AlertVariant;
61
47
  isDismissible: () => boolean;
@@ -64,10 +50,6 @@ export interface AlertContextValue {
64
50
 
65
51
  export const AlertContext = createContext<AlertContextValue | null>(null);
66
52
 
67
- // ============================================
68
- // ALERT COMPONENT
69
- // ============================================
70
-
71
53
  /**
72
54
  * An alert displays a brief, important message in a way that
73
55
  * attracts the user's attention without interrupting their task.
@@ -84,19 +66,18 @@ export const AlertContext = createContext<AlertContextValue | null>(null);
84
66
  */
85
67
  export function Alert(props: AlertProps): JSX.Element {
86
68
  const [local, rest] = splitProps(props, [
87
- 'children',
88
- 'class',
89
- 'style',
90
- 'slot',
91
- 'variant',
92
- 'isDismissible',
93
- 'onDismiss',
69
+ "children",
70
+ "class",
71
+ "style",
72
+ "slot",
73
+ "variant",
74
+ "isDismissible",
75
+ "onDismiss",
94
76
  ]);
95
77
 
96
- const variant = () => local.variant ?? 'info';
78
+ const variant = () => local.variant ?? "info";
97
79
  const isDismissible = () => !!local.isDismissible;
98
80
 
99
- // Render props values
100
81
  const renderValues = createMemo<AlertRenderProps>(() => ({
101
82
  variant: variant(),
102
83
  isDismissible: isDismissible(),
@@ -108,18 +89,16 @@ export function Alert(props: AlertProps): JSX.Element {
108
89
  // is in scope, breaking context for sub-components.
109
90
  const computedClass = createMemo(() => {
110
91
  const cls = local.class;
111
- return typeof cls === 'function' ? cls(renderValues()) : cls ?? 'solidaria-Alert';
92
+ return typeof cls === "function" ? cls(renderValues()) : (cls ?? "solidaria-Alert");
112
93
  });
113
94
 
114
95
  const computedStyle = createMemo(() => {
115
96
  const s = local.style;
116
- return typeof s === 'function' ? s(renderValues()) : s;
97
+ return typeof s === "function" ? s(renderValues()) : s;
117
98
  });
118
99
 
119
- // Filter DOM props
120
100
  const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
121
101
 
122
- // Context value for sub-components
123
102
  const contextValue: AlertContextValue = {
124
103
  variant,
125
104
  isDismissible,
@@ -138,7 +117,7 @@ export function Alert(props: AlertProps): JSX.Element {
138
117
  data-variant={variant()}
139
118
  data-dismissible={isDismissible() || undefined}
140
119
  >
141
- {typeof local.children === 'function'
120
+ {typeof local.children === "function"
142
121
  ? (local.children as (props: AlertRenderProps) => JSX.Element)(renderValues())
143
122
  : local.children}
144
123
  </div>
@@ -146,11 +125,7 @@ export function Alert(props: AlertProps): JSX.Element {
146
125
  );
147
126
  }
148
127
 
149
- // ============================================
150
- // ALERT DISMISS BUTTON
151
- // ============================================
152
-
153
- export interface AlertDismissButtonProps extends Omit<ButtonProps, 'onPress'> {}
128
+ export interface AlertDismissButtonProps extends Omit<ButtonProps, "onPress"> {}
154
129
 
155
130
  /**
156
131
  * A dismiss button for use inside an Alert.
@@ -170,7 +145,7 @@ export function AlertDismissButton(props: AlertDismissButtonProps): JSX.Element
170
145
  return (
171
146
  <Button
172
147
  {...props}
173
- aria-label={props['aria-label'] ?? 'Dismiss'}
148
+ aria-label={props["aria-label"] ?? "Dismiss"}
174
149
  onPress={() => context?.onDismiss?.()}
175
150
  />
176
151
  );
@@ -15,62 +15,56 @@ import {
15
15
  createMemo,
16
16
  splitProps,
17
17
  createSignal,
18
- } from 'solid-js'
18
+ } from "solid-js";
19
19
  import {
20
20
  createAutocomplete,
21
21
  type AriaAutocompleteOptions,
22
22
  type AutocompleteInputProps,
23
23
  type CollectionOptions,
24
- } from '@proyecto-viviana/solidaria'
24
+ } from "@proyecto-viviana/solidaria";
25
25
  import {
26
26
  createAutocompleteState,
27
27
  type AutocompleteState,
28
28
  type AutocompleteStateOptions,
29
- } from '@proyecto-viviana/solid-stately'
30
- import { type SlotProps } from './utils'
31
-
32
- // ============================================
33
- // TYPES
34
- // ============================================
29
+ } from "@proyecto-viviana/solid-stately";
30
+ import { type SlotProps } from "./utils";
35
31
 
36
32
  export interface AutocompleteProps<T = unknown>
37
- extends Omit<AutocompleteStateOptions, 'children'>,
38
- Omit<AriaAutocompleteOptions<T>, 'inputRef' | 'collectionRef'>,
33
+ extends
34
+ Omit<AutocompleteStateOptions, "children">,
35
+ Omit<AriaAutocompleteOptions<T>, "inputRef" | "collectionRef">,
39
36
  ParentProps,
40
37
  SlotProps {}
41
38
 
42
- // ============================================
43
- // CONTEXTS
44
- // ============================================
45
-
46
39
  export interface AutocompleteContextValue {
47
- inputProps: AutocompleteInputProps
48
- inputRef: (el: HTMLInputElement) => void
40
+ inputProps: AutocompleteInputProps;
41
+ inputRef: (el: HTMLInputElement) => void;
49
42
  }
50
43
 
51
44
  export interface AutocompleteCollectionContextValue {
52
- collectionProps: CollectionOptions
53
- collectionRef: (el: HTMLElement) => void
54
- filter?: (textValue: string) => boolean
45
+ collectionProps: CollectionOptions;
46
+ collectionRef: (el: HTMLElement) => void;
47
+ filter?: (textValue: string) => boolean;
55
48
  }
56
49
 
57
- export const AutocompleteContext = createContext<AutocompleteContextValue | null>(null)
58
- export const AutocompleteStateContext = createContext<AutocompleteState | null>(null)
59
- export const AutocompleteCollectionContext = createContext<AutocompleteCollectionContextValue | null>(null)
50
+ export const AutocompleteContext = createContext<AutocompleteContextValue | null>(null);
51
+ export const AutocompleteStateContext = createContext<AutocompleteState | null>(null);
52
+ export const AutocompleteCollectionContext =
53
+ createContext<AutocompleteCollectionContextValue | null>(null);
60
54
 
61
55
  /**
62
56
  * Hook to consume autocomplete input context.
63
57
  * Use this in your input component (TextField/SearchField) to get the autocomplete props.
64
58
  */
65
59
  export function useAutocompleteInput() {
66
- return useContext(AutocompleteContext)
60
+ return useContext(AutocompleteContext);
67
61
  }
68
62
 
69
63
  /**
70
64
  * Hook to consume autocomplete state context.
71
65
  */
72
66
  export function useAutocompleteState() {
73
- return useContext(AutocompleteStateContext)
67
+ return useContext(AutocompleteStateContext);
74
68
  }
75
69
 
76
70
  /**
@@ -78,13 +72,9 @@ export function useAutocompleteState() {
78
72
  * Use this in your collection component (ListBox/Menu) to get the autocomplete props.
79
73
  */
80
74
  export function useAutocompleteCollection() {
81
- return useContext(AutocompleteCollectionContext)
75
+ return useContext(AutocompleteCollectionContext);
82
76
  }
83
77
 
84
- // ============================================
85
- // AUTOCOMPLETE COMPONENT
86
- // ============================================
87
-
88
78
  /**
89
79
  * An autocomplete allows users to search or filter a list of suggestions.
90
80
  * It wraps a text input and a collection component (ListBox or Menu),
@@ -124,16 +114,21 @@ export function useAutocompleteCollection() {
124
114
  export function Autocomplete<T = unknown>(props: AutocompleteProps<T>): JSX.Element {
125
115
  const [stateProps, ariaProps, local] = splitProps(
126
116
  props,
127
- ['inputValue', 'defaultInputValue', 'onInputChange'],
128
- ['filter', 'disableAutoFocusFirst', 'disableVirtualFocus', 'collectionId', 'collectionAriaLabel']
129
- )
130
-
131
- // Create state
132
- const state = createAutocompleteState(stateProps)
117
+ ["inputValue", "defaultInputValue", "onInputChange"],
118
+ [
119
+ "filter",
120
+ "disableAutoFocusFirst",
121
+ "disableVirtualFocus",
122
+ "collectionId",
123
+ "collectionAriaLabel",
124
+ ],
125
+ );
126
+
127
+ const state = createAutocompleteState(stateProps);
133
128
 
134
129
  // Create refs
135
- let inputRef: HTMLInputElement | undefined
136
- let collectionRef: HTMLElement | undefined
130
+ let inputRef: HTMLInputElement | undefined;
131
+ let collectionRef: HTMLElement | undefined;
137
132
 
138
133
  // Create autocomplete aria
139
134
  const autocomplete = createAutocomplete<T>(
@@ -142,25 +137,25 @@ export function Autocomplete<T = unknown>(props: AutocompleteProps<T>): JSX.Elem
142
137
  inputRef: () => inputRef,
143
138
  collectionRef: () => collectionRef,
144
139
  },
145
- state
146
- )
140
+ state,
141
+ );
147
142
 
148
143
  // Input context value
149
144
  const inputContextValue = createMemo<AutocompleteContextValue>(() => ({
150
145
  inputProps: autocomplete.inputProps,
151
146
  inputRef: (el: HTMLInputElement) => {
152
- inputRef = el
147
+ inputRef = el;
153
148
  },
154
- }))
149
+ }));
155
150
 
156
151
  // Collection context value
157
152
  const collectionContextValue = createMemo<AutocompleteCollectionContextValue>(() => ({
158
153
  collectionProps: autocomplete.collectionProps,
159
154
  collectionRef: (el: HTMLElement) => {
160
- collectionRef = el
155
+ collectionRef = el;
161
156
  },
162
157
  filter: autocomplete.filter,
163
- }))
158
+ }));
164
159
 
165
160
  return (
166
161
  <AutocompleteStateContext.Provider value={state}>
@@ -170,5 +165,5 @@ export function Autocomplete<T = unknown>(props: AutocompleteProps<T>): JSX.Elem
170
165
  </AutocompleteCollectionContext.Provider>
171
166
  </AutocompleteContext.Provider>
172
167
  </AutocompleteStateContext.Provider>
173
- )
168
+ );
174
169
  }