@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
@@ -5,9 +5,9 @@
5
5
  * state and aria primitives.
6
6
  */
7
7
 
8
- import type { Accessor, JSX } from 'solid-js';
9
- import { DragPreview } from './DragPreview';
10
- import { ListDropTargetDelegate } from './ListDropTargetDelegate';
8
+ import type { Accessor, JSX } from "solid-js";
9
+ import { DragPreview } from "./DragPreview";
10
+ import { ListDropTargetDelegate } from "./ListDropTargetDelegate";
11
11
  import {
12
12
  createDraggableCollection,
13
13
  createDraggableItem,
@@ -24,7 +24,7 @@ import {
24
24
  type DroppableItemOptions,
25
25
  type DroppableItemAria,
26
26
  type DropTargetDelegate as AriaDropTargetDelegate,
27
- } from '@proyecto-viviana/solidaria';
27
+ } from "@proyecto-viviana/solidaria";
28
28
  import {
29
29
  createDraggableCollectionState,
30
30
  createDroppableCollectionState,
@@ -37,42 +37,51 @@ import {
37
37
  type DroppableCollectionProps,
38
38
  type DroppableCollectionState,
39
39
  type DroppableCollectionStateOptions,
40
- } from '@proyecto-viviana/solid-stately';
40
+ } from "@proyecto-viviana/solid-stately";
41
41
 
