@indielayer/ui 1.0.0-alpha.0 → 1.0.0-alpha.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 (103) hide show
  1. package/README.md +26 -10
  2. package/lib/components/avatar/Avatar.vue.d.ts +2 -2
  3. package/lib/components/badge/Badge.vue.d.ts +2 -2
  4. package/lib/components/button/Button.vue.d.ts +2 -2
  5. package/lib/components/button/ButtonGroup.vue.d.ts +2 -2
  6. package/lib/components/checkbox/Checkbox.vue.d.ts +5 -4
  7. package/lib/components/drawer/Drawer.vue.d.ts +1 -1
  8. package/lib/components/icon/Icon.vue.d.ts +2 -2
  9. package/lib/components/index.d.ts +2 -2
  10. package/lib/components/input/Input.vue.d.ts +4 -3
  11. package/lib/components/menu/Menu.vue.d.ts +2 -2
  12. package/lib/components/menu/MenuItem.vue.d.ts +3 -3
  13. package/lib/components/notifications/Notifications.vue.d.ts +2 -2
  14. package/lib/components/pagination/Pagination.vue.d.ts +3 -2
  15. package/lib/components/pagination/PaginationItem.vue.d.ts +2 -2
  16. package/lib/components/radio/Radio.vue.d.ts +3 -3
  17. package/lib/components/select/Select.vue.d.ts +4 -3
  18. package/lib/components/slider/Slider.vue.d.ts +3 -3
  19. package/lib/components/spacer/Spacer.vue.d.ts +1 -1
  20. package/lib/components/spinner/Spinner.vue.d.ts +2 -2
  21. package/lib/components/{tabs → tab}/Tab.vue.d.ts +2 -2
  22. package/lib/components/{tabs/Tabs.vue.d.ts → tab/TabGroup.vue.d.ts} +0 -0
  23. package/lib/components/table/TableBody.vue.d.ts +1 -1
  24. package/lib/components/table/TableHead.vue.d.ts +1 -1
  25. package/lib/components/tag/Tag.vue.d.ts +2 -2
  26. package/lib/components/textarea/Textarea.vue.d.ts +4 -12
  27. package/lib/components/toggle/Toggle.vue.d.ts +3 -3
  28. package/lib/composables/colors.d.ts +1 -1
  29. package/lib/composables/css.d.ts +4 -4
  30. package/lib/composables/keys.d.ts +1 -0
  31. package/lib/create.d.ts +11 -0
  32. package/lib/index.cjs.js +2 -2
  33. package/lib/index.d.ts +2 -0
  34. package/lib/index.es.js +183 -107
  35. package/lib/install.d.ts +4 -6
  36. package/lib/nuxt.js +15 -16
  37. package/lib/nuxt.plugin.js +8 -0
  38. package/lib/style.css +1 -1
  39. package/lib/version.d.ts +1 -1
  40. package/package.json +19 -15
  41. package/src/components/alert/Alert.vue +164 -0
  42. package/src/components/avatar/Avatar.vue +137 -0
  43. package/src/components/badge/Badge.vue +107 -0
  44. package/src/components/breadcrumbs/Breadcrumbs.vue +60 -0
  45. package/src/components/button/Button.vue +433 -0
  46. package/src/components/button/ButtonGroup.vue +73 -0
  47. package/src/components/card/Card.vue +25 -0
  48. package/src/components/checkbox/Checkbox.vue +205 -0
  49. package/src/components/collapse/Collapse.vue +181 -0
  50. package/src/components/container/Container.vue +23 -0
  51. package/src/components/divider/Divider.vue +52 -0
  52. package/src/components/drawer/Drawer.vue +244 -0
  53. package/src/components/form/Form.vue +111 -0
  54. package/src/components/icon/Icon.vue +56 -0
  55. package/src/components/image/Image.vue +36 -0
  56. package/src/components/index.ts +45 -0
  57. package/src/components/input/Input.vue +198 -0
  58. package/src/components/link/Link.vue +110 -0
  59. package/src/components/menu/Menu.vue +118 -0
  60. package/src/components/menu/MenuItem.vue +277 -0
  61. package/src/components/modal/Modal.vue +175 -0
  62. package/src/components/notifications/Notifications.vue +318 -0
  63. package/src/components/pagination/Pagination.vue +181 -0
  64. package/src/components/pagination/PaginationItem.vue +58 -0
  65. package/src/components/popover/Popover.vue +194 -0
  66. package/src/components/popover/PopoverContainer.vue +23 -0
  67. package/src/components/progress/Progress.vue +86 -0
  68. package/src/components/radio/Radio.vue +220 -0
  69. package/src/components/scroll/Scroll.vue +143 -0
  70. package/src/components/select/Select.vue +408 -0
  71. package/src/components/skeleton/Skeleton.vue +23 -0
  72. package/src/components/slider/Slider.vue +240 -0
  73. package/src/components/spacer/Spacer.vue +11 -0
  74. package/src/components/spinner/Spinner.vue +45 -0
  75. package/src/components/tab/Tab.vue +100 -0
  76. package/src/components/tab/TabGroup.vue +151 -0
  77. package/src/components/table/Table.vue +172 -0
  78. package/src/components/table/TableBody.vue +13 -0
  79. package/src/components/table/TableCell.vue +78 -0
  80. package/src/components/table/TableHead.vue +15 -0
  81. package/src/components/table/TableHeader.vue +94 -0
  82. package/src/components/table/TableRow.vue +43 -0
  83. package/src/components/tag/Tag.vue +98 -0
  84. package/src/components/textarea/Textarea.vue +156 -0
  85. package/src/components/toggle/Toggle.vue +144 -0
  86. package/src/components/tooltip/Tooltip.vue +26 -0
  87. package/src/composables/colors-utils.ts +378 -0
  88. package/src/composables/colors.ts +82 -0
  89. package/src/composables/common.ts +20 -0
  90. package/src/composables/css.ts +45 -0
  91. package/src/composables/index.ts +7 -0
  92. package/src/composables/inputtable.ts +128 -0
  93. package/src/composables/interactive.ts +16 -0
  94. package/src/composables/keys.ts +8 -0
  95. package/src/composables/notification.ts +10 -0
  96. package/src/create.ts +36 -0
  97. package/src/exports/nuxt.js +32 -0
  98. package/src/exports/nuxt.plugin.js +8 -0
  99. package/src/exports/tailwind.preset.js +55 -0
  100. package/src/index.ts +8 -0
  101. package/src/install.ts +8 -0
  102. package/src/shims-vue.d.ts +6 -0
  103. package/src/version.ts +1 -0
