@indielayer/ui 1.0.0-alpha.8 → 1.0.1
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/common/icons.d.ts +15 -0
- package/lib/common/utils.d.ts +32 -0
- package/lib/components/alert/Alert.theme.d.ts +8 -0
- package/lib/components/alert/Alert.vue.d.ts +1 -12
- package/lib/components/alert/__tests__/Alert.spec.d.ts +1 -0
- package/lib/components/avatar/Avatar.theme.d.ts +8 -0
- package/lib/components/avatar/Avatar.vue.d.ts +5 -8
- package/lib/components/avatar/__tests__/Avatar.spec.d.ts +1 -0
- package/lib/components/badge/Badge.theme.d.ts +8 -0
- package/lib/components/badge/Badge.vue.d.ts +5 -6
- package/lib/components/badge/__tests__/Badge.spec.d.ts +1 -0
- package/lib/components/breadcrumbs/Breadcrumbs.theme.d.ts +8 -0
- package/lib/components/breadcrumbs/Breadcrumbs.vue.d.ts +19 -8
- package/lib/components/breadcrumbs/__tests__/Breadcrumbs.spec.d.ts +1 -0
- package/lib/components/button/Button.theme.d.ts +10 -0
- package/lib/components/button/Button.vue.d.ts +10 -16
- package/lib/components/button/ButtonGroup.theme.d.ts +6 -0
- package/lib/components/button/ButtonGroup.vue.d.ts +5 -2
- package/lib/components/button/__tests__/ Button.spec.d.ts +1 -0
- package/lib/components/button/__tests__/ ButtonGroup.spec.d.ts +1 -0
- package/lib/components/card/Card.theme.d.ts +7 -0
- package/lib/components/card/Card.vue.d.ts +2 -2
- package/lib/components/card/__tests__/Card.spec.d.ts +1 -0
- package/lib/components/checkbox/Checkbox.theme.d.ts +11 -0
- package/lib/components/checkbox/Checkbox.vue.d.ts +10 -14
- package/lib/components/checkbox/__tests__/Checkbox.spec.d.ts +1 -0
- package/lib/components/collapse/Collapse.theme.d.ts +9 -0
- package/lib/components/collapse/Collapse.vue.d.ts +12 -19
- package/lib/components/collapse/__tests__/Collapse.spec.d.ts +1 -0
- package/lib/components/container/Container.theme.d.ts +6 -0
- package/lib/components/container/Container.vue.d.ts +1 -1
- package/lib/components/container/__tests__/Container.spec.d.ts +1 -0
- package/lib/components/divider/Divider.theme.d.ts +9 -0
- package/lib/components/divider/Divider.vue.d.ts +1 -1
- package/lib/components/divider/__tests__/Divider.spec.d.ts +1 -0
- package/lib/components/drawer/Drawer.theme.d.ts +7 -0
- package/lib/components/drawer/Drawer.vue.d.ts +3 -15
- package/lib/components/drawer/__tests__/Drawer.spec.d.ts +1 -0
- package/lib/components/form/Form.theme.d.ts +6 -0
- package/lib/components/form/Form.vue.d.ts +9 -7
- package/lib/components/form/__tests__/Form.spec.d.ts +1 -0
- package/lib/components/helpers/InputError.d.ts +8 -0
- package/lib/components/icon/Icon.theme.d.ts +7 -0
- package/lib/components/icon/Icon.vue.d.ts +4 -8
- package/lib/components/icon/__tests__/Icon.spec.d.ts +1 -0
- package/lib/components/image/Image.theme.d.ts +6 -0
- package/lib/components/image/Image.vue.d.ts +1 -3
- package/lib/components/image/__tests__/Image.spec.d.ts +1 -0
- package/lib/components/index.d.ts +3 -3
- package/lib/components/input/Input.theme.d.ts +11 -0
- package/lib/components/input/Input.vue.d.ts +27 -25
- package/lib/components/input/__tests__/Input.spec.d.ts +1 -0
- package/lib/components/link/Link.theme.d.ts +8 -0
- package/lib/components/link/Link.vue.d.ts +3 -5
- package/lib/components/link/__tests__/Link.spec.d.ts +1 -0
- package/lib/components/menu/Menu.theme.d.ts +6 -0
- package/lib/components/menu/Menu.vue.d.ts +6 -3
- package/lib/components/menu/MenuItem.theme.d.ts +8 -0
- package/lib/components/menu/MenuItem.vue.d.ts +5 -30
- package/lib/components/menu/__tests__/Menu.spec.d.ts +1 -0
- package/lib/components/menu/__tests__/MenuItem.spec.d.ts +1 -0
- package/lib/components/modal/Modal.theme.d.ts +13 -0
- package/lib/components/modal/Modal.vue.d.ts +1 -6
- package/lib/components/modal/__tests__/Modal.spec.d.ts +1 -0
- package/lib/components/notifications/Notifications.theme.d.ts +8 -0
- package/lib/components/notifications/Notifications.vue.d.ts +11 -24
- package/lib/components/notifications/__tests__/Notifications.spec.d.ts +1 -0
- package/lib/components/pagination/Pagination.theme.d.ts +9 -0
- package/lib/components/pagination/Pagination.vue.d.ts +7 -16
- package/lib/components/pagination/PaginationItem.theme.d.ts +7 -0
- package/lib/components/pagination/PaginationItem.vue.d.ts +4 -3
- package/lib/components/pagination/__tests__/Pagination.spec.d.ts +1 -0
- package/lib/components/pagination/__tests__/PaginationItem.spec.d.ts +1 -0
- package/lib/components/popover/Popover.theme.d.ts +7 -0
- package/lib/components/popover/Popover.vue.d.ts +13 -13
- package/lib/components/popover/PopoverContainer.theme.d.ts +6 -0
- package/lib/components/popover/PopoverContainer.vue.d.ts +1 -1
- package/lib/components/popover/__tests__/Popover.spec.d.ts +1 -0
- package/lib/components/popover/__tests__/PopoverContainer.spec.d.ts +1 -0
- package/lib/components/progress/Progress.theme.d.ts +10 -0
- package/lib/components/progress/Progress.vue.d.ts +1 -3
- package/lib/components/progress/__tests__/Progress.spec.d.ts +1 -0
- package/lib/components/radio/Radio.theme.d.ts +12 -0
- package/lib/components/radio/Radio.vue.d.ts +12 -13
- package/lib/components/radio/__tests__/Radio.spec.d.ts +1 -0
- package/lib/components/scroll/Scroll.theme.d.ts +6 -0
- package/lib/components/scroll/Scroll.vue.d.ts +1 -7
- package/lib/components/scroll/__tests__/Scroll.spec.d.ts +1 -0
- package/lib/components/select/Select.theme.d.ts +13 -0
- package/lib/components/select/Select.vue.d.ts +8 -28
- package/lib/components/select/__tests__/Select.spec.d.ts +1 -0
- package/lib/components/skeleton/Skeleton.theme.d.ts +6 -0
- package/lib/components/skeleton/Skeleton.vue.d.ts +1 -1
- package/lib/components/skeleton/__tests__/Skeleton.spec.d.ts +1 -0
- package/lib/components/slider/Slider.theme.d.ts +10 -0
- package/lib/components/slider/Slider.vue.d.ts +8 -17
- package/lib/components/slider/__tests__/Slider.spec.d.ts +1 -0
- package/lib/components/spacer/Spacer.d.ts +2 -0
- package/lib/components/spacer/__tests__/Spacer.spec.d.ts +1 -0
- package/lib/components/spinner/Spinner.vue.d.ts +15 -6
- package/lib/components/spinner/__tests__/Spinner.spec.d.ts +1 -0
- package/lib/components/tab/Tab.theme.d.ts +9 -0
- package/lib/components/tab/Tab.vue.d.ts +4 -13
- package/lib/components/tab/TabGroup.theme.d.ts +10 -0
- package/lib/components/tab/TabGroup.vue.d.ts +4 -8
- package/lib/components/tab/__tests__/Tab.spec.d.ts +1 -0
- package/lib/components/tab/__tests__/TabGroup.spec.d.ts +1 -0
- package/lib/components/table/Table.theme.d.ts +8 -0
- package/lib/components/table/Table.vue.d.ts +6 -10
- package/lib/components/table/TableBody.d.ts +2 -0
- package/lib/components/table/TableCell.theme.d.ts +7 -0
- package/lib/components/table/TableCell.vue.d.ts +1 -1
- package/lib/components/table/TableHead.d.ts +2 -0
- package/lib/components/table/TableHeader.vue.d.ts +2 -2
- package/lib/components/table/TableRow.vue.d.ts +1 -1
- package/lib/components/table/__tests__/Table.spec.d.ts +1 -0
- package/lib/components/tag/Tag.theme.d.ts +9 -0
- package/lib/components/tag/Tag.vue.d.ts +5 -5
- package/lib/components/tag/__tests__/Tag.spec.d.ts +1 -0
- package/lib/components/textarea/Textarea.theme.d.ts +10 -0
- package/lib/components/textarea/Textarea.vue.d.ts +18 -24
- package/lib/components/textarea/__tests__/Textarea.spec.d.ts +1 -0
- package/lib/components/toggle/Toggle.theme.d.ts +11 -0
- package/lib/components/toggle/Toggle.vue.d.ts +10 -11
- package/lib/components/toggle/__tests__/Toggle.spec.d.ts +1 -0
- package/lib/components/tooltip/Tooltip.theme.d.ts +11 -0
- package/lib/components/tooltip/__tests__/Tooltip.spec.d.ts +1 -0
- package/lib/composables/colors-utils.d.ts +0 -1
- package/lib/composables/colors.d.ts +8 -4
- package/lib/composables/common.d.ts +1 -0
- package/lib/composables/css.d.ts +6 -5
- package/lib/composables/index.d.ts +1 -1
- package/lib/composables/inputtable.d.ts +1 -1
- package/lib/composables/interactive.d.ts +7 -2
- package/lib/composables/keys.d.ts +1 -0
- package/lib/composables/notifications.d.ts +1 -0
- package/lib/composables/theme.d.ts +20 -0
- package/lib/create.d.ts +3 -2
- package/lib/index.cjs.js +1 -15
- package/lib/index.es.js +4451 -3649
- package/lib/nuxt.js +2 -1
- package/lib/version.d.ts +1 -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 +8 -3
- package/src/exports/nuxt.js +2 -1
- package/src/version.ts +1 -1
- package/volar.d.ts +1 -0
- package/lib/components/spacer/Spacer.vue.d.ts +0 -2
- package/lib/components/table/TableBody.vue.d.ts +0 -2
- package/lib/components/table/TableHead.vue.d.ts +0 -2
- package/lib/composables/notification.d.ts +0 -1
- package/lib/style.css +0 -1
- package/src/components/table/TableHead.vue +0 -15
- package/src/composables/notification.ts +0 -10
|
@@ -1,78 +1,66 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export default { name: 'XToggle' }
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { computed, ref } from 'vue'
|
|
7
|
+
import { useTheme } from '../../composables/theme'
|
|
4
8
|
import { useCommon } from '../../composables/common'
|
|
5
9
|
import { useColors } from '../../composables/colors'
|
|
6
10
|
import { useInputtable } from '../../composables/inputtable'
|
|
7
11
|
import { useInteractive } from '../../composables/interactive'
|
|
8
12
|
|
|
9
13
|
import XSpinner from '../../components/spinner/Spinner.vue'
|
|
14
|
+
import XInputError from '../helpers/InputError'
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
name: 'XToggle',
|
|
13
|
-
|
|
14
|
-
components: {
|
|
15
|
-
XSpinner,
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
validators: {
|
|
19
|
-
...useCommon.validators(),
|
|
20
|
-
},
|
|
16
|
+
import theme from './Toggle.theme'
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
const props = defineProps({
|
|
19
|
+
...useCommon.props(),
|
|
20
|
+
...useColors.props('primary'),
|
|
21
|
+
...useInteractive.props(),
|
|
22
|
+
...useInputtable.props(),
|
|
23
|
+
id: String,
|
|
24
|
+
label: String,
|
|
25
|
+
helper: String,
|
|
26
|
+
glow: Boolean,
|
|
27
|
+
})
|
|
31
28
|
|
|
32
|
-
|
|
29
|
+
const emit = defineEmits(useInputtable.emits(false))
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
const elRef = ref<HTMLElement>()
|
|
36
|
-
const checked = computed({
|
|
37
|
-
get(): boolean {
|
|
38
|
-
return !!props.modelValue
|
|
39
|
-
},
|
|
40
|
-
set(val: boolean) {
|
|
41
|
-
emit('update:modelValue', val)
|
|
42
|
-
},
|
|
43
|
-
})
|
|
31
|
+
const elRef = ref<HTMLElement | null>(null)
|
|
44
32
|
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
const checked = computed({
|
|
34
|
+
get(): boolean {
|
|
35
|
+
return !!props.modelValue
|
|
36
|
+
},
|
|
37
|
+
set(val: boolean) {
|
|
38
|
+
emit('update:modelValue', val)
|
|
39
|
+
},
|
|
40
|
+
})
|
|
47
41
|
|
|
48
|
-
|
|
49
|
-
const color = colors.getPalette(props.color)
|
|
42
|
+
const { focus, blur } = useInteractive(elRef)
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})
|
|
44
|
+
const {
|
|
45
|
+
errorInternal,
|
|
46
|
+
reset,
|
|
47
|
+
validate,
|
|
48
|
+
setError,
|
|
49
|
+
} = useInputtable(props, { focus, emit, withListeners: false })
|
|
58
50
|
|
|
59
|
-
|
|
51
|
+
const { styles, classes, className } = useTheme('toggle', theme, props)
|
|
60
52
|
|
|
61
|
-
|
|
62
|
-
...interactive,
|
|
63
|
-
...useInputtable(props, { focus: interactive.focus, emit, withListeners: false }),
|
|
64
|
-
elRef,
|
|
65
|
-
checked,
|
|
66
|
-
styles,
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
})
|
|
53
|
+
defineExpose({ focus, blur, reset, validate, setError })
|
|
70
54
|
</script>
|
|
71
55
|
|
|
72
56
|
<template>
|
|
73
57
|
<label
|
|
74
58
|
class="inline-block"
|
|
75
|
-
:class="[
|
|
59
|
+
:class="[
|
|
60
|
+
className,
|
|
61
|
+
classes.wrapper,
|
|
62
|
+
disabled ? 'cursor-not-allowed' : 'cursor-pointer'
|
|
63
|
+
]"
|
|
76
64
|
>
|
|
77
65
|
<div class="flex items-center">
|
|
78
66
|
<div
|
|
@@ -82,20 +70,10 @@ export default defineComponent({
|
|
|
82
70
|
[`shadow-lg shadow-${color}-500/50`]: glow && modelValue,
|
|
83
71
|
'bg-gray-300 dark:bg-gray-500': !disabled && !checked && !loading,
|
|
84
72
|
'bg-gray-100 dark:bg-gray-700': disabled || loading,
|
|
85
|
-
'bg-[color:var(--x-bg)]': !disabled && checked,
|
|
73
|
+
'bg-[color:var(--x-toggle-bg)] dark:bg-[color:var(--x-toggle-dark-bg)]': !disabled && checked,
|
|
86
74
|
}"
|
|
87
75
|
>
|
|
88
|
-
<div
|
|
89
|
-
class="relative shrink-0"
|
|
90
|
-
:class="[
|
|
91
|
-
{
|
|
92
|
-
'w-6': size === 'sm' || size === 'xs',
|
|
93
|
-
'w-8': !size || !['xs', 'sm', 'lg', 'xl'].includes(size),
|
|
94
|
-
'w-10': size === 'lg',
|
|
95
|
-
'w-12': size === 'xl',
|
|
96
|
-
}
|
|
97
|
-
]"
|
|
98
|
-
>
|
|
76
|
+
<div :class="classes.buttonWrapper">
|
|
99
77
|
<input
|
|
100
78
|
:id="id"
|
|
101
79
|
ref="elRef"
|
|
@@ -110,35 +88,27 @@ export default defineComponent({
|
|
|
110
88
|
:value="modelValue"
|
|
111
89
|
/>
|
|
112
90
|
<div
|
|
113
|
-
class="rounded-full shadow transform transition duration-300 flex-shrink-0"
|
|
114
91
|
:class="[
|
|
92
|
+
classes.button,
|
|
115
93
|
{
|
|
116
|
-
'h-3 w-3': size === 'sm' || size === 'xs',
|
|
117
|
-
'h-4 w-4': !size || !['xs', 'sm', 'lg', 'xl'].includes(size),
|
|
118
|
-
'h-5 w-5': size === 'lg',
|
|
119
|
-
'h-6 w-6': size === 'xl',
|
|
120
94
|
'translate-x-full': checked,
|
|
121
|
-
'
|
|
95
|
+
'shadow': !disabled
|
|
122
96
|
},
|
|
123
|
-
|
|
97
|
+
disabled ? 'bg-gray-50 dark:bg-gray-800' : 'bg-white dark:bg-gray-800'
|
|
124
98
|
]"
|
|
125
99
|
></div>
|
|
126
100
|
</div>
|
|
127
101
|
</div>
|
|
128
102
|
<span
|
|
129
103
|
v-if="label"
|
|
130
|
-
class="
|
|
131
|
-
:class="
|
|
132
|
-
'text-xs': size === 'xs',
|
|
133
|
-
'text-sm': size === 'sm',
|
|
134
|
-
'text-lg': size === 'lg',
|
|
135
|
-
'text-xl': size === 'xl',
|
|
136
|
-
}"
|
|
104
|
+
class="ml-2"
|
|
105
|
+
:class="classes.label"
|
|
137
106
|
v-text="label"
|
|
138
107
|
>
|
|
139
108
|
</span>
|
|
140
109
|
<x-spinner v-if="loading" :size="size" class="ml-1" />
|
|
141
110
|
</div>
|
|
142
|
-
|
|
111
|
+
|
|
112
|
+
<x-input-error :error="errorInternal" :helper="helper"/>
|
|
143
113
|
</label>
|
|
144
114
|
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import Toggle from '../Toggle.vue'
|
|
4
|
+
|
|
5
|
+
describe('Toggle', () => {
|
|
6
|
+
it('renders without errors', () => {
|
|
7
|
+
const wrapper = mount(Toggle)
|
|
8
|
+
|
|
9
|
+
expect(wrapper.vm).toBeTruthy()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ThemeParams } from '../../composables/theme'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
classes: {
|
|
5
|
+
wrapper: '',
|
|
6
|
+
|
|
7
|
+
label: ({ props }: ThemeParams) => {
|
|
8
|
+
const c = 'font-medium text-gray-800 dark:text-gray-200'
|
|
9
|
+
|
|
10
|
+
if (props.size === 'xs') return c + ' text-xs'
|
|
11
|
+
else if (props.size === 'sm') return c + ' text-sm'
|
|
12
|
+
else if (props.size === 'lg') return c + ' text-lg'
|
|
13
|
+
else if (props.size === 'xl') return c + ' text-xl'
|
|
14
|
+
|
|
15
|
+
return c + ' text-sm'
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
buttonWrapper: ({ props }: ThemeParams) => {
|
|
19
|
+
let c = 'relative shrink-0'
|
|
20
|
+
|
|
21
|
+
if (props.size === 'sm' || props.size === 'xs') c += ' w-6'
|
|
22
|
+
else if (props.size === 'lg') c += ' w-10'
|
|
23
|
+
else if (props.size === 'xl') c += ' w-12'
|
|
24
|
+
else c += ' w-8'
|
|
25
|
+
|
|
26
|
+
return c
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
button: ({ props }: ThemeParams) => {
|
|
30
|
+
let c = 'rounded-full shadow transform transition duration-300 shrink-0'
|
|
31
|
+
|
|
32
|
+
if (props.size === 'sm' || props.size === 'xs') c += ' h-3 w-3'
|
|
33
|
+
else if (props.size === 'lg') c += ' h-5 w-5'
|
|
34
|
+
else if (props.size === 'xl') c += ' h-6 w-6'
|
|
35
|
+
else c += ' h-4 w-4'
|
|
36
|
+
|
|
37
|
+
return c
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
styles: ({ colors, props, css }: ThemeParams) => {
|
|
42
|
+
const color = colors.getPalette(props.color)
|
|
43
|
+
|
|
44
|
+
return css.variables({
|
|
45
|
+
bg: color[500],
|
|
46
|
+
dark: {
|
|
47
|
+
bg: color[600],
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
},
|
|
51
|
+
}
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
2
|
+
export default { name: 'XTooltip' }
|
|
3
|
+
</script>
|
|
3
4
|
|
|
5
|
+
<script setup lang="ts">
|
|
4
6
|
import XPopover from '../../components/popover/Popover.vue'
|
|
5
7
|
import XPopoverContainer from '../../components/popover/PopoverContainer.vue'
|
|
6
|
-
|
|
7
|
-
export default defineComponent({
|
|
8
|
-
name: 'XTooltip',
|
|
9
|
-
|
|
10
|
-
components: {
|
|
11
|
-
XPopover,
|
|
12
|
-
XPopoverContainer,
|
|
13
|
-
},
|
|
14
|
-
})
|
|
15
8
|
</script>
|
|
16
9
|
|
|
17
10
|
<template>
|
|
18
|
-
<x-popover hover
|
|
11
|
+
<x-popover hover>
|
|
19
12
|
<slot></slot>
|
|
20
13
|
<template #content>
|
|
21
|
-
<
|
|
22
|
-
<
|
|
23
|
-
|
|
14
|
+
<div class="dark">
|
|
15
|
+
<x-popover-container class="p-2 text-white text-sm w-max max-w-xs">
|
|
16
|
+
<slot name="tooltip"></slot>
|
|
17
|
+
</x-popover-container>
|
|
18
|
+
</div>
|
|
24
19
|
</template>
|
|
25
20
|
</x-popover>
|
|
26
21
|
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import Tooltip from '../Tooltip.vue'
|
|
4
|
+
|
|
5
|
+
describe('Tooltip', () => {
|
|
6
|
+
it('renders without errors', () => {
|
|
7
|
+
const wrapper = mount(Tooltip)
|
|
8
|
+
|
|
9
|
+
expect(wrapper.vm).toBeTruthy()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -34,81 +34,81 @@ export const shades: Tone[] = ['50', '100', '200', '300', '400', '500', '600', '
|
|
|
34
34
|
export const indielayerColors = ['primary', 'secondary', 'success', 'warning', 'error']
|
|
35
35
|
|
|
36
36
|
// calculate custom colors
|
|
37
|
-
export function calculateColors(): ColorLibrary {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
// export function calculateColors(): ColorLibrary {
|
|
38
|
+
// const cc = computedColors
|
|
39
|
+
// const customColors: ColorLibrary = {}
|
|
40
|
+
// const e = document.createElement('div')
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
// document.body.appendChild(e)
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// indielayerColors.forEach((color) => {
|
|
45
|
+
// const c: ColorPalette = { ...tailwindColors.gray }
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
// shades.forEach((shade) => {
|
|
48
|
+
// e.className = `bg-${color}-${shade}`
|
|
49
|
+
// c[shade] = window.getComputedStyle(e ,null).getPropertyValue('background-color')
|
|
50
|
+
// })
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
// customColors[color] = c
|
|
53
|
+
// })
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
// e.remove()
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
}
|
|
57
|
+
// return customColors
|
|
58
|
+
// }
|
|
59
59
|
|
|
60
|
-
const computedColors = Object.freeze([
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
])
|
|
60
|
+
// const computedColors = Object.freeze([
|
|
61
|
+
// 'bg-primary-50',
|
|
62
|
+
// 'bg-primary-100',
|
|
63
|
+
// 'bg-primary-200',
|
|
64
|
+
// 'bg-primary-300',
|
|
65
|
+
// 'bg-primary-400',
|
|
66
|
+
// 'bg-primary-500',
|
|
67
|
+
// 'bg-primary-600',
|
|
68
|
+
// 'bg-primary-700',
|
|
69
|
+
// 'bg-primary-800',
|
|
70
|
+
// 'bg-primary-900',
|
|
71
|
+
// 'bg-secondary-50',
|
|
72
|
+
// 'bg-secondary-100',
|
|
73
|
+
// 'bg-secondary-200',
|
|
74
|
+
// 'bg-secondary-300',
|
|
75
|
+
// 'bg-secondary-400',
|
|
76
|
+
// 'bg-secondary-500',
|
|
77
|
+
// 'bg-secondary-600',
|
|
78
|
+
// 'bg-secondary-700',
|
|
79
|
+
// 'bg-secondary-800',
|
|
80
|
+
// 'bg-secondary-900',
|
|
81
|
+
// 'bg-error-50',
|
|
82
|
+
// 'bg-error-100',
|
|
83
|
+
// 'bg-error-200',
|
|
84
|
+
// 'bg-error-300',
|
|
85
|
+
// 'bg-error-400',
|
|
86
|
+
// 'bg-error-500',
|
|
87
|
+
// 'bg-error-600',
|
|
88
|
+
// 'bg-error-700',
|
|
89
|
+
// 'bg-error-800',
|
|
90
|
+
// 'bg-error-900',
|
|
91
|
+
// 'bg-warning-50',
|
|
92
|
+
// 'bg-warning-100',
|
|
93
|
+
// 'bg-warning-200',
|
|
94
|
+
// 'bg-warning-300',
|
|
95
|
+
// 'bg-warning-400',
|
|
96
|
+
// 'bg-warning-500',
|
|
97
|
+
// 'bg-warning-600',
|
|
98
|
+
// 'bg-warning-700',
|
|
99
|
+
// 'bg-warning-800',
|
|
100
|
+
// 'bg-warning-900',
|
|
101
|
+
// 'bg-success-50',
|
|
102
|
+
// 'bg-success-100',
|
|
103
|
+
// 'bg-success-200',
|
|
104
|
+
// 'bg-success-300',
|
|
105
|
+
// 'bg-success-400',
|
|
106
|
+
// 'bg-success-500',
|
|
107
|
+
// 'bg-success-600',
|
|
108
|
+
// 'bg-success-700',
|
|
109
|
+
// 'bg-success-800',
|
|
110
|
+
// 'bg-success-900',
|
|
111
|
+
// ])
|
|
112
112
|
|
|
113
113
|
export const tailwindColors: ColorLibrary = Object.freeze({
|
|
114
114
|
slate: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as R from 'ramda'
|
|
2
|
+
import { computed, inject, unref } from 'vue'
|
|
3
|
+
import { injectThemeKey } from './keys'
|
|
3
4
|
import { isValidColor, tailwindColors, colorShade, setOpacity } from './colors-utils'
|
|
4
5
|
|
|
5
6
|
export type Tone = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'
|
|
@@ -19,6 +20,15 @@ export interface ColorPalette {
|
|
|
19
20
|
|
|
20
21
|
export type ColorLibrary = Record<string, ColorPalette>
|
|
21
22
|
|
|
23
|
+
export interface ColorsProps {
|
|
24
|
+
color?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ColorComposition {
|
|
28
|
+
getPalette: (color: string)=> ColorPalette
|
|
29
|
+
getColorOpacity: (color: string, opacity: number)=> string
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
const colorCache: ColorLibrary = {}
|
|
23
33
|
|
|
24
34
|
const defaultColors = {
|
|
@@ -29,20 +39,22 @@ const defaultColors = {
|
|
|
29
39
|
error: tailwindColors.red,
|
|
30
40
|
}
|
|
31
41
|
|
|
32
|
-
export const useColors = () => {
|
|
33
|
-
const
|
|
34
|
-
|
|
42
|
+
export const useColors = (): ColorComposition => {
|
|
43
|
+
const globalTheme = inject(injectThemeKey, {})
|
|
44
|
+
const customColors = computed(() => R.mergeRight(defaultColors, unref(globalTheme).colors))
|
|
35
45
|
|
|
36
46
|
const getTailwindColor = (color: string) => tailwindColors[color]
|
|
37
47
|
|
|
38
48
|
const getColorOpacity = (color: string, opacity: number) => setOpacity(color, opacity)
|
|
39
49
|
|
|
40
50
|
const getPalette = (color: string): ColorPalette => {
|
|
51
|
+
if (!color) return getTailwindColor('gray')
|
|
52
|
+
|
|
41
53
|
const twColor = getTailwindColor(color)
|
|
42
54
|
|
|
43
55
|
if (twColor) return twColor
|
|
44
56
|
if (colorCache[color]) return colorCache[color]
|
|
45
|
-
if (customColors[color]) return customColors[color]
|
|
57
|
+
if (customColors.value[color]) return customColors.value[color]
|
|
46
58
|
|
|
47
59
|
if (!isValidColor(color)) {
|
|
48
60
|
console.warn(`Invalid color: ${color}`)
|
package/src/composables/css.ts
CHANGED
|
@@ -4,12 +4,17 @@ const modifiers = ['hover', 'active', 'focus', 'visited']
|
|
|
4
4
|
const isTheme = (theme: string) => themes.includes(theme)
|
|
5
5
|
const isModifier = (modifier: string) => modifiers.includes(modifier)
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export interface CSSComposition {
|
|
8
|
+
get: (name: string, value: string, theme?: string, modifier?: string)=> string
|
|
9
|
+
variable: (name: string, theme?: string, modifier?: string)=> string
|
|
10
|
+
variables: (object: Record<string, string | object>, theme?: string, modifier?: string)=> Record<string, string>
|
|
11
|
+
}
|
|
8
12
|
|
|
13
|
+
export const useCSS = (namespace?: string): CSSComposition => {
|
|
9
14
|
const get = (name: string, value: string, theme?: string, modifier?: string) => `${variable(name,theme,modifier)}: ${value}`
|
|
10
15
|
|
|
11
16
|
const variable = (name: string, theme?: string, modifier?: string) =>
|
|
12
|
-
`--x${
|
|
17
|
+
`--x${namespace ? `-${namespace}` : ''}${theme ? `-${theme}` : ''}-${name}${modifier ? `-${modifier}` : ''}`
|
|
13
18
|
|
|
14
19
|
const variables = (object: Record<string, string | object>, theme?: string, modifier?: string) => {
|
|
15
20
|
let styles: Record<string, string> = {}
|
package/src/composables/index.ts
CHANGED
|
@@ -112,7 +112,7 @@ useInputtable.emits = (withListeners = true): string[] => {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
useInputtable.props = () => ({
|
|
115
|
-
modelValue: [String, Number, Boolean, Object, Array] as PropType<
|
|
115
|
+
modelValue: [String, Number, Boolean, Object, Array] as PropType<string | number | boolean | object | any[] | undefined>,
|
|
116
116
|
name: String,
|
|
117
117
|
readonly: Boolean,
|
|
118
118
|
required: Boolean,
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { Ref } from 'vue'
|
|
2
2
|
|
|
3
|
+
export interface InteractiveProps {
|
|
4
|
+
disabled?: boolean
|
|
5
|
+
loading?: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
export const useInteractive = (
|
|
4
|
-
el: Ref<HTMLElement |
|
|
9
|
+
el: Ref<HTMLElement | null>,
|
|
5
10
|
) => {
|
|
6
11
|
return {
|
|
7
|
-
focus: () =>
|
|
8
|
-
|
|
9
|
-
},
|
|
12
|
+
focus: () => el.value?.focus?.(),
|
|
13
|
+
blur: () => el.value?.blur?.(),
|
|
10
14
|
}
|
|
11
15
|
}
|
|
12
16
|
|
package/src/composables/keys.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { InjectionKey } from 'vue'
|
|
|
2
2
|
|
|
3
3
|
export const injectTabKey = Symbol() as InjectionKey<any>
|
|
4
4
|
export const injectFormKey = Symbol() as InjectionKey<any>
|
|
5
|
+
export const injectThemeKey = Symbol() as InjectionKey<any>
|
|
5
6
|
export const injectIconsKey = Symbol() as InjectionKey<any>
|
|
6
7
|
export const injectColorsKey = Symbol() as InjectionKey<any>
|
|
7
8
|
export const injectButtonGroupKey = Symbol() as InjectionKey<any>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { inject } from 'vue'
|
|
2
|
+
import { injectNotificationKey } from './keys'
|
|
3
|
+
|
|
4
|
+
export const useNotifications = (key?: symbol | string) => {
|
|
5
|
+
const notifications = inject(key || injectNotificationKey)
|
|
6
|
+
|
|
7
|
+
if (!notifications) console.warn('useNotifications must have a parent wrapped with Notifications component')
|
|
8
|
+
|
|
9
|
+
return notifications
|
|
10
|
+
}
|