@indielayer/ui 1.0.0-alpha.7 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/README.md +6 -3
  2. package/lib/index.cjs.js +1 -15
  3. package/lib/index.es.js +4453 -3651
  4. package/lib/nuxt.js +2 -1
  5. package/package.json +16 -6
  6. package/src/common/icons.ts +15 -0
  7. package/src/common/utils.ts +68 -0
  8. package/src/components/alert/Alert.theme.ts +57 -0
  9. package/src/components/alert/Alert.vue +51 -127
  10. package/src/components/alert/__tests__/Alert.spec.ts +14 -0
  11. package/src/components/avatar/Avatar.theme.ts +39 -0
  12. package/src/components/avatar/Avatar.vue +58 -96
  13. package/src/components/avatar/__tests__/Avatar.spec.ts +11 -0
  14. package/src/components/badge/Badge.theme.ts +13 -0
  15. package/src/components/badge/Badge.vue +58 -65
  16. package/src/components/badge/__tests__/Badge.spec.ts +11 -0
  17. package/src/components/breadcrumbs/Breadcrumbs.theme.ts +9 -0
  18. package/src/components/breadcrumbs/Breadcrumbs.vue +34 -24
  19. package/src/components/breadcrumbs/__tests__/Breadcrumbs.spec.ts +11 -0
  20. package/src/components/button/Button.theme.ts +234 -0
  21. package/src/components/button/Button.vue +94 -356
  22. package/src/components/button/ButtonGroup.theme.ts +5 -0
  23. package/src/components/button/ButtonGroup.vue +30 -29
  24. package/src/components/button/__tests__/ Button.spec.ts +11 -0
  25. package/src/components/button/__tests__/ ButtonGroup.spec.ts +11 -0
  26. package/src/components/card/Card.theme.ts +7 -0
  27. package/src/components/card/Card.vue +18 -11
  28. package/src/components/card/__tests__/Card.spec.ts +11 -0
  29. package/src/components/checkbox/Checkbox.theme.ts +92 -0
  30. package/src/components/checkbox/Checkbox.vue +69 -156
  31. package/src/components/checkbox/__tests__/Checkbox.spec.ts +11 -0
  32. package/src/components/collapse/Collapse.theme.ts +11 -0
  33. package/src/components/collapse/Collapse.vue +99 -118
  34. package/src/components/collapse/__tests__/Collapse.spec.ts +11 -0
  35. package/src/components/container/Container.theme.ts +7 -0
  36. package/src/components/container/Container.vue +17 -9
  37. package/src/components/container/__tests__/Container.spec.ts +11 -0
  38. package/src/components/divider/Divider.theme.ts +11 -0
  39. package/src/components/divider/Divider.vue +22 -18
  40. package/src/components/divider/__tests__/Divider.spec.ts +11 -0
  41. package/src/components/drawer/Drawer.theme.ts +9 -0
  42. package/src/components/drawer/Drawer.vue +160 -177
  43. package/src/components/drawer/__tests__/Drawer.spec.ts +11 -0
  44. package/src/components/form/Form.theme.ts +7 -0
  45. package/src/components/form/Form.vue +90 -73
  46. package/src/components/form/__tests__/Form.spec.ts +11 -0
  47. package/src/components/helpers/InputError.tsx +14 -0
  48. package/src/components/icon/Icon.theme.ts +16 -0
  49. package/src/components/icon/Icon.vue +72 -88
  50. package/src/components/icon/__tests__/Icon.spec.ts +11 -0
  51. package/src/components/image/Image.theme.ts +7 -0
  52. package/src/components/image/Image.vue +22 -23
  53. package/src/components/image/__tests__/Image.spec.ts +11 -0
  54. package/src/components/index.ts +3 -3
  55. package/src/components/input/Input.theme.ts +44 -0
  56. package/src/components/input/Input.vue +97 -130
  57. package/src/components/input/__tests__/Input.spec.ts +11 -0
  58. package/src/components/link/Link.theme.ts +26 -0
  59. package/src/components/link/Link.vue +41 -66
  60. package/src/components/link/__tests__/Link.spec.ts +11 -0
  61. package/src/components/menu/Menu.theme.ts +7 -0
  62. package/src/components/menu/Menu.vue +54 -45
  63. package/src/components/menu/MenuItem.theme.ts +107 -0
  64. package/src/components/menu/MenuItem.vue +97 -199
  65. package/src/components/menu/__tests__/Menu.spec.ts +11 -0
  66. package/src/components/menu/__tests__/MenuItem.spec.ts +11 -0
  67. package/src/components/modal/Modal.theme.ts +29 -0
  68. package/src/components/modal/Modal.vue +78 -101
  69. package/src/components/modal/__tests__/Modal.spec.ts +11 -0
  70. package/src/components/notifications/Notifications.theme.ts +11 -0
  71. package/src/components/notifications/Notifications.vue +233 -247
  72. package/src/components/notifications/__tests__/Notifications.spec.ts +11 -0
  73. package/src/components/pagination/Pagination.theme.ts +27 -0
  74. package/src/components/pagination/Pagination.vue +142 -164
  75. package/src/components/pagination/PaginationItem.theme.ts +14 -0
  76. package/src/components/pagination/PaginationItem.vue +26 -33
  77. package/src/components/pagination/__tests__/Pagination.spec.ts +11 -0
  78. package/src/components/pagination/__tests__/PaginationItem.spec.ts +11 -0
  79. package/src/components/popover/Popover.theme.ts +9 -0
  80. package/src/components/popover/Popover.vue +153 -101
  81. package/src/components/popover/PopoverContainer.theme.ts +7 -0
  82. package/src/components/popover/PopoverContainer.vue +17 -9
  83. package/src/components/popover/__tests__/Popover.spec.ts +11 -0
  84. package/src/components/popover/__tests__/PopoverContainer.spec.ts +11 -0
  85. package/src/components/progress/Progress.theme.ts +26 -0
  86. package/src/components/progress/Progress.vue +29 -53
  87. package/src/components/progress/__tests__/Progress.spec.ts +11 -0
  88. package/src/components/radio/Radio.theme.ts +121 -0
  89. package/src/components/radio/Radio.vue +81 -158
  90. package/src/components/radio/__tests__/Radio.spec.ts +11 -0
  91. package/src/components/scroll/Scroll.theme.ts +7 -0
  92. package/src/components/scroll/Scroll.vue +34 -36
  93. package/src/components/scroll/__tests__/Scroll.spec.ts +11 -0
  94. package/src/components/select/Select.theme.ts +54 -0
  95. package/src/components/select/Select.vue +219 -273
  96. package/src/components/select/__tests__/Select.spec.ts +11 -0
  97. package/src/components/skeleton/Skeleton.theme.ts +7 -0
  98. package/src/components/skeleton/Skeleton.vue +17 -9
  99. package/src/components/skeleton/__tests__/Skeleton.spec.ts +11 -0
  100. package/src/components/slider/Slider.theme.ts +30 -0
  101. package/src/components/slider/Slider.vue +135 -168
  102. package/src/components/slider/__tests__/Slider.spec.ts +11 -0
  103. package/src/components/spacer/{Spacer.vue → Spacer.tsx} +3 -6
  104. package/src/components/spacer/__tests__/Spacer.spec.ts +11 -0
  105. package/src/components/spinner/Spinner.vue +10 -34
  106. package/src/components/spinner/__tests__/Spinner.spec.ts +11 -0
  107. package/src/components/tab/Tab.theme.ts +22 -0
  108. package/src/components/tab/Tab.vue +89 -93
  109. package/src/components/tab/TabGroup.theme.ts +43 -0
  110. package/src/components/tab/TabGroup.vue +94 -127
  111. package/src/components/tab/__tests__/Tab.spec.ts +11 -0
  112. package/src/components/tab/__tests__/TabGroup.spec.ts +11 -0
  113. package/src/components/table/Table.theme.ts +19 -0
  114. package/src/components/table/Table.vue +136 -147
  115. package/src/components/table/{TableBody.vue → TableBody.tsx} +3 -8
  116. package/src/components/table/TableCell.theme.ts +27 -0
  117. package/src/components/table/TableCell.vue +30 -58
  118. package/src/components/table/TableHead.tsx +14 -0
  119. package/src/components/table/TableHeader.vue +18 -20
  120. package/src/components/table/TableRow.vue +23 -20
  121. package/src/components/table/__tests__/Table.spec.ts +11 -0
  122. package/src/components/tag/Tag.theme.ts +32 -0
  123. package/src/components/tag/Tag.vue +40 -68
  124. package/src/components/tag/__tests__/Tag.spec.ts +11 -0
  125. package/src/components/textarea/Textarea.theme.ts +62 -0
  126. package/src/components/textarea/Textarea.vue +100 -115
  127. package/src/components/textarea/__tests__/Textarea.spec.ts +11 -0
  128. package/src/components/toggle/Toggle.theme.ts +51 -0
  129. package/src/components/toggle/Toggle.vue +51 -81
  130. package/src/components/toggle/__tests__/Toggle.spec.ts +11 -0
  131. package/src/components/tooltip/Tooltip.theme.ts +51 -0
  132. package/src/components/tooltip/Tooltip.vue +9 -14
  133. package/src/components/tooltip/__tests__/Tooltip.spec.ts +11 -0
  134. package/src/composables/colors-utils.ts +68 -68
  135. package/src/composables/colors.ts +18 -6
  136. package/src/composables/common.ts +1 -0
  137. package/src/composables/css.ts +7 -2
  138. package/src/composables/index.ts +1 -1
  139. package/src/composables/inputtable.ts +1 -1
  140. package/src/composables/interactive.ts +8 -4
  141. package/src/composables/keys.ts +1 -0
  142. package/src/composables/notifications.ts +10 -0
  143. package/src/composables/theme.ts +88 -0
  144. package/src/create.ts +9 -4
  145. package/src/exports/nuxt.js +2 -1
  146. package/src/version.ts +1 -1
  147. package/volar.d.ts +1 -0
  148. package/lib/components/alert/Alert.vue.d.ts +0 -42
  149. package/lib/components/avatar/Avatar.vue.d.ts +0 -49
  150. package/lib/components/badge/Badge.vue.d.ts +0 -75
  151. package/lib/components/breadcrumbs/Breadcrumbs.vue.d.ts +0 -30
  152. package/lib/components/button/Button.vue.d.ts +0 -87
  153. package/lib/components/button/ButtonGroup.vue.d.ts +0 -49
  154. package/lib/components/card/Card.vue.d.ts +0 -17
  155. package/lib/components/checkbox/Checkbox.vue.d.ts +0 -81
  156. package/lib/components/collapse/Collapse.vue.d.ts +0 -47
  157. package/lib/components/container/Container.vue.d.ts +0 -14
  158. package/lib/components/divider/Divider.vue.d.ts +0 -10
  159. package/lib/components/drawer/Drawer.vue.d.ts +0 -73
  160. package/lib/components/form/Form.vue.d.ts +0 -46
  161. package/lib/components/icon/Icon.vue.d.ts +0 -40
  162. package/lib/components/image/Image.vue.d.ts +0 -8
  163. package/lib/components/index.d.ts +0 -45
  164. package/lib/components/input/Input.vue.d.ts +0 -117
  165. package/lib/components/link/Link.vue.d.ts +0 -36
  166. package/lib/components/menu/Menu.vue.d.ts +0 -62
  167. package/lib/components/menu/MenuItem.vue.d.ts +0 -114
  168. package/lib/components/modal/Modal.vue.d.ts +0 -34
  169. package/lib/components/notifications/Notifications.vue.d.ts +0 -104
  170. package/lib/components/pagination/Pagination.vue.d.ts +0 -58
  171. package/lib/components/pagination/PaginationItem.vue.d.ts +0 -32
  172. package/lib/components/popover/Popover.vue.d.ts +0 -64
  173. package/lib/components/popover/PopoverContainer.vue.d.ts +0 -14
  174. package/lib/components/progress/Progress.vue.d.ts +0 -42
  175. package/lib/components/radio/Radio.vue.d.ts +0 -79
  176. package/lib/components/scroll/Scroll.vue.d.ts +0 -29
  177. package/lib/components/select/Select.vue.d.ts +0 -100
  178. package/lib/components/skeleton/Skeleton.vue.d.ts +0 -14
  179. package/lib/components/slider/Slider.vue.d.ts +0 -96
  180. package/lib/components/spacer/Spacer.vue.d.ts +0 -2
  181. package/lib/components/spinner/Spinner.vue.d.ts +0 -16
  182. package/lib/components/tab/Tab.vue.d.ts +0 -52
  183. package/lib/components/tab/TabGroup.vue.d.ts +0 -61
  184. package/lib/components/table/Table.vue.d.ts +0 -82
  185. package/lib/components/table/TableBody.vue.d.ts +0 -2
  186. package/lib/components/table/TableCell.vue.d.ts +0 -33
  187. package/lib/components/table/TableHead.vue.d.ts +0 -2
  188. package/lib/components/table/TableHeader.vue.d.ts +0 -33
  189. package/lib/components/table/TableRow.vue.d.ts +0 -23
  190. package/lib/components/tag/Tag.vue.d.ts +0 -45
  191. package/lib/components/textarea/Textarea.vue.d.ts +0 -106
  192. package/lib/components/toggle/Toggle.vue.d.ts +0 -79
  193. package/lib/components/tooltip/Tooltip.vue.d.ts +0 -2
  194. package/lib/composables/colors-utils.d.ts +0 -8
  195. package/lib/composables/colors.d.ts +0 -26
  196. package/lib/composables/common.d.ts +0 -14
  197. package/lib/composables/css.d.ts +0 -5
  198. package/lib/composables/index.d.ts +0 -7
  199. package/lib/composables/inputtable.d.ts +0 -37
  200. package/lib/composables/interactive.d.ts +0 -10
  201. package/lib/composables/keys.d.ts +0 -7
  202. package/lib/composables/notification.d.ts +0 -1
  203. package/lib/create.d.ts +0 -12
  204. package/lib/index.d.ts +0 -6
  205. package/lib/install.d.ts +0 -4
  206. package/lib/style.css +0 -1
  207. package/lib/version.d.ts +0 -2
  208. package/src/components/table/TableHead.vue +0 -15
  209. package/src/composables/notification.ts +0 -10
