@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,322 +1,88 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export default { name: 'XButton' }
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { computed, ref, inject, useAttrs, unref } from 'vue'
|
|
7
|
+
import { useTheme } from '../../composables/theme'
|
|
5
8
|
import { useColors } from '../../composables/colors'
|
|
9
|
+
import { useCommon } from '../../composables/common'
|
|
6
10
|
import { useInteractive } from '../../composables/interactive'
|
|
7
11
|
import { injectButtonGroupKey } from '../../composables/keys'
|
|
8
12
|
|
|
9
|
-
import XSpinner from '
|
|
10
|
-
import XIcon from '
|
|
13
|
+
import XSpinner from '../spinner/Spinner.vue'
|
|
14
|
+
import XIcon from '../icon/Icon.vue'
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
import theme from './Button.theme'
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
validators: {
|
|
23
|
-
...useCommon.validators(),
|
|
18
|
+
const props = defineProps({
|
|
19
|
+
...useCommon.props(),
|
|
20
|
+
...useColors.props(),
|
|
21
|
+
...useInteractive.props(),
|
|
22
|
+
tag: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: 'button',
|
|
24
25
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
...useColors.props(),
|
|
29
|
-
...useInteractive.props(),
|
|
30
|
-
tag: {
|
|
31
|
-
type: String,
|
|
32
|
-
default: 'button',
|
|
33
|
-
},
|
|
34
|
-
type: {
|
|
35
|
-
type: String,
|
|
36
|
-
default: 'button',
|
|
37
|
-
},
|
|
38
|
-
icon: String,
|
|
39
|
-
iconRight: String,
|
|
40
|
-
to: String,
|
|
41
|
-
outlined: Boolean,
|
|
42
|
-
rounded: Boolean,
|
|
43
|
-
glow: Boolean,
|
|
44
|
-
ghost: Boolean,
|
|
45
|
-
light: Boolean,
|
|
46
|
-
block: Boolean,
|
|
47
|
-
flat: Boolean,
|
|
26
|
+
type: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: 'button',
|
|
48
29
|
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
outlined: undefined,
|
|
62
|
-
disabled: undefined,
|
|
63
|
-
},
|
|
64
|
-
})
|
|
65
|
-
const { isButtonGroup } = buttonGroup
|
|
66
|
-
|
|
67
|
-
const computedSize = computed(() => buttonGroup.groupProps.size || props.size)
|
|
68
|
-
const computedFlat = computed(() => buttonGroup.groupProps.flat || props.flat)
|
|
69
|
-
const computedColor = computed(() => props.color || buttonGroup.groupProps.color)
|
|
70
|
-
const computedGhost = computed(() => props.ghost || buttonGroup.groupProps.ghost)
|
|
71
|
-
const computedLight = computed(() => props.light || buttonGroup.groupProps.light)
|
|
72
|
-
const computedOutlined = computed(() => props.outlined || buttonGroup.groupProps.outlined)
|
|
73
|
-
const computedDisabled = computed(() => props.disabled || buttonGroup.groupProps.disabled)
|
|
74
|
-
const isLight = computed(() => computedColor.value && computedLight.value)
|
|
75
|
-
const isDefault = computed(() => !computedColor.value && !computedGhost.value)
|
|
76
|
-
const htmlTag = computed(() => (attrs.href ? 'a' : props.to ? 'router-link' : props.tag))
|
|
77
|
-
|
|
78
|
-
const css = useCSS('button')
|
|
79
|
-
const colors = useColors()
|
|
80
|
-
const gray = colors.getPalette('gray')
|
|
81
|
-
|
|
82
|
-
const styles = computed(() => {
|
|
83
|
-
const color = computedColor.value ? colors.getPalette(computedColor.value) : gray
|
|
84
|
-
const vars: (object | string)[] = []
|
|
85
|
-
|
|
86
|
-
if (props.glow) vars.push(css.get('glow', colors.getColorOpacity(computedColor.value ? color[500] : gray[500], 0.5)))
|
|
87
|
-
|
|
88
|
-
if (isDefault.value) {
|
|
89
|
-
if (computedDisabled.value) {
|
|
90
|
-
vars.push(css.variables({
|
|
91
|
-
bg: gray[50],
|
|
92
|
-
text: gray[300],
|
|
93
|
-
border: gray[200],
|
|
94
|
-
dark: {
|
|
95
|
-
bg: gray[900],
|
|
96
|
-
text: gray[600],
|
|
97
|
-
border: gray[700],
|
|
98
|
-
},
|
|
99
|
-
}))
|
|
100
|
-
} else {
|
|
101
|
-
vars.push(css.variables({
|
|
102
|
-
bg: 'white',
|
|
103
|
-
text: gray[800],
|
|
104
|
-
border: gray[300],
|
|
105
|
-
hover: { bg: !props.loading ? gray[100] : '' },
|
|
106
|
-
active: { bg: !props.loading ? gray[200] : '' },
|
|
107
|
-
dark: {
|
|
108
|
-
bg: gray[800],
|
|
109
|
-
text: 'white',
|
|
110
|
-
border: gray[600],
|
|
111
|
-
hover: { bg: !props.loading ? gray[700] : '' },
|
|
112
|
-
active: { bg: !props.loading ? gray[600] : '' },
|
|
113
|
-
},
|
|
114
|
-
}))
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// light
|
|
119
|
-
else if (isLight.value) {
|
|
120
|
-
if (!computedOutlined.value || computedDisabled.value) vars.push(css.get('border', 'transparent'))
|
|
121
|
-
|
|
122
|
-
if (computedDisabled.value) {
|
|
123
|
-
vars.push(css.variables({
|
|
124
|
-
bg: color[50],
|
|
125
|
-
text: color[200],
|
|
126
|
-
border: 'transparent',
|
|
127
|
-
dark: {
|
|
128
|
-
bg: color[900],
|
|
129
|
-
text: color[600],
|
|
130
|
-
border: 'transparent',
|
|
131
|
-
},
|
|
132
|
-
}))
|
|
133
|
-
} else {
|
|
134
|
-
vars.push(css.variables({
|
|
135
|
-
bg: color[50],
|
|
136
|
-
text: color[600],
|
|
137
|
-
border: computedOutlined.value ? color[500] : 'transparent',
|
|
138
|
-
hover: { bg: !props.loading ? color[100] : '' },
|
|
139
|
-
active: { bg: !props.loading ? color[200] : '' },
|
|
140
|
-
dark: {
|
|
141
|
-
bg: color[200],
|
|
142
|
-
text: color[800],
|
|
143
|
-
border: computedOutlined.value ? color[500] : 'transparent',
|
|
144
|
-
hover: { bg: !props.loading ? color[100] : '' },
|
|
145
|
-
active: { bg: !props.loading ? color[50] : '' },
|
|
146
|
-
},
|
|
147
|
-
}))
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// ghost
|
|
152
|
-
else if (computedGhost.value) {
|
|
153
|
-
if (!computedOutlined.value) vars.push(css.get('border', 'transparent'))
|
|
154
|
-
|
|
155
|
-
if (computedColor.value) {
|
|
156
|
-
if (computedDisabled.value) {
|
|
157
|
-
vars.push(css.variables({
|
|
158
|
-
text: color[200],
|
|
159
|
-
dark: {
|
|
160
|
-
text: color[700],
|
|
161
|
-
},
|
|
162
|
-
}))
|
|
163
|
-
} else {
|
|
164
|
-
vars.push(css.variables({
|
|
165
|
-
text: color[600],
|
|
166
|
-
dark: {
|
|
167
|
-
text: color[200],
|
|
168
|
-
},
|
|
169
|
-
}))
|
|
170
|
-
if (!props.loading) {
|
|
171
|
-
vars.push(css.variables({
|
|
172
|
-
hover: { bg: color[50] },
|
|
173
|
-
active: { bg: color[100] },
|
|
174
|
-
dark: {
|
|
175
|
-
hover: { bg: color[900] },
|
|
176
|
-
active: { bg: color[800] },
|
|
177
|
-
},
|
|
178
|
-
}))
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
} else {
|
|
182
|
-
if (computedDisabled.value) {
|
|
183
|
-
vars.push(css.variables({
|
|
184
|
-
text: gray[200],
|
|
185
|
-
dark: {
|
|
186
|
-
text: gray[700],
|
|
187
|
-
},
|
|
188
|
-
}))
|
|
189
|
-
} else {
|
|
190
|
-
vars.push(css.variables({
|
|
191
|
-
text: gray[800],
|
|
192
|
-
dark: {
|
|
193
|
-
text: 'white',
|
|
194
|
-
},
|
|
195
|
-
}))
|
|
196
|
-
if (!props.loading) {
|
|
197
|
-
vars.push(css.variables({
|
|
198
|
-
hover: { bg: gray[100] },
|
|
199
|
-
active: { bg: gray[200] },
|
|
200
|
-
dark: {
|
|
201
|
-
hover: { bg: gray[800] },
|
|
202
|
-
active: { bg: gray[700] },
|
|
203
|
-
},
|
|
204
|
-
}))
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
30
|
+
icon: String,
|
|
31
|
+
iconLeft: String,
|
|
32
|
+
iconRight: String,
|
|
33
|
+
to: String,
|
|
34
|
+
outlined: Boolean,
|
|
35
|
+
rounded: Boolean,
|
|
36
|
+
glow: Boolean,
|
|
37
|
+
ghost: Boolean,
|
|
38
|
+
light: Boolean,
|
|
39
|
+
block: Boolean,
|
|
40
|
+
flat: Boolean,
|
|
41
|
+
})
|
|
209
42
|
|
|
210
|
-
|
|
211
|
-
else {
|
|
212
|
-
if (computedOutlined.value) {
|
|
213
|
-
if (computedDisabled.value) {
|
|
214
|
-
vars.push(css.variables({
|
|
215
|
-
text: color[200],
|
|
216
|
-
border: color[200],
|
|
217
|
-
dark: {
|
|
218
|
-
text: color[700],
|
|
219
|
-
border: color[700],
|
|
220
|
-
},
|
|
221
|
-
}))
|
|
222
|
-
} else {
|
|
223
|
-
vars.push(css.variables({
|
|
224
|
-
text: color[600],
|
|
225
|
-
border: color[600],
|
|
226
|
-
dark: {
|
|
227
|
-
text: color[300],
|
|
228
|
-
border: color[300],
|
|
229
|
-
},
|
|
230
|
-
}))
|
|
231
|
-
if (!props.loading) {
|
|
232
|
-
vars.push(css.variables({
|
|
233
|
-
hover: { bg: color[100] },
|
|
234
|
-
active: { bg: color[200] },
|
|
235
|
-
dark: {
|
|
236
|
-
hover: { bg: color[800] },
|
|
237
|
-
active: { bg: color[700] },
|
|
238
|
-
},
|
|
239
|
-
}))
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
} else {
|
|
243
|
-
vars.push(css.variables({
|
|
244
|
-
text: '#fff',
|
|
245
|
-
border: !isButtonGroup ? 'transparent' : color[600],
|
|
246
|
-
dark: {
|
|
247
|
-
text: '#fff',
|
|
248
|
-
border: !isButtonGroup ? 'transparent' : color[500],
|
|
249
|
-
},
|
|
250
|
-
}))
|
|
251
|
-
if (computedDisabled.value) {
|
|
252
|
-
vars.push(css.variables({
|
|
253
|
-
bg: color[100],
|
|
254
|
-
dark: {
|
|
255
|
-
bg: color[900],
|
|
256
|
-
},
|
|
257
|
-
}))
|
|
258
|
-
} else {
|
|
259
|
-
vars.push(css.variables({
|
|
260
|
-
bg: color[500],
|
|
261
|
-
hover: { bg: !props.loading ? color[600] : '' },
|
|
262
|
-
active: { bg: !props.loading ? color[800] : '' },
|
|
263
|
-
dark: {
|
|
264
|
-
bg: color[600],
|
|
265
|
-
hover: { bg: !props.loading ? color[500] : '' },
|
|
266
|
-
active: { bg: !props.loading ? color[400] : '' },
|
|
267
|
-
},
|
|
268
|
-
}))
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
43
|
+
const elRef = ref<HTMLElement | null>(null)
|
|
272
44
|
|
|
273
|
-
|
|
274
|
-
|
|
45
|
+
// Button group props
|
|
46
|
+
const buttonGroup = inject(injectButtonGroupKey, {
|
|
47
|
+
isButtonGroup: false,
|
|
48
|
+
groupProps: {},
|
|
49
|
+
})
|
|
50
|
+
const { isButtonGroup } = buttonGroup
|
|
51
|
+
const computedSize = computed(() => buttonGroup.groupProps.size || props.size)
|
|
52
|
+
const computedFlat = computed(() => buttonGroup.groupProps.flat || props.flat)
|
|
53
|
+
const computedColor = computed(() => props.color || buttonGroup.groupProps.color)
|
|
54
|
+
const computedGhost = computed(() => props.ghost || buttonGroup.groupProps.ghost)
|
|
55
|
+
const computedLight = computed(() => props.light || buttonGroup.groupProps.light)
|
|
56
|
+
const computedOutlined = computed(() => props.outlined || buttonGroup.groupProps.outlined)
|
|
57
|
+
const computedDisabled = computed(() => props.disabled || buttonGroup.groupProps.disabled)
|
|
58
|
+
const computedIconLeft = computed(() => props.icon || props.iconLeft)
|
|
59
|
+
|
|
60
|
+
const attrs = useAttrs()
|
|
61
|
+
const htmlTag = computed(() => (attrs.href ? 'a' : props.to ? 'router-link' : props.tag))
|
|
62
|
+
|
|
63
|
+
const computedProps = computed(() => ({
|
|
64
|
+
size: unref(computedSize),
|
|
65
|
+
flat: unref(computedFlat),
|
|
66
|
+
color: unref(computedColor),
|
|
67
|
+
ghost: unref(computedGhost),
|
|
68
|
+
light: unref(computedLight),
|
|
69
|
+
outlined: unref(computedOutlined),
|
|
70
|
+
disabled: unref(computedDisabled),
|
|
71
|
+
loading: props.loading,
|
|
72
|
+
block: props.block,
|
|
73
|
+
glow: props.glow,
|
|
74
|
+
iconLeft: unref(computedIconLeft),
|
|
75
|
+
iconRight: props.iconRight,
|
|
76
|
+
rounded: props.rounded,
|
|
77
|
+
}))
|
|
78
|
+
|
|
79
|
+
const { className, classes, styles } = useTheme('button', theme, computedProps, {
|
|
80
|
+
isButtonGroup,
|
|
81
|
+
})
|
|
275
82
|
|
|
276
|
-
|
|
277
|
-
if (slots.default) {
|
|
278
|
-
switch (computedSize.value) {
|
|
279
|
-
case 'xs':
|
|
280
|
-
return `py-1 text-xs ${props.icon ? 'px-2' : 'px-3'}`
|
|
281
|
-
case 'sm':
|
|
282
|
-
return `py-2 text-sm ${props.icon ? 'px-3' : 'px-4'}`
|
|
283
|
-
case 'lg':
|
|
284
|
-
return `py-3 text-lg ${props.icon ? 'px-4' : 'px-6'}`
|
|
285
|
-
case 'xl':
|
|
286
|
-
return `py-4 text-xl ${props.icon ? 'px-6' : 'px-6'}`
|
|
287
|
-
default:
|
|
288
|
-
return `py-2 ${props.icon ? 'px-4' : 'px-5'}`
|
|
289
|
-
}
|
|
290
|
-
} else {
|
|
291
|
-
switch (computedSize.value) {
|
|
292
|
-
case 'xs':
|
|
293
|
-
return 'leading-none p-1'
|
|
294
|
-
case 'lg':
|
|
295
|
-
return 'leading-none p-3'
|
|
296
|
-
case 'xl':
|
|
297
|
-
return 'leading-none p-4'
|
|
298
|
-
default:
|
|
299
|
-
return 'leading-none p-2'
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
})
|
|
83
|
+
const { focus, blur } = useInteractive(elRef)
|
|
303
84
|
|
|
304
|
-
|
|
305
|
-
...useInteractive(elRef),
|
|
306
|
-
elRef,
|
|
307
|
-
sizeClasses,
|
|
308
|
-
styles,
|
|
309
|
-
htmlTag,
|
|
310
|
-
isButtonGroup,
|
|
311
|
-
computedSize,
|
|
312
|
-
computedFlat,
|
|
313
|
-
computedGhost,
|
|
314
|
-
computedLight,
|
|
315
|
-
computedOutlined,
|
|
316
|
-
computedDisabled,
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
})
|
|
85
|
+
defineExpose({ focus, blur })
|
|
320
86
|
</script>
|
|
321
87
|
|
|
322
88
|
<template>
|
|
@@ -324,36 +90,14 @@ export default defineComponent({
|
|
|
324
90
|
:is="htmlTag"
|
|
325
91
|
ref="elRef"
|
|
326
92
|
:to="to"
|
|
327
|
-
class="relative transition duration-150 focus:outline-none inline-flex items-center justify-center font-medium whitespace-nowrap overflow-hidden align-middle active:!shadow-none border-y"
|
|
328
|
-
:style="styles"
|
|
329
93
|
:class="[
|
|
94
|
+
className,
|
|
330
95
|
$style['button'],
|
|
331
96
|
(glow && !computedDisabled && !loading) ? $style['button--glow'] : '',
|
|
332
|
-
|
|
333
|
-
{
|
|
334
|
-
'rounded-none border-r border-l-0': isButtonGroup,
|
|
335
|
-
'rounded-full': rounded && !isButtonGroup,
|
|
336
|
-
'rounded-md': !rounded && !isButtonGroup,
|
|
337
|
-
'border-x': !isButtonGroup,
|
|
338
|
-
|
|
339
|
-
// shadow
|
|
340
|
-
'shadow-sm':
|
|
341
|
-
!computedFlat &&
|
|
342
|
-
!computedLight &&
|
|
343
|
-
!computedGhost &&
|
|
344
|
-
!computedDisabled &&
|
|
345
|
-
!loading &&
|
|
346
|
-
!isButtonGroup,
|
|
347
|
-
|
|
348
|
-
// cursor
|
|
349
|
-
'cursor-not-allowed': computedDisabled,
|
|
350
|
-
'cursor-default': loading,
|
|
351
|
-
'cursor-pointer': !loading && !computedDisabled,
|
|
352
|
-
|
|
353
|
-
// size
|
|
354
|
-
'w-full': block,
|
|
355
|
-
},
|
|
97
|
+
classes.wrapper,
|
|
98
|
+
{ 'w-full': block }
|
|
356
99
|
]"
|
|
100
|
+
:style="styles"
|
|
357
101
|
:aria-busy="loading ? 'true' : null"
|
|
358
102
|
:aria-disabled="tag !== 'button' && computedDisabled ? 'true' : null"
|
|
359
103
|
:disabled="computedDisabled || loading"
|
|
@@ -361,36 +105,30 @@ export default defineComponent({
|
|
|
361
105
|
>
|
|
362
106
|
<x-spinner v-if="loading" :size="computedSize" class="absolute" />
|
|
363
107
|
<x-icon
|
|
364
|
-
v-if="
|
|
108
|
+
v-if="computedIconLeft"
|
|
365
109
|
:size="computedSize"
|
|
366
|
-
:icon="
|
|
367
|
-
class="shrink-0"
|
|
110
|
+
:icon="computedIconLeft"
|
|
368
111
|
:class="[
|
|
369
|
-
|
|
370
|
-
{
|
|
371
|
-
invisible: loading,
|
|
372
|
-
},
|
|
112
|
+
classes.iconLeft,
|
|
113
|
+
{ 'invisible': loading },
|
|
373
114
|
]"
|
|
374
115
|
/>
|
|
375
|
-
<span :class="{ invisible: loading }">
|
|
116
|
+
<span :class="{ 'invisible': loading }">
|
|
376
117
|
<slot></slot>
|
|
377
118
|
</span>
|
|
378
119
|
<x-icon
|
|
379
120
|
v-if="iconRight"
|
|
380
121
|
:size="computedSize"
|
|
381
122
|
:icon="iconRight"
|
|
382
|
-
class="shrink-0"
|
|
383
123
|
:class="[
|
|
384
|
-
|
|
385
|
-
{
|
|
386
|
-
invisible: loading,
|
|
387
|
-
},
|
|
124
|
+
classes.iconRight,
|
|
125
|
+
{ 'invisible': loading },
|
|
388
126
|
]"
|
|
389
127
|
/>
|
|
390
128
|
</component>
|
|
391
129
|
</template>
|
|
392
130
|
|
|
393
|
-
<style lang="postcss" module
|
|
131
|
+
<style lang="postcss" scoped module>
|
|
394
132
|
.button {
|
|
395
133
|
color: var(--x-button-text);
|
|
396
134
|
background-color: var(--x-button-bg);
|
|
@@ -412,21 +150,21 @@ export default defineComponent({
|
|
|
412
150
|
border-color: var(--x-button-border-active, var(--x-button-border));
|
|
413
151
|
}
|
|
414
152
|
|
|
415
|
-
:global(.dark)
|
|
416
|
-
color: var(--x-dark-
|
|
417
|
-
background-color: var(--x-dark-
|
|
418
|
-
border-color: var(--x-dark-
|
|
153
|
+
:global(.dark) &, &:global(.dark) {
|
|
154
|
+
color: var(--x-button-dark-text, var(--x-button-text));
|
|
155
|
+
background-color: var(--x-button-dark-bg, var(--x-button-bg));
|
|
156
|
+
border-color: var(--x-button-dark-border, var(--x-button-border));
|
|
419
157
|
|
|
420
158
|
&:hover {
|
|
421
|
-
color: var(--x-dark-
|
|
422
|
-
background-color: var(--x-dark-
|
|
423
|
-
border-color: var(--x-dark-
|
|
159
|
+
color: var(--x-button-dark-text-hover, var(--x-button-dark-text, var(--x-button-text)));
|
|
160
|
+
background-color: var(--x-button-dark-bg-hover, var(--x-button-dark-bg, var(--x-button-bg)));
|
|
161
|
+
border-color: var(--x-button-dark-border-hover, var(--x-button-dark-border, var(--x-button-border)));
|
|
424
162
|
}
|
|
425
163
|
|
|
426
164
|
&:active {
|
|
427
|
-
color: var(--x-dark-
|
|
428
|
-
background-color: var(--x-dark-
|
|
429
|
-
border-color: var(--x-dark-
|
|
165
|
+
color: var(--x-button-dark-text-active, var(--x-button-dark-text));
|
|
166
|
+
background-color: var(--x-button-dark-bg-active, var(--x-button-dark-bg, var(--x-button-bg)));
|
|
167
|
+
border-color: var(--x-button-dark-border-active, var(--x-button-dark-border, var(--x-button-border)));
|
|
430
168
|
}
|
|
431
169
|
}
|
|
432
170
|
}
|
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
2
|
+
export default { name: 'XButtonGroup' }
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { provide } from 'vue'
|
|
7
|
+
import { useTheme } from '../../composables/theme'
|
|
3
8
|
import { useCommon } from '../../composables/common'
|
|
4
9
|
import { useColors } from '../../composables/colors'
|
|
5
10
|
import { useInteractive } from '../../composables/interactive'
|
|
6
11
|
import { injectButtonGroupKey } from '../../composables/keys'
|
|
7
12
|
|
|
8
|
-
|
|
9
|
-
name: 'XButtonGroup',
|
|
10
|
-
|
|
11
|
-
validators: {
|
|
12
|
-
...useCommon.validators(),
|
|
13
|
-
},
|
|
13
|
+
import theme from './ButtonGroup.theme'
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
outlined: Boolean,
|
|
24
|
-
rounded: Boolean,
|
|
25
|
-
ghost: Boolean,
|
|
26
|
-
light: Boolean,
|
|
15
|
+
const props = defineProps({
|
|
16
|
+
...useCommon.props(),
|
|
17
|
+
...useColors.props(),
|
|
18
|
+
...useInteractive.props(),
|
|
19
|
+
tag: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: 'div',
|
|
27
22
|
},
|
|
23
|
+
outlined: Boolean,
|
|
24
|
+
rounded: Boolean,
|
|
25
|
+
ghost: Boolean,
|
|
26
|
+
light: Boolean,
|
|
27
|
+
})
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
isButtonGroup: true,
|
|
33
|
-
})
|
|
34
|
-
},
|
|
29
|
+
provide(injectButtonGroupKey, {
|
|
30
|
+
groupProps: props,
|
|
31
|
+
isButtonGroup: true,
|
|
35
32
|
})
|
|
33
|
+
|
|
34
|
+
const { className, classes, styles } = useTheme('button-group', theme, props)
|
|
36
35
|
</script>
|
|
37
36
|
|
|
38
37
|
<template>
|
|
39
38
|
<component
|
|
40
39
|
:is="tag"
|
|
41
|
-
|
|
40
|
+
:style="styles"
|
|
42
41
|
:class="[
|
|
42
|
+
className,
|
|
43
43
|
$style['button-group'],
|
|
44
|
-
rounded ? $style['button-group--rounded'] : ''
|
|
44
|
+
rounded ? $style['button-group--rounded'] : '',
|
|
45
|
+
classes.wrapper
|
|
45
46
|
]"
|
|
46
47
|
>
|
|
47
48
|
<slot></slot>
|
|
@@ -52,7 +53,7 @@ export default defineComponent({
|
|
|
52
53
|
.button-group {
|
|
53
54
|
&:not(&--rounded) {
|
|
54
55
|
> :first-child {
|
|
55
|
-
@apply rounded-l-md
|
|
56
|
+
@apply rounded-l-md
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
> :last-child {
|
|
@@ -62,7 +63,7 @@ export default defineComponent({
|
|
|
62
63
|
|
|
63
64
|
&--rounded {
|
|
64
65
|
> :first-of-type {
|
|
65
|
-
@apply rounded-l-full
|
|
66
|
+
@apply rounded-l-full
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
> :last-child {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import Button from '../Button.vue'
|
|
4
|
+
|
|
5
|
+
describe('Button', () => {
|
|
6
|
+
it('renders without errors', () => {
|
|
7
|
+
const wrapper = mount(Button)
|
|
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 ButtonGroup from '../ButtonGroup.vue'
|
|
4
|
+
|
|
5
|
+
describe('ButtonGroup', () => {
|
|
6
|
+
it('renders without errors', () => {
|
|
7
|
+
const wrapper = mount(ButtonGroup)
|
|
8
|
+
|
|
9
|
+
expect(wrapper.vm).toBeTruthy()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
2
|
+
export default { name: 'XCard' }
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { useTheme } from '../../composables/theme'
|
|
3
7
|
|
|
4
|
-
|
|
5
|
-
name: 'XCard',
|
|
8
|
+
import theme from './Card.theme'
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
flat: Boolean,
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
tag: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: 'div',
|
|
13
14
|
},
|
|
15
|
+
flat: Boolean,
|
|
14
16
|
})
|
|
17
|
+
|
|
18
|
+
const { styles, classes, className } = useTheme('card', theme, props)
|
|
15
19
|
</script>
|
|
16
20
|
|
|
17
21
|
<template>
|
|
18
22
|
<component
|
|
19
23
|
:is="tag"
|
|
20
|
-
|
|
21
|
-
:class="[
|
|
24
|
+
:styles="styles"
|
|
25
|
+
:class="[
|
|
26
|
+
className,
|
|
27
|
+
classes.wrapper
|
|
28
|
+
]"
|
|
22
29
|
>
|
|
23
30
|
<slot></slot>
|
|
24
31
|
</component>
|