@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/TagGroup.tsx
CHANGED
|
@@ -17,19 +17,15 @@ import {
|
|
|
17
17
|
useContext,
|
|
18
18
|
For,
|
|
19
19
|
Show,
|
|
20
|
-
} from
|
|
21
|
-
import {
|
|
22
|
-
createTagGroup,
|
|
23
|
-
createTag,
|
|
24
|
-
type AriaTagGroupProps,
|
|
25
|
-
} from '@proyecto-viviana/solidaria';
|
|
20
|
+
} from "solid-js";
|
|
21
|
+
import { createTagGroup, createTag, type AriaTagGroupProps } from "@proyecto-viviana/solidaria";
|
|
26
22
|
import {
|
|
27
23
|
createListState,
|
|
28
24
|
type ListState,
|
|
29
25
|
type Key,
|
|
30
26
|
type SelectionMode,
|
|
31
27
|
type SelectionBehavior,
|
|
32
|
-
} from
|
|
28
|
+
} from "@proyecto-viviana/solid-stately";
|
|
33
29
|
import {
|
|
34
30
|
type RenderChildren,
|
|
35
31
|
type ClassNameOrFunction,
|
|
@@ -38,16 +34,12 @@ import {
|
|
|
38
34
|
useRenderProps,
|
|
39
35
|
filterDOMProps,
|
|
40
36
|
dataAttr,
|
|
41
|
-
} from
|
|
42
|
-
import { SharedElementTransition } from
|
|
37
|
+
} from "./utils";
|
|
38
|
+
import { SharedElementTransition } from "./SharedElementTransition";
|
|
43
39
|
import {
|
|
44
40
|
SelectionIndicatorContext,
|
|
45
41
|
type SelectionIndicatorContextValue,
|
|
46
|
-
} from
|
|
47
|
-
|
|
48
|
-
// ============================================
|
|
49
|
-
// TYPES
|
|
50
|
-
// ============================================
|
|
42
|
+
} from "./SelectionIndicator";
|
|
51
43
|
|
|
52
44
|
export interface TagGroupRenderProps {
|
|
53
45
|
/** Whether the tag group is disabled. */
|
|
@@ -57,9 +49,10 @@ export interface TagGroupRenderProps {
|
|
|
57
49
|
}
|
|
58
50
|
|
|
59
51
|
export interface TagGroupProps
|
|
60
|
-
extends
|
|
52
|
+
extends
|
|
53
|
+
Omit<AriaTagGroupProps, "id">,
|
|
61
54
|
SlotProps,
|
|
62
|
-
Omit<JSX.HTMLAttributes<HTMLDivElement>,
|
|
55
|
+
Omit<JSX.HTMLAttributes<HTMLDivElement>, "class" | "style" | "children"> {
|
|
63
56
|
/** The children of the component. */
|
|
64
57
|
children?: JSX.Element;
|
|
65
58
|
/** The CSS className for the element. */
|
|
@@ -75,7 +68,10 @@ export interface TagListRenderProps {
|
|
|
75
68
|
isFocused: boolean;
|
|
76
69
|
}
|
|
77
70
|
|
|
78
|
-
export interface TagListProps<T>
|
|
71
|
+
export interface TagListProps<T>
|
|
72
|
+
extends
|
|
73
|
+
SlotProps,
|
|
74
|
+
Omit<JSX.HTMLAttributes<HTMLDivElement>, "class" | "style" | "children" | "onSelectionChange"> {
|
|
79
75
|
/** The items to display in the tag list. */
|
|
80
76
|
items: T[];
|
|
81
77
|
/** Function to render each item. */
|
|
@@ -95,7 +91,7 @@ export interface TagListProps<T> extends SlotProps, Omit<JSX.HTMLAttributes<HTML
|
|
|
95
91
|
/** The default selected keys (uncontrolled). */
|
|
96
92
|
defaultSelectedKeys?: Iterable<Key>;
|
|
97
93
|
/** Handler called when selection changes. */
|
|
98
|
-
onSelectionChange?: (keys:
|
|
94
|
+
onSelectionChange?: (keys: "all" | Set<Key>) => void;
|
|
99
95
|
/** Keys that are disabled. */
|
|
100
96
|
disabledKeys?: Iterable<Key>;
|
|
101
97
|
/** Function to get a unique key from an item. */
|
|
@@ -103,11 +99,11 @@ export interface TagListProps<T> extends SlotProps, Omit<JSX.HTMLAttributes<HTML
|
|
|
103
99
|
/** Accessibility label. */
|
|
104
100
|
label?: string;
|
|
105
101
|
/** Custom aria-label. */
|
|
106
|
-
|
|
102
|
+
"aria-label"?: string;
|
|
107
103
|
/** Reference to external label element. */
|
|
108
|
-
|
|
104
|
+
"aria-labelledby"?: string;
|
|
109
105
|
/** Reference to description element. */
|
|
110
|
-
|
|
106
|
+
"aria-describedby"?: string;
|
|
111
107
|
/** Whether the tag list is disabled. */
|
|
112
108
|
isDisabled?: boolean;
|
|
113
109
|
/** Handler called when tags are removed. */
|
|
@@ -144,12 +140,10 @@ export interface TagProps extends SlotProps {
|
|
|
144
140
|
class?: ClassNameOrFunction<TagRenderProps>;
|
|
145
141
|
/** The inline style for the element. */
|
|
146
142
|
style?: StyleOrFunction<TagRenderProps>;
|
|
143
|
+
/** Handler called when the tag is activated. */
|
|
144
|
+
onAction?: (key: Key) => void;
|
|
147
145
|
}
|
|
148
146
|
|
|
149
|
-
// ============================================
|
|
150
|
-
// CONTEXT
|
|
151
|
-
// ============================================
|
|
152
|
-
|
|
153
147
|
interface TagGroupContextValue {
|
|
154
148
|
state: ListState;
|
|
155
149
|
onRemove?: (keys: Set<Key>) => void;
|
|
@@ -169,10 +163,6 @@ export function useTagGroupContext(): TagGroupContextValue | null {
|
|
|
169
163
|
return useContext(TagGroupContext);
|
|
170
164
|
}
|
|
171
165
|
|
|
172
|
-
// ============================================
|
|
173
|
-
// TAG GROUP COMPONENT
|
|
174
|
-
// ============================================
|
|
175
|
-
|
|
176
166
|
/**
|
|
177
167
|
* A tag group is a focusable list of labels, categories, keywords, filters, or other items,
|
|
178
168
|
* with support for keyboard navigation, selection, and removal.
|
|
@@ -187,19 +177,14 @@ export function useTagGroupContext(): TagGroupContextValue | null {
|
|
|
187
177
|
* ```
|
|
188
178
|
*/
|
|
189
179
|
export function TagGroup(props: TagGroupProps): JSX.Element {
|
|
190
|
-
const [local, domProps] = splitProps(props, [
|
|
191
|
-
'class',
|
|
192
|
-
'style',
|
|
193
|
-
'slot',
|
|
194
|
-
'children',
|
|
195
|
-
]);
|
|
180
|
+
const [local, domProps] = splitProps(props, ["class", "style", "slot", "children"]);
|
|
196
181
|
|
|
197
182
|
// We need TagList to provide the state, so TagGroup just provides context
|
|
198
183
|
return (
|
|
199
184
|
<div
|
|
200
185
|
{...domProps}
|
|
201
|
-
class={typeof local.class ===
|
|
202
|
-
style={typeof local.style ===
|
|
186
|
+
class={typeof local.class === "string" ? local.class : "solidaria-TagGroup"}
|
|
187
|
+
style={typeof local.style === "object" ? local.style : undefined}
|
|
203
188
|
slot={local.slot}
|
|
204
189
|
>
|
|
205
190
|
{props.children}
|
|
@@ -207,34 +192,30 @@ export function TagGroup(props: TagGroupProps): JSX.Element {
|
|
|
207
192
|
);
|
|
208
193
|
}
|
|
209
194
|
|
|
210
|
-
// ============================================
|
|
211
|
-
// TAG LIST COMPONENT
|
|
212
|
-
// ============================================
|
|
213
|
-
|
|
214
195
|
/**
|
|
215
196
|
* TagList contains the list of tags within a TagGroup.
|
|
216
197
|
*/
|
|
217
198
|
export function TagList<T extends { id?: Key; key?: Key }>(props: TagListProps<T>): JSX.Element {
|
|
218
199
|
const [local, domProps] = splitProps(props, [
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
200
|
+
"items",
|
|
201
|
+
"class",
|
|
202
|
+
"style",
|
|
203
|
+
"slot",
|
|
204
|
+
"renderEmptyState",
|
|
205
|
+
"children",
|
|
206
|
+
"selectionMode",
|
|
207
|
+
"selectionBehavior",
|
|
208
|
+
"selectedKeys",
|
|
209
|
+
"defaultSelectedKeys",
|
|
210
|
+
"onSelectionChange",
|
|
211
|
+
"disabledKeys",
|
|
212
|
+
"getKey",
|
|
213
|
+
"label",
|
|
214
|
+
"aria-label",
|
|
215
|
+
"aria-labelledby",
|
|
216
|
+
"aria-describedby",
|
|
217
|
+
"isDisabled",
|
|
218
|
+
"onRemove",
|
|
238
219
|
]);
|
|
239
220
|
|
|
240
221
|
// Create a ref for the grid
|
|
@@ -248,55 +229,78 @@ export function TagList<T extends { id?: Key; key?: Key }>(props: TagListProps<T
|
|
|
248
229
|
return String(item);
|
|
249
230
|
};
|
|
250
231
|
|
|
251
|
-
// Create list state
|
|
252
232
|
const state = createListState({
|
|
253
|
-
get items() {
|
|
233
|
+
get items() {
|
|
234
|
+
return local.items;
|
|
235
|
+
},
|
|
254
236
|
getKey,
|
|
255
|
-
get selectionMode() {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
get
|
|
259
|
-
|
|
260
|
-
|
|
237
|
+
get selectionMode() {
|
|
238
|
+
return local.selectionMode ?? "none";
|
|
239
|
+
},
|
|
240
|
+
get selectionBehavior() {
|
|
241
|
+
return local.selectionBehavior ?? "toggle";
|
|
242
|
+
},
|
|
243
|
+
get selectedKeys() {
|
|
244
|
+
return local.selectedKeys;
|
|
245
|
+
},
|
|
246
|
+
get defaultSelectedKeys() {
|
|
247
|
+
return local.defaultSelectedKeys;
|
|
248
|
+
},
|
|
249
|
+
get onSelectionChange() {
|
|
250
|
+
return local.onSelectionChange;
|
|
251
|
+
},
|
|
252
|
+
get disabledKeys() {
|
|
253
|
+
return local.disabledKeys;
|
|
254
|
+
},
|
|
261
255
|
});
|
|
262
256
|
|
|
263
257
|
// Create tag group accessibility props
|
|
264
258
|
const tagGroupAria = createTagGroup(
|
|
265
259
|
{
|
|
266
|
-
get
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
get
|
|
270
|
-
|
|
260
|
+
get "aria-label"() {
|
|
261
|
+
return local["aria-label"] ?? (!local["aria-labelledby"] ? local.label : undefined);
|
|
262
|
+
},
|
|
263
|
+
get "aria-labelledby"() {
|
|
264
|
+
return local["aria-labelledby"];
|
|
265
|
+
},
|
|
266
|
+
get "aria-describedby"() {
|
|
267
|
+
return local["aria-describedby"];
|
|
268
|
+
},
|
|
269
|
+
get isDisabled() {
|
|
270
|
+
return local.isDisabled;
|
|
271
|
+
},
|
|
272
|
+
get onRemove() {
|
|
273
|
+
return local.onRemove;
|
|
274
|
+
},
|
|
271
275
|
},
|
|
272
276
|
state,
|
|
273
|
-
gridRef
|
|
277
|
+
gridRef,
|
|
274
278
|
);
|
|
275
279
|
|
|
276
|
-
// Track focus
|
|
277
280
|
const [isFocused, setIsFocused] = createSignal(false);
|
|
278
281
|
|
|
279
|
-
// Render props values
|
|
280
282
|
const renderValues = createMemo<TagListRenderProps>(() => ({
|
|
281
283
|
isEmpty: local.items.length === 0,
|
|
282
284
|
isFocused: isFocused(),
|
|
283
285
|
}));
|
|
284
286
|
|
|
285
|
-
// Resolve render props
|
|
286
287
|
const renderProps = useRenderProps(
|
|
287
288
|
{
|
|
288
289
|
class: local.class,
|
|
289
290
|
style: local.style,
|
|
290
|
-
defaultClassName:
|
|
291
|
+
defaultClassName: "solidaria-TagList",
|
|
291
292
|
},
|
|
292
|
-
renderValues
|
|
293
|
+
renderValues,
|
|
293
294
|
);
|
|
294
295
|
|
|
295
|
-
// Context value
|
|
296
296
|
const contextValue: TagGroupContextValue = {
|
|
297
297
|
state,
|
|
298
|
-
get onRemove() {
|
|
299
|
-
|
|
298
|
+
get onRemove() {
|
|
299
|
+
return local.onRemove;
|
|
300
|
+
},
|
|
301
|
+
get isDisabled() {
|
|
302
|
+
return local.isDisabled;
|
|
303
|
+
},
|
|
300
304
|
};
|
|
301
305
|
|
|
302
306
|
return (
|
|
@@ -325,13 +329,8 @@ export function TagList<T extends { id?: Key; key?: Key }>(props: TagListProps<T
|
|
|
325
329
|
data-focused={dataAttr(isFocused())}
|
|
326
330
|
>
|
|
327
331
|
<SharedElementTransition>
|
|
328
|
-
<Show
|
|
329
|
-
|
|
330
|
-
fallback={local.renderEmptyState?.()}
|
|
331
|
-
>
|
|
332
|
-
<For each={local.items}>
|
|
333
|
-
{(item) => props.children(item)}
|
|
334
|
-
</For>
|
|
332
|
+
<Show when={local.items.length > 0} fallback={local.renderEmptyState?.()}>
|
|
333
|
+
<For each={local.items}>{(item) => props.children(item)}</For>
|
|
335
334
|
</Show>
|
|
336
335
|
</SharedElementTransition>
|
|
337
336
|
</div>
|
|
@@ -340,21 +339,18 @@ export function TagList<T extends { id?: Key; key?: Key }>(props: TagListProps<T
|
|
|
340
339
|
);
|
|
341
340
|
}
|
|
342
341
|
|
|
343
|
-
// ============================================
|
|
344
|
-
// TAG COMPONENT
|
|
345
|
-
// ============================================
|
|
346
|
-
|
|
347
342
|
/**
|
|
348
343
|
* A Tag is an individual item within a TagList.
|
|
349
344
|
*/
|
|
350
345
|
export function Tag(props: TagProps): JSX.Element {
|
|
351
346
|
const [local, rest] = splitProps(props, [
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
347
|
+
"id",
|
|
348
|
+
"class",
|
|
349
|
+
"style",
|
|
350
|
+
"slot",
|
|
351
|
+
"isDisabled",
|
|
352
|
+
"textValue",
|
|
353
|
+
"onAction",
|
|
358
354
|
]);
|
|
359
355
|
|
|
360
356
|
const state = useContext(TagListStateContext);
|
|
@@ -366,17 +362,23 @@ export function Tag(props: TagProps): JSX.Element {
|
|
|
366
362
|
// Create tag accessibility props
|
|
367
363
|
const tagAria = createTag(
|
|
368
364
|
{
|
|
369
|
-
get key() {
|
|
370
|
-
|
|
371
|
-
|
|
365
|
+
get key() {
|
|
366
|
+
return local.id;
|
|
367
|
+
},
|
|
368
|
+
get isDisabled() {
|
|
369
|
+
return local.isDisabled || groupContext?.isDisabled;
|
|
370
|
+
},
|
|
371
|
+
get textValue() {
|
|
372
|
+
return local.textValue;
|
|
373
|
+
},
|
|
372
374
|
},
|
|
373
375
|
state!,
|
|
374
|
-
tagRef
|
|
376
|
+
tagRef,
|
|
375
377
|
);
|
|
376
378
|
|
|
377
379
|
const normalizedRemoveButtonProps = createMemo<Record<string, unknown>>(() => {
|
|
378
380
|
const raw = tagAria.removeButtonProps;
|
|
379
|
-
const rawHandler = typeof raw.onPress ===
|
|
381
|
+
const rawHandler = typeof raw.onPress === "function" ? (raw.onPress as () => void) : undefined;
|
|
380
382
|
return {
|
|
381
383
|
...raw,
|
|
382
384
|
onPress: () => {
|
|
@@ -389,41 +391,42 @@ export function Tag(props: TagProps): JSX.Element {
|
|
|
389
391
|
};
|
|
390
392
|
});
|
|
391
393
|
|
|
392
|
-
// Render props values
|
|
393
394
|
const renderValues = createMemo<TagRenderProps>(() => ({
|
|
394
395
|
isSelected: tagAria.isSelected,
|
|
395
396
|
isDisabled: tagAria.isDisabled,
|
|
396
397
|
isFocused: tagAria.isFocused,
|
|
397
398
|
isPressed: tagAria.isPressed,
|
|
398
399
|
allowsRemoving: tagAria.allowsRemoving,
|
|
399
|
-
selectionMode: state?.selectionMode() ??
|
|
400
|
+
selectionMode: state?.selectionMode() ?? "none",
|
|
400
401
|
removeButtonProps: normalizedRemoveButtonProps(),
|
|
401
402
|
}));
|
|
402
403
|
|
|
403
|
-
// Resolve render props
|
|
404
404
|
const renderProps = useRenderProps(
|
|
405
405
|
{
|
|
406
406
|
children: props.children,
|
|
407
407
|
class: local.class,
|
|
408
408
|
style: local.style,
|
|
409
|
-
defaultClassName:
|
|
409
|
+
defaultClassName: "solidaria-Tag",
|
|
410
410
|
},
|
|
411
|
-
renderValues
|
|
411
|
+
renderValues,
|
|
412
412
|
);
|
|
413
413
|
|
|
414
414
|
const selectionIndicatorContext = createMemo<SelectionIndicatorContextValue>(() => ({
|
|
415
415
|
isSelected: () => tagAria.isSelected,
|
|
416
416
|
}));
|
|
417
417
|
|
|
418
|
-
// Filter DOM props
|
|
419
418
|
const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
|
|
420
419
|
|
|
421
420
|
return (
|
|
422
421
|
<SelectionIndicatorContext.Provider value={selectionIndicatorContext()}>
|
|
423
422
|
<TagContext.Provider
|
|
424
423
|
value={{
|
|
425
|
-
get removeButtonProps() {
|
|
426
|
-
|
|
424
|
+
get removeButtonProps() {
|
|
425
|
+
return normalizedRemoveButtonProps();
|
|
426
|
+
},
|
|
427
|
+
get allowsRemoving() {
|
|
428
|
+
return tagAria.allowsRemoving;
|
|
429
|
+
},
|
|
427
430
|
}}
|
|
428
431
|
>
|
|
429
432
|
<div
|
|
@@ -432,13 +435,23 @@ export function Tag(props: TagProps): JSX.Element {
|
|
|
432
435
|
{...tagAria.rowProps}
|
|
433
436
|
class={renderProps.class()}
|
|
434
437
|
style={renderProps.style()}
|
|
438
|
+
onClick={(event) => {
|
|
439
|
+
const rowClick = tagAria.rowProps.onClick;
|
|
440
|
+
if (typeof rowClick === "function") {
|
|
441
|
+
(rowClick as JSX.EventHandler<HTMLDivElement, MouseEvent>)(event);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if (!tagAria.isDisabled && !(event.target as Element | null)?.closest("button")) {
|
|
445
|
+
local.onAction?.(local.id);
|
|
446
|
+
}
|
|
447
|
+
}}
|
|
435
448
|
data-selected={dataAttr(tagAria.isSelected)}
|
|
436
449
|
data-disabled={dataAttr(tagAria.isDisabled)}
|
|
437
450
|
data-focused={dataAttr(tagAria.isFocused)}
|
|
438
451
|
data-pressed={dataAttr(tagAria.isPressed)}
|
|
439
452
|
data-allows-removing={dataAttr(tagAria.allowsRemoving)}
|
|
440
453
|
>
|
|
441
|
-
<div {...tagAria.gridCellProps} style={{ display:
|
|
454
|
+
<div {...tagAria.gridCellProps} style={{ display: "contents" }}>
|
|
442
455
|
{renderProps.renderChildren()}
|
|
443
456
|
</div>
|
|
444
457
|
</div>
|
|
@@ -447,10 +460,6 @@ export function Tag(props: TagProps): JSX.Element {
|
|
|
447
460
|
);
|
|
448
461
|
}
|
|
449
462
|
|
|
450
|
-
// ============================================
|
|
451
|
-
// TAG REMOVE BUTTON COMPONENT
|
|
452
|
-
// ============================================
|
|
453
|
-
|
|
454
463
|
export interface TagRemoveButtonProps {
|
|
455
464
|
/** The children of the button (usually an X icon). */
|
|
456
465
|
children?: JSX.Element;
|
|
@@ -471,36 +480,40 @@ export function TagRemoveButton(props: TagRemoveButtonProps): JSX.Element {
|
|
|
471
480
|
const getRemoveButtonProps = () => props.buttonProps ?? tagContext?.removeButtonProps ?? {};
|
|
472
481
|
const getIsDisabled = () => Boolean(getRemoveButtonProps().isDisabled);
|
|
473
482
|
const rawId = getRemoveButtonProps().id;
|
|
474
|
-
const rawAriaLabel = getRemoveButtonProps()[
|
|
475
|
-
const rawAriaLabelledBy = getRemoveButtonProps()[
|
|
476
|
-
const buttonId: string | undefined = typeof rawId ===
|
|
477
|
-
const ariaLabel: string = typeof rawAriaLabel ===
|
|
478
|
-
const ariaLabelledBy: string | undefined =
|
|
483
|
+
const rawAriaLabel = getRemoveButtonProps()["aria-label"];
|
|
484
|
+
const rawAriaLabelledBy = getRemoveButtonProps()["aria-labelledby"];
|
|
485
|
+
const buttonId: string | undefined = typeof rawId === "string" ? rawId : undefined;
|
|
486
|
+
const ariaLabel: string = typeof rawAriaLabel === "string" ? rawAriaLabel : "Remove";
|
|
487
|
+
const ariaLabelledBy: string | undefined =
|
|
488
|
+
typeof rawAriaLabelledBy === "string" ? rawAriaLabelledBy : undefined;
|
|
479
489
|
|
|
480
490
|
const handleClick: JSX.EventHandler<HTMLButtonElement, MouseEvent> = (event) => {
|
|
481
491
|
event.stopPropagation();
|
|
482
492
|
const handler = getRemoveButtonProps().onPress;
|
|
483
|
-
if (typeof handler ===
|
|
493
|
+
if (typeof handler === "function" && !getIsDisabled()) {
|
|
484
494
|
(handler as () => void)();
|
|
485
495
|
}
|
|
486
496
|
};
|
|
497
|
+
const stopRowPress: JSX.EventHandler<HTMLButtonElement, PointerEvent> = (event) => {
|
|
498
|
+
event.stopPropagation();
|
|
499
|
+
};
|
|
487
500
|
|
|
488
501
|
return (
|
|
489
502
|
<button
|
|
490
503
|
type="button"
|
|
491
|
-
class={props.class ??
|
|
504
|
+
class={props.class ?? "solidaria-TagRemoveButton"}
|
|
492
505
|
style={props.style}
|
|
493
506
|
id={buttonId}
|
|
494
507
|
aria-label={ariaLabel}
|
|
495
508
|
aria-labelledby={ariaLabelledBy}
|
|
496
509
|
disabled={getIsDisabled()}
|
|
497
510
|
data-allows-removing={dataAttr(tagContext?.allowsRemoving ?? false)}
|
|
511
|
+
onPointerDown={stopRowPress}
|
|
498
512
|
onClick={handleClick}
|
|
499
513
|
>
|
|
500
|
-
{props.children ??
|
|
514
|
+
{props.children ?? "×"}
|
|
501
515
|
</button>
|
|
502
516
|
);
|
|
503
517
|
}
|
|
504
518
|
|
|
505
|
-
// Re-export types
|
|
506
519
|
export type { Key, SelectionMode, SelectionBehavior };
|
package/src/Text.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type JSX, createContext } from
|
|
2
|
-
import type { SlotProps } from
|
|
1
|
+
import { type JSX, createContext } from "solid-js";
|
|
2
|
+
import type { SlotProps } from "./utils";
|
|
3
3
|
|
|
4
4
|
export interface TextProps extends SlotProps {
|
|
5
5
|
children?: JSX.Element;
|
|
@@ -11,7 +11,7 @@ export const TextContext = createContext<null>(null);
|
|
|
11
11
|
|
|
12
12
|
export function Text(props: TextProps): JSX.Element {
|
|
13
13
|
return (
|
|
14
|
-
<span class={props.class ??
|
|
14
|
+
<span class={props.class ?? "solidaria-Text"} style={props.style}>
|
|
15
15
|
{props.children}
|
|
16
16
|
</span>
|
|
17
17
|
);
|