numori-ui 0.1.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 (130) hide show
  1. package/LICENSE +651 -0
  2. package/README.md +466 -0
  3. package/dist/components/Alert.js +137 -0
  4. package/dist/components/Alert.js.map +1 -0
  5. package/dist/components/Avatar.js +133 -0
  6. package/dist/components/Avatar.js.map +1 -0
  7. package/dist/components/Badge.js +93 -0
  8. package/dist/components/Badge.js.map +1 -0
  9. package/dist/components/Button.js +428 -0
  10. package/dist/components/Button.js.map +1 -0
  11. package/dist/components/ButtonsGroup.js +153 -0
  12. package/dist/components/ButtonsGroup.js.map +1 -0
  13. package/dist/components/Checkbox.js +93 -0
  14. package/dist/components/Checkbox.js.map +1 -0
  15. package/dist/components/Divider.js +79 -0
  16. package/dist/components/Divider.js.map +1 -0
  17. package/dist/components/Dropdown.js +166 -0
  18. package/dist/components/Dropdown.js.map +1 -0
  19. package/dist/components/DropdownItem.js +106 -0
  20. package/dist/components/DropdownItem.js.map +1 -0
  21. package/dist/components/DropdownRow.js +41 -0
  22. package/dist/components/DropdownRow.js.map +1 -0
  23. package/dist/components/DropdownSubmenu.js +142 -0
  24. package/dist/components/DropdownSubmenu.js.map +1 -0
  25. package/dist/components/FileInput.js +122 -0
  26. package/dist/components/FileInput.js.map +1 -0
  27. package/dist/components/FormField.js +112 -0
  28. package/dist/components/FormField.js.map +1 -0
  29. package/dist/components/Input.js +603 -0
  30. package/dist/components/Input.js.map +1 -0
  31. package/dist/components/Kbd.js +35 -0
  32. package/dist/components/Kbd.js.map +1 -0
  33. package/dist/components/ListMenu.js +143 -0
  34. package/dist/components/ListMenu.js.map +1 -0
  35. package/dist/components/ListMenuItem.js +189 -0
  36. package/dist/components/ListMenuItem.js.map +1 -0
  37. package/dist/components/Modal.js +206 -0
  38. package/dist/components/Modal.js.map +1 -0
  39. package/dist/components/Numpad.js +123 -0
  40. package/dist/components/Numpad.js.map +1 -0
  41. package/dist/components/Popup.js +170 -0
  42. package/dist/components/Popup.js.map +1 -0
  43. package/dist/components/ProgressBar.js +118 -0
  44. package/dist/components/ProgressBar.js.map +1 -0
  45. package/dist/components/Prompt.js +201 -0
  46. package/dist/components/Prompt.js.map +1 -0
  47. package/dist/components/Radio.js +81 -0
  48. package/dist/components/Radio.js.map +1 -0
  49. package/dist/components/Select.js +441 -0
  50. package/dist/components/Select.js.map +1 -0
  51. package/dist/components/Slider.js +116 -0
  52. package/dist/components/Slider.js.map +1 -0
  53. package/dist/components/Stepper.js +65 -0
  54. package/dist/components/Stepper.js.map +1 -0
  55. package/dist/components/Toggle.js +133 -0
  56. package/dist/components/Toggle.js.map +1 -0
  57. package/dist/components/Tooltip.js +120 -0
  58. package/dist/components/Tooltip.js.map +1 -0
  59. package/dist/components/index.js +81 -0
  60. package/dist/components/index.js.map +1 -0
  61. package/dist/composables/onClickOutside.js +51 -0
  62. package/dist/composables/onClickOutside.js.map +1 -0
  63. package/dist/composables/useBackButton.js +98 -0
  64. package/dist/composables/useBackButton.js.map +1 -0
  65. package/dist/composables/useEventListener.js +63 -0
  66. package/dist/composables/useEventListener.js.map +1 -0
  67. package/dist/icons/Icon.js +120 -0
  68. package/dist/icons/Icon.js.map +1 -0
  69. package/dist/icons/mdi.js +69 -0
  70. package/dist/icons/mdi.js.map +1 -0
  71. package/dist/icons/registry.js +63 -0
  72. package/dist/icons/registry.js.map +1 -0
  73. package/dist/icons/resolver.js +49 -0
  74. package/dist/icons/resolver.js.map +1 -0
  75. package/dist/index.d.ts +108 -0
  76. package/dist/index.js +157 -0
  77. package/dist/index.js.map +1 -0
  78. package/dist/manifest.js +89 -0
  79. package/dist/manifest.js.map +1 -0
  80. package/dist/numori-ui.css +184 -0
  81. package/dist/nuxt.d.ts +35 -0
  82. package/dist/nuxt.mjs +243 -0
  83. package/dist/nuxt.mjs.map +1 -0
  84. package/dist/vite.d.ts +29 -0
  85. package/dist/vite.mjs +187 -0
  86. package/dist/vite.mjs.map +1 -0
  87. package/package.json +138 -0
  88. package/src/components/Alert.vue +127 -0
  89. package/src/components/Avatar.vue +100 -0
  90. package/src/components/Badge.vue +77 -0
  91. package/src/components/Button.vue +419 -0
  92. package/src/components/ButtonsGroup.vue +140 -0
  93. package/src/components/Checkbox.vue +81 -0
  94. package/src/components/Divider.vue +64 -0
  95. package/src/components/Dropdown.vue +150 -0
  96. package/src/components/DropdownItem.vue +78 -0
  97. package/src/components/DropdownRow.vue +37 -0
  98. package/src/components/DropdownSubmenu.vue +127 -0
  99. package/src/components/FileInput.vue +107 -0
  100. package/src/components/FormField.vue +86 -0
  101. package/src/components/Input.vue +619 -0
  102. package/src/components/Kbd.vue +30 -0
  103. package/src/components/ListMenu.vue +127 -0
  104. package/src/components/ListMenuItem.vue +171 -0
  105. package/src/components/Modal.vue +209 -0
  106. package/src/components/Numpad.vue +118 -0
  107. package/src/components/Popup.vue +156 -0
  108. package/src/components/ProgressBar.vue +107 -0
  109. package/src/components/Prompt.vue +161 -0
  110. package/src/components/Radio.vue +50 -0
  111. package/src/components/Select.vue +470 -0
  112. package/src/components/Slider.vue +93 -0
  113. package/src/components/Stepper.vue +53 -0
  114. package/src/components/Toggle.vue +125 -0
  115. package/src/components/Tooltip.vue +113 -0
  116. package/src/components/index.js +109 -0
  117. package/src/composables/onClickOutside.js +61 -0
  118. package/src/composables/useBackButton.js +98 -0
  119. package/src/composables/useEventListener.js +65 -0
  120. package/src/icons/Icon.vue +139 -0
  121. package/src/icons/mdi.js +67 -0
  122. package/src/icons/registry.js +64 -0
  123. package/src/icons/resolver.js +48 -0
  124. package/src/index.js +167 -0
  125. package/src/manifest.js +86 -0
  126. package/src/nuxt.js +315 -0
  127. package/src/style.css +20 -0
  128. package/src/tailwind.css +18 -0
  129. package/src/theme.css +172 -0
  130. package/src/vite.js +235 -0
