@kuina-ui/vue 0.5.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.d.ts +55 -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.d.ts +49 -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.d.ts +30 -0
- package/dist/components/slider/SliderHeader.vue_vue_type_script_setup_true_lang.js +61 -0
- package/dist/components/slider/index.d.ts +5 -0
- package/dist/components/slider/slider.theme.d.ts +33 -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.d.ts +35 -0
- package/dist/elements/slider-control/SliderControl.vue_vue_type_script_setup_true_lang.js +228 -0
- package/dist/elements/slider-control/index.d.ts +3 -0
- package/dist/elements/slider-control/slider-control.theme.d.ts +38 -0
- package/dist/elements/slider-control/slider-control.theme.js +35 -0
- package/dist/elements/slider-control/useSliderMarksLayout.d.ts +6 -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.d.ts +48 -0
- package/dist/elements/tooltip/Tooltip.vue_vue_type_script_setup_true_lang.js +161 -0
- package/dist/elements/tooltip/index.d.ts +2 -0
- package/dist/elements/tooltip/tooltip.theme.d.ts +29 -0
- package/dist/elements/tooltip/tooltip.theme.js +46 -0
- package/dist/elements/tooltip/useTooltipOpenState.d.ts +17 -0
- package/dist/elements/tooltip/useTooltipOpenState.js +57 -0
- package/dist/index.d.ts +21 -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.d.ts +21 -0
- package/dist/shared/composables/useNumberFieldTyping.js +70 -0
- package/dist/shared/composables/usePointerGraceArea.d.ts +11 -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/pointer-grace-area.d.ts +12 -0
- package/dist/shared/types/slider.d.ts +6 -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.d.ts +5 -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.d.ts +3 -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.d.ts +11 -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.d.ts +3 -0
- package/dist/shared/utils/shiftFloatingPosition.js +21 -0
- package/dist/shared/utils/sliderPosition.d.ts +11 -0
- package/dist/shared/utils/sliderPosition.js +27 -0
- package/dist/shared/utils/sliderThumbs.d.ts +13 -0
- package/dist/shared/utils/sliderThumbs.js +16 -0
- package/dist/shared/utils/steppedValue.d.ts +18 -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 +2 -0
- package/src/shared/styles/utilities/shake.css +21 -0
- package/src/shared/styles/utilities/slider-mark-position.css +8 -0
- package/dist/src-Bnn36nLV.js +0 -7856
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { readRowKey as e } from "../utils/tableColumns.js";
|
|
2
|
+
import { computed as t, toValue as n, unref as r } from "vue";
|
|
3
|
+
// src/shared/composables/useRowSelection.ts
|
|
4
|
+
function i(i, a, o = {}) {
|
|
5
|
+
function s(t) {
|
|
6
|
+
return e(t, r(o.rowKey) ?? "id");
|
|
7
|
+
}
|
|
8
|
+
function c(e) {
|
|
9
|
+
return o.isRowSelectable?.(e) ?? !0;
|
|
10
|
+
}
|
|
11
|
+
function l(e) {
|
|
12
|
+
return a.value.includes(s(e));
|
|
13
|
+
}
|
|
14
|
+
let u = t(() => n(i).filter(c)), d = t(() => {
|
|
15
|
+
let e = u.value.filter(l).length;
|
|
16
|
+
return e === 0 ? "none" : e === u.value.length ? "all" : "some";
|
|
17
|
+
}), f = t(() => a.value.length);
|
|
18
|
+
function p(e, t = !l(e)) {
|
|
19
|
+
if (!c(e) || t === l(e)) return;
|
|
20
|
+
let n = s(e);
|
|
21
|
+
a.value = t ? [...a.value, n] : a.value.filter((e) => e !== n);
|
|
22
|
+
}
|
|
23
|
+
function m(e = d.value !== "all") {
|
|
24
|
+
let t = new Set(u.value.map(s)), n = a.value.filter((e) => !t.has(e));
|
|
25
|
+
a.value = e ? [...n, ...t] : n;
|
|
26
|
+
}
|
|
27
|
+
function h() {
|
|
28
|
+
a.value = [];
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
selectionState: d,
|
|
32
|
+
selectedRowCount: f,
|
|
33
|
+
isRowSelected: l,
|
|
34
|
+
isRowSelectable: c,
|
|
35
|
+
toggleRow: p,
|
|
36
|
+
toggleAllRows: m,
|
|
37
|
+
clearSelection: h
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export { i as useRowSelection };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createShortcutHandler as e } from "../utils/createShortcutHandler.js";
|
|
2
|
+
import { editableFieldGuard as t } from "../utils/editableFieldGuard.js";
|
|
3
|
+
import { onMounted as n, toValue as r, watch as i } from "vue";
|
|
4
|
+
// src/shared/composables/useShortcuts.ts
|
|
5
|
+
function a(a, o = {}) {
|
|
6
|
+
function s() {
|
|
7
|
+
return o.target === void 0 ? document : r(o.target);
|
|
8
|
+
}
|
|
9
|
+
n(() => {
|
|
10
|
+
i(() => [
|
|
11
|
+
r(a),
|
|
12
|
+
s(),
|
|
13
|
+
r(o.enabled) ?? !0
|
|
14
|
+
], ([n, r, i], a, s) => {
|
|
15
|
+
if (!i || !r) return;
|
|
16
|
+
let c = e(n, { guards: [t, ...o.guards ?? []] });
|
|
17
|
+
r.addEventListener("keydown", c), s(() => r.removeEventListener("keydown", c));
|
|
18
|
+
}, { immediate: !0 });
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export { a as useShortcuts };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { computed as e, onBeforeUnmount as t, onMounted as n, ref as r, shallowRef as i, watch as a } from "vue";
|
|
2
|
+
// src/shared/composables/useSlidingThumb.ts
|
|
3
|
+
var o = .15;
|
|
4
|
+
function s(e, t) {
|
|
5
|
+
let n = t.offsetLeft, r = Math.floor(t.clientWidth), i = e.scrollWidth - (n + r) < 2;
|
|
6
|
+
return {
|
|
7
|
+
offset: n,
|
|
8
|
+
width: Math.max(0, i ? r - 1 : r)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function c(e, t) {
|
|
12
|
+
return e?.offset === t.offset && e.width === t.width;
|
|
13
|
+
}
|
|
14
|
+
function l(e, t, n) {
|
|
15
|
+
let r = e.clientWidth;
|
|
16
|
+
if (e.scrollWidth <= r) return;
|
|
17
|
+
let i = r * o;
|
|
18
|
+
(t.offset < e.scrollLeft + i || t.offset + t.width > e.scrollLeft + r - i) && e.scrollTo({
|
|
19
|
+
left: t.offset + t.width / 2 - r / 2,
|
|
20
|
+
behavior: n
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function u(e, t) {
|
|
24
|
+
let n = e, r = requestAnimationFrame(function e() {
|
|
25
|
+
--n, n === 0 ? t() : r = requestAnimationFrame(e);
|
|
26
|
+
});
|
|
27
|
+
return () => cancelAnimationFrame(r);
|
|
28
|
+
}
|
|
29
|
+
function d({ trackElement: o, findSelectedElement: d, placementSources: f }) {
|
|
30
|
+
let p = i(), m = r(!1), h = r(!1), g, _;
|
|
31
|
+
function v() {
|
|
32
|
+
let e = o.value, t = d();
|
|
33
|
+
return e && t ? {
|
|
34
|
+
track: e,
|
|
35
|
+
placement: s(e, t)
|
|
36
|
+
} : void 0;
|
|
37
|
+
}
|
|
38
|
+
function y(e) {
|
|
39
|
+
let t = v();
|
|
40
|
+
t && !c(p.value, t.placement) && (g?.(), h.value = !1, p.value = t.placement, e && l(t.track, t.placement, e), g = u(2, () => {
|
|
41
|
+
m.value = !0, h.value = !0;
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
function b() {
|
|
45
|
+
if (!m.value) {
|
|
46
|
+
y("instant");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let e = v();
|
|
50
|
+
e && (p.value = e.placement, l(e.track, e.placement, "smooth"));
|
|
51
|
+
}
|
|
52
|
+
return n(() => {
|
|
53
|
+
y("instant"), o.value && (_ = new ResizeObserver(() => y()), _.observe(o.value));
|
|
54
|
+
}), t(() => {
|
|
55
|
+
_?.disconnect(), g?.();
|
|
56
|
+
}), a(f, b, { flush: "post" }), {
|
|
57
|
+
thumbStyle: e(() => p.value ? {
|
|
58
|
+
width: `${p.value.width}px`,
|
|
59
|
+
transform: `translateX(${p.value.offset}px)`
|
|
60
|
+
} : void 0),
|
|
61
|
+
isThumbPlaced: m,
|
|
62
|
+
animatesThumb: h
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export { d as useSlidingThumb };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type MaybeRef, type MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import type { TableColumn, TableColumnFilters, TableColumnTypes, TableRowKey, TableRowKeyReader, TableSort } from '../types/table';
|
|
3
|
+
export interface TableRowsOptions<Row> {
|
|
4
|
+
columns?: MaybeRefOrGetter<TableColumn<Row>[] | undefined>;
|
|
5
|
+
columnTypes?: MaybeRefOrGetter<TableColumnTypes | undefined>;
|
|
6
|
+
locale?: MaybeRefOrGetter<string | undefined>;
|
|
7
|
+
searchQuery?: MaybeRefOrGetter<string | undefined>;
|
|
8
|
+
searchMatcher?: (row: Row, searchQuery: string) => boolean;
|
|
9
|
+
columnFilters?: MaybeRefOrGetter<TableColumnFilters | undefined>;
|
|
10
|
+
sort?: MaybeRefOrGetter<TableSort | undefined>;
|
|
11
|
+
page?: MaybeRef<number>;
|
|
12
|
+
rowsPerPage?: MaybeRefOrGetter<number | undefined>;
|
|
13
|
+
serverSide?: MaybeRefOrGetter<boolean | undefined>;
|
|
14
|
+
childrenKey?: MaybeRefOrGetter<string | undefined>;
|
|
15
|
+
rowKey?: MaybeRef<TableRowKeyReader<Row> | undefined>;
|
|
16
|
+
pinnedRows?: MaybeRefOrGetter<TableRowKey[] | undefined>;
|
|
17
|
+
}
|
|
18
|
+
/** Search, filter, sort and page rows, for a table or any list, back to page one when the query changes. */
|
|
19
|
+
export declare function useTableRows<Row>(rows: MaybeRefOrGetter<Row[]>, rowsOptions?: TableRowsOptions<Row>): {
|
|
20
|
+
resolvedColumns: import("vue").ComputedRef<TableColumn<Row>[]>;
|
|
21
|
+
matchingRows: import("vue").ComputedRef<Row[]>;
|
|
22
|
+
sortedRows: import("vue").ComputedRef<Row[]>;
|
|
23
|
+
visibleRows: import("vue").ComputedRef<Row[]>;
|
|
24
|
+
matchingRowCount: import("vue").ComputedRef<number>;
|
|
25
|
+
pageCount: import("vue").ComputedRef<number>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { inferTableColumns as e } from "../utils/tableColumns.js";
|
|
2
|
+
import { countTablePages as t, createRowQueryKey as n, filterTableRows as r, pinTableRows as i, sliceTablePage as a, sortTableRows as o } from "../utils/tableRows.js";
|
|
3
|
+
import { computed as s, isRef as c, toValue as l, unref as u, watch as d } from "vue";
|
|
4
|
+
// src/shared/composables/useTableRows.ts
|
|
5
|
+
function f(f, p = {}) {
|
|
6
|
+
let m = s(() => l(p.columns) ?? e(l(f))), h = s(() => !!l(p.serverSide)), g = s(() => ({
|
|
7
|
+
columns: m.value,
|
|
8
|
+
columnTypes: l(p.columnTypes),
|
|
9
|
+
locale: l(p.locale)
|
|
10
|
+
})), _ = s(() => h.value ? l(f) : r(l(f), {
|
|
11
|
+
...g.value,
|
|
12
|
+
searchQuery: l(p.searchQuery),
|
|
13
|
+
searchMatcher: p.searchMatcher,
|
|
14
|
+
columnFilters: l(p.columnFilters),
|
|
15
|
+
childrenKey: l(p.childrenKey)
|
|
16
|
+
})), v = s(() => {
|
|
17
|
+
if (h.value) return _.value;
|
|
18
|
+
let e = o(_.value, {
|
|
19
|
+
...g.value,
|
|
20
|
+
sort: l(p.sort)
|
|
21
|
+
});
|
|
22
|
+
return i(e, l(p.pinnedRows), u(p.rowKey) ?? "id");
|
|
23
|
+
}), y = s(() => _.value.length), b = s(() => t(y.value, l(p.rowsPerPage))), x = s(() => h.value ? v.value : a(v.value, l(p.page) ?? 1, l(p.rowsPerPage))), S = p.page;
|
|
24
|
+
if (c(S)) {
|
|
25
|
+
let e = s(() => n(l(p.searchQuery), l(p.columnFilters), l(p.sort)));
|
|
26
|
+
d(e, () => {
|
|
27
|
+
S.value = 1;
|
|
28
|
+
}), d(b, (e) => {
|
|
29
|
+
!h.value && S.value > e && (S.value = e);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
resolvedColumns: m,
|
|
34
|
+
matchingRows: _,
|
|
35
|
+
sortedRows: v,
|
|
36
|
+
visibleRows: x,
|
|
37
|
+
matchingRowCount: y,
|
|
38
|
+
pageCount: b
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export { f as useTableRows };
|
|
@@ -15,6 +15,15 @@ export interface BoxRect extends BoxSize {
|
|
|
15
15
|
x: number;
|
|
16
16
|
y: number;
|
|
17
17
|
}
|
|
18
|
+
export interface VirtualFloatingAnchor {
|
|
19
|
+
getBoundingClientRect: () => BoxRect;
|
|
20
|
+
contextElement?: HTMLElement;
|
|
21
|
+
}
|
|
22
|
+
export type FloatingAnchor = HTMLElement | VirtualFloatingAnchor;
|
|
23
|
+
export interface FloatingPoint {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
}
|
|
18
27
|
export interface FloatingPositionContext {
|
|
19
28
|
anchorRect: BoxRect;
|
|
20
29
|
floatingSize: BoxSize;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface PointerPosition {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export interface ElementEdges {
|
|
6
|
+
top: number;
|
|
7
|
+
right: number;
|
|
8
|
+
bottom: number;
|
|
9
|
+
left: number;
|
|
10
|
+
}
|
|
11
|
+
export type PointerExitSide = keyof ElementEdges;
|
|
12
|
+
export type PointerGraceArea = PointerPosition[];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ClassNameValue } from '../utils/tv';
|
|
2
|
+
import type { ValuePath } from './value-path';
|
|
3
|
+
export type TableCellAlign = 'start' | 'center' | 'end';
|
|
4
|
+
export type TableSortDirection = 'ascending' | 'descending';
|
|
5
|
+
export interface TableSortEntry {
|
|
6
|
+
key: string;
|
|
7
|
+
direction: TableSortDirection;
|
|
8
|
+
}
|
|
9
|
+
export type TableSort = TableSortEntry[];
|
|
10
|
+
export type TableColumnFilters = Record<string, unknown>;
|
|
11
|
+
export type TableRowKey = string | number;
|
|
12
|
+
export type TableRowKeyReader<Row> = (keyof Row & string) | ((row: Row) => TableRowKey);
|
|
13
|
+
export type TableFormatOptions = Intl.NumberFormatOptions & Intl.DateTimeFormatOptions;
|
|
14
|
+
export interface TableValueContext {
|
|
15
|
+
locale?: string;
|
|
16
|
+
formatOptions?: TableFormatOptions;
|
|
17
|
+
}
|
|
18
|
+
export interface TableColumnType {
|
|
19
|
+
align?: TableCellAlign;
|
|
20
|
+
tabularNumbers?: boolean;
|
|
21
|
+
format?: (cellValue: unknown, valueContext: TableValueContext) => string;
|
|
22
|
+
compare?: (firstValue: unknown, secondValue: unknown, valueContext: TableValueContext) => number;
|
|
23
|
+
}
|
|
24
|
+
export type TableColumnTypes = Record<string, TableColumnType>;
|
|
25
|
+
export type BuiltInTableColumnTypeName = 'text' | 'number' | 'decimal' | 'percentage' | 'date' | 'boolean';
|
|
26
|
+
export type TableAggregate<Row> = 'sum' | 'average' | 'count' | 'min' | 'max' | ((rows: Row[]) => unknown);
|
|
27
|
+
export type TableColumnPinning = 'start' | 'end';
|
|
28
|
+
export type TableFooter<Row> = string | number | ((matchingRows: Row[]) => unknown);
|
|
29
|
+
export interface TableColumn<Row = Record<string, unknown>> {
|
|
30
|
+
key: string;
|
|
31
|
+
label?: string;
|
|
32
|
+
accessor?: ValuePath<Row> | ((row: Row) => unknown);
|
|
33
|
+
type?: BuiltInTableColumnTypeName | (string & {});
|
|
34
|
+
formatOptions?: TableFormatOptions;
|
|
35
|
+
format?: (cellValue: unknown, row: Row) => string;
|
|
36
|
+
align?: TableCellAlign;
|
|
37
|
+
sortable?: boolean;
|
|
38
|
+
compare?: (firstValue: unknown, secondValue: unknown, firstRow: Row, secondRow: Row) => number;
|
|
39
|
+
firstSortDirection?: TableSortDirection;
|
|
40
|
+
searchable?: boolean;
|
|
41
|
+
filter?: (cellValue: unknown, filterValue: unknown, row: Row) => boolean;
|
|
42
|
+
hint?: string;
|
|
43
|
+
width?: string;
|
|
44
|
+
maxWidth?: string;
|
|
45
|
+
hideLabel?: boolean;
|
|
46
|
+
wrap?: boolean;
|
|
47
|
+
headerClass?: ClassNameValue;
|
|
48
|
+
cellClass?: ClassNameValue | ((row: Row) => ClassNameValue);
|
|
49
|
+
aggregate?: TableAggregate<Row>;
|
|
50
|
+
pinned?: TableColumnPinning;
|
|
51
|
+
hidden?: boolean;
|
|
52
|
+
mergeRepeated?: boolean;
|
|
53
|
+
footer?: TableFooter<Row>;
|
|
54
|
+
}
|
|
55
|
+
export type TableRowColor = 'success' | 'warning' | 'danger' | 'info';
|
|
56
|
+
export interface TableColumnSettings {
|
|
57
|
+
columnTypes?: TableColumnTypes;
|
|
58
|
+
locale?: string;
|
|
59
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type RemainingPathDepth = [never, 0, 1, 2, 3];
|
|
2
|
+
type PathLeafValue = Date | readonly unknown[] | ((...callArguments: never[]) => unknown);
|
|
3
|
+
export type ValuePath<Value, Depth extends number = 4> = [Depth] extends [never] ? never : Value extends PathLeafValue ? never : Value extends object ? {
|
|
4
|
+
[Key in keyof Value & string]: Key | (NonNullable<Value[Key]> extends PathLeafValue ? never : NonNullable<Value[Key]> extends object ? `${Key}.${ValuePath<NonNullable<Value[Key]>, RemainingPathDepth[Depth]>}` : never);
|
|
5
|
+
}[keyof Value & string] : never;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { addDaysToIsoDate as e, countDaysInIsoMonth as t, findIsoDateWeekday as n } from "./isoDate.js";
|
|
2
|
+
// src/shared/utils/calendarMonth.ts
|
|
3
|
+
var r = 7;
|
|
4
|
+
function i(e) {
|
|
5
|
+
return Array.from({ length: r }, (t, n) => (e + n) % r);
|
|
6
|
+
}
|
|
7
|
+
function a(i, a) {
|
|
8
|
+
let o = `${i}-01`, s = t(i), c = (n(o) - a + r) % r, l = Array.from({ length: s }, (t, r) => {
|
|
9
|
+
let i = e(o, r);
|
|
10
|
+
return {
|
|
11
|
+
isoDate: i,
|
|
12
|
+
dayNumber: r + 1,
|
|
13
|
+
weekday: n(i)
|
|
14
|
+
};
|
|
15
|
+
}), u = [...Array(c).fill(null), ...l], d = Array.from({ length: Math.ceil(u.length / r) }, (e, t) => u.slice(t * r, (t + 1) * r));
|
|
16
|
+
return {
|
|
17
|
+
isoMonth: i,
|
|
18
|
+
firstIsoDate: o,
|
|
19
|
+
lastIsoDate: l[s - 1].isoDate,
|
|
20
|
+
weeks: d
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export { a as createCalendarMonth, i as orderWeekdays };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/shared/utils/computeFloatingPosition.ts
|
|
2
|
+
function e(e, t, n, r) {
|
|
3
|
+
return r.align === "center" ? e + (t - n) / 2 : r.align === "end" ? e + t - n - r.alignOffset : e + r.alignOffset;
|
|
4
|
+
}
|
|
5
|
+
var t = {
|
|
6
|
+
top: ({ anchorRect: t, floatingSize: n }, r) => ({
|
|
7
|
+
x: e(t.x, t.width, n.width, r),
|
|
8
|
+
y: t.y - n.height - r.sideOffset
|
|
9
|
+
}),
|
|
10
|
+
bottom: ({ anchorRect: t, floatingSize: n }, r) => ({
|
|
11
|
+
x: e(t.x, t.width, n.width, r),
|
|
12
|
+
y: t.y + t.height + r.sideOffset
|
|
13
|
+
}),
|
|
14
|
+
left: ({ anchorRect: t, floatingSize: n }, r) => ({
|
|
15
|
+
x: t.x - n.width - r.sideOffset,
|
|
16
|
+
y: e(t.y, t.height, n.height, r)
|
|
17
|
+
}),
|
|
18
|
+
right: ({ anchorRect: t, floatingSize: n }, r) => ({
|
|
19
|
+
x: t.x + t.width + r.sideOffset,
|
|
20
|
+
y: e(t.y, t.height, n.height, r)
|
|
21
|
+
})
|
|
22
|
+
};
|
|
23
|
+
function n(e, n) {
|
|
24
|
+
return {
|
|
25
|
+
...t[n.side](e, n),
|
|
26
|
+
placement: n
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function r(e, t, r = []) {
|
|
30
|
+
return r.reduce((t, n) => n(t, e), n(e, t));
|
|
31
|
+
}
|
|
32
|
+
export { r as computeFloatingPosition, n as placeFloatingAgainstAnchor };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { addDaysToIsoDate as e, isoDateToUtcDate as t } from "./isoDate.js";
|
|
2
|
+
// src/shared/utils/createDateFormatters.ts
|
|
3
|
+
var n = "2023-01-01";
|
|
4
|
+
function r(e) {
|
|
5
|
+
return Array.from(e.replace(/\.$/, "")).slice(0, 2).join("");
|
|
6
|
+
}
|
|
7
|
+
function i(i) {
|
|
8
|
+
let a = new Intl.DateTimeFormat(i, {
|
|
9
|
+
year: "2-digit",
|
|
10
|
+
month: "2-digit",
|
|
11
|
+
day: "2-digit",
|
|
12
|
+
timeZone: "UTC"
|
|
13
|
+
}), o = new Intl.DateTimeFormat(i, {
|
|
14
|
+
dateStyle: "full",
|
|
15
|
+
timeZone: "UTC"
|
|
16
|
+
}), s = new Intl.DateTimeFormat(i, {
|
|
17
|
+
month: "long",
|
|
18
|
+
year: "numeric",
|
|
19
|
+
timeZone: "UTC"
|
|
20
|
+
}), c = new Intl.DateTimeFormat(i, {
|
|
21
|
+
weekday: "short",
|
|
22
|
+
timeZone: "UTC"
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
formatShortDate: (e) => a.format(t(e)),
|
|
26
|
+
formatFullDate: (e) => o.format(t(e)),
|
|
27
|
+
formatMonth: (e) => s.format(t(`${e}-01`)),
|
|
28
|
+
formatWeekday: (i) => r(c.format(t(e(n, i))))
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export { i as createDateFormatters };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { countDaysInIsoMonth as e } from "./isoDate.js";
|
|
2
|
+
// src/shared/utils/createDateInputMask.ts
|
|
3
|
+
var t = {
|
|
4
|
+
day: 2,
|
|
5
|
+
month: 2,
|
|
6
|
+
year: 4
|
|
7
|
+
}, n = {
|
|
8
|
+
day: "DD",
|
|
9
|
+
month: "MM",
|
|
10
|
+
year: "YYYY"
|
|
11
|
+
}, r = /[]/g, i = "/", a = " – ";
|
|
12
|
+
function o(e) {
|
|
13
|
+
return e === "day" || e === "month" || e === "year";
|
|
14
|
+
}
|
|
15
|
+
function s(e, t) {
|
|
16
|
+
return String(e).padStart(t, "0");
|
|
17
|
+
}
|
|
18
|
+
function c(e) {
|
|
19
|
+
let t = new Intl.DateTimeFormat(e, {
|
|
20
|
+
year: "numeric",
|
|
21
|
+
month: "2-digit",
|
|
22
|
+
day: "2-digit",
|
|
23
|
+
timeZone: "UTC",
|
|
24
|
+
numberingSystem: "latn"
|
|
25
|
+
}), n = [], a = [];
|
|
26
|
+
for (let e of t.formatToParts(new Date(Date.UTC(2026, 10, 26)))) if (o(e.type)) n.push(e.type);
|
|
27
|
+
else if (n.length > 0 && n.length < 3) {
|
|
28
|
+
let t = n.length - 1;
|
|
29
|
+
a[t] = (a[t] ?? "") + e.value.replace(r, "");
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
datePartOrder: n,
|
|
33
|
+
separators: a.map((e) => e || i)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function l(e) {
|
|
37
|
+
return e.replace(/[#@*!]/g, (e) => `!${e}`);
|
|
38
|
+
}
|
|
39
|
+
function u(t, n, r) {
|
|
40
|
+
if (t < 1 || n < 1 || n > 12 || r < 1) return;
|
|
41
|
+
let i = `${s(t, 4)}-${s(n, 2)}`;
|
|
42
|
+
return r > e(i) ? void 0 : `${i}-${s(r, 2)}`;
|
|
43
|
+
}
|
|
44
|
+
function d(e) {
|
|
45
|
+
let { datePartOrder: r, separators: i } = c(e), o = r.reduce((e, n) => e + t[n], 0), s = r.map((e, n) => "#".repeat(t[e]) + l(i[n] ?? "")).join(""), d = r.map((e, t) => n[e] + (i[t] ?? "")).join("");
|
|
46
|
+
function f(e) {
|
|
47
|
+
let t = {
|
|
48
|
+
year: e.slice(0, 4),
|
|
49
|
+
month: e.slice(5, 7),
|
|
50
|
+
day: e.slice(8, 10)
|
|
51
|
+
};
|
|
52
|
+
return r.map((e, n) => t[e] + (i[n] ?? "")).join("");
|
|
53
|
+
}
|
|
54
|
+
function p(e) {
|
|
55
|
+
let n = e.trim(), i = /^(\d{4})-(\d{2})-(\d{2})$/.exec(n);
|
|
56
|
+
if (i) return u(Number(i[1]), Number(i[2]), Number(i[3]));
|
|
57
|
+
let a = n.split(/\D+/).filter(Boolean), s = {};
|
|
58
|
+
if (a.length === r.length) r.forEach((e, t) => {
|
|
59
|
+
s[e] = a[t];
|
|
60
|
+
});
|
|
61
|
+
else {
|
|
62
|
+
let e = n.replace(/\D/g, "");
|
|
63
|
+
if (e.length !== o) return;
|
|
64
|
+
let i = 0;
|
|
65
|
+
for (let n of r) s[n] = e.slice(i, i + t[n]), i += t[n];
|
|
66
|
+
}
|
|
67
|
+
if (s.year?.length === 4) return u(Number(s.year), Number(s.month), Number(s.day));
|
|
68
|
+
}
|
|
69
|
+
function m(e) {
|
|
70
|
+
let t = p(e);
|
|
71
|
+
return t ? f(t) : e;
|
|
72
|
+
}
|
|
73
|
+
let h = s + l(a) + s, g = d + a + d;
|
|
74
|
+
function _([e, t]) {
|
|
75
|
+
return f(e) + a + f(t);
|
|
76
|
+
}
|
|
77
|
+
function v(e) {
|
|
78
|
+
let t = e.replace(/\D/g, ""), n = t.length >= o, r = t.length >= o * 2;
|
|
79
|
+
return {
|
|
80
|
+
hasCompleteStart: n,
|
|
81
|
+
hasCompleteEnd: r,
|
|
82
|
+
rangeStart: n ? p(t.slice(0, o)) : void 0,
|
|
83
|
+
rangeEnd: r ? p(t.slice(o, o * 2)) : void 0
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function y(e) {
|
|
87
|
+
let t = /^\s*(\d{4}-\d{2}-\d{2})\D+(\d{4}-\d{2}-\d{2})\s*$/.exec(e), n = e.split(/\D+/).filter(Boolean), [r, i] = t ? [t[1], t[2]] : [n.slice(0, 3).join(" "), n.slice(3, 6).join(" ")], a = t || n.length === 6 ? p(r) : void 0, o = a ? p(i) : void 0;
|
|
88
|
+
return a && o ? _([a, o]) : e;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
pattern: s,
|
|
92
|
+
formatHint: d,
|
|
93
|
+
formatIsoDate: f,
|
|
94
|
+
parseTypedDate: p,
|
|
95
|
+
normalizeTypedDate: m,
|
|
96
|
+
rangePattern: h,
|
|
97
|
+
rangeFormatHint: g,
|
|
98
|
+
formatIsoRange: _,
|
|
99
|
+
parseTypedRange: v,
|
|
100
|
+
normalizeTypedRange: y
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export { d as createDateInputMask };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Delay a callback until no call happened for the given time, keeping only the arguments of the last call. */
|
|
2
|
+
export declare function createDebouncedCallback<CallbackArguments extends unknown[]>(callback: (...callbackArguments: CallbackArguments) => void, delay: number): {
|
|
3
|
+
callAfterDelay: (...callbackArguments: CallbackArguments) => void;
|
|
4
|
+
cancel: () => void;
|
|
5
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/shared/utils/createDebouncedCallback.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
let n;
|
|
4
|
+
function r() {
|
|
5
|
+
clearTimeout(n), n = void 0;
|
|
6
|
+
}
|
|
7
|
+
function i(...i) {
|
|
8
|
+
r(), n = setTimeout(() => {
|
|
9
|
+
n = void 0, e(...i);
|
|
10
|
+
}, t);
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
callAfterDelay: i,
|
|
14
|
+
cancel: r
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export { e as createDebouncedCallback };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// src/shared/utils/createMask.ts
|
|
2
|
+
var e = {
|
|
3
|
+
"#": { pattern: /\d/ },
|
|
4
|
+
"@": { pattern: /\p{L}/u },
|
|
5
|
+
"*": { pattern: /[\p{L}\d]/u }
|
|
6
|
+
};
|
|
7
|
+
function t(e) {
|
|
8
|
+
return typeof e == "string" || Array.isArray(e) ? { pattern: e } : e;
|
|
9
|
+
}
|
|
10
|
+
function n(e, t) {
|
|
11
|
+
let n = [], r = [...e];
|
|
12
|
+
for (let e = 0; e < r.length; e += 1) {
|
|
13
|
+
let i = r[e];
|
|
14
|
+
i === "!" && e + 1 < r.length ? (e += 1, n.push({ literal: r[e] })) : t[i] ? n.push({ token: t[i] }) : n.push({ literal: i });
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
steps: n,
|
|
18
|
+
tokenCount: n.filter((e) => e.token).length
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function r(e, t, n) {
|
|
22
|
+
let r = [...t], i = "", a = "", o = "", s = 0;
|
|
23
|
+
for (let t of e.steps) {
|
|
24
|
+
if (t.literal !== void 0) {
|
|
25
|
+
o += t.literal, r[s] === t.literal && (s += 1);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
for (; s < r.length && !t.token.pattern.test(r[s]);) s += 1;
|
|
29
|
+
if (s >= r.length) break;
|
|
30
|
+
let e = t.token.transform?.(r[s]) ?? r[s];
|
|
31
|
+
i += o + e, a += e, o = "", s += 1;
|
|
32
|
+
}
|
|
33
|
+
return n && a && (i += o), {
|
|
34
|
+
masked: i,
|
|
35
|
+
unmasked: a,
|
|
36
|
+
completed: [...a].length === e.tokenCount
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function i(i) {
|
|
40
|
+
let a = t(i), o = {
|
|
41
|
+
...e,
|
|
42
|
+
...a.tokens
|
|
43
|
+
}, s = (Array.isArray(a.pattern) ? a.pattern : [a.pattern]).map((e) => n(e, o)).sort((e, t) => e.tokenCount - t.tokenCount), c = s[s.length - 1];
|
|
44
|
+
function l(e) {
|
|
45
|
+
return s.find((t) => t.tokenCount >= e) ?? c;
|
|
46
|
+
}
|
|
47
|
+
function u(e, t = {}) {
|
|
48
|
+
let n = a.preprocess ? a.preprocess(e) : e, i = t.eager ?? a.eager ?? !0, o = [...r(c, n, !1).unmasked].length;
|
|
49
|
+
return r(l(o), n, i);
|
|
50
|
+
}
|
|
51
|
+
function d(e, t) {
|
|
52
|
+
if (t <= 0) return 0;
|
|
53
|
+
let { steps: n } = l([...u(e, { eager: !1 }).unmasked].length), r = 0, i = 0;
|
|
54
|
+
for (let [a, o] of n.entries()) {
|
|
55
|
+
if (a >= e.length) break;
|
|
56
|
+
if (i = a + 1, o.token && (r += 1), r === t) return i;
|
|
57
|
+
}
|
|
58
|
+
return e.length;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
apply: u,
|
|
62
|
+
findCaretPosition: d
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export { i as createMask, e as defaultMaskTokens };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { isApplePlatform as e } from "./isApplePlatform.js";
|
|
2
|
+
import { parseShortcut as t } from "./parseShortcut.js";
|
|
3
|
+
// src/shared/utils/createShortcutHandler.ts
|
|
4
|
+
var n = 1e3, r = /* @__PURE__ */ new Set([
|
|
5
|
+
"shift",
|
|
6
|
+
"control",
|
|
7
|
+
"alt",
|
|
8
|
+
"meta",
|
|
9
|
+
"altgraph",
|
|
10
|
+
"capslock",
|
|
11
|
+
"fn"
|
|
12
|
+
]), i = /^(?:Key|Digit)(.)$/;
|
|
13
|
+
function a(e) {
|
|
14
|
+
return [...e].length === 1 && e.toLowerCase() === e.toUpperCase();
|
|
15
|
+
}
|
|
16
|
+
function o(e, t) {
|
|
17
|
+
if (e.key.toLowerCase() === t) return !0;
|
|
18
|
+
let n = i.exec(e.code)?.[1]?.toLowerCase();
|
|
19
|
+
return e.altKey && n === t;
|
|
20
|
+
}
|
|
21
|
+
function s(t, n) {
|
|
22
|
+
let { modifiers: r } = n, i = e(), o = a(n.key), s = o && t.getModifierState("AltGraph"), c = r.has("ctrl") || r.has("mod") && !i, l = r.has("meta") || r.has("mod") && i;
|
|
23
|
+
return t.metaKey === l && (s || t.ctrlKey === c) && (s || t.altKey === r.has("alt")) && (o || t.shiftKey === r.has("shift"));
|
|
24
|
+
}
|
|
25
|
+
function c(e, t) {
|
|
26
|
+
return t ? o(e, t.key) && s(e, t) : !1;
|
|
27
|
+
}
|
|
28
|
+
function l(e, n) {
|
|
29
|
+
let r = typeof n == "function" ? { handler: n } : n;
|
|
30
|
+
return {
|
|
31
|
+
shortcut: e,
|
|
32
|
+
keySequence: t(e),
|
|
33
|
+
handler: r.handler,
|
|
34
|
+
preventDefault: r.preventDefault ?? !0,
|
|
35
|
+
allowInEditable: r.allowInEditable ?? !1
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function u(e, t = {}) {
|
|
39
|
+
let i = Object.entries(e).map(([e, t]) => l(e, t)), a = t.guards ?? [], o = t.sequenceTimeout ?? n, s = /* @__PURE__ */ new Map(), u;
|
|
40
|
+
function d(e, t) {
|
|
41
|
+
let n = s.get(t) ?? 0;
|
|
42
|
+
return c(e, t.keySequence[n]) ? n + 1 : +!!c(e, t.keySequence[0]);
|
|
43
|
+
}
|
|
44
|
+
function f(e, t) {
|
|
45
|
+
t.preventDefault && e.preventDefault(), t.handler(e, { shortcut: t.shortcut });
|
|
46
|
+
}
|
|
47
|
+
function p() {
|
|
48
|
+
clearTimeout(u), s.size > 0 && (u = setTimeout(() => s.clear(), o));
|
|
49
|
+
}
|
|
50
|
+
return function(e) {
|
|
51
|
+
if (e instanceof KeyboardEvent && !e.isComposing && !r.has(e.key.toLowerCase())) {
|
|
52
|
+
for (let t of i) {
|
|
53
|
+
let n = a.every((n) => n(e, t)) ? d(e, t) : 0;
|
|
54
|
+
n === t.keySequence.length ? (s.delete(t), f(e, t)) : n > 0 ? s.set(t, n) : s.delete(t);
|
|
55
|
+
}
|
|
56
|
+
p();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export { u as createShortcutHandler };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/shared/utils/createTypeaheadSearch.ts
|
|
2
|
+
function e(e = 500) {
|
|
3
|
+
let t = "", n;
|
|
4
|
+
return function(r, i, a) {
|
|
5
|
+
clearTimeout(n), t += r.toLowerCase(), n = setTimeout(() => {
|
|
6
|
+
t = "";
|
|
7
|
+
}, e);
|
|
8
|
+
let o = t.charAt(0), s = [...t].every((e) => e === o) ? o : t, c = s.length === 1 ? a + 1 : Math.max(a, 0);
|
|
9
|
+
for (let e = 0; e < i.length; e++) {
|
|
10
|
+
let t = (c + e) % i.length;
|
|
11
|
+
if (i[t]?.toLowerCase().startsWith(s)) return t;
|
|
12
|
+
}
|
|
13
|
+
return -1;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export { e as createTypeaheadSearch };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/shared/utils/editableFieldGuard.ts
|
|
2
|
+
var e = /* @__PURE__ */ new Set([
|
|
3
|
+
"INPUT",
|
|
4
|
+
"TEXTAREA",
|
|
5
|
+
"SELECT"
|
|
6
|
+
]);
|
|
7
|
+
function t(t) {
|
|
8
|
+
return t instanceof HTMLElement && (t.isContentEditable || e.has(t.tagName));
|
|
9
|
+
}
|
|
10
|
+
var n = (e, n) => n.allowInEditable || !t(e.target);
|
|
11
|
+
export { n as editableFieldGuard };
|