@bjj/nuxt-layer-shadcn-ui 0.15.17 → 0.16.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 (45) hide show
  1. package/app/assets/styles/controlSize.stories.ts +121 -0
  2. package/app/assets/styles/tailwind-utilities.css +94 -0
  3. package/app/components/ui/AsyncDataTable/index.vue +3 -3
  4. package/app/components/ui/Button/index.stories.ts +18 -10
  5. package/app/components/ui/Button/index.vue +36 -6
  6. package/app/components/ui/Button/types.ts +7 -1
  7. package/app/components/ui/Card/index.stories.ts +2 -2
  8. package/app/components/ui/CopyButton/index.stories.ts +1 -1
  9. package/app/components/ui/DatePicker/index.stories.ts +33 -0
  10. package/app/components/ui/DatePicker/index.vue +2 -0
  11. package/app/components/ui/DatePicker/types.ts +4 -0
  12. package/app/components/ui/DateRangePicker/index.stories.ts +31 -0
  13. package/app/components/ui/DateRangePicker/index.vue +3 -0
  14. package/app/components/ui/DateRangePicker/types.ts +3 -0
  15. package/app/components/ui/Dropdown/index.stories.ts +2 -2
  16. package/app/components/ui/InfiniteDataTable/index.vue +3 -3
  17. package/app/components/ui/Input/index.stories.ts +33 -0
  18. package/app/components/ui/Input/index.vue +39 -3
  19. package/app/components/ui/Input/types.ts +4 -0
  20. package/app/components/ui/InputCurrency/index.stories.ts +31 -0
  21. package/app/components/ui/InputCurrency/types.ts +1 -1
  22. package/app/components/ui/InputNumber/index.stories.ts +63 -0
  23. package/app/components/ui/InputNumber/index.vue +24 -11
  24. package/app/components/ui/InputNumber/types.ts +4 -0
  25. package/app/components/ui/InputOtp/index.stories.ts +31 -0
  26. package/app/components/ui/InputOtp/index.vue +6 -1
  27. package/app/components/ui/InputOtp/types.ts +4 -0
  28. package/app/components/ui/InputPercent/index.stories.ts +31 -0
  29. package/app/components/ui/InputPercent/types.ts +1 -1
  30. package/app/components/ui/InputRange/index.stories.ts +31 -0
  31. package/app/components/ui/PageCard/index.stories.ts +4 -4
  32. package/app/components/ui/Pagination/index.vue +7 -5
  33. package/app/components/ui/Popover/index.stories.ts +2 -2
  34. package/app/components/ui/SearchSelect/index.stories.ts +33 -0
  35. package/app/components/ui/SearchSelect/index.vue +2 -0
  36. package/app/components/ui/SearchSelect/types.ts +3 -0
  37. package/app/components/ui/Select/index.stories.ts +33 -0
  38. package/app/components/ui/Select/index.vue +20 -7
  39. package/app/components/ui/Select/types.ts +4 -0
  40. package/app/components/ui/StaticDataTable/index.vue +2 -2
  41. package/app/components/ui/Textarea/index.stories.ts +31 -0
  42. package/app/components/ui/Textarea/index.vue +11 -2
  43. package/app/components/ui/Textarea/types.ts +4 -0
  44. package/app/types/control.ts +5 -0
  45. package/package.json +2 -2
