@toife/vue 3.1.5 → 3.2.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 +1 -52
- 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 +46 -0
- package/dist/components/decision-modal/decision-modal.vue.d.ts +16 -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 +32 -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 +11 -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 +17 -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/factory.d.ts +38 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +3491 -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 +40 -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/types.d.ts +4 -0
- package/package.json +24 -14
- package/src/components/action/action.composable.ts +0 -32
- package/src/components/action/action.html +0 -25
- package/src/components/action/action.scss +0 -106
- package/src/components/action/action.type.ts +0 -44
- package/src/components/action/action.vue +0 -72
- package/src/components/action/index.ts +0 -9
- package/src/components/app/app.constants.ts +0 -1
- package/src/components/app/app.html +0 -24
- package/src/components/app/app.scss +0 -27
- package/src/components/app/app.type.ts +0 -36
- package/src/components/app/app.vue +0 -52
- package/src/components/app/index.ts +0 -3
- package/src/components/avatar/avatar.html +0 -3
- package/src/components/avatar/avatar.scss +0 -45
- package/src/components/avatar/avatar.type.ts +0 -8
- package/src/components/avatar/avatar.vue +0 -44
- package/src/components/avatar/index.ts +0 -2
- package/src/components/button/button.html +0 -6
- package/src/components/button/button.scss +0 -116
- package/src/components/button/button.type.ts +0 -16
- package/src/components/button/button.vue +0 -61
- package/src/components/button/index.ts +0 -2
- package/src/components/cable/cable.constants.ts +0 -1
- package/src/components/cable/cable.html +0 -3
- package/src/components/cable/cable.scss +0 -37
- package/src/components/cable/cable.type.ts +0 -11
- package/src/components/cable/cable.vue +0 -33
- package/src/components/cable/index.ts +0 -3
- package/src/components/card/card/card.constants.ts +0 -1
- package/src/components/card/card/card.html +0 -3
- package/src/components/card/card/card.scss +0 -37
- package/src/components/card/card/card.type.ts +0 -14
- package/src/components/card/card/card.vue +0 -62
- package/src/components/card/card/index.ts +0 -3
- package/src/components/card/card-body/card-body.html +0 -3
- package/src/components/card/card-body/card-body.scss +0 -23
- package/src/components/card/card-body/card-body.vue +0 -9
- 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.scss +0 -32
- package/src/components/card/card-footer/card-footer.vue +0 -25
- 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.scss +0 -32
- package/src/components/card/card-header/card-header.vue +0 -25
- 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.scss +0 -150
- package/src/components/checkbox/checkbox.type.ts +0 -21
- package/src/components/checkbox/checkbox.vue +0 -80
- package/src/components/checkbox/index.ts +0 -2
- package/src/components/collapse/collapse.html +0 -16
- package/src/components/collapse/collapse.scss +0 -59
- package/src/components/collapse/collapse.type.ts +0 -11
- package/src/components/collapse/collapse.vue +0 -127
- package/src/components/collapse/index.ts +0 -2
- package/src/components/container/container.html +0 -1
- package/src/components/container/container.scss +0 -10
- package/src/components/container/container.vue +0 -10
- 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.scss +0 -144
- package/src/components/decision-modal/decision-modal.type.ts +0 -35
- package/src/components/decision-modal/decision-modal.vue +0 -96
- package/src/components/decision-modal/index.ts +0 -9
- package/src/components/divider/divider.html +0 -1
- package/src/components/divider/divider.scss +0 -29
- package/src/components/divider/divider.type.ts +0 -6
- package/src/components/divider/divider.vue +0 -31
- package/src/components/divider/index.ts +0 -2
- package/src/components/dropdown/dropdown.html +0 -6
- package/src/components/dropdown/dropdown.scss +0 -71
- package/src/components/dropdown/dropdown.type.ts +0 -22
- package/src/components/dropdown/dropdown.vue +0 -111
- package/src/components/dropdown/index.ts +0 -2
- package/src/components/field/field.html +0 -12
- package/src/components/field/field.type.ts +0 -43
- package/src/components/field/field.vue +0 -86
- package/src/components/field/index.ts +0 -2
- package/src/components/field/outline/index.ts +0 -1
- package/src/components/field/outline/outline.html +0 -36
- package/src/components/field/outline/outline.scss +0 -282
- package/src/components/field/outline/outline.vue +0 -294
- package/src/components/form-group/form-group.html +0 -3
- package/src/components/form-group/form-group.scss +0 -91
- package/src/components/form-group/form-group.type.ts +0 -5
- package/src/components/form-group/form-group.vue +0 -21
- package/src/components/form-group/index.ts +0 -2
- package/src/components/gesture-indicator/gesture-indicator.html +0 -1
- package/src/components/gesture-indicator/gesture-indicator.scss +0 -47
- package/src/components/gesture-indicator/gesture-indicator.type.ts +0 -5
- package/src/components/gesture-indicator/gesture-indicator.vue +0 -31
- package/src/components/gesture-indicator/index.ts +0 -1
- package/src/components/image/image.html +0 -1
- package/src/components/image/image.type.ts +0 -5
- package/src/components/image/image.vue +0 -29
- package/src/components/image/index.ts +0 -2
- package/src/components/index.ts +0 -31
- package/src/components/layout/flex/flex.html +0 -1
- package/src/components/layout/flex/flex.scss +0 -57
- package/src/components/layout/flex/flex.type.ts +0 -15
- package/src/components/layout/flex/flex.vue +0 -34
- package/src/components/layout/flex/index.ts +0 -2
- package/src/components/layout/flex-item/flex-item.html +0 -1
- package/src/components/layout/flex-item/flex-item.scss +0 -48
- package/src/components/layout/flex-item/flex-item.type.ts +0 -11
- package/src/components/layout/flex-item/flex-item.vue +0 -27
- package/src/components/layout/flex-item/index.ts +0 -2
- package/src/components/layout/grid/grid.html +0 -1
- package/src/components/layout/grid/grid.scss +0 -51
- package/src/components/layout/grid/grid.type.ts +0 -12
- package/src/components/layout/grid/grid.vue +0 -32
- package/src/components/layout/grid/index.ts +0 -2
- package/src/components/layout/grid-item/grid-item.html +0 -1
- package/src/components/layout/grid-item/grid-item.scss +0 -49
- package/src/components/layout/grid-item/grid-item.type.ts +0 -14
- package/src/components/layout/grid-item/grid-item.vue +0 -27
- package/src/components/layout/grid-item/index.ts +0 -2
- package/src/components/layout/index.ts +0 -4
- package/src/components/modal/index.ts +0 -2
- package/src/components/modal/modal.html +0 -20
- package/src/components/modal/modal.scss +0 -80
- package/src/components/modal/modal.type.ts +0 -21
- package/src/components/modal/modal.vue +0 -251
- package/src/components/page/index.ts +0 -1
- package/src/components/page/page.html +0 -3
- package/src/components/page/page.scss +0 -17
- package/src/components/page/page.vue +0 -10
- package/src/components/present/index.ts +0 -3
- package/src/components/present/present.composable.ts +0 -22
- package/src/components/present/present.html +0 -9
- package/src/components/present/present.scss +0 -81
- package/src/components/present/present.type.ts +0 -26
- package/src/components/present/present.vue +0 -198
- package/src/components/radio/index.ts +0 -2
- package/src/components/radio/radio/index.ts +0 -2
- package/src/components/radio/radio/radio.html +0 -11
- package/src/components/radio/radio/radio.scss +0 -142
- package/src/components/radio/radio/radio.type.ts +0 -15
- package/src/components/radio/radio/radio.vue +0 -87
- package/src/components/radio/radio-group/index.ts +0 -7
- package/src/components/radio/radio-group/radio-group.constants.ts +0 -1
- package/src/components/radio/radio-group/radio-group.html +0 -3
- package/src/components/radio/radio-group/radio-group.scss +0 -16
- package/src/components/radio/radio-group/radio-group.type.ts +0 -28
- package/src/components/radio/radio-group/radio-group.vue +0 -57
- package/src/components/refresher/index.ts +0 -2
- package/src/components/refresher/refresher.html +0 -3
- package/src/components/refresher/refresher.scss +0 -18
- package/src/components/refresher/refresher.type.ts +0 -16
- package/src/components/refresher/refresher.vue +0 -123
- package/src/components/route/index.ts +0 -5
- package/src/components/route/route-navigator/index.ts +0 -2
- package/src/components/route/route-navigator/route-navigator.html +0 -19
- package/src/components/route/route-navigator/route-navigator.scss +0 -127
- package/src/components/route/route-navigator/route-navigator.type.ts +0 -36
- package/src/components/route/route-navigator/route-navigator.vue +0 -275
- 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 -3
- package/src/components/route/route-provider/route-provider.constant.ts +0 -1
- package/src/components/route/route-provider/route-provider.html +0 -1
- package/src/components/route/route-provider/route-provider.type.ts +0 -10
- package/src/components/route/route-provider/route-provider.vue +0 -20
- package/src/components/route/route-wrapper/index.ts +0 -3
- 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.type.ts +0 -3
- package/src/components/route/route-wrapper/route-wrapper.vue +0 -45
- package/src/components/route/route.type.ts +0 -7
- package/src/components/route/route.util.ts +0 -9
- package/src/components/segmented-field/index.ts +0 -7
- package/src/components/segmented-field/segmented-field.html +0 -17
- package/src/components/segmented-field/segmented-field.scss +0 -53
- package/src/components/segmented-field/segmented-field.type.ts +0 -29
- package/src/components/segmented-field/segmented-field.vue +0 -145
- package/src/components/select/index.ts +0 -2
- package/src/components/select/select.html +0 -29
- package/src/components/select/select.scss +0 -129
- package/src/components/select/select.type.ts +0 -45
- package/src/components/select/select.vue +0 -119
- package/src/components/skeleton/index.ts +0 -2
- package/src/components/skeleton/skeleton.html +0 -1
- package/src/components/skeleton/skeleton.scss +0 -52
- package/src/components/skeleton/skeleton.type.ts +0 -7
- package/src/components/skeleton/skeleton.vue +0 -38
- package/src/components/slide-range/index.ts +0 -2
- package/src/components/slide-range/slide-range.html +0 -19
- package/src/components/slide-range/slide-range.scss +0 -161
- package/src/components/slide-range/slide-range.type.ts +0 -16
- package/src/components/slide-range/slide-range.vue +0 -229
- package/src/components/switch/index.ts +0 -2
- package/src/components/switch/switch.html +0 -14
- package/src/components/switch/switch.scss +0 -128
- package/src/components/switch/switch.type.ts +0 -19
- package/src/components/switch/switch.vue +0 -97
- package/src/components/tabs/index.ts +0 -2
- package/src/components/tabs/tab/index.ts +0 -2
- package/src/components/tabs/tab/tab.html +0 -5
- package/src/components/tabs/tab/tab.scss +0 -13
- package/src/components/tabs/tab/tab.type.ts +0 -5
- package/src/components/tabs/tab/tab.vue +0 -40
- package/src/components/tabs/tabs/index.ts +0 -10
- package/src/components/tabs/tabs/tabs.constants.ts +0 -1
- package/src/components/tabs/tabs/tabs.html +0 -3
- package/src/components/tabs/tabs/tabs.scss +0 -341
- package/src/components/tabs/tabs/tabs.type.ts +0 -39
- package/src/components/tabs/tabs/tabs.vue +0 -177
- package/src/components/toast/index.ts +0 -4
- package/src/components/toast/toast/index.ts +0 -1
- package/src/components/toast/toast/toast.html +0 -9
- package/src/components/toast/toast/toast.scss +0 -61
- package/src/components/toast/toast/toast.vue +0 -34
- 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.scss +0 -42
- package/src/components/toast/toast-content/toast-content.vue +0 -53
- package/src/components/toast/toast.composable.ts +0 -22
- package/src/components/toast/toast.type.ts +0 -25
- package/src/components/toolbar/index.ts +0 -2
- package/src/components/toolbar/toolbar.html +0 -3
- package/src/components/toolbar/toolbar.scss +0 -64
- package/src/components/toolbar/toolbar.type.ts +0 -7
- package/src/components/toolbar/toolbar.vue +0 -41
- package/src/env.d.ts +0 -7
- package/src/factory.ts +0 -152
- package/src/index.ts +0 -4
- package/src/type.ts +0 -4
- package/src/utils/element.md +0 -33
- package/src/utils/element.ts +0 -22
- package/src/utils/events.md +0 -29
- package/src/utils/events.ts +0 -18
- package/src/utils/index.ts +0 -3
- package/src/utils/style/index.ts +0 -57
- package/src/utils/style.md +0 -49
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
<style lang="scss" src="./select.scss" scoped></style>
|
|
2
|
-
<template src="./select.html"></template>
|
|
3
|
-
<script lang="ts" setup>
|
|
4
|
-
import { computed, inject, ref } from "vue";
|
|
5
|
-
import { type SelectOption, type SelectProps, type SelectEmit } from "./select.type";
|
|
6
|
-
import { cssProperty, cssPrefix } from "../../utils";
|
|
7
|
-
import { type AppProviderState, APP_PROVIDER_STATE_KEY } from "../app";
|
|
8
|
-
import { Field } from "../field";
|
|
9
|
-
import { Dropdown } from "../dropdown";
|
|
10
|
-
|
|
11
|
-
// Component setup (props, emits, injects)
|
|
12
|
-
// ----------------------------------------------------------------------------
|
|
13
|
-
const props = withDefaults(defineProps<SelectProps>(), {
|
|
14
|
-
modelValue: "",
|
|
15
|
-
type: "text",
|
|
16
|
-
size: "standard",
|
|
17
|
-
disabled: false,
|
|
18
|
-
message: "",
|
|
19
|
-
help: "",
|
|
20
|
-
variant: "outline",
|
|
21
|
-
placeholder: "",
|
|
22
|
-
shadow: undefined,
|
|
23
|
-
direction: undefined,
|
|
24
|
-
options: () => [] as Array<SelectOption>,
|
|
25
|
-
});
|
|
26
|
-
const appState = inject<AppProviderState>(APP_PROVIDER_STATE_KEY);
|
|
27
|
-
const emit = defineEmits<SelectEmit>();
|
|
28
|
-
const visible = ref(false);
|
|
29
|
-
|
|
30
|
-
// Computed properties
|
|
31
|
-
// ----------------------------------------------------------------------------
|
|
32
|
-
const role = computed(() => {
|
|
33
|
-
return props.role || appState?.role.value || "";
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const direction = computed(() => {
|
|
37
|
-
return props.direction || appState?.direction?.value || "left";
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const shadow = computed(() => {
|
|
41
|
-
return props.shadow || appState?.shadow.value || false;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const shape = computed(() => {
|
|
45
|
-
return props.shape || appState?.shape.value || "";
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const selectAttrs = computed(() => {
|
|
49
|
-
return {
|
|
50
|
-
class: [
|
|
51
|
-
cssPrefix(["layer", "select"]),
|
|
52
|
-
cssPrefix(["role", role.value]),
|
|
53
|
-
cssPrefix("select"),
|
|
54
|
-
cssPrefix(["direction", direction.value]),
|
|
55
|
-
cssPrefix(["size", props.size]),
|
|
56
|
-
{
|
|
57
|
-
disabled: props.disabled,
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const dropdownAttrs = computed(() => {
|
|
64
|
-
return {
|
|
65
|
-
role: role.value,
|
|
66
|
-
direction: direction.value,
|
|
67
|
-
shadow: shadow.value,
|
|
68
|
-
shape: shape.value,
|
|
69
|
-
disabled: props.disabled,
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const fieldAttrs = computed(() => {
|
|
74
|
-
const propsValue = props.modelValue || props.value;
|
|
75
|
-
let val: string[] = [];
|
|
76
|
-
if (propsValue) val = typeof propsValue === "string" ? [propsValue] : (propsValue as string[]);
|
|
77
|
-
const values: string[] = props.options
|
|
78
|
-
.filter((option): option is SelectOption => (val || []).includes(option.value))
|
|
79
|
-
.map((option) => option.label ?? option.value);
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
modelValue: values.join(","),
|
|
83
|
-
size: props.size,
|
|
84
|
-
variant: props.variant,
|
|
85
|
-
placeholder: props.placeholder,
|
|
86
|
-
direction: direction.value,
|
|
87
|
-
role: role.value,
|
|
88
|
-
shape: shape.value,
|
|
89
|
-
readonly: true,
|
|
90
|
-
disabled: props.disabled,
|
|
91
|
-
shadow: shadow.value,
|
|
92
|
-
};
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const selectIconAttrs = computed(() => ({
|
|
96
|
-
class: [cssPrefix("select-icon")],
|
|
97
|
-
}));
|
|
98
|
-
|
|
99
|
-
const selectOptionAttrs = computed(() => ({
|
|
100
|
-
class: [cssPrefix("select-option")],
|
|
101
|
-
}));
|
|
102
|
-
|
|
103
|
-
const selectMessageAttrs = computed(() => ({
|
|
104
|
-
class: [cssPrefix("select-message")],
|
|
105
|
-
}));
|
|
106
|
-
|
|
107
|
-
const selectHelpAttrs = computed(() => ({
|
|
108
|
-
class: [cssPrefix("select-help")],
|
|
109
|
-
}));
|
|
110
|
-
|
|
111
|
-
// Methods
|
|
112
|
-
// ----------------------------------------------------------------------------
|
|
113
|
-
const pickOption = (option: SelectOption) => {
|
|
114
|
-
if (option.disabled || option.value === undefined) return;
|
|
115
|
-
emit("update:modelValue", option.value);
|
|
116
|
-
emit("select", option);
|
|
117
|
-
visible.value = false;
|
|
118
|
-
};
|
|
119
|
-
</script>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<div v-bind="skeletonAttrs"></div>
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
@use "@toife/sass-layer" as sass;
|
|
2
|
-
|
|
3
|
-
// Classes
|
|
4
|
-
$skeleton: sass.fn-naming-prefix("skeleton");
|
|
5
|
-
|
|
6
|
-
// Property name - layer: skeleton
|
|
7
|
-
$skeleton-width: sass.fn-naming-var("skeleton", "width");
|
|
8
|
-
$skeleton-height: sass.fn-naming-var("skeleton", "height");
|
|
9
|
-
$skeleton-background-color: sass.fn-naming-var("skeleton", "background-color");
|
|
10
|
-
|
|
11
|
-
$radius-ratio: sass.fn-naming-var("radius-ratio");
|
|
12
|
-
$transition-duration: sass.fn-naming-var("motion", "duration");
|
|
13
|
-
$radius-size: sass.fn-naming-var("radius-size");
|
|
14
|
-
$border-radius: calc(#{$radius-size} * #{$radius-ratio});
|
|
15
|
-
|
|
16
|
-
.#{$skeleton} {
|
|
17
|
-
width: #{$skeleton-width};
|
|
18
|
-
height: #{$skeleton-height};
|
|
19
|
-
position: relative;
|
|
20
|
-
overflow: hidden;
|
|
21
|
-
border-radius: #{$border-radius};
|
|
22
|
-
background-color: rgba(#{$skeleton-background-color}, 0.2);
|
|
23
|
-
display: inline-block;
|
|
24
|
-
line-height: 0;
|
|
25
|
-
transition:
|
|
26
|
-
box-shadow #{$transition-duration} ease,
|
|
27
|
-
border-color #{$transition-duration} ease,
|
|
28
|
-
background-color #{$transition-duration} ease,
|
|
29
|
-
color #{$transition-duration} ease,
|
|
30
|
-
border-radius #{$transition-duration} ease;
|
|
31
|
-
|
|
32
|
-
&::after {
|
|
33
|
-
content: "";
|
|
34
|
-
position: absolute;
|
|
35
|
-
inset: 0;
|
|
36
|
-
transform: translateX(-100%);
|
|
37
|
-
background: linear-gradient(
|
|
38
|
-
90deg,
|
|
39
|
-
transparent,
|
|
40
|
-
rgba(#{$skeleton-background-color}, 1),
|
|
41
|
-
transparent
|
|
42
|
-
);
|
|
43
|
-
opacity: 0.2;
|
|
44
|
-
animation: shimmer 1.2s infinite;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@keyframes shimmer {
|
|
49
|
-
100% {
|
|
50
|
-
transform: translateX(100%);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
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 { cssProperty, cssPrefix } from "../../utils";
|
|
7
|
-
import { type AppProviderState, APP_PROVIDER_STATE_KEY } from "../app";
|
|
8
|
-
|
|
9
|
-
// Component setup (props, emits, injects)
|
|
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 properties
|
|
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
|
-
cssPrefix(["layer", "skeleton"]),
|
|
26
|
-
cssPrefix(["role", role]),
|
|
27
|
-
cssPrefix(["shape", shape]),
|
|
28
|
-
cssPrefix("skeleton"),
|
|
29
|
-
],
|
|
30
|
-
style: {
|
|
31
|
-
[cssProperty(["skeleton", "width"])]:
|
|
32
|
-
props.width + (typeof props.width === "number" ? "px" : ""),
|
|
33
|
-
[cssProperty(["skeleton", "height"])]:
|
|
34
|
-
props.height + (typeof props.height === "number" ? "px" : ""),
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
</script>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<div v-bind="slideRangeAttrs">
|
|
2
|
-
<div v-bind="trackContainerAttrs" ref="container">
|
|
3
|
-
<div v-bind="trackBodyAttrs">
|
|
4
|
-
<div v-bind="trackBackAttrs" @pointerup="onClickPath"></div>
|
|
5
|
-
<div v-bind="trackFrontAttrs" @pointerup="onClickPath"></div>
|
|
6
|
-
<div
|
|
7
|
-
v-for="value in ranges"
|
|
8
|
-
:key="value"
|
|
9
|
-
v-bind="nodeAttrs(value)"
|
|
10
|
-
@pointerup="onNodeSelect(value)"
|
|
11
|
-
></div>
|
|
12
|
-
</div>
|
|
13
|
-
|
|
14
|
-
<div v-bind="thumbAttrs" ref="point">
|
|
15
|
-
<div v-bind="thumbInnerAttrs"></div>
|
|
16
|
-
<span v-if="percent > 0 && isShowTooltip" v-bind="tooltipAttrs">{{ displayValue }}</span>
|
|
17
|
-
</div>
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
@use "@toife/sass-layer" as sass;
|
|
2
|
-
|
|
3
|
-
// Class name
|
|
4
|
-
$slide-range: sass.fn-naming-prefix("slide-range");
|
|
5
|
-
$slide-range-track-container: sass.fn-naming-prefix("slide-range-track-container");
|
|
6
|
-
$slide-range-track-body: sass.fn-naming-prefix("slide-range-track-body");
|
|
7
|
-
$slide-range-track: sass.fn-naming-prefix("slide-range-track");
|
|
8
|
-
$slide-range-node: sass.fn-naming-prefix("slide-range-node");
|
|
9
|
-
$slide-range-thumb: sass.fn-naming-prefix("slide-range-thumb");
|
|
10
|
-
$slide-range-thumb-inner: sass.fn-naming-prefix("slide-range-thumb-inner");
|
|
11
|
-
$slide-range-tooltip: sass.fn-naming-prefix("slide-range-tooltip");
|
|
12
|
-
$shape-pill: sass.fn-naming-prefix("shape-pill");
|
|
13
|
-
$shape-rounded: sass.fn-naming-prefix("shape-rounded");
|
|
14
|
-
$shape-flat: sass.fn-naming-prefix("shape-flat");
|
|
15
|
-
$property-border-radius: sass.fn-naming-property("border-radius");
|
|
16
|
-
|
|
17
|
-
// Property name
|
|
18
|
-
$spacing-x: sass.fn-naming-var("spacing", "x");
|
|
19
|
-
$border-width: sass.fn-naming-var("stroke", "width");
|
|
20
|
-
$radius-ratio: sass.fn-naming-var("radius-ratio");
|
|
21
|
-
$radius-size: sass.fn-naming-var("radius-size");
|
|
22
|
-
|
|
23
|
-
$slide-range-background-color: sass.fn-naming-var("slide-range", "background-color");
|
|
24
|
-
$slide-range-background-color-hover: sass.fn-naming-var("slide-range", "background-color", "hover");
|
|
25
|
-
$slide-range-background-color-focus: sass.fn-naming-var("slide-range", "background-color", "focus");
|
|
26
|
-
$slide-range-background-color-active: sass.fn-naming-var(
|
|
27
|
-
"slide-range",
|
|
28
|
-
"background-color",
|
|
29
|
-
"active"
|
|
30
|
-
);
|
|
31
|
-
$slide-range-border-color: sass.fn-naming-var("slide-range", "border-color");
|
|
32
|
-
$slide-range-border-color-hover: sass.fn-naming-var("slide-range", "border-color", "hover");
|
|
33
|
-
$slide-range-border-color-focus: sass.fn-naming-var("slide-range", "border-color", "focus");
|
|
34
|
-
$slide-range-border-color-active: sass.fn-naming-var("slide-range", "border-color", "active");
|
|
35
|
-
$slide-range-percent: sass.fn-naming-var("slide-range", "percent");
|
|
36
|
-
$slide-range-position: sass.fn-naming-var("slide-range", "position");
|
|
37
|
-
$slide-range-tooltip-background-color: sass.fn-naming-var(
|
|
38
|
-
"slide-range",
|
|
39
|
-
"tooltip-background-color"
|
|
40
|
-
);
|
|
41
|
-
$slide-range-tooltip-color: sass.fn-naming-var("slide-range", "tooltip-color");
|
|
42
|
-
|
|
43
|
-
.#{$slide-range} {
|
|
44
|
-
display: flex;
|
|
45
|
-
justify-content: center;
|
|
46
|
-
align-items: center;
|
|
47
|
-
width: 100%;
|
|
48
|
-
|
|
49
|
-
&.#{$shape-pill} {
|
|
50
|
-
#{$property-border-radius}: 50%;
|
|
51
|
-
|
|
52
|
-
.#{$slide-range-tooltip} {
|
|
53
|
-
border-radius: 3px;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&.#{$shape-rounded} {
|
|
58
|
-
#{$property-border-radius}: 2px;
|
|
59
|
-
|
|
60
|
-
.#{$slide-range-tooltip} {
|
|
61
|
-
border-radius: 2px;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
&.#{$shape-flat} {
|
|
66
|
-
#{$property-border-radius}: 0;
|
|
67
|
-
|
|
68
|
-
.#{$slide-range-tooltip} {
|
|
69
|
-
border-radius: 0;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
&.disabled,
|
|
74
|
-
&.readonly {
|
|
75
|
-
opacity: 0.6;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
&.disabled {
|
|
79
|
-
cursor: not-allowed;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.#{$slide-range-track-container} {
|
|
83
|
-
position: relative;
|
|
84
|
-
margin: calc(#{$spacing-x} * 2) #{$spacing-x};
|
|
85
|
-
width: calc(100% - #{$spacing-x} * 2);
|
|
86
|
-
height: 1rem;
|
|
87
|
-
touch-action: none;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.#{$slide-range-track-body} {
|
|
91
|
-
position: relative;
|
|
92
|
-
width: 100%;
|
|
93
|
-
height: 1px;
|
|
94
|
-
top: 50%;
|
|
95
|
-
transform: translateY(-50%);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.#{$slide-range-track} {
|
|
99
|
-
position: absolute;
|
|
100
|
-
top: 0;
|
|
101
|
-
left: 0;
|
|
102
|
-
height: 1px;
|
|
103
|
-
|
|
104
|
-
&.back {
|
|
105
|
-
width: 100%;
|
|
106
|
-
background-color: rgba(#{$slide-range-border-color});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
&.front {
|
|
110
|
-
width: #{$slide-range-percent};
|
|
111
|
-
background-color: rgba(#{$slide-range-border-color-active});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.#{$slide-range-node} {
|
|
116
|
-
position: absolute;
|
|
117
|
-
left: #{$slide-range-position};
|
|
118
|
-
top: -3.5px;
|
|
119
|
-
height: 8px;
|
|
120
|
-
width: 8px;
|
|
121
|
-
border-radius: calc(min(8px, #{$radius-size}) * #{$radius-ratio});
|
|
122
|
-
transform: rotate(45deg);
|
|
123
|
-
background-color: rgba(#{$slide-range-background-color});
|
|
124
|
-
border: 1px solid rgba(#{$slide-range-border-color});
|
|
125
|
-
|
|
126
|
-
&.active {
|
|
127
|
-
border-color: rgba(#{$slide-range-border-color-active});
|
|
128
|
-
background-color: rgba(#{$slide-range-background-color-active});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.#{$slide-range-thumb} {
|
|
133
|
-
position: absolute;
|
|
134
|
-
left: #{$slide-range-percent};
|
|
135
|
-
top: 2px;
|
|
136
|
-
height: 100%;
|
|
137
|
-
|
|
138
|
-
.#{$slide-range-thumb-inner} {
|
|
139
|
-
position: absolute;
|
|
140
|
-
width: 12px;
|
|
141
|
-
height: 12px;
|
|
142
|
-
border: 1px solid rgba(#{$slide-range-border-color-active});
|
|
143
|
-
border-radius: calc(12px * #{$radius-ratio});
|
|
144
|
-
background-color: rgba(#{$slide-range-background-color});
|
|
145
|
-
transform: translateX(calc(-50% + 2px)) rotate(45deg);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.#{$slide-range-tooltip} {
|
|
149
|
-
position: absolute;
|
|
150
|
-
top: -23px;
|
|
151
|
-
left: calc(50% + 0.15rem);
|
|
152
|
-
transform: translateX(-50%);
|
|
153
|
-
padding: 0 calc(#{$spacing-x} * 0.5);
|
|
154
|
-
font-size: 0.6rem;
|
|
155
|
-
line-height: 0.9rem;
|
|
156
|
-
white-space: nowrap;
|
|
157
|
-
color: rgba(#{$slide-range-tooltip-color});
|
|
158
|
-
background-color: rgba(#{$slide-range-tooltip-background-color});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export type SlideRangeProps = {
|
|
2
|
-
modelValue?: string | number;
|
|
3
|
-
min?: number;
|
|
4
|
-
max?: number;
|
|
5
|
-
step?: number;
|
|
6
|
-
unit?: string;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
readonly?: boolean;
|
|
9
|
-
role?: string;
|
|
10
|
-
shape?: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type SlideRangeEmit = {
|
|
14
|
-
(e: "update:modelValue", value: string): void;
|
|
15
|
-
(e: "change", value: string): void;
|
|
16
|
-
};
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
<style lang="scss" src="./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, onMounted, onUnmounted, ref } from "vue";
|
|
6
|
-
import { cssProperty, cssPrefix } from "../../utils";
|
|
7
|
-
import type { SlideRangeProps, SlideRangeEmit } from "./slide-range.type";
|
|
8
|
-
import { type AppProviderState, APP_PROVIDER_STATE_KEY } from "../app";
|
|
9
|
-
import { inject } from "vue";
|
|
10
|
-
|
|
11
|
-
// Component setup (props, emits, injects)
|
|
12
|
-
// ----------------------------------------------------------------------------
|
|
13
|
-
const props = withDefaults(defineProps<SlideRangeProps>(), {
|
|
14
|
-
modelValue: "",
|
|
15
|
-
min: 0,
|
|
16
|
-
max: 100,
|
|
17
|
-
step: 25,
|
|
18
|
-
unit: "",
|
|
19
|
-
disabled: false,
|
|
20
|
-
readonly: false,
|
|
21
|
-
});
|
|
22
|
-
const emit = defineEmits<SlideRangeEmit>();
|
|
23
|
-
const appState = inject<AppProviderState>(APP_PROVIDER_STATE_KEY);
|
|
24
|
-
|
|
25
|
-
// Reactive state
|
|
26
|
-
// ----------------------------------------------------------------------------
|
|
27
|
-
const point = ref<HTMLElement | null>(null);
|
|
28
|
-
const container = ref<HTMLElement | null>(null);
|
|
29
|
-
const isShowTooltip = ref(false);
|
|
30
|
-
let tooltipTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
31
|
-
let gestureCleanup: { destroy: () => void } | null = null;
|
|
32
|
-
let dragStartPercent = 0;
|
|
33
|
-
|
|
34
|
-
// Computed properties
|
|
35
|
-
// ----------------------------------------------------------------------------
|
|
36
|
-
const normalizedValue = computed(() => {
|
|
37
|
-
if (typeof props.modelValue === "number") return props.modelValue;
|
|
38
|
-
if (typeof props.modelValue !== "string") return props.min;
|
|
39
|
-
const parsed = Number.parseFloat(props.modelValue);
|
|
40
|
-
if (Number.isNaN(parsed)) return props.min;
|
|
41
|
-
return parsed;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const percent = computed(() => {
|
|
45
|
-
const delta = props.max - props.min;
|
|
46
|
-
if (delta <= 0) return 0;
|
|
47
|
-
const p = ((normalizedValue.value - props.min) / delta) * 100;
|
|
48
|
-
return Math.max(0, Math.min(100, Math.round(p)));
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const ranges = computed(() => {
|
|
52
|
-
const { min, max, step } = props;
|
|
53
|
-
if (step <= 0 || max < min) return [min, max];
|
|
54
|
-
|
|
55
|
-
const result: number[] = [];
|
|
56
|
-
for (let value = min; value <= max; value += step) {
|
|
57
|
-
result.push(value);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (result.at(-1) !== max) {
|
|
61
|
-
result.push(max);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return result;
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const displayValue = computed(() => {
|
|
68
|
-
const value = getValueFromPercent(percent.value);
|
|
69
|
-
return formatValue(value);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const slideRangeAttrs = computed(() => {
|
|
73
|
-
const role = props.role || appState?.role.value || "";
|
|
74
|
-
const shape = props.shape || appState?.shape.value || "";
|
|
75
|
-
return {
|
|
76
|
-
class: [
|
|
77
|
-
cssPrefix("slide-range"),
|
|
78
|
-
cssPrefix(["layer", "slide-range"]),
|
|
79
|
-
cssPrefix(["role", role]),
|
|
80
|
-
cssPrefix(["shape", shape]),
|
|
81
|
-
{
|
|
82
|
-
disabled: props.disabled,
|
|
83
|
-
readonly: props.readonly,
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const trackContainerAttrs = {
|
|
90
|
-
class: [cssPrefix("slide-range-track-container")],
|
|
91
|
-
} as const;
|
|
92
|
-
|
|
93
|
-
const trackBodyAttrs = {
|
|
94
|
-
class: [cssPrefix("slide-range-track-body")],
|
|
95
|
-
} as const;
|
|
96
|
-
|
|
97
|
-
const trackBackAttrs = {
|
|
98
|
-
class: [cssPrefix("slide-range-track"), "back"],
|
|
99
|
-
} as const;
|
|
100
|
-
|
|
101
|
-
const trackFrontAttrs = computed(() => {
|
|
102
|
-
return {
|
|
103
|
-
class: [cssPrefix("slide-range-track"), "front"],
|
|
104
|
-
style: {
|
|
105
|
-
[cssProperty(["slide-range", "percent"])]: `${percent.value}%`,
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
const thumbAttrs = computed(() => {
|
|
111
|
-
return {
|
|
112
|
-
class: [cssPrefix("slide-range-thumb")],
|
|
113
|
-
style: {
|
|
114
|
-
[cssProperty(["slide-range", "percent"])]: `${percent.value}%`,
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const thumbInnerAttrs = {
|
|
120
|
-
class: [cssPrefix("slide-range-thumb-inner")],
|
|
121
|
-
} as const;
|
|
122
|
-
|
|
123
|
-
const tooltipAttrs = {
|
|
124
|
-
class: [cssPrefix("slide-range-tooltip")],
|
|
125
|
-
} as const;
|
|
126
|
-
|
|
127
|
-
// Methods
|
|
128
|
-
// ----------------------------------------------------------------------------
|
|
129
|
-
const nodeAttrs = (value: number) => {
|
|
130
|
-
const nodePercent = getPercentFromValue(value);
|
|
131
|
-
return {
|
|
132
|
-
class: [cssPrefix("slide-range-node"), { active: percent.value > nodePercent }],
|
|
133
|
-
style: {
|
|
134
|
-
[cssProperty(["slide-range", "position"])]: `${nodePercent}%`,
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const getValueFromPercent = (currentPercent: number) => {
|
|
140
|
-
const { min, max } = props;
|
|
141
|
-
return Math.round(min + (max - min) * (currentPercent / 100));
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const getPercentFromValue = (value: number) => {
|
|
145
|
-
const { min, max } = props;
|
|
146
|
-
if (max <= min) return 0;
|
|
147
|
-
const p = ((value - min) / (max - min)) * 100;
|
|
148
|
-
return Math.max(0, Math.min(100, p));
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const formatValue = (value: number) => {
|
|
152
|
-
if (value === 0) return "";
|
|
153
|
-
return `${value}${props.unit || ""}`;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const showTooltipTemporarily = () => {
|
|
157
|
-
if (tooltipTimeout) clearTimeout(tooltipTimeout);
|
|
158
|
-
isShowTooltip.value = true;
|
|
159
|
-
tooltipTimeout = setTimeout(() => {
|
|
160
|
-
isShowTooltip.value = false;
|
|
161
|
-
}, 300);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const emitValueFromPercent = (currentPercent: number) => {
|
|
165
|
-
if (props.disabled || props.readonly) return;
|
|
166
|
-
const value = getValueFromPercent(currentPercent);
|
|
167
|
-
const payload = formatValue(value);
|
|
168
|
-
emit("update:modelValue", payload);
|
|
169
|
-
emit("change", payload);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const onNodeSelect = (value: number) => {
|
|
173
|
-
const nodePercent = getPercentFromValue(value);
|
|
174
|
-
emitValueFromPercent(nodePercent);
|
|
175
|
-
showTooltipTemporarily();
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
const getClientX = (ev: MouseEvent | TouchEvent) => {
|
|
179
|
-
if ("changedTouches" in ev && ev.changedTouches.length > 0) {
|
|
180
|
-
return ev.changedTouches[0].clientX;
|
|
181
|
-
}
|
|
182
|
-
return (ev as MouseEvent).clientX;
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const onClickPath = (ev: MouseEvent | TouchEvent) => {
|
|
186
|
-
if (props.disabled || props.readonly || !container.value) return;
|
|
187
|
-
const width = container.value.offsetWidth;
|
|
188
|
-
const rect = container.value.getBoundingClientRect();
|
|
189
|
-
const x = getClientX(ev) - rect.left;
|
|
190
|
-
const p = (x / width) * 100;
|
|
191
|
-
emitValueFromPercent(Math.max(0, Math.min(100, p)));
|
|
192
|
-
showTooltipTemporarily();
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
// Lifecycle
|
|
196
|
-
// ----------------------------------------------------------------------------
|
|
197
|
-
onMounted(() => {
|
|
198
|
-
if (!point.value || !container.value) return;
|
|
199
|
-
gestureCleanup = gesture(point.value, {
|
|
200
|
-
down() {
|
|
201
|
-
if (props.disabled || props.readonly) return;
|
|
202
|
-
dragStartPercent = percent.value;
|
|
203
|
-
},
|
|
204
|
-
up() {
|
|
205
|
-
isShowTooltip.value = false;
|
|
206
|
-
},
|
|
207
|
-
cancel() {
|
|
208
|
-
isShowTooltip.value = false;
|
|
209
|
-
},
|
|
210
|
-
move({ initialDirection, deltaX }: { initialDirection: string; deltaX: number }) {
|
|
211
|
-
if (props.disabled || props.readonly) return;
|
|
212
|
-
if (initialDirection !== "right" && initialDirection !== "left") return;
|
|
213
|
-
if (!container.value) return;
|
|
214
|
-
|
|
215
|
-
const width = container.value.offsetWidth;
|
|
216
|
-
const p = (deltaX / width) * 100;
|
|
217
|
-
const nextPercent = Math.max(0, Math.min(100, Math.round(dragStartPercent + p)));
|
|
218
|
-
emitValueFromPercent(nextPercent);
|
|
219
|
-
if (tooltipTimeout) clearTimeout(tooltipTimeout);
|
|
220
|
-
isShowTooltip.value = true;
|
|
221
|
-
},
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
onUnmounted(() => {
|
|
226
|
-
if (tooltipTimeout) clearTimeout(tooltipTimeout);
|
|
227
|
-
gestureCleanup?.destroy();
|
|
228
|
-
});
|
|
229
|
-
</script>
|
|
@@ -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>
|