@kuina-ui/vue 0.6.0 → 0.7.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/blocks/pagination/Pagination.js +4 -0
- package/dist/blocks/pagination/Pagination.vue.d.ts +39 -0
- package/dist/blocks/pagination/Pagination.vue_vue_type_script_setup_true_lang.js +151 -0
- package/dist/blocks/pagination/index.d.ts +2 -0
- package/dist/blocks/pagination/pagination.theme.d.ts +12 -0
- package/dist/blocks/pagination/pagination.theme.js +12 -0
- package/dist/blocks/table/Table.js +4 -0
- package/dist/blocks/table/Table.vue.d.ts +149 -0
- package/dist/blocks/table/Table.vue_vue_type_script_setup_true_lang.js +933 -0
- package/dist/blocks/table/TableCellText.js +4 -0
- package/dist/blocks/table/TableCellText.vue.d.ts +8 -0
- package/dist/blocks/table/TableCellText.vue_vue_type_script_setup_true_lang.js +30 -0
- package/dist/blocks/table/index.d.ts +2 -0
- package/dist/blocks/table/table.theme.d.ts +286 -0
- package/dist/blocks/table/table.theme.js +391 -0
- package/dist/blocks/table/useLoadMoreTrigger.d.ts +11 -0
- package/dist/blocks/table/useLoadMoreTrigger.js +31 -0
- package/dist/blocks/table/usePinnedColumnOffsets.d.ts +10 -0
- package/dist/blocks/table/usePinnedColumnOffsets.js +63 -0
- package/dist/blocks/table/useRowReorder.d.ts +18 -0
- package/dist/blocks/table/useRowReorder.js +92 -0
- package/dist/blocks/table/useRowVirtualizer.d.ts +17 -0
- package/dist/blocks/table/useRowVirtualizer.js +45 -0
- package/dist/blocks/table/useTableSections.d.ts +46 -0
- package/dist/blocks/table/useTableSections.js +86 -0
- package/dist/components/alert/Alert.js +4 -0
- package/dist/components/alert/Alert.vue.d.ts +2 -2
- package/dist/components/alert/Alert.vue_vue_type_script_setup_true_lang.js +87 -0
- package/dist/components/alert/alert.theme.js +93 -0
- package/dist/components/avatar-group/AvatarGroup.js +4 -0
- package/dist/components/avatar-group/AvatarGroup.vue.d.ts +1 -1
- package/dist/components/avatar-group/AvatarGroup.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/components/avatar-group/avatar-group.theme.js +22 -0
- package/dist/components/date-picker/DateCalendar.js +4 -0
- package/dist/components/date-picker/DateCalendar.vue_vue_type_script_setup_true_lang.js +194 -0
- package/dist/components/date-picker/DateCalendarMonth.js +4 -0
- package/dist/components/date-picker/DateCalendarMonth.vue_vue_type_script_setup_true_lang.js +106 -0
- package/dist/components/date-picker/DateCalendarPopover.js +4 -0
- package/dist/components/date-picker/DateCalendarPopover.vue_vue_type_script_setup_true_lang.js +161 -0
- package/dist/components/date-picker/DatePicker.js +4 -0
- package/dist/components/date-picker/DatePicker.vue.d.ts +6 -6
- package/dist/components/date-picker/DatePicker.vue_vue_type_script_setup_true_lang.js +224 -0
- package/dist/components/date-picker/DatePickerField.js +4 -0
- package/dist/components/date-picker/DatePickerField.vue.d.ts +6 -6
- package/dist/components/date-picker/DatePickerField.vue_vue_type_script_setup_true_lang.js +241 -0
- package/dist/components/date-picker/DatePickerPanel.js +4 -0
- package/dist/components/date-picker/DatePickerPanel.vue_vue_type_script_setup_true_lang.js +55 -0
- package/dist/components/date-picker/DateRangePicker.js +4 -0
- package/dist/components/date-picker/DateRangePicker.vue.d.ts +6 -6
- package/dist/components/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.js +212 -0
- package/dist/components/date-picker/DateRangePickerField.js +4 -0
- package/dist/components/date-picker/DateRangePickerField.vue.d.ts +7 -7
- package/dist/components/date-picker/DateRangePickerField.vue_vue_type_script_setup_true_lang.js +228 -0
- package/dist/components/date-picker/date-calendar.theme.js +46 -0
- package/dist/components/date-picker/date-picker.theme.js +16 -0
- package/dist/components/date-picker/useDatePickerControl.js +47 -0
- package/dist/components/date-picker/useDatePickerPopover.js +39 -0
- package/dist/components/date-picker/useDateRangeSelection.js +50 -0
- package/dist/components/date-picker/useDateRangeTyping.js +59 -0
- package/dist/components/date-picker/useDateTypingFocus.js +37 -0
- package/dist/components/date-picker/useSingleDateSelection.js +11 -0
- package/dist/components/date-picker/useSingleDateTyping.js +31 -0
- package/dist/components/date-picker/useTypedDateInput.js +39 -0
- package/dist/components/menu/Menu.js +4 -0
- package/dist/components/menu/Menu.vue.d.ts +3 -2
- package/dist/components/menu/Menu.vue_vue_type_script_setup_true_lang.js +137 -0
- package/dist/components/menu/MenuItemRow.js +4 -0
- package/dist/components/menu/MenuItemRow.vue_vue_type_script_setup_true_lang.js +117 -0
- package/dist/components/menu/MenuPanel.js +4 -0
- package/dist/components/menu/MenuPanel.vue.d.ts +2 -1
- package/dist/components/menu/MenuPanel.vue_vue_type_script_setup_true_lang.js +249 -0
- package/dist/components/menu/menu.theme.d.ts +5 -0
- package/dist/components/menu/menu.theme.js +174 -0
- package/dist/components/menu/menuContext.js +9 -0
- package/dist/components/menu/menuEntries.js +25 -0
- package/dist/components/select/Select.js +4 -0
- package/dist/components/select/Select.vue.d.ts +2 -2
- package/dist/components/select/Select.vue_vue_type_script_setup_true_lang.js +262 -0
- package/dist/components/select/SelectField.js +4 -0
- package/dist/components/select/SelectField.vue.d.ts +2 -2
- package/dist/components/select/SelectField.vue_vue_type_script_setup_true_lang.js +271 -0
- package/dist/components/select/SelectOptionRow.js +4 -0
- package/dist/components/select/SelectOptionRow.vue_vue_type_script_setup_true_lang.js +55 -0
- package/dist/components/select/SelectPanel.js +4 -0
- package/dist/components/select/SelectPanel.vue_vue_type_script_setup_true_lang.js +169 -0
- package/dist/components/select/select-panel.theme.js +44 -0
- package/dist/components/select/selectOptions.d.ts +0 -2
- package/dist/components/select/selectOptions.js +66 -0
- package/dist/components/select/useSelectControl.d.ts +3 -3
- package/dist/components/select/useSelectControl.js +62 -0
- package/dist/components/select/useSelectListbox.js +169 -0
- package/dist/components/slider/RangeSlider.js +4 -0
- package/dist/components/slider/RangeSlider.vue_vue_type_script_setup_true_lang.js +214 -0
- package/dist/components/slider/Slider.js +4 -0
- package/dist/components/slider/Slider.vue_vue_type_script_setup_true_lang.js +151 -0
- package/dist/components/slider/SliderHeader.js +4 -0
- package/dist/components/slider/SliderHeader.vue_vue_type_script_setup_true_lang.js +61 -0
- package/dist/components/slider/slider.theme.js +34 -0
- package/dist/components/text-field/TextField.js +4 -0
- package/dist/components/text-field/TextField.vue.d.ts +2 -2
- package/dist/components/text-field/TextField.vue_vue_type_script_setup_true_lang.js +122 -0
- package/dist/components/text-field/text-field.theme.js +379 -0
- package/dist/components/textarea/Textarea.js +4 -0
- package/dist/components/textarea/Textarea.vue.d.ts +1 -1
- package/dist/components/textarea/Textarea.vue_vue_type_script_setup_true_lang.js +93 -0
- package/dist/components/textarea/textarea.theme.js +222 -0
- package/dist/elements/avatar/Avatar.js +4 -0
- package/dist/elements/avatar/Avatar.vue.d.ts +3 -3
- package/dist/elements/avatar/Avatar.vue_vue_type_script_setup_true_lang.js +71 -0
- package/dist/elements/avatar/avatar.theme.js +141 -0
- package/dist/elements/badge/Badge.js +4 -0
- package/dist/elements/badge/Badge.vue.d.ts +2 -2
- package/dist/elements/badge/Badge.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/elements/badge/badge.theme.js +111 -0
- package/dist/elements/button/Button.js +4 -0
- package/dist/elements/button/Button.vue.d.ts +3 -3
- package/dist/elements/button/Button.vue_vue_type_script_setup_true_lang.js +83 -0
- package/dist/elements/button/button.theme.js +424 -0
- package/dist/elements/checkbox/Checkbox.js +4 -0
- package/dist/elements/checkbox/Checkbox.vue.d.ts +3 -1
- package/dist/elements/checkbox/Checkbox.vue_vue_type_script_setup_true_lang.js +69 -0
- package/dist/elements/checkbox/checkbox.theme.d.ts +1 -0
- package/dist/elements/checkbox/checkbox.theme.js +22 -0
- package/dist/elements/circular-progress/CircularProgress.js +4 -0
- package/dist/elements/circular-progress/CircularProgress.vue_vue_type_script_setup_true_lang.js +44 -0
- package/dist/elements/circular-progress/circular-progress.theme.js +8 -0
- package/dist/elements/input/Input.js +4 -0
- package/dist/elements/input/Input.vue.d.ts +62 -0
- package/dist/elements/input/Input.vue_vue_type_script_setup_true_lang.js +138 -0
- package/dist/elements/input/focusInputFromContainer.d.ts +2 -0
- package/dist/elements/input/focusInputFromContainer.js +28 -0
- package/dist/elements/input/index.d.ts +2 -0
- package/dist/elements/input/input.theme.d.ts +81 -0
- package/dist/elements/input/input.theme.js +391 -0
- package/dist/elements/loading-dots/LoadingDots.js +4 -0
- package/dist/elements/loading-dots/LoadingDots.vue_vue_type_script_setup_true_lang.js +26 -0
- package/dist/elements/loading-dots/loading-dots.theme.js +4 -0
- package/dist/elements/loading-indicator/LoadingIndicator.js +4 -0
- package/dist/elements/loading-indicator/LoadingIndicator.vue_vue_type_script_setup_true_lang.js +26 -0
- package/dist/elements/loading-indicator/loading-indicator.theme.js +4 -0
- package/dist/elements/popover/Popover.js +4 -0
- package/dist/elements/popover/Popover.vue.d.ts +60 -0
- package/dist/elements/popover/Popover.vue_vue_type_script_setup_true_lang.js +218 -0
- package/dist/elements/popover/index.d.ts +2 -0
- package/dist/elements/popover/popover.theme.d.ts +20 -0
- package/dist/elements/popover/popover.theme.js +17 -0
- package/dist/elements/popover/popoverLayers.d.ts +5 -0
- package/dist/elements/popover/popoverLayers.js +22 -0
- package/dist/elements/radio-group/RadioGroup.js +4 -0
- package/dist/elements/radio-group/RadioGroup.vue.d.ts +1 -1
- package/dist/elements/radio-group/RadioGroup.vue_vue_type_script_setup_true_lang.js +105 -0
- package/dist/elements/radio-group/radio-group.theme.js +126 -0
- package/dist/elements/segmented-control/SegmentedControl.js +4 -0
- package/dist/elements/segmented-control/SegmentedControl.vue.d.ts +1 -1
- package/dist/elements/segmented-control/SegmentedControl.vue_vue_type_script_setup_true_lang.js +98 -0
- package/dist/elements/segmented-control/segmented-control.theme.js +201 -0
- package/dist/elements/select-control/SelectControl.js +4 -0
- package/dist/elements/select-control/SelectControl.vue.d.ts +1 -1
- package/dist/elements/select-control/SelectControl.vue_vue_type_script_setup_true_lang.js +105 -0
- package/dist/elements/select-control/select-control.theme.js +360 -0
- package/dist/elements/select-field-control/SelectFieldControl.js +4 -0
- package/dist/elements/select-field-control/SelectFieldControl.vue.d.ts +1 -1
- package/dist/elements/select-field-control/SelectFieldControl.vue_vue_type_script_setup_true_lang.js +123 -0
- package/dist/elements/select-field-control/select-field-control.theme.js +299 -0
- package/dist/elements/slider-control/SliderControl.js +4 -0
- package/dist/elements/slider-control/SliderControl.vue_vue_type_script_setup_true_lang.js +228 -0
- package/dist/elements/slider-control/slider-control.theme.js +35 -0
- package/dist/elements/slider-control/useSliderMarksLayout.js +25 -0
- package/dist/elements/switch/Switch.js +4 -0
- package/dist/elements/switch/Switch.vue.d.ts +1 -1
- package/dist/elements/switch/Switch.vue_vue_type_script_setup_true_lang.js +71 -0
- package/dist/elements/switch/switch.theme.js +37 -0
- package/dist/elements/text-link/TextLink.js +4 -0
- package/dist/elements/text-link/TextLink.vue_vue_type_script_setup_true_lang.js +64 -0
- package/dist/elements/text-link/text-link.theme.js +25 -0
- package/dist/elements/tooltip/Tooltip.js +4 -0
- package/dist/elements/tooltip/Tooltip.vue_vue_type_script_setup_true_lang.js +161 -0
- package/dist/elements/tooltip/tooltip.theme.js +46 -0
- package/dist/elements/tooltip/useTooltipOpenState.js +57 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +38 -1
- package/dist/nuxt.js +12 -13
- package/dist/shared/composables/useApplePlatform.js +10 -0
- package/dist/shared/composables/useCalendarLabels.js +13 -0
- package/dist/shared/composables/useCustomColor.js +10 -0
- package/dist/shared/composables/useDismissOnOutsidePointerDown.d.ts +1 -1
- package/dist/shared/composables/useDismissOnOutsidePointerDown.js +14 -0
- package/dist/shared/composables/useFieldDescription.js +16 -0
- package/dist/shared/composables/useFloatingPosition.d.ts +3 -2
- package/dist/shared/composables/useFloatingPosition.js +113 -0
- package/dist/shared/composables/useMask.js +32 -0
- package/dist/shared/composables/useMaskedFieldModel.d.ts +7 -0
- package/dist/shared/composables/useMaskedFieldModel.js +19 -0
- package/dist/shared/composables/useNumberFieldTyping.js +70 -0
- package/dist/shared/composables/usePointerGraceArea.js +40 -0
- package/dist/shared/composables/useRowSelection.d.ts +17 -0
- package/dist/shared/composables/useRowSelection.js +40 -0
- package/dist/shared/composables/useShortcuts.js +21 -0
- package/dist/shared/composables/useSlidingThumb.js +65 -0
- package/dist/shared/composables/useTableRows.d.ts +26 -0
- package/dist/shared/composables/useTableRows.js +41 -0
- package/dist/shared/types/floating-position.d.ts +9 -0
- package/dist/shared/types/table.d.ts +59 -0
- package/dist/shared/types/value-path.d.ts +6 -0
- package/dist/shared/utils/calendarMonth.js +23 -0
- package/dist/shared/utils/computeFloatingPosition.js +32 -0
- package/dist/shared/utils/createDateFormatters.js +31 -0
- package/dist/shared/utils/createDateInputMask.js +103 -0
- package/dist/shared/utils/createDebouncedCallback.js +17 -0
- package/dist/shared/utils/createMask.js +65 -0
- package/dist/shared/utils/createShortcutHandler.js +60 -0
- package/dist/shared/utils/createTypeaheadSearch.js +16 -0
- package/dist/shared/utils/editableFieldGuard.js +11 -0
- package/dist/shared/utils/findFirstRenderedVNode.js +14 -0
- package/dist/shared/utils/flipFloatingPosition.js +28 -0
- package/dist/shared/utils/floatingPanelTransition.js +25 -0
- package/dist/shared/utils/formatShortcut.js +86 -0
- package/dist/shared/utils/isApplePlatform.js +5 -0
- package/dist/shared/utils/isExternalUrl.js +5 -0
- package/dist/shared/utils/isoDate.js +50 -0
- package/dist/shared/utils/normalizeSearchText.d.ts +2 -0
- package/dist/shared/utils/normalizeSearchText.js +6 -0
- package/dist/shared/utils/parseShortcut.js +48 -0
- package/dist/shared/utils/pointerGraceArea.js +92 -0
- package/dist/shared/utils/readValueAtPath.d.ts +2 -0
- package/dist/shared/utils/readValueAtPath.js +7 -0
- package/dist/shared/utils/resolveFloatingAnchor.d.ts +4 -0
- package/dist/shared/utils/resolveFloatingAnchor.js +15 -0
- package/dist/shared/utils/resolvePressScale.js +5 -0
- package/dist/shared/utils/shiftFloatingPosition.js +21 -0
- package/dist/shared/utils/sliderPosition.js +27 -0
- package/dist/shared/utils/sliderThumbs.js +16 -0
- package/dist/shared/utils/steppedValue.js +21 -0
- package/dist/shared/utils/tableColumnTypes.d.ts +21 -0
- package/dist/shared/utils/tableColumnTypes.js +77 -0
- package/dist/shared/utils/tableColumns.d.ts +20 -0
- package/dist/shared/utils/tableColumns.js +77 -0
- package/dist/shared/utils/tableGroups.d.ts +10 -0
- package/dist/shared/utils/tableGroups.js +34 -0
- package/dist/shared/utils/tableRows.d.ts +25 -0
- package/dist/shared/utils/tableRows.js +80 -0
- package/dist/shared/utils/tableTree.d.ts +15 -0
- package/dist/shared/utils/tableTree.js +22 -0
- package/dist/shared/utils/toggleColumnSort.d.ts +5 -0
- package/dist/shared/utils/toggleColumnSort.js +27 -0
- package/dist/shared/utils/tv.js +1 -0
- package/dist/shared/utils/warnInDevelopment.d.ts +3 -0
- package/dist/shared/utils/warnInDevelopment.js +13 -0
- package/package.json +1 -1
- package/src/index.css +1 -0
- package/src/shared/styles/utilities/shake.css +21 -0
- package/dist/src-Rouj5r7z.js +0 -9111
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
function e(e, t) {
|
|
2
|
+
return [
|
|
3
|
+
["left", Math.abs(t.left - e.x)],
|
|
4
|
+
["right", Math.abs(t.right - e.x)],
|
|
5
|
+
["top", Math.abs(t.top - e.y)],
|
|
6
|
+
["bottom", Math.abs(t.bottom - e.y)]
|
|
7
|
+
].reduce((e, t) => t[1] < e[1] ? t : e)[0];
|
|
8
|
+
}
|
|
9
|
+
function t(e, t) {
|
|
10
|
+
let { x: n, y: r } = e;
|
|
11
|
+
return {
|
|
12
|
+
top: [{
|
|
13
|
+
x: n - 5,
|
|
14
|
+
y: r + 5
|
|
15
|
+
}, {
|
|
16
|
+
x: n + 5,
|
|
17
|
+
y: r + 5
|
|
18
|
+
}],
|
|
19
|
+
bottom: [{
|
|
20
|
+
x: n - 5,
|
|
21
|
+
y: r - 5
|
|
22
|
+
}, {
|
|
23
|
+
x: n + 5,
|
|
24
|
+
y: r - 5
|
|
25
|
+
}],
|
|
26
|
+
left: [{
|
|
27
|
+
x: n + 5,
|
|
28
|
+
y: r - 5
|
|
29
|
+
}, {
|
|
30
|
+
x: n + 5,
|
|
31
|
+
y: r + 5
|
|
32
|
+
}],
|
|
33
|
+
right: [{
|
|
34
|
+
x: n - 5,
|
|
35
|
+
y: r - 5
|
|
36
|
+
}, {
|
|
37
|
+
x: n - 5,
|
|
38
|
+
y: r + 5
|
|
39
|
+
}]
|
|
40
|
+
}[t];
|
|
41
|
+
}
|
|
42
|
+
function n({ top: e, right: t, bottom: n, left: r }) {
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
x: r,
|
|
46
|
+
y: e
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
x: t,
|
|
50
|
+
y: e
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
x: t,
|
|
54
|
+
y: n
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
x: r,
|
|
58
|
+
y: n
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
function r(e, t) {
|
|
63
|
+
return e.x - t.x || e.y - t.y;
|
|
64
|
+
}
|
|
65
|
+
function i(e, t, n) {
|
|
66
|
+
return (t.x - e.x) * (n.y - e.y) >= (t.y - e.y) * (n.x - e.x);
|
|
67
|
+
}
|
|
68
|
+
function a(e) {
|
|
69
|
+
let t = [];
|
|
70
|
+
for (let n of e) {
|
|
71
|
+
for (; t.length >= 2 && i(t[t.length - 2], t[t.length - 1], n);) t.pop();
|
|
72
|
+
t.push(n);
|
|
73
|
+
}
|
|
74
|
+
return t.pop(), t;
|
|
75
|
+
}
|
|
76
|
+
function o(e) {
|
|
77
|
+
let t = [...e].sort(r);
|
|
78
|
+
if (t.length <= 1) return t;
|
|
79
|
+
let n = a(t), i = a([...t].reverse());
|
|
80
|
+
return n.length === 1 && i.length === 1 && n[0].x === i[0].x && n[0].y === i[0].y ? n : [...n, ...i];
|
|
81
|
+
}
|
|
82
|
+
function s(e, t) {
|
|
83
|
+
let n = !1;
|
|
84
|
+
return t.forEach((r, i) => {
|
|
85
|
+
let a = t.at(i - 1);
|
|
86
|
+
r.y > e.y != a.y > e.y && e.x < (a.x - r.x) * (e.y - r.y) / (a.y - r.y) + r.x && (n = !n);
|
|
87
|
+
}), n;
|
|
88
|
+
}
|
|
89
|
+
function c(r, i, a) {
|
|
90
|
+
return o([...t(r, e(r, i)), ...n(a)]);
|
|
91
|
+
}
|
|
92
|
+
export { o as computeConvexHull, c as createPointerGraceArea, e as findPointerExitSide, s as isPointInPolygon, t as padPointerExitPoint };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FloatingAnchor, FloatingPoint } from '../types/floating-position';
|
|
2
|
+
export declare function isFloatingPoint(requestedAnchor: FloatingAnchor | FloatingPoint): requestedAnchor is FloatingPoint;
|
|
3
|
+
/** Turn an element, a virtual anchor or a point of the viewport into an anchor to place a floating element against. */
|
|
4
|
+
export declare function resolveFloatingAnchor(requestedAnchor: FloatingAnchor | FloatingPoint): FloatingAnchor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/shared/utils/resolveFloatingAnchor.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return !("getBoundingClientRect" in e);
|
|
4
|
+
}
|
|
5
|
+
function t(t) {
|
|
6
|
+
if (!e(t)) return t;
|
|
7
|
+
let { x: n, y: r } = t;
|
|
8
|
+
return { getBoundingClientRect: () => ({
|
|
9
|
+
x: n,
|
|
10
|
+
y: r,
|
|
11
|
+
width: 0,
|
|
12
|
+
height: 0
|
|
13
|
+
}) };
|
|
14
|
+
}
|
|
15
|
+
export { e as isFloatingPoint, t as resolveFloatingAnchor };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/shared/utils/shiftFloatingPosition.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
return Math.max(t, Math.min(e, n));
|
|
4
|
+
}
|
|
5
|
+
function t(t = 8) {
|
|
6
|
+
return (n, { anchorRect: r, floatingSize: i, viewportSize: a }) => {
|
|
7
|
+
if (n.placement.side === "top" || n.placement.side === "bottom") {
|
|
8
|
+
let o = e(n.x, t, a.width - t - i.width);
|
|
9
|
+
return {
|
|
10
|
+
...n,
|
|
11
|
+
x: e(o, r.x - i.width, r.x + r.width)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
let o = e(n.y, t, a.height - t - i.height);
|
|
15
|
+
return {
|
|
16
|
+
...n,
|
|
17
|
+
y: e(o, r.y - i.height, r.y + r.height)
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export { t as shiftFloatingPosition };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { clampToRange as e } from "./steppedValue.js";
|
|
2
|
+
// src/shared/utils/sliderPosition.ts
|
|
3
|
+
function t(e, t, n) {
|
|
4
|
+
return n > t ? (e - t) / (n - t) : 0;
|
|
5
|
+
}
|
|
6
|
+
function n(n, r, i) {
|
|
7
|
+
return e(t(n, r, i) * 100, 0, 100);
|
|
8
|
+
}
|
|
9
|
+
function r(e, t, n, r) {
|
|
10
|
+
return t > 0 ? n + (r - n) / t * e : n;
|
|
11
|
+
}
|
|
12
|
+
function i(e, t, n) {
|
|
13
|
+
let r = /* @__PURE__ */ new Set();
|
|
14
|
+
for (let i of e) {
|
|
15
|
+
if (i.value < t || i.value > n) throw Error(`Slider mark value ${i.value} is out of bounds [${t}, ${n}]`);
|
|
16
|
+
if (r.has(i.value)) throw Error("Slider marks must have unique values");
|
|
17
|
+
r.add(i.value);
|
|
18
|
+
}
|
|
19
|
+
return [...e].sort((e, t) => e.value - t.value);
|
|
20
|
+
}
|
|
21
|
+
function a(e, t) {
|
|
22
|
+
return e.some((n, r) => {
|
|
23
|
+
let i = e[r + 1];
|
|
24
|
+
return i !== void 0 && n.right + t > i.left;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export { r as convertPointerToValue, n as convertValueToPercent, t as convertValueToRatio, a as hasCrowdedMarks, i as sortSliderMarks };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/shared/utils/sliderThumbs.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
let r = e[t - 1], i = e[t + 1];
|
|
4
|
+
return {
|
|
5
|
+
lowestValue: r === void 0 ? n.min : r + n.minRange,
|
|
6
|
+
highestValue: i === void 0 ? n.max : i - n.minRange
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function t(e, t) {
|
|
10
|
+
let n = e.map((e) => Math.abs(e - t)), r = Math.min(...n), i = n.indexOf(r), a = n.lastIndexOf(r);
|
|
11
|
+
return t > (e[a] ?? t) ? a : i;
|
|
12
|
+
}
|
|
13
|
+
function n(e, t) {
|
|
14
|
+
return e.some((n, r) => r !== t && n === e[t]);
|
|
15
|
+
}
|
|
16
|
+
export { t as findClosestThumbIndex, n as isThumbStacked, e as resolveThumbBounds };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/shared/utils/steppedValue.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (!Number.isFinite(e)) return 0;
|
|
4
|
+
let [t = "", n] = String(e).split("e"), r = t.split(".")[1]?.length ?? 0;
|
|
5
|
+
return Math.max(0, r - Number(n ?? 0));
|
|
6
|
+
}
|
|
7
|
+
function t(e, t) {
|
|
8
|
+
let [n = "", r] = String(e).split("e"), i = Math.round(Number(`${n}e${Number(r ?? 0) + t}`)), [a = "", o] = String(i).split("e");
|
|
9
|
+
return Number(`${a}e${Number(o ?? 0) - t}`);
|
|
10
|
+
}
|
|
11
|
+
function n(e, t, n) {
|
|
12
|
+
return Math.min(Math.max(e, t), n);
|
|
13
|
+
}
|
|
14
|
+
function r(r, { min: i, max: a, step: o }) {
|
|
15
|
+
return n(t(Math.round((r - i) / o) * o + i, e(o)), i, a);
|
|
16
|
+
}
|
|
17
|
+
function i(n, { min: r, step: i }, { direction: a, stepCount: o }) {
|
|
18
|
+
let s = e(i), c = (n - r) / i, l = Math.round(c), u = t(l * i + r, s) === t(n, s), d = a > 0 ? Math.ceil(c) : Math.floor(c);
|
|
19
|
+
return u && (d = l + o * a), t(d * i + r, s);
|
|
20
|
+
}
|
|
21
|
+
export { n as clampToRange, e as countStepDecimals, i as moveByStep, t as roundToDecimals, r as snapToStep };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TableColumnType, TableColumnTypes, TableValueContext } from '../types/table';
|
|
2
|
+
export declare const builtInTableColumnTypes: {
|
|
3
|
+
text: {
|
|
4
|
+
format: (cellValue: unknown) => string;
|
|
5
|
+
compare: (firstValue: unknown, secondValue: unknown, { locale }: TableValueContext) => number;
|
|
6
|
+
};
|
|
7
|
+
number: TableColumnType;
|
|
8
|
+
decimal: TableColumnType;
|
|
9
|
+
percentage: TableColumnType;
|
|
10
|
+
date: {
|
|
11
|
+
format: (cellValue: unknown, { locale, formatOptions }: TableValueContext) => string;
|
|
12
|
+
compare: (firstValue: unknown, secondValue: unknown) => number;
|
|
13
|
+
};
|
|
14
|
+
boolean: {
|
|
15
|
+
align: "center";
|
|
16
|
+
format: (cellValue: unknown) => "Yes" | "No";
|
|
17
|
+
compare: (firstValue: unknown, secondValue: unknown) => number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/** Declare column types of your own, like a status ordered by importance, with the same shape as the built-in ones. */
|
|
21
|
+
export declare function defineTableColumnTypes<ColumnTypes extends TableColumnTypes>(columnTypes: ColumnTypes): ColumnTypes;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { isoDateToUtcDate as e } from "./isoDate.js";
|
|
2
|
+
// src/shared/utils/tableColumnTypes.ts
|
|
3
|
+
var t = /^\d{4}-\d{2}-\d{2}$/, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
4
|
+
function a(e, t) {
|
|
5
|
+
let r = `${e}|${JSON.stringify(t)}`, i = n.get(r);
|
|
6
|
+
return i || (i = new Intl.NumberFormat(e, t), n.set(r, i)), i;
|
|
7
|
+
}
|
|
8
|
+
function o(e, t) {
|
|
9
|
+
let n = `${e}|${JSON.stringify(t)}`, i = r.get(n);
|
|
10
|
+
return i || (i = new Intl.DateTimeFormat(e, t), r.set(n, i)), i;
|
|
11
|
+
}
|
|
12
|
+
function s(e) {
|
|
13
|
+
let t = String(e), n = i.get(t);
|
|
14
|
+
return n || (n = new Intl.Collator(e, {
|
|
15
|
+
numeric: !0,
|
|
16
|
+
sensitivity: "base"
|
|
17
|
+
}), i.set(t, n)), n;
|
|
18
|
+
}
|
|
19
|
+
function c(e) {
|
|
20
|
+
return typeof e == "string" && t.test(e);
|
|
21
|
+
}
|
|
22
|
+
function l(t) {
|
|
23
|
+
return t instanceof Date ? t : c(t) ? e(t) : new Date(t);
|
|
24
|
+
}
|
|
25
|
+
function u(e, t) {
|
|
26
|
+
let n = t !== void 0 && Object.keys(t).length > 0 ? { ...t } : { dateStyle: "medium" };
|
|
27
|
+
return c(e) && n.timeZone === void 0 && (n.timeZone = "UTC"), n;
|
|
28
|
+
}
|
|
29
|
+
function d(e, t = {}) {
|
|
30
|
+
let n = {
|
|
31
|
+
...e,
|
|
32
|
+
...t
|
|
33
|
+
}, { minimumFractionDigits: r = 0, maximumFractionDigits: i } = n;
|
|
34
|
+
return i === void 0 || r <= i ? n : t.minimumFractionDigits === void 0 ? {
|
|
35
|
+
...n,
|
|
36
|
+
minimumFractionDigits: i
|
|
37
|
+
} : t.maximumFractionDigits === void 0 ? {
|
|
38
|
+
...n,
|
|
39
|
+
maximumFractionDigits: r
|
|
40
|
+
} : n;
|
|
41
|
+
}
|
|
42
|
+
function f(e) {
|
|
43
|
+
return {
|
|
44
|
+
align: "end",
|
|
45
|
+
tabularNumbers: !0,
|
|
46
|
+
format: (t, { locale: n, formatOptions: r }) => a(n, d(e, r)).format(Number(t)),
|
|
47
|
+
compare: (e, t) => Number(e) - Number(t)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
var p = {
|
|
51
|
+
text: {
|
|
52
|
+
format: (e) => String(e),
|
|
53
|
+
compare: (e, t, { locale: n }) => s(n).compare(String(e), String(t))
|
|
54
|
+
},
|
|
55
|
+
number: f({}),
|
|
56
|
+
decimal: f({
|
|
57
|
+
minimumFractionDigits: 2,
|
|
58
|
+
maximumFractionDigits: 2
|
|
59
|
+
}),
|
|
60
|
+
percentage: f({
|
|
61
|
+
style: "percent",
|
|
62
|
+
maximumFractionDigits: 1
|
|
63
|
+
}),
|
|
64
|
+
date: {
|
|
65
|
+
format: (e, { locale: t, formatOptions: n }) => o(t, u(e, n)).format(l(e)),
|
|
66
|
+
compare: (e, t) => l(e).getTime() - l(t).getTime()
|
|
67
|
+
},
|
|
68
|
+
boolean: {
|
|
69
|
+
align: "center",
|
|
70
|
+
format: (e) => e ? "Yes" : "No",
|
|
71
|
+
compare: (e, t) => Number(!!e) - Number(!!t)
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
function m(e) {
|
|
75
|
+
return e;
|
|
76
|
+
}
|
|
77
|
+
export { p as builtInTableColumnTypes, m as defineTableColumnTypes };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TableCellAlign, TableColumn, TableColumnSettings, TableColumnType, TableRowKey, TableRowKeyReader } from '../types/table';
|
|
2
|
+
/** Describe the columns of a table with autocompletion on the keys and paths of your rows. */
|
|
3
|
+
export declare function defineTableColumns<Row>(columns: TableColumn<Row>[]): TableColumn<Row>[];
|
|
4
|
+
export declare function isEmptyCellValue(cellValue: unknown): cellValue is "" | null | undefined;
|
|
5
|
+
export declare function readCellValue<Row>(row: Row, column: TableColumn<Row>): unknown;
|
|
6
|
+
export declare function readRowKey<Row>(row: Row, rowKey: TableRowKeyReader<Row>): TableRowKey;
|
|
7
|
+
export declare function resolveTableColumnType<Row>(column: TableColumn<Row>, { columnTypes }?: TableColumnSettings): TableColumnType;
|
|
8
|
+
export declare function resolveColumnAlign<Row>(column: TableColumn<Row>, columnSettings?: TableColumnSettings): TableCellAlign;
|
|
9
|
+
/** Format a value with the type and the format options of a column, like a group total. */
|
|
10
|
+
export declare function formatColumnValue<Row>(columnValue: unknown, column: TableColumn<Row>, columnSettings?: TableColumnSettings): string;
|
|
11
|
+
export declare function formatCellValue<Row>(row: Row, column: TableColumn<Row>, columnSettings?: TableColumnSettings): string;
|
|
12
|
+
/** Compare two rows on one column, keeping empty cells after the others whatever the direction. */
|
|
13
|
+
export declare function compareRowsOnColumn<Row>(firstRow: Row, secondRow: Row, column: TableColumn<Row>, columnSettings?: TableColumnSettings): {
|
|
14
|
+
comparison: number;
|
|
15
|
+
hasEmptyCell: boolean;
|
|
16
|
+
};
|
|
17
|
+
/** Turn a key like "createdAt" or "first_name" into a label like "Created at" or "First name". */
|
|
18
|
+
export declare function humanizeColumnKey(columnKey: string): string;
|
|
19
|
+
/** Build columns from the fields of the first row, when a table is given rows only. */
|
|
20
|
+
export declare function inferTableColumns<Row>(rows: Row[]): TableColumn<Row>[];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { readValueAtPath as e } from "./readValueAtPath.js";
|
|
2
|
+
import { builtInTableColumnTypes as t } from "./tableColumnTypes.js";
|
|
3
|
+
import { warnInDevelopment as n } from "./warnInDevelopment.js";
|
|
4
|
+
// src/shared/utils/tableColumns.ts
|
|
5
|
+
var r = /^\d{4}-\d{2}-\d{2}(T[\d:.]+(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
6
|
+
function i(e) {
|
|
7
|
+
return e;
|
|
8
|
+
}
|
|
9
|
+
function a(e) {
|
|
10
|
+
return e == null || e === "";
|
|
11
|
+
}
|
|
12
|
+
function o(t, n) {
|
|
13
|
+
return typeof n.accessor == "function" ? n.accessor(t) : e(t, n.accessor ?? n.key);
|
|
14
|
+
}
|
|
15
|
+
function s(t, n) {
|
|
16
|
+
return typeof n == "function" ? n(t) : e(t, n);
|
|
17
|
+
}
|
|
18
|
+
function c(e, { columnTypes: r } = {}) {
|
|
19
|
+
let i = e.type ?? "text";
|
|
20
|
+
return {
|
|
21
|
+
...t,
|
|
22
|
+
...r
|
|
23
|
+
}[i] || (n(`The column "${e.key}" has the unknown type "${i}". Add it to column-types.`), t.text);
|
|
24
|
+
}
|
|
25
|
+
function l(e, t = {}) {
|
|
26
|
+
return e.align ?? c(e, t).align ?? "start";
|
|
27
|
+
}
|
|
28
|
+
function u(e, t, n = {}) {
|
|
29
|
+
if (a(e)) return "";
|
|
30
|
+
let r = c(t, n), i = {
|
|
31
|
+
locale: n.locale,
|
|
32
|
+
formatOptions: t.formatOptions
|
|
33
|
+
};
|
|
34
|
+
return r.format ? r.format(e, i) : String(e);
|
|
35
|
+
}
|
|
36
|
+
function d(e, t, n = {}) {
|
|
37
|
+
let r = o(e, t);
|
|
38
|
+
return t.format ? t.format(r, e) : u(r, t, n);
|
|
39
|
+
}
|
|
40
|
+
function f(e, t, n, r = {}) {
|
|
41
|
+
let i = o(e, n), s = o(t, n), l = a(i), u = a(s);
|
|
42
|
+
if (l || u) return {
|
|
43
|
+
comparison: Number(l) - Number(u),
|
|
44
|
+
hasEmptyCell: !0
|
|
45
|
+
};
|
|
46
|
+
if (n.compare) return {
|
|
47
|
+
comparison: n.compare(i, s, e, t),
|
|
48
|
+
hasEmptyCell: !1
|
|
49
|
+
};
|
|
50
|
+
let d = c(n, r), f = {
|
|
51
|
+
locale: r.locale,
|
|
52
|
+
formatOptions: n.formatOptions
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
comparison: d.compare ? d.compare(i, s, f) : String(i).localeCompare(String(s)),
|
|
56
|
+
hasEmptyCell: !1
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function p(e) {
|
|
60
|
+
let t = e.replace(/[_-]+/g, " ").replace(/([a-z\d])([A-Z])/g, "$1 $2").trim().toLowerCase();
|
|
61
|
+
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
62
|
+
}
|
|
63
|
+
function m(e) {
|
|
64
|
+
return typeof e == "number" ? "number" : typeof e == "boolean" ? "boolean" : e instanceof Date || typeof e == "string" && r.test(e) ? "date" : "text";
|
|
65
|
+
}
|
|
66
|
+
function h(e) {
|
|
67
|
+
return typeof e != "object" || !e || e instanceof Date;
|
|
68
|
+
}
|
|
69
|
+
function g(e) {
|
|
70
|
+
let [t] = e;
|
|
71
|
+
return typeof t != "object" || !t ? [] : Object.entries(t).filter(([, e]) => h(e)).map(([e, t]) => ({
|
|
72
|
+
key: e,
|
|
73
|
+
label: p(e),
|
|
74
|
+
type: m(t)
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
export { f as compareRowsOnColumn, i as defineTableColumns, d as formatCellValue, u as formatColumnValue, p as humanizeColumnKey, g as inferTableColumns, a as isEmptyCellValue, o as readCellValue, s as readRowKey, l as resolveColumnAlign, c as resolveTableColumnType };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TableColumn, TableColumnSettings } from '../types/table';
|
|
2
|
+
export interface TableRowGroup<Row> {
|
|
3
|
+
groupKey: string;
|
|
4
|
+
groupValue: unknown;
|
|
5
|
+
rows: Row[];
|
|
6
|
+
}
|
|
7
|
+
/** Gather rows that share a value, keeping the groups in the order their first row appears. */
|
|
8
|
+
export declare function groupTableRows<Row>(rows: Row[], readGroupValue: (row: Row) => unknown): TableRowGroup<Row>[];
|
|
9
|
+
/** Total the values of a column over some rows with its `aggregate`, like a sum or an average. */
|
|
10
|
+
export declare function aggregateColumnValues<Row>(rows: Row[], column: TableColumn<Row>, columnSettings?: TableColumnSettings): unknown;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { compareRowsOnColumn as e, isEmptyCellValue as t, readCellValue as n } from "./tableColumns.js";
|
|
2
|
+
// src/shared/utils/tableGroups.ts
|
|
3
|
+
function r(e, t) {
|
|
4
|
+
let n = /* @__PURE__ */ new Map();
|
|
5
|
+
for (let r of e) {
|
|
6
|
+
let e = t(r), i = String(e ?? ""), a = n.get(i);
|
|
7
|
+
a ? a.rows.push(r) : n.set(i, {
|
|
8
|
+
groupKey: i,
|
|
9
|
+
groupValue: e,
|
|
10
|
+
rows: [r]
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return [...n.values()];
|
|
14
|
+
}
|
|
15
|
+
function i(r, i, a, o) {
|
|
16
|
+
return r.filter((e) => !t(n(e, i))).reduce((t, n) => {
|
|
17
|
+
if (t === void 0) return n;
|
|
18
|
+
let { comparison: r } = e(n, t, i, a);
|
|
19
|
+
return (o ? r < 0 : r > 0) ? n : t;
|
|
20
|
+
}, void 0);
|
|
21
|
+
}
|
|
22
|
+
function a(e, r, a = {}) {
|
|
23
|
+
let { aggregate: o } = r;
|
|
24
|
+
if (o === void 0) return;
|
|
25
|
+
if (typeof o == "function") return o(e);
|
|
26
|
+
if (o === "count") return e.length;
|
|
27
|
+
if (o === "min" || o === "max") {
|
|
28
|
+
let t = i(e, r, a, o === "min");
|
|
29
|
+
return t === void 0 ? void 0 : n(t, r);
|
|
30
|
+
}
|
|
31
|
+
let s = e.map((e) => n(e, r)).filter((e) => !t(e)).map(Number), c = s.reduce((e, t) => e + t, 0);
|
|
32
|
+
return o === "sum" ? c : s.length === 0 ? void 0 : c / s.length;
|
|
33
|
+
}
|
|
34
|
+
export { a as aggregateColumnValues, r as groupTableRows };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TableColumn, TableColumnFilters, TableColumnSettings, TableRowKey, TableRowKeyReader, TableSort } from '../types/table';
|
|
2
|
+
export interface TableRowFiltering<Row> extends TableColumnSettings {
|
|
3
|
+
columns: TableColumn<Row>[];
|
|
4
|
+
searchQuery?: string;
|
|
5
|
+
searchMatcher?: (row: Row, searchQuery: string) => boolean;
|
|
6
|
+
columnFilters?: TableColumnFilters;
|
|
7
|
+
childrenKey?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface TableRowSorting<Row> extends TableColumnSettings {
|
|
10
|
+
columns: TableColumn<Row>[];
|
|
11
|
+
sort?: TableSort;
|
|
12
|
+
}
|
|
13
|
+
export declare function hasActiveRowFiltering<Row>(rowFiltering: TableRowFiltering<Row>): boolean;
|
|
14
|
+
/** Build the test that tells whether one row, on its own, matches the search and every column filter. */
|
|
15
|
+
export declare function createRowMatcher<Row>(rowFiltering: TableRowFiltering<Row>): (row: Row) => boolean;
|
|
16
|
+
/** Keep the rows that match the search and every column filter; in a tree, a row also stays for a matching child. */
|
|
17
|
+
export declare function filterTableRows<Row>(rows: Row[], rowFiltering: TableRowFiltering<Row>): Row[];
|
|
18
|
+
/** Sort rows by each sort entry in turn, keeping the original order between equal rows. */
|
|
19
|
+
export declare function sortTableRows<Row>(rows: Row[], rowSorting: TableRowSorting<Row>): Row[];
|
|
20
|
+
/** Move the pinned rows to the top, in the order of their keys, and keep the other rows in place. */
|
|
21
|
+
export declare function pinTableRows<Row>(rows: Row[], pinnedRowKeys: TableRowKey[] | undefined, rowKey: TableRowKeyReader<Row>): Row[];
|
|
22
|
+
/** Turn the search, the filters and the sort into text, so an equal object written again changes nothing. */
|
|
23
|
+
export declare function createRowQueryKey(searchQuery: string | undefined, columnFilters?: TableColumnFilters, sort?: TableSort): string;
|
|
24
|
+
export declare function countTablePages(rowCount: number, rowsPerPage: number | undefined): number;
|
|
25
|
+
export declare function sliceTablePage<Row>(rows: Row[], page: number, rowsPerPage: number | undefined): Row[];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { normalizeSearchText as e } from "./normalizeSearchText.js";
|
|
2
|
+
import { compareRowsOnColumn as t, formatCellValue as n, isEmptyCellValue as r, readCellValue as i, readRowKey as a } from "./tableColumns.js";
|
|
3
|
+
import { hasMatchingDescendant as o } from "./tableTree.js";
|
|
4
|
+
import { warnInDevelopment as s } from "./warnInDevelopment.js";
|
|
5
|
+
// src/shared/utils/tableRows.ts
|
|
6
|
+
function c(e) {
|
|
7
|
+
return r(e) || Array.isArray(e) && e.length === 0;
|
|
8
|
+
}
|
|
9
|
+
function l(e, t) {
|
|
10
|
+
return Array.isArray(t) ? t.some((t) => l(e, t)) : e === t || !r(e) && String(e) === String(t);
|
|
11
|
+
}
|
|
12
|
+
function u(e, t, n) {
|
|
13
|
+
let r = e.find((e) => e.key === t);
|
|
14
|
+
return r || s(`The ${n} uses the key "${t}", but no column has it.`), r;
|
|
15
|
+
}
|
|
16
|
+
function d(t, a, o) {
|
|
17
|
+
return o.columns.some((s) => {
|
|
18
|
+
if (s.searchable === !1) return !1;
|
|
19
|
+
let c = i(t, s), l = typeof c == "object" || r(c) ? "" : String(c), u = n(t, s, o);
|
|
20
|
+
return e(l).includes(a) || e(u).includes(a);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function f(e, t) {
|
|
24
|
+
return Object.entries(t.columnFilters ?? {}).every(([n, r]) => {
|
|
25
|
+
if (c(r)) return !0;
|
|
26
|
+
let a = u(t.columns, n, "filter");
|
|
27
|
+
if (!a) return !0;
|
|
28
|
+
let o = i(e, a);
|
|
29
|
+
return a.filter ? a.filter(o, r, e) : l(o, r);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function p(t) {
|
|
33
|
+
let n = e(t.searchQuery ?? "") !== "", r = Object.values(t.columnFilters ?? {}).some((e) => !c(e));
|
|
34
|
+
return n || r;
|
|
35
|
+
}
|
|
36
|
+
function m(t) {
|
|
37
|
+
let n = t.searchQuery ?? "", r = e(n);
|
|
38
|
+
return (e) => (!r || (t.searchMatcher ? t.searchMatcher(e, n) : d(e, r, t))) && f(e, t);
|
|
39
|
+
}
|
|
40
|
+
function h(e, t) {
|
|
41
|
+
let n = m(t);
|
|
42
|
+
return e.filter((e) => n(e) || o(e, t.childrenKey, n));
|
|
43
|
+
}
|
|
44
|
+
function g(e, n) {
|
|
45
|
+
let r = (n.sort ?? []).flatMap((e) => {
|
|
46
|
+
let t = u(n.columns, e.key, "sort");
|
|
47
|
+
return t ? [{
|
|
48
|
+
sortedColumn: t,
|
|
49
|
+
direction: e.direction
|
|
50
|
+
}] : [];
|
|
51
|
+
});
|
|
52
|
+
return r.length === 0 ? e : [...e].sort((e, i) => {
|
|
53
|
+
for (let { sortedColumn: a, direction: o } of r) {
|
|
54
|
+
let { comparison: r, hasEmptyCell: s } = t(e, i, a, n);
|
|
55
|
+
if (r !== 0) return s || o === "ascending" ? r : -r;
|
|
56
|
+
}
|
|
57
|
+
return 0;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function _(e, t, n) {
|
|
61
|
+
if (!t?.length) return e;
|
|
62
|
+
let r = new Map(e.map((e) => [a(e, n), e])), i = [...new Set(t)].flatMap((e) => r.has(e) ? [r.get(e)] : []), o = new Set(i);
|
|
63
|
+
return [...i, ...e.filter((e) => !o.has(e))];
|
|
64
|
+
}
|
|
65
|
+
function v(e, t, n) {
|
|
66
|
+
return JSON.stringify([
|
|
67
|
+
e ?? "",
|
|
68
|
+
t ?? {},
|
|
69
|
+
n ?? []
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
function y(e, t) {
|
|
73
|
+
return t ? Math.max(1, Math.ceil(e / t)) : 1;
|
|
74
|
+
}
|
|
75
|
+
function b(e, t, n) {
|
|
76
|
+
if (!n) return e;
|
|
77
|
+
let r = (t - 1) * n;
|
|
78
|
+
return e.slice(r, r + n);
|
|
79
|
+
}
|
|
80
|
+
export { y as countTablePages, m as createRowMatcher, v as createRowQueryKey, h as filterTableRows, p as hasActiveRowFiltering, _ as pinTableRows, b as sliceTablePage, g as sortTableRows };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface TableDisplayRow<Row> {
|
|
2
|
+
row: Row;
|
|
3
|
+
depth: number;
|
|
4
|
+
hasChildren: boolean;
|
|
5
|
+
isExpanded: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface TableRowFlattening<Row> {
|
|
8
|
+
childrenKey?: string;
|
|
9
|
+
isRowExpanded: (row: Row) => boolean;
|
|
10
|
+
orderChildRows?: (childRows: Row[]) => Row[];
|
|
11
|
+
}
|
|
12
|
+
export declare function readRowChildren<Row>(row: Row, childrenKey: string | undefined): Row[];
|
|
13
|
+
export declare function hasMatchingDescendant<Row>(row: Row, childrenKey: string | undefined, matchesRow: (row: Row) => boolean): boolean;
|
|
14
|
+
/** List the rows to show in order, with the children of expanded rows right under them. */
|
|
15
|
+
export declare function flattenTableRows<Row>(rows: Row[], rowFlattening: TableRowFlattening<Row>, depth?: number): TableDisplayRow<Row>[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { readValueAtPath as e } from "./readValueAtPath.js";
|
|
2
|
+
// src/shared/utils/tableTree.ts
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
if (!n) return [];
|
|
5
|
+
let r = e(t, n);
|
|
6
|
+
return Array.isArray(r) ? r : [];
|
|
7
|
+
}
|
|
8
|
+
function n(e, r, i) {
|
|
9
|
+
return t(e, r).some((e) => i(e) || n(e, r, i));
|
|
10
|
+
}
|
|
11
|
+
function r(e, n, i = 0) {
|
|
12
|
+
return e.flatMap((e) => {
|
|
13
|
+
let a = t(e, n.childrenKey), o = a.length > 0, s = o && n.isRowExpanded(e), c = {
|
|
14
|
+
row: e,
|
|
15
|
+
depth: i,
|
|
16
|
+
hasChildren: o,
|
|
17
|
+
isExpanded: s
|
|
18
|
+
};
|
|
19
|
+
return s ? [c, ...r(n.orderChildRows?.(a) ?? a, n, i + 1)] : [c];
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export { r as flattenTableRows, n as hasMatchingDescendant, t as readRowChildren };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TableColumn, TableSort } from '../types/table';
|
|
2
|
+
/** Move a column to its next sort state, alone like a click, or among the others like Shift + click. */
|
|
3
|
+
export declare function toggleColumnSort<Row>(currentSort: TableSort, sortedColumn: Pick<TableColumn<Row>, 'key' | 'firstSortDirection'>, { keepsOtherColumns }?: {
|
|
4
|
+
keepsOtherColumns?: boolean;
|
|
5
|
+
}): TableSort;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/shared/utils/toggleColumnSort.ts
|
|
2
|
+
var e = {
|
|
3
|
+
ascending: "descending",
|
|
4
|
+
descending: "ascending"
|
|
5
|
+
};
|
|
6
|
+
function t(t, n) {
|
|
7
|
+
return t ? t === n ? e[n] : void 0 : n;
|
|
8
|
+
}
|
|
9
|
+
function n(e, n, { keepsOtherColumns: r = !1 } = {}) {
|
|
10
|
+
let i = n.firstSortDirection ?? "ascending", a = e.find((e) => e.key === n.key);
|
|
11
|
+
if (!r) {
|
|
12
|
+
let r = a !== void 0 && e.length === 1 ? t(a.direction, i) : i;
|
|
13
|
+
return r ? [{
|
|
14
|
+
key: n.key,
|
|
15
|
+
direction: r
|
|
16
|
+
}] : [];
|
|
17
|
+
}
|
|
18
|
+
let o = t(a?.direction, i);
|
|
19
|
+
return a ? o ? e.map((e) => e === a ? {
|
|
20
|
+
...e,
|
|
21
|
+
direction: o
|
|
22
|
+
} : e) : e.filter((e) => e !== a) : [...e, {
|
|
23
|
+
key: n.key,
|
|
24
|
+
direction: i
|
|
25
|
+
}];
|
|
26
|
+
}
|
|
27
|
+
export { n as toggleColumnSort };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { tv } from "tailwind-variants";
|