@proyecto-viviana/solidaria-components 0.2.9 → 0.3.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 (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 +23253 -18564
  139. package/dist/index.js.map +1 -1
  140. package/dist/index.jsx +18116 -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 +251 -176
  186. package/src/NumberField.tsx +139 -143
  187. package/src/Popover.tsx +396 -234
  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 +216 -158
  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 +49 -60
  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
package/src/Focusable.tsx CHANGED
@@ -5,12 +5,14 @@
5
5
  * focusable and capable of auto focus. Port of React Aria's Focusable.
6
6
  */
7
7
 
8
- import { type JSX, children as resolveChildren, createEffect, onCleanup, splitProps } from 'solid-js';
9
- import { createFocusable, type CreateFocusableProps } from '@proyecto-viviana/solidaria';
10
-
11
- // ============================================
12
- // TYPES
13
- // ============================================
8
+ import {
9
+ type JSX,
10
+ children as resolveChildren,
11
+ createEffect,
12
+ onCleanup,
13
+ splitProps,
14
+ } from "solid-js";
15
+ import { createFocusable, type CreateFocusableProps } from "@proyecto-viviana/solidaria";
14
16
 
15
17
  export interface FocusableProps extends CreateFocusableProps {
16
18
  /** A single child element to make focusable. */
@@ -19,10 +21,6 @@ export interface FocusableProps extends CreateFocusableProps {
19
21
  ref?: HTMLElement | ((el: HTMLElement) => void);
20
22
  }
21
23
 
22
- // ============================================
23
- // COMPONENT
24
- // ============================================
25
-
26
24
  /**
27
25
  * Makes its child element focusable and capable of auto focus.
28
26
  * Applies focus and keyboard event handlers from createFocusable.
@@ -35,7 +33,7 @@ export interface FocusableProps extends CreateFocusableProps {
35
33
  * ```
36
34
  */
37
35
  export function Focusable(props: FocusableProps): JSX.Element {
38
- const [local, focusableProps] = splitProps(props, ['children', 'ref']);
36
+ const [local, focusableProps] = splitProps(props, ["children", "ref"]);
39
37
 
40
38
  let ref!: HTMLElement;
41
39
  const { focusableProps: domProps } = createFocusable(focusableProps, () => ref);
@@ -46,8 +44,7 @@ export function Focusable(props: FocusableProps): JSX.Element {
46
44
  const child = resolved() as HTMLElement;
47
45
  if (child instanceof HTMLElement) {
48
46
  ref = child;
49
- // Forward ref
50
- if (typeof local.ref === 'function') {
47
+ if (typeof local.ref === "function") {
51
48
  local.ref(child);
52
49
  }
53
50
 
@@ -55,39 +52,39 @@ export function Focusable(props: FocusableProps): JSX.Element {
55
52
  const props = domProps;
56
53
  const listeners: Array<[string, EventListener]> = [];
57
54
  const addListener = (eventName: string, handler: unknown) => {
58
- if (typeof handler === 'function') {
55
+ if (typeof handler === "function") {
59
56
  const listener = handler as EventListener;
60
57
  child.addEventListener(eventName, listener);
61
58
  listeners.push([eventName, listener]);
62
59
  }
63
60
  };
64
61
 
65
- addListener('focus', props.onFocus);
66
- addListener('blur', props.onBlur);
67
- addListener('keydown', props.onKeyDown);
68
- addListener('keyup', props.onKeyUp);
62
+ addListener("focus", props.onFocus);
63
+ addListener("blur", props.onBlur);
64
+ addListener("keydown", props.onKeyDown);
65
+ addListener("keyup", props.onKeyUp);
69
66
 
70
67
  // Apply non-event focusable props (e.g. tabIndex/aria/data attrs).
71
68
  // Keep explicit child tabIndex to mirror mergeProps(child.props precedence).
72
69
  for (const [key, value] of Object.entries(props)) {
73
- if (key === 'ref' || (key.startsWith('on') && typeof value === 'function')) continue;
70
+ if (key === "ref" || (key.startsWith("on") && typeof value === "function")) continue;
74
71
 
75
- if (key === 'tabIndex') {
76
- if (child.hasAttribute('tabindex')) continue;
72
+ if (key === "tabIndex") {
73
+ if (child.hasAttribute("tabindex")) continue;
77
74
  if (value == null || value === false) {
78
- child.removeAttribute('tabindex');
75
+ child.removeAttribute("tabindex");
79
76
  } else {
80
77
  child.tabIndex = Number(value);
81
78
  }
82
79
  continue;
83
80
  }
84
81
 
85
- if (key.startsWith('aria-') || key.startsWith('data-') || key === 'id' || key === 'role') {
82
+ if (key.startsWith("aria-") || key.startsWith("data-") || key === "id" || key === "role") {
86
83
  if (child.hasAttribute(key)) continue;
87
84
  if (value == null || value === false) {
88
85
  child.removeAttribute(key);
89
86
  } else if (value === true) {
90
- child.setAttribute(key, '');
87
+ child.setAttribute(key, "");
91
88
  } else {
92
89
  child.setAttribute(key, String(value));
93
90
  }
package/src/Form.tsx CHANGED
@@ -5,12 +5,12 @@
5
5
  * Port direction: react-aria-components/src/Form.tsx
6
6
  */
7
7
 
8
- import { type JSX, createContext, splitProps } from 'solid-js';
8
+ import { type JSX, createContext, splitProps } from "solid-js";
9
9
  import {
10
10
  FormValidationContext,
11
11
  type ValidationErrors,
12
12
  type ValidationBehavior,
13
- } from '@proyecto-viviana/solid-stately';
13
+ } from "@proyecto-viviana/solid-stately";
14
14
  import {
15
15
  type ClassNameOrFunction,
16
16
  type StyleOrFunction,
@@ -18,59 +18,114 @@ import {
18
18
  type SlotProps,
19
19
  useRenderProps,
20
20
  filterDOMProps,
21
- } from './utils';
21
+ } from "./utils";
22
+
23
+ type RefLike<T> = ((el: T) => void) | { current?: T | null } | undefined;
24
+
25
+ function assignRef<T>(ref: RefLike<T>, el: T): void {
26
+ if (!ref) return;
27
+ if (typeof ref === "function") {
28
+ ref(el);
29
+ } else {
30
+ ref.current = el;
31
+ }
32
+ }
22
33
 
23
34
  export interface FormRenderProps {
24
35
  validationBehavior: ValidationBehavior;
25
36
  }
26
37
 
27
38
  export interface FormProps
28
- extends Omit<JSX.FormHTMLAttributes<HTMLFormElement>, 'children' | 'class' | 'style'>,
39
+ extends
40
+ Omit<JSX.FormHTMLAttributes<HTMLFormElement>, "children" | "class" | "style" | "ref">,
29
41
  SlotProps {
30
42
  /** Server-side validation errors keyed by field name. */
31
43
  validationErrors?: ValidationErrors;
32
44
  /** Validation behavior mode. */
33
45
  validationBehavior?: ValidationBehavior;
46
+ /** Character encodings accepted by the server. React-style alias for Solid's `accept-charset`. */
47
+ acceptCharset?: string;
48
+ /** Browser auto-capitalization hint. React-style alias for Solid's `autocapitalize`. */
49
+ autoCapitalize?: JSX.HTMLAttributes<HTMLFormElement>["autoCapitalize"];
50
+ /** Browser autocomplete behavior. React-style alias for Solid's `autocomplete`. */
51
+ autoComplete?: JSX.FormHTMLAttributes<HTMLFormElement>["autocomplete"];
52
+ /** Form encoding type. React-style alias for Solid's `enctype`. */
53
+ encType?: JSX.FormHTMLAttributes<HTMLFormElement>["enctype"];
34
54
  /** The children of the component. */
35
55
  children?: RenderChildren<FormRenderProps>;
36
56
  /** The CSS className for the element. */
37
57
  class?: ClassNameOrFunction<FormRenderProps>;
38
58
  /** The inline style for the element. */
39
59
  style?: StyleOrFunction<FormRenderProps>;
60
+ /** Ref for the underlying form element. */
61
+ ref?: RefLike<HTMLFormElement>;
40
62
  }
41
63
 
42
64
  export const FormContext = createContext<FormProps | null>(null);
43
65
 
66
+ const formDOMPropNames = new Set([
67
+ "accept-charset",
68
+ "acceptCharset",
69
+ "action",
70
+ "autocapitalize",
71
+ "autoCapitalize",
72
+ "autocomplete",
73
+ "autoComplete",
74
+ "encoding",
75
+ "enctype",
76
+ "encType",
77
+ "method",
78
+ "name",
79
+ "rel",
80
+ "target",
81
+ ]);
82
+
83
+ function filterFormDOMProps(props: object): Record<string, unknown> {
84
+ const filtered = filterDOMProps<Record<string, unknown>>(props, { global: true });
85
+
86
+ for (const key in props) {
87
+ if (Object.prototype.hasOwnProperty.call(props, key) && formDOMPropNames.has(key)) {
88
+ filtered[key] = (props as Record<string, unknown>)[key];
89
+ }
90
+ }
91
+
92
+ return filtered;
93
+ }
94
+
44
95
  export function Form(props: FormProps): JSX.Element {
45
96
  const [local, domProps] = splitProps(props, [
46
- 'validationErrors',
47
- 'validationBehavior',
48
- 'children',
49
- 'class',
50
- 'style',
51
- 'slot',
97
+ "validationErrors",
98
+ "validationBehavior",
99
+ "children",
100
+ "class",
101
+ "style",
102
+ "ref",
103
+ "slot",
52
104
  ]);
53
105
 
54
- const validationBehavior: ValidationBehavior = local.validationBehavior ?? 'native';
106
+ const validationBehavior: ValidationBehavior = local.validationBehavior ?? "native";
55
107
  const errors = local.validationErrors ?? {};
56
108
  const renderProps = useRenderProps(
57
109
  {
58
- children: local.children,
110
+ get children() {
111
+ return local.children;
112
+ },
59
113
  class: local.class,
60
114
  style: local.style,
61
- defaultClassName: 'solidaria-Form',
115
+ defaultClassName: "solidaria-Form",
62
116
  },
63
117
  () => ({
64
118
  validationBehavior,
65
- })
119
+ }),
66
120
  );
67
121
 
68
- const filteredDomProps = filterDOMProps(domProps, { global: true });
122
+ const filteredDomProps = filterFormDOMProps(domProps);
69
123
 
70
124
  return (
71
125
  <form
72
126
  {...filteredDomProps}
73
- noValidate={validationBehavior !== 'native'}
127
+ ref={(el) => assignRef(local.ref, el)}
128
+ noValidate={validationBehavior !== "native"}
74
129
  class={renderProps.class()}
75
130
  style={renderProps.style()}
76
131
  slot={local.slot}