numori-ui 0.3.0 → 0.4.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 (78) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +23 -20
  3. package/dist/components/Banner.js +29 -32
  4. package/dist/components/Banner.js.map +1 -1
  5. package/dist/components/Button.js +10 -19
  6. package/dist/components/Button.js.map +1 -1
  7. package/dist/components/Card.js +15 -9
  8. package/dist/components/Card.js.map +1 -1
  9. package/dist/components/Checkbox.js +2 -7
  10. package/dist/components/Checkbox.js.map +1 -1
  11. package/dist/components/Dropdown.js +10 -3
  12. package/dist/components/Dropdown.js.map +1 -1
  13. package/dist/components/DropdownSubmenu.js +5 -3
  14. package/dist/components/DropdownSubmenu.js.map +1 -1
  15. package/dist/components/FileInput.js +12 -4
  16. package/dist/components/FileInput.js.map +1 -1
  17. package/dist/components/IconTile.js +5 -9
  18. package/dist/components/IconTile.js.map +1 -1
  19. package/dist/components/Input.js +6 -6
  20. package/dist/components/Input.js.map +1 -1
  21. package/dist/components/ListMenuItem.js +38 -31
  22. package/dist/components/ListMenuItem.js.map +1 -1
  23. package/dist/components/Numpad.js +4 -4
  24. package/dist/components/Numpad.js.map +1 -1
  25. package/dist/components/Popup.js +9 -3
  26. package/dist/components/Popup.js.map +1 -1
  27. package/dist/components/Radio.js +2 -7
  28. package/dist/components/Radio.js.map +1 -1
  29. package/dist/components/Segmented.js +100 -26
  30. package/dist/components/Segmented.js.map +1 -1
  31. package/dist/components/Select.js +6 -4
  32. package/dist/components/Select.js.map +1 -1
  33. package/dist/components/Table.js +174 -0
  34. package/dist/components/Table.js.map +1 -0
  35. package/dist/components/index.js +65 -67
  36. package/dist/components/index.js.map +1 -1
  37. package/dist/composables/useMergedClasses.js +52 -0
  38. package/dist/composables/useMergedClasses.js.map +1 -0
  39. package/dist/icons/mdi.js +1 -0
  40. package/dist/icons/mdi.js.map +1 -1
  41. package/dist/index.d.ts +1 -2
  42. package/dist/index.js +34 -35
  43. package/dist/index.js.map +1 -1
  44. package/dist/internal/controlSizes.js +21 -0
  45. package/dist/internal/controlSizes.js.map +1 -0
  46. package/dist/internal/menu.js +20 -0
  47. package/dist/internal/menu.js.map +1 -0
  48. package/dist/manifest.js +1 -2
  49. package/dist/manifest.js.map +1 -1
  50. package/package.json +2 -1
  51. package/src/components/Banner.vue +20 -9
  52. package/src/components/Button.vue +12 -19
  53. package/src/components/Card.vue +11 -12
  54. package/src/components/Checkbox.vue +2 -10
  55. package/src/components/Dropdown.vue +14 -2
  56. package/src/components/DropdownSubmenu.vue +4 -2
  57. package/src/components/FileInput.vue +19 -4
  58. package/src/components/IconTile.vue +4 -9
  59. package/src/components/Input.vue +6 -6
  60. package/src/components/ListMenuItem.vue +21 -5
  61. package/src/components/Numpad.vue +7 -4
  62. package/src/components/Popup.vue +6 -2
  63. package/src/components/Radio.vue +2 -10
  64. package/src/components/Segmented.vue +108 -38
  65. package/src/components/Select.vue +11 -2
  66. package/src/components/Table.vue +193 -0
  67. package/src/components/index.js +3 -6
  68. package/src/composables/useMergedClasses.js +49 -0
  69. package/src/icons/mdi.js +1 -0
  70. package/src/internal/controlSizes.js +17 -0
  71. package/src/internal/menu.js +16 -0
  72. package/src/manifest.js +1 -2
  73. package/dist/components/ButtonsGroup.js +0 -153
  74. package/dist/components/ButtonsGroup.js.map +0 -1
  75. package/dist/components/ComparisonTable.js +0 -152
  76. package/dist/components/ComparisonTable.js.map +0 -1
  77. package/src/components/ButtonsGroup.vue +0 -140
  78. package/src/components/ComparisonTable.vue +0 -141
@@ -14,8 +14,8 @@
14
14
  <div
15
15
  v-if="show"
16
16
  ref="panelRef"
