ropav 0.4.0 → 0.6.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/drop-zone/drop-zone-root.d.ts +23 -0
- package/dist/components/drop-zone/drop-zone-root.js +153 -0
- package/dist/components/drop-zone/drop-zone-trigger.d.ts +21 -0
- package/dist/components/drop-zone/drop-zone-trigger.js +20 -0
- package/dist/components/drop-zone/drop-zone.accept.d.ts +19 -0
- package/dist/components/drop-zone/drop-zone.accept.js +28 -0
- package/dist/components/drop-zone/drop-zone.context.d.ts +6 -0
- package/dist/components/drop-zone/drop-zone.context.js +5 -0
- package/dist/components/drop-zone/drop-zone.types.d.ts +30 -0
- package/dist/components/drop-zone/index.d.ts +86 -0
- package/dist/components/drop-zone/index.js +11 -0
- 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 +5 -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/progress-bar/index.d.ts +4 -0
- package/dist/components/progress-bar/progress-bar-root.js +4 -0
- package/dist/components/progress-bar/progress-bar.types.d.ts +7 -0
- 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 +546 -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 +140 -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 +273 -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 -70
- 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.d.ts +6 -5
- package/dist/composables/use-draggable-item.d.ts +2 -2
- package/dist/composables/use-droppable-collection.js +3 -3
- 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 +60 -83
- 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 +25 -5
- package/dist/composables/use-table-column-layout.js +0 -214
- /package/dist/{composables → components/dropdown}/use-safely-mouse-to-submenu.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ropav",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "🚀 Beautiful and modern Vue UI library built with Vapor Mode and Tailwind CSS 4.0.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -165,6 +165,10 @@
|
|
|
165
165
|
"import": "./dist/components/drawer/index.js",
|
|
166
166
|
"types": "./dist/components/drawer/index.d.ts"
|
|
167
167
|
},
|
|
168
|
+
"./drop-zone": {
|
|
169
|
+
"import": "./dist/components/drop-zone/index.js",
|
|
170
|
+
"types": "./dist/components/drop-zone/index.d.ts"
|
|
171
|
+
},
|
|
168
172
|
"./dropdown": {
|
|
169
173
|
"import": "./dist/components/dropdown/index.js",
|
|
170
174
|
"types": "./dist/components/dropdown/index.d.ts"
|
|
@@ -285,6 +289,10 @@
|
|
|
285
289
|
"import": "./dist/components/range-calendar/index.js",
|
|
286
290
|
"types": "./dist/components/range-calendar/index.d.ts"
|
|
287
291
|
},
|
|
292
|
+
"./router-provider": {
|
|
293
|
+
"import": "./dist/components/router-provider/index.js",
|
|
294
|
+
"types": "./dist/components/router-provider/index.d.ts"
|
|
295
|
+
},
|
|
288
296
|
"./scroll-shadow": {
|
|
289
297
|
"import": "./dist/components/scroll-shadow/index.js",
|
|
290
298
|
"types": "./dist/components/scroll-shadow/index.d.ts"
|
|
@@ -293,6 +301,10 @@
|
|
|
293
301
|
"import": "./dist/components/search-field/index.js",
|
|
294
302
|
"types": "./dist/components/search-field/index.d.ts"
|
|
295
303
|
},
|
|
304
|
+
"./segmented-control": {
|
|
305
|
+
"import": "./dist/components/segmented-control/index.js",
|
|
306
|
+
"types": "./dist/components/segmented-control/index.d.ts"
|
|
307
|
+
},
|
|
296
308
|
"./select": {
|
|
297
309
|
"import": "./dist/components/select/index.js",
|
|
298
310
|
"types": "./dist/components/select/index.d.ts"
|
|
@@ -301,6 +313,10 @@
|
|
|
301
313
|
"import": "./dist/components/separator/index.js",
|
|
302
314
|
"types": "./dist/components/separator/index.d.ts"
|
|
303
315
|
},
|
|
316
|
+
"./sidebar": {
|
|
317
|
+
"import": "./dist/components/sidebar/index.js",
|
|
318
|
+
"types": "./dist/components/sidebar/index.d.ts"
|
|
319
|
+
},
|
|
304
320
|
"./skeleton": {
|
|
305
321
|
"import": "./dist/components/skeleton/index.js",
|
|
306
322
|
"types": "./dist/components/skeleton/index.d.ts"
|
|
@@ -313,6 +329,10 @@
|
|
|
313
329
|
"import": "./dist/components/spinner/index.js",
|
|
314
330
|
"types": "./dist/components/spinner/index.d.ts"
|
|
315
331
|
},
|
|
332
|
+
"./splitter": {
|
|
333
|
+
"import": "./dist/components/splitter/index.js",
|
|
334
|
+
"types": "./dist/components/splitter/index.d.ts"
|
|
335
|
+
},
|
|
316
336
|
"./surface": {
|
|
317
337
|
"import": "./dist/components/surface/index.js",
|
|
318
338
|
"types": "./dist/components/surface/index.d.ts"
|
|
@@ -386,14 +406,14 @@
|
|
|
386
406
|
"access": "public"
|
|
387
407
|
},
|
|
388
408
|
"dependencies": {
|
|
389
|
-
"@internationalized/date": "3.12.
|
|
390
|
-
"@internationalized/number": "3.6.
|
|
409
|
+
"@internationalized/date": "3.12.4",
|
|
410
|
+
"@internationalized/number": "3.6.8",
|
|
391
411
|
"@internationalized/string": "3.2.10",
|
|
392
412
|
"tailwind-variants": "3.3.1",
|
|
393
|
-
"@ropav/styles": "0.
|
|
413
|
+
"@ropav/styles": "0.6.0"
|
|
394
414
|
},
|
|
395
415
|
"peerDependencies": {
|
|
396
416
|
"tailwindcss": ">=4.0.0",
|
|
397
|
-
"vue": "^3.6.0-rc.
|
|
417
|
+
"vue": "^3.6.0-rc.6"
|
|
398
418
|
}
|
|
399
419
|
}
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { computed, shallowRef, toValue, watch } from "vue";
|
|
2
|
-
//#region src/composables/use-table-column-layout.ts
|
|
3
|
-
/** Pixels and percentages are fixed; `fr` units and anything unrecognised flex. */
|
|
4
|
-
var isStaticWidth = (width) => width != null && (!isNaN(width) || /^(\d+)(?=%$)/.test(String(width)));
|
|
5
|
-
/** The number in front of `fr`. Anything else counts as `1fr`, as React Aria has it. */
|
|
6
|
-
var parseFractionalUnit = (width) => {
|
|
7
|
-
if (!width || typeof width === "number") return 1;
|
|
8
|
-
const match = /^(.+)(?=fr$)/.exec(width);
|
|
9
|
-
return match ? parseFloat(match[0]) : 1;
|
|
10
|
-
};
|
|
11
|
-
var parseStaticWidth = (width, tableWidth) => {
|
|
12
|
-
if (typeof width === "number") return width;
|
|
13
|
-
const match = /^(\d+)(?=%$)/.exec(width);
|
|
14
|
-
if (!match) throw new Error("Only percentages or numbers are supported for static column widths");
|
|
15
|
-
return tableWidth * (parseFloat(match[0]) / 100);
|
|
16
|
-
};
|
|
17
|
-
var getMaxWidth = (maxWidth, tableWidth) => maxWidth != null ? parseStaticWidth(maxWidth, tableWidth) : Number.MAX_SAFE_INTEGER;
|
|
18
|
-
/**
|
|
19
|
-
* A minimum cannot be given in `fr`: knowing what a fraction comes to would need every other
|
|
20
|
-
* column's width, which is the very thing being solved for.
|
|
21
|
-
*/
|
|
22
|
-
var getMinWidth = (minWidth, tableWidth) => minWidth != null ? parseStaticWidth(minWidth, tableWidth) : 0;
|
|
23
|
-
/**
|
|
24
|
-
* Round an array of floats that sums to an integer, keeping the sum.
|
|
25
|
-
*
|
|
26
|
-
* Each column has to come out a whole number of pixels, and rounding them one by one would drift:
|
|
27
|
-
* the remainder is carried forward instead, so the total is preserved.
|
|
28
|
-
*/
|
|
29
|
-
var cascadeRounding = (items) => {
|
|
30
|
-
let floatTotal = 0;
|
|
31
|
-
let intTotal = 0;
|
|
32
|
-
return items.map((item) => {
|
|
33
|
-
const rounded = Math.round(item.targetMainSize + floatTotal) - intTotal;
|
|
34
|
-
floatTotal += item.targetMainSize;
|
|
35
|
-
intTotal += rounded;
|
|
36
|
-
return rounded;
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Column widths for one table width, ported from react-stately's `calculateColumnSizes`.
|
|
41
|
-
*
|
|
42
|
-
* This is the CSS flexbox layout algorithm, cut down to the shape a table needs: one row, a flex
|
|
43
|
-
* basis of zero unless the column asked for a static width, and grow and shrink both equal to the
|
|
44
|
-
* column's `fr`. It is deliberately **not** plain pixel sizing — `1fr` columns have to share what
|
|
45
|
-
* the static and percentage columns leave over, and a minimum or maximum on any one of them
|
|
46
|
-
* redistributes the rest.
|
|
47
|
-
*/
|
|
48
|
-
var calculateColumnSizes = (availableWidth, columns, changedColumns, getDefaultWidth, getDefaultMinWidth) => {
|
|
49
|
-
const originalWidth = availableWidth;
|
|
50
|
-
const flooredWidth = Math.floor(availableWidth);
|
|
51
|
-
const hasFractionalWidth = availableWidth - flooredWidth > 0;
|
|
52
|
-
availableWidth = flooredWidth;
|
|
53
|
-
let hasNonFrozenItems = false;
|
|
54
|
-
const items = columns.map((column, index) => {
|
|
55
|
-
const width = changedColumns.get(column.key) ?? column.width ?? column.defaultWidth ?? getDefaultWidth?.(index) ?? "1fr";
|
|
56
|
-
let frozen = false;
|
|
57
|
-
let baseSize = 0;
|
|
58
|
-
let flex = 0;
|
|
59
|
-
let targetMainSize = 0;
|
|
60
|
-
if (isStaticWidth(width)) {
|
|
61
|
-
baseSize = parseStaticWidth(width, availableWidth);
|
|
62
|
-
frozen = true;
|
|
63
|
-
} else {
|
|
64
|
-
flex = parseFractionalUnit(width);
|
|
65
|
-
if (flex <= 0) frozen = true;
|
|
66
|
-
}
|
|
67
|
-
const min = getMinWidth(column.minWidth ?? getDefaultMinWidth?.(index) ?? 0, availableWidth);
|
|
68
|
-
const max = getMaxWidth(column.maxWidth, availableWidth);
|
|
69
|
-
const hypotheticalMainSize = Math.max(min, Math.min(baseSize, max));
|
|
70
|
-
if (frozen) targetMainSize = hypotheticalMainSize;
|
|
71
|
-
else if (baseSize > hypotheticalMainSize) {
|
|
72
|
-
frozen = true;
|
|
73
|
-
targetMainSize = hypotheticalMainSize;
|
|
74
|
-
}
|
|
75
|
-
if (!frozen) hasNonFrozenItems = true;
|
|
76
|
-
return {
|
|
77
|
-
baseSize,
|
|
78
|
-
flex,
|
|
79
|
-
frozen,
|
|
80
|
-
hypotheticalMainSize,
|
|
81
|
-
max,
|
|
82
|
-
min,
|
|
83
|
-
targetMainSize,
|
|
84
|
-
violation: 0
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
while (hasNonFrozenItems) {
|
|
88
|
-
let usedWidth = 0;
|
|
89
|
-
let flexFactors = 0;
|
|
90
|
-
for (const item of items) if (item.frozen) usedWidth += item.targetMainSize;
|
|
91
|
-
else {
|
|
92
|
-
usedWidth += item.baseSize;
|
|
93
|
-
flexFactors += item.flex;
|
|
94
|
-
}
|
|
95
|
-
const remainingFreeSpace = availableWidth - usedWidth;
|
|
96
|
-
if (remainingFreeSpace > 0) {
|
|
97
|
-
for (const item of items) if (!item.frozen) item.targetMainSize = item.baseSize + item.flex / flexFactors * remainingFreeSpace;
|
|
98
|
-
}
|
|
99
|
-
let totalViolation = 0;
|
|
100
|
-
for (const item of items) {
|
|
101
|
-
item.violation = 0;
|
|
102
|
-
if (item.frozen) continue;
|
|
103
|
-
const unclamped = item.targetMainSize;
|
|
104
|
-
item.targetMainSize = Math.max(item.min, Math.min(unclamped, item.max));
|
|
105
|
-
item.violation = item.targetMainSize - unclamped;
|
|
106
|
-
totalViolation += item.violation;
|
|
107
|
-
}
|
|
108
|
-
hasNonFrozenItems = false;
|
|
109
|
-
for (const item of items) if (totalViolation === 0 || Math.sign(totalViolation) === Math.sign(item.violation)) item.frozen = true;
|
|
110
|
-
else if (!item.frozen) hasNonFrozenItems = true;
|
|
111
|
-
}
|
|
112
|
-
const sizes = cascadeRounding(items);
|
|
113
|
-
if (hasFractionalWidth && sizes.length > 0) {
|
|
114
|
-
const fraction = originalWidth.toString().split(".")[1];
|
|
115
|
-
sizes[sizes.length - 1] = Number(`${sizes.at(-1)}.${fraction}`);
|
|
116
|
-
}
|
|
117
|
-
return sizes;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Every column's width in pixels, keyed by column, ported from react-stately's
|
|
121
|
-
* `TableColumnLayout.buildColumnWidths`.
|
|
122
|
-
*
|
|
123
|
-
* The sizing itself is `calculateColumnSizes` above; what this adds is the pair of defaults a
|
|
124
|
-
* table falls back to — `1fr` for a width nobody declared, and a 75px floor — and the mapping back
|
|
125
|
-
* onto keys. Both the resizable container and the virtualizer's table layout need exactly that,
|
|
126
|
-
* and the two must agree: a column laid out at one width by the browser and at another by the
|
|
127
|
-
* layout would put every cell in the wrong place.
|
|
128
|
-
*
|
|
129
|
-
* @param changedWidths Widths that override what the columns declare, as a resize in flight does.
|
|
130
|
-
*/
|
|
131
|
-
var buildColumnWidths = (availableWidth, columns, changedWidths = /* @__PURE__ */ new Map(), options = {}) => {
|
|
132
|
-
const getDefaultWidth = options.getDefaultWidth ?? (() => "1fr");
|
|
133
|
-
const getDefaultMinWidth = options.getDefaultMinWidth ?? (() => 75);
|
|
134
|
-
const sizes = calculateColumnSizes(availableWidth, columns, changedWidths, (index) => getDefaultWidth(columns[index]), (index) => getDefaultMinWidth(columns[index]));
|
|
135
|
-
return new Map(columns.map((column, index) => [column.key, sizes[index] ?? 0]));
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* Column widths for a resizable table, ported from react-stately's `TableColumnLayout` and
|
|
139
|
-
* `useTableColumnResizeState`.
|
|
140
|
-
*
|
|
141
|
-
* Two things are worth knowing before changing any of it. A column whose `width` the caller set is
|
|
142
|
-
* **controlled**: a resize never writes to it. And dragging one column's edge freezes every column
|
|
143
|
-
* to its **left** at the pixel width it currently has, which is what stops the whole table from
|
|
144
|
-
* reflowing while the pointer moves — the columns to the right keep their declared sizes and
|
|
145
|
-
* absorb the difference.
|
|
146
|
-
*/
|
|
147
|
-
var useTableColumnLayout = (options) => {
|
|
148
|
-
const getDefaultWidth = options.getDefaultWidth ?? (() => "1fr");
|
|
149
|
-
const getDefaultMinWidth = options.getDefaultMinWidth ?? (() => 75);
|
|
150
|
-
const resizingColumn = shallowRef(null);
|
|
151
|
-
const uncontrolledColumns = () => options.columns().filter((column) => column.width == null);
|
|
152
|
-
const initialUncontrolledWidths = () => new Map(uncontrolledColumns().map((column) => [column.key, column.defaultWidth ?? getDefaultWidth(column) ?? "1fr"]));
|
|
153
|
-
const uncontrolledWidths = shallowRef(initialUncontrolledWidths());
|
|
154
|
-
watch(() => options.columns().map((column) => column.key).join(" "), () => {
|
|
155
|
-
uncontrolledWidths.value = initialUncontrolledWidths();
|
|
156
|
-
});
|
|
157
|
-
/** The declared width of every column, with the uncontrolled ones taken from state. */
|
|
158
|
-
const combinedWidths = () => new Map(options.columns().map((column) => [column.key, uncontrolledWidths.value.get(column.key) ?? column.width ?? "1fr"]));
|
|
159
|
-
const layout = computed(() => {
|
|
160
|
-
const columns = options.columns();
|
|
161
|
-
const tableWidth = toValue(options.tableWidth);
|
|
162
|
-
const widths = buildColumnWidths(tableWidth, columns, combinedWidths(), {
|
|
163
|
-
getDefaultMinWidth,
|
|
164
|
-
getDefaultWidth
|
|
165
|
-
});
|
|
166
|
-
const minWidths = /* @__PURE__ */ new Map();
|
|
167
|
-
const maxWidths = /* @__PURE__ */ new Map();
|
|
168
|
-
for (const column of columns) {
|
|
169
|
-
minWidths.set(column.key, getMinWidth(column.minWidth ?? getDefaultMinWidth(column), tableWidth));
|
|
170
|
-
maxWidths.set(column.key, getMaxWidth(column.maxWidth, tableWidth));
|
|
171
|
-
}
|
|
172
|
-
return {
|
|
173
|
-
maxWidths,
|
|
174
|
-
minWidths,
|
|
175
|
-
widths
|
|
176
|
-
};
|
|
177
|
-
});
|
|
178
|
-
const getColumnWidth = (key) => layout.value.widths.get(key) ?? 0;
|
|
179
|
-
const getColumnMinWidth = (key) => layout.value.minWidths.get(key) ?? 0;
|
|
180
|
-
const getColumnMaxWidth = (key) => layout.value.maxWidths.get(key) ?? 0;
|
|
181
|
-
const updateResizedColumns = (key, width) => {
|
|
182
|
-
const previous = layout.value.widths;
|
|
183
|
-
const declared = combinedWidths();
|
|
184
|
-
const clamped = Math.max(getColumnMinWidth(key), Math.min(getColumnMaxWidth(key), Math.floor(width)));
|
|
185
|
-
const next = /* @__PURE__ */ new Map();
|
|
186
|
-
let freeze = true;
|
|
187
|
-
for (const column of options.columns()) if (column.key === key) {
|
|
188
|
-
next.set(column.key, clamped);
|
|
189
|
-
freeze = false;
|
|
190
|
-
} else if (freeze) next.set(column.key, previous.get(column.key) ?? 0);
|
|
191
|
-
else next.set(column.key, column.width ?? declared.get(column.key) ?? "1fr");
|
|
192
|
-
const committed = /* @__PURE__ */ new Map();
|
|
193
|
-
for (const column of uncontrolledColumns()) committed.set(column.key, next.get(column.key) ?? "1fr");
|
|
194
|
-
committed.set(key, clamped);
|
|
195
|
-
uncontrolledWidths.value = committed;
|
|
196
|
-
return next;
|
|
197
|
-
};
|
|
198
|
-
return {
|
|
199
|
-
columnWidths: computed(() => layout.value.widths),
|
|
200
|
-
endResize: () => {
|
|
201
|
-
resizingColumn.value = null;
|
|
202
|
-
},
|
|
203
|
-
getColumnMaxWidth,
|
|
204
|
-
getColumnMinWidth,
|
|
205
|
-
getColumnWidth,
|
|
206
|
-
resizingColumn: computed(() => resizingColumn.value),
|
|
207
|
-
startResize: (key) => {
|
|
208
|
-
resizingColumn.value = key;
|
|
209
|
-
},
|
|
210
|
-
updateResizedColumns
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
//#endregion
|
|
214
|
-
export { buildColumnWidths, calculateColumnSizes, getMaxWidth, getMinWidth, isStaticWidth, parseFractionalUnit, parseStaticWidth, useTableColumnLayout };
|
|
File without changes
|