@nuxt/ui 2.8.1 → 2.10.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 (120) hide show
  1. package/README.md +1 -0
  2. package/dist/module.d.mts +1411 -1092
  3. package/dist/module.d.ts +1411 -1092
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +55 -11
  6. package/dist/runtime/components/data/Table.vue +47 -32
  7. package/dist/runtime/components/data/Table.vue.d.ts +22 -14
  8. package/dist/runtime/components/elements/Accordion.vue +33 -28
  9. package/dist/runtime/components/elements/Accordion.vue.d.ts +25 -18
  10. package/dist/runtime/components/elements/Alert.vue +22 -18
  11. package/dist/runtime/components/elements/Alert.vue.d.ts +26 -19
  12. package/dist/runtime/components/elements/Avatar.vue +22 -16
  13. package/dist/runtime/components/elements/Avatar.vue.d.ts +28 -19
  14. package/dist/runtime/components/elements/AvatarGroup.d.ts +17 -8
  15. package/dist/runtime/components/elements/AvatarGroup.mjs +18 -13
  16. package/dist/runtime/components/elements/Badge.vue +21 -17
  17. package/dist/runtime/components/elements/Badge.vue.d.ts +28 -19
  18. package/dist/runtime/components/elements/Button.vue +22 -18
  19. package/dist/runtime/components/elements/Button.vue.d.ts +28 -19
  20. package/dist/runtime/components/elements/ButtonGroup.d.ts +17 -8
  21. package/dist/runtime/components/elements/ButtonGroup.mjs +22 -15
  22. package/dist/runtime/components/elements/Dropdown.vue +45 -37
  23. package/dist/runtime/components/elements/Dropdown.vue.d.ts +22 -17
  24. package/dist/runtime/components/elements/Kbd.vue +16 -12
  25. package/dist/runtime/components/elements/Kbd.vue.d.ts +20 -12
  26. package/dist/runtime/components/elements/Link.vue +18 -5
  27. package/dist/runtime/components/elements/Meter.vue +166 -0
  28. package/dist/runtime/components/elements/Meter.vue.d.ts +123 -0
  29. package/dist/runtime/components/elements/MeterGroup.d.ts +78 -0
  30. package/dist/runtime/components/elements/MeterGroup.mjs +172 -0
  31. package/dist/runtime/components/elements/Progress.vue +284 -0
  32. package/dist/runtime/components/elements/Progress.vue.d.ts +2 -0
  33. package/dist/runtime/components/forms/Checkbox.vue +27 -17
  34. package/dist/runtime/components/forms/Checkbox.vue.d.ts +33 -15
  35. package/dist/runtime/components/forms/Form.vue +34 -9
  36. package/dist/runtime/components/forms/Form.vue.d.ts +2 -1
  37. package/dist/runtime/components/forms/FormGroup.vue +51 -27
  38. package/dist/runtime/components/forms/FormGroup.vue.d.ts +23 -15
  39. package/dist/runtime/components/forms/Input.vue +41 -29
  40. package/dist/runtime/components/forms/Input.vue.d.ts +51 -24
  41. package/dist/runtime/components/forms/Radio.vue +32 -21
  42. package/dist/runtime/components/forms/Radio.vue.d.ts +36 -18
  43. package/dist/runtime/components/forms/RadioGroup.vue +136 -0
  44. package/dist/runtime/components/forms/RadioGroup.vue.d.ts +118 -0
  45. package/dist/runtime/components/forms/Range.vue +26 -16
  46. package/dist/runtime/components/forms/Range.vue.d.ts +37 -18
  47. package/dist/runtime/components/forms/Select.vue +34 -26
  48. package/dist/runtime/components/forms/Select.vue.d.ts +42 -24
  49. package/dist/runtime/components/forms/SelectMenu.vue +104 -89
  50. package/dist/runtime/components/forms/SelectMenu.vue.d.ts +53 -33
  51. package/dist/runtime/components/forms/Textarea.vue +43 -31
  52. package/dist/runtime/components/forms/Textarea.vue.d.ts +50 -23
  53. package/dist/runtime/components/forms/Toggle.vue +26 -15
  54. package/dist/runtime/components/forms/Toggle.vue.d.ts +31 -12
  55. package/dist/runtime/components/layout/Card.vue +15 -10
  56. package/dist/runtime/components/layout/Card.vue.d.ts +17 -9
  57. package/dist/runtime/components/layout/Container.vue +15 -10
  58. package/dist/runtime/components/layout/Container.vue.d.ts +17 -9
  59. package/dist/runtime/components/layout/Divider.vue +107 -0
  60. package/dist/runtime/components/layout/Divider.vue.d.ts +82 -0
  61. package/dist/runtime/components/layout/Skeleton.vue +15 -10
  62. package/dist/runtime/components/layout/Skeleton.vue.d.ts +17 -9
  63. package/dist/runtime/components/navigation/CommandPalette.vue +57 -38
  64. package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +24 -23
  65. package/dist/runtime/components/navigation/CommandPaletteGroup.vue +1 -1
  66. package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +3 -4
  67. package/dist/runtime/components/navigation/Pagination.vue +129 -64
  68. package/dist/runtime/components/navigation/Pagination.vue.d.ts +70 -25
  69. package/dist/runtime/components/navigation/Tabs.vue +17 -14
  70. package/dist/runtime/components/navigation/Tabs.vue.d.ts +18 -11
  71. package/dist/runtime/components/navigation/VerticalNavigation.vue +15 -13
  72. package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +20 -16
  73. package/dist/runtime/components/overlays/ContextMenu.vue +21 -11
  74. package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +20 -11
  75. package/dist/runtime/components/overlays/Modal.vue +16 -14
  76. package/dist/runtime/components/overlays/Modal.vue.d.ts +18 -11
  77. package/dist/runtime/components/overlays/Notification.vue +25 -15
  78. package/dist/runtime/components/overlays/Notification.vue.d.ts +25 -19
  79. package/dist/runtime/components/overlays/Notifications.vue +19 -13
  80. package/dist/runtime/components/overlays/Notifications.vue.d.ts +22 -14
  81. package/dist/runtime/components/overlays/Popover.vue +39 -22
  82. package/dist/runtime/components/overlays/Popover.vue.d.ts +32 -11
  83. package/dist/runtime/components/overlays/Slideover.vue +15 -13
  84. package/dist/runtime/components/overlays/Slideover.vue.d.ts +18 -11
  85. package/dist/runtime/components/overlays/Tooltip.vue +31 -23
  86. package/dist/runtime/components/overlays/Tooltip.vue.d.ts +19 -11
  87. package/dist/runtime/composables/useFormGroup.d.ts +12 -2
  88. package/dist/runtime/composables/useFormGroup.mjs +21 -4
  89. package/dist/runtime/composables/usePopper.d.ts +3 -3
  90. package/dist/runtime/composables/usePopper.mjs +47 -31
  91. package/dist/runtime/composables/useToast.d.ts +3 -3
  92. package/dist/runtime/composables/useUI.d.ts +10 -0
  93. package/dist/runtime/composables/useUI.mjs +24 -0
  94. package/dist/runtime/types/avatar.d.ts +10 -4
  95. package/dist/runtime/types/badge.d.ts +14 -0
  96. package/dist/runtime/types/button.d.ts +10 -3
  97. package/dist/runtime/types/command-palette.d.ts +3 -1
  98. package/dist/runtime/types/form.d.ts +18 -4
  99. package/dist/runtime/types/index.d.ts +4 -0
  100. package/dist/runtime/types/link.d.ts +1 -0
  101. package/dist/runtime/types/meter.d.ts +5 -0
  102. package/dist/runtime/types/notification.d.ts +5 -3
  103. package/dist/runtime/types/popper.d.ts +1 -0
  104. package/dist/runtime/types/progress.d.ts +4 -0
  105. package/dist/runtime/types/tabs.d.ts +1 -0
  106. package/dist/runtime/types/utils.d.ts +11 -0
  107. package/dist/runtime/ui.config.d.ts +1470 -0
  108. package/dist/runtime/{app.config.mjs → ui.config.mjs} +313 -97
  109. package/dist/runtime/utils/index.d.ts +5 -11
  110. package/dist/runtime/utils/index.mjs +21 -9
  111. package/dist/runtime/utils/lodash.d.ts +2 -0
  112. package/dist/runtime/utils/lodash.mjs +23 -0
  113. package/dist/runtime/utils/uid.d.ts +1 -0
  114. package/dist/runtime/utils/uid.mjs +4 -0
  115. package/dist/types.d.mts +1 -1
  116. package/dist/types.d.ts +1 -1
  117. package/package.json +27 -29
  118. package/dist/runtime/app.config.d.ts +0 -1203
  119. package/dist/runtime/utils/StateEmitter.d.ts +0 -17
  120. package/dist/runtime/utils/StateEmitter.mjs +0 -21
