@indielayer/ui 1.0.0-alpha.9 → 1.0.2

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.
Files changed (293) hide show
  1. package/README.md +6 -3
  2. package/lib/common/icons.d.ts +15 -0
  3. package/lib/common/utils.d.ts +32 -0
  4. package/lib/components/alert/Alert.theme.d.ts +8 -0
  5. package/lib/components/alert/Alert.vue.d.ts +1 -12
  6. package/lib/components/alert/__tests__/Alert.spec.d.ts +1 -0
  7. package/lib/components/avatar/Avatar.theme.d.ts +8 -0
  8. package/lib/components/avatar/Avatar.vue.d.ts +5 -8
  9. package/lib/components/avatar/__tests__/Avatar.spec.d.ts +1 -0
  10. package/lib/components/badge/Badge.theme.d.ts +8 -0
  11. package/lib/components/badge/Badge.vue.d.ts +5 -6
  12. package/lib/components/badge/__tests__/Badge.spec.d.ts +1 -0
  13. package/lib/components/breadcrumbs/Breadcrumbs.theme.d.ts +8 -0
  14. package/lib/components/breadcrumbs/Breadcrumbs.vue.d.ts +19 -8
  15. package/lib/components/breadcrumbs/__tests__/Breadcrumbs.spec.d.ts +1 -0
  16. package/lib/components/button/Button.theme.d.ts +10 -0
  17. package/lib/components/button/Button.vue.d.ts +10 -16
  18. package/lib/components/button/ButtonGroup.theme.d.ts +6 -0
  19. package/lib/components/button/ButtonGroup.vue.d.ts +5 -2
  20. package/lib/components/button/__tests__/ Button.spec.d.ts +1 -0
  21. package/lib/components/button/__tests__/ ButtonGroup.spec.d.ts +1 -0
  22. package/lib/components/card/Card.theme.d.ts +7 -0
  23. package/lib/components/card/Card.vue.d.ts +2 -2
  24. package/lib/components/card/__tests__/Card.spec.d.ts +1 -0
  25. package/lib/components/checkbox/Checkbox.theme.d.ts +11 -0
  26. package/lib/components/checkbox/Checkbox.vue.d.ts +10 -14
  27. package/lib/components/checkbox/__tests__/Checkbox.spec.d.ts +1 -0
  28. package/lib/components/collapse/Collapse.theme.d.ts +9 -0
  29. package/lib/components/collapse/Collapse.vue.d.ts +12 -19
  30. package/lib/components/collapse/__tests__/Collapse.spec.d.ts +1 -0
  31. package/lib/components/container/Container.theme.d.ts +6 -0
  32. package/lib/components/container/Container.vue.d.ts +1 -1
  33. package/lib/components/container/__tests__/Container.spec.d.ts +1 -0
  34. package/lib/components/divider/Divider.theme.d.ts +9 -0
  35. package/lib/components/divider/Divider.vue.d.ts +1 -1
  36. package/lib/components/divider/__tests__/Divider.spec.d.ts +1 -0
  37. package/lib/components/drawer/Drawer.theme.d.ts +7 -0
  38. package/lib/components/drawer/Drawer.vue.d.ts +3 -15
  39. package/lib/components/drawer/__tests__/Drawer.spec.d.ts +1 -0
  40. package/lib/components/form/Form.theme.d.ts +6 -0
  41. package/lib/components/form/Form.vue.d.ts +9 -7
  42. package/lib/components/form/__tests__/Form.spec.d.ts +1 -0
  43. package/lib/components/helpers/InputError.d.ts +8 -0
  44. package/lib/components/icon/Icon.theme.d.ts +7 -0
  45. package/lib/components/icon/Icon.vue.d.ts +4 -8
  46. package/lib/components/icon/__tests__/Icon.spec.d.ts +1 -0
  47. package/lib/components/image/Image.theme.d.ts +6 -0
  48. package/lib/components/image/Image.vue.d.ts +1 -3
  49. package/lib/components/image/__tests__/Image.spec.d.ts +1 -0
  50. package/lib/components/index.d.ts +3 -3
  51. package/lib/components/input/Input.theme.d.ts +11 -0
  52. package/lib/components/input/Input.vue.d.ts +27 -25
  53. package/lib/components/input/__tests__/Input.spec.d.ts +1 -0
  54. package/lib/components/link/Link.theme.d.ts +8 -0
  55. package/lib/components/link/Link.vue.d.ts +3 -5
  56. package/lib/components/link/__tests__/Link.spec.d.ts +1 -0
  57. package/lib/components/menu/Menu.theme.d.ts +6 -0
  58. package/lib/components/menu/Menu.vue.d.ts +6 -3
  59. package/lib/components/menu/MenuItem.theme.d.ts +8 -0
  60. package/lib/components/menu/MenuItem.vue.d.ts +5 -30
  61. package/lib/components/menu/__tests__/Menu.spec.d.ts +1 -0
  62. package/lib/components/menu/__tests__/MenuItem.spec.d.ts +1 -0
  63. package/lib/components/modal/Modal.theme.d.ts +13 -0
  64. package/lib/components/modal/Modal.vue.d.ts +1 -6
  65. package/lib/components/modal/__tests__/Modal.spec.d.ts +1 -0
  66. package/lib/components/notifications/Notifications.theme.d.ts +8 -0
  67. package/lib/components/notifications/Notifications.vue.d.ts +11 -24
  68. package/lib/components/notifications/__tests__/Notifications.spec.d.ts +1 -0
  69. package/lib/components/pagination/Pagination.theme.d.ts +9 -0
  70. package/lib/components/pagination/Pagination.vue.d.ts +7 -16
  71. package/lib/components/pagination/PaginationItem.theme.d.ts +7 -0
  72. package/lib/components/pagination/PaginationItem.vue.d.ts +4 -3
  73. package/lib/components/pagination/__tests__/Pagination.spec.d.ts +1 -0
  74. package/lib/components/pagination/__tests__/PaginationItem.spec.d.ts +1 -0
  75. package/lib/components/popover/Popover.theme.d.ts +7 -0
  76. package/lib/components/popover/Popover.vue.d.ts +13 -13
  77. package/lib/components/popover/PopoverContainer.theme.d.ts +6 -0
  78. package/lib/components/popover/PopoverContainer.vue.d.ts +1 -1
  79. package/lib/components/popover/__tests__/Popover.spec.d.ts +1 -0
  80. package/lib/components/popover/__tests__/PopoverContainer.spec.d.ts +1 -0
  81. package/lib/components/progress/Progress.theme.d.ts +10 -0
  82. package/lib/components/progress/Progress.vue.d.ts +1 -3
  83. package/lib/components/progress/__tests__/Progress.spec.d.ts +1 -0
  84. package/lib/components/radio/Radio.theme.d.ts +12 -0
  85. package/lib/components/radio/Radio.vue.d.ts +12 -13
  86. package/lib/components/radio/__tests__/Radio.spec.d.ts +1 -0
  87. package/lib/components/scroll/Scroll.theme.d.ts +6 -0
  88. package/lib/components/scroll/Scroll.vue.d.ts +1 -7
  89. package/lib/components/scroll/__tests__/Scroll.spec.d.ts +1 -0
  90. package/lib/components/select/Select.theme.d.ts +13 -0
  91. package/lib/components/select/Select.vue.d.ts +8 -28
  92. package/lib/components/select/__tests__/Select.spec.d.ts +1 -0
  93. package/lib/components/skeleton/Skeleton.theme.d.ts +6 -0
  94. package/lib/components/skeleton/Skeleton.vue.d.ts +1 -1
  95. package/lib/components/skeleton/__tests__/Skeleton.spec.d.ts +1 -0
  96. package/lib/components/slider/Slider.theme.d.ts +10 -0
  97. package/lib/components/slider/Slider.vue.d.ts +8 -17
  98. package/lib/components/slider/__tests__/Slider.spec.d.ts +1 -0
  99. package/lib/components/spacer/Spacer.d.ts +2 -0
  100. package/lib/components/spacer/__tests__/Spacer.spec.d.ts +1 -0
  101. package/lib/components/spinner/Spinner.vue.d.ts +15 -6
  102. package/lib/components/spinner/__tests__/Spinner.spec.d.ts +1 -0
  103. package/lib/components/tab/Tab.theme.d.ts +9 -0
  104. package/lib/components/tab/Tab.vue.d.ts +4 -13
  105. package/lib/components/tab/TabGroup.theme.d.ts +10 -0
  106. package/lib/components/tab/TabGroup.vue.d.ts +4 -8
  107. package/lib/components/tab/__tests__/Tab.spec.d.ts +1 -0
  108. package/lib/components/tab/__tests__/TabGroup.spec.d.ts +1 -0
  109. package/lib/components/table/Table.theme.d.ts +8 -0
  110. package/lib/components/table/Table.vue.d.ts +6 -10
  111. package/lib/components/table/TableBody.d.ts +2 -0
  112. package/lib/components/table/TableCell.theme.d.ts +7 -0
  113. package/lib/components/table/TableCell.vue.d.ts +1 -1
  114. package/lib/components/table/TableHead.d.ts +2 -0
  115. package/lib/components/table/TableHeader.vue.d.ts +2 -2
  116. package/lib/components/table/TableRow.vue.d.ts +1 -1
  117. package/lib/components/table/__tests__/Table.spec.d.ts +1 -0
  118. package/lib/components/tag/Tag.theme.d.ts +9 -0
  119. package/lib/components/tag/Tag.vue.d.ts +5 -5
  120. package/lib/components/tag/__tests__/Tag.spec.d.ts +1 -0
  121. package/lib/components/textarea/Textarea.theme.d.ts +10 -0
  122. package/lib/components/textarea/Textarea.vue.d.ts +18 -24
  123. package/lib/components/textarea/__tests__/Textarea.spec.d.ts +1 -0
  124. package/lib/components/toggle/Toggle.theme.d.ts +11 -0
  125. package/lib/components/toggle/Toggle.vue.d.ts +10 -11
  126. package/lib/components/toggle/__tests__/Toggle.spec.d.ts +1 -0
  127. package/lib/components/tooltip/Tooltip.theme.d.ts +11 -0
  128. package/lib/components/tooltip/__tests__/Tooltip.spec.d.ts +1 -0
  129. package/lib/composables/colors-utils.d.ts +0 -1
  130. package/lib/composables/colors.d.ts +8 -4
  131. package/lib/composables/common.d.ts +1 -0
  132. package/lib/composables/css.d.ts +6 -5
  133. package/lib/composables/index.d.ts +1 -1
  134. package/lib/composables/inputtable.d.ts +1 -1
  135. package/lib/composables/interactive.d.ts +7 -2
  136. package/lib/composables/keys.d.ts +1 -0
  137. package/lib/composables/notifications.d.ts +1 -0
  138. package/lib/composables/theme.d.ts +20 -0
  139. package/lib/create.d.ts +3 -2
  140. package/lib/index.cjs.js +1 -15
  141. package/lib/index.es.js +4479 -3667
  142. package/lib/nuxt.js +2 -1
  143. package/lib/version.d.ts +1 -1
  144. package/package.json +16 -6
  145. package/src/common/icons.ts +15 -0
  146. package/src/common/utils.ts +68 -0
  147. package/src/components/alert/Alert.theme.ts +57 -0
  148. package/src/components/alert/Alert.vue +51 -127
  149. package/src/components/alert/__tests__/Alert.spec.ts +14 -0
  150. package/src/components/avatar/Avatar.theme.ts +39 -0
  151. package/src/components/avatar/Avatar.vue +61 -97
  152. package/src/components/avatar/__tests__/Avatar.spec.ts +11 -0
  153. package/src/components/badge/Badge.theme.ts +13 -0
  154. package/src/components/badge/Badge.vue +58 -65
  155. package/src/components/badge/__tests__/Badge.spec.ts +11 -0
  156. package/src/components/breadcrumbs/Breadcrumbs.theme.ts +9 -0
  157. package/src/components/breadcrumbs/Breadcrumbs.vue +34 -24
  158. package/src/components/breadcrumbs/__tests__/Breadcrumbs.spec.ts +11 -0
  159. package/src/components/button/Button.theme.ts +234 -0
  160. package/src/components/button/Button.vue +94 -356
  161. package/src/components/button/ButtonGroup.theme.ts +5 -0
  162. package/src/components/button/ButtonGroup.vue +30 -29
  163. package/src/components/button/__tests__/ Button.spec.ts +11 -0
  164. package/src/components/button/__tests__/ ButtonGroup.spec.ts +11 -0
  165. package/src/components/card/Card.theme.ts +7 -0
  166. package/src/components/card/Card.vue +18 -11
  167. package/src/components/card/__tests__/Card.spec.ts +11 -0
  168. package/src/components/checkbox/Checkbox.theme.ts +92 -0
  169. package/src/components/checkbox/Checkbox.vue +69 -156
  170. package/src/components/checkbox/__tests__/Checkbox.spec.ts +11 -0
  171. package/src/components/collapse/Collapse.theme.ts +11 -0
  172. package/src/components/collapse/Collapse.vue +99 -118
  173. package/src/components/collapse/__tests__/Collapse.spec.ts +11 -0
  174. package/src/components/container/Container.theme.ts +7 -0
  175. package/src/components/container/Container.vue +17 -9
  176. package/src/components/container/__tests__/Container.spec.ts +11 -0
  177. package/src/components/divider/Divider.theme.ts +11 -0
  178. package/src/components/divider/Divider.vue +22 -18
  179. package/src/components/divider/__tests__/Divider.spec.ts +11 -0
  180. package/src/components/drawer/Drawer.theme.ts +9 -0
  181. package/src/components/drawer/Drawer.vue +167 -179
  182. package/src/components/drawer/__tests__/Drawer.spec.ts +11 -0
  183. package/src/components/form/Form.theme.ts +7 -0
  184. package/src/components/form/Form.vue +90 -73
  185. package/src/components/form/__tests__/Form.spec.ts +11 -0
  186. package/src/components/helpers/InputError.tsx +14 -0
  187. package/src/components/icon/Icon.theme.ts +16 -0
  188. package/src/components/icon/Icon.vue +72 -88
  189. package/src/components/icon/__tests__/Icon.spec.ts +11 -0
  190. package/src/components/image/Image.theme.ts +7 -0
  191. package/src/components/image/Image.vue +22 -23
  192. package/src/components/image/__tests__/Image.spec.ts +11 -0
  193. package/src/components/index.ts +3 -3
  194. package/src/components/input/Input.theme.ts +44 -0
  195. package/src/components/input/Input.vue +97 -130
  196. package/src/components/input/__tests__/Input.spec.ts +11 -0
  197. package/src/components/link/Link.theme.ts +26 -0
  198. package/src/components/link/Link.vue +41 -66
  199. package/src/components/link/__tests__/Link.spec.ts +11 -0
  200. package/src/components/menu/Menu.theme.ts +7 -0
  201. package/src/components/menu/Menu.vue +54 -45
  202. package/src/components/menu/MenuItem.theme.ts +107 -0
  203. package/src/components/menu/MenuItem.vue +97 -199
  204. package/src/components/menu/__tests__/Menu.spec.ts +11 -0
  205. package/src/components/menu/__tests__/MenuItem.spec.ts +11 -0
  206. package/src/components/modal/Modal.theme.ts +29 -0
  207. package/src/components/modal/Modal.vue +78 -101
  208. package/src/components/modal/__tests__/Modal.spec.ts +11 -0
  209. package/src/components/notifications/Notifications.theme.ts +11 -0
  210. package/src/components/notifications/Notifications.vue +233 -249
  211. package/src/components/notifications/__tests__/Notifications.spec.ts +11 -0
  212. package/src/components/pagination/Pagination.theme.ts +27 -0
  213. package/src/components/pagination/Pagination.vue +142 -164
  214. package/src/components/pagination/PaginationItem.theme.ts +14 -0
  215. package/src/components/pagination/PaginationItem.vue +26 -33
  216. package/src/components/pagination/__tests__/Pagination.spec.ts +11 -0
  217. package/src/components/pagination/__tests__/PaginationItem.spec.ts +11 -0
  218. package/src/components/popover/Popover.theme.ts +9 -0
  219. package/src/components/popover/Popover.vue +153 -101
  220. package/src/components/popover/PopoverContainer.theme.ts +7 -0
  221. package/src/components/popover/PopoverContainer.vue +17 -9
  222. package/src/components/popover/__tests__/Popover.spec.ts +11 -0
  223. package/src/components/popover/__tests__/PopoverContainer.spec.ts +11 -0
  224. package/src/components/progress/Progress.theme.ts +26 -0
  225. package/src/components/progress/Progress.vue +29 -53
  226. package/src/components/progress/__tests__/Progress.spec.ts +11 -0
  227. package/src/components/radio/Radio.theme.ts +121 -0
  228. package/src/components/radio/Radio.vue +81 -158
  229. package/src/components/radio/__tests__/Radio.spec.ts +11 -0
  230. package/src/components/scroll/Scroll.theme.ts +7 -0
  231. package/src/components/scroll/Scroll.vue +34 -36
  232. package/src/components/scroll/__tests__/Scroll.spec.ts +11 -0
  233. package/src/components/select/Select.theme.ts +54 -0
  234. package/src/components/select/Select.vue +219 -273
  235. package/src/components/select/__tests__/Select.spec.ts +11 -0
  236. package/src/components/skeleton/Skeleton.theme.ts +7 -0
  237. package/src/components/skeleton/Skeleton.vue +17 -9
  238. package/src/components/skeleton/__tests__/Skeleton.spec.ts +11 -0
  239. package/src/components/slider/Slider.theme.ts +30 -0
  240. package/src/components/slider/Slider.vue +137 -168
  241. package/src/components/slider/__tests__/Slider.spec.ts +11 -0
  242. package/src/components/spacer/{Spacer.vue → Spacer.tsx} +3 -6
  243. package/src/components/spacer/__tests__/Spacer.spec.ts +11 -0
  244. package/src/components/spinner/Spinner.vue +10 -34
  245. package/src/components/spinner/__tests__/Spinner.spec.ts +11 -0
  246. package/src/components/tab/Tab.theme.ts +22 -0
  247. package/src/components/tab/Tab.vue +89 -93
  248. package/src/components/tab/TabGroup.theme.ts +43 -0
  249. package/src/components/tab/TabGroup.vue +94 -127
  250. package/src/components/tab/__tests__/Tab.spec.ts +11 -0
  251. package/src/components/tab/__tests__/TabGroup.spec.ts +11 -0
  252. package/src/components/table/Table.theme.ts +19 -0
  253. package/src/components/table/Table.vue +136 -147
  254. package/src/components/table/{TableBody.vue → TableBody.tsx} +3 -8
  255. package/src/components/table/TableCell.theme.ts +27 -0
  256. package/src/components/table/TableCell.vue +30 -58
  257. package/src/components/table/TableHead.tsx +14 -0
  258. package/src/components/table/TableHeader.vue +18 -20
  259. package/src/components/table/TableRow.vue +23 -20
  260. package/src/components/table/__tests__/Table.spec.ts +11 -0
  261. package/src/components/tag/Tag.theme.ts +32 -0
  262. package/src/components/tag/Tag.vue +40 -68
  263. package/src/components/tag/__tests__/Tag.spec.ts +11 -0
  264. package/src/components/textarea/Textarea.theme.ts +62 -0
  265. package/src/components/textarea/Textarea.vue +100 -115
  266. package/src/components/textarea/__tests__/Textarea.spec.ts +11 -0
  267. package/src/components/toggle/Toggle.theme.ts +51 -0
  268. package/src/components/toggle/Toggle.vue +51 -81
  269. package/src/components/toggle/__tests__/Toggle.spec.ts +11 -0
  270. package/src/components/tooltip/Tooltip.theme.ts +51 -0
  271. package/src/components/tooltip/Tooltip.vue +9 -14
  272. package/src/components/tooltip/__tests__/Tooltip.spec.ts +11 -0
  273. package/src/composables/colors-utils.ts +68 -68
  274. package/src/composables/colors.ts +18 -6
  275. package/src/composables/common.ts +1 -0
  276. package/src/composables/css.ts +7 -2
  277. package/src/composables/index.ts +1 -1
  278. package/src/composables/inputtable.ts +1 -1
  279. package/src/composables/interactive.ts +8 -4
  280. package/src/composables/keys.ts +1 -0
  281. package/src/composables/notifications.ts +10 -0
  282. package/src/composables/theme.ts +88 -0
  283. package/src/create.ts +8 -3
  284. package/src/exports/nuxt.js +2 -1
  285. package/src/version.ts +1 -1
  286. package/volar.d.ts +1 -0
  287. package/lib/components/spacer/Spacer.vue.d.ts +0 -2
  288. package/lib/components/table/TableBody.vue.d.ts +0 -2
  289. package/lib/components/table/TableHead.vue.d.ts +0 -2
  290. package/lib/composables/notification.d.ts +0 -1
  291. package/lib/style.css +0 -1
  292. package/src/components/table/TableHead.vue +0 -15
  293. package/src/composables/notification.ts +0 -10
