@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.
- package/app/assets/styles/controlSize.stories.ts +121 -0
- package/app/assets/styles/tailwind-utilities.css +81 -0
- package/app/components/ui/Button/index.stories.ts +11 -7
- package/app/components/ui/Button/index.vue +36 -6
- package/app/components/ui/Button/types.ts +7 -1
- package/app/components/ui/DatePicker/index.stories.ts +33 -0
- package/app/components/ui/DatePicker/index.vue +2 -0
- package/app/components/ui/DatePicker/types.ts +4 -0
- package/app/components/ui/DateRangePicker/index.stories.ts +31 -0
- package/app/components/ui/DateRangePicker/index.vue +3 -0
- package/app/components/ui/DateRangePicker/types.ts +3 -0
- package/app/components/ui/Input/index.stories.ts +33 -0
- package/app/components/ui/Input/index.vue +39 -3
- package/app/components/ui/Input/types.ts +4 -0
- package/app/components/ui/InputCurrency/index.stories.ts +31 -0
- package/app/components/ui/InputCurrency/types.ts +1 -1
- package/app/components/ui/InputNumber/index.stories.ts +63 -0
- package/app/components/ui/InputNumber/index.vue +24 -11
- package/app/components/ui/InputNumber/types.ts +4 -0
- package/app/components/ui/InputOtp/index.stories.ts +31 -0
- package/app/components/ui/InputOtp/index.vue +6 -1
- package/app/components/ui/InputOtp/types.ts +4 -0
- package/app/components/ui/InputPercent/index.stories.ts +31 -0
- package/app/components/ui/InputPercent/types.ts +1 -1
- package/app/components/ui/InputRange/index.stories.ts +31 -0
- package/app/components/ui/SearchSelect/index.stories.ts +33 -0
- package/app/components/ui/SearchSelect/index.vue +3 -1
- package/app/components/ui/SearchSelect/types.ts +3 -0
- package/app/components/ui/Select/index.stories.ts +33 -0
- package/app/components/ui/Select/index.vue +20 -7
- package/app/components/ui/Select/types.ts +4 -0
- package/app/components/ui/Textarea/index.stories.ts +31 -0
- package/app/components/ui/Textarea/index.vue +11 -2
- package/app/components/ui/Textarea/types.ts +4 -0
- package/app/types/control.ts +5 -0
- package/package.json +2 -2
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
+
import Button from '../../components/ui/Button/index.vue'
|
|
3
|
+
import DatePicker from '../../components/ui/DatePicker/index.vue'
|
|
4
|
+
import Icon from '../../components/ui/Icon/index.vue'
|
|
5
|
+
import Input from '../../components/ui/Input/index.vue'
|
|
6
|
+
import InputNumber from '../../components/ui/InputNumber/index.vue'
|
|
7
|
+
import Select from '../../components/ui/Select/index.vue'
|
|
8
|
+
import Textarea from '../../components/ui/Textarea/index.vue'
|
|
9
|
+
|
|
10
|
+
const sizes = [ 'xs', 'sm', 'default', 'lg' ] as const
|
|
11
|
+
|
|
12
|
+
const options = [
|
|
13
|
+
{ label: 'Nuxt', value: 'nuxt' },
|
|
14
|
+
{ label: 'Vue', value: 'vue' },
|
|
15
|
+
{ label: 'Vite', value: 'vite' },
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
const meta = {
|
|
19
|
+
title: 'Theme/Control Size',
|
|
20
|
+
parameters: {
|
|
21
|
+
docs: {
|
|
22
|
+
description: {
|
|
23
|
+
component: 'Size tiers shared by form controls (inputs, selects, pickers, buttons). Each tier sets height, font size, padding, icon and inner button size through `data-control-size`; a control without its own `size` follows the nearest ancestor.',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
} satisfies Meta
|
|
28
|
+
|
|
29
|
+
export default meta
|
|
30
|
+
type Story = StoryObj<typeof meta>
|
|
31
|
+
|
|
32
|
+
export const Tiers: Story = {
|
|
33
|
+
parameters: {
|
|
34
|
+
docs: {
|
|
35
|
+
source: {
|
|
36
|
+
code: `
|
|
37
|
+
<template>
|
|
38
|
+
<Input v-model="text" size="sm" />
|
|
39
|
+
<InputNumber v-model="count" size="sm" />
|
|
40
|
+
<Select v-model="framework" :options="options" size="sm" />
|
|
41
|
+
<Button size="sm" icon="search">Search</Button>
|
|
42
|
+
<Button size="icon-sm" variant="outline" icon="settings" />
|
|
43
|
+
</template>
|
|
44
|
+
`.trim(),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
render: () => ({
|
|
49
|
+
components: { Button, DatePicker, Icon, Input, InputNumber, Select },
|
|
50
|
+
setup: () => ({
|
|
51
|
+
sizes,
|
|
52
|
+
iconSize: (s: typeof sizes[number]) => s === 'default' ? 'icon' : `icon-${s}`,
|
|
53
|
+
options,
|
|
54
|
+
text: ref('Hello'),
|
|
55
|
+
count: ref(10),
|
|
56
|
+
framework: ref('nuxt'),
|
|
57
|
+
date: ref(new Date(2026, 10, 20)),
|
|
58
|
+
}),
|
|
59
|
+
template: `
|
|
60
|
+
<div class="space-y-3">
|
|
61
|
+
<div v-for="s in sizes" :key="s" class="flex flex-wrap items-center gap-3">
|
|
62
|
+
<span class="w-14 text-sm text-muted-foreground">{{ s }}</span>
|
|
63
|
+
<Input v-model="text" :size="s" class="w-44">
|
|
64
|
+
<template #prefix><Icon name="search" /></template>
|
|
65
|
+
</Input>
|
|
66
|
+
<InputNumber v-model="count" :size="s" class="w-36" />
|
|
67
|
+
<div class="w-40">
|
|
68
|
+
<Select v-model="framework" :options="options" :size="s" />
|
|
69
|
+
</div>
|
|
70
|
+
<div class="w-44">
|
|
71
|
+
<DatePicker v-model="date" :size="s" />
|
|
72
|
+
</div>
|
|
73
|
+
<Button :size="s" icon="search">Search</Button>
|
|
74
|
+
<Button :size="iconSize(s)" variant="outline" icon="settings" />
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
`,
|
|
78
|
+
}),
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const InheritedFromAncestor: Story = {
|
|
82
|
+
parameters: {
|
|
83
|
+
docs: {
|
|
84
|
+
source: {
|
|
85
|
+
code: `
|
|
86
|
+
<template>
|
|
87
|
+
<form data-control-size="xs">
|
|
88
|
+
<Input v-model="name" />
|
|
89
|
+
<InputNumber v-model="count" />
|
|
90
|
+
<Select v-model="framework" :options="options" />
|
|
91
|
+
<Textarea v-model="note" />
|
|
92
|
+
<Button icon="check">Save</Button>
|
|
93
|
+
</form>
|
|
94
|
+
</template>
|
|
95
|
+
`.trim(),
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
render: () => ({
|
|
100
|
+
components: { Button, Input, InputNumber, Select, Textarea },
|
|
101
|
+
setup: () => ({
|
|
102
|
+
options,
|
|
103
|
+
name: ref('Lot A'),
|
|
104
|
+
count: ref(10),
|
|
105
|
+
framework: ref('vue'),
|
|
106
|
+
note: ref('Every control inside follows the form tier.'),
|
|
107
|
+
}),
|
|
108
|
+
template: `
|
|
109
|
+
<div data-control-size="xs" class="grid max-w-sm gap-2">
|
|
110
|
+
<Input v-model="name" />
|
|
111
|
+
<InputNumber v-model="count" />
|
|
112
|
+
<Select v-model="framework" :options="options" />
|
|
113
|
+
<Textarea v-model="note" />
|
|
114
|
+
<div class="flex justify-end gap-2">
|
|
115
|
+
<Button variant="outline">Cancel</Button>
|
|
116
|
+
<Button icon="check">Save</Button>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
`,
|
|
120
|
+
}),
|
|
121
|
+
}
|
|
@@ -21,3 +21,84 @@
|
|
|
21
21
|
to { height: 0; }
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
* Form control size scale, shared by every form control (inputs, selects,
|
|
27
|
+
* pickers, buttons …).
|
|
28
|
+
*
|
|
29
|
+
* A control opts in by reading these variables (`h-(--control-height)`,
|
|
30
|
+
* `px-(--control-px)` …) and sets a tier with `data-control-size`. The attribute
|
|
31
|
+
* cascades: a control without its own `size` follows the nearest ancestor that
|
|
32
|
+
* sets one, so a whole form can switch tiers at once. `default` is the
|
|
33
|
+
* pre-existing look and applies when no ancestor sets a tier.
|
|
34
|
+
*
|
|
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
|
|
38
|
+
* default 36 14 12 8 16 12 24 16 12
|
|
39
|
+
* lg 40 14 16 8 16 14 28 24 16
|
|
40
|
+
*
|
|
41
|
+
* --control-px inline padding at an input's outer edges
|
|
42
|
+
* --control-gap tighter padding where the value meets an addon; gap between button content
|
|
43
|
+
* --control-stepper-px inline padding of InputNumber's −/+ steppers
|
|
44
|
+
* --control-addon-button-size square icon buttons inside an input (clear …)
|
|
45
|
+
* --control-button-px inline padding of a text Button
|
|
46
|
+
* --control-button-icon-px the same when an icon is the button's direct child
|
|
47
|
+
*
|
|
48
|
+
* Icon-only buttons are squares of `--control-height`.
|
|
49
|
+
*
|
|
50
|
+
* Components whose default font is `text-base md:text-sm` (Input, Select,
|
|
51
|
+
* Textarea …) keep 16px below `md` to avoid iOS focus zoom and apply
|
|
52
|
+
* `--control-font-size` from `md` up.
|
|
53
|
+
*/
|
|
54
|
+
@layer base {
|
|
55
|
+
:root,
|
|
56
|
+
[data-control-size='default'] {
|
|
57
|
+
--control-height: --spacing(9);
|
|
58
|
+
--control-font-size: --theme(--text-sm);
|
|
59
|
+
--control-line-height: --theme(--text-sm--line-height);
|
|
60
|
+
--control-px: --spacing(3);
|
|
61
|
+
--control-gap: --spacing(2);
|
|
62
|
+
--control-icon: --spacing(4);
|
|
63
|
+
--control-stepper-px: --spacing(3);
|
|
64
|
+
--control-addon-button-size: --spacing(6);
|
|
65
|
+
--control-button-px: --spacing(4);
|
|
66
|
+
--control-button-icon-px: --spacing(3);
|
|
67
|
+
}
|
|
68
|
+
[data-control-size='xs'] {
|
|
69
|
+
--control-height: --spacing(7);
|
|
70
|
+
--control-font-size: --theme(--text-xs);
|
|
71
|
+
--control-line-height: --theme(--text-xs--line-height);
|
|
72
|
+
--control-px: --spacing(2);
|
|
73
|
+
--control-gap: --spacing(1);
|
|
74
|
+
--control-icon: --spacing(3.5);
|
|
75
|
+
--control-stepper-px: --spacing(1);
|
|
76
|
+
--control-addon-button-size: --spacing(5);
|
|
77
|
+
--control-button-px: --spacing(2.5);
|
|
78
|
+
--control-button-icon-px: --spacing(2);
|
|
79
|
+
}
|
|
80
|
+
[data-control-size='sm'] {
|
|
81
|
+
--control-height: --spacing(8);
|
|
82
|
+
--control-font-size: --theme(--text-sm);
|
|
83
|
+
--control-line-height: --theme(--text-sm--line-height);
|
|
84
|
+
--control-px: --spacing(2.5);
|
|
85
|
+
--control-gap: --spacing(1.5);
|
|
86
|
+
--control-icon: --spacing(4);
|
|
87
|
+
--control-stepper-px: --spacing(1.5);
|
|
88
|
+
--control-addon-button-size: --spacing(6);
|
|
89
|
+
--control-button-px: --spacing(3);
|
|
90
|
+
--control-button-icon-px: --spacing(2.5);
|
|
91
|
+
}
|
|
92
|
+
[data-control-size='lg'] {
|
|
93
|
+
--control-height: --spacing(10);
|
|
94
|
+
--control-font-size: --theme(--text-sm);
|
|
95
|
+
--control-line-height: --theme(--text-sm--line-height);
|
|
96
|
+
--control-px: --spacing(4);
|
|
97
|
+
--control-gap: --spacing(2);
|
|
98
|
+
--control-icon: --spacing(4);
|
|
99
|
+
--control-stepper-px: --spacing(3.5);
|
|
100
|
+
--control-addon-button-size: --spacing(7);
|
|
101
|
+
--control-button-px: --spacing(6);
|
|
102
|
+
--control-button-icon-px: --spacing(4);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -15,9 +15,11 @@ const variants = [
|
|
|
15
15
|
] as const satisfies readonly ButtonVariant[]
|
|
16
16
|
|
|
17
17
|
const sizes = [
|
|
18
|
+
'xs',
|
|
18
19
|
'sm',
|
|
19
20
|
'default',
|
|
20
21
|
'lg',
|
|
22
|
+
'icon-xs',
|
|
21
23
|
'icon-sm',
|
|
22
24
|
'icon',
|
|
23
25
|
'icon-lg',
|
|
@@ -110,12 +112,14 @@ export const Sizes: Story = {
|
|
|
110
112
|
source: {
|
|
111
113
|
code: `
|
|
112
114
|
<template>
|
|
115
|
+
<Button size="xs">xs</Button>
|
|
113
116
|
<Button size="sm">sm</Button>
|
|
114
117
|
<Button size="default">default</Button>
|
|
115
118
|
<Button size="lg">lg</Button>
|
|
116
|
-
<Button size="icon-
|
|
117
|
-
<Button size="icon"
|
|
118
|
-
<Button size="icon
|
|
119
|
+
<Button size="icon-xs" icon="plus" />
|
|
120
|
+
<Button size="icon-sm" icon="plus" />
|
|
121
|
+
<Button size="icon" icon="plus" />
|
|
122
|
+
<Button size="icon-lg" icon="plus" />
|
|
119
123
|
</template>
|
|
120
124
|
`.trim(),
|
|
121
125
|
},
|
|
@@ -126,10 +130,10 @@ export const Sizes: Story = {
|
|
|
126
130
|
setup: () => ({ sizes }),
|
|
127
131
|
template: `
|
|
128
132
|
<div class="flex flex-wrap items-center gap-3">
|
|
129
|
-
<
|
|
130
|
-
<
|
|
131
|
-
<
|
|
132
|
-
</
|
|
133
|
+
<template v-for="s in sizes" :key="s">
|
|
134
|
+
<Button v-if="s.startsWith('icon')" :size="s" icon="plus" />
|
|
135
|
+
<Button v-else :size="s">{{ s }}</Button>
|
|
136
|
+
</template>
|
|
133
137
|
</div>
|
|
134
138
|
`,
|
|
135
139
|
}),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { Button as ShadcnButton } from '../../shadcn/button'
|
|
3
3
|
import WebLink from '@bjj/nuxt-layer-shadcn-ui/app/components/ui/WebLink/index.vue'
|
|
4
|
+
import type { ControlSize } from '../../../types/control'
|
|
4
5
|
import type { ButtonProps } from './types'
|
|
5
6
|
|
|
6
7
|
const props = defineProps<ButtonProps>()
|
|
@@ -23,8 +24,31 @@ const variantClasses: Partial<Record<NonNullable<ButtonVariant>, string>> = {
|
|
|
23
24
|
link: 'text-current',
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
const isIconOnly = computed(() => props.size?.startsWith('icon') ?? false)
|
|
28
|
+
|
|
29
|
+
// `icon` is the default tier; `icon-sm` → `sm` …
|
|
30
|
+
const tier = computed<ControlSize | undefined>(() => {
|
|
31
|
+
if (!props.size) return undefined
|
|
32
|
+
if (props.size === 'icon') return 'default'
|
|
33
|
+
return props.size.replace('icon-', '') as ControlSize
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
// Dimensions come from the shared control scale (see `data-control-size`) so a
|
|
37
|
+
// button lines up with the inputs of the same tier.
|
|
38
|
+
const sizeClass = computed(() => isIconOnly.value
|
|
39
|
+
? 'size-(--control-height) p-0 has-[>svg]:p-0'
|
|
40
|
+
: `
|
|
41
|
+
h-(--control-height) gap-(--control-gap) px-(--control-button-px)
|
|
42
|
+
has-[>svg]:px-(--control-button-icon-px)
|
|
43
|
+
`,
|
|
44
|
+
)
|
|
45
|
+
|
|
26
46
|
const mergedClass = computed(() => cn(
|
|
27
|
-
|
|
47
|
+
`
|
|
48
|
+
cursor-pointer text-(length:--control-font-size)
|
|
49
|
+
leading-(--control-line-height)
|
|
50
|
+
`,
|
|
51
|
+
sizeClass.value,
|
|
28
52
|
props.variant && variantClasses[props.variant],
|
|
29
53
|
props.rounded && 'rounded-full',
|
|
30
54
|
props.class,
|
|
@@ -42,7 +66,7 @@ const slots = defineSlots<{
|
|
|
42
66
|
<template>
|
|
43
67
|
<ShadcnButton
|
|
44
68
|
:variant="variant"
|
|
45
|
-
:size="
|
|
69
|
+
:data-control-size="tier"
|
|
46
70
|
:class="mergedClass"
|
|
47
71
|
:asChild="isLink"
|
|
48
72
|
:type="isLink ? undefined : 'button'"
|
|
@@ -58,13 +82,16 @@ const slots = defineSlots<{
|
|
|
58
82
|
<Icon
|
|
59
83
|
v-if="loading"
|
|
60
84
|
name="loader-circle"
|
|
61
|
-
class="animate-spin"
|
|
85
|
+
class="animate-spin size-(--control-icon)"
|
|
62
86
|
/>
|
|
63
87
|
<slot
|
|
64
88
|
v-else-if="hasIcon"
|
|
65
89
|
name="icon"
|
|
66
90
|
>
|
|
67
|
-
<Icon
|
|
91
|
+
<Icon
|
|
92
|
+
:name="icon!"
|
|
93
|
+
class="size-(--control-icon)"
|
|
94
|
+
/>
|
|
68
95
|
</slot>
|
|
69
96
|
</template>
|
|
70
97
|
<slot />
|
|
@@ -73,13 +100,16 @@ const slots = defineSlots<{
|
|
|
73
100
|
<Icon
|
|
74
101
|
v-if="loading"
|
|
75
102
|
name="loader-circle"
|
|
76
|
-
class="animate-spin"
|
|
103
|
+
class="animate-spin size-(--control-icon)"
|
|
77
104
|
/>
|
|
78
105
|
<slot
|
|
79
106
|
v-else-if="hasIcon"
|
|
80
107
|
name="icon"
|
|
81
108
|
>
|
|
82
|
-
<Icon
|
|
109
|
+
<Icon
|
|
110
|
+
:name="icon!"
|
|
111
|
+
class="size-(--control-icon)"
|
|
112
|
+
/>
|
|
83
113
|
</slot>
|
|
84
114
|
</template>
|
|
85
115
|
</component>
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { ButtonVariants } from '../../shadcn/button'
|
|
2
|
+
import type { ControlSize } from '../../../types/control'
|
|
2
3
|
import type { Component } from 'vue'
|
|
3
4
|
import type { RouteLocationRaw } from 'vue-router'
|
|
4
5
|
|
|
5
6
|
export type ButtonVariant = ButtonVariants['variant']
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* A control size tier for text buttons, or `icon-<tier>` for a square icon-only
|
|
9
|
+
* button (`icon` is the `default` tier). Heights match the inputs of the same tier.
|
|
10
|
+
*/
|
|
11
|
+
export type ButtonSize = ControlSize | 'icon-xs' | 'icon-sm' | 'icon' | 'icon-lg'
|
|
7
12
|
|
|
8
13
|
export interface ButtonProps {
|
|
9
14
|
variant?: ButtonVariant
|
|
15
|
+
/** Size tier. Unset follows the nearest ancestor's `data-control-size`, else `default`. */
|
|
10
16
|
size?: ButtonSize
|
|
11
17
|
loading?: boolean
|
|
12
18
|
disabled?: boolean
|
|
@@ -5,6 +5,8 @@ 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
|
|
9
|
+
|
|
8
10
|
const types: DatePickerType[] = [ 'date', 'month', 'year' ]
|
|
9
11
|
|
|
10
12
|
const meta = {
|
|
@@ -14,6 +16,7 @@ const meta = {
|
|
|
14
16
|
modelValue: { control: 'date' },
|
|
15
17
|
type: { control: 'select', options: types },
|
|
16
18
|
showTime: { control: 'boolean' },
|
|
19
|
+
size: { control: 'select', options: sizes },
|
|
17
20
|
disabled: { control: 'boolean' },
|
|
18
21
|
readonly: { control: 'boolean' },
|
|
19
22
|
invalid: { control: 'boolean' },
|
|
@@ -28,6 +31,7 @@ const meta = {
|
|
|
28
31
|
modelValue: null,
|
|
29
32
|
type: 'date',
|
|
30
33
|
showTime: false,
|
|
34
|
+
size: 'default',
|
|
31
35
|
disabled: false,
|
|
32
36
|
readonly: false,
|
|
33
37
|
invalid: false,
|
|
@@ -180,6 +184,35 @@ export const ValueFormat: Story = {
|
|
|
180
184
|
}),
|
|
181
185
|
}
|
|
182
186
|
|
|
187
|
+
export const Sizes: Story = {
|
|
188
|
+
parameters: {
|
|
189
|
+
...noControls,
|
|
190
|
+
docs: {
|
|
191
|
+
source: {
|
|
192
|
+
code: `
|
|
193
|
+
<template>
|
|
194
|
+
<DatePicker v-model="value" size="sm" />
|
|
195
|
+
</template>
|
|
196
|
+
`.trim(),
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
render: () => ({
|
|
201
|
+
components: { DatePicker },
|
|
202
|
+
setup: () => ({ sizes, value: ref(new Date(2026, 10, 20)) }),
|
|
203
|
+
template: `
|
|
204
|
+
<div class="space-y-3">
|
|
205
|
+
<div v-for="s in sizes" :key="s" class="flex items-center gap-3">
|
|
206
|
+
<span class="w-14 text-sm text-muted-foreground">{{ s }}</span>
|
|
207
|
+
<div class="w-64">
|
|
208
|
+
<DatePicker v-model="value" :size="s" />
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
`,
|
|
213
|
+
}),
|
|
214
|
+
}
|
|
215
|
+
|
|
183
216
|
export const Disabled: Story = {
|
|
184
217
|
parameters: {
|
|
185
218
|
...noControls,
|
|
@@ -22,6 +22,7 @@ const props = withDefaults(defineProps<DatePickerProps>(), {
|
|
|
22
22
|
readonly: false,
|
|
23
23
|
invalid: false,
|
|
24
24
|
placeholder: undefined,
|
|
25
|
+
size: undefined,
|
|
25
26
|
minDate: undefined,
|
|
26
27
|
maxDate: undefined,
|
|
27
28
|
valueFormat: undefined,
|
|
@@ -90,6 +91,7 @@ const timeConfig = computed(() => {
|
|
|
90
91
|
<Input
|
|
91
92
|
:modelValue="value"
|
|
92
93
|
:placeholder="placeholder || T('placeholder')"
|
|
94
|
+
:size="size"
|
|
93
95
|
:disabled="disabled"
|
|
94
96
|
:readonly="readonly"
|
|
95
97
|
@update:modelValue="(v: string | undefined) => onInput(v ?? '')"
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ControlSize } from '../../../types/control'
|
|
2
|
+
|
|
1
3
|
export interface DatePickerTimeConfig {
|
|
2
4
|
enableSeconds?: boolean
|
|
3
5
|
enableMinutes?: boolean
|
|
@@ -31,6 +33,8 @@ export interface DatePickerProps {
|
|
|
31
33
|
invalid?: boolean
|
|
32
34
|
/** Placeholder text */
|
|
33
35
|
placeholder?: string
|
|
36
|
+
/** Size tier. Unset follows the nearest ancestor's `data-control-size`, else `default`. */
|
|
37
|
+
size?: ControlSize
|
|
34
38
|
/** Minimum selectable date */
|
|
35
39
|
minDate?: Date | string
|
|
36
40
|
/** Maximum selectable date */
|
|
@@ -2,6 +2,8 @@ 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
|
|
6
|
+
|
|
5
7
|
const meta = {
|
|
6
8
|
title: 'UI/DateRangePicker',
|
|
7
9
|
component: DateRangePicker,
|
|
@@ -11,6 +13,7 @@ const meta = {
|
|
|
11
13
|
minDate: { control: 'date' },
|
|
12
14
|
maxDate: { control: 'date' },
|
|
13
15
|
showTime: { control: 'boolean' },
|
|
16
|
+
size: { control: 'select', options: sizes },
|
|
14
17
|
disabled: { control: 'boolean' },
|
|
15
18
|
readonly: { control: 'boolean' },
|
|
16
19
|
invalid: { control: 'boolean' },
|
|
@@ -27,6 +30,7 @@ const meta = {
|
|
|
27
30
|
minDate: undefined,
|
|
28
31
|
maxDate: undefined,
|
|
29
32
|
showTime: false,
|
|
33
|
+
size: 'default',
|
|
30
34
|
disabled: false,
|
|
31
35
|
readonly: false,
|
|
32
36
|
invalid: false,
|
|
@@ -151,6 +155,33 @@ export const Preselected: Story = {
|
|
|
151
155
|
}),
|
|
152
156
|
}
|
|
153
157
|
|
|
158
|
+
export const Sizes: Story = {
|
|
159
|
+
parameters: {
|
|
160
|
+
...noControls,
|
|
161
|
+
docs: {
|
|
162
|
+
source: {
|
|
163
|
+
code: `
|
|
164
|
+
<template>
|
|
165
|
+
<DateRangePicker v-model:start="start" v-model:end="end" size="sm" />
|
|
166
|
+
</template>
|
|
167
|
+
`.trim(),
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
render: () => ({
|
|
172
|
+
components: { DateRangePicker },
|
|
173
|
+
setup: () => ({ sizes, start: ref(new Date(2026, 10, 1)), end: ref(new Date(2026, 10, 20)) }),
|
|
174
|
+
template: `
|
|
175
|
+
<div class="space-y-3">
|
|
176
|
+
<div v-for="s in sizes" :key="s" class="flex items-center gap-3">
|
|
177
|
+
<span class="w-14 text-sm text-muted-foreground">{{ s }}</span>
|
|
178
|
+
<DateRangePicker v-model:start="start" v-model:end="end" :size="s" class="w-120" />
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
`,
|
|
182
|
+
}),
|
|
183
|
+
}
|
|
184
|
+
|
|
154
185
|
export const Disabled: Story = {
|
|
155
186
|
parameters: {
|
|
156
187
|
...noControls,
|
|
@@ -16,6 +16,7 @@ const props = withDefaults(defineProps<DateRangePickerProps>(), {
|
|
|
16
16
|
minDate: undefined,
|
|
17
17
|
maxDate: undefined,
|
|
18
18
|
maxSpanDays: undefined,
|
|
19
|
+
size: undefined,
|
|
19
20
|
valueFormat: undefined,
|
|
20
21
|
autoApply: true,
|
|
21
22
|
class: undefined,
|
|
@@ -135,6 +136,7 @@ const endMaxDate = computed(() => {
|
|
|
135
136
|
<DatePicker
|
|
136
137
|
v-model="start"
|
|
137
138
|
:showTime="showTime"
|
|
139
|
+
:size="size"
|
|
138
140
|
:disabled="disabled"
|
|
139
141
|
:readonly="readonly"
|
|
140
142
|
:placeholder="startPlaceholder || T('startPlaceholder')"
|
|
@@ -150,6 +152,7 @@ const endMaxDate = computed(() => {
|
|
|
150
152
|
<DatePicker
|
|
151
153
|
v-model="end"
|
|
152
154
|
:showTime="showTime"
|
|
155
|
+
:size="size"
|
|
153
156
|
:disabled="disabled"
|
|
154
157
|
:readonly="readonly"
|
|
155
158
|
:placeholder="endPlaceholder || T('endPlaceholder')"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ControlSize } from '../../../types/control'
|
|
1
2
|
import type { DatePickerTimeConfig } from '../DatePicker/types'
|
|
2
3
|
|
|
3
4
|
export interface DateRangePickerProps {
|
|
@@ -27,6 +28,8 @@ export interface DateRangePickerProps {
|
|
|
27
28
|
startPlaceholder?: string
|
|
28
29
|
/** Placeholder for end date input */
|
|
29
30
|
endPlaceholder?: string
|
|
31
|
+
/** Size tier. Unset follows the nearest ancestor's `data-control-size`, else `default`. */
|
|
32
|
+
size?: ControlSize
|
|
30
33
|
/** Maximum span in days between start and end date */
|
|
31
34
|
maxSpanDays?: number
|
|
32
35
|
/**
|
|
@@ -4,6 +4,8 @@ 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
|
|
8
|
+
|
|
7
9
|
const meta = {
|
|
8
10
|
title: 'UI/Input',
|
|
9
11
|
component: Input,
|
|
@@ -12,6 +14,7 @@ const meta = {
|
|
|
12
14
|
autocomplete: { control: 'text' },
|
|
13
15
|
maxlength: { control: 'number' },
|
|
14
16
|
showCount: { control: 'boolean' },
|
|
17
|
+
size: { control: 'select', options: sizes },
|
|
15
18
|
disabled: { control: 'boolean' },
|
|
16
19
|
readonly: { control: 'boolean' },
|
|
17
20
|
invalid: { control: 'boolean' },
|
|
@@ -22,6 +25,7 @@ const meta = {
|
|
|
22
25
|
autocomplete: 'off',
|
|
23
26
|
maxlength: undefined,
|
|
24
27
|
showCount: false,
|
|
28
|
+
size: 'default',
|
|
25
29
|
disabled: false,
|
|
26
30
|
readonly: false,
|
|
27
31
|
invalid: false,
|
|
@@ -140,6 +144,35 @@ export const Password: Story = {
|
|
|
140
144
|
}),
|
|
141
145
|
}
|
|
142
146
|
|
|
147
|
+
export const Sizes: Story = {
|
|
148
|
+
parameters: {
|
|
149
|
+
...noControls,
|
|
150
|
+
docs: {
|
|
151
|
+
source: {
|
|
152
|
+
code: `
|
|
153
|
+
<template>
|
|
154
|
+
<Input v-model="value" size="sm" placeholder="Search" />
|
|
155
|
+
</template>
|
|
156
|
+
`.trim(),
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
render: () => ({
|
|
161
|
+
components: { Input, Icon },
|
|
162
|
+
setup: () => ({ sizes, value: ref('') }),
|
|
163
|
+
template: `
|
|
164
|
+
<div class="space-y-3">
|
|
165
|
+
<div v-for="s in sizes" :key="s" class="flex items-center gap-3">
|
|
166
|
+
<span class="w-14 text-sm text-muted-foreground">{{ s }}</span>
|
|
167
|
+
<Input v-model="value" :size="s" placeholder="Search" class="w-64">
|
|
168
|
+
<template #prefix><Icon name="search" /></template>
|
|
169
|
+
</Input>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
`,
|
|
173
|
+
}),
|
|
174
|
+
}
|
|
175
|
+
|
|
143
176
|
export const Disabled: Story = {
|
|
144
177
|
parameters: noControls,
|
|
145
178
|
args: {
|