@bjj/nuxt-layer-shadcn-ui 0.12.0 → 0.12.2

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.
@@ -16,6 +16,7 @@ const meta = {
16
16
  argTypes: {
17
17
  visible: { control: 'boolean' },
18
18
  loading: { control: 'boolean' },
19
+ confirmLoading: { control: 'boolean' },
19
20
  disabled: { control: 'boolean' },
20
21
  confirmDisabled: { control: 'boolean' },
21
22
  modal: { control: 'boolean' },
@@ -36,6 +37,7 @@ const meta = {
36
37
  args: {
37
38
  visible: false,
38
39
  loading: false,
40
+ confirmLoading: false,
39
41
  disabled: false,
40
42
  confirmDisabled: false,
41
43
  modal: true,
@@ -57,7 +57,11 @@ const resolvedCancelText = computed(
57
57
 
58
58
  const sheetOpen = ref(props.visible ?? false)
59
59
  const internalLoading = ref(false)
60
- const isLoading = computed(() => internalLoading.value || props.loading)
60
+ // The confirm action is in progress: either the consumer-driven `confirmLoading`
61
+ // prop or an internal async `beforeClose`. This blocks closing and disables the
62
+ // footer/close controls. The `loading` prop is separate — it only dims the
63
+ // content behind a translucent overlay.
64
+ const confirmInProgress = computed(() => internalLoading.value || props.confirmLoading)
61
65
 
62
66
  watch(() => props.visible, value => {
63
67
  if (value !== undefined) sheetOpen.value = value
@@ -70,7 +74,7 @@ watch(sheetOpen, value => {
70
74
  })
71
75
 
72
76
  function onOpenUpdate (value: boolean) {
73
- if (!value && isLoading.value) return
77
+ if (!value && confirmInProgress.value) return
74
78
  if (value) sheetOpen.value = true
75
79
  else handleClose('cancel')
76
80
  }
@@ -161,18 +165,41 @@ const contentClass = computed(() =>
161
165
  </template>
162
166
 
163
167
  <!-- Content -->
164
- <ScrollArea
165
- fadeMask
166
- class="min-h-0 flex-1"
167
- >
168
- <div
169
- :inert="isLoading || disabled || undefined"
170
- :class="[ isLoading || disabled ? 'opacity-50' : undefined ]"
171
- class="p-4"
168
+ <div class="min-h-0 relative flex-1">
169
+ <ScrollArea
170
+ fadeMask
171
+ class="h-full"
172
172
  >
173
- <slot />
174
- </div>
175
- </ScrollArea>
173
+ <div
174
+ :inert="loading || disabled || confirmInProgress || undefined"
175
+ :class="[ disabled ? 'opacity-50' : undefined ]"
176
+ class="p-4"
177
+ >
178
+ <slot />
179
+ </div>
180
+ </ScrollArea>
181
+
182
+ <!-- Content loading overlay -->
183
+ <Transition
184
+ enterActiveClass="transition-opacity duration-200"
185
+ leaveActiveClass="transition-opacity duration-200"
186
+ enterFromClass="opacity-0"
187
+ leaveToClass="opacity-0"
188
+ >
189
+ <div
190
+ v-if="loading"
191
+ class="
192
+ inset-0 bg-popover/60 absolute z-30 flex items-center
193
+ justify-center
194
+ "
195
+ >
196
+ <Icon
197
+ name="loader-circle"
198
+ class="size-6 animate-spin text-muted-foreground"
199
+ />
200
+ </div>
201
+ </Transition>
202
+ </div>
176
203
 
177
204
  <!-- Footer -->
178
205
  <SheetFooter
@@ -189,7 +216,7 @@ const contentClass = computed(() =>
189
216
  v-if="showCancel"
190
217
  class="min-w-24"
191
218
  :variant="cancelVariant"
192
- :disabled="isLoading"
219
+ :disabled="confirmInProgress"
193
220
  @click="onCancel"
194
221
  >
195
222
  {{ resolvedCancelText }}
@@ -197,7 +224,7 @@ const contentClass = computed(() =>
197
224
  <Button
198
225
  :class="showCancel ? 'min-w-24' : 'min-w-32'"
199
226
  :variant="confirmVariant"
200
- :loading="isLoading"
227
+ :loading="confirmInProgress"
201
228
  :disabled="disabled || confirmDisabled"
202
229
  @click="onConfirm"
203
230
  >
@@ -209,7 +236,7 @@ const contentClass = computed(() =>
209
236
 
210
237
  <SheetClose
211
238
  v-if="showClose"
212
- :disabled="isLoading"
239
+ :disabled="confirmInProgress"
213
240
  class="
214
241
  top-3 right-3 size-8 text-muted-foreground ring-offset-background
215
242
  hover:bg-accent/50 hover:text-foreground
@@ -9,6 +9,7 @@ export type DrawerBeforeClose = (action: DrawerAction) => boolean | undefined |
9
9
  export interface DrawerProps {
10
10
  visible?: boolean
11
11
  loading?: boolean
12
+ confirmLoading?: boolean
12
13
  disabled?: boolean
13
14
  confirmDisabled?: boolean
14
15
  modal?: boolean
@@ -10,6 +10,8 @@ const meta = {
10
10
  argTypes: {
11
11
  modelValue: { control: 'text' },
12
12
  autocomplete: { control: 'text' },
13
+ maxlength: { control: 'number' },
14
+ showCount: { control: 'boolean' },
13
15
  disabled: { control: 'boolean' },
14
16
  readonly: { control: 'boolean' },
15
17
  invalid: { control: 'boolean' },
@@ -18,6 +20,8 @@ const meta = {
18
20
  args: {
19
21
  modelValue: '',
20
22
  autocomplete: 'off',
23
+ maxlength: undefined,
24
+ showCount: false,
21
25
  disabled: false,
22
26
  readonly: false,
23
27
  invalid: false,
@@ -4,6 +4,7 @@ import {
4
4
  InputGroupAddon,
5
5
  InputGroupButton,
6
6
  InputGroupInput,
7
+ InputGroupText,
7
8
  } from '../../shadcn/input-group'
8
9
  import type { InputProps } from './types'
9
10
 
@@ -33,6 +34,11 @@ watch(() => props.modelValue, value => {
33
34
 
34
35
  const showClearButton = computed(() => !!internalValue.value && !props.readonly && !props.disabled)
35
36
 
37
+ const countText = computed(() => {
38
+ const length = internalValue.value?.length ?? 0
39
+ return props.maxlength === undefined ? `${length}` : `${length} / ${props.maxlength}`
40
+ })
41
+
36
42
  function handleChange (event: Event) {
37
43
  const target = event.target as HTMLInputElement
38
44
  emit('change', target.value)
@@ -67,6 +73,7 @@ function clearInput () {
67
73
  v-bind="$attrs"
68
74
  :readonly="readonly"
69
75
  :disabled="disabled"
76
+ :maxlength="maxlength"
70
77
  :aria-invalid="isInvalid || undefined"
71
78
  :data-1p-ignore="autocomplete === 'off' || !autocomplete ? true : undefined"
72
79
  :autocomplete="autocomplete || 'off'"
@@ -85,6 +92,12 @@ function clearInput () {
85
92
  <Icon name="x" />
86
93
  </InputGroupButton>
87
94
  </InputGroupAddon>
95
+ <InputGroupAddon
96
+ v-if="showCount"
97
+ align="inline-end"
98
+ >
99
+ <InputGroupText>{{ countText }}</InputGroupText>
100
+ </InputGroupAddon>
88
101
  <InputGroupAddon
89
102
  v-if="slots.suffix"
90
103
  align="inline-end"
@@ -2,6 +2,10 @@ export interface InputProps {
2
2
  modelValue?: string
3
3
  /** Set to enable browser/password-manager autofill (e.g. 'email', 'current-password'). Defaults to 'off'. */
4
4
  autocomplete?: string
5
+ /** Maximum number of characters allowed */
6
+ maxlength?: number
7
+ /** Show character count (rendered as `count / maxlength` when maxlength is set) */
8
+ showCount?: boolean
5
9
  readonly?: boolean
6
10
  disabled?: boolean
7
11
  invalid?: boolean
@@ -15,6 +15,7 @@ const meta = {
15
15
  argTypes: {
16
16
  visible: { control: 'boolean' },
17
17
  loading: { control: 'boolean' },
18
+ confirmLoading: { control: 'boolean' },
18
19
  disabled: { control: 'boolean' },
19
20
  confirmDisabled: { control: 'boolean' },
20
21
  modal: { control: 'boolean' },
@@ -33,6 +34,7 @@ const meta = {
33
34
  args: {
34
35
  visible: false,
35
36
  loading: false,
37
+ confirmLoading: false,
36
38
  disabled: false,
37
39
  confirmDisabled: false,
38
40
  modal: true,
@@ -58,7 +58,11 @@ const resolvedCancelText = computed(
58
58
 
59
59
  const dialogOpen = ref(props.visible ?? false)
60
60
  const internalLoading = ref(false)
61
- const isLoading = computed(() => internalLoading.value || props.loading)
61
+ // The confirm action is in progress: either the consumer-driven `confirmLoading`
62
+ // prop or an internal async `beforeClose`. This blocks closing and disables the
63
+ // footer/close controls. The `loading` prop is separate — it only dims the
64
+ // content behind a translucent overlay.
65
+ const confirmInProgress = computed(() => internalLoading.value || props.confirmLoading)
62
66
 
63
67
  watch(() => props.visible, value => {
64
68
  if (value !== undefined) dialogOpen.value = value
@@ -71,7 +75,7 @@ watch(dialogOpen, value => {
71
75
  })
72
76
 
73
77
  function onOpenUpdate (value: boolean) {
74
- if (!value && isLoading.value) return
78
+ if (!value && confirmInProgress.value) return
75
79
  if (value) dialogOpen.value = true
76
80
  else handleClose('cancel')
77
81
  }
@@ -166,20 +170,43 @@ const contentClass = computed(() =>
166
170
  </template>
167
171
 
168
172
  <!-- Content -->
169
- <ScrollArea
170
- fadeMask
171
- class="my-5 max-h-[60vh]"
172
- >
173
- <ModalContent
174
- :type="type"
175
- :content="content"
176
- :inert="isLoading || disabled || undefined"
177
- :class="[ isLoading || disabled ? 'opacity-50' : undefined ]"
178
- class="p-1"
173
+ <div class="my-5 min-h-16 relative">
174
+ <ScrollArea
175
+ fadeMask
176
+ class="max-h-[60vh]"
177
+ >
178
+ <ModalContent
179
+ :type="type"
180
+ :content="content"
181
+ :inert="loading || disabled || confirmInProgress || undefined"
182
+ :class="[ disabled ? 'opacity-50' : undefined ]"
183
+ class="p-1"
184
+ >
185
+ <slot />
186
+ </ModalContent>
187
+ </ScrollArea>
188
+
189
+ <!-- Content loading overlay -->
190
+ <Transition
191
+ enterActiveClass="transition-opacity duration-200"
192
+ leaveActiveClass="transition-opacity duration-200"
193
+ enterFromClass="opacity-0"
194
+ leaveToClass="opacity-0"
179
195
  >
180
- <slot />
181
- </ModalContent>
182
- </ScrollArea>
196
+ <div
197
+ v-if="loading"
198
+ class="
199
+ inset-0 rounded-md bg-popover/60 absolute z-30 flex items-center
200
+ justify-center
201
+ "
202
+ >
203
+ <Icon
204
+ name="loader-circle"
205
+ class="size-6 animate-spin text-muted-foreground"
206
+ />
207
+ </div>
208
+ </Transition>
209
+ </div>
183
210
 
184
211
  <!-- Footer -->
185
212
  <DialogFooter
@@ -201,7 +228,7 @@ const contentClass = computed(() =>
201
228
  v-if="showCancel"
202
229
  class="min-w-32"
203
230
  :variant="cancelVariant"
204
- :disabled="isLoading"
231
+ :disabled="confirmInProgress"
205
232
  @click="onCancel"
206
233
  >
207
234
  {{ resolvedCancelText }}
@@ -209,7 +236,7 @@ const contentClass = computed(() =>
209
236
  <Button
210
237
  :class="showCancel ? 'min-w-32' : 'min-w-48'"
211
238
  :variant="confirmVariant"
212
- :loading="isLoading"
239
+ :loading="confirmInProgress"
213
240
  :disabled="disabled || confirmDisabled"
214
241
  @click="onConfirm"
215
242
  >
@@ -221,7 +248,7 @@ const contentClass = computed(() =>
221
248
 
222
249
  <DialogClose
223
250
  v-if="showClose"
224
- :disabled="isLoading"
251
+ :disabled="confirmInProgress"
225
252
  class="
226
253
  top-3 right-3 size-8 text-muted-foreground ring-offset-background
227
254
  hover:bg-accent/50 hover:text-foreground
@@ -8,6 +8,7 @@ export type ModalBeforeClose = (action: ModalAction) => boolean | undefined | Pr
8
8
  export interface ModalProps {
9
9
  visible?: boolean
10
10
  loading?: boolean
11
+ confirmLoading?: boolean
11
12
  disabled?: boolean
12
13
  confirmDisabled?: boolean
13
14
  modal?: boolean
@@ -10,6 +10,8 @@ const meta = {
10
10
  modelValue: { control: 'text' },
11
11
  autocomplete: { control: 'text' },
12
12
  rows: { control: 'number' },
13
+ maxlength: { control: 'number' },
14
+ showCount: { control: 'boolean' },
13
15
  invalid: { control: 'boolean' },
14
16
  class: { control: 'text' },
15
17
  },
@@ -17,6 +19,8 @@ const meta = {
17
19
  modelValue: '',
18
20
  autocomplete: '',
19
21
  rows: undefined,
22
+ maxlength: undefined,
23
+ showCount: false,
20
24
  invalid: false,
21
25
  class: '',
22
26
  },
@@ -8,6 +8,8 @@ const props = withDefaults(defineProps<TextareaProps>(), {
8
8
  modelValue: undefined,
9
9
  autocomplete: undefined,
10
10
  rows: undefined,
11
+ maxlength: undefined,
12
+ showCount: false,
11
13
  invalid: false,
12
14
  class: undefined,
13
15
  })
@@ -19,8 +21,22 @@ const emit = defineEmits<{
19
21
 
20
22
  const isInvalid = useFormItemInvalid(() => props.invalid)
21
23
 
24
+ // Internal value tracks the actual textarea content, independent of parent's modelValue
25
+ const internalValue = ref(props.modelValue)
26
+
27
+ // Sync internal value when parent updates modelValue
28
+ watch(() => props.modelValue, value => {
29
+ internalValue.value = value
30
+ })
31
+
32
+ const countText = computed(() => {
33
+ const length = internalValue.value?.length ?? 0
34
+ return props.maxlength === undefined ? `${length}` : `${length} / ${props.maxlength}`
35
+ })
36
+
22
37
  function handleInput (event: Event) {
23
38
  const target = event.target as HTMLTextAreaElement
39
+ internalValue.value = target.value
24
40
  emit('update:modelValue', target.value)
25
41
  }
26
42
 
@@ -41,6 +57,7 @@ const mergedClass = computed(() =>
41
57
  <ShadcnTextarea
42
58
  :modelValue="modelValue"
43
59
  :rows="rows"
60
+ :maxlength="maxlength"
44
61
  :class="mergedClass"
45
62
  :aria-invalid="isInvalid || undefined"
46
63
  :data-1p-ignore="autocomplete === 'off' || !autocomplete ? true : undefined"
@@ -49,4 +66,10 @@ const mergedClass = computed(() =>
49
66
  @input="handleInput"
50
67
  @change="handleChange"
51
68
  />
69
+ <div
70
+ v-if="showCount"
71
+ class="mt-1 text-sm text-muted-foreground text-right"
72
+ >
73
+ {{ countText }}
74
+ </div>
52
75
  </template>
@@ -3,6 +3,10 @@ export interface TextareaProps {
3
3
  /** Set to enable browser/password-manager autofill. Defaults to 'off'. */
4
4
  autocomplete?: string
5
5
  rows?: number
6
+ /** Maximum number of characters allowed */
7
+ maxlength?: number
8
+ /** Show character count below the textarea (rendered as `count / maxlength` when maxlength is set) */
9
+ showCount?: boolean
6
10
  invalid?: boolean
7
11
  class?: ClassValue
8
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bjj/nuxt-layer-shadcn-ui",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
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": "690898135beed9a9a0a5620b27585e0e70e693f8"
45
+ "gitHead": "c47ada34413965a985c7bedc16f23a12a473bbe1"
46
46
  }