@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,10 @@
|
|
|
1
|
+
import { computed as e, toValue as t } from "vue";
|
|
2
|
+
// src/shared/composables/useCustomColor.ts
|
|
3
|
+
function n(n, r) {
|
|
4
|
+
let i = e(() => t(n) in r);
|
|
5
|
+
return {
|
|
6
|
+
themeColor: e(() => i.value ? t(n) : "primary"),
|
|
7
|
+
customColorVariable: e(() => i.value ? void 0 : { "--color-primary": t(n) })
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export { n as useCustomColor };
|
|
@@ -2,7 +2,7 @@ import { type MaybeRefOrGetter } from 'vue';
|
|
|
2
2
|
type MaybeElement = HTMLElement | null | undefined;
|
|
3
3
|
interface OutsidePointerDownOptions {
|
|
4
4
|
active: MaybeRefOrGetter<boolean>;
|
|
5
|
-
onDismiss: () => void;
|
|
5
|
+
onDismiss: (pointerEvent: PointerEvent) => void;
|
|
6
6
|
}
|
|
7
7
|
/** Call onDismiss when a pointer goes down outside the given elements, while active. */
|
|
8
8
|
export declare function useDismissOnOutsidePointerDown(insideElements: MaybeRefOrGetter<MaybeElement>[], options: OutsidePointerDownOptions): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { onMounted as e, toValue as t, watch as n } from "vue";
|
|
2
|
+
// src/shared/composables/useDismissOnOutsidePointerDown.ts
|
|
3
|
+
function r(r, i) {
|
|
4
|
+
function a(e) {
|
|
5
|
+
let n = e.target;
|
|
6
|
+
n instanceof Node && (r.some((e) => t(e)?.contains(n)) || i.onDismiss(e));
|
|
7
|
+
}
|
|
8
|
+
e(() => {
|
|
9
|
+
n(() => t(i.active), (e, t, n) => {
|
|
10
|
+
e && (document.addEventListener("pointerdown", a, { capture: !0 }), n(() => document.removeEventListener("pointerdown", a, { capture: !0 })));
|
|
11
|
+
}, { immediate: !0 });
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export { r as useDismissOnOutsidePointerDown };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { computed as e, useId as t } from "vue";
|
|
2
|
+
// src/shared/composables/useFieldDescription.ts
|
|
3
|
+
function n(n) {
|
|
4
|
+
let r = t(), i = e(() => n.id ?? r), a = e(() => `${i.value}-hint`), o = e(() => `${i.value}-error`);
|
|
5
|
+
return {
|
|
6
|
+
fieldId: i,
|
|
7
|
+
hintId: a,
|
|
8
|
+
errorMessageId: o,
|
|
9
|
+
isInvalid: e(() => !!(n.invalid || n.errorMessage)),
|
|
10
|
+
describingElementId: e(() => {
|
|
11
|
+
if (n.errorMessage) return o.value;
|
|
12
|
+
if (n.hint) return a.value;
|
|
13
|
+
})
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export { n as useFieldDescription };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type CSSProperties, type MaybeRefOrGetter } from 'vue';
|
|
2
|
-
import type { FloatingAlign, FloatingPlacement, FloatingPositionModifier, FloatingSide, FloatingStrategy } from '../types/floating-position';
|
|
2
|
+
import type { FloatingAlign, FloatingAnchor, FloatingPlacement, FloatingPositionModifier, FloatingSide, FloatingStrategy } from '../types/floating-position';
|
|
3
3
|
type MaybeElement = HTMLElement | null | undefined;
|
|
4
|
+
type MaybeAnchor = FloatingAnchor | null | undefined;
|
|
4
5
|
export interface FloatingPositionOptions {
|
|
5
6
|
open: MaybeRefOrGetter<boolean>;
|
|
6
7
|
side?: MaybeRefOrGetter<FloatingSide>;
|
|
@@ -11,7 +12,7 @@ export interface FloatingPositionOptions {
|
|
|
11
12
|
positionModifiers?: MaybeRefOrGetter<FloatingPositionModifier[]>;
|
|
12
13
|
}
|
|
13
14
|
/** Keep a floating element, such as a dropdown panel, placed against its anchor while it is open. */
|
|
14
|
-
export declare function useFloatingPosition(
|
|
15
|
+
export declare function useFloatingPosition(floatingAnchor: MaybeRefOrGetter<MaybeAnchor>, floatingElement: MaybeRefOrGetter<MaybeElement>, options: FloatingPositionOptions): {
|
|
15
16
|
floatingStyles: import("vue").ComputedRef<CSSProperties>;
|
|
16
17
|
floatingPlacement: import("vue").ComputedRef<FloatingPlacement>;
|
|
17
18
|
isPositioned: import("vue").ComputedRef<boolean>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { computeFloatingPosition as e } from "../utils/computeFloatingPosition.js";
|
|
2
|
+
import { computed as t, nextTick as n, onMounted as r, shallowRef as i, toValue as a, watch as o } from "vue";
|
|
3
|
+
// src/shared/composables/useFloatingPosition.ts
|
|
4
|
+
function s(e, t) {
|
|
5
|
+
if (t === "fixed") return {
|
|
6
|
+
x: 0,
|
|
7
|
+
y: 0
|
|
8
|
+
};
|
|
9
|
+
let n = e.offsetParent;
|
|
10
|
+
if (!(n instanceof HTMLElement) || (n === document.body || n === document.documentElement) && getComputedStyle(n).position === "static") return {
|
|
11
|
+
x: -window.scrollX,
|
|
12
|
+
y: -window.scrollY
|
|
13
|
+
};
|
|
14
|
+
let r = n.getBoundingClientRect();
|
|
15
|
+
return {
|
|
16
|
+
x: r.x + n.clientLeft - n.scrollLeft,
|
|
17
|
+
y: r.y + n.clientTop - n.scrollTop
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function c(e) {
|
|
21
|
+
if (e) return e instanceof HTMLElement ? e : e.contextElement;
|
|
22
|
+
}
|
|
23
|
+
function l(e) {
|
|
24
|
+
return Math.round(e * window.devicePixelRatio) / window.devicePixelRatio;
|
|
25
|
+
}
|
|
26
|
+
function u(e, t) {
|
|
27
|
+
return e?.x === t.x && e.y === t.y && e.placement.side === t.placement.side && e.placement.align === t.placement.align;
|
|
28
|
+
}
|
|
29
|
+
function d(d, f, p) {
|
|
30
|
+
let m = i(), h = i(0), g = t(() => a(p.strategy) ?? "absolute"), _ = t(() => ({
|
|
31
|
+
side: a(p.side) ?? "bottom",
|
|
32
|
+
align: a(p.align) ?? "start",
|
|
33
|
+
sideOffset: a(p.sideOffset) ?? 0,
|
|
34
|
+
alignOffset: a(p.alignOffset) ?? 0
|
|
35
|
+
}));
|
|
36
|
+
function v() {
|
|
37
|
+
let t = a(d), r = a(f);
|
|
38
|
+
if (!a(p.open) || !t || !r) return;
|
|
39
|
+
let i = t.getBoundingClientRect();
|
|
40
|
+
if (i.width !== h.value) {
|
|
41
|
+
h.value = i.width, n(v);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let o = {
|
|
45
|
+
anchorRect: {
|
|
46
|
+
x: i.x,
|
|
47
|
+
y: i.y,
|
|
48
|
+
width: i.width,
|
|
49
|
+
height: i.height
|
|
50
|
+
},
|
|
51
|
+
floatingSize: {
|
|
52
|
+
width: r.offsetWidth,
|
|
53
|
+
height: r.offsetHeight
|
|
54
|
+
},
|
|
55
|
+
viewportSize: {
|
|
56
|
+
width: document.documentElement.clientWidth,
|
|
57
|
+
height: document.documentElement.clientHeight
|
|
58
|
+
}
|
|
59
|
+
}, c = e(o, _.value, a(p.positionModifiers)), y = s(r, g.value), b = {
|
|
60
|
+
x: l(c.x - y.x),
|
|
61
|
+
y: l(c.y - y.y),
|
|
62
|
+
placement: c.placement
|
|
63
|
+
};
|
|
64
|
+
u(m.value, b) || (m.value = b);
|
|
65
|
+
}
|
|
66
|
+
function y(e) {
|
|
67
|
+
let t = e.target;
|
|
68
|
+
if (t === document || t === document.documentElement) {
|
|
69
|
+
g.value === "fixed" && v();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
let n = c(a(d));
|
|
73
|
+
n && t instanceof Node && t.contains(n) && v();
|
|
74
|
+
}
|
|
75
|
+
r(() => {
|
|
76
|
+
o(() => [
|
|
77
|
+
a(p.open),
|
|
78
|
+
a(d),
|
|
79
|
+
a(f)
|
|
80
|
+
], ([e, t, n], r, i) => {
|
|
81
|
+
if (!e || !t || !n) return;
|
|
82
|
+
v();
|
|
83
|
+
let a = new ResizeObserver(() => v()), o = c(t);
|
|
84
|
+
o && a.observe(o), a.observe(n), window.addEventListener("scroll", y, {
|
|
85
|
+
capture: !0,
|
|
86
|
+
passive: !0
|
|
87
|
+
}), window.addEventListener("resize", v, { passive: !0 }), i(() => {
|
|
88
|
+
a.disconnect(), window.removeEventListener("scroll", y, { capture: !0 }), window.removeEventListener("resize", v);
|
|
89
|
+
});
|
|
90
|
+
}, {
|
|
91
|
+
immediate: !0,
|
|
92
|
+
flush: "post"
|
|
93
|
+
}), o([
|
|
94
|
+
_,
|
|
95
|
+
g,
|
|
96
|
+
() => a(p.positionModifiers)
|
|
97
|
+
], v, { flush: "post" });
|
|
98
|
+
});
|
|
99
|
+
let b = t(() => m.value !== void 0);
|
|
100
|
+
return {
|
|
101
|
+
floatingStyles: t(() => ({
|
|
102
|
+
position: g.value,
|
|
103
|
+
top: `${m.value?.y ?? 0}px`,
|
|
104
|
+
left: `${m.value?.x ?? 0}px`,
|
|
105
|
+
visibility: b.value ? void 0 : "hidden",
|
|
106
|
+
"--floating-anchor-width": `${h.value}px`
|
|
107
|
+
})),
|
|
108
|
+
floatingPlacement: t(() => m.value?.placement ?? _.value),
|
|
109
|
+
isPositioned: b,
|
|
110
|
+
updatePosition: v
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export { d as useFloatingPosition };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createMask as e } from "../utils/createMask.js";
|
|
2
|
+
import { computed as t, readonly as n, ref as r, toValue as i } from "vue";
|
|
3
|
+
// src/shared/composables/useMask.ts
|
|
4
|
+
function a(e) {
|
|
5
|
+
return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement;
|
|
6
|
+
}
|
|
7
|
+
function o(o, s = "") {
|
|
8
|
+
let c = t(() => e(i(o))), l = r(c.value.apply(s, { eager: !1 }).masked), u = t(() => c.value.apply(l.value, { eager: !1 })), d = t(() => u.value.unmasked), f = t(() => u.value.completed);
|
|
9
|
+
function p(e) {
|
|
10
|
+
l.value = c.value.apply(e, { eager: !1 }).masked;
|
|
11
|
+
}
|
|
12
|
+
function m(e) {
|
|
13
|
+
let t = e.target;
|
|
14
|
+
if (!a(t) || e instanceof InputEvent && e.isComposing) return;
|
|
15
|
+
let n = e instanceof InputEvent ? e.inputType : "", r = t.value, i = t.selectionStart ?? r.length, o = i >= r.length, s = l.value, u = c.value.apply(r, { eager: !n.startsWith("delete") }), d = [...c.value.apply(r.slice(0, i), { eager: !1 }).unmasked].length, f = n === "deleteContentBackward" && u.masked === s;
|
|
16
|
+
if (f && d > 0) {
|
|
17
|
+
let e = [...u.unmasked];
|
|
18
|
+
e.splice(d - 1, 1), u = c.value.apply(e.join(""), { eager: !1 }), --d;
|
|
19
|
+
}
|
|
20
|
+
l.value = u.masked, t.value = u.masked;
|
|
21
|
+
let p = o && !f ? u.masked.length : c.value.findCaretPosition(u.masked, d);
|
|
22
|
+
t.ownerDocument.activeElement === t && t.setSelectionRange(p, p);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
maskedValue: n(l),
|
|
26
|
+
unmaskedValue: d,
|
|
27
|
+
isComplete: f,
|
|
28
|
+
setMaskedValue: p,
|
|
29
|
+
applyMaskOnInput: m
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export { o as useMask };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter, type Ref } from 'vue';
|
|
2
|
+
import type { MaskOptions } from '../types/mask';
|
|
3
|
+
/** Keep a field's masked and unmasked models in sync with what is typed through its mask. */
|
|
4
|
+
export declare function useMaskedFieldModel(maskOptions: MaybeRefOrGetter<MaskOptions | undefined>, fieldValue: Ref<string | undefined>, unmaskedFieldValue: Ref<string | undefined>): {
|
|
5
|
+
maskedValue: Readonly<Ref<string, string>>;
|
|
6
|
+
updateMaskedFieldValue: (inputEvent: Event) => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useMask as e } from "./useMask.js";
|
|
2
|
+
import { toValue as t, watch as n } from "vue";
|
|
3
|
+
// src/shared/composables/useMaskedFieldModel.ts
|
|
4
|
+
function r(r, i, a) {
|
|
5
|
+
let { maskedValue: o, unmaskedValue: s, setMaskedValue: c, applyMaskOnInput: l } = e(() => t(r) ?? "", i.value ?? a.value ?? "");
|
|
6
|
+
n(i, (e) => {
|
|
7
|
+
t(r) && e !== o.value && c(e ?? "");
|
|
8
|
+
}), n(a, (e) => {
|
|
9
|
+
t(r) && e !== s.value && c(e ?? "");
|
|
10
|
+
});
|
|
11
|
+
function u(e) {
|
|
12
|
+
l(e), i.value = o.value, a.value = s.value;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
maskedValue: o,
|
|
16
|
+
updateMaskedFieldValue: u
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export { r as useMaskedFieldModel };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createDebouncedCallback as e } from "../utils/createDebouncedCallback.js";
|
|
2
|
+
import { createShortcutHandler as t } from "../utils/createShortcutHandler.js";
|
|
3
|
+
import { clampToRange as n, countStepDecimals as r, roundToDecimals as i } from "../utils/steppedValue.js";
|
|
4
|
+
import { computed as a, onBeforeUnmount as o, ref as s, toValue as c, watch as l } from "vue";
|
|
5
|
+
// src/shared/composables/useNumberFieldTyping.ts
|
|
6
|
+
var u = 250;
|
|
7
|
+
function d({ fieldValue: d, lowestValue: f, highestValue: p, step: m, fieldElement: h, onFieldFocus: g, onFieldBlur: _ }) {
|
|
8
|
+
let v = a(() => r(c(m)));
|
|
9
|
+
function y(e) {
|
|
10
|
+
return e.toFixed(v.value);
|
|
11
|
+
}
|
|
12
|
+
function b(e) {
|
|
13
|
+
return n(e, c(f), c(p));
|
|
14
|
+
}
|
|
15
|
+
let x = s(y(d.value)), S = e((e) => {
|
|
16
|
+
d.value = e;
|
|
17
|
+
}, u);
|
|
18
|
+
l([d, v], ([e]) => {
|
|
19
|
+
h.value !== document.activeElement && (x.value = y(e));
|
|
20
|
+
});
|
|
21
|
+
function C(e) {
|
|
22
|
+
let t = c(f) < 0 ? /[^\d.-]/g : /[^\d.]/g;
|
|
23
|
+
return e.replace(t, "");
|
|
24
|
+
}
|
|
25
|
+
function w(e) {
|
|
26
|
+
let t = e.target, n = C(t.value), r = Number.parseFloat(n || "0");
|
|
27
|
+
if (x.value = n, t.value !== n && (t.value = n), Number.isNaN(r)) return;
|
|
28
|
+
let i = b(r);
|
|
29
|
+
S.callAfterDelay(c(m) >= 1 ? Math.floor(i) : i);
|
|
30
|
+
}
|
|
31
|
+
function T(e) {
|
|
32
|
+
S.cancel();
|
|
33
|
+
let t = Number.parseFloat(x.value) || 0, n = b(c(m) >= 1 ? Math.floor(t) : i(t, v.value));
|
|
34
|
+
n !== d.value && (d.value = n), x.value = y(n), _?.(e);
|
|
35
|
+
}
|
|
36
|
+
function E(e) {
|
|
37
|
+
h.value?.setSelectionRange(0, h.value.value.length), g?.(e);
|
|
38
|
+
}
|
|
39
|
+
function D(e) {
|
|
40
|
+
let t = b(e);
|
|
41
|
+
S.cancel(), d.value = t, x.value = y(t);
|
|
42
|
+
}
|
|
43
|
+
function O(e) {
|
|
44
|
+
D(i(d.value + c(m) * e, v.value));
|
|
45
|
+
}
|
|
46
|
+
function k() {
|
|
47
|
+
h.value?.blur();
|
|
48
|
+
}
|
|
49
|
+
let A = t({
|
|
50
|
+
home: () => D(c(f)),
|
|
51
|
+
end: () => D(c(p)),
|
|
52
|
+
arrowup: () => O(1),
|
|
53
|
+
"shift+arrowup": () => O(10),
|
|
54
|
+
arrowdown: () => O(-1),
|
|
55
|
+
"shift+arrowdown": () => O(-10),
|
|
56
|
+
enter: k,
|
|
57
|
+
escape: k
|
|
58
|
+
});
|
|
59
|
+
return o(S.cancel), {
|
|
60
|
+
valueText: x,
|
|
61
|
+
fieldListeners: {
|
|
62
|
+
input: w,
|
|
63
|
+
focus: E,
|
|
64
|
+
blur: T,
|
|
65
|
+
keydown: A,
|
|
66
|
+
click: (e) => e.stopPropagation()
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export { d as useNumberFieldTyping };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createPointerGraceArea as e, isPointInPolygon as t } from "../utils/pointerGraceArea.js";
|
|
2
|
+
import { computed as n, onMounted as r, shallowRef as i, toValue as a, watch as o } from "vue";
|
|
3
|
+
// src/shared/composables/usePointerGraceArea.ts
|
|
4
|
+
function s(s, c, l) {
|
|
5
|
+
let u = i(), d = n(() => u.value !== void 0);
|
|
6
|
+
function f() {
|
|
7
|
+
u.value = void 0;
|
|
8
|
+
}
|
|
9
|
+
function p(t, n) {
|
|
10
|
+
let r = t.currentTarget;
|
|
11
|
+
r instanceof HTMLElement && (u.value = e({
|
|
12
|
+
x: t.clientX,
|
|
13
|
+
y: t.clientY
|
|
14
|
+
}, r.getBoundingClientRect(), n.getBoundingClientRect()));
|
|
15
|
+
}
|
|
16
|
+
return r(() => {
|
|
17
|
+
o(() => [
|
|
18
|
+
a(l.active),
|
|
19
|
+
a(s),
|
|
20
|
+
a(c)
|
|
21
|
+
], ([e, t, n], r, i) => {
|
|
22
|
+
if (!e || !t || !n) return;
|
|
23
|
+
let a = (e) => p(e, n), o = (e) => p(e, t);
|
|
24
|
+
t.addEventListener("pointerleave", a), n.addEventListener("pointerleave", o), i(() => {
|
|
25
|
+
t.removeEventListener("pointerleave", a), n.removeEventListener("pointerleave", o), f();
|
|
26
|
+
});
|
|
27
|
+
}, { immediate: !0 }), o(u, (e, n, r) => {
|
|
28
|
+
if (!e) return;
|
|
29
|
+
let i = (n) => {
|
|
30
|
+
let r = n.target;
|
|
31
|
+
r instanceof Node && (a(s)?.contains(r) || a(c)?.contains(r)) ? f() : t({
|
|
32
|
+
x: n.clientX,
|
|
33
|
+
y: n.clientY
|
|
34
|
+
}, e) || (f(), l.onPointerLeaveArea());
|
|
35
|
+
};
|
|
36
|
+
document.addEventListener("pointermove", i), r(() => document.removeEventListener("pointermove", i));
|
|
37
|
+
});
|
|
38
|
+
}), { isPointerInTransit: d };
|
|
39
|
+
}
|
|
40
|
+
export { s as usePointerGraceArea };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type MaybeRef, type MaybeRefOrGetter, type Ref } from 'vue';
|
|
2
|
+
import type { TableRowKey, TableRowKeyReader } from '../types/table';
|
|
3
|
+
export type RowSelectionState = 'none' | 'some' | 'all';
|
|
4
|
+
export interface RowSelectionOptions<Row> {
|
|
5
|
+
rowKey?: MaybeRef<TableRowKeyReader<Row> | undefined>;
|
|
6
|
+
isRowSelectable?: (row: Row) => boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Check rows one by one or all at once, keeping their keys in a ref, where "all" covers the given rows only. */
|
|
9
|
+
export declare function useRowSelection<Row, RowKey extends TableRowKey = TableRowKey>(rows: MaybeRefOrGetter<Row[]>, selectedRowKeys: Ref<RowKey[]>, selectionOptions?: RowSelectionOptions<Row>): {
|
|
10
|
+
selectionState: import("vue").ComputedRef<RowSelectionState>;
|
|
11
|
+
selectedRowCount: import("vue").ComputedRef<number>;
|
|
12
|
+
isRowSelected: (row: Row) => boolean;
|
|
13
|
+
isRowSelectable: (row: Row) => boolean;
|
|
14
|
+
toggleRow: (row: Row, shouldSelect?: boolean) => void;
|
|
15
|
+
toggleAllRows: (shouldSelect?: boolean) => void;
|
|
16
|
+
clearSelection: () => void;
|
|
17
|
+
};
|
|
@@ -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,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 {};
|