@toife/vue 3.2.6 → 3.2.7
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/package.json +19 -20
- package/src/components/action/action.composable.ts +32 -0
- package/src/components/action/action.html +25 -0
- package/src/components/action/action.vue +69 -0
- package/src/components/action/index.ts +2 -0
- package/src/components/app/app.html +24 -0
- package/src/components/app/app.vue +45 -0
- package/src/components/app/index.ts +1 -0
- package/src/components/avatar/avatar.html +3 -0
- package/src/components/avatar/avatar.vue +35 -0
- package/src/components/avatar/index.ts +1 -0
- package/src/components/button/button.html +6 -0
- package/src/components/button/button.vue +54 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/cable/cable.html +3 -0
- package/src/components/cable/cable.vue +33 -0
- package/src/components/cable/index.ts +1 -0
- package/src/components/card/card/card.html +3 -0
- package/src/components/card/card/card.vue +52 -0
- package/src/components/card/card/index.ts +1 -0
- package/src/components/card/card-body/card-body.html +3 -0
- package/src/components/card/card-body/card-body.vue +6 -0
- package/src/components/card/card-body/index.ts +1 -0
- package/src/components/card/card-footer/card-footer.html +3 -0
- package/src/components/card/card-footer/card-footer.vue +18 -0
- package/src/components/card/card-footer/index.ts +1 -0
- package/src/components/card/card-header/card-header.html +3 -0
- package/src/components/card/card-header/card-header.vue +18 -0
- package/src/components/card/card-header/index.ts +1 -0
- package/src/components/card/index.ts +4 -0
- package/src/components/checkbox/checkbox.html +12 -0
- package/src/components/checkbox/checkbox.vue +74 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/collapse/collapse.html +16 -0
- package/src/components/collapse/collapse.vue +126 -0
- package/src/components/collapse/index.ts +1 -0
- package/src/components/container/container.html +1 -0
- package/src/components/container/container.vue +7 -0
- package/src/components/container/index.ts +1 -0
- package/src/components/decision-modal/decision-modal.composable.ts +33 -0
- package/src/components/decision-modal/decision-modal.html +29 -0
- package/src/components/decision-modal/decision-modal.vue +76 -0
- package/src/components/decision-modal/index.ts +2 -0
- package/src/components/divider/divider.html +1 -0
- package/src/components/divider/divider.vue +26 -0
- package/src/components/divider/index.ts +1 -0
- package/src/components/dropdown/dropdown.html +6 -0
- package/src/components/dropdown/dropdown.vue +101 -0
- package/src/components/dropdown/index.ts +1 -0
- package/src/components/field/field.html +30 -0
- package/src/components/field/field.vue +121 -0
- package/src/components/field/index.ts +1 -0
- package/src/components/form-group/form-group.html +3 -0
- package/src/components/form-group/form-group.vue +15 -0
- package/src/components/form-group/index.ts +1 -0
- package/src/components/gesture-indicator/gesture-indicator.html +1 -0
- package/src/components/gesture-indicator/gesture-indicator.vue +32 -0
- package/src/components/gesture-indicator/index.ts +1 -0
- package/src/components/image/image.html +1 -0
- package/src/components/image/image.vue +32 -0
- package/src/components/image/index.ts +1 -0
- package/src/components/index.ts +32 -0
- package/src/components/layout/flex/flex.html +1 -0
- package/src/components/layout/flex/flex.vue +15 -0
- package/src/components/layout/flex/index.ts +1 -0
- package/src/components/layout/flex-item/flex-item.html +1 -0
- package/src/components/layout/flex-item/flex-item.vue +11 -0
- package/src/components/layout/flex-item/index.ts +1 -0
- package/src/components/layout/grid/grid.html +1 -0
- package/src/components/layout/grid/grid.vue +15 -0
- package/src/components/layout/grid/index.ts +1 -0
- package/src/components/layout/grid-item/grid-item.html +1 -0
- package/src/components/layout/grid-item/grid-item.vue +11 -0
- package/src/components/layout/grid-item/index.ts +1 -0
- package/src/components/layout/index.ts +4 -0
- package/src/components/modal/index.ts +1 -0
- package/src/components/modal/modal.html +20 -0
- package/src/components/modal/modal.vue +248 -0
- package/src/components/page/index.ts +1 -0
- package/src/components/page/page.html +3 -0
- package/src/components/page/page.vue +7 -0
- package/src/components/present/index.ts +2 -0
- package/src/components/present/present.composable.ts +22 -0
- package/src/components/present/present.html +11 -0
- package/src/components/present/present.vue +234 -0
- package/src/components/radio/index.ts +2 -0
- package/src/components/radio/radio/index.ts +1 -0
- package/src/components/radio/radio/radio.html +11 -0
- package/src/components/radio/radio/radio.vue +84 -0
- package/src/components/radio/radio-group/index.ts +1 -0
- package/src/components/radio/radio-group/radio-group.html +3 -0
- package/src/components/radio/radio-group/radio-group.vue +59 -0
- package/src/components/refresher/index.ts +1 -0
- package/src/components/refresher/refresher.html +3 -0
- package/src/components/refresher/refresher.vue +100 -0
- package/src/components/route/index.ts +5 -0
- package/src/components/route/route-navigator/index.ts +1 -0
- package/src/components/route/route-navigator/route-navigator.html +19 -0
- package/src/components/route/route-navigator/route-navigator.vue +254 -0
- package/src/components/route/route-outlet/index.ts +1 -0
- package/src/components/route/route-outlet/route-outlet.html +1 -0
- package/src/components/route/route-outlet/route-outlet.vue +39 -0
- package/src/components/route/route-provider/index.ts +1 -0
- package/src/components/route/route-provider/route-provider.html +1 -0
- package/src/components/route/route-provider/route-provider.vue +24 -0
- package/src/components/route/route-wrapper/index.ts +2 -0
- package/src/components/route/route-wrapper/route-wrapper.composable.ts +49 -0
- package/src/components/route/route-wrapper/route-wrapper.html +3 -0
- package/src/components/route/route-wrapper/route-wrapper.vue +44 -0
- package/src/components/route/route.util.ts +9 -0
- package/src/components/segmented-field/index.ts +1 -0
- package/src/components/segmented-field/segmented-field.html +16 -0
- package/src/components/segmented-field/segmented-field.vue +243 -0
- package/src/components/select/index.ts +1 -0
- package/src/components/select/select.html +28 -0
- package/src/components/select/select.vue +101 -0
- package/src/components/skeleton/index.ts +1 -0
- package/src/components/skeleton/skeleton.html +1 -0
- package/src/components/skeleton/skeleton.vue +33 -0
- package/src/components/slide-range/index.ts +1 -0
- package/src/components/slide-range/slide-range.html +20 -0
- package/src/components/slide-range/slide-range.vue +269 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/switch/switch.html +14 -0
- package/src/components/switch/switch.vue +86 -0
- package/src/components/tabs/index.ts +2 -0
- package/src/components/tabs/tab/index.ts +1 -0
- package/src/components/tabs/tab/tab.html +5 -0
- package/src/components/tabs/tab/tab.vue +34 -0
- package/src/components/tabs/tabs/index.ts +1 -0
- package/src/components/tabs/tabs/tabs.html +3 -0
- package/src/components/tabs/tabs/tabs.vue +151 -0
- package/src/components/tag/index.ts +1 -0
- package/src/components/tag/tag.html +1 -0
- package/src/components/tag/tag.vue +33 -0
- package/src/components/toast/index.ts +3 -0
- package/src/components/toast/toast/index.ts +1 -0
- package/src/components/toast/toast/toast.html +9 -0
- package/src/components/toast/toast/toast.vue +28 -0
- package/src/components/toast/toast-content/index.ts +1 -0
- package/src/components/toast/toast-content/toast-content.html +1 -0
- package/src/components/toast/toast-content/toast-content.vue +51 -0
- package/src/components/toast/toast.composable.ts +22 -0
- package/src/components/toolbar/index.ts +1 -0
- package/src/components/toolbar/toolbar.html +3 -0
- package/src/components/toolbar/toolbar.vue +39 -0
- package/src/env.d.ts +7 -0
- package/src/factory.ts +162 -0
- package/src/index.ts +4 -0
- package/src/shared/provider-state.ts +8 -0
- package/src/types.ts +4 -0
- package/dist/components/action/action.composable.d.ts +0 -44
- package/dist/components/action/action.vue.d.ts +0 -16
- package/dist/components/action/index.d.ts +0 -2
- package/dist/components/app/app.vue.d.ts +0 -11
- package/dist/components/app/index.d.ts +0 -1
- package/dist/components/avatar/avatar.vue.d.ts +0 -8
- package/dist/components/avatar/index.d.ts +0 -1
- package/dist/components/button/button.vue.d.ts +0 -9
- package/dist/components/button/index.d.ts +0 -1
- package/dist/components/cable/cable.vue.d.ts +0 -6
- package/dist/components/cable/index.d.ts +0 -1
- package/dist/components/card/card/card.vue.d.ts +0 -7
- package/dist/components/card/card/index.d.ts +0 -1
- package/dist/components/card/card-body/card-body.vue.d.ts +0 -2
- package/dist/components/card/card-body/index.d.ts +0 -1
- package/dist/components/card/card-footer/card-footer.vue.d.ts +0 -2
- package/dist/components/card/card-footer/index.d.ts +0 -1
- package/dist/components/card/card-header/card-header.vue.d.ts +0 -2
- package/dist/components/card/card-header/index.d.ts +0 -1
- package/dist/components/card/index.d.ts +0 -4
- package/dist/components/checkbox/checkbox.vue.d.ts +0 -18
- package/dist/components/checkbox/index.d.ts +0 -1
- package/dist/components/collapse/collapse.vue.d.ts +0 -12
- package/dist/components/collapse/index.d.ts +0 -1
- package/dist/components/container/container.vue.d.ts +0 -2
- package/dist/components/container/index.d.ts +0 -1
- package/dist/components/decision-modal/decision-modal.composable.d.ts +0 -46
- package/dist/components/decision-modal/decision-modal.vue.d.ts +0 -16
- package/dist/components/decision-modal/index.d.ts +0 -2
- package/dist/components/divider/divider.vue.d.ts +0 -5
- package/dist/components/divider/index.d.ts +0 -1
- package/dist/components/dropdown/dropdown.vue.d.ts +0 -20
- package/dist/components/dropdown/index.d.ts +0 -1
- package/dist/components/field/field.vue.d.ts +0 -30
- package/dist/components/field/index.d.ts +0 -1
- package/dist/components/form-group/form-group.vue.d.ts +0 -5
- package/dist/components/form-group/index.d.ts +0 -1
- package/dist/components/gesture-indicator/gesture-indicator.vue.d.ts +0 -6
- package/dist/components/gesture-indicator/index.d.ts +0 -1
- package/dist/components/image/image.vue.d.ts +0 -3
- package/dist/components/image/index.d.ts +0 -1
- package/dist/components/index.d.ts +0 -32
- package/dist/components/layout/flex/flex.vue.d.ts +0 -5
- package/dist/components/layout/flex/index.d.ts +0 -1
- package/dist/components/layout/flex-item/flex-item.vue.d.ts +0 -5
- package/dist/components/layout/flex-item/index.d.ts +0 -1
- package/dist/components/layout/grid/grid.vue.d.ts +0 -5
- package/dist/components/layout/grid/index.d.ts +0 -1
- package/dist/components/layout/grid-item/grid-item.vue.d.ts +0 -5
- package/dist/components/layout/grid-item/index.d.ts +0 -1
- package/dist/components/layout/index.d.ts +0 -4
- package/dist/components/modal/index.d.ts +0 -1
- package/dist/components/modal/modal.vue.d.ts +0 -17
- package/dist/components/page/index.d.ts +0 -1
- package/dist/components/page/page.vue.d.ts +0 -2
- package/dist/components/present/index.d.ts +0 -2
- package/dist/components/present/present.composable.d.ts +0 -5
- package/dist/components/present/present.vue.d.ts +0 -18
- package/dist/components/radio/index.d.ts +0 -2
- package/dist/components/radio/radio/index.d.ts +0 -1
- package/dist/components/radio/radio/radio.vue.d.ts +0 -7
- package/dist/components/radio/radio-group/index.d.ts +0 -1
- package/dist/components/radio/radio-group/radio-group.vue.d.ts +0 -13
- package/dist/components/refresher/index.d.ts +0 -1
- package/dist/components/refresher/refresher.vue.d.ts +0 -12
- package/dist/components/route/index.d.ts +0 -5
- package/dist/components/route/route-navigator/index.d.ts +0 -1
- package/dist/components/route/route-navigator/route-navigator.vue.d.ts +0 -11
- package/dist/components/route/route-outlet/index.d.ts +0 -1
- package/dist/components/route/route-outlet/route-outlet.vue.d.ts +0 -5
- package/dist/components/route/route-provider/index.d.ts +0 -1
- package/dist/components/route/route-provider/route-provider.vue.d.ts +0 -3
- package/dist/components/route/route-wrapper/index.d.ts +0 -2
- package/dist/components/route/route-wrapper/route-wrapper.composable.d.ts +0 -6
- package/dist/components/route/route-wrapper/route-wrapper.vue.d.ts +0 -5
- package/dist/components/route/route.util.d.ts +0 -3
- package/dist/components/segmented-field/index.d.ts +0 -1
- package/dist/components/segmented-field/segmented-field.vue.d.ts +0 -28
- package/dist/components/select/index.d.ts +0 -1
- package/dist/components/select/select.vue.d.ts +0 -19
- package/dist/components/skeleton/index.d.ts +0 -1
- package/dist/components/skeleton/skeleton.vue.d.ts +0 -6
- package/dist/components/slide-range/index.d.ts +0 -1
- package/dist/components/slide-range/slide-range.vue.d.ts +0 -18
- package/dist/components/switch/index.d.ts +0 -1
- package/dist/components/switch/switch.vue.d.ts +0 -13
- package/dist/components/tabs/index.d.ts +0 -2
- package/dist/components/tabs/tab/index.d.ts +0 -1
- package/dist/components/tabs/tab/tab.vue.d.ts +0 -5
- package/dist/components/tabs/tabs/index.d.ts +0 -1
- package/dist/components/tabs/tabs/tabs.vue.d.ts +0 -14
- package/dist/components/tag/index.d.ts +0 -1
- package/dist/components/tag/tag.vue.d.ts +0 -6
- package/dist/components/toast/index.d.ts +0 -3
- package/dist/components/toast/toast/index.d.ts +0 -1
- package/dist/components/toast/toast/toast.vue.d.ts +0 -5
- package/dist/components/toast/toast-content/index.d.ts +0 -1
- package/dist/components/toast/toast-content/toast-content.vue.d.ts +0 -11
- package/dist/components/toast/toast.composable.d.ts +0 -22
- package/dist/components/toolbar/index.d.ts +0 -1
- package/dist/components/toolbar/toolbar.vue.d.ts +0 -7
- package/dist/factory.d.ts +0 -38
- package/dist/index.d.ts +0 -3
- package/dist/index.es.js +0 -3521
- package/dist/index.umd.js +0 -1
- package/dist/shared/provider-state.d.ts +0 -5
- package/dist/styles/action.css +0 -1
- package/dist/styles/app.css +0 -1
- package/dist/styles/avatar.css +0 -1
- package/dist/styles/button.css +0 -1
- package/dist/styles/cable.css +0 -1
- package/dist/styles/card-body.css +0 -1
- package/dist/styles/card-footer.css +0 -1
- package/dist/styles/card-header.css +0 -1
- package/dist/styles/card.css +0 -1
- package/dist/styles/checkbox.css +0 -1
- package/dist/styles/collapse.css +0 -1
- package/dist/styles/container.css +0 -1
- package/dist/styles/decision-modal.css +0 -1
- package/dist/styles/divider.css +0 -1
- package/dist/styles/dropdown.css +0 -1
- package/dist/styles/field.css +0 -1
- package/dist/styles/flex-item.css +0 -1
- package/dist/styles/flex.css +0 -1
- package/dist/styles/form-group.css +0 -1
- package/dist/styles/gesture-indicator.css +0 -1
- package/dist/styles/grid-item.css +0 -1
- package/dist/styles/grid.css +0 -1
- package/dist/styles/index.css +0 -40
- package/dist/styles/modal.css +0 -1
- package/dist/styles/page.css +0 -1
- package/dist/styles/present.css +0 -1
- package/dist/styles/radio-group.css +0 -1
- package/dist/styles/radio.css +0 -1
- package/dist/styles/refresher.css +0 -1
- package/dist/styles/route-navigator.css +0 -1
- package/dist/styles/segmented-field.css +0 -1
- package/dist/styles/select.css +0 -1
- package/dist/styles/skeleton.css +0 -1
- package/dist/styles/slide-range.css +0 -1
- package/dist/styles/switch.css +0 -1
- package/dist/styles/tab.css +0 -1
- package/dist/styles/tabs.css +0 -1
- package/dist/styles/tag.css +0 -1
- package/dist/styles/toast-content.css +0 -1
- package/dist/styles/toast.css +0 -1
- package/dist/styles/toolbar.css +0 -1
- package/dist/types.d.ts +0 -4
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
<style lang="scss" src="@toife/core/features/present/present.scss" scoped></style>
|
|
2
|
+
<template src="./present.html"></template>
|
|
3
|
+
<script lang="ts" setup>
|
|
4
|
+
import { unref, computed, inject, nextTick, onMounted, reactive, ref, watch } from "vue";
|
|
5
|
+
import { usePresent } from "./present.composable";
|
|
6
|
+
import {
|
|
7
|
+
PRESENT_DEFAULT_PROPS,
|
|
8
|
+
PRESENT_DEFAULT_STYLES,
|
|
9
|
+
APP_PROVIDER_STATE_KEY,
|
|
10
|
+
getAppClassSelector,
|
|
11
|
+
getPresentAttrs,
|
|
12
|
+
getPresentBackdropAttrs,
|
|
13
|
+
type AppProviderState,
|
|
14
|
+
type PresentEvent,
|
|
15
|
+
type PresentProps,
|
|
16
|
+
type RenderOptions,
|
|
17
|
+
type PresentStyles,
|
|
18
|
+
} from "@toife/core";
|
|
19
|
+
import type { ProviderStateRefs } from "../../shared/provider-state";
|
|
20
|
+
|
|
21
|
+
// Component setup (props, emits, injects)
|
|
22
|
+
// ----------------------------------------------------------------------------
|
|
23
|
+
defineOptions({ inheritAttrs: false });
|
|
24
|
+
|
|
25
|
+
const props = withDefaults(defineProps<PresentProps>(), {
|
|
26
|
+
...PRESENT_DEFAULT_PROPS,
|
|
27
|
+
});
|
|
28
|
+
const emit = defineEmits(["close"]) as unknown as PresentEvent;
|
|
29
|
+
const presentIndex = usePresent();
|
|
30
|
+
const appState = inject<ProviderStateRefs<AppProviderState> | null>(APP_PROVIDER_STATE_KEY, null);
|
|
31
|
+
|
|
32
|
+
// Reactive state
|
|
33
|
+
// ----------------------------------------------------------------------------
|
|
34
|
+
const isBounced = ref(false);
|
|
35
|
+
const zIndex = ref(0);
|
|
36
|
+
const isShow = ref(false);
|
|
37
|
+
const isReadyBackdrop = ref(false);
|
|
38
|
+
const isTeleportReady = ref(false);
|
|
39
|
+
const styles = reactive<PresentStyles>({ ...PRESENT_DEFAULT_STYLES });
|
|
40
|
+
|
|
41
|
+
// Computed properties
|
|
42
|
+
// ----------------------------------------------------------------------------
|
|
43
|
+
const teleportTo = computed(() => {
|
|
44
|
+
if (props.teleport) return props.teleport;
|
|
45
|
+
if (unref(appState?.rootEl)) return unref(appState?.rootEl);
|
|
46
|
+
return getAppClassSelector();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const syncTeleportReady = () => {
|
|
50
|
+
if (props.teleport) {
|
|
51
|
+
isTeleportReady.value = !!document.querySelector(props.teleport);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (unref(appState?.rootEl)) {
|
|
56
|
+
isTeleportReady.value = true;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
isTeleportReady.value = !!document.querySelector(getAppClassSelector());
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const backdropAttrs = computed(() =>
|
|
64
|
+
getPresentBackdropAttrs({
|
|
65
|
+
zIndex: zIndex.value - 1,
|
|
66
|
+
backdropTransitionDuration: styles.backdropTransitionDuration,
|
|
67
|
+
backdropOpacity: props.backdrop === "transparent" ? 0 : styles.backdropOpacity,
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// Present attributes
|
|
72
|
+
const presentAttrs = computed(() =>
|
|
73
|
+
getPresentAttrs({
|
|
74
|
+
zIndex: zIndex.value,
|
|
75
|
+
presentTransitionDuration: styles.presentTransitionDuration,
|
|
76
|
+
presentTranslate: styles.presentTranslate,
|
|
77
|
+
presentOpacity: styles.presentOpacity,
|
|
78
|
+
className: props.class,
|
|
79
|
+
placement: props.placement,
|
|
80
|
+
style: props.style,
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const isRender = computed(() => {
|
|
85
|
+
return isShow.value || props.keepalive;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const time = computed(() => {
|
|
89
|
+
return props.duration / 1000 + "s";
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Methods
|
|
93
|
+
// ----------------------------------------------------------------------------
|
|
94
|
+
const createIndex = () => {
|
|
95
|
+
if (zIndex.value === 0 || !props.keepalive) {
|
|
96
|
+
zIndex.value = presentIndex.newIndex();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const render = (data: RenderOptions) => {
|
|
101
|
+
if (data.backdropTransitionDuration !== undefined) {
|
|
102
|
+
styles.backdropTransitionDuration = data.backdropTransitionDuration;
|
|
103
|
+
}
|
|
104
|
+
if (data.presentTransitionDuration !== undefined) {
|
|
105
|
+
styles.presentTransitionDuration = data.presentTransitionDuration;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
styles.backdropOpacity = data.backdropOpacity;
|
|
109
|
+
|
|
110
|
+
if (data.presentTranslate !== undefined) {
|
|
111
|
+
styles.presentTranslate = data.presentTranslate;
|
|
112
|
+
}
|
|
113
|
+
if (data.presentOpacity !== undefined) {
|
|
114
|
+
styles.presentOpacity = data.presentOpacity;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// On click backdrop
|
|
119
|
+
const onClickBackdrop = (e: unknown) => {
|
|
120
|
+
(e as Event).preventDefault();
|
|
121
|
+
if (isReadyBackdrop.value) emit("close", "backdrop");
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const open = () => {
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
isReadyBackdrop.value = true;
|
|
127
|
+
}, 300);
|
|
128
|
+
|
|
129
|
+
if (props.bounce && !isBounced.value) {
|
|
130
|
+
isBounced.value = true;
|
|
131
|
+
let presentTranslate = props.bounce;
|
|
132
|
+
|
|
133
|
+
if (props.placement == "bottom" || props.placement == "right") {
|
|
134
|
+
presentTranslate = `calc(${props.bounce} * -1)`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
render({
|
|
138
|
+
backdropTransitionDuration: time.value,
|
|
139
|
+
backdropOpacity: undefined,
|
|
140
|
+
presentTranslate: String(presentTranslate),
|
|
141
|
+
presentTransitionDuration: time.value,
|
|
142
|
+
presentOpacity: 1,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
setTimeout(() => {
|
|
146
|
+
render({
|
|
147
|
+
presentTranslate: "0px",
|
|
148
|
+
});
|
|
149
|
+
}, props.duration);
|
|
150
|
+
} else {
|
|
151
|
+
render({
|
|
152
|
+
backdropOpacity: undefined,
|
|
153
|
+
backdropTransitionDuration: time.value,
|
|
154
|
+
presentTranslate: "0px",
|
|
155
|
+
presentTransitionDuration: time.value,
|
|
156
|
+
presentOpacity: 1,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const close = () => {
|
|
162
|
+
isReadyBackdrop.value = false;
|
|
163
|
+
isBounced.value = false;
|
|
164
|
+
let presentTranslate = "0px";
|
|
165
|
+
let presentOpacity = 1;
|
|
166
|
+
|
|
167
|
+
if (props.placement == "bottom" || props.placement == "right") {
|
|
168
|
+
presentTranslate = "100%";
|
|
169
|
+
} else if (props.placement == "top" || props.placement == "left") {
|
|
170
|
+
presentTranslate = "-100%";
|
|
171
|
+
} else if (props.placement == "center") {
|
|
172
|
+
presentTranslate = "0px";
|
|
173
|
+
presentOpacity = 0;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
render({
|
|
177
|
+
backdropOpacity: 0,
|
|
178
|
+
backdropTransitionDuration: time.value,
|
|
179
|
+
presentTranslate,
|
|
180
|
+
presentTransitionDuration: time.value,
|
|
181
|
+
presentOpacity,
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// Lifecycle
|
|
186
|
+
// ----------------------------------------------------------------------------
|
|
187
|
+
onMounted(() => {
|
|
188
|
+
syncTeleportReady();
|
|
189
|
+
if (!isTeleportReady.value) {
|
|
190
|
+
nextTick(() => {
|
|
191
|
+
syncTeleportReady();
|
|
192
|
+
if (!isTeleportReady.value) requestAnimationFrame(syncTeleportReady);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (props.visible) open();
|
|
197
|
+
else close();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
watch(
|
|
201
|
+
() => [props.teleport, unref(appState?.rootEl)] as const,
|
|
202
|
+
() => syncTeleportReady(),
|
|
203
|
+
{ immediate: true }
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
// Trigger visible
|
|
207
|
+
watch(
|
|
208
|
+
() => props.visible,
|
|
209
|
+
() => {
|
|
210
|
+
if (props.visible) {
|
|
211
|
+
createIndex();
|
|
212
|
+
isShow.value = true;
|
|
213
|
+
|
|
214
|
+
setTimeout(() => {
|
|
215
|
+
open();
|
|
216
|
+
}, 100);
|
|
217
|
+
} else {
|
|
218
|
+
close();
|
|
219
|
+
|
|
220
|
+
setTimeout(() => {
|
|
221
|
+
isShow.value = false;
|
|
222
|
+
}, props.duration);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
// Provide / expose (public API)
|
|
228
|
+
// ----------------------------------------------------------------------------
|
|
229
|
+
defineExpose({
|
|
230
|
+
render,
|
|
231
|
+
open,
|
|
232
|
+
close,
|
|
233
|
+
});
|
|
234
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Radio } from "./radio.vue";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<style lang="scss" src="@toife/core/features/radio/radio.scss" scoped></style>
|
|
2
|
+
<template src="./radio.html"></template>
|
|
3
|
+
<script lang="ts" setup>
|
|
4
|
+
import { unref, computed, inject, ref } from "vue";
|
|
5
|
+
import {
|
|
6
|
+
RADIO_DEFAULT_PROPS,
|
|
7
|
+
APP_PROVIDER_STATE_KEY,
|
|
8
|
+
RADIO_GROUP_PROVIDER_STATE_KEY,
|
|
9
|
+
getRadioAttrs,
|
|
10
|
+
getRadioIconAttrs,
|
|
11
|
+
type AppProviderState,
|
|
12
|
+
type RadioGroupProviderState,
|
|
13
|
+
type RadioProps,
|
|
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<RadioProps>(), {
|
|
20
|
+
...RADIO_DEFAULT_PROPS,
|
|
21
|
+
});
|
|
22
|
+
const appState = inject<ProviderStateRefs<AppProviderState>>(APP_PROVIDER_STATE_KEY);
|
|
23
|
+
const radioGroupState = inject<ProviderStateRefs<RadioGroupProviderState> | null>(
|
|
24
|
+
RADIO_GROUP_PROVIDER_STATE_KEY,
|
|
25
|
+
null
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// Reactive state
|
|
29
|
+
// ----------------------------------------------------------------------------
|
|
30
|
+
const isFocused = ref(false);
|
|
31
|
+
|
|
32
|
+
// Computed properties
|
|
33
|
+
// ----------------------------------------------------------------------------
|
|
34
|
+
const disabled = computed(() => {
|
|
35
|
+
return props.disabled || (unref(radioGroupState?.disabled) ?? false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const readonly = computed(() => {
|
|
39
|
+
return props.readonly || (unref(radioGroupState?.readonly) ?? false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const radioAttrs = computed(() => {
|
|
43
|
+
const shadow = (props?.shadow !== undefined ? props.shadow : unref(appState?.shadow)) ?? false;
|
|
44
|
+
const role = props.role || unref(radioGroupState?.role) || unref(appState?.role) || "";
|
|
45
|
+
const variant = props.variant || unref(radioGroupState?.variant) || "";
|
|
46
|
+
const isChecked = unref(radioGroupState?.modelValue) === props.value;
|
|
47
|
+
|
|
48
|
+
return getRadioAttrs({
|
|
49
|
+
role,
|
|
50
|
+
size: props.size,
|
|
51
|
+
variant,
|
|
52
|
+
checked: isChecked,
|
|
53
|
+
disabled: disabled.value,
|
|
54
|
+
readonly: readonly.value,
|
|
55
|
+
shadow: shadow && !props.disabled && isFocused.value,
|
|
56
|
+
focus: isFocused.value,
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const radioIconAttrs = getRadioIconAttrs();
|
|
61
|
+
|
|
62
|
+
// Methods
|
|
63
|
+
// ----------------------------------------------------------------------------
|
|
64
|
+
const onRadio = () => {
|
|
65
|
+
if (disabled.value || readonly.value || !radioGroupState) return;
|
|
66
|
+
radioGroupState.setValue(props.value);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const onFocus = () => {
|
|
70
|
+
if (disabled.value || readonly.value) return;
|
|
71
|
+
isFocused.value = true;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const onBlur = () => {
|
|
75
|
+
if (disabled.value || readonly.value) return;
|
|
76
|
+
isFocused.value = false;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const onKeydown = (e: KeyboardEvent) => {
|
|
80
|
+
if (e.key !== " " && e.key !== "Enter") return;
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
onRadio();
|
|
83
|
+
};
|
|
84
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as RadioGroup } from "./radio-group.vue";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<style lang="scss" src="@toife/core/features/radio/radio-group.scss" scoped></style>
|
|
2
|
+
<template src="./radio-group.html"></template>
|
|
3
|
+
<script lang="ts" setup>
|
|
4
|
+
import { unref, computed, inject, provide } from "vue";
|
|
5
|
+
import {
|
|
6
|
+
RADIO_GROUP_DEFAULT_PROPS,
|
|
7
|
+
APP_PROVIDER_STATE_KEY,
|
|
8
|
+
RADIO_GROUP_PROVIDER_STATE_KEY,
|
|
9
|
+
getRadioGroupAttrs,
|
|
10
|
+
type AppProviderState,
|
|
11
|
+
type RadioGroupEvent,
|
|
12
|
+
type RadioGroupProps,
|
|
13
|
+
type RadioGroupProviderState,
|
|
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<RadioGroupProps>(), {
|
|
20
|
+
...RADIO_GROUP_DEFAULT_PROPS,
|
|
21
|
+
});
|
|
22
|
+
const emit = defineEmits<RadioGroupEvent>();
|
|
23
|
+
const appState = inject<ProviderStateRefs<AppProviderState>>(APP_PROVIDER_STATE_KEY);
|
|
24
|
+
|
|
25
|
+
// Computed properties
|
|
26
|
+
// ----------------------------------------------------------------------------
|
|
27
|
+
const modelValue = computed(() => props.modelValue);
|
|
28
|
+
|
|
29
|
+
const role = computed(() => {
|
|
30
|
+
return props.role || unref(appState?.role) || "";
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const variant = computed(() => {
|
|
34
|
+
return props.variant;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const shadow = computed(() => {
|
|
38
|
+
return (props?.shadow !== undefined ? props.shadow : unref(appState?.shadow)) ?? false;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const disabled = computed(() => props.disabled);
|
|
42
|
+
const readonly = computed(() => props.readonly);
|
|
43
|
+
|
|
44
|
+
const radioGroupAttrs = computed(() => getRadioGroupAttrs({ direction: props.direction }));
|
|
45
|
+
|
|
46
|
+
// Provide / expose (public API)
|
|
47
|
+
// ----------------------------------------------------------------------------
|
|
48
|
+
provide<ProviderStateRefs<RadioGroupProviderState>>(RADIO_GROUP_PROVIDER_STATE_KEY, {
|
|
49
|
+
modelValue,
|
|
50
|
+
role,
|
|
51
|
+
variant,
|
|
52
|
+
disabled,
|
|
53
|
+
readonly,
|
|
54
|
+
shadow,
|
|
55
|
+
setValue: (val: string | number) => {
|
|
56
|
+
emit("update:modelValue", val);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Refresher } from "./refresher.vue";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<style lang="scss" src="@toife/core/features/refresher/refresher.scss" scoped></style>
|
|
2
|
+
<template src="./refresher.html"></template>
|
|
3
|
+
<script lang="ts" setup>
|
|
4
|
+
import { ref, onUnmounted, watch, computed } from "vue";
|
|
5
|
+
import { gesture, type GestureMovePayload, type GestureUpPayload } from "@toife/gesture";
|
|
6
|
+
import { getRefresherAttrs, type RefresherEvent } from "@toife/core";
|
|
7
|
+
|
|
8
|
+
// Component setup (props, emits, injects)
|
|
9
|
+
// ----------------------------------------------------------------------------
|
|
10
|
+
const emit = defineEmits<RefresherEvent>();
|
|
11
|
+
|
|
12
|
+
// Reactive state
|
|
13
|
+
// ----------------------------------------------------------------------------
|
|
14
|
+
const refreshing = ref(false);
|
|
15
|
+
const container = ref();
|
|
16
|
+
let cleanup: unknown;
|
|
17
|
+
let isPulling = false;
|
|
18
|
+
|
|
19
|
+
// Computed properties
|
|
20
|
+
// ----------------------------------------------------------------------------
|
|
21
|
+
const containerAttrs = computed(() => getRefresherAttrs());
|
|
22
|
+
|
|
23
|
+
// Methods
|
|
24
|
+
// ----------------------------------------------------------------------------
|
|
25
|
+
const close = () => {
|
|
26
|
+
refreshing.value = false;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const refresh = () => {
|
|
30
|
+
refreshing.value = true;
|
|
31
|
+
return close;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const up = () => {
|
|
35
|
+
emit("end", { refresh });
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const cancel = () => {
|
|
39
|
+
isPulling = false;
|
|
40
|
+
refreshing.value = false;
|
|
41
|
+
emit("cancel");
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Lifecycle
|
|
45
|
+
// ----------------------------------------------------------------------------
|
|
46
|
+
watch(
|
|
47
|
+
() => container.value,
|
|
48
|
+
() => {
|
|
49
|
+
cleanup && (cleanup as { destroy: () => void }).destroy();
|
|
50
|
+
if (!container.value) return;
|
|
51
|
+
cleanup = gesture(
|
|
52
|
+
container.value,
|
|
53
|
+
{
|
|
54
|
+
options: {
|
|
55
|
+
minMove: 20,
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
beforeEvent() {
|
|
59
|
+
if (isPulling) return true;
|
|
60
|
+
if ((container.value?.scrollTop || 0) > 0) return false;
|
|
61
|
+
return true;
|
|
62
|
+
},
|
|
63
|
+
down() {
|
|
64
|
+
if (refreshing.value) return;
|
|
65
|
+
isPulling = (container.value?.scrollTop || 0) <= 0;
|
|
66
|
+
if (!isPulling) return;
|
|
67
|
+
emit("start");
|
|
68
|
+
},
|
|
69
|
+
move({ deltaY, initialDirection }: GestureMovePayload) {
|
|
70
|
+
if (refreshing.value || !isPulling || initialDirection != "down") return;
|
|
71
|
+
const v = deltaY < 0 ? 0 : deltaY;
|
|
72
|
+
emit("move", { refresh, offset: v });
|
|
73
|
+
},
|
|
74
|
+
up({ initialDirection }: GestureUpPayload) {
|
|
75
|
+
const wasPulling = isPulling;
|
|
76
|
+
isPulling = false;
|
|
77
|
+
if (refreshing.value || !wasPulling) return;
|
|
78
|
+
if (initialDirection != "down") {
|
|
79
|
+
cancel();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
up();
|
|
83
|
+
},
|
|
84
|
+
cancel() {
|
|
85
|
+
isPulling = false;
|
|
86
|
+
if (refreshing.value) return;
|
|
87
|
+
cancel();
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
passive: false,
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
onUnmounted(() => {
|
|
98
|
+
cleanup && (cleanup as { destroy: () => void }).destroy();
|
|
99
|
+
});
|
|
100
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as RouteNavigator } from "./route-navigator.vue";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<div v-bind="navigatorAttrs" ref="navigatorRef">
|
|
2
|
+
<div
|
|
3
|
+
v-for="(item, index) in stack"
|
|
4
|
+
:key="item.name"
|
|
5
|
+
v-bind="componentAttrs"
|
|
6
|
+
:style="{zIndex: index * 2 + 100}"
|
|
7
|
+
:name="item.name"
|
|
8
|
+
:class="{
|
|
9
|
+
active: index === activeIndex,
|
|
10
|
+
prepare: index === activeIndex + 1,
|
|
11
|
+
back: index === activeIndex - 1,
|
|
12
|
+
}"
|
|
13
|
+
>
|
|
14
|
+
<RouteProvider :stack="item.stack">
|
|
15
|
+
<RouteOutlet :component="item.component" />
|
|
16
|
+
</RouteProvider>
|
|
17
|
+
</div>
|
|
18
|
+
<div v-bind="backdropAttrs"></div>
|
|
19
|
+
</div>
|