@proyecto-viviana/solidaria-components 0.2.4 → 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
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout primitives for solidaria-components Virtualizer.
|
|
3
|
+
*
|
|
4
|
+
* These are lightweight parity contracts inspired by RAC virtualizer layout APIs.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface Point {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Rect {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Size {
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface LayoutInfo {
|
|
25
|
+
key: string | number;
|
|
26
|
+
index: number;
|
|
27
|
+
rect: Rect;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface VirtualizerVisibleRange {
|
|
31
|
+
start: number;
|
|
32
|
+
end: number;
|
|
33
|
+
offsetTop: number;
|
|
34
|
+
offsetBottom: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface VirtualizerRangeContext {
|
|
38
|
+
itemCount: number;
|
|
39
|
+
scrollOffset: number;
|
|
40
|
+
viewportSize: number;
|
|
41
|
+
overscan: number;
|
|
42
|
+
viewportWidth?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface DefaultVirtualizerLayoutOptions {
|
|
46
|
+
itemSize?: number;
|
|
47
|
+
overscan?: number;
|
|
48
|
+
viewportSize?: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface GridLayoutOptions extends DefaultVirtualizerLayoutOptions {
|
|
52
|
+
rowHeight?: number;
|
|
53
|
+
columnCount?: number;
|
|
54
|
+
viewportWidth?: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface WaterfallLayoutOptions extends GridLayoutOptions {
|
|
58
|
+
minColumnWidth?: number;
|
|
59
|
+
viewportWidth?: number;
|
|
60
|
+
gap?: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface VirtualizerLayoutInfoContext {
|
|
64
|
+
viewportWidth: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface VirtualizerDropTarget {
|
|
68
|
+
type: 'item' | 'root';
|
|
69
|
+
index: number;
|
|
70
|
+
position: 'before' | 'on' | 'after';
|
|
71
|
+
key?: string | number;
|
|
72
|
+
parentKey?: string | number | null;
|
|
73
|
+
level?: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function clampRange(itemCount: number, start: number, end: number, itemSize: number): VirtualizerVisibleRange {
|
|
77
|
+
const safeStart = Math.max(0, Math.min(start, itemCount));
|
|
78
|
+
const safeEnd = Math.max(safeStart, Math.min(end, itemCount));
|
|
79
|
+
return {
|
|
80
|
+
start: safeStart,
|
|
81
|
+
end: safeEnd,
|
|
82
|
+
offsetTop: safeStart * itemSize,
|
|
83
|
+
offsetBottom: Math.max(0, (itemCount - safeEnd) * itemSize),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function calculateLinearVisibleRange(
|
|
88
|
+
itemCount: number,
|
|
89
|
+
scrollOffset: number,
|
|
90
|
+
viewportSize: number,
|
|
91
|
+
itemSize: number,
|
|
92
|
+
overscan: number
|
|
93
|
+
): VirtualizerVisibleRange {
|
|
94
|
+
if (itemCount <= 0) return { start: 0, end: 0, offsetTop: 0, offsetBottom: 0 };
|
|
95
|
+
const safeItemSize = Math.max(1, itemSize);
|
|
96
|
+
const safeViewport = Math.max(1, viewportSize);
|
|
97
|
+
const safeOverscan = Math.max(0, overscan);
|
|
98
|
+
const start = Math.floor(scrollOffset / safeItemSize) - safeOverscan;
|
|
99
|
+
const visibleCount = Math.ceil(safeViewport / safeItemSize) + safeOverscan * 2;
|
|
100
|
+
return clampRange(itemCount, start, start + visibleCount, safeItemSize);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export class ListLayout {
|
|
104
|
+
getVisibleRange(
|
|
105
|
+
ctx: VirtualizerRangeContext,
|
|
106
|
+
options?: DefaultVirtualizerLayoutOptions
|
|
107
|
+
): VirtualizerVisibleRange {
|
|
108
|
+
return calculateLinearVisibleRange(
|
|
109
|
+
ctx.itemCount,
|
|
110
|
+
ctx.scrollOffset,
|
|
111
|
+
ctx.viewportSize,
|
|
112
|
+
options?.itemSize ?? 40,
|
|
113
|
+
options?.overscan ?? ctx.overscan
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
getLayoutInfo(
|
|
118
|
+
index: number,
|
|
119
|
+
context: VirtualizerLayoutInfoContext,
|
|
120
|
+
options?: DefaultVirtualizerLayoutOptions
|
|
121
|
+
): LayoutInfo {
|
|
122
|
+
const itemHeight = Math.max(1, options?.itemSize ?? 40);
|
|
123
|
+
return {
|
|
124
|
+
key: String(index),
|
|
125
|
+
index,
|
|
126
|
+
rect: {
|
|
127
|
+
x: 0,
|
|
128
|
+
y: index * itemHeight,
|
|
129
|
+
width: Math.max(0, context.viewportWidth),
|
|
130
|
+
height: itemHeight,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
getDropTargetFromPoint(
|
|
136
|
+
point: Point,
|
|
137
|
+
itemCount: number,
|
|
138
|
+
options?: DefaultVirtualizerLayoutOptions
|
|
139
|
+
): VirtualizerDropTarget | null {
|
|
140
|
+
if (itemCount <= 0) return { type: 'root', index: -1, position: 'on' };
|
|
141
|
+
const itemHeight = Math.max(1, options?.itemSize ?? 40);
|
|
142
|
+
if (point.y < 0) {
|
|
143
|
+
return { type: 'item', index: 0, position: 'before' };
|
|
144
|
+
}
|
|
145
|
+
const totalHeight = itemCount * itemHeight;
|
|
146
|
+
if (point.y >= totalHeight) {
|
|
147
|
+
return { type: 'item', index: itemCount - 1, position: 'after' };
|
|
148
|
+
}
|
|
149
|
+
const rawIndex = Math.floor(point.y / itemHeight);
|
|
150
|
+
const index = Math.max(0, Math.min(rawIndex, itemCount - 1));
|
|
151
|
+
const offsetWithinItem = Math.max(0, point.y - index * itemHeight);
|
|
152
|
+
const threshold = itemHeight / 3;
|
|
153
|
+
const position: VirtualizerDropTarget['position'] =
|
|
154
|
+
offsetWithinItem < threshold
|
|
155
|
+
? 'before'
|
|
156
|
+
: offsetWithinItem > threshold * 2
|
|
157
|
+
? 'after'
|
|
158
|
+
: 'on';
|
|
159
|
+
return { type: 'item', index, position };
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export class TableLayout extends ListLayout {}
|
|
164
|
+
|
|
165
|
+
export class GridLayout {
|
|
166
|
+
getVisibleRange(ctx: VirtualizerRangeContext, options?: GridLayoutOptions): VirtualizerVisibleRange {
|
|
167
|
+
if (ctx.itemCount <= 0) return { start: 0, end: 0, offsetTop: 0, offsetBottom: 0 };
|
|
168
|
+
const rowHeight = Math.max(1, options?.rowHeight ?? options?.itemSize ?? 40);
|
|
169
|
+
const columns = Math.max(1, options?.columnCount ?? 1);
|
|
170
|
+
const safeViewport = Math.max(1, ctx.viewportSize);
|
|
171
|
+
const safeOverscan = Math.max(0, options?.overscan ?? ctx.overscan);
|
|
172
|
+
|
|
173
|
+
const startRow = Math.max(0, Math.floor(ctx.scrollOffset / rowHeight) - safeOverscan);
|
|
174
|
+
const visibleRows = Math.ceil(safeViewport / rowHeight) + safeOverscan * 2;
|
|
175
|
+
const endRow = startRow + visibleRows;
|
|
176
|
+
|
|
177
|
+
const start = startRow * columns;
|
|
178
|
+
const end = Math.min(ctx.itemCount, endRow * columns);
|
|
179
|
+
|
|
180
|
+
const totalRows = Math.ceil(ctx.itemCount / columns);
|
|
181
|
+
const clampedStartRow = Math.floor(start / columns);
|
|
182
|
+
const renderedRows = Math.ceil((end - start) / columns);
|
|
183
|
+
const offsetTop = clampedStartRow * rowHeight;
|
|
184
|
+
const offsetBottom = Math.max(0, (totalRows - clampedStartRow - renderedRows) * rowHeight);
|
|
185
|
+
|
|
186
|
+
return { start, end, offsetTop, offsetBottom };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
getLayoutInfo(index: number, context: VirtualizerLayoutInfoContext, options?: GridLayoutOptions): LayoutInfo {
|
|
190
|
+
const rowHeight = Math.max(1, options?.rowHeight ?? options?.itemSize ?? 40);
|
|
191
|
+
const columns = Math.max(1, options?.columnCount ?? 1);
|
|
192
|
+
const row = Math.floor(index / columns);
|
|
193
|
+
const col = index % columns;
|
|
194
|
+
const width = Math.max(1, context.viewportWidth);
|
|
195
|
+
const cellWidth = Math.floor(width / columns);
|
|
196
|
+
return {
|
|
197
|
+
key: String(index),
|
|
198
|
+
index,
|
|
199
|
+
rect: {
|
|
200
|
+
x: col * cellWidth,
|
|
201
|
+
y: row * rowHeight,
|
|
202
|
+
width: cellWidth,
|
|
203
|
+
height: rowHeight,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
getDropTargetFromPoint(
|
|
209
|
+
point: Point,
|
|
210
|
+
itemCount: number,
|
|
211
|
+
options?: GridLayoutOptions
|
|
212
|
+
): VirtualizerDropTarget | null {
|
|
213
|
+
if (itemCount <= 0) return { type: 'root', index: -1, position: 'on' };
|
|
214
|
+
const rowHeight = Math.max(1, options?.rowHeight ?? options?.itemSize ?? 40);
|
|
215
|
+
const columns = Math.max(1, options?.columnCount ?? 1);
|
|
216
|
+
const totalRows = Math.ceil(itemCount / columns);
|
|
217
|
+
const totalHeight = totalRows * rowHeight;
|
|
218
|
+
if (point.y < 0) {
|
|
219
|
+
return { type: 'item', index: 0, position: 'before' };
|
|
220
|
+
}
|
|
221
|
+
if (point.y >= totalHeight) {
|
|
222
|
+
return { type: 'item', index: itemCount - 1, position: 'after' };
|
|
223
|
+
}
|
|
224
|
+
const width = Math.max(1, options?.viewportWidth ?? 320);
|
|
225
|
+
const cellWidth = width / columns;
|
|
226
|
+
const row = Math.max(0, Math.floor(point.y / rowHeight));
|
|
227
|
+
const col = Math.max(0, Math.min(columns - 1, Math.floor(Math.max(0, point.x) / cellWidth)));
|
|
228
|
+
const index = Math.max(0, Math.min(itemCount - 1, row * columns + col));
|
|
229
|
+
const withinRow = Math.max(0, point.y - row * rowHeight);
|
|
230
|
+
const threshold = rowHeight / 3;
|
|
231
|
+
const position: VirtualizerDropTarget['position'] =
|
|
232
|
+
withinRow < threshold ? 'before' : withinRow > threshold * 2 ? 'after' : 'on';
|
|
233
|
+
return { type: 'item', index, position };
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export class WaterfallLayout extends GridLayout {
|
|
238
|
+
override getVisibleRange(ctx: VirtualizerRangeContext, options?: WaterfallLayoutOptions): VirtualizerVisibleRange {
|
|
239
|
+
const width = Math.max(1, options?.viewportWidth ?? 320);
|
|
240
|
+
const minColumnWidth = Math.max(1, options?.minColumnWidth ?? 200);
|
|
241
|
+
const gap = Math.max(0, options?.gap ?? 0);
|
|
242
|
+
const columnCount = Math.max(1, Math.floor((width + gap) / (minColumnWidth + gap)));
|
|
243
|
+
return super.getVisibleRange(ctx, { ...options, columnCount });
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
override getLayoutInfo(index: number, context: VirtualizerLayoutInfoContext, options?: WaterfallLayoutOptions): LayoutInfo {
|
|
247
|
+
const width = Math.max(1, options?.viewportWidth ?? context.viewportWidth);
|
|
248
|
+
const minColumnWidth = Math.max(1, options?.minColumnWidth ?? 200);
|
|
249
|
+
const gap = Math.max(0, options?.gap ?? 0);
|
|
250
|
+
const columnCount = Math.max(1, Math.floor((width + gap) / (minColumnWidth + gap)));
|
|
251
|
+
return super.getLayoutInfo(index, context, { ...options, columnCount });
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
override getDropTargetFromPoint(
|
|
255
|
+
point: Point,
|
|
256
|
+
itemCount: number,
|
|
257
|
+
options?: WaterfallLayoutOptions
|
|
258
|
+
): VirtualizerDropTarget | null {
|
|
259
|
+
const width = Math.max(1, options?.viewportWidth ?? 320);
|
|
260
|
+
const minColumnWidth = Math.max(1, options?.minColumnWidth ?? 200);
|
|
261
|
+
const gap = Math.max(0, options?.gap ?? 0);
|
|
262
|
+
const columnCount = Math.max(1, Math.floor((width + gap) / (minColumnWidth + gap)));
|
|
263
|
+
return super.getDropTargetFromPoint(point, itemCount, { ...options, columnCount });
|
|
264
|
+
}
|
|
265
|
+
}
|
package/src/VisuallyHidden.tsx
CHANGED
|
@@ -7,35 +7,21 @@
|
|
|
7
7
|
|
|
8
8
|
import { type JSX, type ParentProps, splitProps } from 'solid-js';
|
|
9
9
|
import { Dynamic } from 'solid-js/web';
|
|
10
|
+
import { createVisuallyHidden, mergeProps } from '@proyecto-viviana/solidaria';
|
|
10
11
|
|
|
11
12
|
// ============================================
|
|
12
13
|
// TYPES
|
|
13
14
|
// ============================================
|
|
14
15
|
|
|
15
|
-
export interface VisuallyHiddenProps extends ParentProps {
|
|
16
|
+
export interface VisuallyHiddenProps extends ParentProps, JSX.HTMLAttributes<HTMLElement> {
|
|
16
17
|
/** The element type to render. @default 'span' */
|
|
17
18
|
elementType?: keyof JSX.IntrinsicElements;
|
|
18
19
|
/** Whether the element should be focusable when focused. */
|
|
19
20
|
isFocusable?: boolean;
|
|
21
|
+
/** Inline style object merged with visually hidden styles. */
|
|
22
|
+
style?: JSX.CSSProperties;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
// ============================================
|
|
23
|
-
// STYLES
|
|
24
|
-
// ============================================
|
|
25
|
-
|
|
26
|
-
const visuallyHiddenStyles: JSX.CSSProperties = {
|
|
27
|
-
border: '0',
|
|
28
|
-
clip: 'rect(0 0 0 0)',
|
|
29
|
-
'clip-path': 'inset(50%)',
|
|
30
|
-
height: '1px',
|
|
31
|
-
margin: '-1px',
|
|
32
|
-
overflow: 'hidden',
|
|
33
|
-
padding: '0',
|
|
34
|
-
position: 'absolute',
|
|
35
|
-
width: '1px',
|
|
36
|
-
'white-space': 'nowrap',
|
|
37
|
-
};
|
|
38
|
-
|
|
39
25
|
// ============================================
|
|
40
26
|
// COMPONENT
|
|
41
27
|
// ============================================
|
|
@@ -44,15 +30,23 @@ const visuallyHiddenStyles: JSX.CSSProperties = {
|
|
|
44
30
|
* VisuallyHidden hides its children visually, while keeping content visible to screen readers.
|
|
45
31
|
*/
|
|
46
32
|
export function VisuallyHidden(props: VisuallyHiddenProps): JSX.Element {
|
|
47
|
-
const [local, others] = splitProps(props, ['elementType', 'isFocusable']);
|
|
33
|
+
const [local, others] = splitProps(props, ['elementType', 'isFocusable', 'style']);
|
|
34
|
+
const { visuallyHiddenProps } = createVisuallyHidden(() => ({
|
|
35
|
+
style: local.style,
|
|
36
|
+
isFocusable: local.isFocusable,
|
|
37
|
+
}));
|
|
48
38
|
|
|
49
39
|
const elementType = () => local.elementType ?? 'span';
|
|
40
|
+
const mergedProps = () =>
|
|
41
|
+
mergeProps<Record<string, unknown>>(
|
|
42
|
+
others as unknown as Record<string, unknown>,
|
|
43
|
+
visuallyHiddenProps() as unknown as Record<string, unknown>
|
|
44
|
+
);
|
|
50
45
|
|
|
51
46
|
return (
|
|
52
47
|
<Dynamic
|
|
53
48
|
component={elementType()}
|
|
54
|
-
|
|
55
|
-
{...others}
|
|
49
|
+
{...mergedProps()}
|
|
56
50
|
>
|
|
57
51
|
{props.children}
|
|
58
52
|
</Dynamic>
|
package/src/contexts.ts
CHANGED
|
@@ -35,6 +35,7 @@ export function useOverlayTriggerState(): OverlayTriggerState | null {
|
|
|
35
35
|
export interface DialogTriggerContextValue {
|
|
36
36
|
state: StatelyOverlayTriggerState
|
|
37
37
|
triggerRef: () => HTMLElement | null
|
|
38
|
+
setTriggerRef: (el: HTMLElement | null) => void
|
|
38
39
|
triggerId: string
|
|
39
40
|
}
|
|
40
41
|
|