17
- class="absolute bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1"
18
- :class="[width, panelZ]"
17
+ class="absolute py-1"
18
+ :class="[MENU_PANEL_CLASS, width, panelZ]"
19
19
  :style="positionStyle"
20
20
  >
21
21
  <slot />
@@ -48,6 +48,7 @@
48
48
  * @slot default — Popup content
49
49
  */
50
50
  import { ref, computed, watch, nextTick } from 'vue'
51
+ import { MENU_PANEL_CLASS } from '../internal/menu.js'
51
52
  const props = defineProps({
52
53
  /**
53
54
  * Controls popup visibility.
@@ -107,6 +108,9 @@ const clampedPos = ref({ left: 0, top: 0 })
107
108
  const positionStyle = computed(() => ({
108
109
  left: clampedPos.value.left + 'px',
109
110
  top: clampedPos.value.top + 'px',
111
+ // Inline (not a Tailwind class) so the popup reliably scales in from its
112
+ // top-left corner rather than drifting in from its centre.
113
+ transformOrigin: 'top left',
110
114
  }))
111
115
 
112
116
  // Clamp the panel position so it stays within the viewport (8px margin)
@@ -23,6 +23,7 @@
23
23
  * <UiRadio v-model="selected" value="b" name="choice" />
24
24
  */
25
25
  import { computed } from 'vue'
26
+ import { checkableSizeClass } from '../internal/controlSizes.js'
26
27
  const props = defineProps({
27
28
  modelValue: { type: [String, Number, Boolean], default: null },
28
29
  value: { type: [String, Number, Boolean], required: true },
@@ -33,16 +34,7 @@ const props = defineProps({
33
34
 
34
35
  const emit = defineEmits(['update:modelValue'])
35
36
 
36
- const sizeClass = computed(() => {
37
- switch (props.size) {
38
- case 'sm':
39
- return 'w-3.5 h-3.5'
40
- case 'lg':
41
- return 'w-5 h-5'
42
- default:
43
- return 'w-4 h-4'
44
- }
45
- })
37
+ const sizeClass = computed(() => checkableSizeClass(props.size))
46
38
 
47
39
  function onChange() {
48
40
  emit('update:modelValue', props.value)
@@ -2,40 +2,41 @@
2
2
  <div
3
3
  role="group"
4
4
  :aria-label="ariaLabel"
5
- class="relative inline-grid p-1"
6
- :class="[trackClass, 'border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-900']"
7
- :style="{ gridTemplateColumns: `repeat(${count}, minmax(0, 1fr))` }"
5
+ class="relative p-1"
6
+ :class="[
7
+ block ? 'grid w-full' : 'inline-grid',
8
+ radiusClass,
9
+ 'border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-900',
10
+ ]"
11
+ :style="gridStyle"
8
12
  >
9
13
  <!--
10
- A single pill slides between segments rather than each segment owning its
11
- own background, so the movement animates. Segments are equal-width, so the
12
- pill's width is one column and it translates by whole columns. `top/bottom/
13
- left` inset it inside the track's padding; `%` in translateX resolves
14
- against the pill's own (one-column) width.
14
+ A single indicator slides between segments, so changing the selection
15
+ animates in every variant. Segments are equal-width grid columns, so the
16
+ indicator is one column wide and translates by whole columns. The variant
17
+ only changes how the indicator looks (accent fill vs raised surface); the
18
+ sliding mechanism is shared.
15
19
  -->
16
20
  <span
17
21
  aria-hidden="true"
18
- class="pointer-events-none absolute bottom-1 left-1 top-1 bg-primary-500 shadow-sm transition-transform duration-300 ease-out motion-reduce:transition-none"
19
- :class="pillClass"
20
- :style="pillStyle"
22
+ class="pointer-events-none absolute bottom-1 left-1 top-1 shadow-sm transition-transform duration-300 ease-out motion-reduce:transition-none"
23
+ :class="[radiusClass, indicatorClass]"
24
+ :style="indicatorStyle"
21
25
  />
22
26
 
23
27
  <button
24
- v-for="(option, index) in options"
28
+ v-for="option in options"
25
29
  :key="option.value"
26
30
  type="button"
27
31
  :aria-pressed="isActive(option) ? 'true' : 'false'"
28
32
  :disabled="option.disabled"
33
+ :title="option.title || undefined"
29
34
  class="relative z-10 inline-flex items-center justify-center gap-1.5 font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50"
30
- :class="[
31
- buttonSizeClass,
32
- buttonShapeClass,
33
- isActive(option) ? activeTextClass : idleTextClass,
34
- ]"
35
- @click="select(option, index)"
35
+ :class="[buttonSizeClass, radiusClass, isActive(option) ? activeTextClass : idleTextClass]"
36
+ @click="select(option)"
36
37
  >
37
38
  <UiIcon v-if="option.icon" :name="option.icon" :class="iconSizeClass" />
38
- {{ option.label }}
39
+ <span v-if="option.label">{{ option.label }}</span>
39
40
  </button>
40
41
  </div>
41
42
  </template>
@@ -43,17 +44,32 @@
43
44
  <script setup>
44
45
  /**
45
46
  * UiSegmented — a segmented control: pick one of a few named options from a row
46
- * of buttons, with a pill that slides to the active choice.
47
+ * of segments, with an indicator that slides to the active choice.
47
48
  *
48
49
  * This is a set of toggle buttons (`role="group"` + `aria-pressed`), not a
49
50
  * switch, because the choice is between named options rather than on/off — "the
50
51
  * second option is off" is not something a screen reader should say. Segments
51
- * are equal width so the pill can slide by whole columns.
52
+ * are equal width so the indicator can slide by whole columns, and the slide
53
+ * animates in both variants.
54
+ *
55
+ * The `variant` values match `UiButton`'s — `solid`, `outline`, `ghost` — so a
56
+ * segmented control sits alongside buttons as part of one visual family. The
57
+ * indicator slides (and animates) to the active choice in every variant.
58
+ *
59
+ * - `variant="solid"` (default) — a filled accent indicator; the active label
60
+ * goes white. Like a solid button.
61
+ * - `variant="outline"` — a bordered accent indicator; the active label takes
62
+ * the accent colour. Like an outline button.
63
+ * - `variant="ghost"` — a soft tinted indicator; the active label takes the
64
+ * accent colour. Like a ghost button.
65
+ *
66
+ * `shape` controls the corners — `pill`, `round`, or `square` (matching
67
+ * `UiButton`) — and the indicator matches the track's radius.
52
68
  *
53
69
  * For an on/off control use `UiToggle`; for many options or a searchable list
54
70
  * use `UiSelect`.
55
71
  *
56
- * @example Billing period
72
+ * @example Billing period (solid, the default)
57
73
  * <UiSegmented
58
74
  * v-model="billing"
59
75
  * :options="[
@@ -63,9 +79,20 @@
63
79
  * aria-label="Billing period"
64
80
  * />
65
81
  *
66
- * @example With icons and a labelled-by heading
67
- * <h2 id="view-h" class="sr-only">View</h2>
68
- * <UiSegmented v-model="view" :options="views" aria-labelledby="view-h" />
82
+ * @example Icon toolbar (outline, square corners)
83
+ * <UiSegmented
84
+ * v-model="view"
85
+ * variant="outline"
86
+ * shape="square"
87
+ * :options="[
88
+ * { value: 'grid', icon: 'mdi:view-grid', title: 'Grid' },
89
+ * { value: 'list', icon: 'mdi:view-list', title: 'List' },
90
+ * ]"
91
+ * aria-label="View"
92
+ * />
93
+ *
94
+ * @example Full-width ghost tabs
95
+ * <UiSegmented v-model="tab" variant="ghost" block :options="tabs" />
69
96
  *
70
97
  * @emits {string|number} update:modelValue — the chosen option's `value`
71
98
  */
@@ -81,11 +108,25 @@ const props = defineProps({
81
108
  modelValue: { type: [String, Number], default: undefined },
82
109
 
83
110
  /**
84
- * The options. Each is `{ value, label, icon?, disabled? }`.
85
- * @type {Array<{ value: string|number, label: string, icon?: string, disabled?: boolean }>}
111
+ * The options. Each is `{ value, label?, icon?, disabled?, title? }`. Provide
112
+ * `label` for text segments, `icon` for icon-only segments, or both. `title`
113
+ * sets the native tooltip (useful for icon-only segments).
114
+ * @type {Array<{ value: string|number, label?: string, icon?: string, disabled?: boolean, title?: string }>}
86
115
  */
87
116
  options: { type: Array, required: true },
88
117
 
118
+ /**
119
+ * Active-segment appearance, mirroring the equivalent `UiButton` variants so
120
+ * the two feel like one family. The sliding indicator animates in every case.
121
+ * - 'solid' — a filled accent indicator; the active label goes white (default).
122
+ * - 'outline' — a bordered accent indicator; the active label takes the accent.
123
+ * - 'ghost' — a soft tinted indicator; the active label takes the accent.
124
+ * @type {string}
125
+ * @default 'solid'
126
+ * @values 'solid' | 'outline' | 'ghost'
127
+ */
128
+ variant: { type: String, default: 'solid' },
129
+
89
130
  /**
90
131
  * Size preset controlling padding and font size.
91
132
  * @type {string}
@@ -95,13 +136,22 @@ const props = defineProps({
95
136
  size: { type: String, default: 'md' },
96
137
 
97
138
  /**
98
- * Corner shape of the track and pill.
139
+ * Corner shape of the track, indicator, and segments. Matches `UiButton`'s
140
+ * `shape` naming.
99
141
  * @type {string}
100
142
  * @default 'pill'
101
- * @values 'pill' | 'rounded'
143
+ * @values 'pill' | 'round' | 'square'
102
144
  */
103
145
  shape: { type: String, default: 'pill' },
104
146
 
147
+ /**
148
+ * Full-width mode — the control fills its container and segments share the
149
+ * width equally.
150
+ * @type {boolean}
151
+ * @default false
152
+ */
153
+ block: { type: Boolean, default: false },
154
+
105
155
  /**
106
156
  * Accessible name for the group. Omit if you label it with an external
107
157
  * heading via `aria-labelledby` (which falls through to the root).
@@ -122,28 +172,48 @@ const activeIndex = computed(() => {
122
172
  return i === -1 ? 0 : i
123
173
  })
124
174
 
125
- function select(option, index) {
175
+ function select(option) {
126
176
  if (option.disabled) return
127
177
  emit('update:modelValue', option.value)
128
- // index is accepted for symmetry with the template call site; the value is
129
- // what identifies the option.
130
- void index
131
178
  }
132
179
 
133
- const trackClass = computed(() => (props.shape === 'rounded' ? 'rounded-xl' : 'rounded-full'))
134
- const buttonShapeClass = computed(() => (props.shape === 'rounded' ? 'rounded-lg' : 'rounded-full'))
135
- const pillClass = computed(() => (props.shape === 'rounded' ? 'rounded-lg' : 'rounded-full'))
180
+ const gridStyle = computed(() => ({
181
+ gridTemplateColumns: `repeat(${count.value}, minmax(0, 1fr))`,
182
+ }))
183
+
184
+ // ── Shape ─────────────────────────────────────────────────
185
+ // The track, the sliding indicator, and the segments all share one radius so
186
+ // the indicator's corners match the holder's rather than reading as a tighter
187
+ // (or looser) curve inside it.
188
+ const radiusClass = computed(() => {
189
+ const map = { pill: 'rounded-full', round: 'rounded-lg', square: 'rounded-none' }
190
+ return map[props.shape] ?? map.pill
191
+ })
136
192
 
193
+ // ── Size ──────────────────────────────────────────────────
137
194
  const buttonSizeClass = computed(() =>
138
195
  props.size === 'sm' ? 'px-3 py-1 text-xs' : 'px-4 py-1.5 text-sm',
139
196
  )
140
197
  const iconSizeClass = computed(() => (props.size === 'sm' ? 'size-3.5' : 'size-4'))
141
198
 
142
- const activeTextClass = 'text-white'
199
+ // ── Variant: indicator look + active label colour ─────────
200
+ // These mirror UiButton's solid / outline / ghost variants (primary colour) so
201
+ // a segmented control reads as part of the same family as the buttons near it.
202
+ const indicatorClass = computed(() => {
203
+ const map = {
204
+ solid: 'bg-primary-600 shadow-sm',
205
+ outline: 'border border-primary-500',
206
+ ghost: 'bg-primary-50 dark:bg-primary-900/20',
207
+ }
208
+ return map[props.variant] ?? map.solid
209
+ })
210
+ const activeTextClass = computed(() =>
211
+ props.variant === 'solid' ? 'text-white' : 'text-primary-600 dark:text-primary-400',
212
+ )
143
213
  const idleTextClass =
144
214
  'text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100'
145
215
 
146
- const pillStyle = computed(() => ({
216
+ const indicatorStyle = computed(() => ({
147
217
  // Track padding is p-1 (0.25rem) each side, so the usable width is
148
218
  // `100% - 0.5rem`; one segment is that divided by the option count.
149
219
  width: `calc((100% - 0.5rem) / ${count.value})`,
@@ -64,7 +64,8 @@
64
64
  <div
65
65
  v-show="isOpen"
66
66
  ref="panelRef"
67
- class="fixed z-[60] bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg overflow-hidden"
67
+ class="fixed z-[60] overflow-hidden"
68
+ :class="MENU_PANEL_CLASS"
68
69
  :style="panelStyle"
69
70
  >
70
71
  <!-- Search input for filtering options -->
@@ -172,6 +173,7 @@
172
173
  */
173
174
  import { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue'
174
175
  import UiIcon from '../icons/Icon.vue'
176
+ import { MENU_PANEL_CLASS } from '../internal/menu.js'
175
177
  const props = defineProps({
176
178
  /**
177
179
  * Currently selected value (v-model).
@@ -275,7 +277,14 @@ const reposition = () => {
275
277
  const rect = el.getBoundingClientRect()
276
278
  const spaceBelow = window.innerHeight - rect.bottom
277
279
  const openUp = spaceBelow < 260 && rect.top > spaceBelow
278
- const style = { left: `${rect.left}px`, minWidth: `${rect.width}px` }
280
+ // Inline transform-origin (not a Tailwind class) so the panel reliably scales
281
+ // in from the edge nearest the trigger — top when dropping down, bottom when
282
+ // dropping up — instead of drifting in from its centre.
283
+ const style = {
284
+ left: `${rect.left}px`,
285
+ minWidth: `${rect.width}px`,
286
+ transformOrigin: openUp ? 'bottom center' : 'top center',
287
+ }
279
288
  if (props.block) style.width = `${rect.width}px`
280
289
  if (openUp) style.bottom = `${window.innerHeight - rect.top + 4}px`
281
290
  else style.top = `${rect.bottom + 4}px`
@@ -0,0 +1,193 @@
1
+ <template>
2
+ <div class="overflow-x-auto rounded-2xl border border-gray-200 dark:border-gray-700">
3
+ <table class="w-full border-collapse text-sm">
4
+ <caption
5
+ v-if="caption || $slots.caption"
6
+ :class="
7
+ hideCaption
8
+ ? 'sr-only'
9
+ : 'caption-top px-5 py-4 text-left text-sm font-semibold text-gray-900 dark:text-gray-100'
10
+ "
11
+ >
12
+ <slot name="caption">{{ caption }}</slot>
13
+ </caption>
14
+
15
+ <thead>
16
+ <tr class="border-b border-gray-200 dark:border-gray-700">
17
+ <th
18
+ v-for="col in columns"
19
+ :key="col.key"
20
+ scope="col"
21
+ class="px-5 py-4 font-semibold"
22
+ :class="[
23
+ alignClass(col.align),
24
+ col.highlight
25
+ ? 'bg-primary-50 text-primary-800 dark:bg-primary-400/10 dark:text-primary-200'
26
+ : 'text-gray-600 dark:text-gray-300',
27
+ col.width,
28
+ ]"
29
+ >
30
+ <span v-if="col.label" :class="col.header && !col.label ? 'sr-only' : ''">{{
31
+ col.label
32
+ }}</span>
33
+ </th>
34
+ </tr>
35
+ </thead>
36
+
37
+ <tbody>
38
+ <tr
39
+ v-for="(row, index) in rows"
40
+ :key="row[rowKey] ?? index"
41
+ class="border-b border-gray-100 transition-colors duration-200 last:border-0 hover:bg-gray-50 dark:border-gray-800 dark:hover:bg-gray-900/60"
42
+ >
43
+ <template v-for="col in columns" :key="col.key">
44
+ <!-- Header columns render as row headers (<th scope="row">), e.g. the
45
+ feature column of a comparison table. -->
46
+ <th
47
+ v-if="col.header"
48
+ scope="row"
49
+ class="px-5 py-4 font-medium text-gray-900 dark:text-gray-100"
50
+ :class="alignClass(col.align)"
51
+ >
52
+ <slot name="cell" :row="row" :column="col" :value="row[col.key]">
53
+ {{ row[col.key] }}
54
+ </slot>
55
+ </th>
56
+ <td
57
+ v-else
58
+ class="px-5 py-4"
59
+ :class="[
60
+ alignClass(col.align),
61
+ col.highlight
62
+ ? 'bg-primary-50/50 text-gray-700 dark:bg-primary-400/5 dark:text-gray-200'
63
+ : 'text-gray-600 dark:text-gray-400',
64
+ ]"
65
+ >
66
+ <slot name="cell" :row="row" :column="col" :value="row[col.key]">
67
+ <span :class="col.icon ? 'flex items-start gap-2' : ''">
68
+ <UiIcon
69
+ v-if="col.icon"
70
+ :name="col.icon"
71
+ class="mt-0.5 size-4 shrink-0"
72
+ :class="
73
+ col.highlight
74
+ ? 'text-success-600 dark:text-success-400'
75
+ : 'text-gray-400 dark:text-gray-500'
76
+ "
77
+ />
78
+ {{ row[col.key] }}
79
+ </span>
80
+ </slot>
81
+ </td>
82
+ </template>
83
+ </tr>
84
+ </tbody>
85
+ </table>
86
+ </div>
87
+ </template>
88
+
89
+ <script setup>
90
+ /**
91
+ * UiTable — a data table with sensible defaults, and a built-in comparison mode.
92
+ *
93
+ * Drive it with `columns` and `rows`: each column names a `key`, and each row
94
+ * is an object keyed by those column keys. It renders a real, accessible
95
+ * `<table>` (`<caption>`, `scope="col"` headers) that scrolls horizontally on
96
+ * narrow screens rather than crushing its columns.
97
+ *
98
+ * **Comparison** is just a configuration, not a separate component: mark the
99
+ * label column `header: true` (so it renders as a `<th scope="row">`), give the
100
+ * column you want to feature `highlight: true` (accent tint), and hand each
101
+ * value column an `icon` (e.g. a tick for the highlighted column, a dash for
102
+ * the others). That reproduces the "us vs. the usual" table without a bespoke
103
+ * component. For full control of a cell, use the `#cell` scoped slot.
104
+ *
105
+ * @example A plain data table
106
+ * <UiTable
107
+ * caption="Team"
108
+ * :columns="[
109
+ * { key: 'name', label: 'Name' },
110
+ * { key: 'role', label: 'Role' },
111
+ * { key: 'commits', label: 'Commits', align: 'right' },
112
+ * ]"
113
+ * :rows="[
114
+ * { name: 'Ada Lovelace', role: 'Engineer', commits: 128 },
115
+ * { name: 'Grace Hopper', role: 'Lead', commits: 342 },
116
+ * ]"
117
+ * />
118
+ *
119
+ * @example A comparison table (the old UiComparisonTable, now a configuration)
120
+ * <UiTable
121
+ * caption="How Numori compares"
122
+ * :columns="[
123
+ * { key: 'feature', label: 'Feature', header: true },
124
+ * { key: 'numori', label: 'Numori', highlight: true, icon: 'mdi:check-circle' },
125
+ * { key: 'usual', label: 'The usual', icon: 'mdi:minus-circle-outline' },
126
+ * ]"
127
+ * :rows="[
128
+ * { feature: 'Open source', numori: 'Entire ecosystem', usual: 'The client, sometimes' },
129
+ * ]"
130
+ * />
131
+ *
132
+ * @example Custom cell rendering
133
+ * <UiTable :columns="cols" :rows="rows">
134
+ * <template #cell="{ column, value }">
135
+ * <UiBadge v-if="column.key === 'status'" :color="value === 'active' ? 'green' : 'gray'">
136
+ * {{ value }}
137
+ * </UiBadge>
138
+ * <template v-else>{{ value }}</template>
139
+ * </template>
140
+ * </UiTable>
141
+ *
142
+ * @slot caption — Rich caption content (overrides the `caption` prop).
143
+ * @slot cell — Custom cell content. Scope: `{ row, column, value }`.
144
+ */
145
+ import UiIcon from '../icons/Icon.vue'
146
+
147
+ defineProps({
148
+ /**
149
+ * Column definitions, left to right. Each is
150
+ * `{ key, label?, align?, header?, highlight?, icon?, width? }`:
151
+ * - `key` — the row field this column reads.
152
+ * - `label` — the column heading.
153
+ * - `align` — `'left'` (default) | `'center'` | `'right'`.
154
+ * - `header` — render this column's cells as row headers (`<th scope="row">`).
155
+ * - `highlight` — accent-tint the column (the featured column in a comparison).
156
+ * - `icon` — MDI icon shown before each value in the column.
157
+ * - `width` — optional width utility class, e.g. `'w-2/5'`.
158
+ * @type {Array<{ key: string, label?: string, align?: string, header?: boolean, highlight?: boolean, icon?: string, width?: string }>}
159
+ */
160
+ columns: { type: Array, required: true },
161
+
162
+ /**
163
+ * Row objects, each keyed by the column `key`s.
164
+ * @type {Array<Record<string, unknown>>}
165
+ */
166
+ rows: { type: Array, required: true },
167
+
168
+ /**
169
+ * Table caption. Rendered as a real `<caption>` for accessibility; visible by
170
+ * default, or visually hidden with `hideCaption`.
171
+ * @type {string}
172
+ * @default ''
173
+ */
174
+ caption: { type: String, default: '' },
175
+
176
+ /**
177
+ * Keep the caption for assistive technology but hide it visually.
178
+ * @type {boolean}
179
+ * @default false
180
+ */
181
+ hideCaption: { type: Boolean, default: false },
182
+
183
+ /**
184
+ * Row field used as the `v-for` key; falls back to the row index.
185
+ * @type {string}
186
+ * @default 'key'
187
+ */
188
+ rowKey: { type: String, default: 'key' },
189
+ })
190
+
191
+ const alignClass = (align) =>
192
+ align === 'right' ? 'text-right' : align === 'center' ? 'text-center' : 'text-left'
193
+ </script>
@@ -15,11 +15,9 @@ import Badge from './Badge.vue'
15
15
  import Banner from './Banner.vue'
16
16
  import Breadcrumb from './Breadcrumb.vue'
17
17
  import Button from './Button.vue'
18
- import ButtonsGroup from './ButtonsGroup.vue'
19
18
  import Card from './Card.vue'
20
19
  import Checkbox from './Checkbox.vue'
21
20
  import CodeBlock from './CodeBlock.vue'
22
- import ComparisonTable from './ComparisonTable.vue'
23
21
  import Divider from './Divider.vue'
24
22
  import Dropdown from './Dropdown.vue'
25
23
  import DropdownItem from './DropdownItem.vue'
@@ -44,6 +42,7 @@ import Select from './Select.vue'
44
42
  import Slider from './Slider.vue'
45
43
  import Spinner from './Spinner.vue'
46
44
  import Stepper from './Stepper.vue'
45
+ import Table from './Table.vue'
47
46
  import ThemeToggle from './ThemeToggle.vue'
48
47
  import Toast from './Toast.vue'
49
48
  import Toggle from './Toggle.vue'
@@ -57,11 +56,9 @@ export {
57
56
  Banner as UiBanner,
58
57
  Breadcrumb as UiBreadcrumb,
59
58
  Button as UiButton,
60
- ButtonsGroup as UiButtonsGroup,
61
59
  Card as UiCard,
62
60
  Checkbox as UiCheckbox,
63
61
  CodeBlock as UiCodeBlock,
64
- ComparisonTable as UiComparisonTable,
65
62
  Divider as UiDivider,
66
63
  Dropdown as UiDropdown,
67
64
  DropdownItem as UiDropdownItem,
@@ -86,6 +83,7 @@ export {
86
83
  Slider as UiSlider,
87
84
  Spinner as UiSpinner,
88
85
  Stepper as UiStepper,
86
+ Table as UiTable,
89
87
  ThemeToggle as UiThemeToggle,
90
88
  Toast as UiToast,
91
89
  Toggle as UiToggle,
@@ -105,11 +103,9 @@ export const components = {
105
103
  Banner,
106
104
  Breadcrumb,
107
105
  Button,
108
- ButtonsGroup,
109
106
  Card,
110
107
  Checkbox,
111
108
  CodeBlock,
112
- ComparisonTable,
113
109
  Divider,
114
110
  Dropdown,
115
111
  DropdownItem,
@@ -134,6 +130,7 @@ export const components = {
134
130
  Slider,
135
131
  Spinner,
136
132
  Stepper,
133
+ Table,
137
134
  ThemeToggle,
138
135
  Toast,
139
136
  Toggle,
@@ -0,0 +1,49 @@
1
+ import { computed, useAttrs, toValue } from 'vue'
2
+ import { twMerge } from 'tailwind-merge'
3
+
4
+ /**
5
+ * useMergedClasses — merge a component's internal Tailwind classes with the
6
+ * caller's `class`, letting the caller win, and split the remaining attributes
7
+ * off for forwarding.
8
+ *
9
+ * This is the shared half of the "external classes override internals" pattern
10
+ * that UiButton, UiCard and UiIconTile all implement identically: bind
11
+ * `mergedClasses` to the root element's `:class`, spread `restAttrs` onto it
12
+ * with `v-bind`, and declare `defineOptions({ inheritAttrs: false })` in the
13
+ * component so Vue does not also apply `class` a second time.
14
+ *
15
+ * `tailwind-merge` resolves conflicts by keeping the last occurrence, and the
16
+ * caller's `class` is always passed last — so `bg-gray-100` from the outside
17
+ * beats a built-in `bg-primary-600` rather than both landing on the element.
18
+ * Passing the internal classes as one space-joined string is equivalent to
19
+ * passing them as separate arguments; twMerge tokenises either the same way.
20
+ *
21
+ * `defineOptions` is a compiler macro and cannot live in a composable, so each
22
+ * consuming SFC still declares `inheritAttrs: false` itself. Everything else —
23
+ * `useAttrs`, the class/rest split, and the merge — lives here.
24
+ *
25
+ * @param {import('vue').MaybeRefOrGetter<string>} internal
26
+ * The component's own classes, as a ref, getter, or plain string. A getter is
27
+ * the safest form when the internal classes are a `computed` declared later
28
+ * in setup, since it defers evaluation past that declaration.
29
+ * @returns {{ mergedClasses: import('vue').ComputedRef<string>, restAttrs: import('vue').ComputedRef<Record<string, unknown>> }}
30
+ * `mergedClasses` for the root `:class`; `restAttrs` (everything except
31
+ * `class`) for `v-bind`.
32
+ *
33
+ * @example
34
+ * defineOptions({ inheritAttrs: false })
35
+ * const internal = computed(() => `inline-flex ${sizeClass.value} ${colorClass.value}`)
36
+ * const { mergedClasses, restAttrs } = useMergedClasses(internal)
37
+ */
38
+ export function useMergedClasses(internal) {
39
+ const attrs = useAttrs()
40
+
41
+ const restAttrs = computed(() => {
42
+ const { class: _class, ...rest } = attrs
43
+ return rest
44
+ })
45
+
46
+ const mergedClasses = computed(() => twMerge(toValue(internal), attrs.class))
47
+
48
+ return { mergedClasses, restAttrs }
49
+ }
package/src/icons/mdi.js CHANGED
@@ -25,6 +25,7 @@ export const mdiPaths = {
25
25
  'check': "M21 7L9 19l-5.5-5.5l1.41-1.41L9 16.17L19.59 5.59z",
26
26
  'check-circle': "M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10s10-4.5 10-10S17.5 2 12 2m-2 15l-5-5l1.41-1.41L10 14.17l7.59-7.59L19 8z",
27
27
  'chevron-down': "M7.41 8.58L12 13.17l4.59-4.59L18 10l-6 6l-6-6z",
28
+ 'chevron-left': "M15.41 16.58L10.83 12l4.58-4.59L14 6l-6 6l6 6z",
28
29
  'chevron-right': "M8.59 16.58L13.17 12L8.59 7.41L10 6l6 6l-6 6z",
29
30
  'chevron-up': "M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6l-6 6z",
30
31
  'close': "M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12z",
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Size scale shared by the native checkable inputs (`UiCheckbox`, `UiRadio`).
3
+ *
4
+ * Both render a native `<input>` and size it with the same width/height classes;
5
+ * the map lived duplicated in each. A checkbox and a radio stay separate
6
+ * components because their HTML semantics differ, but their sizing does not.
7
+ *
8
+ * @param {string} size One of `sm` | `md` | `lg`. Anything else falls back to `md`.
9
+ * @returns {string} The width/height utility classes for that size.
10
+ */
11
+ export const CHECKABLE_SIZES = {
12
+ sm: 'w-3.5 h-3.5',
13
+ md: 'w-4 h-4',
14
+ lg: 'w-5 h-5',
15
+ }
16
+
17
+ export const checkableSizeClass = (size) => CHECKABLE_SIZES[size] ?? CHECKABLE_SIZES.md
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Shared chrome for floating menu surfaces.
3
+ *
4
+ * `UiDropdown`, `UiSelect`, `UiPopup` and `UiDropdownSubmenu` are four different
5
+ * takes on "a panel that floats over the page" — they differ in how they are
6
+ * positioned (absolute vs fixed vs teleported) and dismissed, which is why they
7
+ * remain separate components. What they share is the *look* of the panel: the
8
+ * surface colour, border, radius and shadow. That string lived copied verbatim
9
+ * in all four, so a tweak to the shared look meant editing four files and hoping
10
+ * none drifted. It now lives here.
11
+ *
12
+ * Positioning, z-index, padding and `overflow` stay at each call site, since
13
+ * those genuinely differ between the four.
14
+ */
15
+ export const MENU_PANEL_CLASS =
16
+ 'bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg'