@bjj/nuxt-layer-shadcn-ui 0.15.3 → 0.15.5
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/components/ui/DataTable/index.vue +14 -1
- package/app/components/ui/InputCurrency/types.ts +1 -1
- package/app/components/ui/InputNumber/index.stories.ts +109 -2
- package/app/components/ui/InputNumber/index.vue +66 -2
- package/app/components/ui/InputNumber/types.ts +5 -0
- package/app/components/ui/InputPercent/types.ts +1 -1
- package/package.json +2 -2
|
@@ -550,6 +550,16 @@ defineExpose({
|
|
|
550
550
|
z-index: 20;
|
|
551
551
|
}
|
|
552
552
|
|
|
553
|
+
/* Separated border model: row-level borders are ignored here, so the row
|
|
554
|
+
divider lives on the cell, where it paints above the cell's opaque
|
|
555
|
+
background — collapsed borders land beneath it in WebKit once the row group
|
|
556
|
+
is clipped. The header's tinted band is its own boundary, so it carries no
|
|
557
|
+
divider. */
|
|
558
|
+
:deep([data-slot="table"]) {
|
|
559
|
+
border-collapse: separate;
|
|
560
|
+
border-spacing: 0;
|
|
561
|
+
}
|
|
562
|
+
|
|
553
563
|
/* clip-path is reliable on table-row-group, unlike overflow:hidden */
|
|
554
564
|
:deep(tbody) {
|
|
555
565
|
clip-path: inset(0 round 8px);
|
|
@@ -567,12 +577,15 @@ defineExpose({
|
|
|
567
577
|
/* Opaque card base under a translucent state overlay: frozen (sticky) cells
|
|
568
578
|
must fully occlude columns scrolling beneath them. */
|
|
569
579
|
:deep(tbody td) {
|
|
580
|
+
border-bottom: 1px solid var(--color-border);
|
|
570
581
|
background:
|
|
571
582
|
linear-gradient(var(--cell-overlay), var(--cell-overlay))
|
|
572
583
|
var(--color-card);
|
|
573
584
|
}
|
|
574
585
|
|
|
575
|
-
|
|
586
|
+
/* The row that ends the body carries no divider — the filler row when present */
|
|
587
|
+
:deep(tbody tr:last-child td),
|
|
588
|
+
:deep(tbody tr:has(+ tr[aria-hidden="true"]) td) {
|
|
576
589
|
border-bottom: 0;
|
|
577
590
|
}
|
|
578
591
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InputNumberProps } from '../InputNumber/types'
|
|
2
2
|
|
|
3
|
-
export interface InputCurrencyProps extends /* @vue-ignore */ Pick<InputNumberProps, 'readonly' | 'disabled' | 'invalid'> {
|
|
3
|
+
export interface InputCurrencyProps extends /* @vue-ignore */ Pick<InputNumberProps, 'readonly' | 'disabled' | 'invalid' | 'align' | 'class'> {
|
|
4
4
|
currency?: string
|
|
5
5
|
currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name'
|
|
6
6
|
}
|
|
@@ -3,6 +3,8 @@ import EventLog from '#storybook/EventLog.vue'
|
|
|
3
3
|
import { useArgsModel } from '#storybook/argsModel'
|
|
4
4
|
import InputNumber from './index.vue'
|
|
5
5
|
|
|
6
|
+
const aligns = [ 'left', 'center', 'right' ] as const
|
|
7
|
+
|
|
6
8
|
const meta = {
|
|
7
9
|
title: 'UI/InputNumber',
|
|
8
10
|
component: InputNumber,
|
|
@@ -13,9 +15,11 @@ const meta = {
|
|
|
13
15
|
step: { control: 'number' },
|
|
14
16
|
placeholder: { control: 'text' },
|
|
15
17
|
showButtons: { control: 'boolean' },
|
|
18
|
+
align: { control: 'select', options: aligns },
|
|
16
19
|
readonly: { control: 'boolean' },
|
|
17
20
|
disabled: { control: 'boolean' },
|
|
18
21
|
invalid: { control: 'boolean' },
|
|
22
|
+
class: { control: 'text' },
|
|
19
23
|
},
|
|
20
24
|
args: {
|
|
21
25
|
modelValue: 0,
|
|
@@ -24,9 +28,11 @@ const meta = {
|
|
|
24
28
|
step: 1,
|
|
25
29
|
placeholder: '',
|
|
26
30
|
showButtons: true,
|
|
31
|
+
align: 'center',
|
|
27
32
|
readonly: false,
|
|
28
33
|
disabled: false,
|
|
29
34
|
invalid: false,
|
|
35
|
+
class: 'max-w-xs',
|
|
30
36
|
},
|
|
31
37
|
render: args => {
|
|
32
38
|
const onUpdate = useArgsModel()
|
|
@@ -34,9 +40,9 @@ const meta = {
|
|
|
34
40
|
components: { InputNumber },
|
|
35
41
|
setup: () => ({ args, onUpdate }),
|
|
36
42
|
template: `
|
|
37
|
-
<div class="
|
|
43
|
+
<div class="space-y-2">
|
|
38
44
|
<InputNumber v-bind="args" @update:modelValue="onUpdate" />
|
|
39
|
-
<div class="
|
|
45
|
+
<div class="text-sm text-muted-foreground">Value: {{ args.modelValue }}</div>
|
|
40
46
|
</div>
|
|
41
47
|
`,
|
|
42
48
|
}
|
|
@@ -65,6 +71,14 @@ export const CustomStep: Story = {
|
|
|
65
71
|
},
|
|
66
72
|
}
|
|
67
73
|
|
|
74
|
+
export const Placeholder: Story = {
|
|
75
|
+
parameters: noControls,
|
|
76
|
+
args: {
|
|
77
|
+
modelValue: undefined,
|
|
78
|
+
placeholder: 'Enter a number',
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
|
|
68
82
|
export const WithoutButtons: Story = {
|
|
69
83
|
parameters: noControls,
|
|
70
84
|
args: {
|
|
@@ -72,6 +86,99 @@ export const WithoutButtons: Story = {
|
|
|
72
86
|
},
|
|
73
87
|
}
|
|
74
88
|
|
|
89
|
+
export const Alignments: Story = {
|
|
90
|
+
parameters: {
|
|
91
|
+
...noControls,
|
|
92
|
+
docs: {
|
|
93
|
+
source: {
|
|
94
|
+
code: `
|
|
95
|
+
<template>
|
|
96
|
+
<InputNumber v-model="value" align="right" />
|
|
97
|
+
</template>
|
|
98
|
+
`.trim(),
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
render: () => ({
|
|
103
|
+
components: { InputNumber },
|
|
104
|
+
setup: () => ({ aligns, value: ref(1234) }),
|
|
105
|
+
template: `
|
|
106
|
+
<div class="max-w-xs space-y-3">
|
|
107
|
+
<div v-for="a in aligns" :key="a" class="flex items-center gap-3">
|
|
108
|
+
<span class="w-14 text-sm text-muted-foreground">{{ a }}</span>
|
|
109
|
+
<InputNumber v-model="value" :align="a" class="flex-1" />
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
`,
|
|
113
|
+
}),
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const WithPrefix: Story = {
|
|
117
|
+
parameters: {
|
|
118
|
+
...noControls,
|
|
119
|
+
docs: {
|
|
120
|
+
source: {
|
|
121
|
+
code: `
|
|
122
|
+
<template>
|
|
123
|
+
<InputNumber v-model="value" align="left">
|
|
124
|
+
<template #prefix>¥</template>
|
|
125
|
+
</InputNumber>
|
|
126
|
+
</template>
|
|
127
|
+
`.trim(),
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
render: () => ({
|
|
132
|
+
components: { InputNumber },
|
|
133
|
+
setup: () => ({ value: ref(1000) }),
|
|
134
|
+
template: `
|
|
135
|
+
<div class="max-w-xs space-y-2">
|
|
136
|
+
<InputNumber v-model="value" align="left">
|
|
137
|
+
<template #prefix>¥</template>
|
|
138
|
+
</InputNumber>
|
|
139
|
+
<div class="text-sm text-muted-foreground">Value: {{ value }}</div>
|
|
140
|
+
</div>
|
|
141
|
+
`,
|
|
142
|
+
}),
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const WithSuffix: Story = {
|
|
146
|
+
parameters: {
|
|
147
|
+
...noControls,
|
|
148
|
+
docs: {
|
|
149
|
+
source: {
|
|
150
|
+
code: `
|
|
151
|
+
<template>
|
|
152
|
+
<InputNumber v-model="value" :showButtons="false" align="right">
|
|
153
|
+
<template #suffix>kg</template>
|
|
154
|
+
</InputNumber>
|
|
155
|
+
</template>
|
|
156
|
+
`.trim(),
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
render: () => ({
|
|
161
|
+
components: { InputNumber },
|
|
162
|
+
setup: () => ({ value: ref(65) }),
|
|
163
|
+
template: `
|
|
164
|
+
<div class="max-w-xs space-y-2">
|
|
165
|
+
<InputNumber v-model="value" :showButtons="false" align="right">
|
|
166
|
+
<template #suffix>kg</template>
|
|
167
|
+
</InputNumber>
|
|
168
|
+
<div class="text-sm text-muted-foreground">Value: {{ value }}</div>
|
|
169
|
+
</div>
|
|
170
|
+
`,
|
|
171
|
+
}),
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export const Readonly: Story = {
|
|
175
|
+
parameters: noControls,
|
|
176
|
+
args: {
|
|
177
|
+
readonly: true,
|
|
178
|
+
modelValue: 42,
|
|
179
|
+
},
|
|
180
|
+
}
|
|
181
|
+
|
|
75
182
|
export const Disabled: Story = {
|
|
76
183
|
parameters: noControls,
|
|
77
184
|
args: {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
NumberFieldIncrement,
|
|
7
7
|
NumberFieldInput,
|
|
8
8
|
} from '../../shadcn/number-field'
|
|
9
|
-
import type { InputNumberProps } from './types'
|
|
9
|
+
import type { InputNumberAlign, InputNumberProps } from './types'
|
|
10
10
|
|
|
11
11
|
const props = withDefaults(defineProps<InputNumberProps>(), {
|
|
12
12
|
modelValue: undefined,
|
|
@@ -17,13 +17,20 @@ const props = withDefaults(defineProps<InputNumberProps>(), {
|
|
|
17
17
|
disabled: false,
|
|
18
18
|
showButtons: true,
|
|
19
19
|
placeholder: undefined,
|
|
20
|
+
align: 'center',
|
|
20
21
|
invalid: false,
|
|
22
|
+
class: undefined,
|
|
21
23
|
})
|
|
22
24
|
|
|
23
25
|
const emit = defineEmits<{
|
|
24
26
|
'update:modelValue': [value: number | undefined]
|
|
25
27
|
}>()
|
|
26
28
|
|
|
29
|
+
const slots = defineSlots<{
|
|
30
|
+
prefix?: () => any
|
|
31
|
+
suffix?: () => any
|
|
32
|
+
}>()
|
|
33
|
+
|
|
27
34
|
const model = computed({
|
|
28
35
|
get: () => props.modelValue,
|
|
29
36
|
set: value => emit('update:modelValue', value),
|
|
@@ -54,12 +61,55 @@ const contentClass = computed(() =>
|
|
|
54
61
|
)
|
|
55
62
|
|
|
56
63
|
const buttonClass = 'static translate-y-0 shrink-0 cursor-pointer'
|
|
57
|
-
|
|
64
|
+
|
|
65
|
+
const alignClass = {
|
|
66
|
+
left: 'text-left',
|
|
67
|
+
center: 'text-center',
|
|
68
|
+
right: 'text-right',
|
|
69
|
+
} satisfies Record<InputNumberAlign, string>
|
|
70
|
+
|
|
71
|
+
const inputClass = computed(() =>
|
|
72
|
+
cn(
|
|
73
|
+
`
|
|
74
|
+
min-w-0 px-3 flex-1 rounded-none border-0 shadow-none
|
|
75
|
+
focus-visible:ring-0
|
|
76
|
+
`,
|
|
77
|
+
alignClass[props.align],
|
|
78
|
+
// An addon already separates the value from that edge, so tighten the gap next to it.
|
|
79
|
+
slots.prefix && 'pl-2',
|
|
80
|
+
slots.suffix && 'pr-2',
|
|
81
|
+
),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
const addonClass = computed(() =>
|
|
85
|
+
cn(
|
|
86
|
+
`
|
|
87
|
+
text-muted-foreground gap-1 text-sm font-medium flex shrink-0 cursor-text
|
|
88
|
+
items-center select-none
|
|
89
|
+
`,
|
|
90
|
+
props.disabled && 'opacity-50',
|
|
91
|
+
),
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
// The stepper buttons pad the content edges themselves; without them the addon does it.
|
|
95
|
+
const prefixClass = computed(() =>
|
|
96
|
+
cn(addonClass.value, !props.showButtons && 'pl-3'),
|
|
97
|
+
)
|
|
98
|
+
const suffixClass = computed(() =>
|
|
99
|
+
cn(addonClass.value, !props.showButtons && 'pr-3'),
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
// Clicking an addon should feel like clicking the field itself.
|
|
103
|
+
function focusInput (event: MouseEvent) {
|
|
104
|
+
const addon = event.currentTarget as HTMLElement
|
|
105
|
+
addon.parentElement?.querySelector('input')?.focus()
|
|
106
|
+
}
|
|
58
107
|
</script>
|
|
59
108
|
|
|
60
109
|
<template>
|
|
61
110
|
<NumberField
|
|
62
111
|
v-model="model"
|
|
112
|
+
:class="props.class"
|
|
63
113
|
:min="min"
|
|
64
114
|
:max="max"
|
|
65
115
|
:step="step"
|
|
@@ -71,10 +121,24 @@ const inputClass = 'flex-1 min-w-0 border-0 shadow-none focus-visible:ring-0 rou
|
|
|
71
121
|
v-if="showButtons"
|
|
72
122
|
:class="buttonClass"
|
|
73
123
|
/>
|
|
124
|
+
<span
|
|
125
|
+
v-if="slots.prefix"
|
|
126
|
+
:class="prefixClass"
|
|
127
|
+
@click="focusInput"
|
|
128
|
+
>
|
|
129
|
+
<slot name="prefix" />
|
|
130
|
+
</span>
|
|
74
131
|
<NumberFieldInput
|
|
75
132
|
:placeholder="placeholder"
|
|
76
133
|
:class="inputClass"
|
|
77
134
|
/>
|
|
135
|
+
<span
|
|
136
|
+
v-if="slots.suffix"
|
|
137
|
+
:class="suffixClass"
|
|
138
|
+
@click="focusInput"
|
|
139
|
+
>
|
|
140
|
+
<slot name="suffix" />
|
|
141
|
+
</span>
|
|
78
142
|
<NumberFieldIncrement
|
|
79
143
|
v-if="showButtons"
|
|
80
144
|
:class="buttonClass"
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export type InputNumberAlign = 'left' | 'center' | 'right'
|
|
2
|
+
|
|
1
3
|
export interface InputNumberProps {
|
|
2
4
|
modelValue?: number
|
|
3
5
|
min?: number
|
|
@@ -7,5 +9,8 @@ export interface InputNumberProps {
|
|
|
7
9
|
disabled?: boolean
|
|
8
10
|
showButtons?: boolean
|
|
9
11
|
placeholder?: string
|
|
12
|
+
/** Horizontal alignment of the value inside the input */
|
|
13
|
+
align?: InputNumberAlign
|
|
10
14
|
invalid?: boolean
|
|
15
|
+
class?: ClassValue
|
|
11
16
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { InputNumberProps } from '../InputNumber/types'
|
|
2
2
|
|
|
3
|
-
export interface InputPercentProps extends /* @vue-ignore */ Pick<InputNumberProps, 'readonly' | 'disabled' | 'invalid'> {}
|
|
3
|
+
export interface InputPercentProps extends /* @vue-ignore */ Pick<InputNumberProps, 'readonly' | 'disabled' | 'invalid' | 'align' | 'class'> {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bjj/nuxt-layer-shadcn-ui",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.5",
|
|
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": "
|
|
45
|
+
"gitHead": "9014a25cfd667901888b509609282d77c9dc0d21"
|
|
46
46
|
}
|