@@ -0,0 +1,172 @@
1
+ import { h, cloneVNode, computed, toRef, defineComponent } from "vue";
2
+ import { twJoin } from "tailwind-merge";
3
+ import UIcon from "./Icon.vue";
4
+ import { useUI } from "../../composables/useUI.mjs";
5
+ import { mergeConfig, getSlotsChildren } from "../../utils/index.mjs";
6
+ import appConfig from "#build/app.config";
7
+ import { meter, meterGroup } from "#ui/ui.config";
8
+ const meterConfig = mergeConfig(appConfig.ui.strategy, appConfig.ui.meter, meter);
9
+ const meterGroupConfig = mergeConfig(appConfig.ui.strategy, appConfig.ui.meterGroup, meterGroup);
10
+ export default defineComponent({
11
+ components: {
12
+ UIcon
13
+ },
14
+ inheritAttrs: false,
15
+ slots: Object,
16
+ props: {
17
+ min: {
18
+ type: Number,
19
+ default: 0
20
+ },
21
+ max: {
22
+ type: Number,
23
+ default: 100
24
+ },
25
+ size: {
26
+ type: String,
27
+ default: () => meterConfig.default.size,
28
+ validator(value) {
29
+ return Object.keys(meterConfig.meter.bar.size).includes(value);
30
+ }
31
+ },
32
+ indicator: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ icon: {
37
+ type: String,
38
+ default: "i-heroicons-minus"
39
+ },
40
+ class: {
41
+ type: [String, Object, Array],
42
+ default: void 0
43
+ },
44
+ ui: {
45
+ type: Object,
46
+ default: void 0
47
+ }
48
+ },
49
+ setup(props, { slots }) {
50
+ const { ui, attrs } = useUI("meterGroup", toRef(props, "ui"), meterGroupConfig);
51
+ const { ui: uiMeter } = useUI("meter", void 0, meterConfig);
52
+ if (!slots.default) {
53
+ throw new Error("Meter Group has no Meter children.");
54
+ }
55
+ const normalizedMin = computed(() => props.min > props.max ? props.max : props.min);
56
+ const normalizedMax = computed(() => props.max < props.min ? props.min : props.max);
57
+ const children = computed(() => getSlotsChildren(slots));
58
+ const rounded = computed(() => {
59
+ const roundedMap = {
60
+ "rounded-none": { left: "rounded-s-none", right: "rounded-e-none" },
61
+ "rounded-sm": { left: "rounded-s-sm", right: "rounded-e-sm" },
62
+ rounded: { left: "rounded-s", right: "rounded-e" },
63
+ "rounded-md": { left: "rounded-s-md", right: "rounded-e-md" },
64
+ "rounded-lg": { left: "rounded-s-lg", right: "rounded-e-lg" },
65
+ "rounded-xl": { left: "rounded-s-xl", right: "rounded-e-xl" },
66
+ "rounded-2xl": { left: "rounded-s-2xl", right: "rounded-e-2xl" },
67
+ "rounded-3xl": { left: "rounded-s-3xl", right: "rounded-e-3xl" },
68
+ "rounded-full": { left: "rounded-s-full", right: "rounded-e-full" }
69
+ };
70
+ return roundedMap[ui.value.rounded];
71
+ });
72
+ function clampPercent(value, min, max) {
73
+ if (min == max) {
74
+ return value < min ? 0 : 100;
75
+ }
76
+ if (min > max) {
77
+ max = [min, min = max][0];
78
+ }
79
+ const percent2 = (value - min) / (max - min) * 100;
80
+ return Math.max(0, Math.min(100, percent2));
81
+ }
82
+ const labels = computed(() => {
83
+ return children.value.map((node) => node.props.label);
84
+ });
85
+ const percents = computed(() => {
86
+ return children.value.map((node) => clampPercent(node.props.value, props.min, props.max));
87
+ });
88
+ const percent = computed(() => {
89
+ return Math.max(0, Math.max(percents.value.reduce((prev, percent2) => prev + percent2, 0)));
90
+ });
91
+ const clones = computed(() => children.value.map((node, index) => {
92
+ const vProps = {};
93
+ vProps.style = { width: `${percents.value[index]}%` };
94
+ vProps.size = props.size;
95
+ vProps.min = normalizedMin.value;
96
+ vProps.max = normalizedMax.value;
97
+ vProps.ui = node.props?.ui || {};
98
+ vProps.ui.wrapper = node.props?.ui?.wrapper || "";
99
+ vProps.ui.wrapper += [
100
+ node.props?.ui?.wrapper,
101
+ props.ui?.meter?.background || ui.value.background,
102
+ ui.value.transition
103
+ ].filter(Boolean).join(" ");
104
+ vProps.ui.meter = node.props?.ui?.meter || {};
105
+ vProps.ui.meter.background = `bg-${node.props.color}-500 dark:bg-${node.props.color}-400`;
106
+ vProps.ui.meter.rounded = "rounded-none";
107
+ vProps.ui.meter.bar = node.props?.ui?.meter?.bar || {};
108
+ if (index === 0) {
109
+ vProps.ui.meter.rounded = `${rounded.value.left} rounded-e-none`;
110
+ }
111
+ if (index === children.value.length - 1) {
112
+ vProps.ui.meter.rounded = `${rounded.value.right} rounded-s-none`;
113
+ }
114
+ labels.value[index] = node.props.label;
115
+ const clone = cloneVNode(node, vProps);
116
+ delete clone.children?.label;
117
+ delete clone.props.indicator;
118
+ delete clone.props.label;
119
+ return clone;
120
+ }));
121
+ const baseClass = computed(() => {
122
+ return twJoin(
123
+ ui.value.base,
124
+ ui.value.background,
125
+ ui.value.rounded,
126
+ ui.value.shadow,
127
+ uiMeter.value.meter.size[props.size]
128
+ );
129
+ });
130
+ const indicatorContainerClass = computed(() => {
131
+ return twJoin(
132
+ uiMeter.value.indicator.container
133
+ );
134
+ });
135
+ const indicatorClass = computed(() => {
136
+ return twJoin(
137
+ uiMeter.value.indicator.text,
138
+ uiMeter.value.indicator.size[props.size]
139
+ );
140
+ });
141
+ const vNodeChildren = computed(() => {
142
+ const vNodeSlots = [
143
+ void 0,
144
+ h("div", { class: baseClass.value }, clones.value),
145
+ void 0
146
+ ];
147
+ if (props.indicator) {
148
+ vNodeSlots[0] = h("div", { class: indicatorContainerClass.value }, [
149
+ h("div", { class: indicatorClass.value, style: { width: `${percent.value}%` } }, Math.round(percent.value) + "%")
150
+ ]);
151
+ } else if (slots.indicator) {
152
+ vNodeSlots[0] = slots.indicator({ percent: percent.value });
153
+ }
154
+ vNodeSlots[2] = h("ol", { class: "list-disc list-inside" }, labels.value.map((label, key) => {
155
+ const labelClass = computed(() => {
156
+ return twJoin(
157
+ uiMeter.value.label.base,
158
+ uiMeter.value.label.text,
159
+ uiMeter.value.color[clones.value[key]?.props.color] ?? uiMeter.value.label.color.replaceAll("{color}", clones.value[key]?.props.color ?? uiMeter.value.default.color),
160
+ uiMeter.value.label.size[props.size]
161
+ );
162
+ });
163
+ return h("li", { class: labelClass.value }, [
164
+ h(UIcon, { name: clones.value[key]?.props.icon ?? props.icon }),
165
+ `${label} (${Math.round(percents.value[key])}%)`
166
+ ]);
167
+ }));
168
+ return vNodeSlots;
169
+ });
170
+ return () => h("div", { class: ui.value.wrapper, ...attrs.value }, vNodeChildren.value);
171
+ }
172
+ });
@@ -0,0 +1,284 @@
1
+ <template>
2
+ <div :class="ui.wrapper" v-bind="attrs">
3
+ <slot v-if="indicator || $slots.indicator" name="indicator" v-bind="{ percent }">
4
+ <div v-if="!isSteps" :class="indicatorContainerClass" :style="{ width: `${percent}%` }">
5
+ <div :class="indicatorClass">
6
+ {{ Math.round(percent) }}%
7
+ </div>
8
+ </div>
9
+ </slot>
10
+
11
+ <progress :class="progressClass" v-bind="{ value, max: realMax }">
12
+ {{ Math.round(percent) }}%
13
+ </progress>
14
+
15
+ <div v-if="isSteps" :class="stepsClass">
16
+ <div v-for="(step, index) in max" :key="index" :class="stepClasses(index)">
17
+ <slot :name="`step-${index}`" v-bind="{ step }">
18
+ {{ step }}
19
+ </slot>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ </template>
24
+
25
+ <script>
26
+ import { computed, defineComponent, toRef } from "vue";
27
+ import { twJoin } from "tailwind-merge";
28
+ import { useUI } from "../../composables/useUI";
29
+ import { mergeConfig } from "../../utils";
30
+ import appConfig from "#build/app.config";
31
+ import { progress } from "#ui/ui.config";
32
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.progress, progress);
33
+ export default defineComponent({
34
+ inheritAttrs: false,
35
+ props: {
36
+ value: {
37
+ type: [Number, null, void 0],
38
+ default: null
39
+ },
40
+ max: {
41
+ type: [Number, Array],
42
+ default: 100
43
+ },
44
+ indicator: {
45
+ type: Boolean,
46
+ default: false
47
+ },
48
+ animation: {
49
+ type: String,
50
+ default: () => config.default.animation,
51
+ validator(value) {
52
+ return Object.keys(config.animation).includes(value);
53
+ }
54
+ },
55
+ size: {
56
+ type: String,
57
+ default: () => config.default.size,
58
+ validator(value) {
59
+ return Object.keys(config.progress.size).includes(value);
60
+ }
61
+ },
62
+ color: {
63
+ type: String,
64
+ default: () => config.default.color,
65
+ validator(value) {
66
+ return appConfig.ui.colors.includes(value);
67
+ }
68
+ },
69
+ class: {
70
+ type: [String, Object, Array],
71
+ default: void 0
72
+ },
73
+ ui: {
74
+ type: Object,
75
+ default: void 0
76
+ }
77
+ },
78
+ setup(props) {
79
+ const { ui, attrs } = useUI("progress", toRef(props, "ui"), config, toRef(props, "class"));
80
+ const indicatorContainerClass = computed(() => {
81
+ return twJoin(
82
+ ui.value.indicator.container.base,
83
+ ui.value.indicator.container.width,
84
+ ui.value.indicator.container.transition
85
+ );
86
+ });
87
+ const indicatorClass = computed(() => {
88
+ return twJoin(
89
+ ui.value.indicator.align,
90
+ ui.value.indicator.width,
91
+ ui.value.indicator.color,
92
+ ui.value.indicator.size[props.size]
93
+ );
94
+ });
95
+ const progressClass = computed(() => {
96
+ const classes = [
97
+ ui.value.progress.base,
98
+ ui.value.progress.width,
99
+ ui.value.progress.size[props.size],
100
+ ui.value.progress.rounded,
101
+ ui.value.progress.track,
102
+ ui.value.progress.bar,
103
+ // Intermediate class to allow thumb ring or background color (set to `current`) as it's impossible to safelist with arbitrary values
104
+ ui.value.progress.color?.replaceAll("{color}", props.color),
105
+ ui.value.progress.background,
106
+ ui.value.progress.indeterminate.base,
107
+ ui.value.progress.indeterminate.rounded
108
+ ];
109
+ if (isIndeterminate.value) {
110
+ classes.push(ui.value.animation[props.animation]);
111
+ }
112
+ return twJoin(...classes);
113
+ });
114
+ const stepsClass = computed(() => {
115
+ return twJoin(
116
+ ui.value.steps.base,
117
+ ui.value.steps.color?.replaceAll("{color}", props.color),
118
+ ui.value.steps.size[props.size]
119
+ );
120
+ });
121
+ const stepClass = computed(() => {
122
+ return twJoin(
123
+ ui.value.step.base,
124
+ ui.value.step.align
125
+ );
126
+ });
127
+ const stepActiveClass = computed(() => {
128
+ return twJoin(
129
+ ui.value.step.active
130
+ );
131
+ });
132
+ const stepFirstClass = computed(() => {
133
+ return twJoin(
134
+ ui.value.step.first
135
+ );
136
+ });
137
+ function isActive(index) {
138
+ return index === Number(props.value);
139
+ }
140
+ function isFirst(index) {
141
+ return index === 0;
142
+ }
143
+ function stepClasses(index) {
144
+ index = Number(index);
145
+ const classes = [stepClass.value];
146
+ if (isFirst(index)) {
147
+ classes.push(stepFirstClass.value);
148
+ }
149
+ if (isActive(index)) {
150
+ classes.push(stepActiveClass.value);
151
+ }
152
+ return classes.join(" ");
153
+ }
154
+ const isIndeterminate = computed(() => [void 0, null].includes(props.value));
155
+ const isSteps = computed(() => Array.isArray(props.max));
156
+ const realMax = computed(() => {
157
+ if (isIndeterminate.value) {
158
+ return null;
159
+ }
160
+ if (Array.isArray(props.max)) {
161
+ return props.max.length - 1;
162
+ }
163
+ return Number(props.max);
164
+ });
165
+ const percent = computed(() => {
166
+ switch (true) {
167
+ case props.value < 0:
168
+ return 0;
169
+ case props.value > 100:
170
+ return 100;
171
+ default:
172
+ return props.value / realMax.value * 100;
173
+ }
174
+ });
175
+ return {
176
+ // eslint-disable-next-line vue/no-dupe-keys
177
+ ui,
178
+ attrs,
179
+ indicatorContainerClass,
180
+ indicatorClass,
181
+ progressClass,
182
+ stepsClass,
183
+ stepClasses,
184
+ isIndeterminate,
185
+ isSteps,
186
+ realMax,
187
+ percent
188
+ };
189
+ }
190
+ });
191
+ </script>
192
+
193
+ <style scoped>
194
+ /** These styles are required to animate the bar */
195
+ progress:indeterminate {
196
+ @apply relative;
197
+
198
+ &:after {
199
+ @apply content-[''];
200
+ @apply absolute inset-0;
201
+ @apply bg-current;
202
+ }
203
+
204
+ &::-webkit-progress-value {
205
+ @apply bg-current;
206
+ }
207
+
208
+ &::-moz-progress-bar {
209
+ @apply bg-current;
210
+ }
211
+
212
+ &.bar-animation-carousel {
213
+ &:after {
214
+ animation: carousel 2s ease-in-out infinite;
215
+ }
216
+ &::-webkit-progress-value {
217
+ animation: carousel 2s ease-in-out infinite;
218
+ }
219
+ &::-moz-progress-bar {
220
+ animation: carousel 2s ease-in-out infinite;
221
+ }
222
+ }
223
+
224
+ &.bar-animation-carousel-inverse {
225
+ &:after {
226
+ animation: carousel-inverse 2s ease-in-out infinite;
227
+ }
228
+ &::-webkit-progress-value {
229
+ animation: carousel-inverse 2s ease-in-out infinite;
230
+ }
231
+ &::-moz-progress-bar {
232
+ animation: carousel-inverse 2s ease-in-out infinite;
233
+ }
234
+ }
235
+
236
+ &.bar-animation-swing {
237
+ &:after {
238
+ animation: swing 3s ease-in-out infinite;
239
+ }
240
+ &::-webkit-progress-value {
241
+ animation: swing 3s ease-in-out infinite;
242
+ }
243
+ &::-moz-progress-bar {
244
+ animation: swing 3s ease-in-out infinite;
245
+ }
246
+ }
247
+
248
+ &.bar-animation-elastic {
249
+ &::after {
250
+ animation: elastic 3s ease-in-out infinite;
251
+ }
252
+ &::-webkit-progress-value {
253
+ animation: elastic 3s ease-in-out infinite;
254
+ }
255
+ &::-moz-progress-bar {
256
+ animation: elastic 3s ease-in-out infinite;
257
+ }
258
+ }
259
+ }
260
+
261
+ @keyframes carousel {
262
+ 0%, 100% { width: 50% }
263
+ 0% { transform: translateX(-100%) }
264
+ 100% { transform: translateX(200%) }
265
+ }
266
+
267
+ @keyframes carousel-inverse {
268
+ 0%, 100% { width: 50% }
269
+ 0% { transform: translateX(200%) }
270
+ 100% { transform: translateX(-100%) }
271
+ }
272
+
273
+ @keyframes swing {
274
+ 0%, 100% { width: 50% }
275
+ 0%, 100% { transform: translateX(-25%) }
276
+ 50% { transform: translateX(125%) }
277
+ }
278
+
279
+ @keyframes elastic {
280
+ /* Firefox doesn't do "margin: 0 auto", we have to play with margin-left */
281
+ 0%, 100% { width: 50%; margin-left: 25%; }
282
+ 50% { width: 90%; margin-left: 5% }
283
+ }
284
+ </style>
@@ -0,0 +1,2 @@
1
+ declare const _default: (props: Record<string, any> & {}) => any;
2
+ export default _default;
@@ -1,8 +1,8 @@
1
1
  <template>
