@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.
- package/README.md +39 -272
- package/dist/ActionBar.d.ts +21 -13
- package/dist/ActionBar.d.ts.map +1 -1
- package/dist/ActionGroup.d.ts +8 -8
- package/dist/ActionGroup.d.ts.map +1 -1
- package/dist/Alert.d.ts +5 -5
- package/dist/Alert.d.ts.map +1 -1
- package/dist/Autocomplete.d.ts +5 -5
- package/dist/Autocomplete.d.ts.map +1 -1
- package/dist/Breadcrumbs.d.ts +18 -7
- package/dist/Breadcrumbs.d.ts.map +1 -1
- package/dist/Button.d.ts +24 -5
- package/dist/Button.d.ts.map +1 -1
- package/dist/Calendar.d.ts +38 -7
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/Checkbox.d.ts +32 -7
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Collection.d.ts +19 -14
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Color.d.ts +103 -14
- package/dist/Color.d.ts.map +1 -1
- package/dist/ColorEditor.d.ts +6 -6
- package/dist/ColorEditor.d.ts.map +1 -1
- package/dist/ComboBox.d.ts +85 -19
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/ContextualHelpTrigger.d.ts +2 -2
- package/dist/ContextualHelpTrigger.d.ts.map +1 -1
- package/dist/DateField.d.ts +8 -6
- package/dist/DateField.d.ts.map +1 -1
- package/dist/DatePicker.d.ts +53 -22
- package/dist/DatePicker.d.ts.map +1 -1
- package/dist/DateRangePickerContext.d.ts +30 -0
- package/dist/DateRangePickerContext.d.ts.map +1 -0
- package/dist/Dialog.d.ts +5 -5
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Disclosure.d.ts +23 -5
- package/dist/Disclosure.d.ts.map +1 -1
- package/dist/DragAndDrop.d.ts +6 -6
- package/dist/DragAndDrop.d.ts.map +1 -1
- package/dist/DragPreview.d.ts +2 -2
- package/dist/DragPreview.d.ts.map +1 -1
- package/dist/DropZone.d.ts +4 -4
- package/dist/DropZone.d.ts.map +1 -1
- package/dist/FieldError.d.ts +9 -5
- package/dist/FieldError.d.ts.map +1 -1
- package/dist/FileTrigger.d.ts +3 -3
- package/dist/FileTrigger.d.ts.map +1 -1
- package/dist/Focusable.d.ts +2 -2
- package/dist/Focusable.d.ts.map +1 -1
- package/dist/Form.d.ts +18 -4
- package/dist/Form.d.ts.map +1 -1
- package/dist/GridList.d.ts +32 -12
- package/dist/GridList.d.ts.map +1 -1
- package/dist/HiddenDateInput.d.ts +26 -0
- package/dist/HiddenDateInput.d.ts.map +1 -0
- package/dist/HiddenTimeInput.d.ts +25 -0
- package/dist/HiddenTimeInput.d.ts.map +1 -0
- package/dist/Icon.d.ts +5 -5
- package/dist/Icon.d.ts.map +1 -1
- package/dist/Keyboard.d.ts +1 -1
- package/dist/Landmark.d.ts +3 -3
- package/dist/Landmark.d.ts.map +1 -1
- package/dist/Link.d.ts +10 -4
- package/dist/Link.d.ts.map +1 -1
- package/dist/ListBox.d.ts +32 -12
- package/dist/ListBox.d.ts.map +1 -1
- package/dist/ListDropTargetDelegate.d.ts +6 -6
- package/dist/ListDropTargetDelegate.d.ts.map +1 -1
- package/dist/Menu.d.ts +65 -14
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Meter.d.ts +3 -3
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Modal.d.ts +5 -5
- package/dist/Modal.d.ts.map +1 -1
- package/dist/NumberField.d.ts +8 -12
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/Popover.d.ts +28 -5
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Pressable.d.ts +2 -2
- package/dist/Pressable.d.ts.map +1 -1
- package/dist/ProgressBar.d.ts +5 -3
- package/dist/ProgressBar.d.ts.map +1 -1
- package/dist/RadioGroup.d.ts +43 -9
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RangeCalendar.d.ts +34 -7
- package/dist/RangeCalendar.d.ts.map +1 -1
- package/dist/RouterProvider.d.ts +2 -2
- package/dist/RouterProvider.d.ts.map +1 -1
- package/dist/SearchField.d.ts +23 -20
- package/dist/SearchField.d.ts.map +1 -1
- package/dist/Select.d.ts +41 -11
- package/dist/Select.d.ts.map +1 -1
- package/dist/SelectionIndicator.d.ts +3 -3
- package/dist/SelectionIndicator.d.ts.map +1 -1
- package/dist/Separator.d.ts +9 -3
- package/dist/Separator.d.ts.map +1 -1
- package/dist/SharedElementTransition.d.ts +6 -4
- package/dist/SharedElementTransition.d.ts.map +1 -1
- package/dist/Slider.d.ts +12 -8
- package/dist/Slider.d.ts.map +1 -1
- package/dist/StepList.d.ts +90 -0
- package/dist/StepList.d.ts.map +1 -0
- package/dist/Switch.d.ts +11 -5
- package/dist/Switch.d.ts.map +1 -1
- package/dist/Table.d.ts +187 -23
- package/dist/Table.d.ts.map +1 -1
- package/dist/Tabs.d.ts +45 -9
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/TagGroup.d.ts +12 -10
- package/dist/TagGroup.d.ts.map +1 -1
- package/dist/Text.d.ts +2 -2
- package/dist/TextField.d.ts +15 -11
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TimeField.d.ts +6 -6
- package/dist/TimeField.d.ts.map +1 -1
- package/dist/Toast.d.ts +29 -14
- package/dist/Toast.d.ts.map +1 -1
- package/dist/ToggleButton.d.ts +11 -5
- package/dist/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButtonGroup.d.ts +7 -7
- package/dist/ToggleButtonGroup.d.ts.map +1 -1
- package/dist/Toolbar.d.ts +7 -3
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Tooltip.d.ts +50 -8
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tree.d.ts +66 -17
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Virtualizer.d.ts +12 -12
- package/dist/Virtualizer.d.ts.map +1 -1
- package/dist/VirtualizerLayouts.d.ts +2 -2
- package/dist/VirtualizerLayouts.d.ts.map +1 -1
- package/dist/VisuallyHidden.d.ts +1 -1
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/contexts.d.ts +5 -1
- package/dist/contexts.d.ts.map +1 -1
- package/dist/index.d.ts +73 -71
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23247 -18564
- package/dist/index.js.map +1 -1
- package/dist/index.jsx +18110 -0
- package/dist/index.jsx.map +1 -0
- package/dist/useDragAndDrop.d.ts +13 -13
- package/dist/useDragAndDrop.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/virtualizer/Layout.d.ts +1 -1
- package/dist/virtualizer/Layout.d.ts.map +1 -1
- package/package.json +31 -32
- package/src/ActionBar.tsx +75 -72
- package/src/ActionGroup.tsx +53 -61
- package/src/Alert.tsx +17 -42
- package/src/Autocomplete.tsx +39 -44
- package/src/Breadcrumbs.tsx +149 -80
- package/src/Button.tsx +267 -70
- package/src/Calendar.tsx +218 -138
- package/src/Checkbox.tsx +413 -121
- package/src/Collection.tsx +67 -58
- package/src/Color.tsx +803 -380
- package/src/ColorEditor.tsx +131 -149
- package/src/ComboBox.tsx +414 -249
- package/src/ContextualHelpTrigger.tsx +86 -74
- package/src/DateField.tsx +185 -91
- package/src/DatePicker.tsx +524 -213
- package/src/DateRangePickerContext.tsx +44 -0
- package/src/Dialog.tsx +156 -118
- package/src/Disclosure.tsx +127 -80
- package/src/DragAndDrop.tsx +60 -54
- package/src/DragPreview.tsx +13 -11
- package/src/DropZone.tsx +42 -22
- package/src/FieldError.tsx +45 -23
- package/src/FileTrigger.tsx +19 -19
- package/src/Focusable.tsx +21 -24
- package/src/Form.tsx +71 -16
- package/src/GridList.tsx +273 -197
- package/src/HiddenDateInput.tsx +153 -0
- package/src/HiddenTimeInput.tsx +133 -0
- package/src/Icon.tsx +22 -43
- package/src/Keyboard.tsx +3 -3
- package/src/Landmark.tsx +37 -63
- package/src/Link.tsx +125 -75
- package/src/ListBox.tsx +332 -233
- package/src/ListDropTargetDelegate.ts +81 -80
- package/src/Menu.tsx +1023 -274
- package/src/Meter.tsx +38 -56
- package/src/Modal.tsx +243 -175
- package/src/NumberField.tsx +139 -143
- package/src/Popover.tsx +386 -233
- package/src/Pressable.tsx +21 -21
- package/src/ProgressBar.tsx +48 -57
- package/src/RadioGroup.tsx +524 -122
- package/src/RangeCalendar.tsx +157 -90
- package/src/RouterProvider.tsx +30 -47
- package/src/SearchField.tsx +362 -143
- package/src/Select.tsx +656 -233
- package/src/SelectionIndicator.tsx +18 -15
- package/src/Separator.tsx +47 -49
- package/src/SharedElementTransition.tsx +103 -97
- package/src/Slider.tsx +138 -98
- package/src/StepList.tsx +272 -0
- package/src/Switch.tsx +93 -46
- package/src/Table.tsx +1308 -342
- package/src/Tabs.tsx +324 -103
- package/src/TagGroup.tsx +139 -126
- package/src/Text.tsx +3 -3
- package/src/TextField.tsx +389 -79
- package/src/TimeField.tsx +136 -76
- package/src/Toast.tsx +209 -157
- package/src/ToggleButton.tsx +47 -37
- package/src/ToggleButtonGroup.tsx +39 -34
- package/src/Toolbar.tsx +54 -69
- package/src/Tooltip.tsx +387 -119
- package/src/Tree.tsx +651 -368
- package/src/Virtualizer.tsx +208 -180
- package/src/VirtualizerLayouts.ts +45 -30
- package/src/VisuallyHidden.tsx +19 -19
- package/src/contexts.ts +29 -37
- package/src/index.ts +110 -195
- package/src/useDragAndDrop.ts +87 -71
- package/src/utils.tsx +40 -55
- package/src/virtualizer/Layout.ts +14 -22
- package/dist/index.ssr.js +0 -16996
- 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 {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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, [
|
|
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
|
-
|
|
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 ===
|
|
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(
|
|
66
|
-
addListener(
|
|
67
|
-
addListener(
|
|
68
|
-
addListener(
|
|
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 ===
|
|
70
|
+
if (key === "ref" || (key.startsWith("on") && typeof value === "function")) continue;
|
|
74
71
|
|
|
75
|
-
if (key ===
|
|
76
|
-
if (child.hasAttribute(
|
|
72
|
+
if (key === "tabIndex") {
|
|
73
|
+
if (child.hasAttribute("tabindex")) continue;
|
|
77
74
|
if (value == null || value === false) {
|
|
78
|
-
child.removeAttribute(
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
97
|
+
"validationErrors",
|
|
98
|
+
"validationBehavior",
|
|
99
|
+
"children",
|
|
100
|
+
"class",
|
|
101
|
+
"style",
|
|
102
|
+
"ref",
|
|
103
|
+
"slot",
|
|
52
104
|
]);
|
|
53
105
|
|
|
54
|
-
const validationBehavior: ValidationBehavior = local.validationBehavior ??
|
|
106
|
+
const validationBehavior: ValidationBehavior = local.validationBehavior ?? "native";
|
|
55
107
|
const errors = local.validationErrors ?? {};
|
|
56
108
|
const renderProps = useRenderProps(
|
|
57
109
|
{
|
|
58
|
-
children
|
|
110
|
+
get children() {
|
|
111
|
+
return local.children;
|
|
112
|
+
},
|
|
59
113
|
class: local.class,
|
|
60
114
|
style: local.style,
|
|
61
|
-
defaultClassName:
|
|
115
|
+
defaultClassName: "solidaria-Form",
|
|
62
116
|
},
|
|
63
117
|
() => ({
|
|
64
118
|
validationBehavior,
|
|
65
|
-
})
|
|
119
|
+
}),
|
|
66
120
|
);
|
|
67
121
|
|
|
68
|
-
const filteredDomProps =
|
|
122
|
+
const filteredDomProps = filterFormDOMProps(domProps);
|
|
69
123
|
|
|
70
124
|
return (
|
|
71
125
|
<form
|
|
72
126
|
{...filteredDomProps}
|
|
73
|
-
|
|
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}
|