@@ -0,0 +1,433 @@
1
+ <script lang="ts">
2
+ import { defineComponent, computed, ref, inject } from 'vue'
3
+ import { useCSS } from '../../composables/css'
4
+ import { useCommon } from '../../composables/common'
5
+ import { useColors } from '../../composables/colors'
6
+ import { useInteractive } from '../../composables/interactive'
7
+ import { injectButtonGroupKey } from '../../composables/keys'
8
+
9
+ import XSpinner from '../../components/spinner/Spinner.vue'
10
+ import XIcon from '../../components/icon/Icon.vue'
11
+
12
+ export type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | undefined
13
+
14
+ export default defineComponent({
15
+ name: 'XButton',
16
+
17
+ components: {
18
+ XIcon,
19
+ XSpinner,
20
+ },
21
+
22
+ validators: {
23
+ ...useCommon.validators(),
24
+ },
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,
48
+ },
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[900],
109
+ text: 'white',
110
+ border: gray[600],
111
+ hover: { bg: !props.loading ? gray[800] : '' },
112
+ active: { bg: !props.loading ? gray[700] : '' },
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
+ }
209
+
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
+ }
272
+
273
+ return vars
274
+ })
275
+
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
+ })
303
+
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
+ })
320
+ </script>
321
+
322
+ <template>
323
+ <component
324
+ :is="htmlTag"
325
+ ref="elRef"
326
+ :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
+ :class="[
330
+ $style['button'],
331
+ (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
+ },
356
+ ]"
357
+ :aria-busy="loading ? 'true' : null"
358
+ :aria-disabled="tag !== 'button' && computedDisabled ? 'true' : null"
359
+ :disabled="computedDisabled || loading"
360
+ :type="tag === 'button' ? type : null"
361
+ >
362
+ <x-spinner v-if="loading" :size="computedSize" class="absolute" />
363
+ <x-icon
364
+ v-if="icon"
365
+ :size="computedSize"
366
+ :icon="icon"
367
+ class="shrink-0"
368
+ :class="[
369
+ [$slots.default ? 'mr-2' : 'm-0.5'],
370
+ {
371
+ invisible: loading,
372
+ },
373
+ ]"
374
+ />
375
+ <span :class="{ invisible: loading }">
376
+ <slot></slot>
377
+ </span>
378
+ <x-icon
379
+ v-if="iconRight"
380
+ :size="computedSize"
381
+ :icon="iconRight"
382
+ class="shrink-0"
383
+ :class="[
384
+ [$slots.default ? 'mr-2' : 'm-0.5'],
385
+ {
386
+ invisible: loading,
387
+ },
388
+ ]"
389
+ />
390
+ </component>
391
+ </template>
392
+
393
+ <style lang="postcss" module scoped>
394
+ .button {
395
+ color: var(--x-button-text);
396
+ background-color: var(--x-button-bg);
397
+ border-color: var(--x-button-border);
398
+
399
+ &--glow {
400
+ box-shadow: 0 0 #000, 0 0 #000, 0 10px 15px -3px var(--x-button-glow), 0 4px 6px -4px var(--x-button-glow);
401
+ }
402
+
403
+ &:hover {
404
+ color: var(--x-button-text-hover, var(--x-button-text));
405
+ background-color: var(--x-button-bg-hover, var(--x-button-bg));
406
+ border-color: var(--x-button-border-hover, var(--x-button-border));
407
+ }
408
+
409
+ &:active {
410
+ color: var(--x-button-text-active, var(--x-button-text));
411
+ background-color: var(--x-button-bg-active, var(--x-button-bg));
412
+ border-color: var(--x-button-border-active, var(--x-button-border));
413
+ }
414
+
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));
419
+
420
+ &: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)));
424
+ }
425
+
426
+ &: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)));
430
+ }
431
+ }
432
+ }
433
+ </style>
@@ -0,0 +1,73 @@
1
+ <script lang="ts">
2
+ import { defineComponent, provide } from 'vue'
3
+ import { useCommon } from '../../composables/common'
4
+ import { useColors } from '../../composables/colors'
5
+ import { useInteractive } from '../../composables/interactive'
6
+ import { injectButtonGroupKey } from '../../composables/keys'
7
+
8
+ export default defineComponent({
9
+ name: 'XButtonGroup',
10
+
11
+ validators: {
12
+ ...useCommon.validators(),
13
+ },
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,
27
+ },
28
+
29
+ setup(props) {
30
+ provide(injectButtonGroupKey, {
31
+ groupProps: props,
32
+ isButtonGroup: true,
33
+ })
34
+ },
35
+ })
36
+ </script>
37
+
38
+ <template>
39
+ <component
40
+ :is="tag"
41
+ class="inline-flex align-middle relative"
42
+ :class="[
43
+ $style['button-group'],
44
+ rounded ? $style['button-group--rounded'] : ''
45
+ ]"
46
+ >
47
+ <slot></slot>
48
+ </component>
49
+ </template>
50
+
51
+ <style lang="postcss" module>
52
+ .button-group {
53
+ &:not(&--rounded) {
54
+ > :first-child {
55
+ @apply rounded-l-md border-l
56
+ }
57
+
58
+ > :last-child {
59
+ @apply rounded-r-md
60
+ }
61
+ }
62
+
63
+ &--rounded {
64
+ > :first-of-type {
65
+ @apply rounded-l-full border-l
66
+ }
67
+
68
+ > :last-child {
69
+ @apply rounded-r-full
70
+ }
71
+ }
72
+ }
73
+ </style>
@@ -0,0 +1,25 @@
1
+ <script lang="ts">
2
+ import { defineComponent } from 'vue'
3
+
4
+ export default defineComponent({
5
+ name: 'XCard',
6
+
7
+ props: {
8
+ tag: {
9
+ type: String,
10
+ default: 'div',
11
+ },
12
+ flat: Boolean,
13
+ },
14
+ })
15
+ </script>
16
+
17
+ <template>
18
+ <component
19
+ :is="tag"
20
+ class="rounded bg-white dark:bg-gray-800"
21
+ :class="[{ 'shadow': !flat }]"
22
+ >
23
+ <slot></slot>
24
+ </component>
25
+ </template>