2
- <div :class="wrapperClass">
2
+ <div :class="ui.wrapper">
3
3
  <div class="flex items-center h-5">
4
4
  <input
5
- :id="name"
5
+ :id="inputId"
6
6
  v-model="toggle"
7
7
  :name="name"
8
8
  :required="required"
@@ -18,7 +18,7 @@
18
18
  >
19
19
  </div>
20
20
  <div v-if="label || $slots.label" class="ms-3 text-sm">
21
- <label :for="name" :class="ui.label">
21
+ <label :for="inputId" :class="ui.label">
22
22
  <slot name="label">{{ label }}</slot>
23
23
  <span v-if="required" :class="ui.required">*</span>
24
24
  </label>
@@ -30,16 +30,23 @@
30
30
  </template>
31
31
 
32
32
  <script>
33
- import { computed, defineComponent } from "vue";
34
- import { omit } from "lodash-es";
33
+ import { computed, toRef, defineComponent } from "vue";
35
34
  import { twMerge, twJoin } from "tailwind-merge";
36
- import { defuTwMerge } from "../../utils";
35
+ import { useUI } from "../../composables/useUI";
37
36
  import { useFormGroup } from "../../composables/useFormGroup";
38
- import { useAppConfig } from "#imports";
37
+ import { mergeConfig } from "../../utils";
38
+ import { uid } from "../../utils/uid";
39
39
  import appConfig from "#build/app.config";