@@ -1,78 +1,66 @@
1
1
  <script lang="ts">
2
- import { computed, defineComponent, ref } from 'vue'
3
- import { useCSS } from '../../composables/css'
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
- export default defineComponent({
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
- props: {
23
- ...useCommon.props(),
24
- ...useColors.props('primary'),
25
- ...useInteractive.props(),
26
- ...useInputtable.props(),
27
- id: String,
28
- label: String,
29
- glow: Boolean,
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
- emits: useInputtable.emits(false),
29
+ const emit = defineEmits(useInputtable.emits(false))
33
30
 
34
- setup(props, { emit }) {
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
- const css = useCSS()
46
- const colors = useColors()
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
- const styles = computed(() => {
49
- const color = colors.getPalette(props.color)
42
+ const { focus, blur } = useInteractive(elRef)
50
43
 
51
- return css.variables({
52
- bg: color[500],
53
- dark: {
54
- bg: color[600],
55
- },
56
- })
57
- })
44
+ const {
45
+ errorInternal,
46
+ reset,
47
+ validate,
48
+ setError,
49
+ } = useInputtable(props, { focus, emit, withListeners: false })
58
50
 
59
- const interactive = useInteractive(elRef)
51
+ const { styles, classes, className } = useTheme('toggle', theme, props)
60
52
 
61
- return {
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="[!disabled ? 'cursor-pointer' : 'cursor-not-allowed']"
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
- 'bg-gray-shadow-md': !disabled
95
+ 'shadow': !disabled
122
96
  },
123
- [disabled ? 'bg-gray-50 dark:bg-gray-800' : 'bg-white dark:bg-gray-800']
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="pl-2 font-medium text-gray-800 dark:text-gray-200"
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
- <p v-if="errorInternal" class="text-sm text-red-500 mt-1" v-text="errorInternal"></p>
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
- import { defineComponent } from 'vue'
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 class="dark">
11
+ <x-popover hover>
19
12
  <slot></slot>
20
13
  <template #content>
21
- <x-popover-container class="p-2 text-white text-sm">
22
- <slot name="tooltip"></slot>
23
- </x-popover-container>
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
- const cc = computedColors
39
- const customColors: ColorLibrary = {}
40
- const e = document.createElement('div')
37
+ // export function calculateColors(): ColorLibrary {
38
+ // const cc = computedColors
39
+ // const customColors: ColorLibrary = {}
40
+ // const e = document.createElement('div')
41
41
 
42
- document.body.appendChild(e)
42
+ // document.body.appendChild(e)
43
43
 
44
- indielayerColors.forEach((color) => {
45
- const c: ColorPalette = { ...tailwindColors.gray }
44
+ // indielayerColors.forEach((color) => {
45
+ // const c: ColorPalette = { ...tailwindColors.gray }
46
46
 
47
- shades.forEach((shade) => {
48
- e.className = `bg-${color}-${shade}`
49
- c[shade] = window.getComputedStyle(e ,null).getPropertyValue('background-color')
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
- customColors[color] = c
53
- })
52
+ // customColors[color] = c
53
+ // })
54
54
 
55
- e.remove()
55
+ // e.remove()
56
56
 
57
- return customColors
58
- }
57
+ // return customColors
58
+ // }
59
59
 
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
- ])
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 { inject } from 'vue'
2
- import { injectColorsKey } from './keys'
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 customColors = inject(injectColorsKey) || defaultColors
34
- // if (Object.keys(customColors).length === 0) customColors = calculateColors()
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}`)
@@ -11,6 +11,7 @@ const validators = Object.freeze({
11
11
  useCommon.props = () => ({
12
12
  size: {
13
13
  type: String as PropType<Size>,
14
+ default: 'md',
14
15
  validator: (value: string) => validators.size.includes(value),
15
16
  },
16
17
  } as const)
@@ -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 const useCSS = (namespace?: string) => {
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${theme ? `-${theme}` : ''}${namespace ? `-${namespace}` : ''}-${name}${modifier ? `-${modifier}` : ''}`
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> = {}
@@ -4,4 +4,4 @@ export * from './colors'
4
4
  export * from './css'
5
5
  export * from './inputtable'
6
6
  export * from './interactive'
7
- export * from './notification'
7
+ export * from './notifications'
@@ -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<[string, number, boolean, object, []]>,
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 | undefined>,
9
+ el: Ref<HTMLElement | null>,
5
10
  ) => {
6
11
  return {
7
- focus: () => {
8
- el.value?.focus?.()
9
- },
12
+ focus: () => el.value?.focus?.(),
13
+ blur: () => el.value?.blur?.(),
10
14
  }
11
15
  }
12
16
 
@@ -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
+ }