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

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 (36) hide show
  1. package/app/assets/styles/controlSize.stories.ts +121 -0
  2. package/app/assets/styles/tailwind-utilities.css +81 -0
  3. package/app/components/ui/Button/index.stories.ts +11 -7
  4. package/app/components/ui/Button/index.vue +36 -6
  5. package/app/components/ui/Button/types.ts +7 -1
  6. package/app/components/ui/DatePicker/index.stories.ts +33 -0
  7. package/app/components/ui/DatePicker/index.vue +2 -0
  8. package/app/components/ui/DatePicker/types.ts +4 -0
  9. package/app/components/ui/DateRangePicker/index.stories.ts +31 -0
  10. package/app/components/ui/DateRangePicker/index.vue +3 -0
  11. package/app/components/ui/DateRangePicker/types.ts +3 -0
  12. package/app/components/ui/Input/index.stories.ts +33 -0
  13. package/app/components/ui/Input/index.vue +39 -3
  14. package/app/components/ui/Input/types.ts +4 -0
  15. package/app/components/ui/InputCurrency/index.stories.ts +31 -0
  16. package/app/components/ui/InputCurrency/types.ts +1 -1
  17. package/app/components/ui/InputNumber/index.stories.ts +63 -0
  18. package/app/components/ui/InputNumber/index.vue +24 -11
  19. package/app/components/ui/InputNumber/types.ts +4 -0
  20. package/app/components/ui/InputOtp/index.stories.ts +31 -0
  21. package/app/components/ui/InputOtp/index.vue +6 -1
  22. package/app/components/ui/InputOtp/types.ts +4 -0
  23. package/app/components/ui/InputPercent/index.stories.ts +31 -0
  24. package/app/components/ui/InputPercent/types.ts +1 -1
  25. package/app/components/ui/InputRange/index.stories.ts +31 -0
  26. package/app/components/ui/SearchSelect/index.stories.ts +33 -0
  27. package/app/components/ui/SearchSelect/index.vue +3 -1
  28. package/app/components/ui/SearchSelect/types.ts +3 -0
  29. package/app/components/ui/Select/index.stories.ts +33 -0
  30. package/app/components/ui/Select/index.vue +20 -7
  31. package/app/components/ui/Select/types.ts +4 -0
  32. package/app/components/ui/Textarea/index.stories.ts +31 -0
  33. package/app/components/ui/Textarea/index.vue +11 -2
  34. package/app/components/ui/Textarea/types.ts +4 -0
  35. package/app/types/control.ts +5 -0
  36. package/package.json +2 -2
@@ -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', '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
@@ -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', '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' | 'default' | 'lg'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bjj/nuxt-layer-shadcn-ui",
3
- "version": "0.15.16",
3
+ "version": "0.15.18",
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": "c6e590a0ab1cec58c0b5564751f15a88296f7377"
45
+ "gitHead": "0c84491b9818c6a70c405a58b01cd44a43f71cbd"
46
46
  }