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,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { layoutInfoToStyle } from "../../utils/virtualizer-layout-info.js";
|
|
4
|
-
import { computed, createSlot, defineVaporComponent, renderEffect, setInsertionState, setStaticTemplateRef, setStyle, shallowRef, template, watch } from "vue";
|
|
1
|
+
import { useVirtualizerItem } from "./use-virtualizer-item.js";
|
|
2
|
+
import { createSlot, defineVaporComponent, renderEffect, setInsertionState, setStaticTemplateRef, setStyle, shallowRef, template, unref } from "vue";
|
|
5
3
|
//#region src/components/virtualizer/virtualizer-item.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
6
4
|
var t0 = template("<div role=presentation>", 1);
|
|
7
5
|
var virtualizer_item_vue_vue_type_script_setup_true_vapor_true_lang_default = /*@__PURE__*/ defineVaporComponent({
|
|
@@ -12,46 +10,14 @@ var virtualizer_item_vue_vue_type_script_setup_true_vapor_true_lang_default = /*
|
|
|
12
10
|
},
|
|
13
11
|
setup(__props) {
|
|
14
12
|
const props = __props;
|
|
15
|
-
const virtualizer = useVirtualizerStateContext();
|
|
16
13
|
const element = shallowRef(null);
|
|
17
|
-
const style =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* The inline height is cleared first: it is the estimate, and measuring through it would just
|
|
22
|
-
* read the guess back. `scrollHeight` rather than `getBoundingClientRect` because that is what
|
|
23
|
-
* React Aria reads, and a row whose content overflows should report the content.
|
|
24
|
-
*/
|
|
25
|
-
const measure = () => {
|
|
26
|
-
const current = element.value;
|
|
27
|
-
if (!current) return;
|
|
28
|
-
const height = current.style.height;
|
|
29
|
-
current.style.height = "";
|
|
30
|
-
const measured = new Size(current.scrollWidth, current.scrollHeight);
|
|
31
|
-
current.style.height = height;
|
|
32
|
-
if (props.layoutInfo) virtualizer?.updateItemSize(props.layoutInfo.key, measured);
|
|
33
|
-
};
|
|
34
|
-
watch(() => [element.value, props.layoutInfo], ([current, layoutInfo]) => {
|
|
35
|
-
if (current && layoutInfo?.estimatedSize) measure();
|
|
36
|
-
}, {
|
|
37
|
-
flush: "post",
|
|
38
|
-
immediate: true
|
|
39
|
-
});
|
|
40
|
-
/**
|
|
41
|
-
* Watching the children rather than the wrapper: the wrapper's height is set by the layout, so it
|
|
42
|
-
* never changes on its own, while what is inside it does.
|
|
43
|
-
*/
|
|
44
|
-
watch(() => [element.value, virtualizer?.shouldObserveItemSize.value], ([current, shouldObserve], _previous, onCleanup) => {
|
|
45
|
-
if (!current || !shouldObserve || typeof ResizeObserver === "undefined") return;
|
|
46
|
-
const observer = new ResizeObserver(() => measure());
|
|
47
|
-
for (const child of current.children) observer.observe(child);
|
|
48
|
-
onCleanup(() => observer.disconnect());
|
|
49
|
-
}, {
|
|
50
|
-
flush: "post",
|
|
51
|
-
immediate: true
|
|
14
|
+
const { style } = useVirtualizerItem({
|
|
15
|
+
element,
|
|
16
|
+
layoutInfo: () => props.layoutInfo,
|
|
17
|
+
parentLayoutInfo: () => props.parentLayoutInfo
|
|
52
18
|
});
|
|
53
19
|
const n1 = t0();
|
|
54
|
-
renderEffect(() => setStyle(n1, style
|
|
20
|
+
renderEffect(() => setStyle(n1, unref(style)));
|
|
55
21
|
setInsertionState(n1);
|
|
56
22
|
createSlot();
|
|
57
23
|
setStaticTemplateRef(n1, element, null, "element");
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const __VLS_export: (__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>['props'], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, 'attrs' | 'emit' | 'slots'>>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>['expose'], __VLS_setup?: Promise<{
|
|
2
|
+
props: import('vue').PublicProps & __VLS_PrettifyLocal<{
|
|
3
|
+
orientation: "horizontal" | "vertical";
|
|
4
|
+
}> & (typeof globalThis extends {
|
|
5
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
6
|
+
} ? P : {});
|
|
7
|
+
expose: (exposed: {}) => void;
|
|
8
|
+
attrs: any;
|
|
9
|
+
slots: {};
|
|
10
|
+
emit: {};
|
|
11
|
+
}>) => import('vue').VNode & {
|
|
12
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
13
|
+
};
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
17
|
+
[K in keyof T]: T[K];
|
|
18
|
+
} : {
|
|
19
|
+
[K in keyof T as K]: T[K];
|
|
20
|
+
}) & {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { dataAttr } from "../../utils/assertion.js";
|
|
2
|
+
import { useInteractionStates } from "../../composables/use-interaction-states.js";
|
|
3
|
+
import { useVirtualizerStateContext } from "./virtualizer.context.js";
|
|
4
|
+
import { useMove } from "../../composables/use-move.js";
|
|
5
|
+
import { child, computed, createIf, defineVaporComponent, on, renderEffect, setAttr, setClass, setStyle, template, unref } from "vue";
|
|
6
|
+
import { virtualizerVariants } from "@ropav/styles";
|
|
7
|
+
//#region src/components/virtualizer/virtualizer-scrollbar-track.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
8
|
+
var t0 = template("<div data-slot=virtualizer-scrollbar-track><div data-slot=virtualizer-scrollbar-thumb>", 1);
|
|
9
|
+
/**
|
|
10
|
+
* One axis of the scrollbar a windowed collection draws for itself: a track, and the thumb in it.
|
|
11
|
+
*
|
|
12
|
+
* The thumb is moved by the main thread. Every pointer move sets the scroll offset and the rows for
|
|
13
|
+
* it in one task, so no frame is ever drawn with rows that were built for another offset — which is
|
|
14
|
+
* what a native thumb, moved by the compositor, cannot promise. See `VirtualizerScrollbar`.
|
|
15
|
+
*/
|
|
16
|
+
var THICKNESS = 10;
|
|
17
|
+
/** The shortest the thumb gets: a long collection would otherwise leave nothing to grab. */
|
|
18
|
+
var MIN_THUMB_LENGTH = 32;
|
|
19
|
+
/**
|
|
20
|
+
* How much of the viewport a press on the track moves by. Less than the whole of it, so what was
|
|
21
|
+
* at the edge is still on screen afterwards to hold the eye — the fraction browsers page by.
|
|
22
|
+
*/
|
|
23
|
+
var PAGE_FRACTION = .875;
|
|
24
|
+
var virtualizer_scrollbar_track_vue_vue_type_script_setup_true_vapor_true_lang_default = /*@__PURE__*/ defineVaporComponent({
|
|
25
|
+
__name: "virtualizer-scrollbar-track",
|
|
26
|
+
props: { orientation: {} },
|
|
27
|
+
setup(__props) {
|
|
28
|
+
const props = __props;
|
|
29
|
+
/** How thick the track is, across its axis. */
|
|
30
|
+
const state = useVirtualizerStateContext();
|
|
31
|
+
if (!state) throw new Error("`VirtualizerScrollbarTrack` was rendered outside of a windowed collection.");
|
|
32
|
+
const { scroll } = state;
|
|
33
|
+
const styles = virtualizerVariants();
|
|
34
|
+
const isVertical = props.orientation === "vertical";
|
|
35
|
+
/** A size measured along this track's axis. */
|
|
36
|
+
const along = (size) => isVertical ? size.height : size.width;
|
|
37
|
+
/** A size measured across it, which is the other track's axis. */
|
|
38
|
+
const across = (size) => isVertical ? size.width : size.height;
|
|
39
|
+
const viewport = computed(() => along(scroll.size.value));
|
|
40
|
+
/** How far the box can scroll along this axis. */
|
|
41
|
+
const range = computed(() => Math.max(0, along(scroll.scrollSize.value) - viewport.value));
|
|
42
|
+
/** Whether the box scrolls along this axis at all, rather than clipping it. */
|
|
43
|
+
const scrolls = computed(() => isVertical ? scroll.box.value.scrollsY : scroll.box.value.scrollsX);
|
|
44
|
+
/** Whether the other axis has a track too, which is when the two leave each other a corner. */
|
|
45
|
+
const hasCorner = computed(() => (isVertical ? scroll.box.value.scrollsX : scroll.box.value.scrollsY) && across(scroll.scrollSize.value) > across(scroll.size.value));
|
|
46
|
+
const trackLength = computed(() => Math.max(0, viewport.value - (hasCorner.value ? THICKNESS : 0)));
|
|
47
|
+
/** The thumb is to the track what the viewport is to the content, down to a graspable floor. */
|
|
48
|
+
const thumbLength = computed(() => {
|
|
49
|
+
const total = along(scroll.scrollSize.value);
|
|
50
|
+
if (total <= 0) return trackLength.value;
|
|
51
|
+
return Math.min(trackLength.value, Math.max(MIN_THUMB_LENGTH, trackLength.value * viewport.value / total));
|
|
52
|
+
});
|
|
53
|
+
/** How far the thumb can travel. */
|
|
54
|
+
const travel = computed(() => Math.max(0, trackLength.value - thumbLength.value));
|
|
55
|
+
/** The scroll offset along this axis, signed. */
|
|
56
|
+
const offset = computed(() => isVertical ? scroll.offset.value.y : scroll.offset.value.x);
|
|
57
|
+
/** Where the thumb sits, measured from the start of the track. */
|
|
58
|
+
const thumbOffset = computed(() => range.value > 0 ? Math.min(Math.abs(offset.value), range.value) / range.value * travel.value : 0);
|
|
59
|
+
const isVisible = computed(() => scrolls.value && range.value > 0);
|
|
60
|
+
const scrollTo = (value) => {
|
|
61
|
+
scroll.scrollTo(isVertical ? { top: value } : { left: value });
|
|
62
|
+
};
|
|
63
|
+
const states = useInteractionStates();
|
|
64
|
+
/** The offset the press started from, and how far the pointer has travelled along the track since. */
|
|
65
|
+
let startOffset = 0;
|
|
66
|
+
let dragged = 0;
|
|
67
|
+
/** Content pixels per thumb pixel, fixed at the press so the mapping cannot drift mid-drag. */
|
|
68
|
+
let ratio = 0;
|
|
69
|
+
const { handlers: moveHandlers } = useMove({
|
|
70
|
+
onMove: ({ deltaX, deltaY }) => {
|
|
71
|
+
dragged += isVertical ? deltaY : deltaX;
|
|
72
|
+
scrollTo(startOffset + dragged * ratio);
|
|
73
|
+
},
|
|
74
|
+
onMoveEnd: () => {
|
|
75
|
+
dragged = 0;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const onThumbPointerdown = (event) => {
|
|
79
|
+
if (event.button !== 0) return;
|
|
80
|
+
startOffset = offset.value;
|
|
81
|
+
dragged = 0;
|
|
82
|
+
ratio = travel.value > 0 ? range.value / travel.value : 0;
|
|
83
|
+
states.onPointerdown(event);
|
|
84
|
+
moveHandlers.onPointerdown(event);
|
|
85
|
+
};
|
|
86
|
+
/** A press beside the thumb pages towards it. The thumb itself stops its press from reaching here. */
|
|
87
|
+
const onTrackPointerdown = (event) => {
|
|
88
|
+
if (event.button !== 0) return;
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
const track = event.currentTarget;
|
|
91
|
+
const bounds = track.getBoundingClientRect();
|
|
92
|
+
const isReversed = !isVertical && getComputedStyle(track).direction === "rtl";
|
|
93
|
+
let pressed;
|
|
94
|
+
if (isVertical) pressed = event.clientY - bounds.top;
|
|
95
|
+
else if (isReversed) pressed = bounds.right - event.clientX;
|
|
96
|
+
else pressed = event.clientX - bounds.left;
|
|
97
|
+
const page = Math.round(viewport.value * PAGE_FRACTION) * (pressed > thumbOffset.value ? 1 : -1);
|
|
98
|
+
scrollTo(offset.value + (isReversed ? -page : page));
|
|
99
|
+
};
|
|
100
|
+
const trackStyle = computed(() => isVertical ? {
|
|
101
|
+
height: `${trackLength.value}px`,
|
|
102
|
+
width: `${THICKNESS}px`
|
|
103
|
+
} : {
|
|
104
|
+
height: `${THICKNESS}px`,
|
|
105
|
+
top: `${across(scroll.size.value) - THICKNESS}px`,
|
|
106
|
+
width: `${trackLength.value}px`
|
|
107
|
+
});
|
|
108
|
+
const thumbStyle = computed(() => isVertical ? {
|
|
109
|
+
height: `${thumbLength.value}px`,
|
|
110
|
+
top: `${thumbOffset.value}px`
|
|
111
|
+
} : {
|
|
112
|
+
"inset-inline-start": `${thumbOffset.value}px`,
|
|
113
|
+
width: `${thumbLength.value}px`
|
|
114
|
+
});
|
|
115
|
+
return createIf(() => isVisible.value, () => {
|
|
116
|
+
const n3 = t0();
|
|
117
|
+
const n2 = child(n3);
|
|
118
|
+
on(n2, "pointerdown", onThumbPointerdown);
|
|
119
|
+
on(n2, "pointerenter", (e) => unref(states).onPointerenter(e));
|
|
120
|
+
on(n2, "pointerleave", (e) => unref(states).onPointerleave(e));
|
|
121
|
+
on(n3, "pointerdown", onTrackPointerdown);
|
|
122
|
+
renderEffect(() => {
|
|
123
|
+
const _styles = unref(styles);
|
|
124
|
+
const _orientation = __props.orientation;
|
|
125
|
+
const _dataAttr = unref(dataAttr);
|
|
126
|
+
const _states = unref(states);
|
|
127
|
+
setClass(n3, _styles.scrollbarTrack());
|
|
128
|
+
setAttr(n3, "data-orientation", _orientation);
|
|
129
|
+
setStyle(n3, trackStyle.value);
|
|
130
|
+
setClass(n2, _styles.scrollbarThumb());
|
|
131
|
+
setAttr(n2, "data-hovered", _dataAttr(_states.isHovered.value));
|
|
132
|
+
setAttr(n2, "data-orientation", _orientation);
|
|
133
|
+
setAttr(n2, "data-pressed", _dataAttr(_states.isPressed.value));
|
|
134
|
+
setStyle(n2, thumbStyle.value);
|
|
135
|
+
});
|
|
136
|
+
return n3;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
//#endregion
|
|
141
|
+
export { virtualizer_scrollbar_track_vue_vue_type_script_setup_true_vapor_true_lang_default as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare const __VLS_export: (__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>['props'], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, 'attrs' | 'emit' | 'slots'>>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>['expose'], __VLS_setup?: Promise<{
|
|
2
|
+
props: import('vue').PublicProps & (typeof globalThis extends {
|
|
3
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
4
|
+
} ? P : {});
|
|
5
|
+
expose: (exposed: {}) => void;
|
|
6
|
+
attrs: any;
|
|
7
|
+
slots: {};
|
|
8
|
+
emit: {};
|
|
9
|
+
}>) => import('vue').VNode & {
|
|
10
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
11
|
+
};
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
14
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
15
|
+
[K in keyof T]: T[K];
|
|
16
|
+
} : {
|
|
17
|
+
[K in keyof T as K]: T[K];
|
|
18
|
+
}) & {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useVirtualizerStateContext } from "./virtualizer.context.js";
|
|
2
|
+
import virtualizer_scrollbar_track_default from "./virtualizer-scrollbar-track.js";
|
|
3
|
+
import { computed, createComponent, defineVaporComponent, renderEffect, setClass, setInsertionState, setStyle, template, unref } from "vue";
|
|
4
|
+
import { virtualizerVariants } from "@ropav/styles";
|
|
5
|
+
//#region src/components/virtualizer/virtualizer-scrollbar.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
6
|
+
var t0 = template("<div aria-hidden=true data-slot=virtualizer-scrollbar>", 1);
|
|
7
|
+
/**
|
|
8
|
+
* The scrollbar a windowed collection draws for itself, in place of the native one it hides.
|
|
9
|
+
*
|
|
10
|
+
* A native thumb is moved by the compositor, which draws every frame at the new offset with
|
|
11
|
+
* whatever rows the main thread last committed — and across a long collection those rows are
|
|
12
|
+
* always somewhere else, so the window is empty for as long as the main thread takes to catch up.
|
|
13
|
+
* This thumb is moved by the main thread: a pointer move sets the offset and the rows for it in
|
|
14
|
+
* one task, so no frame is ever drawn with rows that were built for another offset. Wheel,
|
|
15
|
+
* trackpad and keyboard scrolling stay native, and the thumb follows them.
|
|
16
|
+
*
|
|
17
|
+
* A pointer affordance and nothing more, like the native one: the box stays the focusable
|
|
18
|
+
* scroller and the keyboard reaches every offset through it. Hidden from assistive technology for
|
|
19
|
+
* the same reason a native scrollbar is not exposed.
|
|
20
|
+
*
|
|
21
|
+
* Rendered by the collection as the first child of its content wrapper — inside the wrapper rather
|
|
22
|
+
* than beside it, because a stuck box cannot leave its containing block, and only the wrapper is
|
|
23
|
+
* tall enough to stay stuck to for the whole of the scroll. A stuck box is held inside the scroll
|
|
24
|
+
* container's content box, so on a padded container it sits at the content's corner, not the
|
|
25
|
+
* container's; the difference is the padding, and it is given back with a translation, which
|
|
26
|
+
* sticky positioning leaves alone. A track along the edge then runs the full length of the box.
|
|
27
|
+
*/
|
|
28
|
+
var virtualizer_scrollbar_vue_vue_type_script_setup_true_vapor_true_lang_default = /*@__PURE__*/ defineVaporComponent({
|
|
29
|
+
__name: "virtualizer-scrollbar",
|
|
30
|
+
setup(__props) {
|
|
31
|
+
const state = useVirtualizerStateContext();
|
|
32
|
+
if (!state) throw new Error("`VirtualizerScrollbar` was rendered outside of a windowed collection.");
|
|
33
|
+
const { scroll } = state;
|
|
34
|
+
const styles = virtualizerVariants();
|
|
35
|
+
const style = computed(() => {
|
|
36
|
+
const { direction, paddingInlineStart, paddingTop } = scroll.box.value;
|
|
37
|
+
return {
|
|
38
|
+
translate: `${direction === "rtl" ? paddingInlineStart : -paddingInlineStart}px ${-paddingTop}px`,
|
|
39
|
+
width: `${scroll.size.value.width}px`
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
const n2 = t0();
|
|
43
|
+
renderEffect(() => {
|
|
44
|
+
setClass(n2, unref(styles).scrollbar());
|
|
45
|
+
setStyle(n2, style.value);
|
|
46
|
+
});
|
|
47
|
+
setInsertionState(n2);
|
|
48
|
+
createComponent(virtualizer_scrollbar_track_default, { orientation: "vertical" });
|
|
49
|
+
setInsertionState(n2, 1);
|
|
50
|
+
createComponent(virtualizer_scrollbar_track_default, { orientation: "horizontal" });
|
|
51
|
+
return n2;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
//#endregion
|
|
55
|
+
export { virtualizer_scrollbar_vue_vue_type_script_setup_true_vapor_true_lang_default as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ScrollBoxInfo, ScrollToOffset } from "../../composables/use-virtualizer-scroll.js";
|
|
1
2
|
import type { ItemDropTarget } from "../../utils/dnd-types.js";
|
|
2
|
-
import type { Size } from "../../utils/virtualizer-geometry.js";
|
|
3
|
+
import type { Point, Size } from "../../utils/virtualizer-geometry.js";
|
|
3
4
|
import type { Layout } from "../../utils/virtualizer-layout.js";
|
|
4
5
|
import type { LayoutInfo, VirtualizerKey } from "../../utils/virtualizer-layout-info.js";
|
|
5
6
|
import type { ComputedRef, ShallowRef } from "vue";
|
|
@@ -19,8 +20,23 @@ export interface VirtualizerConfigContext {
|
|
|
19
20
|
* for one would make `Virtualizer` mandatory for every listbox in the library.
|
|
20
21
|
*/
|
|
21
22
|
export declare const useVirtualizerConfigContext: () => VirtualizerConfigContext | null, provideVirtualizerConfigContext: (value: VirtualizerConfigContext | null) => VirtualizerConfigContext | null;
|
|
23
|
+
/** The scroll box as the scrollbar a windowed collection draws for itself reads it. */
|
|
24
|
+
export interface VirtualizerScrollState {
|
|
25
|
+
/** How far the box is scrolled. The inline axis runs negative in a right-to-left box. */
|
|
26
|
+
offset: ComputedRef<Point>;
|
|
27
|
+
/** The box's own size, which is what it shows of the content at once. */
|
|
28
|
+
size: ComputedRef<Size>;
|
|
29
|
+
/** The box's scrollable overflow — everything it could show. */
|
|
30
|
+
scrollSize: ComputedRef<Size>;
|
|
31
|
+
/** The box's padding, and which of its axes scroll at all. */
|
|
32
|
+
box: ComputedRef<ScrollBoxInfo>;
|
|
33
|
+
/** Scrolls the box from the main thread, so the rows and the offset are committed together. */
|
|
34
|
+
scrollTo: (offset: ScrollToOffset) => void;
|
|
35
|
+
}
|
|
22
36
|
/** What a virtualized collection hands its own parts, so they can describe themselves. */
|
|
23
37
|
export interface VirtualizerStateContext {
|
|
38
|
+
/** The scroll box, for the scrollbar the collection draws in place of the native one. */
|
|
39
|
+
scroll: VirtualizerScrollState;
|
|
24
40
|
/** How many items the collection holds, which is not how many are rendered. */
|
|
25
41
|
itemCount: ComputedRef<number>;
|
|
26
42
|
/** An item's position among all of them, zero-based. */
|
|
@@ -109,11 +109,6 @@ var endDragging = () => {
|
|
|
109
109
|
};
|
|
110
110
|
/** Whether a keyboard or screen reader drag is in flight. */
|
|
111
111
|
var isVirtualDragging = () => dragSession != null;
|
|
112
|
-
/** Whether an element is inside a registered drop target. */
|
|
113
|
-
var isValidDropTarget = (element) => {
|
|
114
|
-
for (const target of dropTargets.keys()) if (contains(target, element)) return true;
|
|
115
|
-
return false;
|
|
116
|
-
};
|
|
117
112
|
/**
|
|
118
113
|
* The session in flight, as a ref that updates when one starts or ends.
|
|
119
114
|
*
|
|
@@ -432,12 +427,5 @@ var DragSession = class {
|
|
|
432
427
|
}, dropItem?.target ?? null);
|
|
433
428
|
}
|
|
434
429
|
};
|
|
435
|
-
/**
|
|
436
|
-
* The session in flight, read once.
|
|
437
|
-
*
|
|
438
|
-
* The imperative sibling of `useDragSession`, for callers that are not inside an effect scope —
|
|
439
|
-
* an event handler deciding whether a keystroke belongs to a drag, or a test ending one.
|
|
440
|
-
*/
|
|
441
|
-
var getDragSession = () => dragSession;
|
|
442
430
|
//#endregion
|
|
443
|
-
export { DragSession, beginDragging,
|
|
431
|
+
export { DragSession, beginDragging, isVirtualDragging, registerDropItem, registerDropTarget, useDragSession };
|
|
@@ -1,76 +1,32 @@
|
|
|
1
|
-
export * from "./drag-collection.js";
|
|
2
|
-
export * from "./drag-manager.js";
|
|
3
|
-
export * from "./drag-modality.js";
|
|
4
|
-
export * from "./droppable-collection-registry.js";
|
|
5
1
|
export * from "./focus-responder.js";
|
|
6
2
|
export * from "./press-responder.js";
|
|
7
|
-
export * from "./table-drag-collection.js";
|
|
8
|
-
export * from "./use-auto-scroll.js";
|
|
9
|
-
export * from "./use-autocomplete.js";
|
|
10
|
-
export * from "./use-calendar.js";
|
|
11
|
-
export * from "./use-calendar-cell.js";
|
|
12
|
-
export * from "./use-calendar-grid.js";
|
|
13
|
-
export * from "./use-calendar-heading.js";
|
|
14
3
|
export * from "./use-calendar-state.js";
|
|
15
|
-
export * from "./use-calendar-year-picker.js";
|
|
16
4
|
export * from "./use-checkbox-group-state.js";
|
|
17
5
|
export * from "./use-collator.js";
|
|
18
6
|
export * from "./use-collection.js";
|
|
19
|
-
export * from "./use-collection-auto-focus.js";
|
|
20
|
-
export * from "./use-combo-box.js";
|
|
21
|
-
export * from "./use-combo-box-state.js";
|
|
22
|
-
export * from "./use-color-area.js";
|
|
23
|
-
export * from "./use-color-area-gradient.js";
|
|
24
7
|
export * from "./use-color-area-state.js";
|
|
25
|
-
export * from "./use-color-channel-field.js";
|
|
26
8
|
export * from "./use-color-channel-field-state.js";
|
|
27
|
-
export * from "./use-color-field.js";
|
|
28
9
|
export * from "./use-color-field-state.js";
|
|
29
10
|
export * from "./use-color-picker-state.js";
|
|
30
|
-
export * from "./use-color-slider.js";
|
|
31
11
|
export * from "./use-color-slider-state.js";
|
|
32
|
-
export * from "./use-
|
|
12
|
+
export * from "./use-combo-box-state.js";
|
|
33
13
|
export * from "./use-controllable-state.js";
|
|
34
14
|
export * from "./use-css-variable.js";
|
|
35
|
-
export * from "./use-date-field.js";
|
|
36
15
|
export * from "./use-date-field-state.js";
|
|
37
16
|
export * from "./use-date-formatter.js";
|
|
38
|
-
export * from "./use-date-picker.js";
|
|
39
|
-
export * from "./use-date-picker-group.js";
|
|
40
17
|
export * from "./use-date-picker-state.js";
|
|
41
|
-
export * from "./use-date-
|
|
42
|
-
export * from "./use-default-date-props.js";
|
|
18
|
+
export * from "./use-date-range-picker-state.js";
|
|
43
19
|
export * from "./use-description.js";
|
|
44
|
-
export * from "./use-dialog-trigger.js";
|
|
45
20
|
export * from "./use-disclosure-group.js";
|
|
46
|
-
export * from "./use-disclosure-group-navigation.js";
|
|
47
|
-
export * from "./use-disclosure-panel.js";
|
|
48
21
|
export * from "./use-dismissable.js";
|
|
49
|
-
export * from "./use-display-names.js";
|
|
50
|
-
export * from "./use-drag.js";
|
|
51
22
|
export * from "./use-drag-and-drop.js";
|
|
52
|
-
export * from "./use-draggable-collection.js";
|
|
53
|
-
export * from "./use-draggable-collection-state.js";
|
|
54
|
-
export * from "./use-draggable-item.js";
|
|
55
|
-
export * from "./use-drawer-drag.js";
|
|
56
|
-
export * from "./use-drop.js";
|
|
57
|
-
export * from "./use-drop-indicator.js";
|
|
58
|
-
export * from "./use-droppable-collection.js";
|
|
59
|
-
export * from "./use-droppable-collection-state.js";
|
|
60
|
-
export * from "./use-droppable-item.js";
|
|
61
23
|
export * from "./use-enter-exit.js";
|
|
62
24
|
export * from "./use-field-ids.js";
|
|
63
25
|
export * from "./use-filter.js";
|
|
64
26
|
export * from "./use-focus-scope.js";
|
|
65
27
|
export * from "./use-form-reset.js";
|
|
66
|
-
export * from "./use-form-validation.js";
|
|
67
28
|
export * from "./use-form-validation-state.js";
|
|
68
|
-
export * from "./use-formatted-text-field.js";
|
|
69
|
-
export * from "./use-grid-keyboard.js";
|
|
70
|
-
export * from "./use-grid-selection-announcement.js";
|
|
71
29
|
export * from "./use-id.js";
|
|
72
|
-
export * from "./use-image-loading-status.js";
|
|
73
|
-
export * from "./use-input-otp.js";
|
|
74
30
|
export * from "./use-interaction-states.js";
|
|
75
31
|
export * from "./use-labels.js";
|
|
76
32
|
export * from "./use-list-data.js";
|
|
@@ -78,48 +34,24 @@ export * from "./use-list-keyboard.js";
|
|
|
78
34
|
export * from "./use-locale.js";
|
|
79
35
|
export * from "./use-localized-string-formatter.js";
|
|
80
36
|
export * from "./use-long-press.js";
|
|
81
|
-
export * from "./use-measured-height.js";
|
|
82
37
|
export * from "./use-media-query.js";
|
|
83
|
-
export * from "./use-menu.js";
|
|
84
|
-
export * from "./use-modal-overlay.js";
|
|
85
|
-
export * from "./use-modal-transition.js";
|
|
86
38
|
export * from "./use-move.js";
|
|
87
|
-
export * from "./use-number-field.js";
|
|
88
39
|
export * from "./use-number-field-state.js";
|
|
89
40
|
export * from "./use-number-formatter.js";
|
|
90
41
|
export * from "./use-overlay-position.js";
|
|
91
|
-
export * from "./use-overlay-trigger.js";
|
|
92
42
|
export * from "./use-overlay-trigger-state.js";
|
|
93
|
-
export * from "./use-password-manager-badge.js";
|
|
94
43
|
export * from "./use-press.js";
|
|
95
44
|
export * from "./use-prevent-scroll.js";
|
|
96
45
|
export * from "./use-radio-group-state.js";
|
|
97
|
-
export * from "./use-range-calendar.js";
|
|
98
46
|
export * from "./use-range-calendar-state.js";
|
|
99
|
-
export * from "./use-safely-mouse-to-submenu.js";
|
|
100
|
-
export * from "./use-scroll-wheel.js";
|
|
101
|
-
export * from "./use-search-field.js";
|
|
102
|
-
export * from "./use-select.js";
|
|
103
47
|
export * from "./use-select-state.js";
|
|
104
48
|
export * from "./use-selection-manager.js";
|
|
105
|
-
export * from "./use-
|
|
106
|
-
export * from "./use-slider.js";
|
|
49
|
+
export * from "./use-single-select-list-state.js";
|
|
107
50
|
export * from "./use-slider-state.js";
|
|
108
|
-
export * from "./use-slider-thumb.js";
|
|
109
|
-
export * from "./use-spin-button.js";
|
|
110
51
|
export * from "./use-tab-list-state.js";
|
|
111
|
-
export * from "./use-table-collection.js";
|
|
112
|
-
export * from "./use-table-column-layout.js";
|
|
113
|
-
export * from "./use-text-field.js";
|
|
114
52
|
export * from "./use-time-field-state.js";
|
|
115
53
|
export * from "./use-toast.js";
|
|
116
|
-
export * from "./use-toast-region.js";
|
|
117
54
|
export * from "./use-toggle-group-state.js";
|
|
118
|
-
export * from "./use-toolbar.js";
|
|
119
|
-
export * from "./use-tooltip-trigger.js";
|
|
120
55
|
export * from "./use-tooltip-trigger-state.js";
|
|
121
56
|
export * from "./use-typeahead.js";
|
|
122
57
|
export * from "./use-viewport-size.js";
|
|
123
|
-
export * from "./use-virtual-drop.js";
|
|
124
|
-
export * from "./use-virtualizer.js";
|
|
125
|
-
export * from "./use-virtualizer-scroll.js";
|
|
@@ -33,6 +33,13 @@ export interface UseCollectionReturn {
|
|
|
33
33
|
getKeyBefore: (key: CollectionKey) => CollectionKey | null;
|
|
34
34
|
/** The item's position among its siblings, or `-1` when it is not in the collection. */
|
|
35
35
|
getIndex: (key: CollectionKey) => number;
|
|
36
|
+
/**
|
|
37
|
+
* Run `operation` against a single reading of the collection's order.
|
|
38
|
+
*
|
|
39
|
+
* Wrap anything that walks the collection more than once — arrow navigation, paging, typeahead,
|
|
40
|
+
* extending a selection. See {@link useCollection} for why this is scoped rather than cached.
|
|
41
|
+
*/
|
|
42
|
+
withOrder: <T>(operation: () => T) => T;
|
|
36
43
|
/** Register an item and return the call that unregisters it. */
|
|
37
44
|
register: (key: CollectionKey, meta: CollectionItemMeta) => () => void;
|
|
38
45
|
}
|
|
@@ -44,7 +51,7 @@ export interface UseCollectionReturn {
|
|
|
44
51
|
* rendering a slot is what creates its DOM, so there is no "render to inspect" pass. The flow
|
|
45
52
|
* is inverted instead — each item registers itself, and the parent asks the DOM for the order.
|
|
46
53
|
*
|
|
47
|
-
*
|
|
54
|
+
* Three choices carry the weight:
|
|
48
55
|
*
|
|
49
56
|
* Metadata is stored as **getters**, not values, so the parent always reads an item's current
|
|
50
57
|
* text and disabled state. Nothing has to re-register when a prop changes, and no
|
|
@@ -54,8 +61,20 @@ export interface UseCollectionReturn {
|
|
|
54
61
|
* invalidated by a counter bumped on register and unregister — but reordering items that are
|
|
55
62
|
* already registered changes their document order without touching that counter, which would
|
|
56
63
|
* silently break arrow navigation. Order is only ever read on an interaction (a keypress, a
|
|
57
|
-
* focus change, extending a selection), never during render, so
|
|
58
|
-
*
|
|
64
|
+
* focus change, extending a selection), never during render, so `size` stays reactive — because
|
|
65
|
+
* it *is* read during render — while order deliberately stays outside reactivity.
|
|
66
|
+
*
|
|
67
|
+
* Sorting the DOM per call, however, is only cheap for a *single* read, and the callers that
|
|
68
|
+
* matter walk the collection one neighbour at a time: typeahead, paging, and skipping disabled
|
|
69
|
+
* items all ask for a neighbour in a loop. Sorting inside that loop is quadratic, and a search
|
|
70
|
+
* that matches nothing walks the whole collection twice. {@link UseCollectionReturn.withOrder}
|
|
71
|
+
* is what those callers wrap themselves in: the order is read once and every step reads that one
|
|
72
|
+
* snapshot.
|
|
73
|
+
*
|
|
74
|
+
* The snapshot is **scoped to one synchronous operation** rather than cached across operations,
|
|
75
|
+
* because caching is the very thing the second choice above rules out. Vue flushes renders on
|
|
76
|
+
* `nextTick`, so the DOM cannot reorder itself in the middle of a keydown handler — which is
|
|
77
|
+
* exactly as long as a snapshot is allowed to live. It must never become a `computed`.
|
|
59
78
|
*
|
|
60
79
|
* A collection that is virtualized cannot work that way at all: all but a window of its items are
|
|
61
80
|
* absent from the DOM, so asking the DOM would answer for the window and call the rest
|