@@ -1,322 +1,88 @@
1
1
  <script lang="ts">
2
- import { defineComponent, computed, ref, inject } from 'vue'
3
- import { useCSS } from '../../composables/css'
4
- import { useCommon } from '../../composables/common'
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 '../../components/spinner/Spinner.vue'
10
- import XIcon from '../../components/icon/Icon.vue'
13
+ import XSpinner from '../spinner/Spinner.vue'
14
+ import XIcon from '../icon/Icon.vue'
11
15
 
12
- export type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | undefined
16
+ import theme from './Button.theme'
13
17
 
14
- export default defineComponent({
15
- name: 'XButton',
16
-
17
- components: {
18
- XIcon,
19
- XSpinner,
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
- props: {
27
- ...useCommon.props(),
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
- setup(props, { slots, attrs }) {
50
- const elRef = ref<HTMLElement>()
51
-
52
- // Button group props
53
- const buttonGroup = inject(injectButtonGroupKey, {
54
- isButtonGroup: false,
55
- groupProps: {
56
- size: undefined,
57
- flat: undefined,
58
- color: undefined,
59
- ghost: undefined,
60
- light: undefined,
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
- // outlined / filled
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
- return vars
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
- const sizeClasses = computed(() => {
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
- return {
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
- sizeClasses,
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="icon"
108
+ v-if="computedIconLeft"
365
109
  :size="computedSize"
366
- :icon="icon"
367
- class="shrink-0"
110
+ :icon="computedIconLeft"
368
111
  :class="[
369
- [$slots.default ? 'mr-2' : 'm-0.5'],
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
- [$slots.default ? 'ml-2' : 'm-0.5'],
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 scoped>
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-button-text, var(--x-button-text));
417
- background-color: var(--x-dark-button-bg, var(--x-button-bg));
418
- border-color: var(--x-dark-button-border, var(--x-button-border));
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-button-text-hover, var(--x-dark-button-text, var(--x-button-text)));
422
- background-color: var(--x-dark-button-bg-hover, var(--x-dark-button-bg, var(--x-button-bg)));
423
- border-color: var(--x-dark-button-border-hover, var(--x-dark-button-border, var(--x-button-border)));
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-button-text-active, var(--x-dark-button-text));
428
- background-color: var(--x-dark-button-bg-active, var(--x-dark-button-bg, var(--x-button-bg)));
429
- border-color: var(--x-dark-button-border-active, var(--x-dark-button-border, var(--x-button-border)));
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
  }
@@ -0,0 +1,5 @@
1
+ export default {
2
+ classes: {
3
+ wrapper: 'inline-flex align-middle relative -space-x-[1px]',
4
+ },
5
+ }
@@ -1,47 +1,48 @@
1
1
  <script lang="ts">
2
- import { defineComponent, provide } from 'vue'
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
- export default defineComponent({
9
- name: 'XButtonGroup',
10
-
11
- validators: {
12
- ...useCommon.validators(),
13
- },
13
+ import theme from './ButtonGroup.theme'
14
14
 
15
- props: {
16
- ...useCommon.props(),
17
- ...useColors.props(),
18
- ...useInteractive.props(),
19
- tag: {
20
- type: String,
21
- default: 'div',
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
- setup(props) {
30
- provide(injectButtonGroupKey, {
31
- groupProps: props,
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
- class="inline-flex align-middle relative"
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 border-l
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 border-l
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
+ })
@@ -0,0 +1,7 @@
1
+ import type { ThemeParams } from '../../composables/theme'
2
+
3
+ export default {
4
+ classes: {
5
+ wrapper: ({ props }: ThemeParams) => `rounded bg-white dark:bg-gray-800${props.flat ? '' : ' shadow'}`,
6
+ },
7
+ }
@@ -1,24 +1,31 @@
1
1
  <script lang="ts">
2
- import { defineComponent } from 'vue'
2
+ export default { name: 'XCard' }
3
+ </script>
4
+
5
+ <script setup lang="ts">
6
+ import { useTheme } from '../../composables/theme'
3
7
 
4
- export default defineComponent({
5
- name: 'XCard',
8
+ import theme from './Card.theme'
6
9
 
7
- props: {
8
- tag: {
9
- type: String,
10
- default: 'div',
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
- class="rounded bg-white dark:bg-gray-800"
21
- :class="[{ 'shadow': !flat }]"
24
+ :styles="styles"
25
+ :class="[
26
+ className,
27
+ classes.wrapper
28
+ ]"
22
29
  >
23
30
  <slot></slot>
24
31
  </component>