@indielayer/ui 1.0.0-alpha.9 → 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 +4451 -3650
- 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 -249
- 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 +8 -3
- 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,126 +1,176 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { computed, defineComponent, ref, useCssModule, watch, type PropType } from 'vue'
|
|
3
|
-
import { onClickOutside } from '@vueuse/core'
|
|
4
|
-
|
|
5
2
|
const validators = {
|
|
6
3
|
align: ['bottom','center','left','right','top'],
|
|
7
4
|
position: ['bottom','left','right','top'],
|
|
8
5
|
}
|
|
9
6
|
|
|
10
|
-
export default
|
|
7
|
+
export default {
|
|
11
8
|
name: 'XPopover',
|
|
12
|
-
|
|
13
9
|
validators,
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import { computed, ref, useCssModule, watch, type PropType } from 'vue'
|
|
15
|
+
import { onClickOutside, useEventListener } from '@vueuse/core'
|
|
16
|
+
import { useTheme } from '../../composables/theme'
|
|
17
|
+
|
|
18
|
+
import theme from './Popover.theme'
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
position: {
|
|
22
|
-
type: String as PropType<'bottom' | 'left' | 'right' | 'top'>,
|
|
23
|
-
default: 'bottom',
|
|
24
|
-
validator: (value: string) => validators.position.includes(value),
|
|
25
|
-
},
|
|
26
|
-
dismissOnClick: {
|
|
27
|
-
type: Boolean,
|
|
28
|
-
default: true,
|
|
29
|
-
},
|
|
30
|
-
disabled: Boolean,
|
|
31
|
-
hover: Boolean,
|
|
32
|
-
block: Boolean,
|
|
20
|
+
const props = defineProps({
|
|
21
|
+
align: {
|
|
22
|
+
type: String as PropType<'bottom' | 'center' | 'left' | 'right' | 'top'>,
|
|
23
|
+
default: 'center',
|
|
24
|
+
validator: (value: string) => validators.align.includes(value),
|
|
33
25
|
},
|
|
26
|
+
position: {
|
|
27
|
+
type: String as PropType<'bottom' | 'left' | 'right' | 'top'>,
|
|
28
|
+
default: 'bottom',
|
|
29
|
+
validator: (value: string) => validators.position.includes(value),
|
|
30
|
+
},
|
|
31
|
+
dismissOnClick: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: true,
|
|
34
|
+
},
|
|
35
|
+
autoAlign: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: true,
|
|
38
|
+
},
|
|
39
|
+
disabled: Boolean,
|
|
40
|
+
hover: Boolean,
|
|
41
|
+
block: Boolean,
|
|
42
|
+
})
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
const emit = defineEmits(['open', 'close', 'toggle'])
|
|
36
45
|
|
|
37
|
-
|
|
46
|
+
const elRef = ref<HTMLElement | null>(null)
|
|
47
|
+
const contentRef = ref<HTMLElement | null>(null)
|
|
48
|
+
const isOpen = ref(false)
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
const elRef = ref<HTMLElement>()
|
|
41
|
-
const isOpen = ref(false)
|
|
50
|
+
let stopClickOutside: undefined | (()=> void) = undefined
|
|
42
51
|
|
|
43
|
-
|
|
52
|
+
watch(isOpen, (newValue) => {
|
|
53
|
+
if (props.hover) return
|
|
44
54
|
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
if (newValue) {
|
|
56
|
+
checkVisibility()
|
|
57
|
+
} else {
|
|
58
|
+
resetOutbounds()
|
|
59
|
+
}
|
|
47
60
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
if (stopClickOutside) {
|
|
62
|
+
stopClickOutside()
|
|
63
|
+
stopClickOutside = undefined
|
|
64
|
+
}
|
|
52
65
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
}
|
|
66
|
+
if (newValue) {
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
stopClickOutside = onClickOutside(elRef, close)
|
|
58
69
|
})
|
|
70
|
+
}
|
|
71
|
+
})
|
|
59
72
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// align-center
|
|
68
|
-
'left-1/2 right-auto -translate-x-1/2': props.align === 'center' && ['bottom', 'top'].includes(props.position),
|
|
69
|
-
// align-right
|
|
70
|
-
'right-0 left-auto': props.align === 'right' && ['bottom', 'top'].includes(props.position),
|
|
71
|
-
// align-top
|
|
72
|
-
'top-0 bottom-auto': props.align === 'top' && ['left', 'right'].includes(props.position),
|
|
73
|
-
// align-middle
|
|
74
|
-
'-translate-y-1/2 top-1/2 bottom-auto': props.align === 'center' && ['left', 'right'].includes(props.position),
|
|
75
|
-
// align-bottom
|
|
76
|
-
'bottom-0': props.align === 'bottom' && ['left', 'right'].includes(props.position),
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
if (props.position === 'top') c.push(`bottom-full pb-2 ${$style.popoverTop}`)
|
|
80
|
-
if (props.position === 'right') c.push(`left-full pl-2 ${$style.popoverRight}`)
|
|
81
|
-
if (props.position === 'bottom') c.push(`top-full bottom-0 ${$style.popoverBottom}`)
|
|
82
|
-
if (props.position === 'left') c.push(`right-full left-auto pr-2 ${$style.popoverLeft}`)
|
|
83
|
-
|
|
84
|
-
if (props.block) c.push('min-w-full')
|
|
85
|
-
|
|
86
|
-
return c
|
|
87
|
-
})
|
|
73
|
+
const $style = useCssModule()
|
|
74
|
+
const isOutLeft = ref(false)
|
|
75
|
+
const isOutRight = ref(false)
|
|
76
|
+
const isOutTop = ref(false)
|
|
77
|
+
const isOutBottom = ref(false)
|
|
78
|
+
const contentClasses = computed(() => {
|
|
79
|
+
const c = []
|
|
88
80
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
81
|
+
let align = props.align
|
|
82
|
+
let position = props.position
|
|
83
|
+
|
|
84
|
+
if (isOutTop.value) {
|
|
85
|
+
if (position === 'top') position = 'bottom'
|
|
86
|
+
else if ((position === 'left' || position === 'right')) align = 'top'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (isOutBottom.value) {
|
|
90
|
+
if (position === 'bottom') position = 'top'
|
|
91
|
+
else if ((position === 'left' || position === 'right')) align = 'bottom'
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (isOutLeft.value) {
|
|
95
|
+
if (position === 'left') position = 'right'
|
|
96
|
+
else if ((position === 'top' || position === 'bottom')) align = 'left'
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (isOutRight.value) {
|
|
100
|
+
if (position === 'right') position = 'left'
|
|
101
|
+
else if ((position === 'top' || position === 'bottom')) align = 'right'
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (position === 'top') c.push(`bottom-full ${$style.popoverTop}`)
|
|
105
|
+
if (position === 'bottom') c.push(`top-full bottom-0 ${$style.popoverBottom}`)
|
|
106
|
+
if (position === 'right') c.push(`left-full ${$style.popoverRight}`)
|
|
107
|
+
if (position === 'left') c.push(`right-full left-auto ${$style.popoverLeft}`)
|
|
108
|
+
|
|
109
|
+
if (align === 'left' && ['bottom', 'top'].includes(position)) c.push('left-0 right-auto')
|
|
110
|
+
if (align === 'center' && ['bottom', 'top'].includes(position)) c.push('left-1/2 right-auto -translate-x-1/2')
|
|
111
|
+
if (align === 'right' && ['bottom', 'top'].includes(position)) c.push('right-0 left-auto')
|
|
112
|
+
if (align === 'top' && ['left', 'right'].includes(position)) c.push('top-0 bottom-auto')
|
|
113
|
+
if (align === 'center' && ['left', 'right'].includes(position)) c.push('-translate-y-1/2 top-1/2 bottom-auto')
|
|
114
|
+
if (align === 'bottom' && ['left', 'right'].includes(position)) c.push('bottom-0')
|
|
115
|
+
|
|
116
|
+
if (props.block) c.push('min-w-full')
|
|
117
|
+
|
|
118
|
+
return c
|
|
116
119
|
})
|
|
120
|
+
|
|
121
|
+
if (props.hover) {
|
|
122
|
+
useEventListener(elRef, 'mouseenter', checkVisibility)
|
|
123
|
+
useEventListener(elRef, 'mouseleave', resetOutbounds)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function resetOutbounds() {
|
|
127
|
+
isOutLeft.value = false
|
|
128
|
+
isOutRight.value = false
|
|
129
|
+
isOutTop.value = false
|
|
130
|
+
isOutBottom.value = false
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function checkVisibility() {
|
|
134
|
+
if (!contentRef.value) return
|
|
135
|
+
const clientRect = contentRef.value.getBoundingClientRect()
|
|
136
|
+
|
|
137
|
+
isOutLeft.value = clientRect.left < 0
|
|
138
|
+
isOutRight.value = clientRect.right > (window.innerWidth || document.documentElement.clientWidth)
|
|
139
|
+
isOutTop.value = clientRect.top < 0
|
|
140
|
+
isOutBottom.value = clientRect.bottom > (window.innerHeight || document.documentElement.clientHeight)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function close() {
|
|
144
|
+
if (props.disabled) return
|
|
145
|
+
isOpen.value = false
|
|
146
|
+
emit('close')
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function open() {
|
|
150
|
+
if (props.disabled) return
|
|
151
|
+
isOpen.value = true
|
|
152
|
+
emit('open')
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function toggle() {
|
|
156
|
+
if (props.disabled) return
|
|
157
|
+
isOpen.value = !isOpen.value
|
|
158
|
+
emit('toggle', isOpen.value)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const { styles, classes, className } = useTheme('popover', theme, props)
|
|
162
|
+
|
|
163
|
+
defineExpose({ open, close, toggle, isOpen })
|
|
117
164
|
</script>
|
|
118
165
|
|
|
119
166
|
<template>
|
|
120
167
|
<div
|
|
121
168
|
ref="elRef"
|
|
122
169
|
class="inline-block relative"
|
|
170
|
+
:style="styles"
|
|
123
171
|
:class="[
|
|
172
|
+
className,
|
|
173
|
+
classes.wrapper,
|
|
124
174
|
$style.popover,
|
|
125
175
|
[hover ? $style.hover : ''],
|
|
126
176
|
[isOpen ? $style['is-open'] : ''],
|
|
@@ -132,10 +182,12 @@ export default defineComponent({
|
|
|
132
182
|
</div>
|
|
133
183
|
|
|
134
184
|
<div
|
|
135
|
-
|
|
185
|
+
ref="contentRef"
|
|
186
|
+
class="absolute transform transition-transform z-40 h-fit"
|
|
136
187
|
:class="[
|
|
137
188
|
$style.popoverContent,
|
|
138
|
-
|
|
189
|
+
contentClasses,
|
|
190
|
+
classes.content
|
|
139
191
|
]"
|
|
140
192
|
@click="dismissOnClick ? close() : null"
|
|
141
193
|
>
|
|
@@ -158,7 +210,7 @@ export default defineComponent({
|
|
|
158
210
|
--tw-translate-x: -0.5rem;
|
|
159
211
|
}
|
|
160
212
|
.popoverBottom {
|
|
161
|
-
--tw-translate-y: -0.
|
|
213
|
+
--tw-translate-y: -0.5rem;
|
|
162
214
|
}
|
|
163
215
|
.popoverLeft {
|
|
164
216
|
--tw-translate-x: 0.5rem;
|
|
@@ -173,12 +225,12 @@ export default defineComponent({
|
|
|
173
225
|
|
|
174
226
|
&.hover:hover .popoverTop,
|
|
175
227
|
&.is-open .popoverTop {
|
|
176
|
-
--tw-translate-y: 0.25rem;
|
|
228
|
+
--tw-translate-y: -0.25rem;
|
|
177
229
|
}
|
|
178
230
|
|
|
179
231
|
&.hover:hover .popoverRight,
|
|
180
232
|
&.is-open .popoverRight {
|
|
181
|
-
--tw-translate-x:
|
|
233
|
+
--tw-translate-x: 0.25rem;
|
|
182
234
|
}
|
|
183
235
|
|
|
184
236
|
&.hover:hover .popoverBottom,
|
|
@@ -188,7 +240,7 @@ export default defineComponent({
|
|
|
188
240
|
|
|
189
241
|
&.hover:hover .popoverLeft,
|
|
190
242
|
&.is-open .popoverLeft {
|
|
191
|
-
--tw-translate-x:
|
|
243
|
+
--tw-translate-x: -0.25rem;
|
|
192
244
|
}
|
|
193
245
|
}
|
|
194
246
|
</style>
|
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
2
|
+
export default { name: 'XPopoverContainer' }
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { useTheme } from '../../composables/theme'
|
|
3
7
|
|
|
4
|
-
|
|
5
|
-
name: 'XPopoverContainer',
|
|
8
|
+
import theme from './PopoverContainer.theme'
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
tag: {
|
|
12
|
+
default: 'div',
|
|
13
|
+
type: String,
|
|
12
14
|
},
|
|
13
15
|
})
|
|
16
|
+
|
|
17
|
+
const { styles, classes, className } = useTheme('popover-container', theme, props)
|
|
14
18
|
</script>
|
|
15
19
|
|
|
16
20
|
<template>
|
|
17
21
|
<component
|
|
18
22
|
:is="tag"
|
|
19
|
-
|
|
23
|
+
:style="styles"
|
|
24
|
+
:class="[
|
|
25
|
+
className,
|
|
26
|
+
classes.wrapper
|
|
27
|
+
]"
|
|
20
28
|
>
|
|
21
29
|
<slot></slot>
|
|
22
30
|
</component>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import Popover from '../Popover.vue'
|
|
4
|
+
|
|
5
|
+
describe('Popover', () => {
|
|
6
|
+
it('renders without errors', () => {
|
|
7
|
+
const wrapper = mount(Popover)
|
|
8
|
+
|
|
9
|
+
expect(wrapper.vm).toBeTruthy()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import PopoverContainer from '../PopoverContainer.vue'
|
|
4
|
+
|
|
5
|
+
describe('PopoverContainer', () => {
|
|
6
|
+
it('renders without errors', () => {
|
|
7
|
+
const wrapper = mount(PopoverContainer)
|
|
8
|
+
|
|
9
|
+
expect(wrapper.vm).toBeTruthy()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ThemeParams } from '../../composables/theme'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
classes: {
|
|
5
|
+
wrapper: ({ props }: ThemeParams) => `relative rounded bg-gray-100 dark:bg-gray-700 overflow-hidden pointer-events-none ${props.thick ? 'h-1.5' : 'h-1'}`,
|
|
6
|
+
|
|
7
|
+
list: 'flex flex-col items-end w-full sm:w-[520px] px-4',
|
|
8
|
+
|
|
9
|
+
item: 'w-full flex items-center rounded-md px-4 py-3 bg-gray-800 dark:bg-gray-50 text-white dark:text-gray-900',
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
styles: ({ props, colors, css }: ThemeParams) => {
|
|
13
|
+
const color = colors.getPalette(props.color)
|
|
14
|
+
const vars = []
|
|
15
|
+
|
|
16
|
+
vars.push(css.variables({
|
|
17
|
+
bg: color[500],
|
|
18
|
+
}))
|
|
19
|
+
|
|
20
|
+
if (props.gradient) vars.push({
|
|
21
|
+
'--tw-gradient-stops': `${color[100]}, ${color[800]}`,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
return vars
|
|
25
|
+
},
|
|
26
|
+
}
|
|
@@ -1,67 +1,43 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { useColors } from '../../composables/colors'
|
|
5
|
-
|
|
6
|
-
// const validators = {
|
|
7
|
-
// variant: ['bar','score'],
|
|
8
|
-
// }
|
|
2
|
+
export default { name: 'XProgress' }
|
|
3
|
+
</script>
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { useColors } from '../../composables/colors'
|
|
7
|
+
import { useTheme } from '../../composables/theme'
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
import theme from './Progress.theme'
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
// variant: {
|
|
23
|
-
// type: String as PropType<'bar' | 'score'>,
|
|
24
|
-
// default: 'bar',
|
|
25
|
-
// validator: (value: string) => validators.variant.includes(value),
|
|
26
|
-
// },
|
|
27
|
-
gradient: Boolean,
|
|
28
|
-
animate: {
|
|
29
|
-
type: Boolean,
|
|
30
|
-
default: true,
|
|
31
|
-
},
|
|
32
|
-
thick: Boolean,
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
...useColors.props('primary'),
|
|
13
|
+
percentage: {
|
|
14
|
+
type: Number,
|
|
15
|
+
default: 0,
|
|
16
|
+
validator: (value: number) => value >= 0 && value <= 100,
|
|
33
17
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
bg: color[500],
|
|
44
|
-
}))
|
|
45
|
-
|
|
46
|
-
if (props.gradient) vars.push({
|
|
47
|
-
'--tw-gradient-stops': `${color[100]}, ${color[800]}`,
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
return vars
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
style,
|
|
55
|
-
}
|
|
18
|
+
// variant: {
|
|
19
|
+
// type: String as PropType<'bar' | 'score'>,
|
|
20
|
+
// default: 'bar',
|
|
21
|
+
// validator: (value: string) => validators.variant.includes(value),
|
|
22
|
+
// },
|
|
23
|
+
gradient: Boolean,
|
|
24
|
+
animate: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: true,
|
|
56
27
|
},
|
|
28
|
+
thick: Boolean,
|
|
57
29
|
})
|
|
30
|
+
|
|
31
|
+
const { styles, classes, className } = useTheme('progress', theme, props)
|
|
58
32
|
</script>
|
|
59
33
|
|
|
60
34
|
<template>
|
|
61
35
|
<div
|
|
62
|
-
|
|
63
|
-
:class="[
|
|
64
|
-
|
|
36
|
+
:style="styles"
|
|
37
|
+
:class="[
|
|
38
|
+
className,
|
|
39
|
+
classes.wrapper
|
|
40
|
+
]"
|
|
65
41
|
>
|
|
66
42
|
<div
|
|
67
43
|
class="h-full"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import Progress from '../Progress.vue'
|
|
4
|
+
|
|
5
|
+
describe('Progress', () => {
|
|
6
|
+
it('renders without errors', () => {
|
|
7
|
+
const wrapper = mount(Progress)
|
|
8
|
+
|
|
9
|
+
expect(wrapper.vm).toBeTruthy()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { ThemeParams } from '../../composables/theme'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
classes: {
|
|
5
|
+
wrapper: 'inline-block relative cursor-pointer focus:outline-none group',
|
|
6
|
+
|
|
7
|
+
circle: ({ props }: ThemeParams) => {
|
|
8
|
+
let c = 'rounded-full flex justify-center items-center shrink-0 border-2 outline-offset-2 outline-slate-300 dark:outline-slate-500 group-focus:outline-1 group-focus:outline'
|
|
9
|
+
|
|
10
|
+
if (props.size === 'xs' || props.size === 'sm') c += ' h-4 w-4'
|
|
11
|
+
if (props.size === 'xl') c += ' h-6 w-6'
|
|
12
|
+
else c += ' h-5 w-5'
|
|
13
|
+
|
|
14
|
+
return c
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
circleIcon: ({ props, data }: ThemeParams) => {
|
|
18
|
+
const c = []
|
|
19
|
+
|
|
20
|
+
if (!data.selected) c.push('opacity-0')
|
|
21
|
+
|
|
22
|
+
if (props.size === 'sm' || props.size === 'xs') c.push('h-2')
|
|
23
|
+
else if (props.size === 'lg') c.push('h-2.5')
|
|
24
|
+
else if (props.size === 'xl') c.push('h-3')
|
|
25
|
+
else c.push('h-[0.6rem]')
|
|
26
|
+
|
|
27
|
+
return c
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
label: ({ props, data }: ThemeParams) => {
|
|
31
|
+
let c = 'font-medium text-gray-800 dark:text-gray-200 pl-2'
|
|
32
|
+
|
|
33
|
+
if (props.size === 'xs') c += ' text-xs'
|
|
34
|
+
else if (props.size === 'sm') c += ' text-sm'
|
|
35
|
+
else if (props.size === 'lg') c += ' text-lg'
|
|
36
|
+
else if (props.size === 'xl') c += ' text-xl'
|
|
37
|
+
|
|
38
|
+
return c
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
content: ({ props }: ThemeParams) => {
|
|
42
|
+
let c = 'pl-2'
|
|
43
|
+
|
|
44
|
+
if (props.size === 'xs') c += ' text-xs'
|
|
45
|
+
else if (props.size === 'sm') c += ' text-sm'
|
|
46
|
+
else if (props.size === 'lg') c += ' text-lg'
|
|
47
|
+
else if (props.size === 'xl') c += ' text-xl'
|
|
48
|
+
|
|
49
|
+
return c
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
styles: ({ props, colors, css, data }: ThemeParams) => {
|
|
54
|
+
const gray = colors.getPalette('gray')
|
|
55
|
+
const color = colors.getPalette(props.color)
|
|
56
|
+
const vars = []
|
|
57
|
+
|
|
58
|
+
if (props.loading) {
|
|
59
|
+
return css.variables({
|
|
60
|
+
bg: 'transparent',
|
|
61
|
+
border: 'transparent',
|
|
62
|
+
dark: {
|
|
63
|
+
bg: 'transparent',
|
|
64
|
+
border: 'transparent',
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (props.disabled) {
|
|
70
|
+
if (data.selected) {
|
|
71
|
+
vars.push(css.variables({
|
|
72
|
+
bg: 'transparent',
|
|
73
|
+
border: gray[200],
|
|
74
|
+
circle: gray[200],
|
|
75
|
+
dark: {
|
|
76
|
+
bg: 'transparent',
|
|
77
|
+
border: gray[700],
|
|
78
|
+
circle: gray[700],
|
|
79
|
+
},
|
|
80
|
+
}))
|
|
81
|
+
} else {
|
|
82
|
+
vars.push(css.variables({
|
|
83
|
+
bg: gray[200],
|
|
84
|
+
border: gray[200],
|
|
85
|
+
dark: {
|
|
86
|
+
bg: gray[700],
|
|
87
|
+
border: gray[700],
|
|
88
|
+
},
|
|
89
|
+
}))
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
if (data.selected) {
|
|
93
|
+
vars.push(css.variables({
|
|
94
|
+
bg: 'transparent',
|
|
95
|
+
border: color[500],
|
|
96
|
+
circle: color[500],
|
|
97
|
+
dark: {
|
|
98
|
+
bg: 'transparent',
|
|
99
|
+
border: color[500],
|
|
100
|
+
circle: color[500],
|
|
101
|
+
},
|
|
102
|
+
}))
|
|
103
|
+
} else {
|
|
104
|
+
vars.push(css.variables({
|
|
105
|
+
bg: '#fff',
|
|
106
|
+
border: props.glow ? color[300] : gray[300],
|
|
107
|
+
dark: {
|
|
108
|
+
bg: gray[900],
|
|
109
|
+
border: props.glow ? color[300] : gray[300],
|
|
110
|
+
},
|
|
111
|
+
}))
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (props.glow) {
|
|
115
|
+
vars.push(css.get('glow', colors.getColorOpacity(color[500], 0.5)))
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return vars
|
|
120
|
+
},
|
|
121
|
+
}
|