@@ -124,8 +124,8 @@ export const WithActions: Story = {
124
124
  <template>
125
125
  <PageCard title="API Keys" class="max-w-2xl">
126
126
  <template #actions>
127
- <Button variant="outline" size="sm">Export</Button>
128
- <Button size="sm">Create</Button>
127
+ <Button variant="outline" size="md">Export</Button>
128
+ <Button size="md">Create</Button>
129
129
  </template>
130
130
  <p>Action buttons rendered on the right side of the title.</p>
131
131
  </PageCard>
@@ -139,8 +139,8 @@ export const WithActions: Story = {
139
139
  template: `
140
140
  <PageCard title="API Keys" class="max-w-2xl">
141
141
  <template #actions>
142
- <Button variant="outline" size="sm">Export</Button>
143
- <Button size="sm">Create</Button>
142
+ <Button variant="outline" size="md">Export</Button>
143
+ <Button size="md">Create</Button>
144
144
  </template>
145
145
  <p>Action buttons rendered on the right side of the title.</p>
146
146
  </PageCard>
@@ -33,8 +33,10 @@ const T = useTranslations('components.ui.Pagination')
33
33
  const totalPages = computed(() => Math.ceil(props.total / props.pageSize) || 0)
34
34
  const hasData = computed(() => props.total > 0)
35
35
 
36
+ // shadcn pagination items use the shadcn button scale; the simple-mode Buttons use the control scale.
36
37
  const iconButtonSize = computed(() => props.size === 'sm' ? 'icon-sm' as const : 'icon' as const)
37
- const buttonSize = computed(() => props.size === 'sm' ? 'sm' as const : 'default' as const)
38
+ const simpleButtonSize = computed(() => props.size === 'sm' ? 'icon-md' as const : 'icon' as const)
39
+ const buttonSize = computed(() => props.size === 'sm' ? 'md' as const : 'default' as const)
38
40
 
39
41
  const pageReport = computed(() => {
40
42
  if (!hasData.value) return ''
@@ -77,7 +79,7 @@ const pageSizeMenuItems = computed<DropdownItem[]>(() =>
77
79
  <template v-if="simple">
78
80
  <Button
79
81
  variant="ghost"
80
- :size="iconButtonSize"
82
+ :size="simpleButtonSize"
81
83
  :disabled="page <= 1"
82
84
  @click="emit('update:page', 1)"
83
85
  >
@@ -85,7 +87,7 @@ const pageSizeMenuItems = computed<DropdownItem[]>(() =>
85
87
  </Button>
86
88
  <Button
87
89
  variant="ghost"
88
- :size="iconButtonSize"
90
+ :size="simpleButtonSize"
89
91
  :disabled="page <= 1"
90
92
  @click="emit('update:page', page - 1)"
91
93
  >
@@ -98,7 +100,7 @@ const pageSizeMenuItems = computed<DropdownItem[]>(() =>
98
100
  </span>
99
101
  <Button
100
102
  variant="ghost"
101
- :size="iconButtonSize"
103
+ :size="simpleButtonSize"
102
104
  :disabled="page >= totalPages"
103
105
  @click="emit('update:page', page + 1)"
104
106
  >
@@ -106,7 +108,7 @@ const pageSizeMenuItems = computed<DropdownItem[]>(() =>
106
108
  </Button>
107
109
  <Button
108
110
  variant="ghost"
109
- :size="iconButtonSize"
111
+ :size="simpleButtonSize"
110
112
  :disabled="page >= totalPages"
111
113
  @click="emit('update:page', totalPages)"
112
114
  >
@@ -95,7 +95,7 @@ export const WithForm: Story = {
95
95
  <div class="space-y-3">
96
96
  <h4 class="font-medium">Update Name</h4>
97
97
  <Input placeholder="Enter new name" />
98
- <Button size="sm" class="w-full">Save</Button>
98
+ <Button size="md" class="w-full">Save</Button>
99
99
  </div>
100
100
  </Popover>
101
101
  </template>
@@ -113,7 +113,7 @@ export const WithForm: Story = {
113
113
  <div class="space-y-3">
114
114
  <h4 class="font-medium">Update Name</h4>
115
115
  <Input placeholder="Enter new name" />
116
- <Button size="sm" class="w-full">Save</Button>
116
+ <Button size="md" class="w-full">Save</Button>
117
117
  </div>
118
118
  </Popover>
119
119
  `,
@@ -4,6 +4,8 @@ import { useArgsModel } from '#storybook/argsModel'
4
4
  import type { SearchSelectLoadMethodParams, SearchSelectLoadMethodResult } from './types'
5
5
  import SearchSelect from './index.vue'
6
6
 
7
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
8
+
7
9
  // Mock data: 100 items for simulating server-side search
8
10
  const allItems = Array.from({ length: 100 }, (_, i) => ({
9
11
  label: `Item ${i + 1}`,
@@ -51,6 +53,7 @@ const meta = {
51
53
  createNewText: { control: 'text' },
52
54
  loadLimit: { control: 'number' },
53
55
  autoLoad: { control: 'boolean' },
56
+ size: { control: 'select', options: sizes },
54
57
  readonly: { control: 'boolean' },
55
58
  disabled: { control: 'boolean' },
56
59
  invalid: { control: 'boolean' },
@@ -65,6 +68,7 @@ const meta = {
65
68
  createNewText: '',
66
69
  loadLimit: 20,
67
70
  autoLoad: false,
71
+ size: 'default',
68
72
  readonly: false,
69
73
  disabled: false,
70
74
  invalid: false,
@@ -179,6 +183,35 @@ export const WithCreateNew: Story = {
179
183
  },
180
184
  }
181
185
 
186
+ export const Sizes: Story = {
187
+ parameters: {
188
+ ...noControls,
189
+ docs: {
190
+ source: {
191
+ code: `
192
+ <template>
193
+ <SearchSelect v-model="value" :loadMethod="loadMethod" size="sm" />
194
+ </template>
195
+ `.trim(),
196
+ },
197
+ },
198
+ },
199
+ render: () => ({
200
+ components: { SearchSelect },
201
+ setup: () => ({ sizes, mockLoadMethod, value: ref<string>() }),
202
+ template: `
203
+ <div class="space-y-3">
204
+ <div v-for="s in sizes" :key="s" class="flex items-center gap-3">
205
+ <span class="w-14 text-sm text-muted-foreground">{{ s }}</span>
206
+ <div class="w-64">
207
+ <SearchSelect v-model="value" :loadMethod="mockLoadMethod" :size="s" />
208
+ </div>
209
+ </div>
210
+ </div>
211
+ `,
212
+ }),
213
+ }
214
+
182
215
  export const Disabled: Story = {
183
216
  parameters: noControls,
184
217
  args: {
@@ -15,6 +15,7 @@ const props = withDefaults(defineProps<SearchSelectProps<TValue, TMeta>>(), {
15
15
  loadValueOptionMethod: undefined,
16
16
  loadLimit: 20,
17
17
  placeholder: undefined,
18
+ size: undefined,
18
19
  readonly: false,
19
20
  disabled: false,
20
21
  invalid: false,
@@ -196,6 +197,7 @@ defineExpose({ refresh: resetAndLoad })
196
197
  :options="displayedOptions"
197
198
  :filter="filterFunction"
198
199
  :placeholder="placeholder"
200
+ :size="size"
199
201
  :searchPlaceholder="searchPlaceholder"
200
202
  :emptyText="computedEmptyText"
201
203
  :readonly="readonly"
@@ -1,3 +1,4 @@
1
+ import type { ControlSize } from '../../../types/control'
1
2
  import type { SelectOption } from '../Select/types'
2
3
 
3
4
  /** Result returned by loadMethod */
@@ -26,6 +27,8 @@ export interface SearchSelectProps<V extends string | number = string, M = unkno
26
27
  /** Items per request (default: 20) */
27
28
  loadLimit?: number
28
29
  placeholder?: string
30
+ /** Size tier. Unset follows the nearest ancestor's `data-control-size`, else `default`. */
31
+ size?: ControlSize
29
32
  /** Keep the value visible and focusable but prevent changing it */
30
33
  readonly?: boolean
31
34
  disabled?: boolean
@@ -3,6 +3,8 @@ import EventLog from '#storybook/EventLog.vue'
3
3
  import { useArgsModel } from '#storybook/argsModel'
4
4
  import Select from './index.vue'
5
5
 
6
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
7
+
6
8
  const frameworks = [
7
9
  { label: 'React', value: 'react' },
8
10
  { label: 'Vue', value: 'vue' },
@@ -37,6 +39,7 @@ const meta = {
37
39
  argTypes: {
38
40
  modelValue: { control: 'text' },
39
41
  placeholder: { control: 'text' },
42
+ size: { control: 'select', options: sizes },
40
43
  readonly: { control: 'boolean' },
41
44
  disabled: { control: 'boolean' },
42
45
  invalid: { control: 'boolean' },
@@ -50,6 +53,7 @@ const meta = {
50
53
  args: {
51
54
  modelValue: undefined,
52
55
  placeholder: 'Select an option',
56
+ size: 'default',
53
57
  readonly: false,
54
58
  disabled: false,
55
59
  invalid: false,
@@ -262,6 +266,35 @@ export const Grouped: Story = {
262
266
  }),
263
267
  }
264
268
 
269
+ export const Sizes: Story = {
270
+ parameters: {
271
+ ...noControls,
272
+ docs: {
273
+ source: {
274
+ code: `
275
+ <template>
276
+ <Select v-model="value" :options="options" size="sm" />
277
+ </template>
278
+ `.trim(),
279
+ },
280
+ },
281
+ },
282
+ render: () => ({
283
+ components: { Select },
284
+ setup: () => ({ sizes, frameworks, value: ref('nuxt') }),
285
+ template: `
286
+ <div class="space-y-3">
287
+ <div v-for="s in sizes" :key="s" class="flex items-center gap-3">
288
+ <span class="w-14 text-sm text-muted-foreground">{{ s }}</span>
289
+ <div class="w-64">
290
+ <Select v-model="value" :options="frameworks" :size="s" />
291
+ </div>
292
+ </div>
293
+ </div>
294
+ `,
295
+ }),
296
+ }
297
+
265
298
  export const Disabled: Story = {
266
299
  parameters: {
267
300
  ...noControls,
@@ -27,6 +27,7 @@ const props = withDefaults(defineProps<SelectProps<TValue, TMeta>>(), {
27
27
  options: () => [],
28
28
  modelValue: undefined,
29
29
  placeholder: undefined,
30
+ size: undefined,
30
31
  readonly: false,
31
32
  disabled: false,
32
33
  invalid: false,
@@ -210,6 +211,7 @@ function handleClear (event: MouseEvent) {
210
211
  :aria-readonly="readonlyActive || undefined"
211
212
  :data-disabled="disabled || undefined"
212
213
  :data-state="open ? 'open' : 'closed'"
214
+ :data-control-size="size"
213
215
  :class="cn(
214
216
  `
215
217
  data-[state=open]:border-ring data-[state=open]:ring-ring/50
@@ -218,6 +220,7 @@ function handleClear (event: MouseEvent) {
218
220
  aria-invalid:data-[state=open]:border-destructive
219
221
  aria-invalid:data-[state=open]:ring-destructive/20
220
222
  dark:aria-invalid:data-[state=open]:ring-destructive/40
223
+ h-(--control-height)
221
224
  data-[state=open]:ring-[3px]
222
225
  `,
223
226
  readonlyActive ? 'cursor-default' : 'cursor-pointer',
@@ -226,9 +229,11 @@ function handleClear (event: MouseEvent) {
226
229
  >
227
230
  <span
228
231
  class="
229
- gap-2 px-3 py-1 text-base
230
- md:text-sm
231
- line-clamp-1 flex flex-1 items-center whitespace-nowrap
232
+ gap-2 py-1 text-base
233
+ md:text-(length:--control-font-size)
234
+ md:leading-(--control-line-height)
235
+ line-clamp-1 flex flex-1 items-center px-(--control-px)
236
+ whitespace-nowrap
232
237
  "
233
238
  >
234
239
  <template v-if="multiple && selectedOptions.length > 0">
@@ -257,25 +262,33 @@ function handleClear (event: MouseEvent) {
257
262
  <InputGroupAddon
258
263
  v-if="showClearButton"
259
264
  align="inline-end"
265
+ class="pr-(--control-px)"
260
266
  >
261
267
  <InputGroupButton
262
268
  type="button"
263
269
  size="icon-xs"
270
+ class="size-(--control-addon-button-size)"
264
271
  @click="handleClear"
265
272
  >
266
- <Icon name="x" />
273
+ <Icon
274
+ name="x"
275
+ class="size-(--control-icon)"
276
+ />
267
277
  </InputGroupButton>
268
278
  </InputGroupAddon>
269
- <InputGroupAddon align="inline-end">
279
+ <InputGroupAddon
280
+ align="inline-end"
281
+ class="pr-(--control-px)"
282
+ >
270
283
  <Icon
271
284
  v-if="loading"
272
285
  name="loader-circle"
273
- class="size-4 animate-spin opacity-50"
286
+ class="animate-spin size-(--control-icon) opacity-50"
274
287
  />
275
288
  <Icon
276
289
  v-else
277
290
  name="chevron-down"
278
- class="size-4 opacity-50"
291
+ class="size-(--control-icon) opacity-50"
279
292
  />
280
293
  </InputGroupAddon>
281
294
  </InputGroup>
@@ -1,3 +1,5 @@
1
+ import type { ControlSize } from '../../../types/control'
2
+
1
3
  export interface SelectOption<V extends string | number = string, M = unknown> {
2
4
  label: string
3
5
  value: V
@@ -12,6 +14,8 @@ export type SelectFilterFunction = (items: string[], keyword: string) => string[
12
14
  export type SelectBaseProps<V extends string | number = string, M = unknown> = {
13
15
  options?: SelectOption<V, M>[]
14
16
  placeholder?: string
17
+ /** Size tier. Unset follows the nearest ancestor's `data-control-size`, else `default`. */
18
+ size?: ControlSize
15
19
  /** Keep the value visible and focusable but prevent changing it */
16
20
  readonly?: boolean
17
21
  disabled?: boolean
@@ -172,7 +172,7 @@ function onSortOrderUpdate (value: number | null) {
172
172
  >
173
173
  <Button
174
174
  :variant="batchActionsDisabled ? 'outline' : 'default'"
175
- :size="isMobile ? 'sm' : 'default'"
175
+ :size="isMobile ? 'md' : 'default'"
176
176
  :disabled="batchActionsDisabled"
177
177
  >
178
178
  {{ T('actions') }} ({{ selectedCount }})
@@ -239,7 +239,7 @@ function onSortOrderUpdate (value: number | null) {
239
239
  >
240
240
  <Button
241
241
  :variant="batchActionsDisabled ? 'outline' : 'default'"
242
- :size="isMobile ? 'sm' : 'default'"
242
+ :size="isMobile ? 'md' : 'default'"
243
243
  :disabled="batchActionsDisabled"
244
244
  >
245
245
  {{ T('actions') }} ({{ selectedCount }})
@@ -3,6 +3,8 @@ import EventLog from '#storybook/EventLog.vue'
3
3
  import { useArgsModel } from '#storybook/argsModel'
4
4
  import Textarea from './index.vue'
5
5
 
6
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
7
+
6
8
  const meta = {
7
9
  title: 'UI/Textarea',
8
10
  component: Textarea,
@@ -13,6 +15,7 @@ const meta = {
13
15
  maxlength: { control: 'number' },
14
16
  maxLines: { control: 'number' },
15
17
  showCount: { control: 'boolean' },
18
+ size: { control: 'select', options: sizes },
16
19
  readonly: { control: 'boolean' },
17
20
  disabled: { control: 'boolean' },
18
21
  invalid: { control: 'boolean' },
@@ -25,6 +28,7 @@ const meta = {
25
28
  maxlength: undefined,
26
29
  maxLines: undefined,
27
30
  showCount: false,
31
+ size: 'default',
28
32
  readonly: false,
29
33
  disabled: false,
30
34
  invalid: false,
@@ -91,6 +95,33 @@ export const WithMaxLines: Story = {
91
95
  },
92
96
  }
93
97
 
98
+ export const Sizes: Story = {
99
+ parameters: {
100
+ ...noControls,
101
+ docs: {
102
+ source: {
103
+ code: `
104
+ <template>
105
+ <Textarea v-model="value" size="sm" showCount />
106
+ </template>
107
+ `.trim(),
108
+ },
109
+ },
110
+ },
111
+ render: () => ({
112
+ components: { Textarea },
113
+ setup: () => ({ sizes, value: ref('Compact tiers tighten padding and font size.') }),
114
+ template: `
115
+ <div class="space-y-3">
116
+ <div v-for="s in sizes" :key="s" class="flex items-center gap-3">
117
+ <span class="w-14 text-sm text-muted-foreground">{{ s }}</span>
118
+ <Textarea v-model="value" :size="s" showCount class="w-64" />
119
+ </div>
120
+ </div>
121
+ `,
122
+ }),
123
+ }
124
+
94
125
  export const Invalid: Story = {
95
126
  parameters: noControls,
96
127
  args: {
@@ -11,6 +11,7 @@ const props = withDefaults(defineProps<TextareaProps>(), {
11
11
  maxlength: undefined,
12
12
  maxLines: undefined,
13
13
  showCount: false,
14
+ size: undefined,
14
15
  readonly: false,
15
16
  disabled: false,
16
17
  invalid: false,
@@ -90,6 +91,11 @@ function handleChange (event: Event) {
90
91
 
91
92
  const mergedClass = computed(() =>
92
93
  cn(
94
+ `
95
+ md:text-(length:--control-font-size)
96
+ md:leading-(--control-line-height)
97
+ px-(--control-px)
98
+ `,
93
99
  props.rows ? 'field-sizing-fixed!' : '',
94
100
  props.class,
95
101
  ),
@@ -97,7 +103,7 @@ const mergedClass = computed(() =>
97
103
  </script>
98
104
 
99
105
  <template>
100
- <div>
106
+ <div :data-control-size="size">
101
107
  <ShadcnTextarea
102
108
  :modelValue="modelValue"
103
109
  :rows="rows"
@@ -115,7 +121,10 @@ const mergedClass = computed(() =>
115
121
  />
116
122
  <div
117
123
  v-if="showCount"
118
- class="mt-1 text-sm text-muted-foreground text-right"
124
+ class="
125
+ mt-1 text-muted-foreground text-right text-(length:--control-font-size)
126
+ leading-(--control-line-height)
127
+ "
119
128
  >
120
129
  {{ countText }}
121
130
  </div>
@@ -1,3 +1,5 @@
1
+ import type { ControlSize } from '../../../types/control'
2
+
1
3
  export interface TextareaProps {
2
4
  modelValue?: string
3
5
  /** Set to enable browser/password-manager autofill. Defaults to 'off'. */
@@ -12,6 +14,8 @@ export interface TextareaProps {
12
14
  * Each part gains a ` / limit` suffix when `maxLines` / `maxlength` is set.
13
15
  */
14
16
  showCount?: boolean
17
+ /** Size tier. Unset follows the nearest ancestor's `data-control-size`, else `default`. */
18
+ size?: ControlSize
15
19
  readonly?: boolean
16
20
  disabled?: boolean
17
21
  invalid?: boolean
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Size tier shared by input-like components. The dimensions of each tier live in
3
+ * `assets/styles/tailwind-utilities.css` (`data-control-size`).
4
+ */
5
+ export type ControlSize = 'xs' | 'sm' | 'md' | 'default' | 'lg'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bjj/nuxt-layer-shadcn-ui",
3
- "version": "0.15.17",
3
+ "version": "0.16.0",
4
4
  "description": "Nuxt layer providing shadcn-vue based UI components",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -42,5 +42,5 @@
42
42
  "vue-i18n": "^11",
43
43
  "vue-router": "^4 || ^5"
44
44
  },
45
- "gitHead": "202ba37647364e794cc07b3fb379823f603c8af6"
45
+ "gitHead": "a4d32792ab79adc258207e940a1bdb76488de4d7"
46
46
  }