@proyecto-viviana/solidaria-components 0.1.3 → 0.2.2

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 (64) hide show
  1. package/dist/Color.d.ts +6 -2
  2. package/dist/Color.d.ts.map +1 -1
  3. package/dist/ComboBox.d.ts +3 -3
  4. package/dist/ComboBox.d.ts.map +1 -1
  5. package/dist/GridList.d.ts +2 -2
  6. package/dist/GridList.d.ts.map +1 -1
  7. package/dist/ListBox.d.ts +5 -5
  8. package/dist/ListBox.d.ts.map +1 -1
  9. package/dist/Menu.d.ts +3 -3
  10. package/dist/Menu.d.ts.map +1 -1
  11. package/dist/Select.d.ts +3 -3
  12. package/dist/Select.d.ts.map +1 -1
  13. package/dist/Table.d.ts +2 -2
  14. package/dist/Table.d.ts.map +1 -1
  15. package/dist/Tabs.d.ts +1 -1
  16. package/dist/Tabs.d.ts.map +1 -1
  17. package/dist/index.js +15 -15
  18. package/dist/index.js.map +2 -2
  19. package/dist/index.jsx +9056 -0
  20. package/dist/index.jsx.map +7 -0
  21. package/dist/index.ssr.js +15 -15
  22. package/dist/index.ssr.js.map +2 -2
  23. package/package.json +8 -10
  24. package/src/Autocomplete.tsx +0 -174
  25. package/src/Breadcrumbs.tsx +0 -264
  26. package/src/Button.tsx +0 -238
  27. package/src/Calendar.tsx +0 -471
  28. package/src/Checkbox.tsx +0 -387
  29. package/src/Color.tsx +0 -1370
  30. package/src/ComboBox.tsx +0 -824
  31. package/src/DateField.tsx +0 -337
  32. package/src/DatePicker.tsx +0 -367
  33. package/src/Dialog.tsx +0 -262
  34. package/src/Disclosure.tsx +0 -439
  35. package/src/GridList.tsx +0 -511
  36. package/src/Landmark.tsx +0 -203
  37. package/src/Link.tsx +0 -201
  38. package/src/ListBox.tsx +0 -346
  39. package/src/Menu.tsx +0 -544
  40. package/src/Meter.tsx +0 -157
  41. package/src/Modal.tsx +0 -433
  42. package/src/NumberField.tsx +0 -542
  43. package/src/Popover.tsx +0 -540
  44. package/src/ProgressBar.tsx +0 -162
  45. package/src/RadioGroup.tsx +0 -356
  46. package/src/RangeCalendar.tsx +0 -462
  47. package/src/SearchField.tsx +0 -479
  48. package/src/Select.tsx +0 -734
  49. package/src/Separator.tsx +0 -130
  50. package/src/Slider.tsx +0 -500
  51. package/src/Switch.tsx +0 -213
  52. package/src/Table.tsx +0 -857
  53. package/src/Tabs.tsx +0 -552
  54. package/src/TagGroup.tsx +0 -421
  55. package/src/TextField.tsx +0 -271
  56. package/src/TimeField.tsx +0 -455
  57. package/src/Toast.tsx +0 -503
  58. package/src/Toolbar.tsx +0 -160
  59. package/src/Tooltip.tsx +0 -423
  60. package/src/Tree.tsx +0 -551
  61. package/src/VisuallyHidden.tsx +0 -60
  62. package/src/contexts.ts +0 -74
  63. package/src/index.ts +0 -620
  64. package/src/utils.tsx +0 -329
@@ -1,462 +0,0 @@
1
- /**
2
- * RangeCalendar component for solidaria-components
3
- *
4
- * Pre-wired headless range calendar component that combines aria hooks.
5
- * Port of react-aria-components/src/RangeCalendar.tsx
6
- */
7
-
8
- import {
9
- type JSX,
10
- createContext,
11
- createMemo,
12
- createSignal,
13
- splitProps,
14
- useContext,
15
- For,
16
- Show,
17
- } from 'solid-js';
18
- import {
19
- createRangeCalendar,
20
- createCalendarGrid,
21
- createRangeCalendarCell,
22
- type AriaRangeCalendarProps,
23
- type AriaCalendarGridProps,
24
- } from '@proyecto-viviana/solidaria';
25
- import {
26
- createRangeCalendarState,
27
- type RangeCalendarState,
28
- type RangeCalendarStateProps,
29
- type CalendarDate,
30
- type DateValue,
31
- type RangeValue,
32
- } from '@proyecto-viviana/solid-stately';
33
- import {
34
- type RenderChildren,
35
- type ClassNameOrFunction,
36
- type StyleOrFunction,
37
- type SlotProps,
38
- useRenderProps,
39
- dataAttr,
40
- useIsHydrated,
41
- } from './utils';
42
-
43
- // ============================================
44
- // TYPES
45
- // ============================================
46
-
47
- export interface RangeCalendarRenderProps {
48
- /** Whether the calendar is disabled. */
49
- isDisabled: boolean;
50
- /** Whether the calendar is read-only. */
51
- isReadOnly: boolean;
52
- /** Whether the user is currently selecting a range. */
53
- isDragging: boolean;
54
- }
55
-
56
- export interface RangeCalendarProps<T extends DateValue = DateValue>
57
- extends Omit<AriaRangeCalendarProps, 'id' | 'isDisabled' | 'isReadOnly'>,
58
- Omit<RangeCalendarStateProps<T>, 'locale'>,
59
- SlotProps {
60
- /** The children of the component. */
61
- children?: JSX.Element;
62
- /** The CSS className for the element. */
63
- class?: ClassNameOrFunction<RangeCalendarRenderProps>;
64
- /** The inline style for the element. */
65
- style?: StyleOrFunction<RangeCalendarRenderProps>;
66
- /** The locale to use for formatting. */
67
- locale?: string;
68
- }
69
-
70
- export interface RangeCalendarGridRenderProps {
71
- /** Whether the grid is disabled. */
72
- isDisabled: boolean;
73
- }
74
-
75
- export interface RangeCalendarGridProps extends Omit<AriaCalendarGridProps, 'startDate' | 'endDate'>, SlotProps {
76
- /** The children of the component (render function receiving dates). */
77
- children?: (date: CalendarDate) => JSX.Element;
78
- /** The CSS className for the element. */
79
- class?: ClassNameOrFunction<RangeCalendarGridRenderProps>;
80
- /** The inline style for the element. */
81
- style?: StyleOrFunction<RangeCalendarGridRenderProps>;
82
- }
83
-
84
- export interface RangeCalendarCellRenderProps {
85
- /** Whether the cell is within the selected range. */
86
- isSelected: boolean;
87
- /** Whether the cell is the start of the selection. */
88
- isSelectionStart: boolean;
89
- /** Whether the cell is the end of the selection. */
90
- isSelectionEnd: boolean;
91
- /** Whether the cell is focused. */
92
- isFocused: boolean;
93
- /** Whether the cell is disabled. */
94
- isDisabled: boolean;
95
- /** Whether the cell is unavailable. */
96
- isUnavailable: boolean;
97
- /** Whether the cell is outside the visible month. */
98
- isOutsideMonth: boolean;
99
- /** Whether the cell represents today. */
100
- isToday: boolean;
101
- /** Whether the cell is pressed. */
102
- isPressed: boolean;
103
- /** The formatted date string. */
104
- formattedDate: string;
105
- }
106
-
107
- export interface RangeCalendarCellProps extends SlotProps {
108
- /** The date for this cell. */
109
- date: CalendarDate;
110
- /** The children of the component. A function may be provided to receive render props. */
111
- children?: RenderChildren<RangeCalendarCellRenderProps>;
112
- /** The CSS className for the element. */
113
- class?: ClassNameOrFunction<RangeCalendarCellRenderProps>;
114
- /** The inline style for the element. */
115
- style?: StyleOrFunction<RangeCalendarCellRenderProps>;
116
- }
117
-
118
- // ============================================
119
- // CONTEXT
120
- // ============================================
121
-
122
- export const RangeCalendarContext = createContext<RangeCalendarState<DateValue> | null>(null);
123
-
124
- export function useRangeCalendarContext(): RangeCalendarState<DateValue> {
125
- const context = useContext(RangeCalendarContext);
126
- if (!context) {
127
- throw new Error('RangeCalendar components must be used within a RangeCalendar');
128
- }
129
- return context;
130
- }
131
-
132
- // ============================================
133
- // RANGE CALENDAR COMPONENT
134
- // ============================================
135
-
136
- /**
137
- * A range calendar displays a grid of days and allows users to select a contiguous range of dates.
138
- *
139
- * @example
140
- * ```tsx
141
- * <RangeCalendar aria-label="Date range">
142
- * <header>
143
- * <RangeCalendarButton slot="previous">◀</RangeCalendarButton>
144
- * <RangeCalendarHeading />
145
- * <RangeCalendarButton slot="next">▶</RangeCalendarButton>
146
- * </header>
147
- * <RangeCalendarGrid>
148
- * {(date) => <RangeCalendarCell date={date} />}
149
- * </RangeCalendarGrid>
150
- * </RangeCalendar>
151
- * ```
152
- */
153
- export function RangeCalendar<T extends DateValue = CalendarDate>(
154
- props: RangeCalendarProps<T>
155
- ): JSX.Element {
156
- // Use hydration-safe pattern for client-only rendering
157
- const isHydrated = useIsHydrated();
158
-
159
- return (
160
- <Show
161
- when={isHydrated()}
162
- fallback={<div class="solidaria-RangeCalendar solidaria-RangeCalendar--placeholder" aria-hidden="true" />}
163
- >
164
- <RangeCalendarInner {...props} />
165
- </Show>
166
- );
167
- }
168
-
169
- /**
170
- * Internal RangeCalendar component that renders after client mount.
171
- */
172
- function RangeCalendarInner<T extends DateValue = CalendarDate>(
173
- props: RangeCalendarProps<T>
174
- ): JSX.Element {
175
- const [local, stateProps, rest] = splitProps(
176
- props,
177
- ['children', 'class', 'style', 'slot'],
178
- [
179
- 'value',
180
- 'defaultValue',
181
- 'onChange',
182
- 'minValue',
183
- 'maxValue',
184
- 'isDisabled',
185
- 'isReadOnly',
186
- 'focusedValue',
187
- 'defaultFocusedValue',
188
- 'onFocusChange',
189
- 'locale',
190
- 'isDateUnavailable',
191
- 'visibleMonths',
192
- 'isDateDisabled',
193
- 'validationState',
194
- 'allowsNonContiguousRanges',
195
- 'firstDayOfWeek',
196
- ]
197
- );
198
-
199
- // Create range calendar state
200
- const state = createRangeCalendarState(stateProps);
201
-
202
- // Create range calendar ARIA props
203
- const calendarAria = createRangeCalendar(rest, state as unknown as RangeCalendarState<DateValue>);
204
-
205
- // Render props values
206
- const renderValues = createMemo<RangeCalendarRenderProps>(() => ({
207
- isDisabled: state.isDisabled(),
208
- isReadOnly: state.isReadOnly(),
209
- isDragging: state.isDragging(),
210
- }));
211
-
212
- // Resolve render props
213
- const renderProps = useRenderProps(
214
- {
215
- class: local.class,
216
- style: local.style,
217
- defaultClassName: 'solidaria-RangeCalendar',
218
- },
219
- renderValues
220
- );
221
-
222
- return (
223
- <RangeCalendarContext.Provider value={state as unknown as RangeCalendarState<DateValue>}>
224
- <div
225
- {...calendarAria.calendarProps}
226
- class={renderProps.class()}
227
- style={renderProps.style()}
228
- data-disabled={dataAttr(state.isDisabled())}
229
- data-readonly={dataAttr(state.isReadOnly())}
230
- data-dragging={dataAttr(state.isDragging())}
231
- >
232
- {props.children}
233
- </div>
234
- </RangeCalendarContext.Provider>
235
- );
236
- }
237
-
238
- // ============================================
239
- // RANGE CALENDAR HEADING COMPONENT
240
- // ============================================
241
-
242
- export interface RangeCalendarHeadingProps extends SlotProps {
243
- /** The CSS className for the element. */
244
- class?: string;
245
- /** The inline style for the element. */
246
- style?: JSX.CSSProperties;
247
- }
248
-
249
- /**
250
- * Displays the current month and year in the range calendar.
251
- */
252
- export function RangeCalendarHeading(props: RangeCalendarHeadingProps): JSX.Element {
253
- const state = useRangeCalendarContext();
254
-
255
- return (
256
- <h2
257
- class={props.class ?? 'solidaria-RangeCalendarHeading'}
258
- style={props.style}
259
- aria-live="polite"
260
- >
261
- {state.title()}
262
- </h2>
263
- );
264
- }
265
-
266
- // ============================================
267
- // RANGE CALENDAR BUTTON COMPONENT
268
- // ============================================
269
-
270
- export interface RangeCalendarButtonProps extends SlotProps {
271
- /** The slot for this button (previous or next). */
272
- slot?: 'previous' | 'next';
273
- /** The children of the component. */
274
- children?: JSX.Element;
275
- /** The CSS className for the element. */
276
- class?: string;
277
- /** The inline style for the element. */
278
- style?: JSX.CSSProperties;
279
- /** Whether the button is disabled. */
280
- isDisabled?: boolean;
281
- }
282
-
283
- /**
284
- * A button for navigating the range calendar.
285
- */
286
- export function RangeCalendarButton(props: RangeCalendarButtonProps): JSX.Element {
287
- const state = useRangeCalendarContext();
288
- const calendarAria = createRangeCalendar({}, state);
289
-
290
- const buttonProps = createMemo(() => {
291
- if (props.slot === 'previous') {
292
- return calendarAria.prevButtonProps;
293
- }
294
- return calendarAria.nextButtonProps;
295
- });
296
-
297
- return (
298
- <button
299
- {...buttonProps()}
300
- class={props.class ?? 'solidaria-RangeCalendarButton'}
301
- style={props.style}
302
- disabled={props.isDisabled || state.isDisabled()}
303
- >
304
- {props.children}
305
- </button>
306
- );
307
- }
308
-
309
- // ============================================
310
- // RANGE CALENDAR GRID COMPONENT
311
- // ============================================
312
-
313
- /**
314
- * Displays a grid of range calendar cells.
315
- */
316
- export function RangeCalendarGrid(props: RangeCalendarGridProps): JSX.Element {
317
- const state = useRangeCalendarContext();
318
- const [gridRef, setGridRef] = createSignal<HTMLTableElement | null>(null);
319
-
320
- // Create grid ARIA props
321
- const gridAria = createCalendarGrid(
322
- {
323
- weekdayStyle: props.weekdayStyle,
324
- },
325
- state as unknown as Parameters<typeof createCalendarGrid>[1],
326
- gridRef
327
- );
328
-
329
- // Render props values
330
- const renderValues = createMemo<RangeCalendarGridRenderProps>(() => ({
331
- isDisabled: state.isDisabled(),
332
- }));
333
-
334
- // Resolve render props
335
- const renderProps = useRenderProps(
336
- {
337
- class: props.class,
338
- style: props.style,
339
- defaultClassName: 'solidaria-RangeCalendarGrid',
340
- },
341
- renderValues
342
- );
343
-
344
- // Get weeks to render
345
- const weeks = createMemo(() => {
346
- const numWeeks = state.getWeeksInMonth();
347
- return Array.from({ length: numWeeks }, (_, i) => i);
348
- });
349
-
350
- return (
351
- <table
352
- ref={setGridRef}
353
- {...gridAria.gridProps}
354
- class={renderProps.class()}
355
- style={renderProps.style()}
356
- >
357
- <thead {...gridAria.headerProps}>
358
- <tr>
359
- <For each={gridAria.weekDays}>
360
- {(day) => (
361
- <th scope="col" class="solidaria-RangeCalendarHeaderCell">
362
- {day}
363
- </th>
364
- )}
365
- </For>
366
- </tr>
367
- </thead>
368
- <tbody>
369
- <For each={weeks()}>
370
- {(weekIndex) => (
371
- <tr>
372
- <For each={state.getDatesInWeek(weekIndex)}>
373
- {(date) => (
374
- <Show when={date}>
375
- <td>
376
- {props.children?.(date!)}
377
- </td>
378
- </Show>
379
- )}
380
- </For>
381
- </tr>
382
- )}
383
- </For>
384
- </tbody>
385
- </table>
386
- );
387
- }
388
-
389
- // ============================================
390
- // RANGE CALENDAR CELL COMPONENT
391
- // ============================================
392
-
393
- /**
394
- * A cell in the range calendar grid representing a single day.
395
- */
396
- export function RangeCalendarCell(props: RangeCalendarCellProps): JSX.Element {
397
- const state = useRangeCalendarContext();
398
- const [cellRef, setCellRef] = createSignal<HTMLDivElement | null>(null);
399
-
400
- // Create cell ARIA props
401
- const cellAria = createRangeCalendarCell(
402
- { date: props.date },
403
- state,
404
- cellRef
405
- );
406
-
407
- // Render props values
408
- const renderValues = createMemo<RangeCalendarCellRenderProps>(() => ({
409
- isSelected: cellAria.isSelected,
410
- isSelectionStart: cellAria.isSelectionStart,
411
- isSelectionEnd: cellAria.isSelectionEnd,
412
- isFocused: cellAria.isFocused,
413
- isDisabled: cellAria.isDisabled,
414
- isUnavailable: cellAria.isUnavailable,
415
- isOutsideMonth: cellAria.isOutsideMonth,
416
- isToday: cellAria.isToday,
417
- isPressed: cellAria.isPressed,
418
- formattedDate: cellAria.formattedDate,
419
- }));
420
-
421
- // Resolve render props
422
- const renderProps = useRenderProps(
423
- {
424
- children: props.children,
425
- class: props.class,
426
- style: props.style,
427
- defaultClassName: 'solidaria-RangeCalendarCell',
428
- },
429
- renderValues
430
- );
431
-
432
- // Determine children content - avoid Show for SSR hydration compatibility
433
- const getChildren = () => {
434
- if (typeof props.children === 'function') {
435
- return renderProps.renderChildren();
436
- }
437
- return cellAria.formattedDate;
438
- };
439
-
440
- return (
441
- <div
442
- ref={setCellRef}
443
- {...cellAria.buttonProps}
444
- class={renderProps.class()}
445
- style={renderProps.style()}
446
- data-selected={dataAttr(cellAria.isSelected)}
447
- data-selection-start={dataAttr(cellAria.isSelectionStart)}
448
- data-selection-end={dataAttr(cellAria.isSelectionEnd)}
449
- data-focused={dataAttr(cellAria.isFocused)}
450
- data-disabled={dataAttr(cellAria.isDisabled)}
451
- data-unavailable={dataAttr(cellAria.isUnavailable)}
452
- data-outside-month={dataAttr(cellAria.isOutsideMonth)}
453
- data-today={dataAttr(cellAria.isToday)}
454
- data-pressed={dataAttr(cellAria.isPressed)}
455
- >
456
- {getChildren()}
457
- </div>
458
- );
459
- }
460
-
461
- // Re-export types
462
- export type { RangeCalendarState, RangeValue };