@proyecto-viviana/solidaria-components 0.2.5 → 0.2.9
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/LICENSE +21 -0
- package/dist/ActionBar.d.ts +71 -0
- package/dist/ActionBar.d.ts.map +1 -0
- package/dist/ActionGroup.d.ts +74 -0
- package/dist/ActionGroup.d.ts.map +1 -0
- package/dist/Alert.d.ts +70 -0
- package/dist/Alert.d.ts.map +1 -0
- package/dist/Breadcrumbs.d.ts +10 -2
- package/dist/Breadcrumbs.d.ts.map +1 -1
- package/dist/Button.d.ts +4 -0
- package/dist/Button.d.ts.map +1 -1
- package/dist/Calendar.d.ts +13 -0
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/Checkbox.d.ts +2 -2
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Collection.d.ts +125 -0
- package/dist/Collection.d.ts.map +1 -0
- package/dist/Color.d.ts +114 -2
- package/dist/Color.d.ts.map +1 -1
- package/dist/ColorEditor.d.ts +42 -0
- package/dist/ColorEditor.d.ts.map +1 -0
- package/dist/ComboBox.d.ts +64 -0
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/ContextualHelpTrigger.d.ts +40 -0
- package/dist/ContextualHelpTrigger.d.ts.map +1 -0
- package/dist/DateField.d.ts +27 -2
- package/dist/DateField.d.ts.map +1 -1
- package/dist/DatePicker.d.ts +67 -2
- package/dist/DatePicker.d.ts.map +1 -1
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Disclosure.d.ts +2 -0
- package/dist/Disclosure.d.ts.map +1 -1
- package/dist/DragAndDrop.d.ts +80 -0
- package/dist/DragAndDrop.d.ts.map +1 -0
- package/dist/DragPreview.d.ts +14 -0
- package/dist/DragPreview.d.ts.map +1 -0
- package/dist/DropZone.d.ts +27 -0
- package/dist/DropZone.d.ts.map +1 -0
- package/dist/FieldError.d.ts +23 -0
- package/dist/FieldError.d.ts.map +1 -0
- package/dist/FileTrigger.d.ts +26 -0
- package/dist/FileTrigger.d.ts.map +1 -0
- package/dist/Focusable.d.ts +27 -0
- package/dist/Focusable.d.ts.map +1 -0
- package/dist/Form.d.ts +27 -0
- package/dist/Form.d.ts.map +1 -0
- package/dist/GridList.d.ts +40 -1
- package/dist/GridList.d.ts.map +1 -1
- package/dist/Icon.d.ts +57 -0
- package/dist/Icon.d.ts.map +1 -0
- package/dist/Keyboard.d.ts +13 -0
- package/dist/Keyboard.d.ts.map +1 -0
- package/dist/Link.d.ts.map +1 -1
- package/dist/ListBox.d.ts +43 -1
- package/dist/ListBox.d.ts.map +1 -1
- package/dist/ListDropTargetDelegate.d.ts +38 -0
- package/dist/ListDropTargetDelegate.d.ts.map +1 -0
- package/dist/Menu.d.ts +20 -2
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Meter.d.ts +2 -2
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Modal.d.ts +2 -0
- package/dist/Modal.d.ts.map +1 -1
- package/dist/NumberField.d.ts +2 -0
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/Popover.d.ts +4 -2
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Pressable.d.ts +27 -0
- package/dist/Pressable.d.ts.map +1 -0
- package/dist/ProgressBar.d.ts +2 -2
- package/dist/ProgressBar.d.ts.map +1 -1
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RangeCalendar.d.ts +5 -0
- package/dist/RangeCalendar.d.ts.map +1 -1
- package/dist/RouterProvider.d.ts +75 -0
- package/dist/RouterProvider.d.ts.map +1 -0
- package/dist/SearchField.d.ts +2 -3
- package/dist/SearchField.d.ts.map +1 -1
- package/dist/Select.d.ts +11 -0
- package/dist/Select.d.ts.map +1 -1
- package/dist/SelectionIndicator.d.ts +30 -0
- package/dist/SelectionIndicator.d.ts.map +1 -0
- package/dist/SharedElementTransition.d.ts +39 -0
- package/dist/SharedElementTransition.d.ts.map +1 -0
- package/dist/Slider.d.ts +6 -3
- package/dist/Slider.d.ts.map +1 -1
- package/dist/Table.d.ts +39 -0
- package/dist/Table.d.ts.map +1 -1
- package/dist/Tabs.d.ts +4 -3
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/TagGroup.d.ts +12 -2
- package/dist/TagGroup.d.ts.map +1 -1
- package/dist/Text.d.ts +10 -0
- package/dist/Text.d.ts.map +1 -0
- package/dist/TextField.d.ts +4 -0
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TimeField.d.ts +26 -1
- package/dist/TimeField.d.ts.map +1 -1
- package/dist/Toast.d.ts.map +1 -1
- package/dist/ToggleButton.d.ts +30 -0
- package/dist/ToggleButton.d.ts.map +1 -0
- package/dist/ToggleButtonGroup.d.ts +33 -0
- package/dist/ToggleButtonGroup.d.ts.map +1 -0
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Tooltip.d.ts +9 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tree.d.ts +44 -2
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Virtualizer.d.ts +61 -0
- package/dist/Virtualizer.d.ts.map +1 -0
- package/dist/VirtualizerLayouts.d.ts +82 -0
- package/dist/VirtualizerLayouts.d.ts.map +1 -0
- package/dist/VisuallyHidden.d.ts +3 -1
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/contexts.d.ts +1 -0
- package/dist/contexts.d.ts.map +1 -1
- package/dist/index.d.ts +57 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13961 -5946
- package/dist/index.js.map +1 -7
- package/dist/index.ssr.js +9612 -2401
- package/dist/index.ssr.js.map +1 -7
- package/dist/useDragAndDrop.d.ts +93 -0
- package/dist/useDragAndDrop.d.ts.map +1 -0
- package/dist/utils.d.ts +7 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/virtualizer/Layout.d.ts +79 -0
- package/dist/virtualizer/Layout.d.ts.map +1 -0
- package/package.json +8 -6
- package/src/ActionBar.tsx +248 -0
- package/src/ActionGroup.tsx +285 -0
- package/src/Alert.tsx +177 -0
- package/src/Autocomplete.tsx +1 -1
- package/src/Breadcrumbs.tsx +103 -17
- package/src/Button.tsx +65 -21
- package/src/Calendar.tsx +179 -53
- package/src/Checkbox.tsx +1 -2
- package/src/Collection.tsx +341 -0
- package/src/Color.tsx +652 -34
- package/src/ColorEditor.tsx +231 -0
- package/src/ComboBox.tsx +315 -81
- package/src/ContextualHelpTrigger.tsx +183 -0
- package/src/DateField.tsx +93 -19
- package/src/DatePicker.tsx +495 -25
- package/src/Dialog.tsx +40 -9
- package/src/Disclosure.tsx +33 -27
- package/src/DragAndDrop.tsx +334 -0
- package/src/DragPreview.tsx +45 -0
- package/src/DropZone.tsx +213 -0
- package/src/FieldError.tsx +67 -0
- package/src/FileTrigger.tsx +83 -0
- package/src/Focusable.tsx +106 -0
- package/src/Form.tsx +85 -0
- package/src/GridList.tsx +379 -41
- package/src/Icon.tsx +154 -0
- package/src/Keyboard.tsx +26 -0
- package/src/Link.tsx +14 -1
- package/src/ListBox.tsx +484 -33
- package/src/ListDropTargetDelegate.ts +282 -0
- package/src/Menu.tsx +388 -35
- package/src/Meter.tsx +7 -3
- package/src/Modal.tsx +32 -4
- package/src/NumberField.tsx +163 -43
- package/src/Popover.tsx +136 -180
- package/src/Pressable.tsx +108 -0
- package/src/ProgressBar.tsx +7 -3
- package/src/RadioGroup.tsx +35 -25
- package/src/RangeCalendar.tsx +100 -68
- package/src/RouterProvider.tsx +240 -0
- package/src/SearchField.tsx +142 -34
- package/src/Select.tsx +221 -73
- package/src/SelectionIndicator.tsx +105 -0
- package/src/SharedElementTransition.tsx +258 -0
- package/src/Slider.tsx +16 -6
- package/src/Table.tsx +417 -57
- package/src/Tabs.tsx +68 -35
- package/src/TagGroup.tsx +121 -36
- package/src/Text.tsx +18 -0
- package/src/TextField.tsx +25 -8
- package/src/TimeField.tsx +101 -151
- package/src/Toast.tsx +108 -14
- package/src/ToggleButton.tsx +159 -0
- package/src/ToggleButtonGroup.tsx +136 -0
- package/src/Toolbar.tsx +14 -8
- package/src/Tooltip.tsx +108 -19
- package/src/Tree.tsx +1143 -87
- package/src/Virtualizer.tsx +702 -0
- package/src/VirtualizerLayouts.ts +265 -0
- package/src/VisuallyHidden.tsx +15 -21
- package/src/contexts.ts +1 -0
- package/src/index.ts +1057 -620
- package/src/useDragAndDrop.ts +351 -0
- package/src/utils.tsx +37 -3
- package/src/virtualizer/Layout.ts +200 -0
package/src/Icon.tsx
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icon component for solidaria-components
|
|
3
|
+
*
|
|
4
|
+
* Minimal headless Icon that owns ARIA semantics:
|
|
5
|
+
* - Decorative (no label): aria-hidden="true"
|
|
6
|
+
* - Informative (aria-label): role="img" + aria-label
|
|
7
|
+
* - Interactive (onPress): wraps content in headless Button
|
|
8
|
+
*
|
|
9
|
+
* The UI layer consumes this for styling/composition only.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
type JSX,
|
|
14
|
+
createContext,
|
|
15
|
+
createMemo,
|
|
16
|
+
Show,
|
|
17
|
+
splitProps,
|
|
18
|
+
} from 'solid-js';
|
|
19
|
+
import {
|
|
20
|
+
type RenderChildren,
|
|
21
|
+
type ClassNameOrFunction,
|
|
22
|
+
type StyleOrFunction,
|
|
23
|
+
type SlotProps,
|
|
24
|
+
useRenderProps,
|
|
25
|
+
filterDOMProps,
|
|
26
|
+
} from './utils';
|
|
27
|
+
import { Button } from './Button';
|
|
28
|
+
import type { PressEvent } from '@proyecto-viviana/solidaria';
|
|
29
|
+
|
|
30
|
+
// ============================================
|
|
31
|
+
// TYPES
|
|
32
|
+
// ============================================
|
|
33
|
+
|
|
34
|
+
export interface IconRenderProps {
|
|
35
|
+
/** Whether the icon is purely decorative (no label). */
|
|
36
|
+
isDecorative: boolean;
|
|
37
|
+
/** Whether the icon is interactive (has onPress). */
|
|
38
|
+
isInteractive: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface IconProps extends SlotProps {
|
|
42
|
+
/** Handler called when the icon is pressed (makes it interactive). */
|
|
43
|
+
onPress?: (e: PressEvent) => void;
|
|
44
|
+
/** Accessible label for the icon. When provided, the icon is informative (role="img"). */
|
|
45
|
+
'aria-label'?: string;
|
|
46
|
+
/** ID of an element that labels this icon. */
|
|
47
|
+
'aria-labelledby'?: string;
|
|
48
|
+
/** The children of the component. A function may be provided to receive render props. */
|
|
49
|
+
children?: RenderChildren<IconRenderProps>;
|
|
50
|
+
/** The CSS className for the element. */
|
|
51
|
+
class?: ClassNameOrFunction<IconRenderProps>;
|
|
52
|
+
/** The inline style for the element. */
|
|
53
|
+
style?: StyleOrFunction<IconRenderProps>;
|
|
54
|
+
/** The id of the element. */
|
|
55
|
+
id?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ============================================
|
|
59
|
+
// CONTEXT
|
|
60
|
+
// ============================================
|
|
61
|
+
|
|
62
|
+
export const IconContext = createContext<IconProps | null>(null);
|
|
63
|
+
|
|
64
|
+
// ============================================
|
|
65
|
+
// ICON COMPONENT
|
|
66
|
+
// ============================================
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* An icon wrapper that provides correct ARIA semantics.
|
|
70
|
+
*
|
|
71
|
+
* - **Decorative** (no `aria-label`): renders `<span aria-hidden="true">`
|
|
72
|
+
* - **Informative** (`aria-label` provided): renders `<span role="img" aria-label="...">`
|
|
73
|
+
* - **Interactive** (`onPress` provided): wraps in headless `Button`
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* // Decorative
|
|
78
|
+
* <Icon><SearchSvg /></Icon>
|
|
79
|
+
*
|
|
80
|
+
* // Informative
|
|
81
|
+
* <Icon aria-label="Search"><SearchSvg /></Icon>
|
|
82
|
+
*
|
|
83
|
+
* // Interactive
|
|
84
|
+
* <Icon onPress={handleSearch} aria-label="Search"><SearchSvg /></Icon>
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export function Icon(props: IconProps): JSX.Element {
|
|
88
|
+
const [local, rest] = splitProps(props, [
|
|
89
|
+
'children',
|
|
90
|
+
'class',
|
|
91
|
+
'style',
|
|
92
|
+
'slot',
|
|
93
|
+
'onPress',
|
|
94
|
+
'aria-label',
|
|
95
|
+
'aria-labelledby',
|
|
96
|
+
]);
|
|
97
|
+
|
|
98
|
+
const hasLabel = () => !!(local['aria-label'] || local['aria-labelledby']);
|
|
99
|
+
const isInteractive = () => !!local.onPress;
|
|
100
|
+
const isDecorative = () => !hasLabel();
|
|
101
|
+
|
|
102
|
+
// Render props values
|
|
103
|
+
const renderValues = createMemo<IconRenderProps>(() => ({
|
|
104
|
+
isDecorative: isDecorative(),
|
|
105
|
+
isInteractive: isInteractive(),
|
|
106
|
+
}));
|
|
107
|
+
|
|
108
|
+
// Resolve render props
|
|
109
|
+
const renderProps = useRenderProps(
|
|
110
|
+
{
|
|
111
|
+
children: local.children,
|
|
112
|
+
class: local.class,
|
|
113
|
+
style: local.style,
|
|
114
|
+
defaultClassName: 'solidaria-Icon',
|
|
115
|
+
},
|
|
116
|
+
renderValues
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
// Filter DOM props
|
|
120
|
+
const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<Show
|
|
124
|
+
when={isInteractive()}
|
|
125
|
+
fallback={
|
|
126
|
+
<span
|
|
127
|
+
{...domProps()}
|
|
128
|
+
role={hasLabel() ? 'img' : undefined}
|
|
129
|
+
aria-hidden={isDecorative() ? 'true' : undefined}
|
|
130
|
+
aria-label={local['aria-label']}
|
|
131
|
+
aria-labelledby={local['aria-labelledby']}
|
|
132
|
+
class={renderProps.class()}
|
|
133
|
+
style={renderProps.style()}
|
|
134
|
+
data-interactive={undefined}
|
|
135
|
+
data-decorative={isDecorative() || undefined}
|
|
136
|
+
>
|
|
137
|
+
{renderProps.renderChildren()}
|
|
138
|
+
</span>
|
|
139
|
+
}
|
|
140
|
+
>
|
|
141
|
+
<Button
|
|
142
|
+
{...domProps()}
|
|
143
|
+
onPress={local.onPress}
|
|
144
|
+
aria-label={local['aria-label']}
|
|
145
|
+
aria-labelledby={local['aria-labelledby']}
|
|
146
|
+
class={renderProps.class()}
|
|
147
|
+
style={renderProps.style()}
|
|
148
|
+
data-interactive=""
|
|
149
|
+
>
|
|
150
|
+
{renderProps.renderChildren()}
|
|
151
|
+
</Button>
|
|
152
|
+
</Show>
|
|
153
|
+
);
|
|
154
|
+
}
|
package/src/Keyboard.tsx
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard primitive for solidaria-components.
|
|
3
|
+
*
|
|
4
|
+
* Displays keyboard key hints with semantic <kbd> markup.
|
|
5
|
+
* Port direction: react-aria-components/src/Keyboard.tsx
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { type JSX, createContext, splitProps, useContext } from 'solid-js';
|
|
9
|
+
|
|
10
|
+
export interface KeyboardProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
11
|
+
children?: JSX.Element;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const KeyboardContext = createContext<KeyboardProps | null>(null);
|
|
15
|
+
|
|
16
|
+
export function Keyboard(props: KeyboardProps): JSX.Element {
|
|
17
|
+
const context = useContext(KeyboardContext);
|
|
18
|
+
const merged = () => ({ ...(context ?? {}), ...props });
|
|
19
|
+
const [local, domProps] = splitProps(merged(), ['children']);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<kbd dir="ltr" {...domProps}>
|
|
23
|
+
{local.children}
|
|
24
|
+
</kbd>
|
|
25
|
+
);
|
|
26
|
+
}
|
package/src/Link.tsx
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
useRenderProps,
|
|
29
29
|
filterDOMProps,
|
|
30
30
|
} from './utils';
|
|
31
|
+
import { handleLinkClick, useRouter } from './RouterProvider';
|
|
31
32
|
|
|
32
33
|
// ============================================
|
|
33
34
|
// TYPES
|
|
@@ -98,6 +99,8 @@ export function Link(props: ParentProps<LinkProps>): JSX.Element {
|
|
|
98
99
|
'onHoverEnd',
|
|
99
100
|
'onHoverChange',
|
|
100
101
|
]);
|
|
102
|
+
const router = useRouter();
|
|
103
|
+
const resolvedHref = createMemo(() => ariaProps.href ? router.useHref(ariaProps.href) : undefined);
|
|
101
104
|
|
|
102
105
|
// Determine element type - use 'a' if href is provided and not disabled
|
|
103
106
|
const elementType = () => {
|
|
@@ -111,9 +114,13 @@ export function Link(props: ParentProps<LinkProps>): JSX.Element {
|
|
|
111
114
|
const linkAria = createLink({
|
|
112
115
|
get elementType() { return elementType(); },
|
|
113
116
|
get isDisabled() { return ariaProps.isDisabled; },
|
|
114
|
-
get href() { return
|
|
117
|
+
get href() { return resolvedHref(); },
|
|
118
|
+
get hrefLang() { return ariaProps.hrefLang; },
|
|
115
119
|
get target() { return ariaProps.target; },
|
|
116
120
|
get rel() { return ariaProps.rel; },
|
|
121
|
+
get download() { return ariaProps.download; },
|
|
122
|
+
get ping() { return ariaProps.ping; },
|
|
123
|
+
get referrerPolicy() { return ariaProps.referrerPolicy; },
|
|
117
124
|
get onPress() { return ariaProps.onPress; },
|
|
118
125
|
get onPressStart() { return ariaProps.onPressStart; },
|
|
119
126
|
get onPressEnd() { return ariaProps.onPressEnd; },
|
|
@@ -178,6 +185,11 @@ export function Link(props: ParentProps<LinkProps>): JSX.Element {
|
|
|
178
185
|
const { ref: _ref3, ...rest } = focusProps as Record<string, unknown>;
|
|
179
186
|
return rest;
|
|
180
187
|
};
|
|
188
|
+
const onLinkClick = (event: MouseEvent) => {
|
|
189
|
+
const onClick = cleanLinkProps().onClick as ((event: MouseEvent) => void) | undefined;
|
|
190
|
+
onClick?.(event);
|
|
191
|
+
handleLinkClick(event, router, ariaProps.href, ariaProps.routerOptions);
|
|
192
|
+
};
|
|
181
193
|
|
|
182
194
|
return (
|
|
183
195
|
<Dynamic
|
|
@@ -186,6 +198,7 @@ export function Link(props: ParentProps<LinkProps>): JSX.Element {
|
|
|
186
198
|
{...cleanLinkProps()}
|
|
187
199
|
{...cleanHoverProps()}
|
|
188
200
|
{...cleanFocusProps()}
|
|
201
|
+
onClick={onLinkClick}
|
|
189
202
|
class={renderProps.class()}
|
|
190
203
|
style={renderProps.style()}
|
|
191
204
|
data-hovered={isHovered() || undefined}
|