@m3ui-vue/m3ui-vue 1.6.2 → 1.8.0
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/dist/API.md +1224 -28
- package/dist/{MColorPickerModal-NtkihoK6.js → MColorPickerModal-H8nuX0Wu.js} +3 -4
- package/dist/{MColorPickerModal-NtkihoK6.js.map → MColorPickerModal-H8nuX0Wu.js.map} +1 -1
- package/dist/MDialog-B42Mhn8W.js +331 -0
- package/dist/MDialog-B42Mhn8W.js.map +1 -0
- package/dist/{MListItem-D2cNUyzP.js → MListItem-DiOAxaN7.js} +431 -325
- package/dist/MListItem-DiOAxaN7.js.map +1 -0
- package/dist/{MLoadingIndicator-DWUj0BAB.js → MLoadingIndicator-CuTZYFFj.js} +2 -2
- package/dist/{MLoadingIndicator-DWUj0BAB.js.map → MLoadingIndicator-CuTZYFFj.js.map} +1 -1
- package/dist/{MSeekBar-C4cn9RIF.js → MSeekBar-BCDQTx2t.js} +2 -2
- package/dist/{MSeekBar-C4cn9RIF.js.map → MSeekBar-BCDQTx2t.js.map} +1 -1
- package/dist/MSegmentedButton-BXzRsg1S.js +105 -0
- package/dist/MSegmentedButton-BXzRsg1S.js.map +1 -0
- package/dist/MSignaturePad-BTqGaPXA.js +313 -0
- package/dist/MSignaturePad-BTqGaPXA.js.map +1 -0
- package/dist/MSlider-D_O8J9YH.js +739 -0
- package/dist/MSlider-D_O8J9YH.js.map +1 -0
- package/dist/{MSpinner-DZkXZJpc.js → MSpinner-UCdtSOHP.js} +2 -2
- package/dist/{MSpinner-DZkXZJpc.js.map → MSpinner-UCdtSOHP.js.map} +1 -1
- package/dist/{MTextField-CNH-byir.js → MTextField-CYk9yFvi.js} +162 -115
- package/dist/MTextField-CYk9yFvi.js.map +1 -0
- package/dist/_useFieldValidation-B0B44M_t.js +191 -0
- package/dist/_useFieldValidation-B0B44M_t.js.map +1 -0
- package/dist/api.json +1 -1
- package/dist/code-editor.js +184 -103
- package/dist/code-editor.js.map +1 -1
- package/dist/components/MAddressField.vue.d.ts +18 -3
- package/dist/components/MAppBarWithSearch.vue.d.ts +1 -1
- package/dist/components/MAudioRecorder.vue.d.ts +2 -2
- package/dist/components/MAutocomplete.vue.d.ts +22 -3
- package/dist/components/MCheckbox.vue.d.ts +23 -1
- package/dist/components/MCodeEditor.vue.d.ts +23 -1
- package/dist/components/MColorPicker.vue.d.ts +24 -3
- package/dist/components/MConfirmDialog.vue.d.ts +2 -2
- package/dist/components/MCountrySelect.vue.d.ts +13 -2
- package/dist/components/MCreditCardInput.vue.d.ts +33 -0
- package/dist/components/MCronField.vue.d.ts +23 -1
- package/dist/components/MDataTable.vue.d.ts +1 -1
- package/dist/components/MDatePicker.vue.d.ts +24 -3
- package/dist/components/MDateRangePicker.vue.d.ts +24 -3
- package/dist/components/MFileUpload.vue.d.ts +23 -2
- package/dist/components/MForm.vue.d.ts +61 -0
- package/dist/components/MFormBuilder.vue.d.ts +22 -0
- package/dist/components/MFormRenderer.vue.d.ts +151 -0
- package/dist/components/MJsonEditor.vue.d.ts +23 -1
- package/dist/components/MMapRoute.vue.d.ts +176 -0
- package/dist/components/MMaskField.vue.d.ts +20 -2
- package/dist/components/MMentionField.vue.d.ts +13 -2
- package/dist/components/MMultiAutocomplete.vue.d.ts +22 -3
- package/dist/components/MMultiSelect.vue.d.ts +22 -3
- package/dist/components/MNavigationRail.vue.d.ts +1 -1
- package/dist/components/MNotificationCenter.vue.d.ts +2 -2
- package/dist/components/MNumberField.vue.d.ts +20 -2
- package/dist/components/MPdfSigner.vue.d.ts +499 -0
- package/dist/components/MPdfViewer.vue.d.ts +12 -0
- package/dist/components/MPhoneInput.vue.d.ts +19 -4
- package/dist/components/MPinInput.vue.d.ts +24 -3
- package/dist/components/MPosKeypad.vue.d.ts +3 -3
- package/dist/components/MRadioGroup.vue.d.ts +23 -1
- package/dist/components/MRating.vue.d.ts +23 -1
- package/dist/components/MRichTextEditor.vue.d.ts +23 -1
- package/dist/components/MSearchBar.vue.d.ts +1 -1
- package/dist/components/MSegmentedButton.vue.d.ts +23 -2
- package/dist/components/MSelect.vue.d.ts +22 -3
- package/dist/components/MSignaturePad.vue.d.ts +19 -0
- package/dist/components/MSlider.vue.d.ts +23 -1
- package/dist/components/MSpreadsheet.vue.d.ts +137 -0
- package/dist/components/MStack.vue.d.ts +1 -1
- package/dist/components/MSwitch.vue.d.ts +23 -1
- package/dist/components/MTable.vue.d.ts +1 -1
- package/dist/components/MTagInput.vue.d.ts +20 -2
- package/dist/components/MText.vue.d.ts +1 -1
- package/dist/components/MTextField.vue.d.ts +26 -3
- package/dist/components/MTimePicker.vue.d.ts +24 -3
- package/dist/components/MTimezoneSelect.vue.d.ts +13 -2
- package/dist/components/MTour.vue.d.ts +2 -2
- package/dist/components/MTrackingTimeline.vue.d.ts +75 -0
- package/dist/components/MWindow.vue.d.ts +2 -2
- package/dist/composables/_routeGeometry.d.ts +26 -0
- package/dist/composables/_useFieldValidation.d.ts +91 -0
- package/dist/composables/mapRouting.d.ts +35 -0
- package/dist/composables/pdfSign.d.ts +52 -0
- package/dist/composables/spreadsheetFormula.d.ts +55 -0
- package/dist/composables/useLocale.d.ts +177 -0
- package/dist/composables/validation.d.ts +82 -0
- package/dist/draw.js +2 -2
- package/dist/flow.js +1 -1
- package/dist/gantt.js +2 -2
- package/dist/index.d.ts +12 -0
- package/dist/locales/index.js +693 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +15507 -12417
- package/dist/m3ui.js.map +1 -1
- package/dist/map.d.ts +4 -0
- package/dist/map.js +1207 -745
- package/dist/map.js.map +1 -1
- package/dist/media.js +4 -4
- package/dist/pdf.d.ts +3 -0
- package/dist/pdf.js +1228 -687
- package/dist/pdf.js.map +1 -1
- package/dist/rich-text-editor.js +188 -146
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/{useLocale-DaVSTdm0.js → useLocale-DL96OFgr.js} +99 -1
- package/dist/useLocale-DL96OFgr.js.map +1 -0
- package/package.json +5 -1
- package/src/__tests__/MForm.test.ts +325 -0
- package/src/__tests__/MFormRenderer.test.ts +157 -0
- package/src/__tests__/MMapRoute.test.ts +418 -0
- package/src/__tests__/MPdfSigner.test.ts +175 -0
- package/src/__tests__/MPhoneInput.test.ts +5 -2
- package/src/__tests__/MRichTextEditor.test.ts +2 -1
- package/src/__tests__/MSpreadsheet.test.ts +223 -0
- package/src/__tests__/MTrackingTimeline.test.ts +66 -0
- package/src/__tests__/_fakeMaplibre.ts +4 -1
- package/src/__tests__/_osrmRoutes.ts +10 -0
- package/src/__tests__/attrsFallthrough.test.ts +11 -0
- package/src/__tests__/fieldsValidation.test.ts +229 -0
- package/src/__tests__/spreadsheetFormula.test.ts +77 -0
- package/src/__tests__/ssr.test.ts +4 -0
- package/src/__tests__/validation.test.ts +77 -0
- package/src/components/MAddressField.vue +45 -8
- package/src/components/MAutocomplete.vue +69 -23
- package/src/components/MCheckbox.vue +80 -17
- package/src/components/MCodeEditor.vue +59 -2
- package/src/components/MColorPicker.vue +65 -16
- package/src/components/MCountrySelect.vue +17 -3
- package/src/components/MCreditCardInput.vue +76 -7
- package/src/components/MCronField.vue +60 -10
- package/src/components/MDatePicker.vue +65 -16
- package/src/components/MDateRangePicker.vue +66 -16
- package/src/components/MFileUpload.vue +71 -8
- package/src/components/MForm.vue +208 -0
- package/src/components/MFormBuilder.vue +417 -0
- package/src/components/MFormRenderer.vue +324 -0
- package/src/components/MJsonEditor.vue +57 -3
- package/src/components/MMapRoute.vue +523 -0
- package/src/components/MMaskField.vue +55 -13
- package/src/components/MMentionField.vue +17 -2
- package/src/components/MMultiAutocomplete.vue +70 -23
- package/src/components/MMultiSelect.vue +70 -23
- package/src/components/MNumberField.vue +58 -16
- package/src/components/MPdfSigner.vue +433 -0
- package/src/components/MPdfViewer.vue +12 -0
- package/src/components/MPhoneInput.vue +60 -18
- package/src/components/MPinInput.vue +58 -10
- package/src/components/MRadioGroup.vue +65 -4
- package/src/components/MRating.vue +62 -6
- package/src/components/MRichTextEditor.vue +64 -4
- package/src/components/MSegmentedButton.vue +59 -2
- package/src/components/MSelect.vue +72 -26
- package/src/components/MSignaturePad.vue +71 -6
- package/src/components/MSlider.vue +61 -10
- package/src/components/MSpreadsheet.vue +992 -0
- package/src/components/MSwitch.vue +63 -8
- package/src/components/MTagInput.vue +67 -25
- package/src/components/MTextField.vue +68 -14
- package/src/components/MTimePicker.vue +65 -16
- package/src/components/MTimezoneSelect.vue +17 -3
- package/src/components/MTrackingTimeline.vue +257 -0
- package/src/composables/_routeGeometry.ts +140 -0
- package/src/composables/_useFieldValidation.ts +287 -0
- package/src/composables/mapRouting.ts +55 -0
- package/src/composables/pdfSign.ts +141 -0
- package/src/composables/spreadsheetFormula.ts +459 -0
- package/src/composables/useLocale.ts +277 -0
- package/src/composables/validation.ts +178 -0
- package/src/index.ts +12 -0
- package/src/locales/de.ts +98 -0
- package/src/locales/es.ts +105 -7
- package/src/locales/fr.ts +98 -0
- package/src/locales/ja.ts +98 -0
- package/src/locales/ko.ts +98 -0
- package/src/locales/pt.ts +98 -0
- package/src/locales/zh.ts +98 -0
- package/src/map.ts +4 -0
- package/src/pdf.ts +3 -0
- package/dist/MButton-OQ4wIERQ.js +0 -171
- package/dist/MButton-OQ4wIERQ.js.map +0 -1
- package/dist/MDialog-DYMnaBlt.js +0 -167
- package/dist/MDialog-DYMnaBlt.js.map +0 -1
- package/dist/MListItem-D2cNUyzP.js.map +0 -1
- package/dist/MProgressBar-BWly1UKN.js +0 -179
- package/dist/MProgressBar-BWly1UKN.js.map +0 -1
- package/dist/MSegmentedButton-BEB4gXLA.js +0 -64
- package/dist/MSegmentedButton-BEB4gXLA.js.map +0 -1
- package/dist/MSlider-BIkA6DiE.js +0 -690
- package/dist/MSlider-BIkA6DiE.js.map +0 -1
- package/dist/MTextField-CNH-byir.js.map +0 -1
- package/dist/useLocale-DaVSTdm0.js.map +0 -1
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* @event mention An item was picked: `(item, trigger)`
|
|
15
15
|
*/
|
|
16
16
|
import { computed, nextTick, onBeforeUnmount, ref, shallowRef, useId, watch, watchEffect } from 'vue'
|
|
17
|
+
import type { ValidateOn, ValidationRule } from '../composables/validation'
|
|
17
18
|
import MAvatar from './MAvatar.vue'
|
|
18
19
|
import MIcon from './MIcon.vue'
|
|
19
20
|
import MSpinner from './MSpinner.vue'
|
|
@@ -85,10 +86,18 @@ const props = withDefaults(
|
|
|
85
86
|
leadingIcon?: string
|
|
86
87
|
/** Helper text below the field */
|
|
87
88
|
hint?: string
|
|
88
|
-
/** Error state */
|
|
89
|
-
error?: boolean
|
|
89
|
+
/** Error state. A string is also the message */
|
|
90
|
+
error?: boolean | string
|
|
90
91
|
/** Error message shown when `error` is true */
|
|
91
92
|
errorLabel?: string
|
|
93
|
+
/** Validation rules (functions or a Standard Schema); see `MForm` */
|
|
94
|
+
rules?: ValidationRule | ValidationRule[]
|
|
95
|
+
/** When the rules are checked and shown: on leaving the field (default), while typing, or only on submit */
|
|
96
|
+
validateOn?: ValidateOn
|
|
97
|
+
/** Wait this long (ms) after the value stops changing before re-checking (one request for an async rule, not one per key). Defaults to its `MForm`'s */
|
|
98
|
+
validateDebounce?: number
|
|
99
|
+
/** The key of this field in its `MForm` */
|
|
100
|
+
name?: string
|
|
92
101
|
/** Marks it as required */
|
|
93
102
|
required?: boolean
|
|
94
103
|
/** Disables the field */
|
|
@@ -98,6 +107,7 @@ const props = withDefaults(
|
|
|
98
107
|
)
|
|
99
108
|
|
|
100
109
|
const emit = defineEmits<{
|
|
110
|
+
blur: []
|
|
101
111
|
'update:modelValue': [text: string]
|
|
102
112
|
'update:mentions': [mentions: MentionRef[]]
|
|
103
113
|
mention: [item: MentionItem, trigger: string]
|
|
@@ -325,6 +335,11 @@ defineExpose({
|
|
|
325
335
|
:hint="hint"
|
|
326
336
|
:error="error"
|
|
327
337
|
:error-label="errorLabel"
|
|
338
|
+
:rules="rules"
|
|
339
|
+
:validate-on="validateOn"
|
|
340
|
+
:validate-debounce="validateDebounce"
|
|
341
|
+
:name="name"
|
|
342
|
+
@blur="emit('blur')"
|
|
328
343
|
:required="required"
|
|
329
344
|
:disabled="disabled"
|
|
330
345
|
@update:model-value="onText"
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* @event debounced Emitted debounce ms after the user stops typing the search query (only when debounce > 0)
|
|
7
7
|
*/
|
|
8
8
|
import { computed, ref, useId, onMounted, onUnmounted, watch, nextTick } from 'vue'
|
|
9
|
+
import { useFieldValidation, useFocusLeave } from '../composables/_useFieldValidation'
|
|
10
|
+
import type { ValidateOn, ValidationRule } from '../composables/validation'
|
|
9
11
|
import MIcon from './MIcon.vue'
|
|
10
12
|
import MIconButton from './MIconButton.vue'
|
|
11
13
|
import MCheckbox from './MCheckbox.vue'
|
|
@@ -38,10 +40,21 @@ const props = withDefaults(
|
|
|
38
40
|
mode?: 'docked' | 'modal'
|
|
39
41
|
/** Disables the field */
|
|
40
42
|
disabled?: boolean
|
|
41
|
-
/** Error state */
|
|
42
|
-
error?: boolean
|
|
43
|
+
/** Error state. A string is also the message (`:error="errors.x"`) */
|
|
44
|
+
error?: boolean | string
|
|
43
45
|
/** Error message shown when error is true */
|
|
44
46
|
errorLabel?: string
|
|
47
|
+
/**
|
|
48
|
+
* Validation rules: functions `(value, ctx) => true | 'message'` (may be async; see the built-in `required`,
|
|
49
|
+
* `email`, `minLength`…) or a Standard Schema (zod, valibot…). Checked in order; the first failure is shown
|
|
50
|
+
*/
|
|
51
|
+
rules?: ValidationRule | ValidationRule[]
|
|
52
|
+
/** When the rules are checked and shown: on leaving the field (default; live after that), while typing, or only on submit (`MForm`) */
|
|
53
|
+
validateOn?: ValidateOn
|
|
54
|
+
/** Wait this long (ms) after the value stops changing before re-checking (one request for an async rule, not one per key). Defaults to its `MForm`'s */
|
|
55
|
+
validateDebounce?: number
|
|
56
|
+
/** The key of this field in its `MForm`'s values, errors and schema */
|
|
57
|
+
name?: string
|
|
45
58
|
/** Helper text below field */
|
|
46
59
|
hint?: string
|
|
47
60
|
/** Marks as required — adds a red asterisk after the label */
|
|
@@ -76,7 +89,26 @@ const props = withDefaults(
|
|
|
76
89
|
},
|
|
77
90
|
)
|
|
78
91
|
|
|
79
|
-
const emit = defineEmits<{ 'update:modelValue': [unknown[]]; debounced: [string] }>()
|
|
92
|
+
const emit = defineEmits<{ blur: []; 'update:modelValue': [unknown[]]; debounced: [string] }>()
|
|
93
|
+
|
|
94
|
+
const rootEl = ref<HTMLElement | null>(null)
|
|
95
|
+
const validation = useFieldValidation({
|
|
96
|
+
value: () => props.modelValue,
|
|
97
|
+
rules: () => props.rules,
|
|
98
|
+
required: () => props.required,
|
|
99
|
+
error: () => props.error,
|
|
100
|
+
errorLabel: () => props.errorLabel,
|
|
101
|
+
name: () => props.name,
|
|
102
|
+
validateOn: () => props.validateOn,
|
|
103
|
+
validateDebounce: () => props.validateDebounce,
|
|
104
|
+
disabled: () => props.disabled,
|
|
105
|
+
focus: () => { inputEl.value?.focus() },
|
|
106
|
+
el: () => inputEl.value,
|
|
107
|
+
setValue: (v) => emit('update:modelValue', v as unknown[]),
|
|
108
|
+
})
|
|
109
|
+
/** Its own `disabled` or its MForm's */
|
|
110
|
+
const isDisabled = validation.disabled
|
|
111
|
+
const { hasError, message: errorMessage, messageId } = validation
|
|
80
112
|
|
|
81
113
|
const locale = useLocale()
|
|
82
114
|
const id = useId()
|
|
@@ -169,7 +201,7 @@ function toggle(value: unknown) {
|
|
|
169
201
|
|
|
170
202
|
function removeChip(value: unknown, e: Event) {
|
|
171
203
|
e.stopPropagation()
|
|
172
|
-
if (
|
|
204
|
+
if (isDisabled.value) return
|
|
173
205
|
emit('update:modelValue', props.modelValue.filter((v) => !eq(v, value)))
|
|
174
206
|
nextTick(() => inputEl.value?.focus())
|
|
175
207
|
}
|
|
@@ -198,7 +230,7 @@ const modalFilteredOptions = computed(() => {
|
|
|
198
230
|
})
|
|
199
231
|
|
|
200
232
|
function openDropdown() {
|
|
201
|
-
if (
|
|
233
|
+
if (isDisabled.value || open.value) return
|
|
202
234
|
if (props.mode === 'modal') {
|
|
203
235
|
modalOpen.value = true
|
|
204
236
|
modalSearch.value = ''
|
|
@@ -332,20 +364,20 @@ const triggerClasses = computed(() => {
|
|
|
332
364
|
]
|
|
333
365
|
|
|
334
366
|
if (props.variant === 'outlined') {
|
|
335
|
-
const border =
|
|
367
|
+
const border = isDisabled.value
|
|
336
368
|
? 'border-on-surface/12'
|
|
337
369
|
: open.value
|
|
338
|
-
? (
|
|
339
|
-
: (
|
|
370
|
+
? (hasError.value ? 'border-2 border-error' : 'border-2 border-primary')
|
|
371
|
+
: (hasError.value ? 'border-error' : 'border-outline hover:border-on-surface')
|
|
340
372
|
return [...base, 'rounded-xs border bg-transparent py-2', border].join(' ')
|
|
341
373
|
}
|
|
342
374
|
|
|
343
|
-
const border =
|
|
375
|
+
const border = isDisabled.value
|
|
344
376
|
? 'border-on-surface/38'
|
|
345
377
|
: open.value
|
|
346
|
-
? (
|
|
347
|
-
: (
|
|
348
|
-
const bg =
|
|
378
|
+
? (hasError.value ? 'border-b-2 border-error' : 'border-b-2 border-primary')
|
|
379
|
+
: (hasError.value ? 'border-error' : 'border-on-surface-variant hover:border-on-surface')
|
|
380
|
+
const bg = isDisabled.value
|
|
349
381
|
? 'bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]'
|
|
350
382
|
: 'bg-surface-container-highest'
|
|
351
383
|
return [...base, 'rounded-t-xs border-b pb-2', isFloated.value ? 'pt-7' : 'pt-4', bg, border].join(' ')
|
|
@@ -357,17 +389,30 @@ const labelClasses = computed(() =>
|
|
|
357
389
|
leading: !!props.leadingIcon,
|
|
358
390
|
right: rightInset.value,
|
|
359
391
|
floated: isFloated.value,
|
|
360
|
-
color:
|
|
392
|
+
color: isDisabled.value
|
|
361
393
|
? 'text-on-surface/38'
|
|
362
394
|
: open.value
|
|
363
|
-
? (
|
|
364
|
-
: (
|
|
395
|
+
? (hasError.value ? 'text-error' : 'text-primary')
|
|
396
|
+
: (hasError.value ? 'text-error' : 'text-on-surface-variant'),
|
|
365
397
|
}),
|
|
366
398
|
)
|
|
399
|
+
|
|
400
|
+
defineExpose({
|
|
401
|
+
/** Checks its rules and shows the result; resolves to whether they pass */
|
|
402
|
+
validate: validation.validate,
|
|
403
|
+
/** Hides its validation error (until the next check) */
|
|
404
|
+
resetValidation: validation.resetValidation,
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
// Last: it watches `open`, declared above
|
|
408
|
+
const onFocusOut = useFocusLeave(() => rootEl.value, () => {
|
|
409
|
+
validation.onBlur()
|
|
410
|
+
emit('blur')
|
|
411
|
+
}, () => open.value)
|
|
367
412
|
</script>
|
|
368
413
|
|
|
369
414
|
<template>
|
|
370
|
-
<div class="flex flex-col gap-1" v-bind="$attrs">
|
|
415
|
+
<div ref="rootEl" class="flex flex-col gap-1" v-bind="$attrs" @focusout="onFocusOut">
|
|
371
416
|
<div
|
|
372
417
|
ref="fieldEl"
|
|
373
418
|
class="relative"
|
|
@@ -380,7 +425,7 @@ const labelClasses = computed(() =>
|
|
|
380
425
|
class="pointer-events-none absolute left-3.5"
|
|
381
426
|
:class="[
|
|
382
427
|
variant === 'filled' ? 'top-4.5' : 'top-4',
|
|
383
|
-
|
|
428
|
+
isDisabled ? 'text-on-surface/38' : 'text-on-surface-variant',
|
|
384
429
|
]"
|
|
385
430
|
>
|
|
386
431
|
<MIcon :name="leadingIcon" :size="24" />
|
|
@@ -390,7 +435,7 @@ const labelClasses = computed(() =>
|
|
|
390
435
|
<div
|
|
391
436
|
:class="[
|
|
392
437
|
triggerClasses,
|
|
393
|
-
|
|
438
|
+
isDisabled ? 'pointer-events-none' : 'cursor-text',
|
|
394
439
|
]"
|
|
395
440
|
@click="inputEl?.focus()"
|
|
396
441
|
>
|
|
@@ -399,12 +444,12 @@ const labelClasses = computed(() =>
|
|
|
399
444
|
v-for="(chip, i) in displayChips"
|
|
400
445
|
:key="i"
|
|
401
446
|
class="inline-flex max-w-full min-w-0 items-center gap-1 rounded-full px-2 py-0.5 text-label-small"
|
|
402
|
-
:class="
|
|
447
|
+
:class="isDisabled ? 'bg-on-surface/12 text-on-surface/38' : 'bg-secondary-container text-on-secondary-container'"
|
|
403
448
|
>
|
|
404
449
|
<span v-overflow-title class="min-w-0 truncate">{{ chip.label }}</span>
|
|
405
450
|
<button
|
|
406
451
|
:aria-label="`${locale.remove} ${chip.label}`"
|
|
407
|
-
v-if="!
|
|
452
|
+
v-if="!isDisabled"
|
|
408
453
|
type="button"
|
|
409
454
|
class="flex h-4 w-4 shrink-0 items-center justify-center rounded-full hover:bg-on-secondary-container/20"
|
|
410
455
|
@click="removeChip(chip.value, $event)"
|
|
@@ -432,6 +477,8 @@ const labelClasses = computed(() =>
|
|
|
432
477
|
<input
|
|
433
478
|
:id="id"
|
|
434
479
|
ref="inputEl"
|
|
480
|
+
:aria-invalid="hasError || undefined"
|
|
481
|
+
:aria-describedby="errorMessage || hint ? messageId : undefined"
|
|
435
482
|
type="text"
|
|
436
483
|
:value="search"
|
|
437
484
|
:placeholder="!label && !hasValue ? placeholder : undefined"
|
|
@@ -444,7 +491,7 @@ const labelClasses = computed(() =>
|
|
|
444
491
|
:aria-disabled="disabled"
|
|
445
492
|
:class="[
|
|
446
493
|
'flex-1 min-w-[60px] bg-transparent text-body-large outline-none placeholder:text-on-surface-variant',
|
|
447
|
-
|
|
494
|
+
hasError ? 'caret-error' : 'caret-primary',
|
|
448
495
|
disabled ? 'text-on-surface/38' : 'text-on-surface',
|
|
449
496
|
]"
|
|
450
497
|
@focus="onInputFocus"
|
|
@@ -484,8 +531,8 @@ const labelClasses = computed(() =>
|
|
|
484
531
|
</div>
|
|
485
532
|
</div>
|
|
486
533
|
|
|
487
|
-
<p v-if="
|
|
488
|
-
<p v-else-if="hint" class="px-4 text-body-small text-on-surface-variant">{{ hint }}</p>
|
|
534
|
+
<p v-if="errorMessage" :id="messageId" role="alert" class="px-4 text-body-small text-error">{{ errorMessage }}</p>
|
|
535
|
+
<p v-else-if="hint" :id="messageId" class="px-4 text-body-small text-on-surface-variant">{{ hint }}</p>
|
|
489
536
|
</div>
|
|
490
537
|
|
|
491
538
|
<!-- Docked dropdown -->
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* @event update:modelValue Emitted with the new array of selected values.
|
|
7
7
|
*/
|
|
8
8
|
import { computed, ref, useId, onMounted, onUnmounted, nextTick, watch } from 'vue'
|
|
9
|
+
import { useFieldValidation, useFocusLeave } from '../composables/_useFieldValidation'
|
|
10
|
+
import type { ValidateOn, ValidationRule } from '../composables/validation'
|
|
9
11
|
import MIcon from './MIcon.vue'
|
|
10
12
|
import MIconButton from './MIconButton.vue'
|
|
11
13
|
import MCheckbox from './MCheckbox.vue'
|
|
@@ -43,10 +45,21 @@ const props = withDefaults(
|
|
|
43
45
|
mode?: 'docked' | 'modal'
|
|
44
46
|
/** Disables the field */
|
|
45
47
|
disabled?: boolean
|
|
46
|
-
/** Error state */
|
|
47
|
-
error?: boolean
|
|
48
|
+
/** Error state. A string is also the message (`:error="errors.x"`) */
|
|
49
|
+
error?: boolean | string
|
|
48
50
|
/** Error message shown when error is true */
|
|
49
51
|
errorLabel?: string
|
|
52
|
+
/**
|
|
53
|
+
* Validation rules: functions `(value, ctx) => true | 'message'` (may be async; see the built-in `required`,
|
|
54
|
+
* `email`, `minLength`…) or a Standard Schema (zod, valibot…). Checked in order; the first failure is shown
|
|
55
|
+
*/
|
|
56
|
+
rules?: ValidationRule | ValidationRule[]
|
|
57
|
+
/** When the rules are checked and shown: on leaving the field (default; live after that), while typing, or only on submit (`MForm`) */
|
|
58
|
+
validateOn?: ValidateOn
|
|
59
|
+
/** Wait this long (ms) after the value stops changing before re-checking (one request for an async rule, not one per key). Defaults to its `MForm`'s */
|
|
60
|
+
validateDebounce?: number
|
|
61
|
+
/** The key of this field in its `MForm`'s values, errors and schema */
|
|
62
|
+
name?: string
|
|
50
63
|
/** Hint text below the field */
|
|
51
64
|
hint?: string
|
|
52
65
|
/** Marks as required — adds a red asterisk after the label */
|
|
@@ -83,7 +96,26 @@ const props = withDefaults(
|
|
|
83
96
|
},
|
|
84
97
|
)
|
|
85
98
|
|
|
86
|
-
const emit = defineEmits<{ 'update:modelValue': [unknown[]] }>()
|
|
99
|
+
const emit = defineEmits<{ blur: []; 'update:modelValue': [unknown[]] }>()
|
|
100
|
+
|
|
101
|
+
const rootEl = ref<HTMLElement | null>(null)
|
|
102
|
+
const validation = useFieldValidation({
|
|
103
|
+
value: () => props.modelValue,
|
|
104
|
+
rules: () => props.rules,
|
|
105
|
+
required: () => props.required,
|
|
106
|
+
error: () => props.error,
|
|
107
|
+
errorLabel: () => props.errorLabel,
|
|
108
|
+
name: () => props.name,
|
|
109
|
+
validateOn: () => props.validateOn,
|
|
110
|
+
validateDebounce: () => props.validateDebounce,
|
|
111
|
+
disabled: () => props.disabled,
|
|
112
|
+
focus: () => { fieldEl.value?.querySelector<HTMLElement>('[tabindex]')?.focus() },
|
|
113
|
+
el: () => fieldEl.value,
|
|
114
|
+
setValue: (v) => emit('update:modelValue', v as unknown[]),
|
|
115
|
+
})
|
|
116
|
+
/** Its own `disabled` or its MForm's */
|
|
117
|
+
const isDisabled = validation.disabled
|
|
118
|
+
const { hasError, message: errorMessage, messageId } = validation
|
|
87
119
|
|
|
88
120
|
const id = useId()
|
|
89
121
|
const open = ref(false)
|
|
@@ -157,7 +189,7 @@ function toggle(value: unknown) {
|
|
|
157
189
|
|
|
158
190
|
function removeChip(value: unknown, e: Event) {
|
|
159
191
|
e.stopPropagation()
|
|
160
|
-
if (
|
|
192
|
+
if (isDisabled.value) return
|
|
161
193
|
emit('update:modelValue', props.modelValue.filter((v) => !eq(v, value)))
|
|
162
194
|
}
|
|
163
195
|
|
|
@@ -172,7 +204,7 @@ function computeDropPos() {
|
|
|
172
204
|
}
|
|
173
205
|
|
|
174
206
|
async function openDropdown() {
|
|
175
|
-
if (
|
|
207
|
+
if (isDisabled.value) return
|
|
176
208
|
if (props.mode === 'modal') {
|
|
177
209
|
modalOpen.value = true
|
|
178
210
|
modalSearch.value = ''
|
|
@@ -227,26 +259,26 @@ const triggerClasses = computed(() => {
|
|
|
227
259
|
const base = [
|
|
228
260
|
'flex min-h-[56px] w-full min-w-0 items-center gap-1.5 flex-wrap outline-none',
|
|
229
261
|
'transition-[border-color,border-width] duration-150',
|
|
230
|
-
|
|
262
|
+
isDisabled.value ? 'cursor-not-allowed' : 'cursor-pointer',
|
|
231
263
|
props.leadingIcon ? 'pl-12' : 'pl-4',
|
|
232
264
|
FIELD_PADDING_RIGHT[rightInset.value],
|
|
233
265
|
]
|
|
234
266
|
|
|
235
267
|
if (props.variant === 'outlined') {
|
|
236
|
-
const border =
|
|
268
|
+
const border = isDisabled.value
|
|
237
269
|
? 'border-on-surface/12'
|
|
238
270
|
: highlighted.value
|
|
239
|
-
? (
|
|
240
|
-
: (
|
|
271
|
+
? (hasError.value ? 'border-2 border-error' : 'border-2 border-primary')
|
|
272
|
+
: (hasError.value ? 'border-error' : 'border-outline hover:border-on-surface')
|
|
241
273
|
return [...base, 'rounded-xs border bg-transparent py-2', border].join(' ')
|
|
242
274
|
}
|
|
243
275
|
|
|
244
|
-
const border =
|
|
276
|
+
const border = isDisabled.value
|
|
245
277
|
? 'border-on-surface/38'
|
|
246
278
|
: highlighted.value
|
|
247
|
-
? (
|
|
248
|
-
: (
|
|
249
|
-
const bg =
|
|
279
|
+
? (hasError.value ? 'border-b-2 border-error' : 'border-b-2 border-primary')
|
|
280
|
+
: (hasError.value ? 'border-error' : 'border-on-surface-variant hover:border-on-surface')
|
|
281
|
+
const bg = isDisabled.value
|
|
250
282
|
? 'bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]'
|
|
251
283
|
: 'bg-surface-container-highest'
|
|
252
284
|
return [
|
|
@@ -264,17 +296,30 @@ const labelClasses = computed(() =>
|
|
|
264
296
|
leading: !!props.leadingIcon,
|
|
265
297
|
right: rightInset.value,
|
|
266
298
|
floated: highlighted.value || hasValue.value,
|
|
267
|
-
color:
|
|
299
|
+
color: isDisabled.value
|
|
268
300
|
? 'text-on-surface/38'
|
|
269
301
|
: highlighted.value
|
|
270
|
-
? (
|
|
271
|
-
: (
|
|
302
|
+
? (hasError.value ? 'text-error' : 'text-primary')
|
|
303
|
+
: (hasError.value ? 'text-error' : 'text-on-surface-variant'),
|
|
272
304
|
}),
|
|
273
305
|
)
|
|
306
|
+
|
|
307
|
+
defineExpose({
|
|
308
|
+
/** Checks its rules and shows the result; resolves to whether they pass */
|
|
309
|
+
validate: validation.validate,
|
|
310
|
+
/** Hides its validation error (until the next check) */
|
|
311
|
+
resetValidation: validation.resetValidation,
|
|
312
|
+
})
|
|
313
|
+
|
|
314
|
+
// Last: it watches `open`, declared above
|
|
315
|
+
const onFocusOut = useFocusLeave(() => rootEl.value, () => {
|
|
316
|
+
validation.onBlur()
|
|
317
|
+
emit('blur')
|
|
318
|
+
}, () => open.value)
|
|
274
319
|
</script>
|
|
275
320
|
|
|
276
321
|
<template>
|
|
277
|
-
<div class="flex flex-col gap-1" v-bind="$attrs">
|
|
322
|
+
<div ref="rootEl" class="flex flex-col gap-1" v-bind="$attrs" @focusout="onFocusOut">
|
|
278
323
|
<div
|
|
279
324
|
ref="fieldEl"
|
|
280
325
|
class="relative"
|
|
@@ -286,7 +331,7 @@ const labelClasses = computed(() =>
|
|
|
286
331
|
class="pointer-events-none absolute left-3.5"
|
|
287
332
|
:class="[
|
|
288
333
|
variant === 'filled' ? 'top-4.5' : 'top-4',
|
|
289
|
-
|
|
334
|
+
isDisabled ? 'text-on-surface/38' : 'text-on-surface-variant',
|
|
290
335
|
]"
|
|
291
336
|
>
|
|
292
337
|
<MIcon :name="leadingIcon" :size="24" />
|
|
@@ -297,7 +342,9 @@ const labelClasses = computed(() =>
|
|
|
297
342
|
:id="id"
|
|
298
343
|
:class="triggerClasses"
|
|
299
344
|
role="button"
|
|
300
|
-
:tabindex="
|
|
345
|
+
:tabindex="isDisabled ? -1 : 0"
|
|
346
|
+
:aria-invalid="hasError || undefined"
|
|
347
|
+
:aria-describedby="errorMessage || hint ? messageId : undefined"
|
|
301
348
|
:aria-expanded="open || modalOpen"
|
|
302
349
|
:aria-haspopup="true"
|
|
303
350
|
:aria-controls="open ? `${id}-list` : undefined"
|
|
@@ -314,12 +361,12 @@ const labelClasses = computed(() =>
|
|
|
314
361
|
v-for="(chip, i) in displayChips"
|
|
315
362
|
:key="i"
|
|
316
363
|
class="inline-flex max-w-full min-w-0 items-center gap-1 rounded-full px-2 py-0.5 text-label-small"
|
|
317
|
-
:class="
|
|
364
|
+
:class="isDisabled ? 'bg-on-surface/12 text-on-surface/38' : 'bg-secondary-container text-on-secondary-container'"
|
|
318
365
|
>
|
|
319
366
|
<span v-overflow-title class="min-w-0 truncate">{{ chip.label }}</span>
|
|
320
367
|
<button
|
|
321
368
|
:aria-label="`${locale.remove} ${chip.label}`"
|
|
322
|
-
v-if="!
|
|
369
|
+
v-if="!isDisabled"
|
|
323
370
|
type="button"
|
|
324
371
|
class="flex h-4 w-4 shrink-0 items-center justify-center rounded-full hover:bg-on-secondary-container/20"
|
|
325
372
|
@click="removeChip(chip.value, $event)"
|
|
@@ -375,8 +422,8 @@ const labelClasses = computed(() =>
|
|
|
375
422
|
</div>
|
|
376
423
|
</div>
|
|
377
424
|
|
|
378
|
-
<p v-if="
|
|
379
|
-
<p v-else-if="hint" class="px-4 text-body-small text-on-surface-variant">{{ hint }}</p>
|
|
425
|
+
<p v-if="errorMessage" :id="messageId" role="alert" class="px-4 text-body-small text-error">{{ errorMessage }}</p>
|
|
426
|
+
<p v-else-if="hint" :id="messageId" class="px-4 text-body-small text-on-surface-variant">{{ hint }}</p>
|
|
380
427
|
</div>
|
|
381
428
|
|
|
382
429
|
<!-- Docked dropdown -->
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* clicks/arrow keys still emit instantly
|
|
8
8
|
*/
|
|
9
9
|
import { computed, ref, useId } from 'vue'
|
|
10
|
+
import { useFieldValidation, useFocusLeave } from '../composables/_useFieldValidation'
|
|
11
|
+
import type { ValidateOn, ValidationRule } from '../composables/validation'
|
|
10
12
|
import MIcon from './MIcon.vue'
|
|
11
13
|
import MIconButton from './MIconButton.vue'
|
|
12
14
|
import { useFieldBg } from '../composables/useFieldBg'
|
|
@@ -27,10 +29,21 @@ const props = withDefaults(
|
|
|
27
29
|
max?: number
|
|
28
30
|
/** Increment/decrement step */
|
|
29
31
|
step?: number
|
|
30
|
-
/** Error state */
|
|
31
|
-
error?: boolean
|
|
32
|
+
/** Error state. A string is also the message (`:error="errors.x"`) */
|
|
33
|
+
error?: boolean | string
|
|
32
34
|
/** Error message shown when error is true */
|
|
33
35
|
errorLabel?: string
|
|
36
|
+
/**
|
|
37
|
+
* Validation rules: functions `(value, ctx) => true | 'message'` (may be async; see the built-in `required`,
|
|
38
|
+
* `email`, `minLength`…) or a Standard Schema (zod, valibot…). Checked in order; the first failure is shown
|
|
39
|
+
*/
|
|
40
|
+
rules?: ValidationRule | ValidationRule[]
|
|
41
|
+
/** When the rules are checked and shown: on leaving the field (default; live after that), while typing, or only on submit (`MForm`) */
|
|
42
|
+
validateOn?: ValidateOn
|
|
43
|
+
/** Wait this long (ms) after the value stops changing before re-checking (one request for an async rule, not one per key). Defaults to its `MForm`'s */
|
|
44
|
+
validateDebounce?: number
|
|
45
|
+
/** The key of this field in its `MForm`'s values, errors and schema */
|
|
46
|
+
name?: string
|
|
34
47
|
/** Hint text */
|
|
35
48
|
hint?: string
|
|
36
49
|
/** Disables the field */
|
|
@@ -57,7 +70,30 @@ const props = withDefaults(
|
|
|
57
70
|
},
|
|
58
71
|
)
|
|
59
72
|
|
|
60
|
-
const emit = defineEmits<{ 'update:modelValue': [number | null]; debounced: [number | null] }>()
|
|
73
|
+
const emit = defineEmits<{ blur: []; 'update:modelValue': [number | null]; debounced: [number | null] }>()
|
|
74
|
+
|
|
75
|
+
const rootEl = ref<HTMLElement | null>(null)
|
|
76
|
+
const validation = useFieldValidation({
|
|
77
|
+
value: () => props.modelValue,
|
|
78
|
+
rules: () => props.rules,
|
|
79
|
+
required: () => props.required,
|
|
80
|
+
error: () => props.error,
|
|
81
|
+
errorLabel: () => props.errorLabel,
|
|
82
|
+
name: () => props.name,
|
|
83
|
+
validateOn: () => props.validateOn,
|
|
84
|
+
validateDebounce: () => props.validateDebounce,
|
|
85
|
+
disabled: () => props.disabled,
|
|
86
|
+
focus: () => { inputEl.value?.focus() },
|
|
87
|
+
el: () => inputEl.value,
|
|
88
|
+
setValue: (v) => emit('update:modelValue', v as number | null),
|
|
89
|
+
})
|
|
90
|
+
/** Its own `disabled` or its MForm's */
|
|
91
|
+
const isDisabled = validation.disabled
|
|
92
|
+
const { hasError, message: errorMessage, messageId } = validation
|
|
93
|
+
const onFocusOut = useFocusLeave(() => rootEl.value, () => {
|
|
94
|
+
validation.onBlur()
|
|
95
|
+
emit('blur')
|
|
96
|
+
})
|
|
61
97
|
|
|
62
98
|
const id = useId()
|
|
63
99
|
const fieldBgEl = ref<HTMLElement | null>(null)
|
|
@@ -90,14 +126,14 @@ function onInput(e: Event) {
|
|
|
90
126
|
}
|
|
91
127
|
|
|
92
128
|
function increment() {
|
|
93
|
-
if (
|
|
129
|
+
if (isDisabled.value) return
|
|
94
130
|
const v = clamp((props.modelValue ?? 0) + props.step)
|
|
95
131
|
emit('update:modelValue', v)
|
|
96
132
|
if (props.debounce > 0) emitDebounced(v)
|
|
97
133
|
}
|
|
98
134
|
|
|
99
135
|
function decrement() {
|
|
100
|
-
if (
|
|
136
|
+
if (isDisabled.value) return
|
|
101
137
|
const v = clamp((props.modelValue ?? 0) - props.step)
|
|
102
138
|
emit('update:modelValue', v)
|
|
103
139
|
if (props.debounce > 0) emitDebounced(v)
|
|
@@ -118,13 +154,13 @@ const inputClasses = computed(() => {
|
|
|
118
154
|
'peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent',
|
|
119
155
|
'transition-[border-color,border-width] duration-150',
|
|
120
156
|
'disabled:cursor-not-allowed disabled:text-on-surface/38',
|
|
121
|
-
|
|
157
|
+
hasError.value ? 'caret-error' : 'caret-primary',
|
|
122
158
|
'h-14', pl, pr,
|
|
123
159
|
]
|
|
124
160
|
if (props.variant === 'outlined') {
|
|
125
161
|
return [...base,
|
|
126
162
|
'rounded-xs border bg-transparent py-4',
|
|
127
|
-
|
|
163
|
+
hasError.value
|
|
128
164
|
? 'border-error focus:border-2 focus:border-error'
|
|
129
165
|
: 'border-outline hover:border-on-surface focus:border-2 focus:border-primary',
|
|
130
166
|
'disabled:border-on-surface/12',
|
|
@@ -132,7 +168,7 @@ const inputClasses = computed(() => {
|
|
|
132
168
|
}
|
|
133
169
|
return [...base,
|
|
134
170
|
'rounded-t-xs bg-surface-container-highest border-b pt-6 pb-2',
|
|
135
|
-
|
|
171
|
+
hasError.value
|
|
136
172
|
? 'border-error focus:border-b-2 focus:border-error'
|
|
137
173
|
: 'border-on-surface-variant hover:border-on-surface focus:border-b-2 focus:border-primary',
|
|
138
174
|
'disabled:border-on-surface/38 disabled:bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]',
|
|
@@ -146,13 +182,17 @@ const labelClasses = computed(() =>
|
|
|
146
182
|
right: rightInset.value,
|
|
147
183
|
floated: 'peer',
|
|
148
184
|
color: [
|
|
149
|
-
|
|
185
|
+
hasError.value ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',
|
|
150
186
|
'peer-disabled:text-on-surface/38',
|
|
151
187
|
].join(' '),
|
|
152
188
|
}),
|
|
153
189
|
)
|
|
154
190
|
|
|
155
191
|
defineExpose({
|
|
192
|
+
/** Checks its rules and shows the result; resolves to whether they pass */
|
|
193
|
+
validate: validation.validate,
|
|
194
|
+
/** Hides its validation error (until the next check) */
|
|
195
|
+
resetValidation: validation.resetValidation,
|
|
156
196
|
/** The `<input>` (or `<textarea>`) element */
|
|
157
197
|
inputEl: inputEl,
|
|
158
198
|
/** Focuses the field */
|
|
@@ -165,7 +205,7 @@ defineExpose({
|
|
|
165
205
|
</script>
|
|
166
206
|
|
|
167
207
|
<template>
|
|
168
|
-
<div class="flex flex-col gap-1">
|
|
208
|
+
<div ref="rootEl" class="flex flex-col gap-1" @focusout="onFocusOut">
|
|
169
209
|
<div
|
|
170
210
|
ref="fieldBgEl"
|
|
171
211
|
class="relative"
|
|
@@ -177,7 +217,7 @@ defineExpose({
|
|
|
177
217
|
class="pointer-events-none absolute left-3.5"
|
|
178
218
|
:class="[
|
|
179
219
|
variant === 'filled' ? 'top-4.5' : 'top-4',
|
|
180
|
-
|
|
220
|
+
isDisabled ? 'text-on-surface/38' : 'text-on-surface-variant',
|
|
181
221
|
]"
|
|
182
222
|
>
|
|
183
223
|
<MIcon :name="leadingIcon" :size="24" />
|
|
@@ -185,10 +225,12 @@ defineExpose({
|
|
|
185
225
|
|
|
186
226
|
<input
|
|
187
227
|
ref="inputEl"
|
|
228
|
+
:aria-invalid="hasError || undefined"
|
|
229
|
+
:aria-describedby="errorMessage || hint ? messageId : undefined"
|
|
188
230
|
:id="id"
|
|
189
231
|
type="number"
|
|
190
232
|
:value="modelValue ?? ''"
|
|
191
|
-
:disabled="
|
|
233
|
+
:disabled="isDisabled"
|
|
192
234
|
:required="required"
|
|
193
235
|
:min="min"
|
|
194
236
|
:max="max"
|
|
@@ -205,13 +247,13 @@ defineExpose({
|
|
|
205
247
|
</label>
|
|
206
248
|
|
|
207
249
|
<div v-if="stepper" class="absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5">
|
|
208
|
-
<MIconButton icon="remove" label="Decrease" :size="32" :disabled="
|
|
209
|
-
<MIconButton icon="add" label="Increase" :size="32" :disabled="
|
|
250
|
+
<MIconButton icon="remove" label="Decrease" :size="32" :disabled="isDisabled || (min !== undefined && (modelValue ?? 0) <= min)" @click="decrement" />
|
|
251
|
+
<MIconButton icon="add" label="Increase" :size="32" :disabled="isDisabled || (max !== undefined && (modelValue ?? 0) >= max)" @click="increment" />
|
|
210
252
|
</div>
|
|
211
253
|
</div>
|
|
212
254
|
|
|
213
|
-
<p v-if="
|
|
214
|
-
<p v-else-if="hint" class="px-4 text-body-small text-on-surface-variant">{{ hint }}</p>
|
|
255
|
+
<p v-if="errorMessage" :id="messageId" role="alert" class="px-4 text-body-small text-error">{{ errorMessage }}</p>
|
|
256
|
+
<p v-else-if="hint" :id="messageId" class="px-4 text-body-small text-on-surface-variant">{{ hint }}</p>
|
|
215
257
|
</div>
|
|
216
258
|
</template>
|
|
217
259
|
|