@toife/vue 2.2.0 → 3.0.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/README.md +171 -0
- package/package.json +41 -9
- package/src/components/action/action.composable.ts +32 -0
- package/src/components/action/action.html +25 -0
- package/src/components/action/action.scss +106 -0
- package/src/components/action/action.type.ts +35 -0
- package/src/components/action/action.vue +82 -0
- package/src/components/action/index.ts +9 -0
- package/src/components/app/app.constants.ts +1 -0
- package/src/components/app/app.html +24 -0
- package/src/components/app/app.scss +27 -0
- package/src/components/app/app.type.ts +21 -0
- package/src/components/app/app.vue +45 -0
- package/src/components/app/index.ts +3 -0
- package/src/components/avatar/avatar.html +3 -0
- package/src/components/avatar/avatar.scss +35 -0
- package/src/components/avatar/avatar.type.ts +6 -0
- package/src/components/avatar/avatar.vue +45 -0
- package/src/components/avatar/index.ts +2 -0
- package/src/components/button/button.html +6 -0
- package/src/components/button/button.scss +113 -0
- package/src/components/button/button.type.ts +14 -0
- package/src/components/button/button.vue +66 -0
- package/src/components/button/index.ts +2 -0
- package/src/components/cable/cable.constants.ts +1 -0
- package/src/components/cable/cable.html +3 -0
- package/src/components/cable/cable.scss +37 -0
- package/src/components/cable/cable.type.ts +11 -0
- package/src/components/cable/cable.vue +33 -0
- package/src/components/cable/index.ts +3 -0
- package/src/components/card/card/card.constants.ts +1 -0
- package/src/components/card/card/card.html +3 -0
- package/src/components/card/card/card.scss +34 -0
- package/src/components/card/card/card.type.ts +14 -0
- package/src/components/card/card/card.vue +62 -0
- package/src/components/card/card/index.ts +3 -0
- package/src/components/card/card-body/card-body.html +3 -0
- package/src/components/card/card-body/card-body.scss +23 -0
- package/src/components/card/card-body/card-body.vue +14 -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.scss +31 -0
- package/src/components/card/card-footer/card-footer.vue +28 -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.scss +31 -0
- package/src/components/card/card-header/card-header.vue +28 -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 +13 -0
- package/src/components/checkbox/checkbox.scss +138 -0
- package/src/components/checkbox/checkbox.type.ts +17 -0
- package/src/components/checkbox/checkbox.vue +91 -0
- package/src/components/checkbox/index.ts +2 -0
- package/src/components/collapse/collapse.html +16 -0
- package/src/components/collapse/collapse.scss +59 -0
- package/src/components/collapse/collapse.type.ts +11 -0
- package/src/components/collapse/collapse.vue +131 -0
- package/src/components/collapse/index.ts +2 -0
- package/src/components/container/container.html +1 -0
- package/src/components/container/container.scss +10 -0
- package/src/components/container/container.vue +14 -0
- package/src/components/container/index.ts +1 -0
- package/src/components/decision-modal/decision-modal.composable.ts +32 -0
- package/src/components/decision-modal/decision-modal.html +29 -0
- package/src/components/decision-modal/decision-modal.scss +136 -0
- package/src/components/decision-modal/decision-modal.type.ts +35 -0
- package/src/components/decision-modal/decision-modal.vue +98 -0
- package/src/components/decision-modal/index.ts +9 -0
- package/src/components/divider/divider.html +1 -0
- package/src/components/divider/divider.scss +29 -0
- package/src/components/divider/divider.type.ts +6 -0
- package/src/components/divider/divider.vue +34 -0
- package/src/components/divider/index.ts +2 -0
- package/src/components/field/field.html +1 -0
- package/src/components/field/field.type.ts +43 -0
- package/src/components/field/field.vue +85 -0
- package/src/components/field/index.ts +2 -0
- package/src/components/field/outline/index.ts +1 -0
- package/src/components/field/outline/outline.html +32 -0
- package/src/components/field/outline/outline.scss +224 -0
- package/src/components/field/outline/outline.vue +243 -0
- package/src/components/form-group/form-group.html +3 -0
- package/src/components/form-group/form-group.scss +91 -0
- package/src/components/form-group/form-group.type.ts +5 -0
- package/src/components/form-group/form-group.vue +21 -0
- package/src/components/form-group/index.ts +2 -0
- package/src/components/gesture-indicator/gesture-indicator.html +1 -0
- package/src/components/gesture-indicator/gesture-indicator.scss +45 -0
- package/{dist/components/gesture-indicator/gesture-indicator.type.d.ts → src/components/gesture-indicator/gesture-indicator.type.ts} +2 -1
- 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.scss +1 -0
- package/src/components/image/image.type.ts +5 -0
- package/src/components/image/image.vue +25 -0
- package/src/components/image/index.ts +2 -0
- package/src/components/index.ts +27 -0
- package/src/components/modal/index.ts +2 -0
- package/src/components/modal/modal.html +20 -0
- package/src/components/modal/modal.scss +78 -0
- package/src/components/modal/modal.type.ts +21 -0
- package/src/components/modal/modal.vue +186 -0
- package/src/components/page/index.ts +1 -0
- package/src/components/page/page.html +3 -0
- package/src/components/page/page.scss +17 -0
- package/src/components/page/page.vue +14 -0
- package/src/components/present/index.ts +3 -0
- package/src/components/present/present.composable.ts +21 -0
- package/src/components/present/present.html +9 -0
- package/src/components/present/present.scss +81 -0
- package/src/components/present/present.type.ts +26 -0
- package/src/components/present/present.vue +198 -0
- package/src/components/radio/index.ts +2 -0
- package/src/components/radio/radio/index.ts +2 -0
- package/src/components/radio/radio/radio.html +11 -0
- package/src/components/radio/radio/radio.scss +125 -0
- package/src/components/radio/radio/radio.type.ts +11 -0
- package/src/components/radio/radio/radio.vue +103 -0
- package/src/components/radio/radio-group/index.ts +7 -0
- package/src/components/radio/radio-group/radio-group.constants.ts +1 -0
- package/src/components/radio/radio-group/radio-group.html +3 -0
- package/src/components/radio/radio-group/radio-group.scss +16 -0
- package/src/components/radio/radio-group/radio-group.type.ts +28 -0
- package/src/components/radio/radio-group/radio-group.vue +62 -0
- package/src/components/refresher/index.ts +2 -0
- package/src/components/refresher/refresher.html +6 -0
- package/src/components/refresher/refresher.scss +36 -0
- package/src/components/refresher/refresher.type.ts +16 -0
- package/src/components/refresher/refresher.vue +137 -0
- package/src/components/route/index.ts +5 -0
- package/src/components/route/route-navigator/index.ts +2 -0
- package/src/components/route/route-navigator/route-navigator.html +19 -0
- package/src/components/route/route-navigator/route-navigator.scss +127 -0
- package/src/components/route/route-navigator/route-navigator.type.ts +12 -0
- package/src/components/route/route-navigator/route-navigator.vue +250 -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 +30 -0
- package/src/components/route/route-provider/index.ts +3 -0
- package/src/components/route/route-provider/route-provider.constant.ts +1 -0
- package/src/components/route/route-provider/route-provider.html +1 -0
- package/src/components/route/route-provider/route-provider.type.ts +10 -0
- package/src/components/route/route-provider/route-provider.vue +20 -0
- package/src/components/route/route-wrapper/index.ts +3 -0
- package/src/components/route/route-wrapper/route-wrapper.composable.ts +43 -0
- package/src/components/route/route-wrapper/route-wrapper.html +3 -0
- package/src/components/route/route-wrapper/route-wrapper.type.ts +3 -0
- package/src/components/route/route-wrapper/route-wrapper.vue +43 -0
- package/src/components/route/route.type.ts +7 -0
- package/src/components/route/route.util.ts +8 -0
- package/src/components/segmented-field/index.ts +7 -0
- package/src/components/segmented-field/segmented-field.html +17 -0
- package/src/components/segmented-field/segmented-field.scss +52 -0
- package/src/components/segmented-field/segmented-field.type.ts +29 -0
- package/src/components/segmented-field/segmented-field.vue +151 -0
- package/src/components/skeleton/index.ts +2 -0
- package/src/components/skeleton/skeleton.html +1 -0
- package/src/components/skeleton/skeleton.scss +45 -0
- package/src/components/skeleton/skeleton.type.ts +7 -0
- package/src/components/skeleton/skeleton.vue +38 -0
- package/src/components/switch/index.ts +2 -0
- package/src/components/switch/switch.html +15 -0
- package/src/components/switch/switch.scss +134 -0
- package/src/components/switch/switch.type.ts +13 -0
- package/src/components/switch/switch.vue +92 -0
- package/src/components/tabs/index.ts +2 -0
- package/src/components/tabs/tab/index.ts +2 -0
- package/src/components/tabs/tab/tab.html +5 -0
- package/src/components/tabs/tab/tab.type.ts +5 -0
- package/src/components/tabs/tab/tab.vue +38 -0
- package/src/components/tabs/tabs/index.ts +9 -0
- package/src/components/tabs/tabs/tabs.constants.ts +1 -0
- package/src/components/tabs/tabs/tabs.html +3 -0
- package/src/components/tabs/tabs/tabs.scss +272 -0
- package/src/components/tabs/tabs/tabs.type.ts +36 -0
- package/src/components/tabs/tabs/tabs.vue +159 -0
- package/src/components/toast/index.ts +4 -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.scss +61 -0
- package/src/components/toast/toast/toast.vue +34 -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.scss +41 -0
- package/src/components/toast/toast-content/toast-content.vue +59 -0
- package/src/components/toast/toast.composable.ts +22 -0
- package/src/components/toast/toast.type.ts +25 -0
- package/src/components/toolbar/index.ts +2 -0
- package/src/components/toolbar/toolbar.html +5 -0
- package/src/components/toolbar/toolbar.scss +79 -0
- package/src/components/toolbar/toolbar.type.ts +7 -0
- package/src/components/toolbar/toolbar.vue +47 -0
- package/src/env.d.ts +7 -0
- package/src/factory.ts +81 -0
- package/src/index.ts +4 -0
- package/{dist/type.d.ts → src/type.ts} +1 -1
- package/src/utils/element.ts +16 -0
- package/src/utils/events.ts +12 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/style/index.ts +42 -0
- package/dist/components/action/action.type.d.ts +0 -17
- package/dist/components/action/action.vue.d.ts +0 -14
- package/dist/components/action/factory.d.ts +0 -3
- package/dist/components/action/index.d.ts +0 -2
- package/dist/components/alert/alert.type.d.ts +0 -16
- package/dist/components/alert/alert.vue.d.ts +0 -14
- package/dist/components/alert/factory.d.ts +0 -3
- package/dist/components/alert/index.d.ts +0 -2
- package/dist/components/app/app.type.d.ts +0 -1
- package/dist/components/app/app.vue.d.ts +0 -3
- package/dist/components/app/index.d.ts +0 -1
- package/dist/components/avatar/avatar.type.d.ts +0 -4
- package/dist/components/avatar/avatar.vue.d.ts +0 -6
- package/dist/components/avatar/index.d.ts +0 -1
- package/dist/components/back-button/back-button.type.d.ts +0 -4
- package/dist/components/back-button/back-button.vue.d.ts +0 -3
- package/dist/components/back-button/index.d.ts +0 -1
- package/dist/components/button/button.type.d.ts +0 -10
- package/dist/components/button/button.vue.d.ts +0 -12
- package/dist/components/button/index.d.ts +0 -1
- package/dist/components/cable/cable.type.d.ts +0 -4
- package/dist/components/cable/cable.vue.d.ts +0 -6
- package/dist/components/cable/index.d.ts +0 -1
- package/dist/components/card/card.type.d.ts +0 -3
- package/dist/components/card/card.vue.d.ts +0 -5
- package/dist/components/card/index.d.ts +0 -1
- package/dist/components/checkbox/checkbox.type.d.ts +0 -12
- package/dist/components/checkbox/checkbox.vue.d.ts +0 -14
- package/dist/components/checkbox/index.d.ts +0 -1
- package/dist/components/collapse/collapse.type.d.ts +0 -6
- package/dist/components/collapse/collapse.vue.d.ts +0 -7
- package/dist/components/collapse/index.d.ts +0 -1
- package/dist/components/content/content.type.d.ts +0 -1
- package/dist/components/content/content.vue.d.ts +0 -3
- package/dist/components/content/index.d.ts +0 -1
- package/dist/components/divider/divider.type.d.ts +0 -3
- package/dist/components/divider/divider.vue.d.ts +0 -5
- package/dist/components/divider/index.d.ts +0 -1
- package/dist/components/flex/flex.type.d.ts +0 -4
- package/dist/components/flex/flex.vue.d.ts +0 -6
- package/dist/components/flex/index.d.ts +0 -1
- package/dist/components/gesture-indicator/gesture-indicator.vue.d.ts +0 -5
- package/dist/components/gesture-indicator/index.d.ts +0 -1
- package/dist/components/grid/grid.type.d.ts +0 -4
- package/dist/components/grid/grid.vue.d.ts +0 -6
- package/dist/components/grid/index.d.ts +0 -1
- package/dist/components/icon-spinner/icon-spinner.type.d.ts +0 -4
- package/dist/components/icon-spinner/icon-spinner.vue.d.ts +0 -6
- package/dist/components/icon-spinner/index.d.ts +0 -1
- package/dist/components/image/image.type.d.ts +0 -4
- 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 -36
- package/dist/components/input/index.d.ts +0 -1
- package/dist/components/input/input.type.d.ts +0 -15
- package/dist/components/input/input.vue.d.ts +0 -16
- package/dist/components/keyboard-space/factory.d.ts +0 -3
- package/dist/components/keyboard-space/index.d.ts +0 -2
- package/dist/components/keyboard-space/keyboard-space.type.d.ts +0 -1
- package/dist/components/keyboard-space/keyboard-space.vue.d.ts +0 -3
- package/dist/components/loading/factory.d.ts +0 -4
- package/dist/components/loading/index.d.ts +0 -2
- package/dist/components/loading/loading.type.d.ts +0 -6
- package/dist/components/loading/loading.vue.d.ts +0 -12
- package/dist/components/present/factory.d.ts +0 -1
- package/dist/components/present/index.d.ts +0 -2
- package/dist/components/present/present.type.d.ts +0 -13
- package/dist/components/present/present.vue.d.ts +0 -17
- package/dist/components/refresher/index.d.ts +0 -1
- package/dist/components/refresher/refresher.type.d.ts +0 -11
- package/dist/components/refresher/refresher.vue.d.ts +0 -17
- package/dist/components/richtext/index.d.ts +0 -1
- package/dist/components/richtext/richtext.type.d.ts +0 -1
- package/dist/components/richtext/richtext.vue.d.ts +0 -3
- package/dist/components/ripple/index.d.ts +0 -1
- package/dist/components/ripple/ripple.type.d.ts +0 -3
- package/dist/components/ripple/ripple.vue.d.ts +0 -5
- package/dist/components/screen/index.d.ts +0 -1
- package/dist/components/screen/screen.type.d.ts +0 -1
- package/dist/components/screen/screen.vue.d.ts +0 -3
- package/dist/components/screen-router/factory.d.ts +0 -19
- package/dist/components/screen-router/index.d.ts +0 -2
- package/dist/components/screen-router/screen-router.type.d.ts +0 -8
- package/dist/components/screen-router/screen-router.vue.d.ts +0 -9
- package/dist/components/sheet/index.d.ts +0 -1
- package/dist/components/sheet/sheet.type.d.ts +0 -18
- package/dist/components/sheet/sheet.vue.d.ts +0 -18
- package/dist/components/skeleton/index.d.ts +0 -1
- package/dist/components/skeleton/skeleton.type.d.ts +0 -6
- package/dist/components/skeleton/skeleton.vue.d.ts +0 -8
- package/dist/components/switch/index.d.ts +0 -1
- package/dist/components/switch/switch.type.d.ts +0 -7
- package/dist/components/switch/switch.vue.d.ts +0 -9
- package/dist/components/tab/index.d.ts +0 -1
- package/dist/components/tab/tab.type.d.ts +0 -4
- package/dist/components/tab/tab.vue.d.ts +0 -5
- package/dist/components/tabs/index.d.ts +0 -1
- package/dist/components/tabs/tabs.type.d.ts +0 -13
- package/dist/components/tabs/tabs.vue.d.ts +0 -15
- package/dist/components/text/index.d.ts +0 -1
- package/dist/components/text/text.type.d.ts +0 -4
- package/dist/components/text/text.vue.d.ts +0 -6
- package/dist/components/textarea/index.d.ts +0 -1
- package/dist/components/textarea/textarea.type.d.ts +0 -1
- package/dist/components/textarea/textarea.vue.d.ts +0 -3
- package/dist/components/toast/factory.d.ts +0 -3
- package/dist/components/toast/index.d.ts +0 -2
- package/dist/components/toast/toast.type.d.ts +0 -11
- package/dist/components/toast/toast.vue.d.ts +0 -16
- package/dist/components/toggle-password/index.d.ts +0 -1
- package/dist/components/toggle-password/toggle-password.type.d.ts +0 -6
- package/dist/components/toggle-password/toggle-password.vue.d.ts +0 -9
- package/dist/components/toolbar/index.d.ts +0 -1
- package/dist/components/toolbar/toolbar.type.d.ts +0 -5
- package/dist/components/toolbar/toolbar.vue.d.ts +0 -7
- package/dist/factory.d.ts +0 -4
- package/dist/index.css +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.es.js +0 -1836
- package/dist/index.umd.js +0 -1
- package/dist/utils/element.d.ts +0 -2
- package/dist/utils/events.d.ts +0 -1
- package/dist/utils/index.d.ts +0 -2
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template src="./route-wrapper.html"></template>
|
|
2
|
+
<script lang="ts" setup>
|
|
3
|
+
import { onMounted, watch } from "vue";
|
|
4
|
+
import { useRouteWrapper } from "./route-wrapper.composable";
|
|
5
|
+
import { useRouter, useRoute } from "vue-router";
|
|
6
|
+
import type { RouteWrapperProps } from "./route-wrapper.type";
|
|
7
|
+
import { RouteProvider } from "../route-provider";
|
|
8
|
+
|
|
9
|
+
const { updateRoutes, stack } = useRouteWrapper();
|
|
10
|
+
const route = useRoute();
|
|
11
|
+
const router = useRouter();
|
|
12
|
+
const props = withDefaults(defineProps<RouteWrapperProps>(), {
|
|
13
|
+
homeRouteName: "home",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/// Lifecycle
|
|
17
|
+
/// ------------------------------------------------------------
|
|
18
|
+
watch(
|
|
19
|
+
() => route.matched,
|
|
20
|
+
(matched) => {
|
|
21
|
+
updateRoutes(matched);
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
onMounted(() => {
|
|
26
|
+
// Add home route to stack
|
|
27
|
+
const homeName = props.homeRouteName;
|
|
28
|
+
|
|
29
|
+
if (route.name === homeName) {
|
|
30
|
+
updateRoutes(route.matched);
|
|
31
|
+
} else {
|
|
32
|
+
const homeLocation = router.resolve({ name: homeName });
|
|
33
|
+
if (homeLocation.matched.length > 0) {
|
|
34
|
+
updateRoutes(homeLocation.matched);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Apply current route to stack
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
updateRoutes(route.matched);
|
|
40
|
+
}, 50);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
</script>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<div v-bind="wrapperAttrs">
|
|
2
|
+
<div v-bind="contentAttrs" @click="onFieldClick">
|
|
3
|
+
<Field
|
|
4
|
+
v-for="(_, index) in props.length"
|
|
5
|
+
:key="index"
|
|
6
|
+
:tabindex="index === nextIndex ? 0 : -1"
|
|
7
|
+
v-bind="fieldAttrs"
|
|
8
|
+
:value="segments?.at(index) || ''"
|
|
9
|
+
@beforeinput="onSegmentBeforeinput($event, index)"
|
|
10
|
+
@input="onSegmentInput($event, index)"
|
|
11
|
+
@focus="onFieldFocus"
|
|
12
|
+
ref="fields"
|
|
13
|
+
/>
|
|
14
|
+
</div>
|
|
15
|
+
<div v-bind="messageAttrs" v-if="message">{{ message }}</div>
|
|
16
|
+
<div v-bind="helpAttrs" v-if="help">{{ help }}</div>
|
|
17
|
+
</div>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
@use "@toife/sass-layer-generator" as sass;
|
|
2
|
+
|
|
3
|
+
// Class name
|
|
4
|
+
$segmented-field-wrapper: sass.fn-naming-prefix("segmented-field-wrapper");
|
|
5
|
+
$segmented-field-content: sass.fn-naming-prefix("segmented-field-content");
|
|
6
|
+
$segmented-field-message: sass.fn-naming-prefix("segmented-field-message");
|
|
7
|
+
$segmented-field-help: sass.fn-naming-prefix("segmented-field-help");
|
|
8
|
+
|
|
9
|
+
// Property name
|
|
10
|
+
$spacing-x: sass.fn-naming-var("spacing", "x");
|
|
11
|
+
$transition-duration: sass.fn-naming-var("motion", "duration");
|
|
12
|
+
$role-color: sass.fn-naming-var("item", "background-color");
|
|
13
|
+
$base-color: sass.fn-naming-var("base", "color");
|
|
14
|
+
|
|
15
|
+
.#{$segmented-field-wrapper} {
|
|
16
|
+
.#{$segmented-field-content} {
|
|
17
|
+
display: flex;
|
|
18
|
+
gap: calc(#{$spacing-x} * 2);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Message
|
|
22
|
+
.#{$segmented-field-message} {
|
|
23
|
+
color: rgb(#{$role-color});
|
|
24
|
+
font-size: 0.9em;
|
|
25
|
+
line-height: 1.5;
|
|
26
|
+
transition:
|
|
27
|
+
box-shadow #{$transition-duration} ease,
|
|
28
|
+
border-color #{$transition-duration} ease,
|
|
29
|
+
background-color #{$transition-duration} ease,
|
|
30
|
+
color #{$transition-duration} ease,
|
|
31
|
+
border-radius #{$transition-duration} ease;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Help
|
|
35
|
+
.#{$segmented-field-help} {
|
|
36
|
+
color: rgb(#{$base-color}, 0.75);
|
|
37
|
+
font-size: 0.8em;
|
|
38
|
+
line-height: 1.5;
|
|
39
|
+
transition:
|
|
40
|
+
box-shadow #{$transition-duration} ease,
|
|
41
|
+
border-color #{$transition-duration} ease,
|
|
42
|
+
background-color #{$transition-duration} ease,
|
|
43
|
+
color #{$transition-duration} ease,
|
|
44
|
+
border-radius #{$transition-duration} ease;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// State
|
|
48
|
+
&.disabled {
|
|
49
|
+
opacity: 0.5;
|
|
50
|
+
cursor: not-allowed;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FieldVariant, FieldSize } from "../field/field.type";
|
|
2
|
+
|
|
3
|
+
export type SegmentedFieldVariant = FieldVariant;
|
|
4
|
+
export type SegmentedFieldSize = FieldSize;
|
|
5
|
+
|
|
6
|
+
export type SegmentedFieldProps = {
|
|
7
|
+
modelValue?: string[];
|
|
8
|
+
value?: string[];
|
|
9
|
+
length?: number;
|
|
10
|
+
variant?: SegmentedFieldVariant;
|
|
11
|
+
size?: SegmentedFieldSize;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
readonly?: boolean;
|
|
14
|
+
type?: string;
|
|
15
|
+
role?: string;
|
|
16
|
+
shape?: string;
|
|
17
|
+
shadow?: boolean;
|
|
18
|
+
message?: string;
|
|
19
|
+
help?: string;
|
|
20
|
+
pattern?: string[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type SegmentedFieldEmit = {
|
|
24
|
+
(e: "update:modelValue", value: string[]): void;
|
|
25
|
+
(e: "complete", value: string[]): void;
|
|
26
|
+
(e: "focus", ev: FocusEvent): void;
|
|
27
|
+
(e: "blur", ev: FocusEvent): void;
|
|
28
|
+
(e: "input", value: string[]): void;
|
|
29
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
<style lang="scss" src="./segmented-field.scss" scoped></style>
|
|
2
|
+
<template src="./segmented-field.html"></template>
|
|
3
|
+
<script lang="ts" setup>
|
|
4
|
+
import { computed, inject, nextTick, ref } from "vue";
|
|
5
|
+
import { Field } from "../field";
|
|
6
|
+
import type { SegmentedFieldProps, SegmentedFieldEmit } from "./segmented-field.type";
|
|
7
|
+
import { withPrefix } from "../../utils";
|
|
8
|
+
import { type AppProviderState, APP_PROVIDER_STATE_KEY } from "../app";
|
|
9
|
+
|
|
10
|
+
/// Define
|
|
11
|
+
/// ------------------------------------------------------------
|
|
12
|
+
const props = withDefaults(defineProps<SegmentedFieldProps>(), {
|
|
13
|
+
modelValue: undefined,
|
|
14
|
+
value: undefined,
|
|
15
|
+
length: 6,
|
|
16
|
+
variant: "outline",
|
|
17
|
+
size: "standard",
|
|
18
|
+
disabled: false,
|
|
19
|
+
readonly: false,
|
|
20
|
+
type: "text",
|
|
21
|
+
shadow: undefined,
|
|
22
|
+
message: "",
|
|
23
|
+
help: "",
|
|
24
|
+
pattern: (): string[] => [],
|
|
25
|
+
});
|
|
26
|
+
const emit = defineEmits<SegmentedFieldEmit>();
|
|
27
|
+
const appState = inject<AppProviderState>(APP_PROVIDER_STATE_KEY);
|
|
28
|
+
|
|
29
|
+
/// State
|
|
30
|
+
/// ------------------------------------------------------------
|
|
31
|
+
const keepValue = ref<string[]>([]);
|
|
32
|
+
const fields = ref<InstanceType<typeof Field>[]>([]);
|
|
33
|
+
|
|
34
|
+
/// Computed
|
|
35
|
+
/// ------------------------------------------------------------
|
|
36
|
+
const role = computed(() => props.role || appState?.role.value || "");
|
|
37
|
+
const shape = computed(() => props.shape || appState?.shape.value || "");
|
|
38
|
+
const shadow = computed(
|
|
39
|
+
() => (props.shadow !== undefined ? props.shadow : appState?.shadow.value) ?? false
|
|
40
|
+
);
|
|
41
|
+
const segments = computed(() => {
|
|
42
|
+
let value: string[] | undefined = [];
|
|
43
|
+
if (props.value !== undefined && props.value.length > 0) value = props.value;
|
|
44
|
+
else if (props.modelValue !== undefined && props.modelValue.length > 0) value = props.modelValue;
|
|
45
|
+
else value = keepValue.value;
|
|
46
|
+
return value || [];
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const wrapperAttrs = computed(() => {
|
|
50
|
+
return {
|
|
51
|
+
class: [
|
|
52
|
+
withPrefix("segmented-field-wrapper"),
|
|
53
|
+
withPrefix(["layer", "item"]),
|
|
54
|
+
withPrefix(["role", role.value]),
|
|
55
|
+
withPrefix(["shape", shape.value]),
|
|
56
|
+
props.variant,
|
|
57
|
+
props.size,
|
|
58
|
+
{ disabled: props.disabled },
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const contentAttrs = computed(() => {
|
|
64
|
+
return {
|
|
65
|
+
class: [withPrefix("segmented-field-content")],
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const fieldAttrs = computed(() => {
|
|
70
|
+
return {
|
|
71
|
+
variant: props.variant,
|
|
72
|
+
size: props.size,
|
|
73
|
+
disabled: props.disabled,
|
|
74
|
+
readonly: props.readonly,
|
|
75
|
+
shadow: shadow.value,
|
|
76
|
+
shape: shape.value,
|
|
77
|
+
role: role.value,
|
|
78
|
+
type: props.type,
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const messageAttrs = computed(() => ({
|
|
83
|
+
class: [withPrefix("segmented-field-message")],
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
const helpAttrs = computed(() => ({
|
|
87
|
+
class: [
|
|
88
|
+
withPrefix("segmented-field-help"),
|
|
89
|
+
withPrefix(["layer", "surface"]),
|
|
90
|
+
withPrefix(["role", "mode"]),
|
|
91
|
+
],
|
|
92
|
+
}));
|
|
93
|
+
|
|
94
|
+
const nextIndex = computed(() => {
|
|
95
|
+
let nextIndex = segments.value.length;
|
|
96
|
+
if (nextIndex > props.length - 1) {
|
|
97
|
+
nextIndex = props.length - 1;
|
|
98
|
+
}
|
|
99
|
+
return nextIndex;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
/// Methods
|
|
103
|
+
/// ------------------------------------------------------------
|
|
104
|
+
const updateValue = (newValue: string[]) => {
|
|
105
|
+
keepValue.value = newValue;
|
|
106
|
+
emit("update:modelValue", newValue);
|
|
107
|
+
emit("input", newValue);
|
|
108
|
+
|
|
109
|
+
if (newValue.length === props.length) {
|
|
110
|
+
emit("complete", newValue);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
focusNextInput();
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const focusNextInput = async () => {
|
|
117
|
+
await nextTick();
|
|
118
|
+
const el = fields.value.at(nextIndex.value)?.$el?.querySelector("[contenteditable='true']");
|
|
119
|
+
if (el) {
|
|
120
|
+
el.focus();
|
|
121
|
+
el.setSelectionRange(el.value.length, el.value.length);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const onFieldFocus = () => {
|
|
126
|
+
focusNextInput();
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const onSegmentBeforeinput = (ev: InputEvent, index: number) => {
|
|
130
|
+
const type = ev.inputType;
|
|
131
|
+
|
|
132
|
+
if (
|
|
133
|
+
(type === "deleteContentBackward" || type === "deleteContentForward") &&
|
|
134
|
+
!segments.value.at(index)
|
|
135
|
+
) {
|
|
136
|
+
let newModelValue = [...segments.value];
|
|
137
|
+
newModelValue.pop();
|
|
138
|
+
updateValue(newModelValue);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const onSegmentInput = (ev: Event, index: number) => {
|
|
143
|
+
const newModelValue = [...segments.value];
|
|
144
|
+
const val = (ev as InputEvent).data;
|
|
145
|
+
|
|
146
|
+
if (val === "" || val === null) newModelValue.pop();
|
|
147
|
+
else newModelValue[index] = val;
|
|
148
|
+
|
|
149
|
+
updateValue(newModelValue);
|
|
150
|
+
};
|
|
151
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div v-bind="skeletonAttrs"></div>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
@use "@toife/sass-layer-generator" as sass;
|
|
2
|
+
|
|
3
|
+
// Classes
|
|
4
|
+
$skeleton: sass.fn-naming-prefix("skeleton");
|
|
5
|
+
|
|
6
|
+
// Properties - layer: item
|
|
7
|
+
$width: sass.fn-naming-var("skeleton", "width");
|
|
8
|
+
$height: sass.fn-naming-var("skeleton", "height");
|
|
9
|
+
$border-radius: sass.fn-naming-var("border-radius");
|
|
10
|
+
$background-color: sass.fn-naming-var("item", "background-color");
|
|
11
|
+
$background-color-subtle: sass.fn-naming-var("item", "background-color", "subtle");
|
|
12
|
+
$transition-duration: sass.fn-naming-var("motion", "duration");
|
|
13
|
+
|
|
14
|
+
.#{$skeleton} {
|
|
15
|
+
width: #{$width};
|
|
16
|
+
height: #{$height};
|
|
17
|
+
position: relative;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
border-radius: #{$border-radius};
|
|
20
|
+
background-color: rgba(#{$background-color-subtle}, 0.2);
|
|
21
|
+
display: inline-block;
|
|
22
|
+
line-height: 0;
|
|
23
|
+
transition:
|
|
24
|
+
box-shadow #{$transition-duration} ease,
|
|
25
|
+
border-color #{$transition-duration} ease,
|
|
26
|
+
background-color #{$transition-duration} ease,
|
|
27
|
+
color #{$transition-duration} ease,
|
|
28
|
+
border-radius #{$transition-duration} ease;
|
|
29
|
+
|
|
30
|
+
&::after {
|
|
31
|
+
content: "";
|
|
32
|
+
position: absolute;
|
|
33
|
+
inset: 0;
|
|
34
|
+
transform: translateX(-100%);
|
|
35
|
+
background: linear-gradient(90deg, transparent, rgba(#{$background-color}, 1), transparent);
|
|
36
|
+
opacity: 0.2;
|
|
37
|
+
animation: shimmer 1.2s infinite;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@keyframes shimmer {
|
|
42
|
+
100% {
|
|
43
|
+
transform: translateX(100%);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<style lang="scss" src="./skeleton.scss" scoped></style>
|
|
2
|
+
<template src="./skeleton.html"></template>
|
|
3
|
+
<script lang="ts" setup>
|
|
4
|
+
import { computed, inject } from "vue";
|
|
5
|
+
import { type SkeletonProps } from "./skeleton.type";
|
|
6
|
+
import { property, withPrefix } from "../../utils";
|
|
7
|
+
import { type AppProviderState, APP_PROVIDER_STATE_KEY } from "../app";
|
|
8
|
+
|
|
9
|
+
/// Define
|
|
10
|
+
/// ------------------------------------------------------------
|
|
11
|
+
const props = withDefaults(defineProps<SkeletonProps>(), {
|
|
12
|
+
width: "100%",
|
|
13
|
+
height: "1rem",
|
|
14
|
+
});
|
|
15
|
+
const appState = inject<AppProviderState>(APP_PROVIDER_STATE_KEY);
|
|
16
|
+
|
|
17
|
+
/// Computed
|
|
18
|
+
/// ------------------------------------------------------------
|
|
19
|
+
const skeletonAttrs = computed(() => {
|
|
20
|
+
const shape = props.shape || appState?.shape.value || "";
|
|
21
|
+
const role = props.role || appState?.role.value || "";
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
class: [
|
|
25
|
+
withPrefix(["layer", "item"]),
|
|
26
|
+
withPrefix(["role", role]),
|
|
27
|
+
withPrefix(["shape", shape]),
|
|
28
|
+
withPrefix("skeleton"),
|
|
29
|
+
],
|
|
30
|
+
style: {
|
|
31
|
+
[property(["skeleton", "width"])]:
|
|
32
|
+
props.width + (typeof props.width === "number" ? "px" : ""),
|
|
33
|
+
[property(["skeleton", "height"])]:
|
|
34
|
+
props.height + (typeof props.height === "number" ? "px" : ""),
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<div
|
|
2
|
+
v-bind="switchWrapperAttrs"
|
|
3
|
+
:tabindex="disabled ? -1 : 0"
|
|
4
|
+
role="switch"
|
|
5
|
+
:aria-checked="props.modelValue"
|
|
6
|
+
@click="onSwitch"
|
|
7
|
+
@focus="onFocus"
|
|
8
|
+
@blur="onBlur"
|
|
9
|
+
@keydown="onKeydown"
|
|
10
|
+
>
|
|
11
|
+
<div v-bind="switchAttrs">
|
|
12
|
+
<div v-bind="switchIconAttrs"></div>
|
|
13
|
+
</div>
|
|
14
|
+
<slot />
|
|
15
|
+
</div>
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
@use "@toife/sass-layer-generator" as sass;
|
|
2
|
+
|
|
3
|
+
// Classes
|
|
4
|
+
$switch: sass.fn-naming-prefix("switch");
|
|
5
|
+
$switch-icon: sass.fn-naming-prefix("switch-icon");
|
|
6
|
+
$shape-rounded: sass.fn-naming-prefix("shape-rounded");
|
|
7
|
+
$shape-pill: sass.fn-naming-prefix("shape-pill");
|
|
8
|
+
$switch-wrapper: sass.fn-naming-prefix("switch-wrapper");
|
|
9
|
+
|
|
10
|
+
// Properties - switch track: surface (inactive), item (on); switch icon: item
|
|
11
|
+
$background-color: sass.fn-naming-var("item", "background-color");
|
|
12
|
+
$background-color-hover: sass.fn-naming-var("item", "background-color", "soft");
|
|
13
|
+
$background-color-inactive: sass.fn-naming-var("item", "background-color", "subtle");
|
|
14
|
+
$background-color-disabled: sass.fn-naming-var("item", "background-color", "subtle");
|
|
15
|
+
$background-color-contrast: sass.fn-naming-var("item", "background-color", "contrast");
|
|
16
|
+
$border-color: sass.fn-naming-var("item", "border-color");
|
|
17
|
+
$color-hover: sass.fn-naming-var("item", "color", "strong");
|
|
18
|
+
$transition-duration: sass.fn-naming-var("motion", "duration");
|
|
19
|
+
$border-radius: sass.fn-naming-var("border-radius");
|
|
20
|
+
$spacing-x: sass.fn-naming-var("spacing", "x");
|
|
21
|
+
|
|
22
|
+
.#{$switch-wrapper} {
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
gap: calc(#{$spacing-x} * 2);
|
|
25
|
+
align-items: center;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
box-shadow: none !important;
|
|
28
|
+
|
|
29
|
+
.#{$switch} {
|
|
30
|
+
height: 1.5rem;
|
|
31
|
+
aspect-ratio: 11/6;
|
|
32
|
+
position: relative;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
transition:
|
|
35
|
+
background-color #{$transition-duration} ease,
|
|
36
|
+
color #{$transition-duration} ease,
|
|
37
|
+
border-color #{$transition-duration} ease,
|
|
38
|
+
border-radius #{$transition-duration} ease,
|
|
39
|
+
box-shadow #{$transition-duration} ease;
|
|
40
|
+
border-radius: #{$border-radius};
|
|
41
|
+
|
|
42
|
+
.#{$switch-icon} {
|
|
43
|
+
height: calc(100% - 0.3rem);
|
|
44
|
+
position: absolute;
|
|
45
|
+
top: 0;
|
|
46
|
+
background-color: rgb(#{$background-color-contrast});
|
|
47
|
+
border-radius: #{$border-radius};
|
|
48
|
+
aspect-ratio: 1/1;
|
|
49
|
+
margin: 0.15rem;
|
|
50
|
+
transition:
|
|
51
|
+
background-color #{$transition-duration} ease,
|
|
52
|
+
color #{$transition-duration} ease,
|
|
53
|
+
border-color #{$transition-duration} ease,
|
|
54
|
+
border-radius #{$transition-duration} ease,
|
|
55
|
+
transform #{$transition-duration} ease;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&.#{$shape-rounded} {
|
|
59
|
+
.#{$switch-icon} {
|
|
60
|
+
border-radius: calc(#{$border-radius} - 10%);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&.#{$shape-pill} {
|
|
65
|
+
.#{$switch-icon} {
|
|
66
|
+
border-radius: 50%;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&.disabled {
|
|
72
|
+
cursor: not-allowed;
|
|
73
|
+
|
|
74
|
+
.#{$switch} {
|
|
75
|
+
background-color: rgb(#{$background-color-disabled});
|
|
76
|
+
cursor: not-allowed;
|
|
77
|
+
opacity: 0.3;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&.readonly {
|
|
82
|
+
cursor: default;
|
|
83
|
+
|
|
84
|
+
.#{$switch} {
|
|
85
|
+
cursor: default;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&:not(.on) {
|
|
90
|
+
.#{$switch} {
|
|
91
|
+
background-color: rgb(#{$background-color-inactive});
|
|
92
|
+
|
|
93
|
+
.#{$switch-icon} {
|
|
94
|
+
left: 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&:not(.disabled):not(.readonly):hover {
|
|
98
|
+
background-color: rgb(#{$background-color-hover});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&.on {
|
|
104
|
+
.#{$switch} {
|
|
105
|
+
background-color: rgb(#{$background-color});
|
|
106
|
+
|
|
107
|
+
.#{$switch-icon} {
|
|
108
|
+
right: 0;
|
|
109
|
+
animation: shrink #{$transition-duration} linear;
|
|
110
|
+
animation-fill-mode: forwards;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&.focus {
|
|
116
|
+
&.shadow {
|
|
117
|
+
.#{$switch} {
|
|
118
|
+
box-shadow: 0 0 0 0.25rem rgb(#{$border-color}, 0.25);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@keyframes shrink {
|
|
125
|
+
0% {
|
|
126
|
+
transform: scale(1);
|
|
127
|
+
}
|
|
128
|
+
50% {
|
|
129
|
+
transform: scale(1.5);
|
|
130
|
+
}
|
|
131
|
+
100% {
|
|
132
|
+
transform: scale(1);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Define
|
|
2
|
+
export type SwitchProps = {
|
|
3
|
+
modelValue?: boolean;
|
|
4
|
+
role?: string;
|
|
5
|
+
shape?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
readonly?: boolean;
|
|
8
|
+
shadow?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type SwitchEmit = {
|
|
12
|
+
(e: "update:modelValue", value: boolean): void;
|
|
13
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<style lang="scss" src="./switch.scss" scoped></style>
|
|
2
|
+
<template src="./switch.html"></template>
|
|
3
|
+
<script lang="ts" setup>
|
|
4
|
+
import { computed, inject, ref } from "vue";
|
|
5
|
+
import type { SwitchProps, SwitchEmit } from "./switch.type";
|
|
6
|
+
import { withPrefix } from "../../utils";
|
|
7
|
+
import { type AppProviderState, APP_PROVIDER_STATE_KEY } from "../app";
|
|
8
|
+
|
|
9
|
+
/// Define
|
|
10
|
+
/// ------------------------------------------------------------
|
|
11
|
+
const props = withDefaults(defineProps<SwitchProps>(), {
|
|
12
|
+
modelValue: false,
|
|
13
|
+
readonly: false,
|
|
14
|
+
shadow: undefined,
|
|
15
|
+
});
|
|
16
|
+
const emit = defineEmits<SwitchEmit>();
|
|
17
|
+
const appState = inject<AppProviderState>(APP_PROVIDER_STATE_KEY);
|
|
18
|
+
|
|
19
|
+
/// State
|
|
20
|
+
/// ------------------------------------------------------------
|
|
21
|
+
const isFocused = ref(false);
|
|
22
|
+
|
|
23
|
+
/// Computed
|
|
24
|
+
/// ------------------------------------------------------------
|
|
25
|
+
const role = computed(() => {
|
|
26
|
+
return props.role || appState?.role.value || "";
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const shadow = computed(() => {
|
|
30
|
+
return (props?.shadow !== undefined ? props.shadow : appState?.shadow.value) ?? false;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const switchWrapperAttrs = computed(() => {
|
|
34
|
+
return {
|
|
35
|
+
class: [
|
|
36
|
+
withPrefix("switch-wrapper"),
|
|
37
|
+
{
|
|
38
|
+
disabled: props.disabled,
|
|
39
|
+
readonly: props.readonly,
|
|
40
|
+
shadow: shadow.value,
|
|
41
|
+
focus: isFocused.value,
|
|
42
|
+
on: props.modelValue,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const switchAttrs = computed(() => {
|
|
49
|
+
const shape = props.shape || appState?.shape.value || "";
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
class: [
|
|
53
|
+
withPrefix(["layer", "item"]),
|
|
54
|
+
withPrefix([
|
|
55
|
+
"role",
|
|
56
|
+
props.modelValue && !props.disabled ? role.value : appState?.role.value || "",
|
|
57
|
+
]),
|
|
58
|
+
withPrefix(["shape", shape]),
|
|
59
|
+
withPrefix("switch"),
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const switchIconAttrs = computed(() => {
|
|
65
|
+
return {
|
|
66
|
+
class: [withPrefix("switch-icon")],
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/// Methods
|
|
71
|
+
/// ------------------------------------------------------------
|
|
72
|
+
const onSwitch = () => {
|
|
73
|
+
if (props.disabled || props.readonly) return;
|
|
74
|
+
emit("update:modelValue", !props.modelValue);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const onFocus = () => {
|
|
78
|
+
if (props.disabled || props.readonly) return;
|
|
79
|
+
isFocused.value = true;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const onBlur = () => {
|
|
83
|
+
if (props.disabled || props.readonly) return;
|
|
84
|
+
isFocused.value = false;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const onKeydown = (e: KeyboardEvent) => {
|
|
88
|
+
if (e.key !== " " && e.key !== "Enter") return;
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
onSwitch();
|
|
91
|
+
};
|
|
92
|
+
</script>
|