40
+ import { checkbox } from "#ui/ui.config";
41
+ const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.checkbox, checkbox);
40
42
  export default defineComponent({
41
43
  inheritAttrs: false,
42
44
  props: {
45
+ id: {
46
+ type: String,
47
+ // A default value is needed here to bind the label
48
+ default: () => uid()
49
+ },
43
50
  value: {
44
51
  type: [String, Number, Boolean, Object],
45
52
  default: null
@@ -78,7 +85,7 @@ export default defineComponent({
78
85
  },
79
86
  color: {
80
87
  type: String,
81
- default: () => appConfig.ui.checkbox.default.color,
88
+ default: () => config.default.color,
82
89
  validator(value) {
83
90
  return appConfig.ui.colors.includes(value);
84
91
  }
@@ -87,17 +94,19 @@ export default defineComponent({
87
94
  type: String,
88
95
  default: ""
89
96
  },
97
+ class: {
98
+ type: [String, Object, Array],
99
+ default: void 0
100
+ },
90
101
  ui: {
91
102
  type: Object,
92
- default: () => ({})
103
+ default: void 0
93
104
  }
94
105
  },
95
106
  emits: ["update:modelValue", "change"],
96
- setup(props, { emit, attrs }) {
97
- const appConfig2 = useAppConfig();
98
- const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.checkbox));
99
- const { emitFormChange, formGroup } = useFormGroup();
100
- const color = computed(() => formGroup?.error?.value ? "red" : props.color);
107
+ setup(props, { emit }) {
108
+ const { ui, attrs } = useUI("checkbox", toRef(props, "ui"), config, toRef(props, "class"));
109
+ const { emitFormChange, color, name, inputId } = useFormGroup(props);
101
110
  const toggle = computed({
102
111
  get() {
103
112
  return props.modelValue;
@@ -110,7 +119,6 @@ export default defineComponent({
110
119
  emit("change", event);
111
120
  emitFormChange();
112
121
  };
113
- const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
114
122
  const inputClass = computed(() => {
115
123
  return twMerge(twJoin(
116
124
  ui.value.base,
@@ -122,11 +130,13 @@ export default defineComponent({
122
130
  ), props.inputClass);
123
131
  });
124
132
  return {
125
- attrs: omit(attrs, ["class"]),
126
133
  // eslint-disable-next-line vue/no-dupe-keys
127
134
  ui,
135
+ attrs,
128
136
  toggle,
129
- wrapperClass,
137
+ inputId,
138
+ // eslint-disable-next-line vue/no-dupe-keys
139
+ name,
130
140
  // eslint-disable-next-line vue/no-dupe-keys
131
141
  inputClass,
132
142
  onChange
@@ -1,8 +1,11 @@
1
- /// <reference types="lodash" />
2
1
  import type { PropType } from 'vue';
3
2
  declare const _default: import("vue").DefineComponent<{
3
+ id: {
4
+ type: StringConstructor;
5
+ default: () => string;
6
+ };
4
7
  value: {
5
- type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
8
+ type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[];
6
9
  default: null;
7
10
  };
8
11
  modelValue: {
@@ -38,7 +41,7 @@ declare const _default: import("vue").DefineComponent<{
38
41
  default: boolean;
39
42
  };
40
43
  color: {
41
- type: StringConstructor;
44
+ type: PropType<any>;
42
45
  default: () => any;
43
46
  validator(value: string): any;
44
47
  };
@@ -46,22 +49,31 @@ declare const _default: import("vue").DefineComponent<{
46
49
  type: StringConstructor;
47
50
  default: string;
48
51
  };
49
- ui: {
52
+ class: {
50
53
  type: PropType<any>;
51
- default: () => {};
54
+ default: undefined;
55
+ };
56
+ ui: {
57
+ type: PropType<Partial<any>>;
58
+ default: undefined;
52
59
  };
53
60
  }, {
54
- attrs: import("lodash").Omit<{
55
- [x: string]: unknown;
56
- }, "class">;
57
61
  ui: import("vue").ComputedRef<any>;
62
+ attrs: import("vue").ComputedRef<Pick<{
63
+ [x: string]: unknown;
64
+ }, string>>;
58
65
  toggle: import("vue").WritableComputedRef<boolean | unknown[]>;
59
- wrapperClass: import("vue").ComputedRef<string>;
66
+ inputId: import("vue").Ref<string | undefined>;
67
+ name: import("vue").ComputedRef<string | undefined>;
60
68
  inputClass: import("vue").ComputedRef<string>;
61
69
  onChange: (event: Event) => void;
62
70
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
71
+ id: {
72
+ type: StringConstructor;
73
+ default: () => string;
74
+ };
63
75
  value: {
64
- type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
76
+ type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[];
65
77
  default: null;
66
78
  };
67
79
  modelValue: {
@@ -97,7 +109,7 @@ declare const _default: import("vue").DefineComponent<{
97
109
  default: boolean;
98
110
  };
99
111
  color: {
100
- type: StringConstructor;
112
+ type: PropType<any>;
101
113
  default: () => any;
102
114
  validator(value: string): any;
103
115
  };
@@ -105,17 +117,23 @@ declare const _default: import("vue").DefineComponent<{
105
117
  type: StringConstructor;
106
118
  default: string;
107
119
  };
108
- ui: {
120
+ class: {
109
121
  type: PropType<any>;
110
- default: () => {};
122
+ default: undefined;
123
+ };
124
+ ui: {
125
+ type: PropType<Partial<any>>;
126
+ default: undefined;
111
127
  };
112
128
  }>> & {
113
129
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
114
130
  onChange?: ((...args: any[]) => any) | undefined;
115
131
  }, {
116
- color: string;
117
- ui: any;
132
+ id: string;
133
+ color: any;
134
+ ui: Partial<any>;
118
135
  name: string;
136
+ class: any;
119
137
  value: string | number | boolean | Record<string, any>;
120
138
  label: string;
121
139
  modelValue: boolean | unknown[];