42
- interface DraggableCollectionStateOpts<T = object>
43
- extends Omit<DraggableCollectionStateOptions<T>, 'getItems'> {
42
+ interface DraggableCollectionStateOpts<T = object> extends Omit<
43
+ DraggableCollectionStateOptions<T>,
44
+ "getItems"
45
+ > {
44
46
  items?: T[];
45
47
  }
46
48
 
47
49
  interface DragHooks<T = object> {
48
- useDraggableCollectionState?: (props: DraggableCollectionStateOpts<T>) => DraggableCollectionState;
50
+ useDraggableCollectionState?: (
51
+ props: DraggableCollectionStateOpts<T>,
52
+ ) => DraggableCollectionState;
49
53
  useDraggableCollection?: (
50
- props: Omit<DraggableCollectionOptions, 'ref'>,
54
+ props: Omit<DraggableCollectionOptions, "ref">,
51
55
  state: DraggableCollectionState,
52
- ref: Accessor<HTMLElement | null>
56
+ ref: Accessor<HTMLElement | null>,
53
57
  ) => DraggableCollectionAria;
54
- useDraggableItem?: (props: DraggableItemOptions, state: DraggableCollectionState) => DraggableItemAria;
58
+ useDraggableItem?: (
59
+ props: DraggableItemOptions,
60
+ state: DraggableCollectionState,
61
+ ) => DraggableItemAria;
55
62
  DragPreview?: typeof DragPreview;
56
- renderDragPreview?: DragAndDropOptions<T>['renderDragPreview'];
63
+ renderDragPreview?: DragAndDropOptions<T>["renderDragPreview"];
57
64
  isVirtualDragging?: () => boolean;
58
65
  }
59
66
 
60
67
  interface DropHooks {
61
- useDroppableCollectionState?: (props: DroppableCollectionStateOptions) => DroppableCollectionState;
68
+ useDroppableCollectionState?: (
69
+ props: DroppableCollectionStateOptions,
70
+ ) => DroppableCollectionState;
62
71
  useDroppableCollection?: (
63
- props: Omit<DroppableCollectionOptions, 'ref'>,
72
+ props: Omit<DroppableCollectionOptions, "ref">,
64
73
  state: DroppableCollectionState,
65
- ref: Accessor<HTMLElement | null>
74
+ ref: Accessor<HTMLElement | null>,
66
75
  ) => DroppableCollectionAria;
67
76
  useDroppableItem?: (
68
- options: Omit<DroppableItemOptions, 'ref'>,
77
+ options: Omit<DroppableItemOptions, "ref">,
69
78
  state: DroppableCollectionState,
70
- ref: Accessor<HTMLElement | null>
79
+ ref: Accessor<HTMLElement | null>,
71
80
  ) => DroppableItemAria;
72
81
  useDropIndicator?: (
73
82
  props: { target: DropTarget },
74
83
  state: DroppableCollectionState,
75
- ref: Accessor<HTMLElement | null>
84
+ ref: Accessor<HTMLElement | null>,
76
85
  ) => {
77
86
  dropIndicatorProps: JSX.HTMLAttributes<HTMLElement>;
78
87
  isDropTarget: boolean;
@@ -91,16 +100,15 @@ export interface DragAndDrop<T = object> {
91
100
  }
92
101
 
93
102
  export interface DragAndDropOptions<T = object>
94
- extends Partial<Omit<DraggableCollectionProps<T>, 'preview'>>,
95
- Partial<DroppableCollectionProps> {
103
+ extends Partial<Omit<DraggableCollectionProps<T>, "preview">>, Partial<DroppableCollectionProps> {
96
104
  /**
97
105
  * Optional keyboard delegate forwarded to the collection droppable hook.
98
106
  */
99
- keyboardDelegate?: DroppableCollectionOptions['keyboardDelegate'];
107
+ keyboardDelegate?: DroppableCollectionOptions["keyboardDelegate"];
100
108
  /**
101
109
  * Optional keydown handler composed with collection droppable keyboard behavior.
102
110
  */
103
- onKeyDown?: DroppableCollectionOptions['onKeyDown'];
111
+ onKeyDown?: DroppableCollectionOptions["onKeyDown"];
104
112
  /**
105
113
  * A function that returns the items being dragged.
106
114
  * If omitted, draggable hooks are not added.
@@ -109,7 +117,9 @@ export interface DragAndDropOptions<T = object>
109
117
  /**
110
118
  * Optional custom drag preview renderer.
111
119
  */
112
- renderDragPreview?: (items: DragItem[]) => JSX.Element | { element: JSX.Element; x: number; y: number };
120
+ renderDragPreview?: (
121
+ items: DragItem[],
122
+ ) => JSX.Element | { element: JSX.Element; x: number; y: number };
113
123
  /**
114
124
  * Optional drop indicator renderer for collection components.
115
125
  */
@@ -149,39 +159,44 @@ export function useDragAndDrop<T = object>(options: DragAndDropOptions<T> = {}):
149
159
  dropTargetDelegate,
150
160
  } = options;
151
161
 
152
- const isDraggable = typeof getItems === 'function';
153
- const isDroppable = Boolean(onDrop || onInsert || onItemDrop || onReorder || onMove || onRootDrop);
162
+ const isDraggable = typeof getItems === "function";
163
+ const isDroppable = Boolean(
164
+ onDrop || onInsert || onItemDrop || onReorder || onMove || onRootDrop,
165
+ );
154
166
 
155
167
  const hooks: DragAndDropHooks<T> = {};
156
- const hasDom = typeof HTMLElement !== 'undefined';
168
+ const hasDom = typeof HTMLElement !== "undefined";
157
169
  const isElementNode = (value: unknown): value is HTMLElement => {
158
170
  if (!value) return false;
159
171
  if (hasDom && value instanceof HTMLElement) return true;
160
- return typeof value === 'object' && (value as { nodeType?: number }).nodeType === 1;
172
+ return typeof value === "object" && (value as { nodeType?: number }).nodeType === 1;
161
173
  };
162
- const resolvedPreview = options.preview ?? (
163
- renderDragPreview
174
+ const resolvedPreview =
175
+ options.preview ??
176
+ (renderDragPreview
164
177
  ? {
165
- current: (items: DragItem[], callback: (node: HTMLElement | null, x?: number, y?: number) => void) => {
178
+ current: (
179
+ items: DragItem[],
180
+ callback: (node: HTMLElement | null, x?: number, y?: number) => void,
181
+ ) => {
166
182
  const rendered = renderDragPreview(items);
167
183
  if (!rendered) {
168
184
  callback(null);
169
185
  return;
170
186
  }
171
- if (
172
- typeof rendered === 'object' &&
173
- rendered !== null &&
174
- 'element' in rendered
175
- ) {
187
+ if (typeof rendered === "object" && rendered !== null && "element" in rendered) {
176
188
  const previewValue = rendered as { element: unknown; x?: number; y?: number };
177
- callback(isElementNode(previewValue.element) ? previewValue.element : null, previewValue.x, previewValue.y);
189
+ callback(
190
+ isElementNode(previewValue.element) ? previewValue.element : null,
191
+ previewValue.x,
192
+ previewValue.y,
193
+ );
178
194
  return;
179
195
  }
180
196
  callback(isElementNode(rendered) ? rendered : null);
181
197
  },
182
198
  }
183
- : undefined
184
- );
199
+ : undefined);
185
200
 
186
201
  if (isDraggable && getItems) {
187
202
  hooks.useDraggableCollectionState = (props: DraggableCollectionStateOpts<T>) => {
@@ -189,7 +204,8 @@ export function useDragAndDrop<T = object>(options: DragAndDropOptions<T> = {}):
189
204
  onDragStart: options.onDragStart ?? props.onDragStart,
190
205
  onDragMove: options.onDragMove ?? props.onDragMove,
191
206
  onDragEnd: options.onDragEnd ?? props.onDragEnd,
192
- getAllowedDropOperations: options.getAllowedDropOperations ?? props.getAllowedDropOperations,
207
+ getAllowedDropOperations:
208
+ options.getAllowedDropOperations ?? props.getAllowedDropOperations,
193
209
  isDisabled: options.isDisabled ?? props.isDisabled,
194
210
  preview: resolvedPreview ?? props.preview,
195
211
  getItems: (keys) => {
@@ -199,9 +215,9 @@ export function useDragAndDrop<T = object>(options: DragAndDropOptions<T> = {}):
199
215
  }));
200
216
  };
201
217
  hooks.useDraggableCollection = (
202
- props: Omit<DraggableCollectionOptions, 'ref'>,
218
+ props: Omit<DraggableCollectionOptions, "ref">,
203
219
  state: DraggableCollectionState,
204
- ref: Accessor<HTMLElement | null>
220
+ ref: Accessor<HTMLElement | null>,
205
221
  ) => createDraggableCollection({ ...props, ref }, state);
206
222
  hooks.useDraggableItem = (props, state) => createDraggableItem(() => props, state);
207
223
  hooks.DragPreview = DragPreview;
@@ -229,17 +245,19 @@ export function useDragAndDrop<T = object>(options: DragAndDropOptions<T> = {}):
229
245
  }));
230
246
  };
231
247
  hooks.useDroppableCollection = (
232
- props: Omit<DroppableCollectionOptions, 'ref'>,
248
+ props: Omit<DroppableCollectionOptions, "ref">,
233
249
  state: DroppableCollectionState,
234
- ref: Accessor<HTMLElement | null>
250
+ ref: Accessor<HTMLElement | null>,
235
251
  ) => {
236
- const acceptedDragTypes = (options.acceptedDragTypes ?? props.acceptedDragTypes);
237
- const normalizedAcceptedDragTypes = acceptedDragTypes === 'all'
238
- ? 'all'
239
- : acceptedDragTypes?.filter((type): type is string | symbol =>
240
- typeof type === 'string' || typeof type === 'symbol');
241
- return (
242
- createDroppableCollection(
252
+ const acceptedDragTypes = options.acceptedDragTypes ?? props.acceptedDragTypes;
253
+ const normalizedAcceptedDragTypes =
254
+ acceptedDragTypes === "all"
255
+ ? "all"
256
+ : acceptedDragTypes?.filter(
257
+ (type): type is string | symbol =>
258
+ typeof type === "string" || typeof type === "symbol",
259
+ );
260
+ return createDroppableCollection(
243
261
  () => ({
244
262
  ref,
245
263
  dropTargetDelegate: options.dropTargetDelegate ?? props.dropTargetDelegate,
@@ -249,7 +267,7 @@ export function useDragAndDrop<T = object>(options: DragAndDropOptions<T> = {}):
249
267
  isDisabled: options.isDisabled ?? props.isDisabled,
250
268
  onDropActivate: (e) => {
251
269
  (options.onDropActivate ?? props.onDropActivate)?.({
252
- type: 'dropactivate',
270
+ type: "dropactivate",
253
271
  target: e.target,
254
272
  x: e.x,
255
273
  y: e.y,
@@ -257,7 +275,7 @@ export function useDragAndDrop<T = object>(options: DragAndDropOptions<T> = {}):
257
275
  },
258
276
  onDrop: (e) => {
259
277
  (options.onDrop ?? props.onDrop)?.({
260
- type: 'drop',
278
+ type: "drop",
261
279
  target: e.target,
262
280
  x: e.x,
263
281
  y: e.y,
@@ -267,7 +285,7 @@ export function useDragAndDrop<T = object>(options: DragAndDropOptions<T> = {}):
267
285
  },
268
286
  onRootDrop: options.onRootDrop ?? props.onRootDrop,
269
287
  onItemDrop: (e) => {
270
- if (e.target.type === 'item') {
288
+ if (e.target.type === "item") {
271
289
  (options.onItemDrop ?? props.onItemDrop)?.({
272
290
  items: e.items,
273
291
  target: e.target,
@@ -277,7 +295,7 @@ export function useDragAndDrop<T = object>(options: DragAndDropOptions<T> = {}):
277
295
  }
278
296
  },
279
297
  onInsert: (e) => {
280
- if (e.target.type === 'item') {
298
+ if (e.target.type === "item") {
281
299
  (options.onInsert ?? props.onInsert)?.({
282
300
  items: e.items,
283
301
  target: e.target,
@@ -286,7 +304,7 @@ export function useDragAndDrop<T = object>(options: DragAndDropOptions<T> = {}):
286
304
  }
287
305
  },
288
306
  onReorder: (e) => {
289
- if (e.target.type === 'item') {
307
+ if (e.target.type === "item") {
290
308
  (options.onReorder ?? props.onReorder)?.({
291
309
  keys: e.keys,
292
310
  target: e.target,
@@ -295,7 +313,7 @@ export function useDragAndDrop<T = object>(options: DragAndDropOptions<T> = {}):
295
313
  }
296
314
  },
297
315
  onMove: (e) => {
298
- if (e.target.type === 'item') {
316
+ if (e.target.type === "item") {
299
317
  (options.onMove ?? props.onMove)?.({
300
318
  keys: e.keys,
301
319
  target: e.target,
@@ -304,37 +322,35 @@ export function useDragAndDrop<T = object>(options: DragAndDropOptions<T> = {}):
304
322
  }
305
323
  },
306
324
  }),
307
- state
308
- ));
325
+ state,
326
+ );
309
327
  };
310
328
  hooks.useDroppableItem = (
311
- props: Omit<DroppableItemOptions, 'ref'>,
329
+ props: Omit<DroppableItemOptions, "ref">,
312
330
  state: DroppableCollectionState,
313
- ref: Accessor<HTMLElement | null>
331
+ ref: Accessor<HTMLElement | null>,
314
332
  ) => createDroppableItem(() => ({ ...props, ref }), state);
315
333
  hooks.useDropIndicator = (
316
334
  props: { target: DropTarget },
317
335
  state: DroppableCollectionState,
318
- _ref: Accessor<HTMLElement | null>
336
+ _ref: Accessor<HTMLElement | null>,
319
337
  ) => {
320
338
  const target = props.target;
321
339
  const activeTarget = state.target;
322
340
  const isDropTarget =
323
341
  activeTarget?.type === target.type &&
324
- (target.type === 'root'
325
- || (
326
- activeTarget.type === 'item' &&
327
- target.type === 'item' &&
342
+ (target.type === "root" ||
343
+ (activeTarget.type === "item" &&
344
+ target.type === "item" &&
328
345
  activeTarget.key === target.key &&
329
- activeTarget.dropPosition === target.dropPosition
330
- ));
346
+ activeTarget.dropPosition === target.dropPosition));
331
347
  return {
332
348
  dropIndicatorProps: {
333
- role: 'option',
334
- 'aria-disabled': true,
335
- 'aria-hidden': isDropTarget ? undefined : 'true',
349
+ role: "option",
350
+ "aria-disabled": true,
351
+ "aria-hidden": isDropTarget ? undefined : "true",
336
352
  tabIndex: -1,
337
- 'data-drop-target': isDropTarget ? '' : undefined,
353
+ "data-drop-target": isDropTarget ? "" : undefined,
338
354
  },
339
355
  isDropTarget,
340
356
  isHidden: !isDropTarget,
package/src/utils.tsx CHANGED
@@ -14,12 +14,8 @@ import {
14
14
  createSignal,
15
15
  onMount,
16
16
  Show,
17
- } from 'solid-js';
18
- import { isServer } from 'solid-js/web';
19
-
20
- // ============================================
21
- // TYPES
22
- // ============================================
17
+ } from "solid-js";
18
+ import { isServer } from "solid-js/web";
23
19
 
24
20
  /**
25
21
  * Render props pattern - children can be a function that receives state
@@ -56,11 +52,7 @@ export interface SlotProps {
56
52
  slot?: string;
57
53
  }
58
54
 
59
- export const DEFAULT_SLOT = 'default';
60
-
61
- // ============================================
62
- // RENDER PROPS
63
- // ============================================
55
+ export const DEFAULT_SLOT = "default";
64
56
 
65
57
  /**
66
58
  * Return type for useRenderProps
@@ -98,25 +90,23 @@ export interface RenderPropsResult<T> {
98
90
  */
99
91
  export function useRenderProps<T extends object>(
100
92
  props: RenderPropsBase<T> & { defaultClassName?: string },
101
- values: Accessor<T>
93
+ values: Accessor<T>,
102
94
  ): RenderPropsResult<T> {
103
95
  // Don't destructure children — access lazily to avoid eager evaluation
104
96
  // that would trigger child component creation before context providers mount.
105
- const { class: className, style, defaultClassName = '' } = props;
97
+ const { class: className, style, defaultClassName = "" } = props;
106
98
 
107
99
  // Compute class and style eagerly (they don't depend on context)
108
100
  const computedClass = createMemo(() => {
109
101
  const currentValues = values();
110
- return typeof className === 'function'
102
+ return typeof className === "function"
111
103
  ? className(currentValues)
112
- : className ?? defaultClassName;
104
+ : (className ?? defaultClassName);
113
105
  });
114
106
 
115
107
  const computedStyle = createMemo(() => {
116
108
  const currentValues = values();
117
- return typeof style === 'function'
118
- ? style(currentValues)
119
- : style;
109
+ return typeof style === "function" ? style(currentValues) : style;
120
110
  });
121
111
 
122
112
  // Return object with explicit function for rendering children
@@ -127,18 +117,18 @@ export function useRenderProps<T extends object>(
127
117
  renderChildren: () => {
128
118
  const currentValues = values();
129
119
  const children = props.children;
130
- return typeof children === 'function'
131
- ? children(currentValues)
132
- : children;
120
+ return typeof children === "function" ? children(currentValues) : children;
121
+ },
122
+ get children() {
123
+ return props.children;
133
124
  },
134
- get children() { return props.children; },
135
125
  values,
136
126
  };
137
127
  }
138
128
 
139
129
  export function composeRenderProps<T extends object>(
140
130
  base: RenderPropsBase<T> | undefined,
141
- override: RenderPropsBase<T> | undefined
131
+ override: RenderPropsBase<T> | undefined,
142
132
  ): RenderPropsBase<T> {
143
133
  if (!base) return override ?? {};
144
134
  if (!override) return base;
@@ -149,10 +139,6 @@ export function composeRenderProps<T extends object>(
149
139
  };
150
140
  }
151
141
 
152
- // ============================================
153
- // CONTEXT UTILITIES
154
- // ============================================
155
-
156
142
  /**
157
143
  * Context value that can be null or the actual value
158
144
  */
@@ -168,14 +154,16 @@ export function createSlottedContext<T>() {
168
154
  /**
169
155
  * Use context with null check
170
156
  */
171
- export function useSlottedContext<T>(context: ReturnType<typeof createContext<T | null>>): T | null {
157
+ export function useSlottedContext<T>(
158
+ context: ReturnType<typeof createContext<T | null>>,
159
+ ): T | null {
172
160
  return useContext(context);
173
161
  }
174
162
 
175
163
  export function useContextProps<TProps extends object, TRef>(
176
164
  props: TProps,
177
165
  ref: TRef,
178
- context?: ContextValue<Partial<TProps>>
166
+ context?: ContextValue<Partial<TProps>>,
179
167
  ): [TProps, TRef] {
180
168
  if (!context) return [props, ref];
181
169
  return [{ ...(context as TProps), ...props }, ref];
@@ -187,28 +175,24 @@ export const Provider: ParentComponent<{
187
175
  return props.children;
188
176
  };
189
177
 
190
- // ============================================
191
- // DATA ATTRIBUTES
192
- // ============================================
193
-
194
178
  /**
195
179
  * Converts boolean state values to data attributes
196
180
  */
197
- export function dataAttr(value: boolean | undefined): '' | undefined {
198
- return value ? '' : undefined;
181
+ export function dataAttr(value: boolean | undefined): "" | undefined {
182
+ return value ? "" : undefined;
199
183
  }
200
184
 
201
185
  /**
202
186
  * Creates data attributes from render props
203
187
  */
204
188
  export function createDataAttributes<T extends Record<string, boolean | string | undefined>>(
205
- values: T
189
+ values: T,
206
190
  ): Record<string, string | undefined> {
207
191
  const result: Record<string, string | undefined> = {};
208
192
 
209
193
  for (const [key, value] of Object.entries(values)) {
210
- if (typeof value === 'boolean') {
211
- result[`data-${camelToKebab(key)}`] = value ? '' : undefined;
194
+ if (typeof value === "boolean") {
195
+ result[`data-${camelToKebab(key)}`] = value ? "" : undefined;
212
196
  } else if (value !== undefined) {
213
197
  result[`data-${camelToKebab(key)}`] = value;
214
198
  }
@@ -218,13 +202,9 @@ export function createDataAttributes<T extends Record<string, boolean | string |
218
202
  }
219
203
 
220
204
  function camelToKebab(str: string): string {
221
- return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
205
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
222
206
  }
223
207
 
224
- // ============================================
225
- // PROPS UTILITIES
226
- // ============================================
227
-
228
208
  /**
229
209
  * Remove data attributes from props (for internal use)
230
210
  */
@@ -232,7 +212,7 @@ export function removeDataAttributes<T extends Record<string, unknown>>(props: T
232
212
  const result: Record<string, unknown> = {};
233
213
 
234
214
  for (const [key, value] of Object.entries(props)) {
235
- if (!key.startsWith('data-')) {
215
+ if (!key.startsWith("data-")) {
236
216
  result[key] = value;
237
217
  }
238
218
  }
@@ -249,14 +229,25 @@ export function removeDataAttributes<T extends Record<string, unknown>>(props: T
249
229
  */
250
230
  export function filterDOMProps<R extends object = Record<string, unknown>>(
251
231
  props: object,
252
- options: { global?: boolean } = {}
232
+ options: { global?: boolean } = {},
253
233
  ): R {
254
234
  const { global = false } = options;
255
235
  const result: Record<string, unknown> = {};
256
236
 
257
237
  const globalAttrs = new Set([
258
- 'id', 'class', 'style', 'tabIndex', 'role', 'title', 'lang', 'dir',
259
- 'hidden', 'draggable', 'accessKey', 'contentEditable', 'spellcheck',
238
+ "id",
239
+ "class",
240
+ "style",
241
+ "tabIndex",
242
+ "role",
243
+ "title",
244
+ "lang",
245
+ "dir",
246
+ "hidden",
247
+ "draggable",
248
+ "accessKey",
249
+ "contentEditable",
250
+ "spellcheck",
260
251
  ]);
261
252
 
262
253
  const ariaAttrs = /^aria-/;
@@ -266,12 +257,10 @@ export function filterDOMProps<R extends object = Record<string, unknown>>(
266
257
  for (const key in props) {
267
258
  if (
268
259
  Object.prototype.hasOwnProperty.call(props, key) &&
269
- (
270
- (global && globalAttrs.has(key)) ||
260
+ ((global && globalAttrs.has(key)) ||
271
261
  ariaAttrs.test(key) ||
272
262
  dataAttrs.test(key) ||
273
- eventHandlers.test(key)
274
- )
263
+ eventHandlers.test(key))
275
264
  ) {
276
265
  result[key] = (props as Record<string, unknown>)[key];
277
266
  }
@@ -280,10 +269,6 @@ export function filterDOMProps<R extends object = Record<string, unknown>>(
280
269
  return result as R;
281
270
  }
282
271
 
283
- // ============================================
284
- // CLIENT-ONLY UTILITIES
285
- // ============================================
286
-
287
272
  export interface ClientOnlyProps {
288
273
  /** The children to render only on the client */
289
274
  children: JSX.Element;
@@ -1,4 +1,4 @@
1
- import type { Key } from '@proyecto-viviana/solid-stately';
1
+ import type { Key } from "@proyecto-viviana/solid-stately";
2
2
 
3
3
  export interface InvalidationContext<O = unknown> {
4
4
  contentChanged?: boolean;
@@ -10,7 +10,10 @@ export interface InvalidationContext<O = unknown> {
10
10
  }
11
11
 
12
12
  export class Point {
13
- constructor(public x = 0, public y = 0) {}
13
+ constructor(
14
+ public x = 0,
15
+ public y = 0,
16
+ ) {}
14
17
  copy(): Point {
15
18
  return new Point(this.x, this.y);
16
19
  }
@@ -49,7 +52,7 @@ export class Rect {
49
52
  public x = 0,
50
53
  public y = 0,
51
54
  public width = 0,
52
- public height = 0
55
+ public height = 0,
53
56
  ) {}
54
57
 
55
58
  get maxX(): number {
@@ -81,30 +84,15 @@ export class Rect {
81
84
  }
82
85
 
83
86
  intersects(rect: Rect): boolean {
84
- return (
85
- this.x <= rect.maxX &&
86
- rect.x <= this.maxX &&
87
- this.y <= rect.maxY &&
88
- rect.y <= this.maxY
89
- );
87
+ return this.x <= rect.maxX && rect.x <= this.maxX && this.y <= rect.maxY && rect.y <= this.maxY;
90
88
  }
91
89
 
92
90
  containsRect(rect: Rect): boolean {
93
- return (
94
- this.x <= rect.x &&
95
- this.y <= rect.y &&
96
- this.maxX >= rect.maxX &&
97
- this.maxY >= rect.maxY
98
- );
91
+ return this.x <= rect.x && this.y <= rect.y && this.maxX >= rect.maxX && this.maxY >= rect.maxY;
99
92
  }
100
93
 
101
94
  containsPoint(point: Point): boolean {
102
- return (
103
- this.x <= point.x &&
104
- this.y <= point.y &&
105
- this.maxX >= point.x &&
106
- this.maxY >= point.y
107
- );
95
+ return this.x <= point.x && this.y <= point.y && this.maxX >= point.x && this.maxY >= point.y;
108
96
  }
109
97
 
110
98
  union(other: Rect): Rect {
@@ -150,7 +138,11 @@ export class LayoutInfo {
150
138
  zIndex = 0;
151
139
  allowOverflow = false;
152
140
 
153
- constructor(public type: string, public key: Key, public rect: Rect) {}
141
+ constructor(
142
+ public type: string,
143
+ public key: Key,
144
+ public rect: Rect,
145
+ ) {}
154
146
 
155
147
  copy(): LayoutInfo {
156
148
  const copy = new LayoutInfo(this.type, this.key, this.rect.copy());