@bjj/nuxt-layer-shadcn-ui 0.15.18 → 0.16.1

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 (49) hide show
  1. package/app/assets/styles/controlSize.stories.ts +3 -3
  2. package/app/assets/styles/tailwind-utilities.css +16 -3
  3. package/app/components/ui/AsyncDataTable/index.vue +3 -3
  4. package/app/components/ui/Button/index.stories.ts +7 -3
  5. package/app/components/ui/Button/types.ts +1 -1
  6. package/app/components/ui/Card/index.stories.ts +2 -2
  7. package/app/components/ui/CopyButton/index.stories.ts +1 -1
  8. package/app/components/ui/DatePicker/index.stories.ts +1 -1
  9. package/app/components/ui/DateRangePicker/index.stories.ts +1 -1
  10. package/app/components/ui/Dropdown/index.stories.ts +2 -2
  11. package/app/components/ui/InfiniteDataTable/index.vue +3 -3
  12. package/app/components/ui/Input/index.stories.ts +1 -1
  13. package/app/components/ui/InputCurrency/index.stories.ts +1 -1
  14. package/app/components/ui/InputNumber/index.stories.ts +1 -1
  15. package/app/components/ui/InputOtp/index.stories.ts +1 -1
  16. package/app/components/ui/InputPercent/index.stories.ts +1 -1
  17. package/app/components/ui/InputRange/index.stories.ts +1 -1
  18. package/app/components/ui/PageCard/index.stories.ts +4 -4
  19. package/app/components/ui/Pagination/index.vue +7 -5
  20. package/app/components/ui/Popover/index.stories.ts +2 -2
  21. package/app/components/ui/SearchSelect/index.stories.ts +1 -1
  22. package/app/components/ui/Select/index.stories.ts +1 -1
  23. package/app/components/ui/StaticDataTable/index.vue +2 -2
  24. package/app/components/ui/Tag/en.json +3 -0
  25. package/app/components/ui/Tag/index.stories.ts +145 -0
  26. package/app/components/ui/Tag/index.vue +40 -0
  27. package/app/components/ui/Tag/types.ts +4 -0
  28. package/app/components/ui/Textarea/index.stories.ts +1 -1
  29. package/app/types/control.ts +1 -1
  30. package/i18n/messages/ar.json +3 -0
  31. package/i18n/messages/de.json +3 -0
  32. package/i18n/messages/en.json +3 -0
  33. package/i18n/messages/es.json +3 -0
  34. package/i18n/messages/fr.json +3 -0
  35. package/i18n/messages/hi.json +3 -0
  36. package/i18n/messages/id.json +3 -0
  37. package/i18n/messages/it.json +3 -0
  38. package/i18n/messages/ja.json +3 -0
  39. package/i18n/messages/ko.json +3 -0
  40. package/i18n/messages/nl.json +3 -0
  41. package/i18n/messages/pl.json +3 -0
  42. package/i18n/messages/pt.json +3 -0
  43. package/i18n/messages/ru.json +3 -0
  44. package/i18n/messages/th.json +3 -0
  45. package/i18n/messages/tr.json +3 -0
  46. package/i18n/messages/vi.json +3 -0
  47. package/i18n/messages/zh-CN.json +3 -0
  48. package/i18n/messages/zh-TW.json +3 -0
  49. package/package.json +2 -2
@@ -7,7 +7,7 @@ import InputNumber from '../../components/ui/InputNumber/index.vue'
7
7
  import Select from '../../components/ui/Select/index.vue'
8
8
  import Textarea from '../../components/ui/Textarea/index.vue'
9
9
 
10
- const sizes = [ 'xs', 'sm', 'default', 'lg' ] as const
10
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
11
11
 
