@indielayer/ui 1.0.0-alpha.7 → 1.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 +6 -3
- package/lib/index.cjs.js +1 -15
- package/lib/index.es.js +4453 -3651
- package/lib/nuxt.js +2 -1
- package/package.json +16 -6
- package/src/common/icons.ts +15 -0
- package/src/common/utils.ts +68 -0
- package/src/components/alert/Alert.theme.ts +57 -0
- package/src/components/alert/Alert.vue +51 -127
- package/src/components/alert/__tests__/Alert.spec.ts +14 -0
- package/src/components/avatar/Avatar.theme.ts +39 -0
- package/src/components/avatar/Avatar.vue +58 -96
- package/src/components/avatar/__tests__/Avatar.spec.ts +11 -0
- package/src/components/badge/Badge.theme.ts +13 -0
- package/src/components/badge/Badge.vue +58 -65
- package/src/components/badge/__tests__/Badge.spec.ts +11 -0
- package/src/components/breadcrumbs/Breadcrumbs.theme.ts +9 -0
- package/src/components/breadcrumbs/Breadcrumbs.vue +34 -24
- package/src/components/breadcrumbs/__tests__/Breadcrumbs.spec.ts +11 -0
- package/src/components/button/Button.theme.ts +234 -0
- package/src/components/button/Button.vue +94 -356
- package/src/components/button/ButtonGroup.theme.ts +5 -0
- package/src/components/button/ButtonGroup.vue +30 -29
- package/src/components/button/__tests__/ Button.spec.ts +11 -0
- package/src/components/button/__tests__/ ButtonGroup.spec.ts +11 -0
- package/src/components/card/Card.theme.ts +7 -0
- package/src/components/card/Card.vue +18 -11
- package/src/components/card/__tests__/Card.spec.ts +11 -0
- package/src/components/checkbox/Checkbox.theme.ts +92 -0
- package/src/components/checkbox/Checkbox.vue +69 -156
- package/src/components/checkbox/__tests__/Checkbox.spec.ts +11 -0
- package/src/components/collapse/Collapse.theme.ts +11 -0
- package/src/components/collapse/Collapse.vue +99 -118
- package/src/components/collapse/__tests__/Collapse.spec.ts +11 -0
- package/src/components/container/Container.theme.ts +7 -0
- package/src/components/container/Container.vue +17 -9
- package/src/components/container/__tests__/Container.spec.ts +11 -0
- package/src/components/divider/Divider.theme.ts +11 -0
- package/src/components/divider/Divider.vue +22 -18
- package/src/components/divider/__tests__/Divider.spec.ts +11 -0
- package/src/components/drawer/Drawer.theme.ts +9 -0
- package/src/components/drawer/Drawer.vue +160 -177
- package/src/components/drawer/__tests__/Drawer.spec.ts +11 -0
- package/src/components/form/Form.theme.ts +7 -0
- package/src/components/form/Form.vue +90 -73
- package/src/components/form/__tests__/Form.spec.ts +11 -0
- package/src/components/helpers/InputError.tsx +14 -0
- package/src/components/icon/Icon.theme.ts +16 -0
- package/src/components/icon/Icon.vue +72 -88
- package/src/components/icon/__tests__/Icon.spec.ts +11 -0
- package/src/components/image/Image.theme.ts +7 -0
- package/src/components/image/Image.vue +22 -23
- package/src/components/image/__tests__/Image.spec.ts +11 -0
- package/src/components/index.ts +3 -3
- package/src/components/input/Input.theme.ts +44 -0
- package/src/components/input/Input.vue +97 -130
- package/src/components/input/__tests__/Input.spec.ts +11 -0
- package/src/components/link/Link.theme.ts +26 -0
- package/src/components/link/Link.vue +41 -66
- package/src/components/link/__tests__/Link.spec.ts +11 -0
- package/src/components/menu/Menu.theme.ts +7 -0
- package/src/components/menu/Menu.vue +54 -45
- package/src/components/menu/MenuItem.theme.ts +107 -0
- package/src/components/menu/MenuItem.vue +97 -199
- package/src/components/menu/__tests__/Menu.spec.ts +11 -0
- package/src/components/menu/__tests__/MenuItem.spec.ts +11 -0
- package/src/components/modal/Modal.theme.ts +29 -0
- package/src/components/modal/Modal.vue +78 -101
- package/src/components/modal/__tests__/Modal.spec.ts +11 -0
- package/src/components/notifications/Notifications.theme.ts +11 -0
- package/src/components/notifications/Notifications.vue +233 -247
- package/src/components/notifications/__tests__/Notifications.spec.ts +11 -0
- package/src/components/pagination/Pagination.theme.ts +27 -0
- package/src/components/pagination/Pagination.vue +142 -164
- package/src/components/pagination/PaginationItem.theme.ts +14 -0
- package/src/components/pagination/PaginationItem.vue +26 -33
- package/src/components/pagination/__tests__/Pagination.spec.ts +11 -0
- package/src/components/pagination/__tests__/PaginationItem.spec.ts +11 -0
- package/src/components/popover/Popover.theme.ts +9 -0
- package/src/components/popover/Popover.vue +153 -101
- package/src/components/popover/PopoverContainer.theme.ts +7 -0
- package/src/components/popover/PopoverContainer.vue +17 -9
- package/src/components/popover/__tests__/Popover.spec.ts +11 -0
- package/src/components/popover/__tests__/PopoverContainer.spec.ts +11 -0
- package/src/components/progress/Progress.theme.ts +26 -0
- package/src/components/progress/Progress.vue +29 -53
- package/src/components/progress/__tests__/Progress.spec.ts +11 -0
- package/src/components/radio/Radio.theme.ts +121 -0
- package/src/components/radio/Radio.vue +81 -158
- package/src/components/radio/__tests__/Radio.spec.ts +11 -0
- package/src/components/scroll/Scroll.theme.ts +7 -0
- package/src/components/scroll/Scroll.vue +34 -36
- package/src/components/scroll/__tests__/Scroll.spec.ts +11 -0
- package/src/components/select/Select.theme.ts +54 -0
- package/src/components/select/Select.vue +219 -273
- package/src/components/select/__tests__/Select.spec.ts +11 -0
- package/src/components/skeleton/Skeleton.theme.ts +7 -0
- package/src/components/skeleton/Skeleton.vue +17 -9
- package/src/components/skeleton/__tests__/Skeleton.spec.ts +11 -0
- package/src/components/slider/Slider.theme.ts +30 -0
- package/src/components/slider/Slider.vue +135 -168
- package/src/components/slider/__tests__/Slider.spec.ts +11 -0
- package/src/components/spacer/{Spacer.vue → Spacer.tsx} +3 -6
- package/src/components/spacer/__tests__/Spacer.spec.ts +11 -0
- package/src/components/spinner/Spinner.vue +10 -34
- package/src/components/spinner/__tests__/Spinner.spec.ts +11 -0
- package/src/components/tab/Tab.theme.ts +22 -0
- package/src/components/tab/Tab.vue +89 -93
- package/src/components/tab/TabGroup.theme.ts +43 -0
- package/src/components/tab/TabGroup.vue +94 -127
- package/src/components/tab/__tests__/Tab.spec.ts +11 -0
- package/src/components/tab/__tests__/TabGroup.spec.ts +11 -0
- package/src/components/table/Table.theme.ts +19 -0
- package/src/components/table/Table.vue +136 -147
- package/src/components/table/{TableBody.vue → TableBody.tsx} +3 -8
- package/src/components/table/TableCell.theme.ts +27 -0
- package/src/components/table/TableCell.vue +30 -58
- package/src/components/table/TableHead.tsx +14 -0
- package/src/components/table/TableHeader.vue +18 -20
- package/src/components/table/TableRow.vue +23 -20
- package/src/components/table/__tests__/Table.spec.ts +11 -0
- package/src/components/tag/Tag.theme.ts +32 -0
- package/src/components/tag/Tag.vue +40 -68
- package/src/components/tag/__tests__/Tag.spec.ts +11 -0
- package/src/components/textarea/Textarea.theme.ts +62 -0
- package/src/components/textarea/Textarea.vue +100 -115
- package/src/components/textarea/__tests__/Textarea.spec.ts +11 -0
- package/src/components/toggle/Toggle.theme.ts +51 -0
- package/src/components/toggle/Toggle.vue +51 -81
- package/src/components/toggle/__tests__/Toggle.spec.ts +11 -0
- package/src/components/tooltip/Tooltip.theme.ts +51 -0
- package/src/components/tooltip/Tooltip.vue +9 -14
- package/src/components/tooltip/__tests__/Tooltip.spec.ts +11 -0
- package/src/composables/colors-utils.ts +68 -68
- package/src/composables/colors.ts +18 -6
- package/src/composables/common.ts +1 -0
- package/src/composables/css.ts +7 -2
- package/src/composables/index.ts +1 -1
- package/src/composables/inputtable.ts +1 -1
- package/src/composables/interactive.ts +8 -4
- package/src/composables/keys.ts +1 -0
- package/src/composables/notifications.ts +10 -0
- package/src/composables/theme.ts +88 -0
- package/src/create.ts +9 -4
- package/src/exports/nuxt.js +2 -1
- package/src/version.ts +1 -1
- package/volar.d.ts +1 -0
- package/lib/components/alert/Alert.vue.d.ts +0 -42
- package/lib/components/avatar/Avatar.vue.d.ts +0 -49
- package/lib/components/badge/Badge.vue.d.ts +0 -75
- package/lib/components/breadcrumbs/Breadcrumbs.vue.d.ts +0 -30
- package/lib/components/button/Button.vue.d.ts +0 -87
- package/lib/components/button/ButtonGroup.vue.d.ts +0 -49
- package/lib/components/card/Card.vue.d.ts +0 -17
- package/lib/components/checkbox/Checkbox.vue.d.ts +0 -81
- package/lib/components/collapse/Collapse.vue.d.ts +0 -47
- package/lib/components/container/Container.vue.d.ts +0 -14
- package/lib/components/divider/Divider.vue.d.ts +0 -10
- package/lib/components/drawer/Drawer.vue.d.ts +0 -73
- package/lib/components/form/Form.vue.d.ts +0 -46
- package/lib/components/icon/Icon.vue.d.ts +0 -40
- package/lib/components/image/Image.vue.d.ts +0 -8
- package/lib/components/index.d.ts +0 -45
- package/lib/components/input/Input.vue.d.ts +0 -117
- package/lib/components/link/Link.vue.d.ts +0 -36
- package/lib/components/menu/Menu.vue.d.ts +0 -62
- package/lib/components/menu/MenuItem.vue.d.ts +0 -114
- package/lib/components/modal/Modal.vue.d.ts +0 -34
- package/lib/components/notifications/Notifications.vue.d.ts +0 -104
- package/lib/components/pagination/Pagination.vue.d.ts +0 -58
- package/lib/components/pagination/PaginationItem.vue.d.ts +0 -32
- package/lib/components/popover/Popover.vue.d.ts +0 -64
- package/lib/components/popover/PopoverContainer.vue.d.ts +0 -14
- package/lib/components/progress/Progress.vue.d.ts +0 -42
- package/lib/components/radio/Radio.vue.d.ts +0 -79
- package/lib/components/scroll/Scroll.vue.d.ts +0 -29
- package/lib/components/select/Select.vue.d.ts +0 -100
- package/lib/components/skeleton/Skeleton.vue.d.ts +0 -14
- package/lib/components/slider/Slider.vue.d.ts +0 -96
- package/lib/components/spacer/Spacer.vue.d.ts +0 -2
- package/lib/components/spinner/Spinner.vue.d.ts +0 -16
- package/lib/components/tab/Tab.vue.d.ts +0 -52
- package/lib/components/tab/TabGroup.vue.d.ts +0 -61
- package/lib/components/table/Table.vue.d.ts +0 -82
- package/lib/components/table/TableBody.vue.d.ts +0 -2
- package/lib/components/table/TableCell.vue.d.ts +0 -33
- package/lib/components/table/TableHead.vue.d.ts +0 -2
- package/lib/components/table/TableHeader.vue.d.ts +0 -33
- package/lib/components/table/TableRow.vue.d.ts +0 -23
- package/lib/components/tag/Tag.vue.d.ts +0 -45
- package/lib/components/textarea/Textarea.vue.d.ts +0 -106
- package/lib/components/toggle/Toggle.vue.d.ts +0 -79
- package/lib/components/tooltip/Tooltip.vue.d.ts +0 -2
- package/lib/composables/colors-utils.d.ts +0 -8
- package/lib/composables/colors.d.ts +0 -26
- package/lib/composables/common.d.ts +0 -14
- package/lib/composables/css.d.ts +0 -5
- package/lib/composables/index.d.ts +0 -7
- package/lib/composables/inputtable.d.ts +0 -37
- package/lib/composables/interactive.d.ts +0 -10
- package/lib/composables/keys.d.ts +0 -7
- package/lib/composables/notification.d.ts +0 -1
- package/lib/create.d.ts +0 -12
- package/lib/index.d.ts +0 -6
- package/lib/install.d.ts +0 -4
- package/lib/style.css +0 -1
- package/lib/version.d.ts +0 -2
- package/src/components/table/TableHead.vue +0 -15
- package/src/composables/notification.ts +0 -10
|
@@ -1,209 +1,175 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export default { name: 'XSlider' }
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { computed, ref, watch } from 'vue'
|
|
7
|
+
import { useEventListener } from '@vueuse/core'
|
|
4
8
|
import { useCommon } from '../../composables/common'
|
|
5
9
|
import { useColors } from '../../composables/colors'
|
|
6
10
|
import { useInteractive } from '../../composables/interactive'
|
|
7
11
|
import { useInputtable } from '../../composables/inputtable'
|
|
8
|
-
|
|
9
|
-
import { useEventListener } from '@vueuse/core'
|
|
12
|
+
import { useTheme } from '../../composables/theme'
|
|
10
13
|
|
|
11
14
|
import XProgress from '../../components/progress/Progress.vue'
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
import theme from './Slider.theme'
|
|
17
|
+
|
|
18
|
+
const props = defineProps({
|
|
19
|
+
...useCommon.props(),
|
|
20
|
+
...useColors.props('primary'),
|
|
21
|
+
...useInteractive.props(),
|
|
22
|
+
...useInputtable.props(),
|
|
23
|
+
label: String,
|
|
24
|
+
min: Number,
|
|
25
|
+
max: Number,
|
|
26
|
+
step: {
|
|
27
|
+
type: Number,
|
|
28
|
+
default: 1,
|
|
18
29
|
},
|
|
30
|
+
gradient: Boolean,
|
|
31
|
+
})
|
|
19
32
|
|
|
20
|
-
|
|
21
|
-
...useCommon.validators(),
|
|
22
|
-
},
|
|
33
|
+
const emit = defineEmits(useInputtable.emits(false))
|
|
23
34
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
...useInputtable.props(),
|
|
29
|
-
label: String,
|
|
30
|
-
min: Number,
|
|
31
|
-
max: Number,
|
|
32
|
-
step: {
|
|
33
|
-
type: Number,
|
|
34
|
-
default: 1,
|
|
35
|
-
},
|
|
36
|
-
gradient: Boolean,
|
|
37
|
-
},
|
|
35
|
+
const elRef = ref<HTMLElement | null>(null)
|
|
36
|
+
const dragRef = ref<HTMLElement | null>(null)
|
|
37
|
+
const progressRef = ref<HTMLElement | null>(null)
|
|
38
|
+
const value = ref<number>(Number(props.modelValue ?? 0))
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (props.size === 'xs') return 'text-xs'
|
|
52
|
-
else if (props.size === 'sm') return 'text-sm'
|
|
53
|
-
else if (props.size === 'lg') return 'text-lg'
|
|
54
|
-
else if (props.size === 'xl') return 'text-xl'
|
|
55
|
-
|
|
56
|
-
return ''
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
const css = useCSS('slider')
|
|
60
|
-
const colors = useColors()
|
|
61
|
-
const primary = colors.getPalette('primary')
|
|
62
|
-
const style = computed(() => {
|
|
63
|
-
const color = colors.getPalette(props.color)
|
|
64
|
-
|
|
65
|
-
return css.variables({
|
|
66
|
-
bg: color[500],
|
|
67
|
-
border: primary[500],
|
|
68
|
-
// width: value.value + '%',
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
watch(() => props.modelValue, (val) => {
|
|
73
|
-
value.value = Number(val ?? 0)
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
watch(value, (val) => {
|
|
77
|
-
emit('update:modelValue', val)
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
const initial = ref()
|
|
81
|
-
const position = ref()
|
|
82
|
-
const isDragging = computed(() => !!initial.value)
|
|
83
|
-
|
|
84
|
-
function startProgressDrag(e: PointerEvent) {
|
|
85
|
-
e.stopPropagation()
|
|
86
|
-
if (!dragRef.value || !progressRef.value) return
|
|
87
|
-
|
|
88
|
-
interactive.focus()
|
|
89
|
-
|
|
90
|
-
const maxWidth = progressRef.value.offsetWidth
|
|
91
|
-
let percent = Math.floor(e.offsetX * 100 / maxWidth)
|
|
92
|
-
|
|
93
|
-
console.log(e, e.offsetX, percent)
|
|
94
|
-
|
|
95
|
-
if (percent < 0) percent = 0
|
|
96
|
-
if (percent > 100) percent = 100
|
|
97
|
-
|
|
98
|
-
value.value = percent
|
|
99
|
-
|
|
100
|
-
setTimeout(() => {
|
|
101
|
-
initial.value = {
|
|
102
|
-
x: e.x,
|
|
103
|
-
y: e.y,
|
|
104
|
-
maxWidth,
|
|
105
|
-
offsetX: dragRef.value?.offsetLeft,
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
e.preventDefault()
|
|
109
|
-
e.stopPropagation()
|
|
110
|
-
}
|
|
40
|
+
const { focus, blur } = useInteractive(elRef)
|
|
41
|
+
|
|
42
|
+
watch(() => props.modelValue, (val) => {
|
|
43
|
+
value.value = Number(val ?? 0)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
watch(value, (val) => {
|
|
47
|
+
emit('update:modelValue', val)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const initial = ref()
|
|
51
|
+
const isDragging = computed(() => !!initial.value)
|
|
111
52
|
|
|
112
|
-
|
|
113
|
-
|
|
53
|
+
function startProgressDrag(e: PointerEvent) {
|
|
54
|
+
e.stopPropagation()
|
|
55
|
+
if (!dragRef.value || !progressRef.value) return
|
|
114
56
|
|
|
115
|
-
|
|
57
|
+
focus()
|
|
116
58
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
y: e.y,
|
|
120
|
-
maxWidth: progressRef.value.offsetWidth,
|
|
121
|
-
offsetX: dragRef.value.offsetLeft,
|
|
122
|
-
}
|
|
59
|
+
const maxWidth = progressRef.value.offsetWidth
|
|
60
|
+
let percent = Math.floor(e.offsetX * 100 / maxWidth)
|
|
123
61
|
|
|
124
|
-
|
|
125
|
-
|
|
62
|
+
if (percent < 0) percent = 0
|
|
63
|
+
if (percent > 100) percent = 100
|
|
64
|
+
|
|
65
|
+
value.value = percent
|
|
66
|
+
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
initial.value = {
|
|
69
|
+
x: e.x,
|
|
70
|
+
y: e.y,
|
|
71
|
+
maxWidth,
|
|
72
|
+
offsetX: dragRef.value?.offsetLeft,
|
|
126
73
|
}
|
|
74
|
+
})
|
|
75
|
+
e.preventDefault()
|
|
76
|
+
e.stopPropagation()
|
|
77
|
+
}
|
|
127
78
|
|
|
128
|
-
|
|
129
|
-
|
|
79
|
+
function startDrag(e: PointerEvent) {
|
|
80
|
+
if (!dragRef.value || !progressRef.value) return
|
|
130
81
|
|
|
131
|
-
|
|
132
|
-
const movedX = e.x - x
|
|
82
|
+
focus()
|
|
133
83
|
|
|
134
|
-
|
|
84
|
+
initial.value = {
|
|
85
|
+
x: e.x,
|
|
86
|
+
y: e.y,
|
|
87
|
+
maxWidth: progressRef.value.offsetWidth,
|
|
88
|
+
offsetX: dragRef.value.offsetLeft,
|
|
89
|
+
}
|
|
135
90
|
|
|
136
|
-
|
|
137
|
-
|
|
91
|
+
e.preventDefault()
|
|
92
|
+
e.stopPropagation()
|
|
93
|
+
}
|
|
138
94
|
|
|
139
|
-
|
|
140
|
-
|
|
95
|
+
function moveDrag(e: PointerEvent) {
|
|
96
|
+
if (!initial.value || !dragRef.value) return
|
|
141
97
|
|
|
142
|
-
|
|
98
|
+
const { x, maxWidth, offsetX } = initial.value
|
|
99
|
+
const movedX = e.x - x
|
|
143
100
|
|
|
144
|
-
|
|
145
|
-
e.stopPropagation()
|
|
146
|
-
}
|
|
101
|
+
if (movedX === 0) return
|
|
147
102
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
initial.value = undefined
|
|
151
|
-
e.preventDefault()
|
|
152
|
-
e.stopPropagation()
|
|
153
|
-
}
|
|
103
|
+
const newMoveX = offsetX + movedX
|
|
104
|
+
let percent = Math.floor(newMoveX * 100 / maxWidth)
|
|
154
105
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
useEventListener(window, 'pointermove', moveDrag, true)
|
|
158
|
-
useEventListener(window, 'pointerup', endDrag, true)
|
|
106
|
+
if (percent < 0) percent = 0
|
|
107
|
+
if (percent > 100) percent = 100
|
|
159
108
|
|
|
160
|
-
|
|
109
|
+
value.value = percent
|
|
161
110
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
111
|
+
e.preventDefault()
|
|
112
|
+
e.stopPropagation()
|
|
113
|
+
}
|
|
165
114
|
|
|
166
|
-
|
|
115
|
+
function endDrag(e: PointerEvent) {
|
|
116
|
+
if (!initial.value) return
|
|
117
|
+
initial.value = undefined
|
|
118
|
+
e.preventDefault()
|
|
119
|
+
e.stopPropagation()
|
|
120
|
+
}
|
|
167
121
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
122
|
+
useEventListener(progressRef, 'pointerdown', startProgressDrag, false)
|
|
123
|
+
useEventListener(dragRef, 'pointerdown', startDrag, false)
|
|
124
|
+
useEventListener(window, 'pointermove', moveDrag, true)
|
|
125
|
+
useEventListener(window, 'pointerup', endDrag, true)
|
|
171
126
|
|
|
172
|
-
|
|
127
|
+
useEventListener(elRef, 'keydown', handleKeydown)
|
|
173
128
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
129
|
+
function handleKeydown(e: KeyboardEvent) {
|
|
130
|
+
if (e.code === 'ArrowLeft') {
|
|
131
|
+
const nextValue = value.value - 1
|
|
177
132
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
133
|
+
if (nextValue >= 0) value.value = nextValue
|
|
134
|
+
|
|
135
|
+
e.preventDefault()
|
|
136
|
+
} else if (e.code === 'ArrowRight') {
|
|
137
|
+
const nextValue = value.value + 1
|
|
138
|
+
|
|
139
|
+
if (nextValue <= 100) value.value = nextValue
|
|
140
|
+
|
|
141
|
+
e.preventDefault()
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const {
|
|
146
|
+
errorInternal,
|
|
147
|
+
reset,
|
|
148
|
+
validate,
|
|
149
|
+
setError,
|
|
150
|
+
isInsideForm,
|
|
151
|
+
} = useInputtable(props, { focus, emit, withListeners: false })
|
|
152
|
+
|
|
153
|
+
const { styles, classes, className } = useTheme('slider', theme, props)
|
|
154
|
+
|
|
155
|
+
defineExpose({ focus, blur, reset, validate, setError })
|
|
193
156
|
</script>
|
|
194
157
|
|
|
195
158
|
<template>
|
|
196
159
|
<label
|
|
197
160
|
ref="elRef"
|
|
198
161
|
tabindex="0"
|
|
199
|
-
class="group
|
|
200
|
-
:class="
|
|
201
|
-
|
|
162
|
+
class="group relative"
|
|
163
|
+
:class="[
|
|
164
|
+
className,
|
|
165
|
+
classes.wrapper,
|
|
166
|
+
{ 'mb-3': isInsideForm }
|
|
167
|
+
]"
|
|
168
|
+
:style="styles"
|
|
202
169
|
>
|
|
203
170
|
<p
|
|
204
171
|
v-if="label"
|
|
205
|
-
class="
|
|
206
|
-
:class="labelClasses"
|
|
172
|
+
:class="classes.label"
|
|
207
173
|
v-text="label"
|
|
208
174
|
></p>
|
|
209
175
|
|
|
@@ -225,10 +191,11 @@ export default defineComponent({
|
|
|
225
191
|
</div>
|
|
226
192
|
<div
|
|
227
193
|
ref="dragRef"
|
|
228
|
-
class="absolute
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
194
|
+
class="absolute group-focus:border-[color:var(--x-slider-border)]"
|
|
195
|
+
:class="[
|
|
196
|
+
classes.drag,
|
|
197
|
+
isDragging ? 'cursor-grabbing' : 'cursor-grab'
|
|
198
|
+
]"
|
|
232
199
|
:style="`left: ${value}%;`"
|
|
233
200
|
></div>
|
|
234
201
|
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import Slider from '../Slider.vue'
|
|
4
|
+
|
|
5
|
+
describe('Slider', () => {
|
|
6
|
+
it('renders without errors', () => {
|
|
7
|
+
const wrapper = mount(Slider)
|
|
8
|
+
|
|
9
|
+
expect(wrapper.vm).toBeTruthy()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
1
|
import { defineComponent } from 'vue'
|
|
3
2
|
|
|
4
3
|
export default defineComponent({
|
|
5
4
|
name: 'XSpacer',
|
|
5
|
+
setup() {
|
|
6
|
+
return () => <div class="flex-grow"></div>
|
|
7
|
+
},
|
|
6
8
|
})
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<template>
|
|
10
|
-
<div class="flex-grow"></div>
|
|
11
|
-
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import Spacer from '../Spacer'
|
|
4
|
+
|
|
5
|
+
describe('Spacer', () => {
|
|
6
|
+
it('renders without errors', () => {
|
|
7
|
+
const wrapper = mount(Spacer)
|
|
8
|
+
|
|
9
|
+
expect(wrapper.classes()).toContain('flex-grow')
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -1,45 +1,21 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
2
|
+
export default { name: 'XSpinner' }
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
3
6
|
import { useCommon } from '../../composables/common'
|
|
4
7
|
|
|
5
8
|
import XIcon from '../../components/icon/Icon.vue'
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
props: {
|
|
15
|
-
...useCommon.props(),
|
|
16
|
-
icon: String,
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
setup() {
|
|
20
|
-
const defaultIcon = `<g fill="none" fill-rule="evenodd">
|
|
21
|
-
<g transform="translate(1 1)" stroke-width="2">
|
|
22
|
-
<circle stroke-opacity=".5" cx="18" cy="18" r="18"/>
|
|
23
|
-
<path d="M36 18c0-9.94-8.06-18-18-18">
|
|
24
|
-
<animateTransform
|
|
25
|
-
attributeName="transform"
|
|
26
|
-
type="rotate"
|
|
27
|
-
from="0 18 18"
|
|
28
|
-
to="360 18 18"
|
|
29
|
-
dur="0.5s"
|
|
30
|
-
repeatCount="indefinite"
|
|
31
|
-
/>
|
|
32
|
-
</path>
|
|
33
|
-
</g>
|
|
34
|
-
</g>`
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
defaultIcon,
|
|
38
|
-
}
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
...useCommon.props(),
|
|
12
|
+
icon: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: '<g fill="none" fill-rule="evenodd"><g transform="translate(1 1)" stroke-width="2"><circle stroke-opacity=".5" cx="18" cy="18" r="18"/><path d="M36 18c0-9.94-8.06-18-18-18"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.5s" repeatCount="indefinite"/></path></g></g>',
|
|
39
15
|
},
|
|
40
16
|
})
|
|
41
17
|
</script>
|
|
42
18
|
|
|
43
19
|
<template>
|
|
44
|
-
<x-icon :icon="icon
|
|
20
|
+
<x-icon :icon="icon" :size="size" view-box="0 0 38 38"/>
|
|
45
21
|
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import Spinner from '../Spinner.vue'
|
|
4
|
+
|
|
5
|
+
describe('Spinner', () => {
|
|
6
|
+
it('renders without errors', () => {
|
|
7
|
+
const wrapper = mount(Spinner)
|
|
8
|
+
|
|
9
|
+
expect(wrapper.vm).toBeTruthy()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ThemeParams } from '../../composables/theme'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
classes: {
|
|
5
|
+
wrapper: ({ props, data }: ThemeParams) => {
|
|
6
|
+
const c = ['py-2 transition-colors duration-150 ease-in-out whitespace-nowrap text-center']
|
|
7
|
+
|
|
8
|
+
if (data.variant === 'block') c.push('px-8')
|
|
9
|
+
|
|
10
|
+
if (props.size === 'xs') c.push('text-xs')
|
|
11
|
+
else if (props.size === 'sm') c.push('text-sm')
|
|
12
|
+
else if (props.size === 'lg') c.push('text-lg')
|
|
13
|
+
else if (props.size === 'xl') c.push('text-xl')
|
|
14
|
+
|
|
15
|
+
return c
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
label: '',
|
|
19
|
+
|
|
20
|
+
icon: 'mr-1.5',
|
|
21
|
+
},
|
|
22
|
+
}
|