@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
|
@@ -65,15 +65,20 @@ export interface VirtualizerLayoutInfoContext {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export interface VirtualizerDropTarget {
|
|
68
|
-
type:
|
|
68
|
+
type: "item" | "root";
|
|
69
69
|
index: number;
|
|
70
|
-
position:
|
|
70
|
+
position: "before" | "on" | "after";
|
|
71
71
|
key?: string | number;
|
|
72
72
|
parentKey?: string | number | null;
|
|
73
73
|
level?: number;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
function clampRange(
|
|
76
|
+
function clampRange(
|
|
77
|
+
itemCount: number,
|
|
78
|
+
start: number,
|
|
79
|
+
end: number,
|
|
80
|
+
itemSize: number,
|
|
81
|
+
): VirtualizerVisibleRange {
|
|
77
82
|
const safeStart = Math.max(0, Math.min(start, itemCount));
|
|
78
83
|
const safeEnd = Math.max(safeStart, Math.min(end, itemCount));
|
|
79
84
|
return {
|
|
@@ -89,7 +94,7 @@ export function calculateLinearVisibleRange(
|
|
|
89
94
|
scrollOffset: number,
|
|
90
95
|
viewportSize: number,
|
|
91
96
|
itemSize: number,
|
|
92
|
-
overscan: number
|
|
97
|
+
overscan: number,
|
|
93
98
|
): VirtualizerVisibleRange {
|
|
94
99
|
if (itemCount <= 0) return { start: 0, end: 0, offsetTop: 0, offsetBottom: 0 };
|
|
95
100
|
const safeItemSize = Math.max(1, itemSize);
|
|
@@ -103,21 +108,21 @@ export function calculateLinearVisibleRange(
|
|
|
103
108
|
export class ListLayout {
|
|
104
109
|
getVisibleRange(
|
|
105
110
|
ctx: VirtualizerRangeContext,
|
|
106
|
-
options?: DefaultVirtualizerLayoutOptions
|
|
111
|
+
options?: DefaultVirtualizerLayoutOptions,
|
|
107
112
|
): VirtualizerVisibleRange {
|
|
108
113
|
return calculateLinearVisibleRange(
|
|
109
114
|
ctx.itemCount,
|
|
110
115
|
ctx.scrollOffset,
|
|
111
116
|
ctx.viewportSize,
|
|
112
117
|
options?.itemSize ?? 40,
|
|
113
|
-
options?.overscan ?? ctx.overscan
|
|
118
|
+
options?.overscan ?? ctx.overscan,
|
|
114
119
|
);
|
|
115
120
|
}
|
|
116
121
|
|
|
117
122
|
getLayoutInfo(
|
|
118
123
|
index: number,
|
|
119
124
|
context: VirtualizerLayoutInfoContext,
|
|
120
|
-
options?: DefaultVirtualizerLayoutOptions
|
|
125
|
+
options?: DefaultVirtualizerLayoutOptions,
|
|
121
126
|
): LayoutInfo {
|
|
122
127
|
const itemHeight = Math.max(1, options?.itemSize ?? 40);
|
|
123
128
|
return {
|
|
@@ -135,35 +140,34 @@ export class ListLayout {
|
|
|
135
140
|
getDropTargetFromPoint(
|
|
136
141
|
point: Point,
|
|
137
142
|
itemCount: number,
|
|
138
|
-
options?: DefaultVirtualizerLayoutOptions
|
|
143
|
+
options?: DefaultVirtualizerLayoutOptions,
|
|
139
144
|
): VirtualizerDropTarget | null {
|
|
140
|
-
if (itemCount <= 0) return { type:
|
|
145
|
+
if (itemCount <= 0) return { type: "root", index: -1, position: "on" };
|
|
141
146
|
const itemHeight = Math.max(1, options?.itemSize ?? 40);
|
|
142
147
|
if (point.y < 0) {
|
|
143
|
-
return { type:
|
|
148
|
+
return { type: "item", index: 0, position: "before" };
|
|
144
149
|
}
|
|
145
150
|
const totalHeight = itemCount * itemHeight;
|
|
146
151
|
if (point.y >= totalHeight) {
|
|
147
|
-
return { type:
|
|
152
|
+
return { type: "item", index: itemCount - 1, position: "after" };
|
|
148
153
|
}
|
|
149
154
|
const rawIndex = Math.floor(point.y / itemHeight);
|
|
150
155
|
const index = Math.max(0, Math.min(rawIndex, itemCount - 1));
|
|
151
156
|
const offsetWithinItem = Math.max(0, point.y - index * itemHeight);
|
|
152
157
|
const threshold = itemHeight / 3;
|
|
153
|
-
const position: VirtualizerDropTarget[
|
|
154
|
-
offsetWithinItem < threshold
|
|
155
|
-
|
|
156
|
-
: offsetWithinItem > threshold * 2
|
|
157
|
-
? 'after'
|
|
158
|
-
: 'on';
|
|
159
|
-
return { type: 'item', index, position };
|
|
158
|
+
const position: VirtualizerDropTarget["position"] =
|
|
159
|
+
offsetWithinItem < threshold ? "before" : offsetWithinItem > threshold * 2 ? "after" : "on";
|
|
160
|
+
return { type: "item", index, position };
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
export class TableLayout extends ListLayout {}
|
|
164
165
|
|
|
165
166
|
export class GridLayout {
|
|
166
|
-
getVisibleRange(
|
|
167
|
+
getVisibleRange(
|
|
168
|
+
ctx: VirtualizerRangeContext,
|
|
169
|
+
options?: GridLayoutOptions,
|
|
170
|
+
): VirtualizerVisibleRange {
|
|
167
171
|
if (ctx.itemCount <= 0) return { start: 0, end: 0, offsetTop: 0, offsetBottom: 0 };
|
|
168
172
|
const rowHeight = Math.max(1, options?.rowHeight ?? options?.itemSize ?? 40);
|
|
169
173
|
const columns = Math.max(1, options?.columnCount ?? 1);
|
|
@@ -186,7 +190,11 @@ export class GridLayout {
|
|
|
186
190
|
return { start, end, offsetTop, offsetBottom };
|
|
187
191
|
}
|
|
188
192
|
|
|
189
|
-
getLayoutInfo(
|
|
193
|
+
getLayoutInfo(
|
|
194
|
+
index: number,
|
|
195
|
+
context: VirtualizerLayoutInfoContext,
|
|
196
|
+
options?: GridLayoutOptions,
|
|
197
|
+
): LayoutInfo {
|
|
190
198
|
const rowHeight = Math.max(1, options?.rowHeight ?? options?.itemSize ?? 40);
|
|
191
199
|
const columns = Math.max(1, options?.columnCount ?? 1);
|
|
192
200
|
const row = Math.floor(index / columns);
|
|
@@ -208,18 +216,18 @@ export class GridLayout {
|
|
|
208
216
|
getDropTargetFromPoint(
|
|
209
217
|
point: Point,
|
|
210
218
|
itemCount: number,
|
|
211
|
-
options?: GridLayoutOptions
|
|
219
|
+
options?: GridLayoutOptions,
|
|
212
220
|
): VirtualizerDropTarget | null {
|
|
213
|
-
if (itemCount <= 0) return { type:
|
|
221
|
+
if (itemCount <= 0) return { type: "root", index: -1, position: "on" };
|
|
214
222
|
const rowHeight = Math.max(1, options?.rowHeight ?? options?.itemSize ?? 40);
|
|
215
223
|
const columns = Math.max(1, options?.columnCount ?? 1);
|
|
216
224
|
const totalRows = Math.ceil(itemCount / columns);
|
|
217
225
|
const totalHeight = totalRows * rowHeight;
|
|
218
226
|
if (point.y < 0) {
|
|
219
|
-
return { type:
|
|
227
|
+
return { type: "item", index: 0, position: "before" };
|
|
220
228
|
}
|
|
221
229
|
if (point.y >= totalHeight) {
|
|
222
|
-
return { type:
|
|
230
|
+
return { type: "item", index: itemCount - 1, position: "after" };
|
|
223
231
|
}
|
|
224
232
|
const width = Math.max(1, options?.viewportWidth ?? 320);
|
|
225
233
|
const cellWidth = width / columns;
|
|
@@ -228,14 +236,17 @@ export class GridLayout {
|
|
|
228
236
|
const index = Math.max(0, Math.min(itemCount - 1, row * columns + col));
|
|
229
237
|
const withinRow = Math.max(0, point.y - row * rowHeight);
|
|
230
238
|
const threshold = rowHeight / 3;
|
|
231
|
-
const position: VirtualizerDropTarget[
|
|
232
|
-
withinRow < threshold ?
|
|
233
|
-
return { type:
|
|
239
|
+
const position: VirtualizerDropTarget["position"] =
|
|
240
|
+
withinRow < threshold ? "before" : withinRow > threshold * 2 ? "after" : "on";
|
|
241
|
+
return { type: "item", index, position };
|
|
234
242
|
}
|
|
235
243
|
}
|
|
236
244
|
|
|
237
245
|
export class WaterfallLayout extends GridLayout {
|
|
238
|
-
override getVisibleRange(
|
|
246
|
+
override getVisibleRange(
|
|
247
|
+
ctx: VirtualizerRangeContext,
|
|
248
|
+
options?: WaterfallLayoutOptions,
|
|
249
|
+
): VirtualizerVisibleRange {
|
|
239
250
|
const width = Math.max(1, options?.viewportWidth ?? 320);
|
|
240
251
|
const minColumnWidth = Math.max(1, options?.minColumnWidth ?? 200);
|
|
241
252
|
const gap = Math.max(0, options?.gap ?? 0);
|
|
@@ -243,7 +254,11 @@ export class WaterfallLayout extends GridLayout {
|
|
|
243
254
|
return super.getVisibleRange(ctx, { ...options, columnCount });
|
|
244
255
|
}
|
|
245
256
|
|
|
246
|
-
override getLayoutInfo(
|
|
257
|
+
override getLayoutInfo(
|
|
258
|
+
index: number,
|
|
259
|
+
context: VirtualizerLayoutInfoContext,
|
|
260
|
+
options?: WaterfallLayoutOptions,
|
|
261
|
+
): LayoutInfo {
|
|
247
262
|
const width = Math.max(1, options?.viewportWidth ?? context.viewportWidth);
|
|
248
263
|
const minColumnWidth = Math.max(1, options?.minColumnWidth ?? 200);
|
|
249
264
|
const gap = Math.max(0, options?.gap ?? 0);
|
|
@@ -254,7 +269,7 @@ export class WaterfallLayout extends GridLayout {
|
|
|
254
269
|
override getDropTargetFromPoint(
|
|
255
270
|
point: Point,
|
|
256
271
|
itemCount: number,
|
|
257
|
-
options?: WaterfallLayoutOptions
|
|
272
|
+
options?: WaterfallLayoutOptions,
|
|
258
273
|
): VirtualizerDropTarget | null {
|
|
259
274
|
const width = Math.max(1, options?.viewportWidth ?? 320);
|
|
260
275
|
const minColumnWidth = Math.max(1, options?.minColumnWidth ?? 200);
|
package/src/VisuallyHidden.tsx
CHANGED
|
@@ -5,13 +5,9 @@
|
|
|
5
5
|
* Port of react-aria's VisuallyHidden.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { type JSX, type ParentProps, splitProps } from
|
|
9
|
-
import { Dynamic } from
|
|
10
|
-
import { createVisuallyHidden, mergeProps } from
|
|
11
|
-
|
|
12
|
-
// ============================================
|
|
13
|
-
// TYPES
|
|
14
|
-
// ============================================
|
|
8
|
+
import { type JSX, type ParentProps, splitProps } from "solid-js";
|
|
9
|
+
import { Dynamic } from "solid-js/web";
|
|
10
|
+
import { createVisuallyHidden, mergeProps } from "@proyecto-viviana/solidaria";
|
|
15
11
|
|
|
16
12
|
export interface VisuallyHiddenProps extends ParentProps, JSX.HTMLAttributes<HTMLElement> {
|
|
17
13
|
/** The element type to render. @default 'span' */
|
|
@@ -22,33 +18,37 @@ export interface VisuallyHiddenProps extends ParentProps, JSX.HTMLAttributes<HTM
|
|
|
22
18
|
style?: JSX.CSSProperties;
|
|
23
19
|
}
|
|
24
20
|
|
|
25
|
-
// ============================================
|
|
26
|
-
// COMPONENT
|
|
27
|
-
// ============================================
|
|
28
|
-
|
|
29
21
|
/**
|
|
30
22
|
* VisuallyHidden hides its children visually, while keeping content visible to screen readers.
|
|
31
23
|
*/
|
|
32
24
|
export function VisuallyHidden(props: VisuallyHiddenProps): JSX.Element {
|
|
33
|
-
|
|
25
|
+
// Split children so the getter is not read once through `{...mergedProps()}`
|
|
26
|
+
// and again during explicit rendering. Hydration code is sensitive to that.
|
|
27
|
+
const [local, others] = splitProps(props, ["elementType", "isFocusable", "style", "children"]);
|
|
34
28
|
const { visuallyHiddenProps } = createVisuallyHidden(() => ({
|
|
35
29
|
style: local.style,
|
|
36
30
|
isFocusable: local.isFocusable,
|
|
37
31
|
}));
|
|
38
32
|
|
|
39
|
-
const elementType = () => local.elementType ?? 'span';
|
|
40
33
|
const mergedProps = () =>
|
|
41
34
|
mergeProps<Record<string, unknown>>(
|
|
42
35
|
others as unknown as Record<string, unknown>,
|
|
43
|
-
visuallyHiddenProps() as unknown as Record<string, unknown
|
|
36
|
+
visuallyHiddenProps() as unknown as Record<string, unknown>,
|
|
44
37
|
);
|
|
45
38
|
|
|
39
|
+
// elementType is read once (structural, not reactive). The default `span` is
|
|
40
|
+
// rendered as a static element rather than via `<Dynamic>`: a reactive
|
|
41
|
+
// `<Dynamic>` desyncs Solid's hydration markers, leaving the registry dirty so
|
|
42
|
+
// a later sibling re-render throws "template is not a function" in prod (and a
|
|
43
|
+
// hard hydration crash under solid-refresh in dev). `<Dynamic>` is reserved for
|
|
44
|
+
// an explicit custom elementType.
|
|
45
|
+
const tag = local.elementType ?? "span";
|
|
46
|
+
if (tag === "span") {
|
|
47
|
+
return <span {...mergedProps()}>{local.children}</span>;
|
|
48
|
+
}
|
|
46
49
|
return (
|
|
47
|
-
<Dynamic
|
|
48
|
-
|
|
49
|
-
{...mergedProps()}
|
|
50
|
-
>
|
|
51
|
-
{props.children}
|
|
50
|
+
<Dynamic component={tag} {...mergedProps()}>
|
|
51
|
+
{local.children}
|
|
52
52
|
</Dynamic>
|
|
53
53
|
);
|
|
54
54
|
}
|
package/src/contexts.ts
CHANGED
|
@@ -5,71 +5,63 @@
|
|
|
5
5
|
* Dialog, Modal, Popover, and Button components.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { createContext, useContext } from
|
|
9
|
-
import type { OverlayTriggerState as StatelyOverlayTriggerState } from
|
|
10
|
-
|
|
11
|
-
// ============================================
|
|
12
|
-
// OVERLAY TRIGGER STATE CONTEXT
|
|
13
|
-
// ============================================
|
|
8
|
+
import { createContext, useContext } from "solid-js";
|
|
9
|
+
import type { OverlayTriggerState as StatelyOverlayTriggerState } from "@proyecto-viviana/solid-stately";
|
|
14
10
|
|
|
15
11
|
export interface OverlayTriggerState {
|
|
16
|
-
isOpen: boolean
|
|
17
|
-
open: () => void
|
|
18
|
-
close: () => void
|
|
19
|
-
toggle: () => void
|
|
12
|
+
isOpen: boolean;
|
|
13
|
+
open: () => void;
|
|
14
|
+
close: () => void;
|
|
15
|
+
toggle: () => void;
|
|
20
16
|
}
|
|
21
17
|
|
|
22
|
-
export const OverlayTriggerStateContext = createContext<OverlayTriggerState | null>(null)
|
|
18
|
+
export const OverlayTriggerStateContext = createContext<OverlayTriggerState | null>(null);
|
|
23
19
|
|
|
24
20
|
/**
|
|
25
21
|
* Hook to access the overlay trigger state from context.
|
|
26
22
|
*/
|
|
27
23
|
export function useOverlayTriggerState(): OverlayTriggerState | null {
|
|
28
|
-
return useContext(OverlayTriggerStateContext)
|
|
24
|
+
return useContext(OverlayTriggerStateContext);
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
// ============================================
|
|
32
|
-
// DIALOG TRIGGER CONTEXT
|
|
33
|
-
// ============================================
|
|
34
|
-
|
|
35
27
|
export interface DialogTriggerContextValue {
|
|
36
|
-
state: StatelyOverlayTriggerState
|
|
37
|
-
triggerRef: () => HTMLElement | null
|
|
38
|
-
setTriggerRef: (el: HTMLElement | null) => void
|
|
39
|
-
triggerId: string
|
|
28
|
+
state: StatelyOverlayTriggerState;
|
|
29
|
+
triggerRef: () => HTMLElement | null;
|
|
30
|
+
setTriggerRef: (el: HTMLElement | null) => void;
|
|
31
|
+
triggerId: string;
|
|
32
|
+
triggerProps?: Record<string, unknown>;
|
|
33
|
+
overlayProps?: Record<string, unknown>;
|
|
40
34
|
}
|
|
41
35
|
|
|
42
|
-
export const DialogTriggerContext = createContext<DialogTriggerContextValue | null>(null)
|
|
36
|
+
export const DialogTriggerContext = createContext<DialogTriggerContextValue | null>(null);
|
|
43
37
|
|
|
44
38
|
/**
|
|
45
39
|
* Hook to access the dialog trigger state from context.
|
|
46
40
|
*/
|
|
47
41
|
export function useDialogTrigger(): DialogTriggerContextValue | null {
|
|
48
|
-
return useContext(DialogTriggerContext)
|
|
42
|
+
return useContext(DialogTriggerContext);
|
|
49
43
|
}
|
|
50
44
|
|
|
51
|
-
// ============================================
|
|
52
|
-
// POPOVER TRIGGER CONTEXT
|
|
53
|
-
// ============================================
|
|
54
|
-
|
|
55
45
|
export interface PopoverTriggerContextValue {
|
|
56
46
|
state: {
|
|
57
|
-
isOpen: () => boolean
|
|
58
|
-
open: () => void
|
|
59
|
-
close: () => void
|
|
60
|
-
toggle: () => void
|
|
61
|
-
}
|
|
62
|
-
triggerRef: () => HTMLElement | null
|
|
63
|
-
setTriggerRef: (el: HTMLElement | null) => void
|
|
64
|
-
triggerId: string
|
|
65
|
-
|
|
47
|
+
isOpen: () => boolean;
|
|
48
|
+
open: () => void;
|
|
49
|
+
close: () => void;
|
|
50
|
+
toggle: () => void;
|
|
51
|
+
};
|
|
52
|
+
triggerRef: () => HTMLElement | null;
|
|
53
|
+
setTriggerRef: (el: HTMLElement | null) => void;
|
|
54
|
+
triggerId: string;
|
|
55
|
+
triggerProps?: Record<string, unknown>;
|
|
56
|
+
overlayProps?: Record<string, unknown>;
|
|
57
|
+
trigger: string;
|
|
66
58
|
}
|
|
67
59
|
|
|
68
|
-
export const PopoverTriggerContext = createContext<PopoverTriggerContextValue | null>(null)
|
|
60
|
+
export const PopoverTriggerContext = createContext<PopoverTriggerContextValue | null>(null);
|
|
69
61
|
|
|
70
62
|
/**
|
|
71
63
|
* Hook to access the popover trigger state from context.
|
|
72
64
|
*/
|
|
73
65
|
export function usePopoverTrigger(): PopoverTriggerContextValue | null {
|
|
74
|
-
return useContext(PopoverTriggerContext)
|
|
66
|
+
return useContext(PopoverTriggerContext);
|
|
75
67
|
}
|