12
12
  const options = [
13
13
  { label: 'Nuxt', value: 'nuxt' },
@@ -84,7 +84,7 @@ export const InheritedFromAncestor: Story = {
84
84
  source: {
85
85
  code: `
86
86
  <template>
87
- <form data-control-size="xs">
87
+ <form data-control-size="sm">
88
88
  <Input v-model="name" />
89
89
  <InputNumber v-model="count" />
90
90
  <Select v-model="framework" :options="options" />
@@ -106,7 +106,7 @@ export const InheritedFromAncestor: Story = {
106
106
  note: ref('Every control inside follows the form tier.'),
107
107
  }),
108
108
  template: `
109
- <div data-control-size="xs" class="grid max-w-sm gap-2">
109
+ <div data-control-size="sm" class="grid max-w-sm gap-2">
110
110
  <Input v-model="name" />
111
111
  <InputNumber v-model="count" />
112
112
  <Select v-model="framework" :options="options" />
@@ -33,8 +33,9 @@
33
33
  * pre-existing look and applies when no ancestor sets a tier.
34
34
  *
35
35
  * tier height font edge px gap icon stepper px addon button button px button+icon px
36
- * xs 28 12 8 4 14 4 20 10 8
37
- * sm 32 14 10 6 16 6 24 12 10
36
+ * xs 24 12 6 4 12 4 16 8 6
37
+ * sm 28 12 8 4 14 4 20 10 8
38
+ * md 32 14 10 6 16 6 24 12 10
38
39
  * default 36 14 12 8 16 12 24 16 12
39
40
  * lg 40 14 16 8 16 14 28 24 16
40
41
  *
@@ -66,6 +67,18 @@
66
67
  --control-button-icon-px: --spacing(3);
67
68
  }
68
69
  [data-control-size='xs'] {
70
+ --control-height: --spacing(6);
71
+ --control-font-size: --theme(--text-xs);
72
+ --control-line-height: --theme(--text-xs--line-height);
73
+ --control-px: --spacing(1.5);
74
+ --control-gap: --spacing(1);
75
+ --control-icon: --spacing(3);
76
+ --control-stepper-px: --spacing(1);
77
+ --control-addon-button-size: --spacing(4);
78
+ --control-button-px: --spacing(2);
79
+ --control-button-icon-px: --spacing(1.5);
80
+ }
81
+ [data-control-size='sm'] {
69
82
  --control-height: --spacing(7);
70
83
  --control-font-size: --theme(--text-xs);
71
84
  --control-line-height: --theme(--text-xs--line-height);
@@ -77,7 +90,7 @@
77
90
  --control-button-px: --spacing(2.5);
78
91
  --control-button-icon-px: --spacing(2);
79
92
  }
80
- [data-control-size='sm'] {
93
+ [data-control-size='md'] {
81
94
  --control-height: --spacing(8);
82
95
  --control-font-size: --theme(--text-sm);
83
96
  --control-line-height: --theme(--text-sm--line-height);
@@ -304,7 +304,7 @@ onMounted(() => {
304
304
  >
305
305
  <Button
306
306
  :variant="batchActionsDisabled ? 'outline' : 'default'"
307
- :size="isMobile ? 'sm' : 'default'"
307
+ :size="isMobile ? 'md' : 'default'"
308
308
  :disabled="batchActionsDisabled"
309
309
  >
310
310
  {{ T('actions') }} ({{ selectedCount }})
@@ -372,7 +372,7 @@ onMounted(() => {
372
372
  </span>
373
373
  <Button
374
374
  variant="outline"
375
- size="sm"
375
+ size="md"
376
376
  @click="() => fetchData(undefined, true)"
377
377
  >
378
378
  {{ t('common.actions.retry') }}
@@ -400,7 +400,7 @@ onMounted(() => {
400
400
  >
401
401
  <Button
402
402
  :variant="batchActionsDisabled ? 'outline' : 'default'"
403
- :size="isMobile ? 'sm' : 'default'"
403
+ :size="isMobile ? 'md' : 'default'"
404
404
  :disabled="batchActionsDisabled"
405
405
  >
406
406
  {{ T('actions') }} ({{ selectedCount }})
@@ -17,10 +17,12 @@ const variants = [
17
17
  const sizes = [
18
18
  'xs',
19
19
  'sm',
20
+ 'md',
20
21
  'default',
21
22
  'lg',
22
23
  'icon-xs',
23
24
  'icon-sm',
25
+ 'icon-md',
24
26
  'icon',
25
27
  'icon-lg',
26
28
  ] as const satisfies readonly ButtonSize[]
@@ -114,10 +116,12 @@ export const Sizes: Story = {
114
116
  <template>
115
117
  <Button size="xs">xs</Button>
116
118
  <Button size="sm">sm</Button>
119
+ <Button size="md">md</Button>
117
120
  <Button size="default">default</Button>
118
121
  <Button size="lg">lg</Button>
119
122
  <Button size="icon-xs" icon="plus" />
120
123
  <Button size="icon-sm" icon="plus" />
124
+ <Button size="icon-md" icon="plus" />
121
125
  <Button size="icon" icon="plus" />
122
126
  <Button size="icon-lg" icon="plus" />
123
127
  </template>
@@ -313,9 +317,9 @@ export const InheritedHoverColor: Story = {
313
317
  class="p-3 flex items-center gap-2"
314
318
  >
315
319
  <span class="mr-auto text-sm font-medium capitalize">{{ c }}</span>
316
- <Button variant="outline" size="sm">Outline</Button>
317
- <Button variant="ghost" size="sm">Ghost</Button>
318
- <Button variant="link" size="sm">Link</Button>
320
+ <Button variant="outline" size="md">Outline</Button>
321
+ <Button variant="ghost" size="md">Ghost</Button>
322
+ <Button variant="link" size="md">Link</Button>
319
323
  </Surface>
320
324
  </div>
321
325
  `,
@@ -8,7 +8,7 @@ export type ButtonVariant = ButtonVariants['variant']
8
8
  * A control size tier for text buttons, or `icon-<tier>` for a square icon-only
9
9
  * button (`icon` is the `default` tier). Heights match the inputs of the same tier.
10
10
  */
11
- export type ButtonSize = ControlSize | 'icon-xs' | 'icon-sm' | 'icon' | 'icon-lg'
11
+ export type ButtonSize = ControlSize | 'icon-xs' | 'icon-sm' | 'icon-md' | 'icon' | 'icon-lg'
12
12
 
13
13
  export interface ButtonProps {
14
14
  variant?: ButtonVariant
@@ -40,7 +40,7 @@ export const CustomHeader: Story = {
40
40
  <template #header>
41
41
  <div class="flex items-center justify-between">
42
42
  <span class="text-lg font-semibold">Custom Header</span>
43
- <Button variant="ghost" size="sm">Action</Button>
43
+ <Button variant="ghost" size="md">Action</Button>
44
44
  </div>
45
45
  </template>
46
46
  <p>This card uses the header slot for a custom layout.</p>
@@ -57,7 +57,7 @@ export const CustomHeader: Story = {
57
57
  <template #header>
58
58
  <div class="flex items-center justify-between">
59
59
  <span class="text-lg font-semibold">Custom Header</span>
60
- <Button variant="ghost" size="sm">Action</Button>
60
+ <Button variant="ghost" size="md">Action</Button>
61
61
  </div>
62
62
  </template>
63
63
  <p>This card uses the header slot for a custom layout.</p>
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/vue3'
2
2
  import CopyButton from './index.vue'
3
3
 
4
4
  const variants = [ 'default', 'destructive', 'outline', 'secondary', 'ghost', 'link' ] as const
5
- const sizes = [ 'sm', 'default', 'lg', 'icon-sm', 'icon', 'icon-lg' ] as const
5
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg', 'icon-xs', 'icon-sm', 'icon-md', 'icon', 'icon-lg' ] as const
6
6
 
7
7
  const meta = {
8
8
  title: 'UI/CopyButton',
@@ -5,7 +5,7 @@ import Button from '../Button/index.vue'
5
5
  import Modal from '../Modal/index.vue'
6
6
  import DatePicker from './index.vue'
7
7
 
8
- const sizes = [ 'xs', 'sm', 'default', 'lg' ] as const
8
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
9
9
 
10
10
  const types: DatePickerType[] = [ 'date', 'month', 'year' ]
11
11
 
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/vue3'
2
2
  import { useArgsModel } from '#storybook/argsModel'
3
3
  import DateRangePicker from './index.vue'
4
4
 
5
- const sizes = [ 'xs', 'sm', 'default', 'lg' ] as const
5
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
6
6
 
7
7
  const meta = {
8
8
  title: 'UI/DateRangePicker',
@@ -280,7 +280,7 @@ export const PopupSlot: Story = {
280
280
  <p class="text-sm text-muted-foreground">
281
281
  Use the <code>popup</code> slot to render arbitrary content inside the menu.
282
282
  </p>
283
- <Button size="sm" @click="hide">Close</Button>
283
+ <Button size="md" @click="hide">Close</Button>
284
284
  </div>
285
285
  </template>
286
286
  </Dropdown>
@@ -300,7 +300,7 @@ export const PopupSlot: Story = {
300
300
  <p class="text-sm text-muted-foreground">
301
301
  Use the <code>popup</code> slot to render arbitrary content inside the menu.
302
302
  </p>
303
- <Button size="sm" @click="hide">Close</Button>
303
+ <Button size="md" @click="hide">Close</Button>
304
304
  </div>
305
305
  </template>
306
306
  </Dropdown>
@@ -292,7 +292,7 @@ onMounted(() => {
292
292
  </span>
293
293
  <Button
294
294
  variant="ghost"
295
- size="sm"
295
+ size="md"
296
296
  @click="loadMore"
297
297
  >
298
298
  {{ t('common.actions.retry') }}
@@ -327,7 +327,7 @@ onMounted(() => {
327
327
  <Tooltip :text="T('scrollToTop')">
328
328
  <Button
329
329
  variant="ghost"
330
- size="icon-sm"
330
+ size="icon-md"
331
331
  icon="arrow-up-to-line"
332
332
  :disabled="loading || internalData.length === 0 || isAtTop"
333
333
  @click="scrollToTop"
@@ -336,7 +336,7 @@ onMounted(() => {
336
336
  <Tooltip :text="t('common.actions.refresh')">
337
337
  <Button
338
338
  variant="ghost"
339
- size="icon-sm"
339
+ size="icon-md"
340
340
  icon="rotate-cw"
341
341
  :disabled="loading"
342
342
  @click="refresh"
@@ -4,7 +4,7 @@ import { useArgsModel } from '#storybook/argsModel'
4
4
  import Icon from '../Icon/index.vue'
5
5
  import Input from './index.vue'
6
6
 
7
- const sizes = [ 'xs', 'sm', 'default', 'lg' ] as const
7
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
8
8
 
9
9
  const meta = {
10
10
  title: 'UI/Input',
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/vue3'
2
2
  import { useArgsModel } from '#storybook/argsModel'
3
3
  import InputCurrency from './index.vue'
4
4
 
5
- const sizes = [ 'xs', 'sm', 'default', 'lg' ] as const
5
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
6
6
 
7
7
  const currencyDisplays = [ 'symbol', 'narrowSymbol', 'code', 'name' ] as const
8
8
 
@@ -4,7 +4,7 @@ import { useArgsModel } from '#storybook/argsModel'
4
4
  import InputNumber from './index.vue'
5
5
 
6
6
  const aligns = [ 'left', 'center', 'right' ] as const
7
- const sizes = [ 'xs', 'sm', 'default', 'lg' ] as const
7
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
8
8
 
9
9
  const meta = {
10
10
  title: 'UI/InputNumber',
@@ -3,7 +3,7 @@ import EventLog from '#storybook/EventLog.vue'
3
3
  import { useArgsModel } from '#storybook/argsModel'
4
4
  import InputOtp from './index.vue'
5
5
 
6
- const sizes = [ 'xs', 'sm', 'default', 'lg' ] as const
6
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
7
7
 
8
8
  const meta = {
9
9
  title: 'UI/InputOtp',
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/vue3'
2
2
  import { useArgsModel } from '#storybook/argsModel'
3
3
  import InputPercent from './index.vue'
4
4
 
5
- const sizes = [ 'xs', 'sm', 'default', 'lg' ] as const
5
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
6
6
 
7
7
  const meta = {
8
8
  title: 'UI/InputPercent',
@@ -4,7 +4,7 @@ import { useArgsModel } from '#storybook/argsModel'
4
4
  import InputCurrency from '../InputCurrency/index.vue'
5
5
  import InputRange from './index.vue'
6
6
 
7
- const sizes = [ 'xs', 'sm', 'default', 'lg' ] as const
7
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
8
8
 
9
9
  const meta = {
10
10
  title: 'UI/InputRange',
@@ -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,7 +4,7 @@ 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', 'default', 'lg' ] as const
7
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
8
8
 
9
9
  // Mock data: 100 items for simulating server-side search
10
10
  const allItems = Array.from({ length: 100 }, (_, i) => ({
@@ -3,7 +3,7 @@ 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', 'default', 'lg' ] as const
6
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
7
7
 
8
8
  const frameworks = [
9
9
  { label: 'React', value: 'react' },
@@ -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 }})
@@ -0,0 +1,3 @@
1
+ {
2
+ "remove": "Remove"
3
+ }
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3'
2
2
  import type { TagColor, TagSize, TagVariant } from './types'
3
+ import EventLog from '#storybook/EventLog.vue'
3
4
  import Tag from './index.vue'
4
5
 
5
6
  const colors: TagColor[] = [ 'default', 'primary', 'success', 'info', 'help', 'warn', 'danger' ]
@@ -13,11 +14,15 @@ const meta = {
13
14
  color: { control: 'select', options: colors },
14
15
  variant: { control: 'select', options: variants },
15
16
  size: { control: 'select', options: sizes },
17
+ closable: { control: 'boolean' },
18
+ closeLabel: { control: 'text' },
16
19
  },
17
20
  args: {
18
21
  color: 'default',
19
22
  variant: 'soft',
20
23
  size: 'md',
24
+ closable: false,
25
+ closeLabel: '',
21
26
  },
22
27
  render: args => ({
23
28
  components: { Tag },
@@ -142,3 +147,143 @@ export const VariantColorMatrix: Story = {
142
147
  `,
143
148
  }),
144
149
  }
150
+
151
+ export const Closable: Story = {
152
+ parameters: noControls,
153
+ args: {
154
+ closable: true,
155
+ closeLabel: 'Remove filter',
156
+ },
157
+ }
158
+
159
+ export const ClosableSizes: Story = {
160
+ parameters: {
161
+ ...noControls,
162
+ docs: {
163
+ source: {
164
+ code: `
165
+ <template>
166
+ <div class="flex flex-wrap items-center gap-3">
167
+ <Tag v-for="s in sizes" :key="s" :size="s" closable>{{ s }}</Tag>
168
+ </div>
169
+ </template>
170
+ `.trim(),
171
+ },
172
+ },
173
+ },
174
+ render: () => ({
175
+ components: { Tag },
176
+ setup: () => ({ sizes }),
177
+ template: `
178
+ <div class="flex flex-wrap items-center gap-3">
179
+ <Tag v-for="s in sizes" :key="s" :size="s" closable>{{ s }}</Tag>
180
+ </div>
181
+ `,
182
+ }),
183
+ }
184
+
185
+ export const ClosableVariantColorMatrix: Story = {
186
+ parameters: {
187
+ ...noControls,
188
+ docs: {
189
+ source: {
190
+ code: `
191
+ <template>
192
+ <div class="space-y-3">
193
+ <div v-for="v in variants" :key="v" class="flex flex-wrap items-center gap-3">
194
+ <span class="w-20 text-sm text-muted-foreground">{{ v }}</span>
195
+ <Tag v-for="c in colors" :key="c" :color="c" :variant="v" closable>{{ c }}</Tag>
196
+ </div>
197
+ </div>
198
+ </template>
199
+ `.trim(),
200
+ },
201
+ },
202
+ },
203
+ render: () => ({
204
+ components: { Tag },
205
+ setup: () => ({ colors, variants }),
206
+ template: `
207
+ <div class="space-y-3">
208
+ <div v-for="v in variants" :key="v" class="flex flex-wrap items-center gap-3">
209
+ <span class="w-20 text-sm text-muted-foreground">{{ v }}</span>
210
+ <Tag v-for="c in colors" :key="c" :color="c" :variant="v" closable>{{ c }}</Tag>
211
+ </div>
212
+ </div>
213
+ `,
214
+ }),
215
+ }
216
+
217
+ export const EventHandling: Story = {
218
+ parameters: {
219
+ ...noControls,
220
+ docs: {
221
+ source: {
222
+ code: `
223
+ <script setup lang="ts">
224
+ const filters = ref([ 'Status: Active', 'Plan: Pro', 'Region: Tokyo' ])
225
+
226
+ function remove (name: string) {
227
+ filters.value = filters.value.filter(f => f !== name)
228
+ }
229
+ </script>
230
+
231
+ <template>
232
+ <div class="flex flex-wrap items-center gap-2">
233
+ <Tag
234
+ v-for="name in filters"
235
+ :key="name"
236
+ color="info"
237
+ class="rounded-full"
238
+ closable
239
+ :close-label="'Remove ' + name"
240
+ @close="remove(name)"
241
+ >
242
+ {{ name }}
243
+ </Tag>
244
+ </div>
245
+ </template>
246
+ `.trim(),
247
+ },
248
+ },
249
+ },
250
+ render: () => ({
251
+ components: { Tag, EventLog },
252
+ setup () {
253
+ const initial = [ 'Status: Active', 'Plan: Pro', 'Region: Tokyo' ]
254
+ const filters = ref([ ...initial ])
255
+ const remove = (name: string) => {
256
+ filters.value = filters.value.filter(f => f !== name)
257
+ }
258
+ const reset = () => {
259
+ filters.value = [ ...initial ]
260
+ }
261
+ return { filters, remove, reset }
262
+ },
263
+ template: `
264
+ <EventLog v-slot="{ record }">
265
+ <div class="flex flex-wrap items-center gap-2">
266
+ <Tag
267
+ v-for="name in filters"
268
+ :key="name"
269
+ color="info"
270
+ class="rounded-full"
271
+ closable
272
+ :close-label="'Remove ' + name"
273
+ @close="record('close', name); remove(name)"
274
+ >
275
+ {{ name }}
276
+ </Tag>
277
+ <button
278
+ v-if="!filters.length"
279
+ type="button"
280
+ class="text-sm text-muted-foreground underline"
281
+ @click="reset"
282
+ >
283
+ Reset
284
+ </button>
285
+ </div>
286
+ </EventLog>
287
+ `,
288
+ }),
289
+ }
@@ -106,17 +106,44 @@ const tagVariants = cva(
106
106
  },
107
107
  )
108
108
 
109
+ // Remove button: sized from the tag's own size so it fits the text line
110
+ // without touching the tag's padding. The negative end margin pulls it into
111
+ // the padding by a fixed amount, offsetting the whitespace around the × glyph
112
+ // so both sides look even whatever padding the tag has. Colors derive from
113
+ // `currentColor`, so hover / focus follow every color × variant combination.
114
+ const closeClass = `
115
+ -me-1 inline-flex shrink-0 cursor-pointer items-center justify-center
116
+ rounded-full
117
+ opacity-60 transition
118
+ hover:bg-current/15 hover:opacity-100
119
+ focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-current/50
120
+ focus-visible:outline-none
121
+ `
122
+
123
+ const closeSizes = {
124
+ sm: { button: 'size-3.5', icon: 'size-2.5' },
125
+ md: { button: 'size-4', icon: 'size-3' },
126
+ } as const
127
+
109
128
  const props = withDefaults(defineProps<TagProps>(), {
110
129
  color: 'default',
111
130
  variant: 'soft',
112
131
  size: 'md',
132
+ closable: false,
133
+ closeLabel: undefined,
113
134
  class: undefined,
114
135
  })
115
136
 
137
+ const emit = defineEmits<{
138
+ close: [event: MouseEvent]
139
+ }>()
140
+
116
141
  defineSlots<{
117
142
  default?: () => any
118
143
  }>()
119
144
 
145
+ const T = useTranslations('components.ui.Tag')
146
+
120
147
  const mergedClass = computed(() =>
121
148
  cn(tagVariants({ color: props.color, variant: props.variant, size: props.size }), props.class),
122
149
  )
@@ -125,5 +152,18 @@ const mergedClass = computed(() =>
125
152
  <template>
126
153
  <span :class="mergedClass">
127
154
  <slot />
155
+ <button
156
+ v-if="closable"
157
+ type="button"
158
+ data-slot="tag-close"
159
+ :class="[ closeClass, closeSizes[size].button ]"
160
+ :aria-label="closeLabel || T('remove')"
161
+ @click="emit('close', $event)"
162
+ >
163
+ <Icon
164
+ name="x"
165
+ :class="closeSizes[size].icon"
166
+ />
167
+ </button>
128
168
  </span>
129
169
  </template>
@@ -6,5 +6,9 @@ export interface TagProps {
6
6
  color?: TagColor
7
7
  variant?: TagVariant
8
8
  size?: TagSize
9
+ /** Render a remove (×) button after the content; clicking it emits `close`. */
10
+ closable?: boolean
11
+ /** Accessible name of the remove button. Defaults to the localized "Remove". */
12
+ closeLabel?: string
9
13
  class?: ClassValue
10
14
  }
@@ -3,7 +3,7 @@ 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', 'default', 'lg' ] as const
6
+ const sizes = [ 'xs', 'sm', 'md', 'default', 'lg' ] as const
7
7
 
8
8
  const meta = {
9
9
  title: 'UI/Textarea',
@@ -2,4 +2,4 @@
2
2
  * Size tier shared by input-like components. The dimensions of each tier live in
3
3
  * `assets/styles/tailwind-utilities.css` (`data-control-size`).
4
4
  */
5
- export type ControlSize = 'xs' | 'sm' | 'default' | 'lg'
5
+ export type ControlSize = 'xs' | 'sm' | 'md' | 'default' | 'lg'
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "الإجراءات"
91
91
  },
92
+ "Tag": {
93
+ "remove": "إزالة"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} أسطر"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "Aktionen"
91
91
  },
92
+ "Tag": {
93
+ "remove": "Entfernen"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} Zeilen"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "Actions"
91
91
  },
92
+ "Tag": {
93
+ "remove": "Remove"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} lines"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "Acciones"
91
91
  },
92
+ "Tag": {
93
+ "remove": "Eliminar"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} líneas"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "Actions"
91
91
  },
92
+ "Tag": {
93
+ "remove": "Supprimer"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} lignes"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "क्रियाएं"
91
91
  },
92
+ "Tag": {
93
+ "remove": "हटाएं"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} पंक्तियाँ"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "Tindakan"
91
91
  },
92
+ "Tag": {
93
+ "remove": "Hapus"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} baris"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "Azioni"
91
91
  },
92
+ "Tag": {
93
+ "remove": "Rimuovi"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} righe"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "アクション"
91
91
  },
92
+ "Tag": {
93
+ "remove": "削除"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} 行"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "작업"
91
91
  },
92
+ "Tag": {
93
+ "remove": "제거"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count}줄"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "Acties"
91
91
  },
