@toife/vue 3.3.3 → 3.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/action/action.composable.d.ts +44 -0
- package/dist/components/action/action.vue.d.ts +16 -0
- package/dist/components/action/index.d.ts +2 -0
- package/dist/components/app/app.vue.d.ts +11 -0
- package/dist/components/app/index.d.ts +1 -0
- package/dist/components/avatar/avatar.vue.d.ts +8 -0
- package/dist/components/avatar/index.d.ts +1 -0
- package/dist/components/button/button.vue.d.ts +9 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/cable/cable.vue.d.ts +6 -0
- package/dist/components/cable/index.d.ts +1 -0
- package/dist/components/card/card/card.vue.d.ts +7 -0
- package/dist/components/card/card/index.d.ts +1 -0
- package/dist/components/card/card-body/card-body.vue.d.ts +2 -0
- package/dist/components/card/card-body/index.d.ts +1 -0
- package/dist/components/card/card-footer/card-footer.vue.d.ts +2 -0
- package/dist/components/card/card-footer/index.d.ts +1 -0
- package/dist/components/card/card-header/card-header.vue.d.ts +2 -0
- package/dist/components/card/card-header/index.d.ts +1 -0
- package/dist/components/card/index.d.ts +4 -0
- package/dist/components/checkbox/checkbox.vue.d.ts +18 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/collapse/collapse.vue.d.ts +12 -0
- package/dist/components/collapse/index.d.ts +1 -0
- package/dist/components/container/container.vue.d.ts +2 -0
- package/dist/components/container/index.d.ts +1 -0
- package/dist/components/decision-modal/decision-modal.composable.d.ts +48 -0
- package/dist/components/decision-modal/decision-modal.vue.d.ts +17 -0
- package/dist/components/decision-modal/index.d.ts +2 -0
- package/dist/components/divider/divider.vue.d.ts +5 -0
- package/dist/components/divider/index.d.ts +1 -0
- package/dist/components/dropdown/dropdown.vue.d.ts +20 -0
- package/dist/components/dropdown/index.d.ts +1 -0
- package/dist/components/field/field.vue.d.ts +30 -0
- package/dist/components/field/index.d.ts +1 -0
- package/dist/components/form-group/form-group.vue.d.ts +5 -0
- package/dist/components/form-group/index.d.ts +1 -0
- package/dist/components/gesture-indicator/gesture-indicator.vue.d.ts +6 -0
- package/dist/components/gesture-indicator/index.d.ts +1 -0
- package/dist/components/image/image.vue.d.ts +3 -0
- package/dist/components/image/index.d.ts +1 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/layout/flex/flex.vue.d.ts +5 -0
- package/dist/components/layout/flex/index.d.ts +1 -0
- package/dist/components/layout/flex-item/flex-item.vue.d.ts +5 -0
- package/dist/components/layout/flex-item/index.d.ts +1 -0
- package/dist/components/layout/grid/grid.vue.d.ts +5 -0
- package/dist/components/layout/grid/index.d.ts +1 -0
- package/dist/components/layout/grid-item/grid-item.vue.d.ts +5 -0
- package/dist/components/layout/grid-item/index.d.ts +1 -0
- package/dist/components/layout/index.d.ts +4 -0
- package/dist/components/modal/index.d.ts +1 -0
- package/dist/components/modal/modal.vue.d.ts +17 -0
- package/dist/components/page/index.d.ts +1 -0
- package/dist/components/page/page.vue.d.ts +2 -0
- package/dist/components/present/index.d.ts +2 -0
- package/dist/components/present/present.composable.d.ts +5 -0
- package/dist/components/present/present.vue.d.ts +18 -0
- package/dist/components/radio/index.d.ts +2 -0
- package/dist/components/radio/radio/index.d.ts +1 -0
- package/dist/components/radio/radio/radio.vue.d.ts +7 -0
- package/dist/components/radio/radio-group/index.d.ts +1 -0
- package/dist/components/radio/radio-group/radio-group.vue.d.ts +13 -0
- package/dist/components/refresher/index.d.ts +1 -0
- package/dist/components/refresher/refresher.vue.d.ts +12 -0
- package/dist/components/route/index.d.ts +5 -0
- package/dist/components/route/route-navigator/index.d.ts +1 -0
- package/dist/components/route/route-navigator/route-navigator.vue.d.ts +12 -0
- package/dist/components/route/route-outlet/index.d.ts +1 -0
- package/dist/components/route/route-outlet/route-outlet.vue.d.ts +5 -0
- package/dist/components/route/route-provider/index.d.ts +1 -0
- package/dist/components/route/route-provider/route-provider.vue.d.ts +3 -0
- package/dist/components/route/route-wrapper/index.d.ts +2 -0
- package/dist/components/route/route-wrapper/route-wrapper.composable.d.ts +6 -0
- package/dist/components/route/route-wrapper/route-wrapper.vue.d.ts +5 -0
- package/dist/components/route/route.util.d.ts +3 -0
- package/dist/components/segmented-field/index.d.ts +1 -0
- package/dist/components/segmented-field/segmented-field.vue.d.ts +28 -0
- package/dist/components/select/index.d.ts +1 -0
- package/dist/components/select/select.vue.d.ts +19 -0
- package/dist/components/skeleton/index.d.ts +1 -0
- package/dist/components/skeleton/skeleton.vue.d.ts +6 -0
- package/dist/components/slide-range/index.d.ts +1 -0
- package/dist/components/slide-range/slide-range.vue.d.ts +18 -0
- package/dist/components/switch/index.d.ts +1 -0
- package/dist/components/switch/switch.vue.d.ts +13 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/tab/index.d.ts +1 -0
- package/dist/components/tabs/tab/tab.vue.d.ts +5 -0
- package/dist/components/tabs/tabs/index.d.ts +1 -0
- package/dist/components/tabs/tabs/tabs.vue.d.ts +14 -0
- package/dist/components/tag/index.d.ts +1 -0
- package/dist/components/tag/tag.vue.d.ts +6 -0
- package/dist/components/toast/index.d.ts +3 -0
- package/dist/components/toast/toast/index.d.ts +1 -0
- package/dist/components/toast/toast/toast.vue.d.ts +5 -0
- package/dist/components/toast/toast-content/index.d.ts +1 -0
- package/dist/components/toast/toast-content/toast-content.vue.d.ts +11 -0
- package/dist/components/toast/toast.composable.d.ts +22 -0
- package/dist/components/toolbar/index.d.ts +1 -0
- package/dist/components/toolbar/toolbar.vue.d.ts +7 -0
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/tooltip/tooltip.vue.d.ts +7 -0
- package/dist/factory.d.ts +38 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +3611 -0
- package/dist/index.umd.js +1 -0
- package/dist/shared/provider-state.d.ts +5 -0
- package/dist/styles/action.css +1 -0
- package/dist/styles/app.css +1 -0
- package/dist/styles/avatar.css +1 -0
- package/dist/styles/button.css +1 -0
- package/dist/styles/cable.css +1 -0
- package/dist/styles/card-body.css +1 -0
- package/dist/styles/card-footer.css +1 -0
- package/dist/styles/card-header.css +1 -0
- package/dist/styles/card.css +1 -0
- package/dist/styles/checkbox.css +1 -0
- package/dist/styles/collapse.css +1 -0
- package/dist/styles/container.css +1 -0
- package/dist/styles/decision-modal.css +1 -0
- package/dist/styles/divider.css +1 -0
- package/dist/styles/dropdown.css +1 -0
- package/dist/styles/field.css +1 -0
- package/dist/styles/flex-item.css +1 -0
- package/dist/styles/flex.css +1 -0
- package/dist/styles/form-group.css +1 -0
- package/dist/styles/gesture-indicator.css +1 -0
- package/dist/styles/grid-item.css +1 -0
- package/dist/styles/grid.css +1 -0
- package/dist/styles/index.css +41 -0
- package/dist/styles/modal.css +1 -0
- package/dist/styles/page.css +1 -0
- package/dist/styles/present.css +1 -0
- package/dist/styles/radio-group.css +1 -0
- package/dist/styles/radio.css +1 -0
- package/dist/styles/refresher.css +1 -0
- package/dist/styles/route-navigator.css +1 -0
- package/dist/styles/segmented-field.css +1 -0
- package/dist/styles/select.css +1 -0
- package/dist/styles/skeleton.css +1 -0
- package/dist/styles/slide-range.css +1 -0
- package/dist/styles/switch.css +1 -0
- package/dist/styles/tab.css +1 -0
- package/dist/styles/tabs.css +1 -0
- package/dist/styles/tag.css +1 -0
- package/dist/styles/toast-content.css +1 -0
- package/dist/styles/toast.css +1 -0
- package/dist/styles/toolbar.css +1 -0
- package/dist/styles/tooltip.css +1 -0
- package/dist/types.d.ts +4 -0
- package/package.json +22 -26
- package/src/components/action/action.composable.ts +0 -32
- package/src/components/action/action.html +0 -25
- package/src/components/action/action.vue +0 -69
- package/src/components/action/index.ts +0 -2
- package/src/components/app/app.html +0 -24
- package/src/components/app/app.vue +0 -45
- package/src/components/app/index.ts +0 -1
- package/src/components/avatar/avatar.html +0 -3
- package/src/components/avatar/avatar.vue +0 -35
- package/src/components/avatar/index.ts +0 -1
- package/src/components/button/button.html +0 -6
- package/src/components/button/button.vue +0 -54
- package/src/components/button/index.ts +0 -1
- package/src/components/cable/cable.html +0 -3
- package/src/components/cable/cable.vue +0 -33
- package/src/components/cable/index.ts +0 -1
- package/src/components/card/card/card.html +0 -3
- package/src/components/card/card/card.vue +0 -52
- package/src/components/card/card/index.ts +0 -1
- package/src/components/card/card-body/card-body.html +0 -3
- package/src/components/card/card-body/card-body.vue +0 -6
- package/src/components/card/card-body/index.ts +0 -1
- package/src/components/card/card-footer/card-footer.html +0 -3
- package/src/components/card/card-footer/card-footer.vue +0 -18
- package/src/components/card/card-footer/index.ts +0 -1
- package/src/components/card/card-header/card-header.html +0 -3
- package/src/components/card/card-header/card-header.vue +0 -18
- package/src/components/card/card-header/index.ts +0 -1
- package/src/components/card/index.ts +0 -4
- package/src/components/checkbox/checkbox.html +0 -12
- package/src/components/checkbox/checkbox.vue +0 -74
- package/src/components/checkbox/index.ts +0 -1
- package/src/components/collapse/collapse.html +0 -16
- package/src/components/collapse/collapse.vue +0 -126
- package/src/components/collapse/index.ts +0 -1
- package/src/components/container/container.html +0 -1
- package/src/components/container/container.vue +0 -7
- package/src/components/container/index.ts +0 -1
- package/src/components/decision-modal/decision-modal.composable.ts +0 -33
- package/src/components/decision-modal/decision-modal.html +0 -29
- package/src/components/decision-modal/decision-modal.vue +0 -76
- package/src/components/decision-modal/index.ts +0 -2
- package/src/components/divider/divider.html +0 -1
- package/src/components/divider/divider.vue +0 -26
- package/src/components/divider/index.ts +0 -1
- package/src/components/dropdown/dropdown.html +0 -6
- package/src/components/dropdown/dropdown.vue +0 -101
- package/src/components/dropdown/index.ts +0 -1
- package/src/components/field/field.html +0 -30
- package/src/components/field/field.vue +0 -121
- package/src/components/field/index.ts +0 -1
- package/src/components/form-group/form-group.html +0 -3
- package/src/components/form-group/form-group.vue +0 -15
- package/src/components/form-group/index.ts +0 -1
- package/src/components/gesture-indicator/gesture-indicator.html +0 -1
- package/src/components/gesture-indicator/gesture-indicator.vue +0 -32
- package/src/components/gesture-indicator/index.ts +0 -1
- package/src/components/image/image.html +0 -1
- package/src/components/image/image.vue +0 -32
- package/src/components/image/index.ts +0 -1
- package/src/components/index.ts +0 -33
- package/src/components/layout/flex/flex.html +0 -1
- package/src/components/layout/flex/flex.vue +0 -15
- package/src/components/layout/flex/index.ts +0 -1
- package/src/components/layout/flex-item/flex-item.html +0 -1
- package/src/components/layout/flex-item/flex-item.vue +0 -11
- package/src/components/layout/flex-item/index.ts +0 -1
- package/src/components/layout/grid/grid.html +0 -1
- package/src/components/layout/grid/grid.vue +0 -15
- package/src/components/layout/grid/index.ts +0 -1
- package/src/components/layout/grid-item/grid-item.html +0 -1
- package/src/components/layout/grid-item/grid-item.vue +0 -11
- package/src/components/layout/grid-item/index.ts +0 -1
- package/src/components/layout/index.ts +0 -4
- package/src/components/modal/index.ts +0 -1
- package/src/components/modal/modal.html +0 -21
- package/src/components/modal/modal.vue +0 -248
- package/src/components/page/index.ts +0 -1
- package/src/components/page/page.html +0 -3
- package/src/components/page/page.vue +0 -7
- package/src/components/present/index.ts +0 -2
- package/src/components/present/present.composable.ts +0 -22
- package/src/components/present/present.html +0 -11
- package/src/components/present/present.vue +0 -234
- package/src/components/radio/index.ts +0 -2
- package/src/components/radio/radio/index.ts +0 -1
- package/src/components/radio/radio/radio.html +0 -11
- package/src/components/radio/radio/radio.vue +0 -86
- package/src/components/radio/radio-group/index.ts +0 -1
- package/src/components/radio/radio-group/radio-group.html +0 -3
- package/src/components/radio/radio-group/radio-group.vue +0 -64
- package/src/components/refresher/index.ts +0 -1
- package/src/components/refresher/refresher.html +0 -3
- package/src/components/refresher/refresher.vue +0 -100
- package/src/components/route/index.ts +0 -5
- package/src/components/route/route-navigator/index.ts +0 -1
- package/src/components/route/route-navigator/route-navigator.html +0 -19
- package/src/components/route/route-navigator/route-navigator.vue +0 -254
- package/src/components/route/route-outlet/index.ts +0 -1
- package/src/components/route/route-outlet/route-outlet.html +0 -1
- package/src/components/route/route-outlet/route-outlet.vue +0 -39
- package/src/components/route/route-provider/index.ts +0 -1
- package/src/components/route/route-provider/route-provider.html +0 -1
- package/src/components/route/route-provider/route-provider.vue +0 -24
- package/src/components/route/route-wrapper/index.ts +0 -2
- package/src/components/route/route-wrapper/route-wrapper.composable.ts +0 -49
- package/src/components/route/route-wrapper/route-wrapper.html +0 -3
- package/src/components/route/route-wrapper/route-wrapper.vue +0 -44
- package/src/components/route/route.util.ts +0 -9
- package/src/components/segmented-field/index.ts +0 -1
- package/src/components/segmented-field/segmented-field.html +0 -16
- package/src/components/segmented-field/segmented-field.vue +0 -243
- package/src/components/select/index.ts +0 -1
- package/src/components/select/select.html +0 -28
- package/src/components/select/select.vue +0 -101
- package/src/components/skeleton/index.ts +0 -1
- package/src/components/skeleton/skeleton.html +0 -1
- package/src/components/skeleton/skeleton.vue +0 -33
- package/src/components/slide-range/index.ts +0 -1
- package/src/components/slide-range/slide-range.html +0 -20
- package/src/components/slide-range/slide-range.vue +0 -269
- package/src/components/switch/index.ts +0 -1
- package/src/components/switch/switch.html +0 -14
- package/src/components/switch/switch.vue +0 -86
- package/src/components/tabs/index.ts +0 -2
- package/src/components/tabs/tab/index.ts +0 -1
- package/src/components/tabs/tab/tab.html +0 -5
- package/src/components/tabs/tab/tab.vue +0 -34
- package/src/components/tabs/tabs/index.ts +0 -1
- package/src/components/tabs/tabs/tabs.html +0 -3
- package/src/components/tabs/tabs/tabs.vue +0 -151
- package/src/components/tag/index.ts +0 -1
- package/src/components/tag/tag.html +0 -1
- package/src/components/tag/tag.vue +0 -33
- package/src/components/toast/index.ts +0 -3
- package/src/components/toast/toast/index.ts +0 -1
- package/src/components/toast/toast/toast.html +0 -9
- package/src/components/toast/toast/toast.vue +0 -28
- package/src/components/toast/toast-content/index.ts +0 -1
- package/src/components/toast/toast-content/toast-content.html +0 -1
- package/src/components/toast/toast-content/toast-content.vue +0 -51
- package/src/components/toast/toast.composable.ts +0 -22
- package/src/components/toolbar/index.ts +0 -1
- package/src/components/toolbar/toolbar.html +0 -3
- package/src/components/toolbar/toolbar.vue +0 -39
- package/src/components/tooltip/index.ts +0 -1
- package/src/components/tooltip/tooltip.html +0 -15
- package/src/components/tooltip/tooltip.vue +0 -63
- package/src/env.d.ts +0 -7
- package/src/factory.ts +0 -164
- package/src/index.ts +0 -4
- package/src/shared/provider-state.ts +0 -8
- package/src/types.ts +0 -4
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
<style lang="scss" src="@toife/core/features/slide-range/slide-range.scss" scoped></style>
|
|
2
|
-
<template src="./slide-range.html"></template>
|
|
3
|
-
<script lang="ts" setup>
|
|
4
|
-
import { gesture } from "@toife/gesture";
|
|
5
|
-
import { computed, inject, onMounted, onUnmounted, ref, unref } from "vue";
|
|
6
|
-
import {
|
|
7
|
-
SLIDE_RANGE_DEFAULT_PROPS,
|
|
8
|
-
APP_PROVIDER_STATE_KEY,
|
|
9
|
-
getSlideRangeAttrs,
|
|
10
|
-
getSlideRangeTickAttrs,
|
|
11
|
-
getSlideRangeThumbAttrs,
|
|
12
|
-
getSlideRangeThumbInnerAttrs,
|
|
13
|
-
getSlideRangeTooltipAttrs,
|
|
14
|
-
getSlideRangeTrackBackAttrs,
|
|
15
|
-
getSlideRangeTrackBodyAttrs,
|
|
16
|
-
getSlideRangeTrackContainerAttrs,
|
|
17
|
-
getSlideRangeTrackFrontAttrs,
|
|
18
|
-
type AppProviderState,
|
|
19
|
-
type SlideRangeEvent,
|
|
20
|
-
type SlideRangeProps,
|
|
21
|
-
type SlideRangeValue,
|
|
22
|
-
} from "@toife/core";
|
|
23
|
-
import type { ProviderStateRefs } from "../../shared/provider-state";
|
|
24
|
-
|
|
25
|
-
// Component setup (props, emits, injects)
|
|
26
|
-
// ----------------------------------------------------------------------------
|
|
27
|
-
const props = withDefaults(defineProps<SlideRangeProps>(), {
|
|
28
|
-
...SLIDE_RANGE_DEFAULT_PROPS,
|
|
29
|
-
});
|
|
30
|
-
const emit = defineEmits<SlideRangeEvent>();
|
|
31
|
-
const appState = inject<ProviderStateRefs<AppProviderState>>(APP_PROVIDER_STATE_KEY);
|
|
32
|
-
|
|
33
|
-
// Reactive state
|
|
34
|
-
// ----------------------------------------------------------------------------
|
|
35
|
-
const point = ref<HTMLElement | null>(null);
|
|
36
|
-
const container = ref<HTMLElement | null>(null);
|
|
37
|
-
const isShowTooltip = ref(false);
|
|
38
|
-
let tooltipTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
39
|
-
let gestureCleanup: { destroy: () => void } | null = null;
|
|
40
|
-
let dragStartPercent = 0;
|
|
41
|
-
let isHorizontalDrag = false;
|
|
42
|
-
|
|
43
|
-
const suppressPointerEvent = (ev?: Event) => {
|
|
44
|
-
if (!ev) return;
|
|
45
|
-
ev.stopPropagation();
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const isHorizontalDirection = (direction?: string) => direction === "left" || direction === "right";
|
|
49
|
-
|
|
50
|
-
const parseRangeValue = (value: SlideRangeValue | undefined, fallback: number): number => {
|
|
51
|
-
if (typeof value === "number") return value;
|
|
52
|
-
if (typeof value === "string") {
|
|
53
|
-
const parsed = Number.parseFloat(value);
|
|
54
|
-
return Number.isNaN(parsed) ? fallback : parsed;
|
|
55
|
-
}
|
|
56
|
-
return fallback;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// Computed properties
|
|
60
|
-
// ----------------------------------------------------------------------------
|
|
61
|
-
const rangeMin = computed(() => parseRangeValue(props.min, 0));
|
|
62
|
-
const rangeMax = computed(() => parseRangeValue(props.max, 100));
|
|
63
|
-
const rangeStep = computed(() => {
|
|
64
|
-
const step = parseRangeValue(props.step, 1);
|
|
65
|
-
return step > 0 ? step : 1;
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const snapToStep = (rawValue: number) => {
|
|
69
|
-
const min = rangeMin.value;
|
|
70
|
-
const max = rangeMax.value;
|
|
71
|
-
const stepSize = rangeStep.value;
|
|
72
|
-
if (max <= min) return min;
|
|
73
|
-
const clamped = Math.max(min, Math.min(max, rawValue));
|
|
74
|
-
const stepIndex = Math.round((clamped - min) / stepSize);
|
|
75
|
-
return Math.max(min, Math.min(max, min + stepIndex * stepSize));
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const normalizedValue = computed(() => {
|
|
79
|
-
const value = parseRangeValue(props.modelValue, rangeMin.value);
|
|
80
|
-
return snapToStep(value);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const percent = computed(() => getPercentFromValue(normalizedValue.value));
|
|
84
|
-
|
|
85
|
-
const ticks = computed(() => {
|
|
86
|
-
if (props.tick === false) return [];
|
|
87
|
-
const min = rangeMin.value;
|
|
88
|
-
const max = rangeMax.value;
|
|
89
|
-
const tickStep = props.tick === true ? 1 : parseRangeValue(props.tick, 0);
|
|
90
|
-
if (tickStep <= 0 || max < min) return [min, max];
|
|
91
|
-
|
|
92
|
-
const result: number[] = [];
|
|
93
|
-
for (let value = min; value <= max; value += tickStep) {
|
|
94
|
-
result.push(value);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (result.at(-1) !== max) {
|
|
98
|
-
result.push(max);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return result;
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const displayValue = computed(() => {
|
|
105
|
-
const value = getValueFromPercent(percent.value);
|
|
106
|
-
return `${value}${props.unit || ""}`;
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
const slideRangeAttrs = computed(() => {
|
|
110
|
-
const role = props.role || unref(appState?.role) || "";
|
|
111
|
-
const shape = props.shape || unref(appState?.shape) || "";
|
|
112
|
-
return getSlideRangeAttrs({
|
|
113
|
-
role,
|
|
114
|
-
shape,
|
|
115
|
-
disabled: props.disabled,
|
|
116
|
-
readonly: props.readonly,
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const trackContainerAttrs = getSlideRangeTrackContainerAttrs();
|
|
121
|
-
const trackBodyAttrs = getSlideRangeTrackBodyAttrs();
|
|
122
|
-
const trackBackAttrs = getSlideRangeTrackBackAttrs();
|
|
123
|
-
const trackFrontAttrs = computed(() => getSlideRangeTrackFrontAttrs({ percent: percent.value }));
|
|
124
|
-
const thumbAttrs = computed(() => getSlideRangeThumbAttrs({ percent: percent.value }));
|
|
125
|
-
const thumbInnerAttrs = getSlideRangeThumbInnerAttrs();
|
|
126
|
-
const tooltipAttrs = getSlideRangeTooltipAttrs();
|
|
127
|
-
|
|
128
|
-
// Methods
|
|
129
|
-
// ----------------------------------------------------------------------------
|
|
130
|
-
const tickAttrs = (value: number) => {
|
|
131
|
-
const tickPercent = getPercentFromValue(value);
|
|
132
|
-
return getSlideRangeTickAttrs({
|
|
133
|
-
active: percent.value > tickPercent,
|
|
134
|
-
percent: tickPercent,
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const getValueFromPercent = (currentPercent: number) => {
|
|
139
|
-
const min = rangeMin.value;
|
|
140
|
-
const max = rangeMax.value;
|
|
141
|
-
const raw = min + (max - min) * (currentPercent / 100);
|
|
142
|
-
return snapToStep(raw);
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const getPercentFromValue = (value: number) => {
|
|
146
|
-
const min = rangeMin.value;
|
|
147
|
-
const max = rangeMax.value;
|
|
148
|
-
if (max <= min) return 0;
|
|
149
|
-
const p = ((value - min) / (max - min)) * 100;
|
|
150
|
-
return Math.max(0, Math.min(100, p));
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const showTooltipTemporarily = () => {
|
|
154
|
-
if (tooltipTimeout) clearTimeout(tooltipTimeout);
|
|
155
|
-
isShowTooltip.value = true;
|
|
156
|
-
tooltipTimeout = setTimeout(() => {
|
|
157
|
-
isShowTooltip.value = false;
|
|
158
|
-
}, 300);
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const emitValueFromPercent = (currentPercent: number) => {
|
|
162
|
-
if (props.disabled || props.readonly) return;
|
|
163
|
-
const value = getValueFromPercent(currentPercent);
|
|
164
|
-
|
|
165
|
-
if (value !== props.modelValue) {
|
|
166
|
-
emit("update:modelValue", value);
|
|
167
|
-
emit("change", value);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const onTickSelect = (value: number, ev?: Event) => {
|
|
172
|
-
suppressPointerEvent(ev);
|
|
173
|
-
const tickPercent = getPercentFromValue(value);
|
|
174
|
-
emitValueFromPercent(tickPercent);
|
|
175
|
-
showTooltipTemporarily();
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
const onTrackPointerDown = (ev: Event) => {
|
|
179
|
-
if (props.disabled || props.readonly) return;
|
|
180
|
-
suppressPointerEvent(ev);
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
const onThumbPointerDown = (ev: Event) => {
|
|
184
|
-
if (props.disabled || props.readonly) return;
|
|
185
|
-
suppressPointerEvent(ev);
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const getClientX = (ev: MouseEvent | TouchEvent) => {
|
|
189
|
-
if ("changedTouches" in ev && ev.changedTouches.length > 0) {
|
|
190
|
-
return ev.changedTouches[0].clientX;
|
|
191
|
-
}
|
|
192
|
-
return (ev as MouseEvent).clientX;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
const onClickPath = (ev: MouseEvent | TouchEvent) => {
|
|
196
|
-
if (props.disabled || props.readonly || !container.value) return;
|
|
197
|
-
suppressPointerEvent(ev);
|
|
198
|
-
const width = container.value.offsetWidth;
|
|
199
|
-
const rect = container.value.getBoundingClientRect();
|
|
200
|
-
const x = getClientX(ev) - rect.left;
|
|
201
|
-
const p = (x / width) * 100;
|
|
202
|
-
emitValueFromPercent(Math.max(0, Math.min(100, p)));
|
|
203
|
-
showTooltipTemporarily();
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
// Lifecycle
|
|
207
|
-
// ----------------------------------------------------------------------------
|
|
208
|
-
onMounted(() => {
|
|
209
|
-
if (!point.value || !container.value) return;
|
|
210
|
-
gestureCleanup = gesture(
|
|
211
|
-
point.value,
|
|
212
|
-
{
|
|
213
|
-
options: { trackOutsideElement: true },
|
|
214
|
-
beforeEvent(ev: Event) {
|
|
215
|
-
if (props.disabled || props.readonly) return false;
|
|
216
|
-
return true;
|
|
217
|
-
},
|
|
218
|
-
afterEvent(ev?: Event) {
|
|
219
|
-
if (isHorizontalDrag) suppressPointerEvent(ev);
|
|
220
|
-
},
|
|
221
|
-
down({ event }: { event?: Event }) {
|
|
222
|
-
if (props.disabled || props.readonly) return;
|
|
223
|
-
dragStartPercent = percent.value;
|
|
224
|
-
isHorizontalDrag = false;
|
|
225
|
-
suppressPointerEvent(event);
|
|
226
|
-
},
|
|
227
|
-
up({ event }: { event?: Event }) {
|
|
228
|
-
isHorizontalDrag = false;
|
|
229
|
-
isShowTooltip.value = false;
|
|
230
|
-
suppressPointerEvent(event);
|
|
231
|
-
},
|
|
232
|
-
cancel(event?: Event) {
|
|
233
|
-
isHorizontalDrag = false;
|
|
234
|
-
isShowTooltip.value = false;
|
|
235
|
-
suppressPointerEvent(event);
|
|
236
|
-
},
|
|
237
|
-
move({
|
|
238
|
-
initialDirection,
|
|
239
|
-
deltaX,
|
|
240
|
-
event,
|
|
241
|
-
}: {
|
|
242
|
-
initialDirection?: string;
|
|
243
|
-
deltaX: number;
|
|
244
|
-
event?: Event;
|
|
245
|
-
}) {
|
|
246
|
-
if (props.disabled || props.readonly) return;
|
|
247
|
-
if (!isHorizontalDirection(initialDirection)) return;
|
|
248
|
-
if (!container.value) return;
|
|
249
|
-
|
|
250
|
-
isHorizontalDrag = true;
|
|
251
|
-
suppressPointerEvent(event);
|
|
252
|
-
|
|
253
|
-
const width = container.value.offsetWidth;
|
|
254
|
-
const p = (deltaX / width) * 100;
|
|
255
|
-
const nextPercent = Math.max(0, Math.min(100, dragStartPercent + p));
|
|
256
|
-
emitValueFromPercent(nextPercent);
|
|
257
|
-
if (tooltipTimeout) clearTimeout(tooltipTimeout);
|
|
258
|
-
isShowTooltip.value = true;
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
{ passive: false, capture: true }
|
|
262
|
-
);
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
onUnmounted(() => {
|
|
266
|
-
if (tooltipTimeout) clearTimeout(tooltipTimeout);
|
|
267
|
-
gestureCleanup?.destroy();
|
|
268
|
-
});
|
|
269
|
-
</script>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Switch } from "./switch.vue";
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<div
|
|
2
|
-
v-bind="switchWrapperAttrs"
|
|
3
|
-
:tabindex="disabled ? -1 : 0"
|
|
4
|
-
:aria-checked="props.modelValue"
|
|
5
|
-
@pointerup="onSwitch"
|
|
6
|
-
@focus="onFocus"
|
|
7
|
-
@blur="onBlur"
|
|
8
|
-
@keydown="onKeydown"
|
|
9
|
-
>
|
|
10
|
-
<div v-bind="switchAttrs">
|
|
11
|
-
<div v-bind="switchIconAttrs"></div>
|
|
12
|
-
</div>
|
|
13
|
-
<slot />
|
|
14
|
-
</div>
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
<style lang="scss" src="@toife/core/features/switch/switch.scss" scoped></style>
|
|
2
|
-
<template src="./switch.html"></template>
|
|
3
|
-
<script lang="ts" setup>
|
|
4
|
-
import { unref, computed, inject, ref, onMounted } from "vue";
|
|
5
|
-
import {
|
|
6
|
-
SWITCH_DEFAULT_PROPS,
|
|
7
|
-
APP_PROVIDER_STATE_KEY,
|
|
8
|
-
getSwitchAttrs,
|
|
9
|
-
getSwitchIconAttrs,
|
|
10
|
-
getSwitchWrapperAttrs,
|
|
11
|
-
type AppProviderState,
|
|
12
|
-
type SwitchEvent,
|
|
13
|
-
type SwitchProps,
|
|
14
|
-
} from "@toife/core";
|
|
15
|
-
import type { ProviderStateRefs } from "../../shared/provider-state";
|
|
16
|
-
|
|
17
|
-
// Component setup (props, emits, injects)
|
|
18
|
-
// ----------------------------------------------------------------------------
|
|
19
|
-
const props = withDefaults(defineProps<SwitchProps>(), {
|
|
20
|
-
...SWITCH_DEFAULT_PROPS,
|
|
21
|
-
});
|
|
22
|
-
const emit = defineEmits<SwitchEvent>();
|
|
23
|
-
const appState = inject<ProviderStateRefs<AppProviderState>>(APP_PROVIDER_STATE_KEY);
|
|
24
|
-
|
|
25
|
-
// Reactive state
|
|
26
|
-
// ----------------------------------------------------------------------------
|
|
27
|
-
const isFocused = ref(false);
|
|
28
|
-
const isFirstRender = ref(true);
|
|
29
|
-
|
|
30
|
-
// Computed properties
|
|
31
|
-
// ----------------------------------------------------------------------------
|
|
32
|
-
const switchWrapperAttrs = computed(() => {
|
|
33
|
-
const shadow = (props?.shadow !== undefined ? props.shadow : unref(appState?.shadow)) ?? false;
|
|
34
|
-
return getSwitchWrapperAttrs({
|
|
35
|
-
disabled: props.disabled,
|
|
36
|
-
readonly: props.readonly,
|
|
37
|
-
shadow: shadow && !props.disabled && isFocused.value,
|
|
38
|
-
focus: isFocused.value,
|
|
39
|
-
modelValue: props.modelValue,
|
|
40
|
-
transition: !isFirstRender.value,
|
|
41
|
-
bounce: props.bounce,
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const switchAttrs = computed(() => {
|
|
46
|
-
const shape = props.shape || unref(appState?.shape) || "";
|
|
47
|
-
const baseRole = unref(appState?.role) || "";
|
|
48
|
-
const role = props.role || baseRole;
|
|
49
|
-
return getSwitchAttrs({
|
|
50
|
-
role,
|
|
51
|
-
shape,
|
|
52
|
-
size: props.size,
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const switchIconAttrs = getSwitchIconAttrs();
|
|
57
|
-
|
|
58
|
-
// Methods
|
|
59
|
-
// ----------------------------------------------------------------------------
|
|
60
|
-
const onSwitch = () => {
|
|
61
|
-
if (props.disabled || props.readonly) return;
|
|
62
|
-
emit("update:modelValue", !props.modelValue);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const onFocus = () => {
|
|
66
|
-
if (props.disabled || props.readonly) return;
|
|
67
|
-
isFocused.value = true;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const onBlur = () => {
|
|
71
|
-
if (props.disabled || props.readonly) return;
|
|
72
|
-
isFocused.value = false;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const onKeydown = (e: KeyboardEvent) => {
|
|
76
|
-
if (e.key !== " " && e.key !== "Enter") return;
|
|
77
|
-
e.preventDefault();
|
|
78
|
-
onSwitch();
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
onMounted(() => {
|
|
82
|
-
setTimeout(() => {
|
|
83
|
-
isFirstRender.value = false;
|
|
84
|
-
}, 500);
|
|
85
|
-
});
|
|
86
|
-
</script>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Tab } from "./tab.vue";
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<template src="./tab.html"></template>
|
|
2
|
-
<style lang="scss" src="@toife/core/features/tabs/tab.scss" scoped></style>
|
|
3
|
-
<script lang="ts" setup>
|
|
4
|
-
import { computed, inject, unref } from "vue";
|
|
5
|
-
import {
|
|
6
|
-
TAB_DEFAULT_PROPS,
|
|
7
|
-
TABS_PROVIDER_STATE_KEY,
|
|
8
|
-
getTabAttrs,
|
|
9
|
-
getTabButtonAttrs,
|
|
10
|
-
type TabProps,
|
|
11
|
-
type TabsProviderState,
|
|
12
|
-
} from "@toife/core";
|
|
13
|
-
import type { ProviderStateRefs } from "../../../shared/provider-state";
|
|
14
|
-
// Component setup (props, emits, injects)
|
|
15
|
-
// ----------------------------------------------------------------------------
|
|
16
|
-
const props = withDefaults(defineProps<TabProps>(), {
|
|
17
|
-
...TAB_DEFAULT_PROPS,
|
|
18
|
-
});
|
|
19
|
-
const tabsState = inject<ProviderStateRefs<TabsProviderState>>(TABS_PROVIDER_STATE_KEY);
|
|
20
|
-
|
|
21
|
-
// Computed properties
|
|
22
|
-
// ----------------------------------------------------------------------------
|
|
23
|
-
const shape = computed(() => unref(tabsState?.shape) || "");
|
|
24
|
-
const size = computed(() => unref(tabsState?.size) || "standard");
|
|
25
|
-
const isActive = computed(() => unref(tabsState?.activeValue) === props.value);
|
|
26
|
-
const tabAttrs = computed(() => getTabAttrs({ active: isActive.value }));
|
|
27
|
-
const buttonAttrs = computed(() => getTabButtonAttrs({ shape: shape.value, size: size.value }));
|
|
28
|
-
// Methods
|
|
29
|
-
// ----------------------------------------------------------------------------
|
|
30
|
-
const handleClick = () => {
|
|
31
|
-
if (props.disabled) return;
|
|
32
|
-
tabsState?.setValue(props.value || "");
|
|
33
|
-
};
|
|
34
|
-
</script>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Tabs } from "./tabs.vue";
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
<style lang="scss" src="@toife/core/features/tabs/tabs.scss" scoped></style>
|
|
2
|
-
<template src="./tabs.html"></template>
|
|
3
|
-
<script lang="ts" setup>
|
|
4
|
-
import {
|
|
5
|
-
unref,
|
|
6
|
-
computed,
|
|
7
|
-
inject,
|
|
8
|
-
nextTick,
|
|
9
|
-
onMounted,
|
|
10
|
-
onUnmounted,
|
|
11
|
-
provide,
|
|
12
|
-
ref,
|
|
13
|
-
watch,
|
|
14
|
-
} from "vue";
|
|
15
|
-
import {
|
|
16
|
-
TABS_DEFAULT_PROPS,
|
|
17
|
-
APP_PROVIDER_STATE_KEY,
|
|
18
|
-
TABS_PROVIDER_STATE_KEY,
|
|
19
|
-
getTabsAttrs,
|
|
20
|
-
getTabsHighlightPosition,
|
|
21
|
-
getTabsHighlightStyle,
|
|
22
|
-
type AppProviderState,
|
|
23
|
-
type TabsEvent,
|
|
24
|
-
type TabsProps,
|
|
25
|
-
type TabsProviderState,
|
|
26
|
-
} from "@toife/core";
|
|
27
|
-
import type { ProviderStateRefs } from "../../../shared/provider-state";
|
|
28
|
-
|
|
29
|
-
// Component setup (props, emits, injects)
|
|
30
|
-
// ----------------------------------------------------------------------------
|
|
31
|
-
const props = withDefaults(defineProps<TabsProps>(), {
|
|
32
|
-
...TABS_DEFAULT_PROPS,
|
|
33
|
-
});
|
|
34
|
-
const emit = defineEmits<TabsEvent>();
|
|
35
|
-
const appState = inject<ProviderStateRefs<AppProviderState>>(APP_PROVIDER_STATE_KEY);
|
|
36
|
-
|
|
37
|
-
// Reactive state
|
|
38
|
-
// ----------------------------------------------------------------------------
|
|
39
|
-
const width = ref(0);
|
|
40
|
-
const height = ref(0);
|
|
41
|
-
const top = ref(0);
|
|
42
|
-
const left = ref(0);
|
|
43
|
-
const container = ref();
|
|
44
|
-
const isFirstRender = ref(true);
|
|
45
|
-
|
|
46
|
-
// Computed properties
|
|
47
|
-
// ----------------------------------------------------------------------------
|
|
48
|
-
const role = computed(() => {
|
|
49
|
-
return props.role || unref(appState?.role) || "";
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const shape = computed(() => {
|
|
53
|
-
return props.shape || unref(appState?.shape) || "";
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const size = computed(() => {
|
|
57
|
-
return props.size;
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const activeValue = computed(() => {
|
|
61
|
-
return props.modelValue || "";
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
const tabsAttrs = computed(() => {
|
|
65
|
-
const highlight = getTabsHighlightPosition({
|
|
66
|
-
top: top.value,
|
|
67
|
-
left: left.value,
|
|
68
|
-
width: width.value,
|
|
69
|
-
height: height.value,
|
|
70
|
-
margin: props.margin,
|
|
71
|
-
border: props.border,
|
|
72
|
-
variant: props.variant,
|
|
73
|
-
placement: props.placement,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
...getTabsAttrs({
|
|
78
|
-
role: role.value,
|
|
79
|
-
shape: shape.value,
|
|
80
|
-
placement: props.placement,
|
|
81
|
-
variant: props.variant,
|
|
82
|
-
transition: isFirstRender.value ? false : props.transition,
|
|
83
|
-
}),
|
|
84
|
-
style: getTabsHighlightStyle({
|
|
85
|
-
top: highlight.top,
|
|
86
|
-
left: highlight.left,
|
|
87
|
-
width: highlight.width,
|
|
88
|
-
height: highlight.height,
|
|
89
|
-
marginX: props.margin[1],
|
|
90
|
-
marginY: props.margin[0],
|
|
91
|
-
}),
|
|
92
|
-
};
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// Methods
|
|
96
|
-
// ----------------------------------------------------------------------------
|
|
97
|
-
const calcPosition = () => {
|
|
98
|
-
let active = container.value.querySelector(".active");
|
|
99
|
-
if (active) {
|
|
100
|
-
width.value = active.offsetWidth;
|
|
101
|
-
height.value = active.offsetHeight;
|
|
102
|
-
left.value =
|
|
103
|
-
active.getBoundingClientRect().left -
|
|
104
|
-
container.value.getBoundingClientRect().left +
|
|
105
|
-
container.value.scrollLeft;
|
|
106
|
-
top.value =
|
|
107
|
-
active.getBoundingClientRect().top -
|
|
108
|
-
container.value.getBoundingClientRect().top +
|
|
109
|
-
container.value.scrollTop;
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const checkRender = async () => {
|
|
114
|
-
await nextTick();
|
|
115
|
-
calcPosition();
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// Lifecycle
|
|
119
|
-
// ----------------------------------------------------------------------------
|
|
120
|
-
watch(
|
|
121
|
-
() => props.modelValue,
|
|
122
|
-
() => {
|
|
123
|
-
checkRender();
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
onMounted(() => {
|
|
128
|
-
checkRender();
|
|
129
|
-
window.addEventListener("resize", calcPosition);
|
|
130
|
-
|
|
131
|
-
setTimeout(() => {
|
|
132
|
-
isFirstRender.value = false;
|
|
133
|
-
}, 500);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
onUnmounted(() => {
|
|
137
|
-
window.removeEventListener("resize", calcPosition);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// Provide / expose (public API)
|
|
141
|
-
// ----------------------------------------------------------------------------
|
|
142
|
-
provide<ProviderStateRefs<TabsProviderState>>(TABS_PROVIDER_STATE_KEY, {
|
|
143
|
-
activeValue,
|
|
144
|
-
role,
|
|
145
|
-
shape,
|
|
146
|
-
size,
|
|
147
|
-
setValue: (val: unknown) => {
|
|
148
|
-
emit("update:modelValue", val as string);
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
</script>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Tag } from "./tag.vue";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<span v-bind="tagAttrs"><slot></slot></span>
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<style lang="scss" src="@toife/core/features/tag/tag.scss" scoped></style>
|
|
2
|
-
<template src="./tag.html"></template>
|
|
3
|
-
<script lang="ts" setup>
|
|
4
|
-
import { unref, computed, inject } from "vue";
|
|
5
|
-
import {
|
|
6
|
-
TAG_DEFAULT_PROPS,
|
|
7
|
-
APP_PROVIDER_STATE_KEY,
|
|
8
|
-
getTagAttrs,
|
|
9
|
-
type AppProviderState,
|
|
10
|
-
type TagProps,
|
|
11
|
-
} from "@toife/core";
|
|
12
|
-
import type { ProviderStateRefs } from "../../shared/provider-state";
|
|
13
|
-
// Component setup (props, emits, injects)
|
|
14
|
-
// ----------------------------------------------------------------------------
|
|
15
|
-
const props = withDefaults(defineProps<TagProps>(), {
|
|
16
|
-
...TAG_DEFAULT_PROPS,
|
|
17
|
-
});
|
|
18
|
-
const appState = inject<ProviderStateRefs<AppProviderState>>(APP_PROVIDER_STATE_KEY);
|
|
19
|
-
|
|
20
|
-
// Computed properties
|
|
21
|
-
// ----------------------------------------------------------------------------
|
|
22
|
-
const tagAttrs = computed(() => {
|
|
23
|
-
const shape = props.shape || unref(appState?.shape) || "";
|
|
24
|
-
const role = props.role || unref(appState?.role) || "";
|
|
25
|
-
|
|
26
|
-
return getTagAttrs({
|
|
27
|
-
role,
|
|
28
|
-
shape,
|
|
29
|
-
size: props.size,
|
|
30
|
-
variant: props.variant,
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
</script>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Toast } from "./toast.vue";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<style lang="scss" src="@toife/core/features/toast/toast.scss" scoped></style>
|
|
2
|
-
<template src="./toast.html"></template>
|
|
3
|
-
<script lang="ts" setup>
|
|
4
|
-
import { computed } from "vue";
|
|
5
|
-
import { useToast } from "../toast.composable";
|
|
6
|
-
import { ToastContent } from "../toast-content";
|
|
7
|
-
import { TOAST_DEFAULT_PROPS, getToastAttrs, type ToastProps } from "@toife/core";
|
|
8
|
-
// Component setup (props, emits, injects)
|
|
9
|
-
// ----------------------------------------------------------------------------
|
|
10
|
-
const props = withDefaults(defineProps<ToastProps>(), {
|
|
11
|
-
...TOAST_DEFAULT_PROPS,
|
|
12
|
-
});
|
|
13
|
-
const toast = useToast();
|
|
14
|
-
|
|
15
|
-
// Computed properties
|
|
16
|
-
// ----------------------------------------------------------------------------
|
|
17
|
-
const toastAttrs = computed(() => getToastAttrs({ placement: props.placement }));
|
|
18
|
-
|
|
19
|
-
const toastMessages = computed(() => {
|
|
20
|
-
return toast.messages.value.filter((item) => item.placement == props.placement);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Methods
|
|
24
|
-
// ----------------------------------------------------------------------------
|
|
25
|
-
const dismiss = (id: number) => {
|
|
26
|
-
toast.close(id);
|
|
27
|
-
};
|
|
28
|
-
</script>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as ToastContent } from "./toast-content.vue";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<div v-bind="contentAttrs">{{ props.message }}</div>
|