ropav 0.4.0 → 0.5.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/dist/components/autocomplete/autocomplete-root.js +3 -1
- package/dist/components/autocomplete/index.d.ts +3 -0
- package/dist/components/breadcrumbs/breadcrumbs-item.js +1 -0
- package/dist/components/breadcrumbs/index.d.ts +1 -0
- package/dist/components/calendar/index.d.ts +5 -3
- package/dist/components/calendar-year-picker/index.d.ts +4 -2
- package/dist/components/checkbox/checkbox-content.js +1 -1
- package/dist/components/color-field/index.d.ts +1 -0
- package/dist/components/color-input-group/color-input-group-root.js +2 -0
- package/dist/components/color-input-group/color-input-group.types.d.ts +2 -0
- package/dist/components/color-input-group/index.d.ts +2 -0
- package/dist/components/combo-box/combo-box-root.js +9 -2
- package/dist/components/combo-box/combo-box.types.d.ts +3 -0
- package/dist/components/combo-box/index.d.ts +3 -0
- package/dist/components/date-field/index.d.ts +1 -0
- package/dist/components/date-input-group/date-input-group-root.js +2 -0
- package/dist/components/date-input-group/date-input-group-segment.js +1 -1
- package/dist/components/date-input-group/date-input-group.types.d.ts +2 -0
- package/dist/{composables → components/date-input-group}/use-date-segment.d.ts +2 -2
- package/dist/{composables → components/date-input-group}/use-date-segment.js +9 -9
- package/dist/components/date-range-picker/date-range-picker-root.js +1 -1
- package/dist/components/date-range-picker/index.d.ts +15 -14
- package/dist/{composables → components/date-range-picker}/use-date-range-picker.d.ts +7 -7
- package/dist/{composables → components/date-range-picker}/use-date-range-picker.js +10 -10
- package/dist/components/drawer/drawer-dialog.js +1 -1
- package/dist/{composables → components/drawer}/use-drawer-drag.d.ts +1 -1
- package/dist/{composables → components/drawer}/use-drawer-drag.js +1 -1
- package/dist/components/dropdown/dropdown-menu.js +1 -0
- package/dist/components/dropdown/dropdown-submenu-trigger.js +1 -1
- package/dist/components/dropdown/index.d.ts +4 -2
- package/dist/{composables → components/dropdown}/use-safely-mouse-to-submenu.js +1 -1
- package/dist/components/icons/icon-overlay-arrow.js +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/input-root.js +3 -0
- package/dist/components/input/input.types.d.ts +5 -0
- package/dist/components/input-group/index.d.ts +2 -0
- package/dist/components/input-group/input-group-root.js +3 -0
- package/dist/components/input-group/input-group.types.d.ts +5 -0
- package/dist/components/input-otp/index.d.ts +6 -4
- package/dist/components/link/index.d.ts +2 -0
- package/dist/components/link/link-root.js +22 -5
- package/dist/components/link/link.types.d.ts +14 -3
- package/dist/{composables → components/list-box}/drag-collection.d.ts +2 -2
- package/dist/{composables → components/list-box}/drag-collection.js +1 -1
- package/dist/components/list-box/index.d.ts +4 -0
- package/dist/components/list-box/list-box-root.js +53 -32
- package/dist/components/list-box/list-box.types.d.ts +2 -0
- package/dist/components/menu/index.d.ts +2 -0
- package/dist/components/menu/menu-root.js +5 -1
- package/dist/components/menu/menu.types.d.ts +3 -0
- package/dist/components/number-field/index.d.ts +3 -0
- package/dist/components/number-field/number-field-root.js +2 -0
- package/dist/components/number-field/number-field.types.d.ts +2 -0
- package/dist/components/overlay/overlay-arrow.js +64 -11
- package/dist/components/radio/radio-content.js +1 -1
- package/dist/components/range-calendar/index.d.ts +18 -15
- package/dist/components/router-provider/index.d.ts +5 -0
- package/dist/components/router-provider/index.js +3 -0
- package/dist/components/router-provider/router-provider.context.d.ts +40 -0
- package/dist/components/router-provider/router-provider.context.js +16 -0
- package/dist/components/router-provider/router-provider.d.ts +21 -0
- package/dist/components/router-provider/router-provider.js +22 -0
- package/dist/components/router-provider/router-provider.types.d.ts +23 -0
- package/dist/components/scroll-shadow/use-scroll-shadow.js +25 -1
- package/dist/components/search-field/index.d.ts +2 -0
- package/dist/components/search-field/search-field-root.js +3 -1
- package/dist/components/search-field/search-field.types.d.ts +2 -0
- package/dist/{composables → components/search-field}/use-search-field.d.ts +2 -2
- package/dist/{composables → components/search-field}/use-search-field.js +3 -3
- package/dist/components/segmented-control/index.d.ts +134 -0
- package/dist/components/segmented-control/index.js +15 -0
- package/dist/components/segmented-control/segmented-control-indicator.d.ts +19 -0
- package/dist/components/segmented-control/segmented-control-indicator.js +36 -0
- package/dist/components/segmented-control/segmented-control-item.d.ts +21 -0
- package/dist/components/segmented-control/segmented-control-item.js +96 -0
- package/dist/components/segmented-control/segmented-control-root.d.ts +25 -0
- package/dist/components/segmented-control/segmented-control-root.js +112 -0
- package/dist/components/segmented-control/segmented-control-separator.d.ts +19 -0
- package/dist/components/segmented-control/segmented-control-separator.js +18 -0
- package/dist/components/segmented-control/segmented-control.context.d.ts +17 -0
- package/dist/components/segmented-control/segmented-control.context.js +12 -0
- package/dist/components/segmented-control/segmented-control.types.d.ts +67 -0
- package/dist/components/select/index.d.ts +3 -0
- package/dist/components/select/select-hidden-select.js +1 -1
- package/dist/components/select/select-root.js +2 -0
- package/dist/components/select/select.types.d.ts +2 -0
- package/dist/components/sidebar/index.d.ts +544 -0
- package/dist/components/sidebar/index.js +47 -0
- package/dist/components/sidebar/sidebar-collapsible-trigger.d.ts +21 -0
- package/dist/components/sidebar/sidebar-collapsible-trigger.js +70 -0
- package/dist/components/sidebar/sidebar-collapsible.d.ts +24 -0
- package/dist/components/sidebar/sidebar-collapsible.js +78 -0
- package/dist/components/sidebar/sidebar-content.d.ts +21 -0
- package/dist/components/sidebar/sidebar-content.js +37 -0
- package/dist/components/sidebar/sidebar-footer.d.ts +21 -0
- package/dist/components/sidebar/sidebar-footer.js +24 -0
- package/dist/components/sidebar/sidebar-group-label.d.ts +21 -0
- package/dist/components/sidebar/sidebar-group-label.js +32 -0
- package/dist/components/sidebar/sidebar-group.d.ts +21 -0
- package/dist/components/sidebar/sidebar-group.js +48 -0
- package/dist/components/sidebar/sidebar-header.d.ts +21 -0
- package/dist/components/sidebar/sidebar-header.js +24 -0
- package/dist/components/sidebar/sidebar-inset.d.ts +21 -0
- package/dist/components/sidebar/sidebar-inset.js +24 -0
- package/dist/components/sidebar/sidebar-item-icon.d.ts +21 -0
- package/dist/components/sidebar/sidebar-item-icon.js +20 -0
- package/dist/components/sidebar/sidebar-item-indicator.d.ts +21 -0
- package/dist/components/sidebar/sidebar-item-indicator.js +48 -0
- package/dist/components/sidebar/sidebar-item-label.d.ts +21 -0
- package/dist/components/sidebar/sidebar-item-label.js +28 -0
- package/dist/components/sidebar/sidebar-item-tooltip.d.ts +21 -0
- package/dist/components/sidebar/sidebar-item-tooltip.js +38 -0
- package/dist/components/sidebar/sidebar-item-trailing.d.ts +21 -0
- package/dist/components/sidebar/sidebar-item-trailing.js +28 -0
- package/dist/components/sidebar/sidebar-item.d.ts +23 -0
- package/dist/components/sidebar/sidebar-item.js +160 -0
- package/dist/components/sidebar/sidebar-panel.d.ts +21 -0
- package/dist/components/sidebar/sidebar-panel.js +88 -0
- package/dist/components/sidebar/sidebar-rail.d.ts +21 -0
- package/dist/components/sidebar/sidebar-rail.js +210 -0
- package/dist/components/sidebar/sidebar-root.d.ts +31 -0
- package/dist/components/sidebar/sidebar-root.js +138 -0
- package/dist/components/sidebar/sidebar-separator.d.ts +19 -0
- package/dist/components/sidebar/sidebar-separator.js +16 -0
- package/dist/components/sidebar/sidebar-sub-menu.d.ts +23 -0
- package/dist/components/sidebar/sidebar-sub-menu.js +40 -0
- package/dist/components/sidebar/sidebar-trigger.d.ts +21 -0
- package/dist/components/sidebar/sidebar-trigger.js +69 -0
- package/dist/components/sidebar/sidebar.context.d.ts +75 -0
- package/dist/components/sidebar/sidebar.context.js +30 -0
- package/dist/components/sidebar/sidebar.state.d.ts +73 -0
- package/dist/components/sidebar/sidebar.state.js +76 -0
- package/dist/components/sidebar/sidebar.storage.d.ts +8 -0
- package/dist/components/sidebar/sidebar.storage.js +45 -0
- package/dist/components/sidebar/sidebar.types.d.ts +259 -0
- package/dist/components/splitter/index.d.ts +143 -0
- package/dist/components/splitter/index.js +13 -0
- package/dist/components/splitter/splitter-handle.d.ts +21 -0
- package/dist/components/splitter/splitter-handle.js +209 -0
- package/dist/components/splitter/splitter-panel.d.ts +21 -0
- package/dist/components/splitter/splitter-panel.js +70 -0
- package/dist/components/splitter/splitter-root.d.ts +31 -0
- package/dist/components/splitter/splitter-root.js +152 -0
- package/dist/components/splitter/splitter.context.d.ts +15 -0
- package/dist/components/splitter/splitter.context.js +5 -0
- package/dist/components/splitter/splitter.state.d.ts +87 -0
- package/dist/components/splitter/splitter.state.js +322 -0
- package/dist/components/splitter/splitter.storage.d.ts +15 -0
- package/dist/components/splitter/splitter.storage.js +56 -0
- package/dist/components/splitter/splitter.types.d.ts +98 -0
- package/dist/components/switch/switch-content.js +1 -1
- package/dist/components/table/index.d.ts +10 -9
- package/dist/components/table/table-body.js +13 -13
- package/dist/components/table/table-cell.js +49 -46
- package/dist/components/table/table-column-resizer.js +1 -1
- package/dist/components/table/table-column.js +1 -1
- package/dist/components/table/table-content.js +37 -18
- package/dist/{composables → components/table}/table-drag-collection.d.ts +1 -1
- package/dist/{composables → components/table}/table-drag-collection.js +1 -1
- package/dist/components/table/table-drop-indicator.js +3 -1
- package/dist/components/table/table-resizable-container.d.ts +4 -5
- package/dist/components/table/table-row.js +45 -14
- package/dist/components/table/table-virtualizer-item.d.ts +2 -7
- package/dist/components/table/table-virtualizer-item.js +20 -9
- package/dist/components/table/table.context.d.ts +11 -3
- package/dist/components/table/table.types.d.ts +1 -1
- package/dist/{composables → components/table}/use-grid-keyboard.d.ts +3 -3
- package/dist/{composables → components/table}/use-grid-keyboard.js +57 -55
- package/dist/{composables → components/table}/use-grid-selection-announcement.d.ts +2 -2
- package/dist/{composables → components/table}/use-grid-selection-announcement.js +2 -2
- package/dist/{composables → components/table}/use-table-collection.d.ts +2 -2
- package/dist/{composables → components/table}/use-table-collection.js +4 -4
- package/dist/{composables → components/table}/use-table-column-layout.d.ts +13 -20
- package/dist/components/table/use-table-column-layout.js +115 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/textarea-root.js +3 -0
- package/dist/components/textarea/textarea.types.d.ts +5 -0
- package/dist/components/textfield/index.d.ts +2 -0
- package/dist/components/textfield/textfield-root.js +5 -1
- package/dist/components/textfield/textfield.context.d.ts +2 -0
- package/dist/components/textfield/textfield.types.d.ts +5 -0
- package/dist/components/time-field/index.d.ts +1 -0
- package/dist/components/toast/index.d.ts +1 -0
- package/dist/components/toast/toast-default-content.js +1 -1
- package/dist/components/toolbar/index.d.ts +3 -2
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/tooltip/tooltip-root.js +1 -1
- package/dist/components/virtualizer/index.d.ts +3 -1
- package/dist/components/virtualizer/index.js +2 -1
- package/dist/components/virtualizer/use-virtualizer-item.d.ts +23 -0
- package/dist/components/virtualizer/use-virtualizer-item.js +45 -0
- package/dist/components/virtualizer/virtualizer-item.js +7 -41
- package/dist/components/virtualizer/virtualizer-scrollbar-track.d.ts +20 -0
- package/dist/components/virtualizer/virtualizer-scrollbar-track.js +141 -0
- package/dist/components/virtualizer/virtualizer-scrollbar.d.ts +18 -0
- package/dist/components/virtualizer/virtualizer-scrollbar.js +55 -0
- package/dist/components/virtualizer/virtualizer.context.d.ts +17 -1
- package/dist/composables/drag-manager.js +1 -13
- package/dist/composables/index.d.ts +3 -71
- package/dist/composables/use-collection.d.ts +22 -3
- package/dist/composables/use-collection.js +67 -14
- package/dist/composables/use-color-area.js +2 -2
- package/dist/composables/use-color-field.js +1 -1
- package/dist/composables/use-combo-box.js +1 -1
- package/dist/composables/use-date-field.js +1 -1
- package/dist/composables/use-drag-and-drop.js +1 -1
- package/dist/composables/use-drag.d.ts +6 -5
- package/dist/composables/use-draggable-item.d.ts +2 -2
- package/dist/composables/use-droppable-collection.js +2 -2
- package/dist/composables/use-droppable-item.js +1 -1
- package/dist/composables/use-form-reset.d.ts +6 -2
- package/dist/composables/use-form-reset.js +9 -5
- package/dist/composables/use-list-keyboard.js +64 -62
- package/dist/composables/use-number-field.js +1 -1
- package/dist/composables/use-select.js +2 -2
- package/dist/composables/use-selection-manager.js +4 -4
- package/dist/composables/use-single-select-list-state.d.ts +37 -0
- package/dist/composables/use-single-select-list-state.js +110 -0
- package/dist/composables/use-slider-thumb.js +2 -2
- package/dist/composables/use-slider.js +1 -1
- package/dist/composables/use-tab-list-state.d.ts +10 -29
- package/dist/composables/use-tab-list-state.js +10 -99
- package/dist/composables/use-text-field.js +1 -1
- package/dist/composables/use-virtualizer-scroll.d.ts +52 -2
- package/dist/composables/use-virtualizer-scroll.js +79 -13
- package/dist/composables/use-virtualizer.d.ts +24 -4
- package/dist/composables/use-virtualizer.js +40 -6
- package/dist/index.js +52 -80
- package/dist/utils/document-order.d.ts +14 -0
- package/dist/utils/document-order.js +17 -0
- package/dist/utils/flex-sizing.d.ts +41 -0
- package/dist/utils/flex-sizing.js +140 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/open-link.d.ts +31 -0
- package/dist/utils/open-link.js +32 -0
- package/dist/utils/story-truncation.d.ts +20 -0
- package/dist/utils/story-users.d.ts +11 -0
- package/dist/utils/virtualizer-collection.d.ts +14 -4
- package/dist/utils/virtualizer-collection.js +9 -14
- package/dist/utils/virtualizer-layout-info.js +3 -2
- package/dist/utils/virtualizer-list-layout.d.ts +75 -29
- package/dist/utils/virtualizer-list-layout.js +182 -99
- package/dist/utils/virtualizer-offsets.d.ts +111 -0
- package/dist/utils/virtualizer-offsets.js +159 -0
- package/dist/utils/virtualizer-overscan.d.ts +9 -15
- package/dist/utils/virtualizer-overscan.js +14 -33
- package/dist/utils/virtualizer-table-layout.d.ts +50 -21
- package/dist/utils/virtualizer-table-layout.js +130 -89
- package/dist/version.js +1 -1
- package/package.json +19 -3
- package/dist/composables/use-table-column-layout.js +0 -214
- /package/dist/{composables → components/dropdown}/use-safely-mouse-to-submenu.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { focusableIn, getScrollParent, isScrollable } from "
|
|
1
|
+
import { focusableIn, getScrollParent, isScrollable } from "../../utils/focus.js";
|
|
2
2
|
import { isTableCellControl } from "./use-table-collection.js";
|
|
3
3
|
import { computed, nextTick, shallowRef, toValue, watch } from "vue";
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/components/table/use-grid-keyboard.ts
|
|
5
5
|
var NO_FOCUS = {
|
|
6
6
|
columnKey: null,
|
|
7
7
|
rowKey: null
|
|
@@ -317,60 +317,62 @@ var useGridKeyboard = (options) => {
|
|
|
317
317
|
event.stopPropagation();
|
|
318
318
|
if (event.shiftKey && next.rowKey != null && selection.selectionMode.value === "multiple") selection.extendSelection(next.rowKey);
|
|
319
319
|
};
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
320
|
+
collection.rows.withOrder(() => {
|
|
321
|
+
switch (event.key) {
|
|
322
|
+
case "ArrowDown":
|
|
323
|
+
move(from.rowKey == null && from.columnKey == null ? firstKey(from, true) : keyBelow(from));
|
|
324
|
+
return;
|
|
325
|
+
case "ArrowUp":
|
|
326
|
+
move(from.rowKey == null && from.columnKey == null ? lastKey(from, true) : keyAbove(from));
|
|
327
|
+
return;
|
|
328
|
+
case "ArrowRight":
|
|
329
|
+
if (handleExpansion(event, from, isReversed() ? "collapse" : "expand")) return;
|
|
330
|
+
move(keyRightOf(from));
|
|
331
|
+
return;
|
|
332
|
+
case "ArrowLeft":
|
|
333
|
+
if (handleExpansion(event, from, isReversed() ? "expand" : "collapse")) return;
|
|
334
|
+
move(keyLeftOf(from));
|
|
335
|
+
return;
|
|
336
|
+
case "Home":
|
|
337
|
+
if (from.rowKey == null && from.columnKey == null && event.shiftKey) return;
|
|
338
|
+
move(firstKey(from, isModified));
|
|
339
|
+
return;
|
|
340
|
+
case "End":
|
|
341
|
+
if (from.rowKey == null && from.columnKey == null && event.shiftKey) return;
|
|
342
|
+
move(lastKey(from, isModified));
|
|
343
|
+
return;
|
|
344
|
+
case "PageUp":
|
|
345
|
+
move(pageStep(from, -1));
|
|
346
|
+
return;
|
|
347
|
+
case "PageDown":
|
|
348
|
+
move(pageStep(from, 1));
|
|
349
|
+
return;
|
|
350
|
+
case "a":
|
|
351
|
+
if (!isModified || toValue(options.disallowSelectAll)) return;
|
|
352
|
+
if (selection.selectionMode.value !== "multiple") return;
|
|
353
|
+
selection.selectAll();
|
|
354
|
+
event.preventDefault();
|
|
355
|
+
event.stopPropagation();
|
|
356
|
+
return;
|
|
357
|
+
case "Escape":
|
|
358
|
+
if (escapeKeyBehavior.value !== "clearSelection" || selection.isEmpty.value) return;
|
|
359
|
+
selection.clearSelection();
|
|
360
|
+
event.preventDefault();
|
|
361
|
+
event.stopPropagation();
|
|
362
|
+
return;
|
|
363
|
+
case " ":
|
|
364
|
+
if (from.rowKey == null || selection.selectionMode.value === "none") return;
|
|
365
|
+
selection.select(from.rowKey, { isShiftPressed: event.shiftKey });
|
|
366
|
+
event.preventDefault();
|
|
367
|
+
return;
|
|
368
|
+
case "Tab": {
|
|
369
|
+
const focusable = focusableIn(element);
|
|
370
|
+
(event.shiftKey ? element : focusable.at(-1))?.focus();
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
default: return;
|
|
371
374
|
}
|
|
372
|
-
|
|
373
|
-
}
|
|
375
|
+
});
|
|
374
376
|
};
|
|
375
377
|
/** Where focus should land when it first enters the grid. */
|
|
376
378
|
const entryTarget = (fromLater) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UseCollectionReturn } from "
|
|
2
|
-
import type { UseSelectionManagerReturn } from "
|
|
1
|
+
import type { UseCollectionReturn } from "../../composables/use-collection.js";
|
|
2
|
+
import type { UseSelectionManagerReturn } from "../../composables/use-selection-manager.js";
|
|
3
3
|
export interface UseGridSelectionAnnouncementOptions {
|
|
4
4
|
collection: UseCollectionReturn;
|
|
5
5
|
selection: UseSelectionManagerReturn;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { announce } from "
|
|
1
|
+
import { announce } from "../../utils/live-announcer.js";
|
|
2
2
|
import { watch } from "vue";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/components/table/use-grid-selection-announcement.ts
|
|
4
4
|
/** The keys in `a` that `b` does not have. A select-all is not a diff anyone can name. */
|
|
5
5
|
var diffSelection = (a, b) => {
|
|
6
6
|
if (a === "all" || b === "all") return /* @__PURE__ */ new Set();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { CollectionKey, UseCollectionReturn } from "../../composables/use-collection.js";
|
|
2
|
+
import type { VirtualizerTableCollection } from "../../utils/virtualizer-collection.js";
|
|
3
3
|
import type { TableColumnSize } from "./use-table-column-layout.js";
|
|
4
4
|
import type { ComputedRef } from "vue";
|
|
5
5
|
/** The least a registry needs from an entry: where it sits in the document. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { FOCUSABLE_SELECTOR } from "
|
|
2
|
-
import { useCollection } from "
|
|
3
|
-
import { createTableCollection } from "
|
|
1
|
+
import { FOCUSABLE_SELECTOR } from "../../utils/focus.js";
|
|
2
|
+
import { useCollection } from "../../composables/use-collection.js";
|
|
3
|
+
import { createTableCollection } from "../../utils/virtualizer-collection.js";
|
|
4
4
|
import { computed, shallowRef } from "vue";
|
|
5
|
-
//#region src/
|
|
5
|
+
//#region src/components/table/use-table-collection.ts
|
|
6
6
|
/**
|
|
7
7
|
* A registry of table parts that need to know **where they sit**, not just that they exist.
|
|
8
8
|
*
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import type { CollectionKey } from "
|
|
1
|
+
import type { CollectionKey } from "../../composables/use-collection.js";
|
|
2
|
+
import type { FlexSize } from "../../utils/flex-sizing.js";
|
|
2
3
|
import type { ComputedRef, MaybeRefOrGetter } from "vue";
|
|
3
|
-
/**
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* A column width: pixels as a number, a percentage of the table, or a fraction of what is left.
|
|
6
|
+
*
|
|
7
|
+
* The one name from the sizing vocabulary this package still publishes, because
|
|
8
|
+
* `TableColumnProps.width` names it.
|
|
9
|
+
*/
|
|
10
|
+
export type TableColumnSize = FlexSize;
|
|
5
11
|
export interface TableColumnDefinition {
|
|
6
12
|
key: CollectionKey;
|
|
7
13
|
/** A width the caller controls. Set, it is never changed by a resize. */
|
|
@@ -11,25 +17,12 @@ export interface TableColumnDefinition {
|
|
|
11
17
|
minWidth?: TableColumnSize | null;
|
|
12
18
|
maxWidth?: TableColumnSize | null;
|
|
13
19
|
}
|
|
14
|
-
/** Pixels and percentages are fixed; `fr` units and anything unrecognised flex. */
|
|
15
|
-
export declare const isStaticWidth: (width?: TableColumnSize | null) => boolean;
|
|
16
|
-
/** The number in front of `fr`. Anything else counts as `1fr`, as React Aria has it. */
|
|
17
|
-
export declare const parseFractionalUnit: (width?: TableColumnSize | null) => number;
|
|
18
|
-
export declare const parseStaticWidth: (width: TableColumnSize, tableWidth: number) => number;
|
|
19
|
-
export declare const getMaxWidth: (maxWidth: TableColumnSize | null | undefined, tableWidth: number) => number;
|
|
20
|
-
/**
|
|
21
|
-
* A minimum cannot be given in `fr`: knowing what a fraction comes to would need every other
|
|
22
|
-
* column's width, which is the very thing being solved for.
|
|
23
|
-
*/
|
|
24
|
-
export declare const getMinWidth: (minWidth: TableColumnSize | null | undefined, tableWidth: number) => number;
|
|
25
20
|
/**
|
|
26
|
-
* Column widths for one table width
|
|
21
|
+
* Column widths for one table width.
|
|
27
22
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* the static and percentage columns leave over, and a minimum or maximum on any one of them
|
|
32
|
-
* redistributes the rest.
|
|
23
|
+
* The sizing itself is `calculateFlexSizes`; what this adds is the table's own precedence — a
|
|
24
|
+
* width changed by a resize in flight outranks the declared one — and the mapping from the
|
|
25
|
+
* table's `width` vocabulary onto the solver's `size` one.
|
|
33
26
|
*/
|
|
34
27
|
export declare const calculateColumnSizes: (availableWidth: number, columns: TableColumnDefinition[], changedColumns: Map<CollectionKey, TableColumnSize>, getDefaultWidth?: (index: number) => TableColumnSize | null | undefined, getDefaultMinWidth?: (index: number) => TableColumnSize | null | undefined) => number[];
|
|
35
28
|
export interface BuildColumnWidthsOptions {
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { calculateFlexSizes, getMaxSize, getMinSize } from "../../utils/flex-sizing.js";
|
|
2
|
+
import { computed, shallowRef, toValue, watch } from "vue";
|
|
3
|
+
//#region src/components/table/use-table-column-layout.ts
|
|
4
|
+
/**
|
|
5
|
+
* Column widths for one table width.
|
|
6
|
+
*
|
|
7
|
+
* The sizing itself is `calculateFlexSizes`; what this adds is the table's own precedence — a
|
|
8
|
+
* width changed by a resize in flight outranks the declared one — and the mapping from the
|
|
9
|
+
* table's `width` vocabulary onto the solver's `size` one.
|
|
10
|
+
*/
|
|
11
|
+
var calculateColumnSizes = (availableWidth, columns, changedColumns, getDefaultWidth, getDefaultMinWidth) => {
|
|
12
|
+
const definitions = columns.map((column) => ({
|
|
13
|
+
defaultSize: column.defaultWidth,
|
|
14
|
+
maxSize: column.maxWidth,
|
|
15
|
+
minSize: column.minWidth,
|
|
16
|
+
size: changedColumns.get(column.key) ?? column.width
|
|
17
|
+
}));
|
|
18
|
+
return calculateFlexSizes(availableWidth, definitions, getDefaultWidth, getDefaultMinWidth);
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Every column's width in pixels, keyed by column, ported from react-stately's
|
|
22
|
+
* `TableColumnLayout.buildColumnWidths`.
|
|
23
|
+
*
|
|
24
|
+
* The sizing itself is `calculateColumnSizes` above; what this adds is the pair of defaults a
|
|
25
|
+
* table falls back to — `1fr` for a width nobody declared, and a 75px floor — and the mapping back
|
|
26
|
+
* onto keys. Both the resizable container and the virtualizer's table layout need exactly that,
|
|
27
|
+
* and the two must agree: a column laid out at one width by the browser and at another by the
|
|
28
|
+
* layout would put every cell in the wrong place.
|
|
29
|
+
*
|
|
30
|
+
* @param changedWidths Widths that override what the columns declare, as a resize in flight does.
|
|
31
|
+
*/
|
|
32
|
+
var buildColumnWidths = (availableWidth, columns, changedWidths = /* @__PURE__ */ new Map(), options = {}) => {
|
|
33
|
+
const getDefaultWidth = options.getDefaultWidth ?? (() => "1fr");
|
|
34
|
+
const getDefaultMinWidth = options.getDefaultMinWidth ?? (() => 75);
|
|
35
|
+
const sizes = calculateColumnSizes(availableWidth, columns, changedWidths, (index) => getDefaultWidth(columns[index]), (index) => getDefaultMinWidth(columns[index]));
|
|
36
|
+
return new Map(columns.map((column, index) => [column.key, sizes[index] ?? 0]));
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Column widths for a resizable table, ported from react-stately's `TableColumnLayout` and
|
|
40
|
+
* `useTableColumnResizeState`.
|
|
41
|
+
*
|
|
42
|
+
* Two things are worth knowing before changing any of it. A column whose `width` the caller set is
|
|
43
|
+
* **controlled**: a resize never writes to it. And dragging one column's edge freezes every column
|
|
44
|
+
* to its **left** at the pixel width it currently has, which is what stops the whole table from
|
|
45
|
+
* reflowing while the pointer moves — the columns to the right keep their declared sizes and
|
|
46
|
+
* absorb the difference.
|
|
47
|
+
*/
|
|
48
|
+
var useTableColumnLayout = (options) => {
|
|
49
|
+
const getDefaultWidth = options.getDefaultWidth ?? (() => "1fr");
|
|
50
|
+
const getDefaultMinWidth = options.getDefaultMinWidth ?? (() => 75);
|
|
51
|
+
const resizingColumn = shallowRef(null);
|
|
52
|
+
const uncontrolledColumns = () => options.columns().filter((column) => column.width == null);
|
|
53
|
+
const initialUncontrolledWidths = () => new Map(uncontrolledColumns().map((column) => [column.key, column.defaultWidth ?? getDefaultWidth(column) ?? "1fr"]));
|
|
54
|
+
const uncontrolledWidths = shallowRef(initialUncontrolledWidths());
|
|
55
|
+
watch(() => options.columns().map((column) => column.key).join(" "), () => {
|
|
56
|
+
uncontrolledWidths.value = initialUncontrolledWidths();
|
|
57
|
+
});
|
|
58
|
+
/** The declared width of every column, with the uncontrolled ones taken from state. */
|
|
59
|
+
const combinedWidths = () => new Map(options.columns().map((column) => [column.key, uncontrolledWidths.value.get(column.key) ?? column.width ?? "1fr"]));
|
|
60
|
+
const layout = computed(() => {
|
|
61
|
+
const columns = options.columns();
|
|
62
|
+
const tableWidth = toValue(options.tableWidth);
|
|
63
|
+
const widths = buildColumnWidths(tableWidth, columns, combinedWidths(), {
|
|
64
|
+
getDefaultMinWidth,
|
|
65
|
+
getDefaultWidth
|
|
66
|
+
});
|
|
67
|
+
const minWidths = /* @__PURE__ */ new Map();
|
|
68
|
+
const maxWidths = /* @__PURE__ */ new Map();
|
|
69
|
+
for (const column of columns) {
|
|
70
|
+
minWidths.set(column.key, getMinSize(column.minWidth ?? getDefaultMinWidth(column), tableWidth));
|
|
71
|
+
maxWidths.set(column.key, getMaxSize(column.maxWidth, tableWidth));
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
maxWidths,
|
|
75
|
+
minWidths,
|
|
76
|
+
widths
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
const getColumnWidth = (key) => layout.value.widths.get(key) ?? 0;
|
|
80
|
+
const getColumnMinWidth = (key) => layout.value.minWidths.get(key) ?? 0;
|
|
81
|
+
const getColumnMaxWidth = (key) => layout.value.maxWidths.get(key) ?? 0;
|
|
82
|
+
const updateResizedColumns = (key, width) => {
|
|
83
|
+
const previous = layout.value.widths;
|
|
84
|
+
const declared = combinedWidths();
|
|
85
|
+
const clamped = Math.max(getColumnMinWidth(key), Math.min(getColumnMaxWidth(key), Math.floor(width)));
|
|
86
|
+
const next = /* @__PURE__ */ new Map();
|
|
87
|
+
let freeze = true;
|
|
88
|
+
for (const column of options.columns()) if (column.key === key) {
|
|
89
|
+
next.set(column.key, clamped);
|
|
90
|
+
freeze = false;
|
|
91
|
+
} else if (freeze) next.set(column.key, previous.get(column.key) ?? 0);
|
|
92
|
+
else next.set(column.key, column.width ?? declared.get(column.key) ?? "1fr");
|
|
93
|
+
const committed = /* @__PURE__ */ new Map();
|
|
94
|
+
for (const column of uncontrolledColumns()) committed.set(column.key, next.get(column.key) ?? "1fr");
|
|
95
|
+
committed.set(key, clamped);
|
|
96
|
+
uncontrolledWidths.value = committed;
|
|
97
|
+
return next;
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
columnWidths: computed(() => layout.value.widths),
|
|
101
|
+
endResize: () => {
|
|
102
|
+
resizingColumn.value = null;
|
|
103
|
+
},
|
|
104
|
+
getColumnMaxWidth,
|
|
105
|
+
getColumnMinWidth,
|
|
106
|
+
getColumnWidth,
|
|
107
|
+
resizingColumn: computed(() => resizingColumn.value),
|
|
108
|
+
startResize: (key) => {
|
|
109
|
+
resizingColumn.value = key;
|
|
110
|
+
},
|
|
111
|
+
updateResizedColumns
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
//#endregion
|
|
115
|
+
export { buildColumnWidths, calculateColumnSizes, useTableColumnLayout };
|
|
@@ -8,6 +8,7 @@ export declare const TextArea: ((__VLS_props: NonNullable<Awaited<typeof __VLS_s
|
|
|
8
8
|
class?: string;
|
|
9
9
|
value?: string;
|
|
10
10
|
variant?: import("@ropav/styles").TextAreaVariants["variant"];
|
|
11
|
+
size?: import("@ropav/styles").TextAreaVariants["size"];
|
|
11
12
|
fullWidth?: boolean;
|
|
12
13
|
placeholder?: string;
|
|
13
14
|
onChange?: ((value: string) => any) | undefined;
|
|
@@ -31,6 +32,7 @@ export declare const TextArea: ((__VLS_props: NonNullable<Awaited<typeof __VLS_s
|
|
|
31
32
|
class?: string;
|
|
32
33
|
value?: string;
|
|
33
34
|
variant?: import("@ropav/styles").TextAreaVariants["variant"];
|
|
35
|
+
size?: import("@ropav/styles").TextAreaVariants["size"];
|
|
34
36
|
fullWidth?: boolean;
|
|
35
37
|
placeholder?: string;
|
|
36
38
|
onChange?: ((value: string) => any) | undefined;
|
|
@@ -13,6 +13,7 @@ var textarea_root_vue_vue_type_script_setup_true_vapor_true_lang_default = /*@__
|
|
|
13
13
|
class: {},
|
|
14
14
|
value: {},
|
|
15
15
|
variant: { default: void 0 },
|
|
16
|
+
size: {},
|
|
16
17
|
fullWidth: {
|
|
17
18
|
type: Boolean,
|
|
18
19
|
default: void 0
|
|
@@ -31,9 +32,11 @@ var textarea_root_vue_vue_type_script_setup_true_vapor_true_lang_default = /*@__
|
|
|
31
32
|
control?.registerElement(element.value);
|
|
32
33
|
};
|
|
33
34
|
const resolvedVariant = computed(() => props.variant ?? textField?.variant.value);
|
|
35
|
+
const resolvedSize = computed(() => props.size ?? textField?.size.value);
|
|
34
36
|
const styles = computed(() => textAreaVariants({
|
|
35
37
|
class: props.class,
|
|
36
38
|
fullWidth: props.fullWidth,
|
|
39
|
+
size: resolvedSize.value,
|
|
37
40
|
variant: resolvedVariant.value
|
|
38
41
|
}));
|
|
39
42
|
const attrs = computed(() => {
|
|
@@ -9,6 +9,11 @@ export interface TextAreaRootProps {
|
|
|
9
9
|
value?: string;
|
|
10
10
|
/** Visual variant. Taken from the surrounding field when unset. @default "primary" */
|
|
11
11
|
variant?: TextAreaVariants["variant"];
|
|
12
|
+
/**
|
|
13
|
+
* How much room the text is given, matching a field of the same size. Taken from the
|
|
14
|
+
* surrounding field when unset. @default "md"
|
|
15
|
+
*/
|
|
16
|
+
size?: TextAreaVariants["size"];
|
|
12
17
|
/** Whether the control stretches to fill its container. */
|
|
13
18
|
fullWidth?: boolean;
|
|
14
19
|
/**
|
|
@@ -9,6 +9,7 @@ export declare const TextField: ((__VLS_props: NonNullable<Awaited<typeof __VLS_
|
|
|
9
9
|
props: import('vue').PublicProps & {
|
|
10
10
|
class?: string;
|
|
11
11
|
variant?: "primary" | "secondary";
|
|
12
|
+
size?: "sm" | "md" | "lg";
|
|
12
13
|
fullWidth?: boolean;
|
|
13
14
|
value?: string;
|
|
14
15
|
defaultValue?: string;
|
|
@@ -61,6 +62,7 @@ export declare const TextField: ((__VLS_props: NonNullable<Awaited<typeof __VLS_
|
|
|
61
62
|
props: import('vue').PublicProps & {
|
|
62
63
|
class?: string;
|
|
63
64
|
variant?: "primary" | "secondary";
|
|
65
|
+
size?: "sm" | "md" | "lg";
|
|
64
66
|
fullWidth?: boolean;
|
|
65
67
|
value?: string;
|
|
66
68
|
defaultValue?: string;
|
|
@@ -12,6 +12,7 @@ var textfield_root_vue_vue_type_script_setup_true_vapor_true_lang_default = /*@_
|
|
|
12
12
|
props: {
|
|
13
13
|
class: {},
|
|
14
14
|
variant: { default: void 0 },
|
|
15
|
+
size: {},
|
|
15
16
|
fullWidth: {
|
|
16
17
|
type: Boolean,
|
|
17
18
|
default: void 0
|
|
@@ -101,7 +102,10 @@ var textfield_root_vue_vue_type_script_setup_true_vapor_true_lang_default = /*@_
|
|
|
101
102
|
});
|
|
102
103
|
provideFieldIdsContext(field.fieldIds);
|
|
103
104
|
provideTextFieldControlContext(field);
|
|
104
|
-
provideTextFieldContext({
|
|
105
|
+
provideTextFieldContext({
|
|
106
|
+
size: computed(() => props.size),
|
|
107
|
+
variant: computed(() => props.variant)
|
|
108
|
+
});
|
|
105
109
|
provideFieldErrorContext({ validation: field.validation.displayValidation });
|
|
106
110
|
const styles = computed(() => textFieldVariants({
|
|
107
111
|
class: props.class,
|
|
@@ -2,6 +2,8 @@ import type { ComputedRef } from "vue";
|
|
|
2
2
|
export interface TextFieldContext {
|
|
3
3
|
/** Visual variant the control inside picks up when it declares none of its own. */
|
|
4
4
|
variant: ComputedRef<"primary" | "secondary" | undefined>;
|
|
5
|
+
/** Size the control inside picks up when it declares none of its own. */
|
|
6
|
+
size: ComputedRef<"sm" | "md" | "lg" | undefined>;
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* Carries the variant alone, kept apart from the control context that carries the behaviour.
|
|
@@ -3,6 +3,11 @@ export interface TextFieldRootProps {
|
|
|
3
3
|
class?: string;
|
|
4
4
|
/** Visual variant handed down to the control inside. @default "primary" */
|
|
5
5
|
variant?: "primary" | "secondary";
|
|
6
|
+
/**
|
|
7
|
+
* How tall the control inside stands, matching a button of the same size. Handed to the control
|
|
8
|
+
* unless it declares one of its own. @default "md"
|
|
9
|
+
*/
|
|
10
|
+
size?: "sm" | "md" | "lg";
|
|
6
11
|
/** Whether the field stretches to fill its container. */
|
|
7
12
|
fullWidth?: boolean;
|
|
8
13
|
/** Text in the field. Makes it controlled. */
|
|
@@ -58,6 +58,7 @@ export declare const TimeField: ((__VLS_props: NonNullable<Awaited<typeof __VLS_
|
|
|
58
58
|
props: import('vue').PublicProps & {
|
|
59
59
|
class?: string;
|
|
60
60
|
variant?: import("@ropav/styles").DateInputGroupVariants["variant"];
|
|
61
|
+
size?: import("@ropav/styles").DateInputGroupVariants["size"];
|
|
61
62
|
fullWidth?: boolean;
|
|
62
63
|
isDisabled?: boolean;
|
|
63
64
|
isInvalid?: boolean;
|
|
@@ -223,6 +223,7 @@ export declare const Toast: ((__VLS_props: NonNullable<Awaited<typeof __VLS_setu
|
|
|
223
223
|
export { ToastActionButton, ToastCloseButton, ToastContent, ToastDescription, ToastIndicator, ToastProvider, ToastRoot, ToastTitle, };
|
|
224
224
|
export type { ToastActionButtonProps, ToastActionValue, ToastAddOptions, ToastCloseButtonProps, ToastContentProps, ToastContentValue, ToastDescriptionProps, ToastIndicatorProps, ToastOptions, ToastPromiseOptions, ToastProviderProps, ToastProviderSlotProps, ToastQueueOptions, ToastRenderable, ToastRootProps, ToastRootProps as ToastProps, ToastTitleProps, QueuedToast, } from "./toast.types.js";
|
|
225
225
|
export { ToastQueue, createToastFunction, getQueuedToastCount, resetToastQueue, toast, toastQueue, useToastQueue, } from "./toast-queue.js";
|
|
226
|
+
export type { Timer } from "./toast-queue.js";
|
|
226
227
|
export type { ToastFunction, UseToastQueueReturn } from "./toast-queue.js";
|
|
227
228
|
export { DEFAULT_GAP, DEFAULT_MAX_VISIBLE_TOAST, DEFAULT_SCALE_FACTOR, DEFAULT_TOAST_TIMEOUT, DEFAULT_TOAST_WIDTH, } from "./toast.constants.js";
|
|
228
229
|
export { useToastItemContext, useToastRegionContext } from "./toast.context.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { useMediaQuery } from "../../composables/use-media-query.js";
|
|
1
2
|
import spinner_root_default from "../spinner/spinner-root.js";
|
|
2
3
|
import toast_action_button_default from "./toast-action-button.js";
|
|
3
4
|
import toast_close_button_default from "./toast-close-button.js";
|
|
4
5
|
import toast_content_default from "./toast-content.js";
|
|
5
6
|
import toast_description_default from "./toast-description.js";
|
|
6
7
|
import toast_indicator_default from "./toast-indicator.js";
|
|
7
|
-
import { useMediaQuery } from "../../composables/use-media-query.js";
|
|
8
8
|
import toast_renderable_default from "./toast-renderable.js";
|
|
9
9
|
import toast_root_default from "./toast-root.js";
|
|
10
10
|
import toast_title_default from "./toast-title.js";
|
|
@@ -9,7 +9,7 @@ export declare const Toolbar: ((__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
9
9
|
props: import('vue').PublicProps & {
|
|
10
10
|
class?: string;
|
|
11
11
|
isAttached?: boolean;
|
|
12
|
-
orientation?: import("
|
|
12
|
+
orientation?: import("./index.js").ToolbarOrientation;
|
|
13
13
|
} & (typeof globalThis extends {
|
|
14
14
|
__VLS_PROPS_FALLBACK: infer P;
|
|
15
15
|
} ? P : {});
|
|
@@ -32,7 +32,7 @@ export declare const Toolbar: ((__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
32
32
|
props: import('vue').PublicProps & {
|
|
33
33
|
class?: string;
|
|
34
34
|
isAttached?: boolean;
|
|
35
|
-
orientation?: import("
|
|
35
|
+
orientation?: import("./index.js").ToolbarOrientation;
|
|
36
36
|
} & (typeof globalThis extends {
|
|
37
37
|
__VLS_PROPS_FALLBACK: infer P;
|
|
38
38
|
} ? P : {});
|
|
@@ -50,5 +50,6 @@ export { ToolbarRoot };
|
|
|
50
50
|
export type { ToolbarRootProps, ToolbarRootProps as ToolbarProps } from "./toolbar.types.js";
|
|
51
51
|
export { useToolbarContext } from "./toolbar.context.js";
|
|
52
52
|
export type { ToolbarContext } from "./toolbar.context.js";
|
|
53
|
+
export type { ToolbarOrientation } from "../../composables/use-toolbar.js";
|
|
53
54
|
export { toolbarVariants } from "@ropav/styles";
|
|
54
55
|
export type { ToolbarVariants } from "@ropav/styles";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import tooltip_arrow_default from "./tooltip-arrow.js";
|
|
2
1
|
import { useTooltipContext } from "./tooltip.context.js";
|
|
3
2
|
import tooltip_content_default from "./tooltip-content.js";
|
|
4
3
|
import tooltip_root_default from "./tooltip-root.js";
|
|
5
4
|
import tooltip_trigger_default from "./tooltip-trigger.js";
|
|
5
|
+
import tooltip_arrow_default from "./tooltip-arrow.js";
|
|
6
6
|
import { tooltipVariants } from "@ropav/styles";
|
|
7
7
|
//#region src/components/tooltip/index.ts
|
|
8
8
|
var Tooltip = Object.assign(tooltip_root_default, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { provideFocusResponder } from "../../composables/focus-responder.js";
|
|
2
|
-
import { useCssVariable } from "../../composables/use-css-variable.js";
|
|
3
2
|
import { provideTooltipContext } from "./tooltip.context.js";
|
|
3
|
+
import { useCssVariable } from "../../composables/use-css-variable.js";
|
|
4
4
|
import { useTooltipTrigger } from "../../composables/use-tooltip-trigger.js";
|
|
5
5
|
import { useTooltipTriggerState } from "../../composables/use-tooltip-trigger-state.js";
|
|
6
6
|
import { parseCssTime } from "../../utils/css.js";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export type { ScrollBoxInfo, ScrollToOffset } from "../../composables/use-virtualizer-scroll.js";
|
|
1
2
|
export { provideVirtualizerStateContext, useVirtualizerConfigContext, useVirtualizerStateContext, } from "./virtualizer.context.js";
|
|
2
|
-
export type { VirtualizerConfigContext, VirtualizerStateContext } from "./virtualizer.context.js";
|
|
3
|
+
export type { VirtualizerConfigContext, VirtualizerScrollState, VirtualizerStateContext, } from "./virtualizer.context.js";
|
|
3
4
|
export { default as VirtualizerItem } from "./virtualizer-item.js";
|
|
4
5
|
export { default as VirtualizerRoot } from "./virtualizer-root.js";
|
|
6
|
+
export { default as VirtualizerScrollbar } from "./virtualizer-scrollbar.js";
|
|
5
7
|
export type { VirtualizerItemProps, VirtualizerLayoutProp, VirtualizerRootProps, } from "./virtualizer.types.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { provideVirtualizerStateContext, useVirtualizerConfigContext, useVirtualizerStateContext } from "./virtualizer.context.js";
|
|
2
2
|
import virtualizer_item_default from "./virtualizer-item.js";
|
|
3
3
|
import virtualizer_root_default from "./virtualizer-root.js";
|
|
4
|
-
|
|
4
|
+
import virtualizer_scrollbar_default from "./virtualizer-scrollbar.js";
|
|
5
|
+
export { virtualizer_item_default as VirtualizerItem, virtualizer_root_default as VirtualizerRoot, virtualizer_scrollbar_default as VirtualizerScrollbar, provideVirtualizerStateContext, useVirtualizerConfigContext, useVirtualizerStateContext };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { LayoutInfo } from "../../utils/virtualizer-layout-info.js";
|
|
2
|
+
import type { ComputedRef, ShallowRef } from "vue";
|
|
3
|
+
import { layoutInfoToStyle } from "../../utils/virtualizer-layout-info.js";
|
|
4
|
+
export interface UseVirtualizerItemOptions {
|
|
5
|
+
/** The wrapper element, once it is in the DOM. */
|
|
6
|
+
element: ShallowRef<HTMLElement | null>;
|
|
7
|
+
layoutInfo: () => LayoutInfo | null | undefined;
|
|
8
|
+
parentLayoutInfo?: () => LayoutInfo | null | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface UseVirtualizerItemReturn {
|
|
11
|
+
/** Where the wrapper sits and how big it is, as the layout worked it out. */
|
|
12
|
+
style: ComputedRef<ReturnType<typeof layoutInfoToStyle> | undefined>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What a wrapper around one windowed element does: carry the geometry the layout gave it, and
|
|
16
|
+
* measure what the layout could only estimate.
|
|
17
|
+
*
|
|
18
|
+
* A wrapper still carrying an estimate has no height of its own, so what it reports is what its
|
|
19
|
+
* content came to. React Aria writes the estimate on, clears it to read `scrollHeight`, and writes
|
|
20
|
+
* it back — a forced reflow per element, and one that fights the size containment the wrapper
|
|
21
|
+
* also carries.
|
|
22
|
+
*/
|
|
23
|
+
export declare const useVirtualizerItem: (options: UseVirtualizerItemOptions) => UseVirtualizerItemReturn;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useVirtualizerStateContext } from "./virtualizer.context.js";
|
|
2
|
+
import { Size } from "../../utils/virtualizer-geometry.js";
|
|
3
|
+
import { layoutInfoToStyle } from "../../utils/virtualizer-layout-info.js";
|
|
4
|
+
import { computed, watch } from "vue";
|
|
5
|
+
//#region src/components/virtualizer/use-virtualizer-item.ts
|
|
6
|
+
/**
|
|
7
|
+
* What a wrapper around one windowed element does: carry the geometry the layout gave it, and
|
|
8
|
+
* measure what the layout could only estimate.
|
|
9
|
+
*
|
|
10
|
+
* A wrapper still carrying an estimate has no height of its own, so what it reports is what its
|
|
11
|
+
* content came to. React Aria writes the estimate on, clears it to read `scrollHeight`, and writes
|
|
12
|
+
* it back — a forced reflow per element, and one that fights the size containment the wrapper
|
|
13
|
+
* also carries.
|
|
14
|
+
*/
|
|
15
|
+
var useVirtualizerItem = (options) => {
|
|
16
|
+
const virtualizer = useVirtualizerStateContext();
|
|
17
|
+
const measure = () => {
|
|
18
|
+
const current = options.element.value;
|
|
19
|
+
const layoutInfo = options.layoutInfo();
|
|
20
|
+
if (!current || !layoutInfo) return;
|
|
21
|
+
const bounds = current.getBoundingClientRect();
|
|
22
|
+
virtualizer?.updateItemSize(layoutInfo.key, new Size(bounds.width, bounds.height));
|
|
23
|
+
};
|
|
24
|
+
watch(() => [options.element.value, options.layoutInfo()], ([current, layoutInfo]) => {
|
|
25
|
+
if (current && layoutInfo?.estimatedSize) measure();
|
|
26
|
+
}, {
|
|
27
|
+
flush: "post",
|
|
28
|
+
immediate: true
|
|
29
|
+
});
|
|
30
|
+
watch(() => [options.element.value, virtualizer?.shouldObserveItemSize.value], ([current, shouldObserve], _previous, onCleanup) => {
|
|
31
|
+
if (!current || !shouldObserve || typeof ResizeObserver === "undefined") return;
|
|
32
|
+
const observer = new ResizeObserver(() => measure());
|
|
33
|
+
for (const child of current.children) observer.observe(child);
|
|
34
|
+
onCleanup(() => observer.disconnect());
|
|
35
|
+
}, {
|
|
36
|
+
flush: "post",
|
|
37
|
+
immediate: true
|
|
38
|
+
});
|
|
39
|
+
return { style: computed(() => {
|
|
40
|
+
const layoutInfo = options.layoutInfo();
|
|
41
|
+
return layoutInfo ? layoutInfoToStyle(layoutInfo, options.parentLayoutInfo?.()) : void 0;
|
|
42
|
+
}) };
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { useVirtualizerItem };
|