@@ -0,0 +1,419 @@
1
+ <template>
2
+ <!-- Dynamic root element — renders as button, anchor, or any tag via :is -->
3
+ <component
4
+ :is="tag"
5
+ :type="isButton ? nativeType : undefined"
6
+ :disabled="isButton ? disabled || loading : undefined"
7
+ :href="tag === 'a' ? href : undefined"
8
+ :class="mergedClasses"
9
+ :title="title"
10
+ :aria-label="ariaLabel"
11
+ :aria-checked="ariaChecked"
12
+ :role="role"
13
+ :tabindex="tabindex"
14
+ v-bind="restAttrs"
15
+ >
16
+ <!-- Loading state: spinner replaces slot content (default) -->
17
+ <template v-if="loading && loadingStyle === 'spinner'">
18
+ <UiIcon :name="spinnerIcon" class="animate-spin" :class="spinnerSizeClass" />
19
+ </template>
20
+ <!-- Default slot: button label, icons, or any child content -->
21
+ <slot v-else :spinning="loading && loadingStyle === 'icon'" />
22
+ </component>
23
+ </template>
24
+
25
+ <script setup>
26
+ /**
27
+ * UiButton — Versatile button component with multiple variants, colors, sizes, and shapes.
28
+ *
29
+ * Supports rendering as any HTML element (button, anchor, div), eight visual variants
30
+ * (solid, outline, ghost, dashed, text, link, menu-item, list-item), six color themes,
31
+ * five sizes, and five shape options. Includes loading state with a configurable spinner,
32
+ * icon-only mode, block/full-width layout, and full accessibility attribute support.
33
+ * External Tailwind classes are merged via `tailwind-merge` so they can override internals.
34
+ *
35
+ * @example Basic solid button
36
+ * <UiButton @click="save">Save</UiButton>
37
+ *
38
+ * @example Ghost icon button
39
+ * <UiButton variant="ghost" color="gray" icon-only>
40
+ * <UiIcon name="mdi:close" class="w-5 h-5" />
41
+ * </UiButton>
42
+ *
43
+ * @example Outline danger button with loading
44
+ * <UiButton variant="outline" color="red" :loading="isSaving">Delete</UiButton>
45
+ *
46
+ * @example Menu item in a dropdown
47
+ * <UiButton variant="menu-item" color="red">
48
+ * <UiIcon name="mdi:trash-can-outline" class="w-4 h-4" /> Delete
49
+ * </UiButton>
50
+ *
51
+ * @example Anchor link
52
+ * <UiButton tag="a" variant="link" href="/docs">Read docs</UiButton>
53
+ *
54
+ * @slot default — Button content (label text, icons, or any child elements)
55
+ */
56
+ import { computed, useAttrs } from 'vue'
57
+ import UiIcon from '../icons/Icon.vue'
58
+ import { twMerge } from 'tailwind-merge'
59
+ const props = defineProps({
60
+ /**
61
+ * HTML element tag to render.
62
+ * @type {string}
63
+ * @default 'button'
64
+ * @values 'button' | 'a' | 'div' | any valid HTML tag
65
+ */
66
+ tag: { type: String, default: 'button' },
67
+
68
+ /**
69
+ * Native button `type` attribute (only applied when tag is 'button').
70
+ * @type {string}
71
+ * @default 'button'
72
+ * @values 'button' | 'submit' | 'reset'
73
+ */
74
+ nativeType: { type: String, default: 'button' },
75
+
76
+ /**
77
+ * Visual variant controlling background, border, and hover styles.
78
+ * - 'solid' — filled background with shadow
79
+ * - 'outline' — transparent with colored border
80
+ * - 'ghost' — transparent, colored on hover
81
+ * - 'dashed' — dashed border, transparent background
82
+ * - 'text' — plain text, underline on hover
83
+ * - 'link' — inline link style, no padding
84
+ * - 'menu-item' — full-width row for dropdown menus
85
+ * - 'list-item' — full-width row for settings lists
86
+ * @type {string}
87
+ * @default 'solid'
88
+ */
89
+ variant: { type: String, default: 'solid' },
90
+
91
+ /**
92
+ * Color theme key mapped to Tailwind color scales.
93
+ * @type {string}
94
+ * @default 'primary'
95
+ * @values 'primary' | 'gray' | 'red' | 'green' | 'amber' | 'white'
96
+ */
97
+ color: { type: String, default: 'primary' },
98
+
99
+ /**
100
+ * Button size controlling padding, font size, and gap.
101
+ * @type {string}
102
+ * @default 'md'
103
+ * @values 'xs' | 'sm' | 'md' | 'lg' | 'xl'
104
+ */
105
+ size: { type: String, default: 'md' },
106
+
107
+ /**
108
+ * Border-radius shape of the button.
109
+ * @type {string}
110
+ * @default 'round'
111
+ * @values 'round' (rounded-lg) | 'pill' (rounded-full) | 'square' (rounded-none) | 'circle' (rounded-full) | 'none'
112
+ */
113
+ shape: { type: String, default: 'round' },
114
+
115
+ /**
116
+ * Disabled state — visually dims the button and prevents interaction.
117
+ * @type {boolean}
118
+ * @default false
119
+ */
120
+ disabled: { type: Boolean, default: false },
121
+
122
+ /**
123
+ * Loading state — replaces slot content with a spinner and disables the button.
124
+ * @type {boolean}
125
+ * @default false
126
+ */
127
+ loading: { type: Boolean, default: false },
128
+
129
+ /**
130
+ * Loading visual style.
131
+ * - 'spinner': replaces slot content with a spinner icon (default)
132
+ * - 'icon': keeps slot content visible, exposes `spinning` slot prop for the icon
133
+ * @type {string}
134
+ * @default 'spinner'
135
+ */
136
+ loadingStyle: { type: String, default: 'spinner' },
137
+
138
+ /**
139
+ * MDI icon name for the loading spinner.
140
+ * @type {string}
141
+ * @default 'mdi:loading'
142
+ */
143
+ spinner: { type: String, default: 'mdi:loading' },
144
+
145
+ /**
146
+ * Block mode — makes the button full-width (w-full).
147
+ * @type {boolean}
148
+ * @default false
149
+ */
150
+ block: { type: Boolean, default: false },
151
+
152
+ /**
153
+ * Icon-only mode — uses equal padding on all sides for a square/circle button.
154
+ * @type {boolean}
155
+ * @default false
156
+ */
157
+ iconOnly: { type: Boolean, default: false },
158
+
159
+ /**
160
+ * URL for anchor tags (only applied when tag is 'a').
161
+ * @type {string}
162
+ * @default undefined
163
+ */
164
+ href: { type: String, default: undefined },
165
+
166
+ /**
167
+ * Native `title` attribute for hover tooltip.
168
+ * @type {string}
169
+ * @default undefined
170
+ */
171
+ title: { type: String, default: undefined },
172
+
173
+ /**
174
+ * Accessible label for screen readers.
175
+ * @type {string}
176
+ * @default undefined
177
+ */
178
+ ariaLabel: { type: String, default: undefined },
179
+
180
+ /**
181
+ * ARIA checked state for toggle-style buttons.
182
+ * @type {string | boolean}
183
+ * @default undefined
184
+ */
185
+ ariaChecked: { type: [String, Boolean], default: undefined },
186
+
187
+ /**
188
+ * ARIA role override (e.g. 'switch', 'tab').
189
+ * @type {string}
190
+ * @default undefined
191
+ */
192
+ role: { type: String, default: undefined },
193
+
194
+ /**
195
+ * Tab index for keyboard navigation order.
196
+ * @type {string | number}
197
+ * @default undefined
198
+ */
199
+ tabindex: { type: [String, Number], default: undefined },
200
+ })
201
+
202
+ defineOptions({ inheritAttrs: false })
203
+
204
+ // Determine element type and variant category for conditional attribute binding
205
+ const isButton = computed(() => props.tag === 'button')
206
+ const isMenuItem = computed(() => props.variant === 'menu-item')
207
+ const isListItem = computed(() => props.variant === 'list-item')
208
+ // Menu-item and list-item variants share full-width, left-aligned layout behavior
209
+ const isInlineVariant = computed(() => isMenuItem.value || isListItem.value)
210
+
211
+ const spinnerIcon = computed(() => props.spinner)
212
+
213
+ const spinnerSizeClass = computed(() => {
214
+ const map = { xs: 'w-3 h-3', sm: 'w-3.5 h-3.5', md: 'w-4 h-4', lg: 'w-5 h-5', xl: 'w-6 h-6' }
215
+ return map[props.size] || map.md
216
+ })
217
+
218
+ // ── Size classes ──────────────────────────────────────────
219
+ const sizeClasses = computed(() => {
220
+ if (isMenuItem.value) return 'px-3 py-1.5 text-sm gap-2'
221
+ if (isListItem.value) return 'px-3.5 py-2.5 text-sm gap-3'
222
+ if (props.iconOnly) {
223
+ const map = { xs: 'p-1', sm: 'p-1.5', md: 'p-2', lg: 'p-2.5', xl: 'p-3' }
224
+ return map[props.size] || map.md
225
+ }
226
+ const map = {
227
+ xs: 'px-2 py-1 text-xs gap-1',
228
+ sm: 'px-2.5 py-1.5 text-xs gap-1.5',
229
+ md: 'px-4 py-2 text-sm gap-2',
230
+ lg: 'px-5 py-2.5 text-sm gap-2',
231
+ xl: 'px-6 py-3 text-base gap-2.5',
232
+ }
233
+ return map[props.size] || map.md
234
+ })
235
+
236
+ // ── Shape classes ─────────────────────────────────────────
237
+ const shapeClasses = computed(() => {
238
+ if (isInlineVariant.value) return ''
239
+ const map = {
240
+ round: 'rounded-lg',
241
+ pill: 'rounded-full',
242
+ square: 'rounded-none',
243
+ circle: 'rounded-full',
244
+ none: '',
245
+ }
246
+ return map[props.shape] || map.round
247
+ })
248
+
249
+ // ── Colour × Variant matrix ──────────────────────────────
250
+ // Each variant defines its own color map. Menu-item and list-item default
251
+ // to gray when color is 'primary' since they sit inside neutral containers.
252
+ const colorVariantClasses = computed(() => {
253
+ const v = props.variant
254
+ const c = props.color
255
+
256
+ // Menu item — no bg, no rounding, consistent hover. Defaults to gray text.
257
+ if (v === 'menu-item') {
258
+ const effectiveColor = c === 'primary' ? 'gray' : c
259
+ const map = {
260
+ gray: 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700',
261
+ red: 'text-red-600 dark:text-red-400 hover:bg-red-100 dark:hover:bg-red-900/30',
262
+ green: 'text-success-600 dark:text-success-400 hover:bg-gray-100 dark:hover:bg-gray-700',
263
+ amber: 'text-amber-600 dark:text-amber-400 hover:bg-gray-100 dark:hover:bg-gray-700',
264
+ white: 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700',
265
+ }
266
+ return map[effectiveColor] || map.gray
267
+ }
268
+
269
+ // List item — settings list rows. Defaults to gray text.
270
+ if (v === 'list-item') {
271
+ const effectiveColor = c === 'primary' ? 'gray' : c
272
+ const map = {
273
+ gray: 'text-gray-700 dark:text-gray-300 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',
274
+ red: 'text-red-600 dark:text-red-400 hover:bg-red-200/50 dark:hover:bg-red-800/30',
275
+ green:
276
+ 'text-success-600 dark:text-success-400 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',
277
+ amber: 'text-amber-600 dark:text-amber-400 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',
278
+ white: 'text-gray-700 dark:text-gray-300 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',
279
+ }
280
+ return map[effectiveColor] || map.gray
281
+ }
282
+
283
+ // Solid
284
+ if (v === 'solid') {
285
+ const map = {
286
+ primary: 'bg-primary-600 hover:bg-primary-700 text-white shadow-sm hover:shadow-md',
287
+ gray: 'bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300',
288
+ red: 'bg-red-600 hover:bg-red-700 text-white shadow-sm hover:shadow-md',
289
+ green: 'bg-success-600 hover:bg-success-700 text-white shadow-sm hover:shadow-md',
290
+ amber: 'bg-amber-600 hover:bg-amber-700 text-white shadow-sm hover:shadow-md',
291
+ white:
292
+ 'bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 text-gray-900 dark:text-gray-200 shadow-sm',
293
+ }
294
+ return map[c] || map.primary
295
+ }
296
+
297
+ // Outline
298
+ if (v === 'outline') {
299
+ const map = {
300
+ primary:
301
+ 'border border-primary-500 text-primary-600 dark:text-primary-400 bg-transparent hover:bg-primary-50 dark:hover:bg-primary-900/20',
302
+ gray: 'border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800',
303
+ red: 'border border-red-300 dark:border-red-700 text-red-600 dark:text-red-400 bg-transparent hover:bg-red-50 dark:hover:bg-red-900/20',
304
+ green:
305
+ 'border border-success-300 dark:border-success-700 text-success-600 dark:text-success-400 bg-transparent hover:bg-success-50 dark:hover:bg-success-900/20',
306
+ amber:
307
+ 'border border-amber-300 dark:border-amber-700 text-amber-600 dark:text-amber-400 bg-transparent hover:bg-amber-50 dark:hover:bg-amber-900/20',
308
+ white:
309
+ 'border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700',
310
+ }
311
+ return map[c] || map.primary
312
+ }
313
+
314
+ // Dashed
315
+ if (v === 'dashed') {
316
+ const map = {
317
+ primary:
318
+ 'border border-dashed border-primary-400 dark:border-primary-600 text-primary-600 dark:text-primary-400 bg-transparent hover:bg-primary-50 dark:hover:bg-primary-900/20',
319
+ gray: 'border border-dashed border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800',
320
+ red: 'border border-dashed border-red-300 dark:border-red-700 text-red-600 dark:text-red-400 bg-transparent hover:bg-red-50 dark:hover:bg-red-900/20',
321
+ green:
322
+ 'border border-dashed border-success-300 dark:border-success-700 text-success-600 dark:text-success-400 bg-transparent hover:bg-success-50 dark:hover:bg-success-900/20',
323
+ amber:
324
+ 'border border-dashed border-amber-300 dark:border-amber-700 text-amber-600 dark:text-amber-400 bg-transparent hover:bg-amber-50 dark:hover:bg-amber-900/20',
325
+ white:
326
+ 'border border-dashed border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-700',
327
+ }
328
+ return map[c] || map.primary
329
+ }
330
+
331
+ // Ghost
332
+ if (v === 'ghost') {
333
+ const map = {
334
+ primary:
335
+ 'text-primary-600 dark:text-primary-400 bg-transparent hover:bg-primary-50 dark:hover:bg-primary-900/20',
336
+ gray: 'text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800',
337
+ red: 'text-red-600 dark:text-red-400 bg-transparent hover:bg-red-50 dark:hover:bg-red-900/20',
338
+ green:
339
+ 'text-success-600 dark:text-success-400 bg-transparent hover:bg-success-50 dark:hover:bg-success-900/20',
340
+ amber:
341
+ 'text-amber-600 dark:text-amber-400 bg-transparent hover:bg-amber-50 dark:hover:bg-amber-900/20',
342
+ white:
343
+ 'text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-700',
344
+ }
345
+ return map[c] || map.primary
346
+ }
347
+
348
+ // Text
349
+ if (v === 'text') {
350
+ const map = {
351
+ primary: 'text-primary-600 dark:text-primary-400 bg-transparent hover:underline',
352
+ gray: 'text-gray-600 dark:text-gray-400 bg-transparent hover:underline',
353
+ red: 'text-red-600 dark:text-red-400 bg-transparent hover:underline',
354
+ green: 'text-success-600 dark:text-success-400 bg-transparent hover:underline',
355
+ amber: 'text-amber-600 dark:text-amber-400 bg-transparent hover:underline',
356
+ white: 'text-gray-700 dark:text-gray-300 bg-transparent hover:underline',
357
+ }
358
+ return map[c] || map.primary
359
+ }
360
+
361
+ // Link
362
+ if (v === 'link') {
363
+ const map = {
364
+ primary: 'text-primary-600 dark:text-primary-400 hover:underline p-0',
365
+ gray: 'text-gray-500 dark:text-gray-400 hover:underline p-0',
366
+ red: 'text-red-600 dark:text-red-400 hover:underline p-0',
367
+ green: 'text-success-600 dark:text-success-400 hover:underline p-0',
368
+ amber: 'text-amber-600 dark:text-amber-400 hover:underline p-0',
369
+ white: 'text-gray-700 dark:text-gray-300 hover:underline p-0',
370
+ }
371
+ return map[c] || map.primary
372
+ }
373
+
374
+ return ''
375
+ })
376
+
377
+ // ── Disabled / loading classes ────────────────────────────
378
+ const stateClasses = computed(() => {
379
+ if (props.disabled || props.loading) {
380
+ return 'opacity-50 cursor-not-allowed pointer-events-none'
381
+ }
382
+ return 'cursor-pointer'
383
+ })
384
+
385
+ // ── Merge with external classes (external wins via twMerge) ──
386
+ const attrs = useAttrs()
387
+
388
+ const restAttrs = computed(() => {
389
+ const { class: _, ...rest } = attrs
390
+ return rest
391
+ })
392
+
393
+ const mergedClasses = computed(() => {
394
+ const externalClass = attrs.class || ''
395
+ return twMerge(internalClasses.value, externalClass)
396
+ })
397
+
398
+ // ── Assembled internal classes ────────────────────────────
399
+ const internalClasses = computed(() => {
400
+ const base = 'inline-flex items-center transition-colors select-none'
401
+ const justify = isInlineVariant.value ? '' : 'justify-center'
402
+ const blockClass = props.block || isInlineVariant.value ? 'w-full' : ''
403
+ const weight = ['ghost', 'text', 'link', 'menu-item', 'list-item'].includes(props.variant)
404
+ ? ''
405
+ : 'font-medium'
406
+ return [
407
+ base,
408
+ justify,
409
+ weight,
410
+ sizeClasses.value,
411
+ shapeClasses.value,
412
+ colorVariantClasses.value,
413
+ stateClasses.value,
414
+ blockClass,
415
+ ]
416
+ .filter(Boolean)
417
+ .join(' ')
418
+ })
419
+ </script>
@@ -0,0 +1,140 @@
1
+ <template>
2
+ <!-- Segmented button group rendered as a flex row with role="group" -->
3
+ <div :class="[wrapperClass, containerClass]" role="group">
4
+ <UiButton
5
+ v-for="(opt, idx) in options"
6
+ :key="opt.value"
7
+ variant="ghost"
8
+ :icon-only="!opt.label"
9
+ :size="buttonSize"
10
+ :class="[
11
+ roundingClass(idx),
12
+ modelValue === opt.value ? activeClass : inactiveClass,
13
+ opt.label ? 'flex-1' : '',
14
+ ]"
15
+ :title="opt.title || opt.label || ''"
16
+ @click="$emit('update:modelValue', opt.value)"
17
+ >
18
+ <UiIcon v-if="opt.icon" :name="opt.icon" :class="iconClass" class="block" />
19
+ <span v-if="opt.label">{{ opt.label }}</span>
20
+ </UiButton>
21
+ </div>
22
+ </template>
23
+
24
+ <script setup>
25
+ /**
26
+ * UiButtonsGroup — Segmented toggle button group for single-select options.
27
+ *
28
+ * Renders a row of UiButton elements styled as a connected group (toolbar or tabs).
29
+ * Only one option can be active at a time (radio-like behavior via v-model).
30
+ * Supports icon-only toolbar mode and text-based tab mode with automatic sizing,
31
+ * rounding, and active/inactive styling.
32
+ *
33
+ * @example Toolbar with icons
34
+ * <UiButtonsGroup v-model="view" :options="[
35
+ * { value: 'grid', icon: 'mdi:view-grid' },
36
+ * { value: 'list', icon: 'mdi:view-list' },
37
+ * ]" />
38
+ *
39
+ * @example Tab-style text group
40
+ * <UiButtonsGroup v-model="tab" variant="tabs" :options="[
41
+ * { value: 'all', label: 'All' },
42
+ * { value: 'active', label: 'Active' },
43
+ * { value: 'archived', label: 'Archived' },
44
+ * ]" />
45
+ *
46
+ * @emits {string | number | boolean} update:modelValue — Emitted when an option is selected
47
+ *
48
+ * @see UiButton — Underlying button component used for each option
49
+ */
50
+ import { computed } from 'vue'
51
+ import UiButton from './Button.vue'
52
+ import UiIcon from '../icons/Icon.vue'
53
+ const props = defineProps({
54
+ /**
55
+ * Currently selected option value (v-model).
56
+ * @type {string | number | boolean}
57
+ * @default ''
58
+ */
59
+ modelValue: { type: [String, Number, Boolean], default: '' },
60
+
61
+ /**
62
+ * Array of option objects: `{ value, icon?, label?, title? }`.
63
+ * At least `value` is required. Provide `icon` for toolbar mode, `label` for tabs.
64
+ * @type {Array<{ value: string|number, icon?: string, label?: string, title?: string }>}
65
+ * @required
66
+ */
67
+ options: { type: Array, required: true },
68
+
69
+ /**
70
+ * Visual style of the group.
71
+ * - 'toolbar': compact icon toggles with gray background
72
+ * - 'tabs': text-based tabs with lighter background and smaller buttons
73
+ * @type {string}
74
+ * @default 'toolbar'
75
+ * @values 'toolbar' | 'tabs'
76
+ */
77
+ variant: { type: String, default: 'toolbar' },
78
+
79
+ /**
80
+ * Icon size class applied to icons in toolbar mode.
81
+ * @type {string}
82
+ * @default 'w-5 h-5'
83
+ */
84
+ iconClass: { type: String, default: 'w-5 h-5' },
85
+
86
+ /**
87
+ * Button size for toolbar variant (tabs always use 'xs').
88
+ * @type {string}
89
+ * @default 'md'
90
+ * @values 'xs' | 'sm' | 'md'
91
+ */
92
+ size: { type: String, default: 'md' },
93
+
94
+ /**
95
+ * Full-width mode. Defaults to true for tabs, false for toolbar.
96
+ * @type {boolean}
97
+ * @default undefined (auto-detected from variant)
98
+ */
99
+ block: { type: Boolean, default: undefined },
100
+ })
101
+
102
+ defineEmits(['update:modelValue'])
103
+
104
+ // Block defaults to true for tabs (full-width) and false for toolbar (inline)
105
+ const isBlock = computed(() => props.block ?? props.variant === 'tabs')
106
+
107
+ const wrapperClass = computed(() =>
108
+ isBlock.value ? 'flex items-center rounded-lg' : 'inline-flex items-center rounded-lg',
109
+ )
110
+
111
+ const containerClass = computed(() =>
112
+ props.variant === 'tabs'
113
+ ? 'bg-gray-100 dark:bg-gray-800 p-0.5'
114
+ : 'bg-gray-200/50 dark:bg-gray-800',
115
+ )
116
+
117
+ const buttonSize = computed(() => (props.variant === 'tabs' ? 'xs' : props.size))
118
+
119
+ // Apply rounding only to first/last buttons; middle buttons get rounded-none
120
+ const roundingClass = (idx) => {
121
+ const last = props.options.length - 1
122
+ const radius = props.variant === 'tabs' ? 'md' : 'lg'
123
+ if (props.options.length === 1) return `rounded-${radius}`
124
+ if (idx === 0) return `rounded-l-${radius} rounded-r-none`
125
+ if (idx === last) return `rounded-r-${radius} rounded-l-none`
126
+ return 'rounded-none'
127
+ }
128
+
129
+ const activeClass = computed(() =>
130
+ props.variant === 'tabs'
131
+ ? 'bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-200 shadow-sm hover:bg-white dark:hover:bg-gray-700'
132
+ : 'bg-white dark:bg-gray-700 text-primary-600 dark:text-primary-400 shadow-sm hover:bg-white dark:hover:bg-gray-700',
133
+ )
134
+
135
+ const inactiveClass = computed(() =>
136
+ props.variant === 'tabs'
137
+ ? 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200/50 dark:hover:bg-gray-700/50'
138
+ : 'text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-300/40 dark:hover:bg-gray-700/50',
139
+ )
140
+ </script>
@@ -0,0 +1,81 @@
1
+ <template>
2
+ <input
3
+ type="checkbox"
4
+ :checked="modelValue ?? checked"
5
+ :disabled="disabled"
6
+ class="rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500"
7
+ :class="sizeClass"
8
+ @change="onChange"
9
+ />
10
+ </template>
11
+
12
+ <script setup>
13
+ /**
14
+ * UiCheckbox — Simple styled checkbox input with configurable size.
15
+ *
16
+ * Wraps a native `<input type="checkbox">` with consistent Tailwind styling,
17
+ * primary color accent, and focus ring. Supports both v-model (`modelValue`)
18
+ * and uncontrolled (`checked`) usage patterns.
19
+ *
20
+ * @example Basic v-model checkbox
21
+ * <UiCheckbox v-model="agreed" />
22
+ *
23
+ * @example Small disabled checkbox
24
+ * <UiCheckbox v-model="locked" size="sm" disabled />
25
+ *
26
+ * @example Uncontrolled with checked prop
27
+ * <UiCheckbox :checked="true" @change="handleChange" />
28
+ *
29
+ * @emits {boolean} update:modelValue — Emitted when the checked state changes (v-model)
30
+ * @emits {Event} change — Emitted with the native change event
31
+ */
32
+ import { computed } from 'vue'
33
+ const props = defineProps({
34
+ /**
35
+ * Controlled checked state (v-model). Takes priority over `checked` when defined.
36
+ * @type {boolean}
37
+ * @default undefined
38
+ */
39
+ modelValue: { type: Boolean, default: undefined },
40
+
41
+ /**
42
+ * Uncontrolled initial checked state (used when modelValue is undefined).
43
+ * @type {boolean}
44
+ * @default false
45
+ */
46
+ checked: { type: Boolean, default: false },
47
+
48
+ /**
49
+ * Disabled state — dims the checkbox and prevents interaction.
50
+ * @type {boolean}
51
+ * @default false
52
+ */
53
+ disabled: { type: Boolean, default: false },
54
+
55
+ /**
56
+ * Checkbox size controlling width and height.
57
+ * @type {string}
58
+ * @default 'md'
59
+ * @values 'sm' (3.5×3.5) | 'md' (4×4) | 'lg' (5×5)
60
+ */
61
+ size: { type: String, default: 'md' },
62
+ })
63
+
64
+ const emit = defineEmits(['update:modelValue', 'change'])
65
+
66
+ const sizeClass = computed(() => {
67
+ switch (props.size) {
68
+ case 'sm':
69
+ return 'w-3.5 h-3.5'
70
+ case 'lg':
71
+ return 'w-5 h-5'
72
+ default:
73
+ return 'w-4 h-4'
74
+ }
75
+ })
76
+
77
+ function onChange(e) {
78
+ emit('update:modelValue', e.target.checked)
79
+ emit('change', e)
80
+ }
81
+ </script>