92
+ "Tag": {
93
+ "remove": "Verwijderen"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} regels"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "Akcje"
91
91
  },
92
+ "Tag": {
93
+ "remove": "Usuń"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} wierszy"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "Ações"
91
91
  },
92
+ "Tag": {
93
+ "remove": "Remover"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} linhas"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "Действия"
91
91
  },
92
+ "Tag": {
93
+ "remove": "Удалить"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} строк"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "การกระทำ"
91
91
  },
92
+ "Tag": {
93
+ "remove": "ลบ"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} บรรทัด"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "İşlemler"
91
91
  },
92
+ "Tag": {
93
+ "remove": "Kaldır"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} satır"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "Hành động"
91
91
  },
92
+ "Tag": {
93
+ "remove": "Xóa"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} dòng"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "操作"
91
91
  },
92
+ "Tag": {
93
+ "remove": "移除"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} 行"
94
97
  },
@@ -89,6 +89,9 @@
89
89
  "StaticDataTable": {
90
90
  "actions": "操作"
91
91
  },
92
+ "Tag": {
93
+ "remove": "移除"
94
+ },
92
95
  "Textarea": {
93
96
  "lines": "{count} 行"
94
97
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bjj/nuxt-layer-shadcn-ui",
3
- "version": "0.15.18",
3
+ "version": "0.16.1",
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": "0c84491b9818c6a70c405a58b01cd44a43f71cbd"
45
+ "gitHead": "50e38d338fe80994bb04b57f1d9865ab830fe289"
46
46
  }