@coreui/vue-pro 5.10.0 → 5.11.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/README.md +1 -1
- package/dist/cjs/components/button/CButton.js +1 -1
- package/dist/cjs/components/button/CButton.js.map +1 -1
- package/dist/cjs/components/calendar/CCalendar.js +4 -3
- package/dist/cjs/components/calendar/CCalendar.js.map +1 -1
- package/dist/cjs/components/calendar/utils.d.ts +8 -0
- package/dist/cjs/components/calendar/utils.js +16 -0
- package/dist/cjs/components/calendar/utils.js.map +1 -1
- package/dist/cjs/components/form/CFormControlWrapper.d.ts +2 -0
- package/dist/cjs/components/form/CFormControlWrapper.js +9 -1
- package/dist/cjs/components/form/CFormControlWrapper.js.map +1 -1
- package/dist/cjs/components/index.d.ts +2 -0
- package/dist/cjs/components/index.js +44 -36
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/components/link/CLink.js.map +1 -1
- package/dist/cjs/components/loading-button/CLoadingButton.d.ts +2 -2
- package/dist/cjs/components/multi-select/CMultiSelect.d.ts +12 -0
- package/dist/cjs/components/multi-select/CMultiSelect.js +23 -1
- package/dist/cjs/components/multi-select/CMultiSelect.js.map +1 -1
- package/dist/cjs/components/nav/CNav.d.ts +2 -2
- package/dist/cjs/components/nav/CNav.js +3 -2
- package/dist/cjs/components/nav/CNav.js.map +1 -1
- package/dist/cjs/components/offcanvas/COffcanvas.js.map +1 -1
- package/dist/cjs/components/password-input/CPasswordInput.d.ts +190 -0
- package/dist/cjs/components/password-input/CPasswordInput.js +178 -0
- package/dist/cjs/components/password-input/CPasswordInput.js.map +1 -0
- package/dist/cjs/components/password-input/index.d.ts +6 -0
- package/dist/cjs/components/password-input/index.js +13 -0
- package/dist/cjs/components/password-input/index.js.map +1 -0
- package/dist/cjs/components/popover/CPopover.d.ts +1 -1
- package/dist/cjs/components/rating/CRating.d.ts +1 -1
- package/dist/cjs/components/smart-table/CSmartTable.js +2 -2
- package/dist/cjs/components/smart-table/CSmartTable.js.map +1 -1
- package/dist/cjs/components/smart-table/utils.js.map +1 -1
- package/dist/cjs/components/stepper/CStepper.d.ts +168 -0
- package/dist/cjs/components/stepper/CStepper.js +305 -0
- package/dist/cjs/components/stepper/CStepper.js.map +1 -0
- package/dist/cjs/components/stepper/index.d.ts +6 -0
- package/dist/cjs/components/stepper/index.js +13 -0
- package/dist/cjs/components/stepper/index.js.map +1 -0
- package/dist/cjs/components/stepper/types.d.ts +15 -0
- package/dist/cjs/components/tabs/CTab.js.map +1 -1
- package/dist/cjs/components/tabs/CTabList.d.ts +2 -2
- package/dist/cjs/components/tabs/CTabList.js +3 -2
- package/dist/cjs/components/tabs/CTabList.js.map +1 -1
- package/dist/cjs/components/time-picker/utils.d.ts +10 -0
- package/dist/cjs/components/time-picker/utils.js +25 -9
- package/dist/cjs/components/time-picker/utils.js.map +1 -1
- package/dist/cjs/components/tooltip/CTooltip.d.ts +1 -1
- package/dist/cjs/components/widgets/CWidgetStatsB.js +2 -2
- package/dist/cjs/components/widgets/CWidgetStatsB.js.map +1 -1
- package/dist/cjs/components/widgets/CWidgetStatsC.js +2 -2
- package/dist/cjs/components/widgets/CWidgetStatsC.js.map +1 -1
- package/dist/cjs/index.js +50 -42
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/node_modules/vue-types/dist/index.js +567 -0
- package/dist/cjs/node_modules/vue-types/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/vue-types/dist/shared/vue-types.8139b772.js +29 -0
- package/dist/cjs/node_modules/vue-types/dist/shared/vue-types.8139b772.js.map +1 -0
- package/dist/cjs/utils/getNextActiveElement.js.map +1 -1
- package/dist/esm/components/avatar/CAvatar.js +1 -1
- package/dist/esm/components/badge/CBadge.js +1 -1
- package/dist/esm/components/button/CButton.js +2 -2
- package/dist/esm/components/button/CButton.js.map +1 -1
- package/dist/esm/components/calendar/CCalendar.js +5 -4
- package/dist/esm/components/calendar/CCalendar.js.map +1 -1
- package/dist/esm/components/calendar/utils.d.ts +8 -0
- package/dist/esm/components/calendar/utils.js +16 -1
- package/dist/esm/components/calendar/utils.js.map +1 -1
- package/dist/esm/components/card/CCard.js +1 -1
- package/dist/esm/components/dropdown/CDropdownToggle.js +2 -2
- package/dist/esm/components/form/CFormControlWrapper.d.ts +2 -0
- package/dist/esm/components/form/CFormControlWrapper.js +9 -1
- package/dist/esm/components/form/CFormControlWrapper.js.map +1 -1
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.js +4 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/link/CLink.js.map +1 -1
- package/dist/esm/components/loading-button/CLoadingButton.d.ts +2 -2
- package/dist/esm/components/multi-select/CMultiSelect.d.ts +12 -0
- package/dist/esm/components/multi-select/CMultiSelect.js +24 -2
- package/dist/esm/components/multi-select/CMultiSelect.js.map +1 -1
- package/dist/esm/components/nav/CNav.d.ts +2 -2
- package/dist/esm/components/nav/CNav.js +3 -2
- package/dist/esm/components/nav/CNav.js.map +1 -1
- package/dist/esm/components/offcanvas/COffcanvas.js.map +1 -1
- package/dist/esm/components/password-input/CPasswordInput.d.ts +190 -0
- package/dist/esm/components/password-input/CPasswordInput.js +176 -0
- package/dist/esm/components/password-input/CPasswordInput.js.map +1 -0
- package/dist/esm/components/password-input/index.d.ts +6 -0
- package/dist/esm/components/password-input/index.js +10 -0
- package/dist/esm/components/password-input/index.js.map +1 -0
- package/dist/esm/components/popover/CPopover.d.ts +1 -1
- package/dist/esm/components/rating/CRating.d.ts +1 -1
- package/dist/esm/components/smart-table/CSmartTable.js +2 -2
- package/dist/esm/components/smart-table/CSmartTable.js.map +1 -1
- package/dist/esm/components/smart-table/CSmartTableBody.js +1 -1
- package/dist/esm/components/smart-table/utils.js.map +1 -1
- package/dist/esm/components/stepper/CStepper.d.ts +168 -0
- package/dist/esm/components/stepper/CStepper.js +303 -0
- package/dist/esm/components/stepper/CStepper.js.map +1 -0
- package/dist/esm/components/stepper/index.d.ts +6 -0
- package/dist/esm/components/stepper/index.js +10 -0
- package/dist/esm/components/stepper/index.js.map +1 -0
- package/dist/esm/components/stepper/types.d.ts +15 -0
- package/dist/esm/components/tabs/CTab.js.map +1 -1
- package/dist/esm/components/tabs/CTabList.d.ts +2 -2
- package/dist/esm/components/tabs/CTabList.js +3 -2
- package/dist/esm/components/tabs/CTabList.js.map +1 -1
- package/dist/esm/components/time-picker/utils.d.ts +10 -0
- package/dist/esm/components/time-picker/utils.js +25 -10
- package/dist/esm/components/time-picker/utils.js.map +1 -1
- package/dist/esm/components/tooltip/CTooltip.d.ts +1 -1
- package/dist/esm/components/widgets/CWidgetStatsB.js +2 -2
- package/dist/esm/components/widgets/CWidgetStatsB.js.map +1 -1
- package/dist/esm/components/widgets/CWidgetStatsC.js +2 -2
- package/dist/esm/components/widgets/CWidgetStatsC.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node_modules/vue-types/dist/index.js +541 -0
- package/dist/esm/node_modules/vue-types/dist/index.js.map +1 -0
- package/dist/esm/node_modules/vue-types/dist/shared/vue-types.8139b772.js +25 -0
- package/dist/esm/node_modules/vue-types/dist/shared/vue-types.8139b772.js.map +1 -0
- package/dist/esm/utils/getNextActiveElement.js.map +1 -1
- package/package.json +9 -9
- package/src/components/button/CButton.ts +1 -1
- package/src/components/calendar/CCalendar.ts +47 -44
- package/src/components/calendar/utils.ts +33 -10
- package/src/components/form/CFormControlWrapper.ts +35 -21
- package/src/components/index.ts +2 -0
- package/src/components/multi-select/CMultiSelect.ts +48 -25
- package/src/components/nav/CNav.ts +3 -2
- package/src/components/password-input/CPasswordInput.ts +214 -0
- package/src/components/password-input/index.ts +10 -0
- package/src/components/stepper/CStepper.ts +384 -0
- package/src/components/stepper/__tests__/CStepper.spec.ts +175 -0
- package/src/components/stepper/index.ts +10 -0
- package/src/components/stepper/types.ts +18 -0
- package/src/components/tabs/CTabList.ts +3 -2
- package/src/components/time-picker/CTimePicker.ts +22 -22
- package/src/components/time-picker/CTimePickerRollCol.ts +3 -3
- package/src/components/time-picker/utils.ts +30 -13
- package/dist/cjs/node_modules/is-plain-object/dist/is-plain-object.js +0 -37
- package/dist/cjs/node_modules/is-plain-object/dist/is-plain-object.js.map +0 -1
- package/dist/cjs/node_modules/vue-types/dist/vue-types.modern.js +0 -33
- package/dist/cjs/node_modules/vue-types/dist/vue-types.modern.js.map +0 -1
- package/dist/esm/node_modules/is-plain-object/dist/is-plain-object.js +0 -35
- package/dist/esm/node_modules/is-plain-object/dist/is-plain-object.js.map +0 -1
- package/dist/esm/node_modules/vue-types/dist/vue-types.modern.js +0 -6
- package/dist/esm/node_modules/vue-types/dist/vue-types.modern.js.map +0 -1
|
@@ -203,7 +203,7 @@ const CMultiSelect = defineComponent({
|
|
|
203
203
|
|
|
204
204
|
// Ensure that all values corresponding to the keys are boolean
|
|
205
205
|
const allValuesBoolean = keys.every(
|
|
206
|
-
(key) => typeof value[key as keyof typeof value] === 'boolean'
|
|
206
|
+
(key) => typeof value[key as keyof typeof value] === 'boolean'
|
|
207
207
|
)
|
|
208
208
|
|
|
209
209
|
return allValuesBoolean
|
|
@@ -296,6 +296,12 @@ const CMultiSelect = defineComponent({
|
|
|
296
296
|
* @since 4.6.0
|
|
297
297
|
*/
|
|
298
298
|
valid: Boolean,
|
|
299
|
+
/**
|
|
300
|
+
* Sets the initially selected values for the multi-select component.
|
|
301
|
+
*
|
|
302
|
+
* @since 5.11.0
|
|
303
|
+
*/
|
|
304
|
+
value: [String, Number, Array] as PropType<string | number | (string | number)[]>,
|
|
299
305
|
/**
|
|
300
306
|
* Enable virtual scroller for the options list.
|
|
301
307
|
*
|
|
@@ -365,18 +371,35 @@ const CMultiSelect = defineComponent({
|
|
|
365
371
|
isExternalSearch(props.search)
|
|
366
372
|
? [...props.options, ...filterOptionsList(searchValue.value, userOptions.value)]
|
|
367
373
|
: filterOptionsList(searchValue.value, [...props.options, ...userOptions.value]),
|
|
368
|
-
true
|
|
369
|
-
)
|
|
374
|
+
true
|
|
375
|
+
)
|
|
370
376
|
)
|
|
371
377
|
|
|
372
|
-
const flattenedOptions = computed(() =>
|
|
378
|
+
const flattenedOptions = computed(() => {
|
|
379
|
+
return flattenOptionsArray(props.options).map((option) => {
|
|
380
|
+
if (props.value && Array.isArray(props.value)) {
|
|
381
|
+
return {
|
|
382
|
+
...option,
|
|
383
|
+
selected: props.value.includes(option.value),
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if (props.value === option.value) {
|
|
388
|
+
return {
|
|
389
|
+
...option,
|
|
390
|
+
selected: true,
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return option
|
|
395
|
+
})
|
|
396
|
+
})
|
|
373
397
|
|
|
374
398
|
const userOption = computed(() => {
|
|
375
399
|
if (
|
|
376
400
|
props.allowCreateOptions &&
|
|
377
401
|
filteredOptions.value.some(
|
|
378
|
-
(option) =>
|
|
379
|
-
option.label && option.label.toLowerCase() === searchValue.value.toLowerCase(),
|
|
402
|
+
(option) => option.label && option.label.toLowerCase() === searchValue.value.toLowerCase()
|
|
380
403
|
)
|
|
381
404
|
) {
|
|
382
405
|
return false
|
|
@@ -394,10 +417,10 @@ const CMultiSelect = defineComponent({
|
|
|
394
417
|
}
|
|
395
418
|
|
|
396
419
|
const _selected = flattenedOptions.value.filter(
|
|
397
|
-
(option: Option | OptionsGroup) => option.selected === true
|
|
420
|
+
(option: Option | OptionsGroup) => option.selected === true
|
|
398
421
|
)
|
|
399
422
|
const deselected = flattenedOptions.value.filter(
|
|
400
|
-
(option: Option | OptionsGroup) => option.selected === false
|
|
423
|
+
(option: Option | OptionsGroup) => option.selected === false
|
|
401
424
|
) as Option[]
|
|
402
425
|
|
|
403
426
|
if (_selected.length > 0) {
|
|
@@ -405,14 +428,14 @@ const CMultiSelect = defineComponent({
|
|
|
405
428
|
props.multiple,
|
|
406
429
|
_selected,
|
|
407
430
|
selected.value,
|
|
408
|
-
deselected
|
|
431
|
+
deselected
|
|
409
432
|
)
|
|
410
433
|
if (!isEqual(newSelectedValue, selected.value)) {
|
|
411
434
|
selected.value = newSelectedValue
|
|
412
435
|
}
|
|
413
436
|
}
|
|
414
437
|
},
|
|
415
|
-
{ immediate: true }
|
|
438
|
+
{ immediate: true }
|
|
416
439
|
)
|
|
417
440
|
|
|
418
441
|
watch(selected, () => {
|
|
@@ -432,7 +455,7 @@ const CMultiSelect = defineComponent({
|
|
|
432
455
|
},
|
|
433
456
|
{
|
|
434
457
|
immediate: true,
|
|
435
|
-
}
|
|
458
|
+
}
|
|
436
459
|
)
|
|
437
460
|
|
|
438
461
|
watch(isOpen, () => {
|
|
@@ -481,7 +504,7 @@ const CMultiSelect = defineComponent({
|
|
|
481
504
|
items,
|
|
482
505
|
target,
|
|
483
506
|
event.key === 'ArrowDown',
|
|
484
|
-
!items.includes(target)
|
|
507
|
+
!items.includes(target)
|
|
485
508
|
).focus()
|
|
486
509
|
return
|
|
487
510
|
}
|
|
@@ -493,7 +516,7 @@ const CMultiSelect = defineComponent({
|
|
|
493
516
|
selected.value = [
|
|
494
517
|
...selected.value,
|
|
495
518
|
filteredOptions.value.find(
|
|
496
|
-
(option) => String(option.label).toLowerCase() === searchValue.value.toLowerCase()
|
|
519
|
+
(option) => String(option.label).toLowerCase() === searchValue.value.toLowerCase()
|
|
497
520
|
) as Option,
|
|
498
521
|
]
|
|
499
522
|
}
|
|
@@ -541,7 +564,7 @@ const CMultiSelect = defineComponent({
|
|
|
541
564
|
items,
|
|
542
565
|
target,
|
|
543
566
|
event.key === 'ArrowDown',
|
|
544
|
-
!items.includes(target)
|
|
567
|
+
!items.includes(target)
|
|
545
568
|
).focus()
|
|
546
569
|
}
|
|
547
570
|
}
|
|
@@ -594,7 +617,7 @@ const CMultiSelect = defineComponent({
|
|
|
594
617
|
...flattenedOptions.value.filter((option: Option | OptionsGroup) => !option.disabled),
|
|
595
618
|
...userOptions.value,
|
|
596
619
|
],
|
|
597
|
-
selected.value
|
|
620
|
+
selected.value
|
|
598
621
|
)
|
|
599
622
|
}
|
|
600
623
|
|
|
@@ -699,7 +722,7 @@ const CMultiSelect = defineComponent({
|
|
|
699
722
|
...(selected.value.length > 0 &&
|
|
700
723
|
!props.multiple && {
|
|
701
724
|
placeholder: selected.value.map(
|
|
702
|
-
(option) => option.label
|
|
725
|
+
(option) => option.label
|
|
703
726
|
)[0],
|
|
704
727
|
}),
|
|
705
728
|
...(props.multiple &&
|
|
@@ -717,9 +740,9 @@ const CMultiSelect = defineComponent({
|
|
|
717
740
|
},
|
|
718
741
|
{
|
|
719
742
|
default: () => props.placeholder,
|
|
720
|
-
}
|
|
743
|
+
}
|
|
721
744
|
),
|
|
722
|
-
}
|
|
745
|
+
}
|
|
723
746
|
),
|
|
724
747
|
h(
|
|
725
748
|
'div',
|
|
@@ -749,10 +772,10 @@ const CMultiSelect = defineComponent({
|
|
|
749
772
|
...(props.disabled && { tabIndex: -1 }),
|
|
750
773
|
}),
|
|
751
774
|
],
|
|
752
|
-
}
|
|
775
|
+
}
|
|
753
776
|
),
|
|
754
777
|
],
|
|
755
|
-
}
|
|
778
|
+
}
|
|
756
779
|
),
|
|
757
780
|
h(
|
|
758
781
|
CConditionalTeleport,
|
|
@@ -786,7 +809,7 @@ const CMultiSelect = defineComponent({
|
|
|
786
809
|
onClick: () => handleSelectAll(),
|
|
787
810
|
type: 'button',
|
|
788
811
|
},
|
|
789
|
-
props.selectAllLabel
|
|
812
|
+
props.selectAllLabel
|
|
790
813
|
),
|
|
791
814
|
h(CMultiSelectOptions, {
|
|
792
815
|
loading: props.loading,
|
|
@@ -804,14 +827,14 @@ const CMultiSelect = defineComponent({
|
|
|
804
827
|
visibleItems: props.visibleItems,
|
|
805
828
|
}),
|
|
806
829
|
],
|
|
807
|
-
}
|
|
830
|
+
}
|
|
808
831
|
),
|
|
809
|
-
}
|
|
832
|
+
}
|
|
810
833
|
),
|
|
811
834
|
],
|
|
812
|
-
}
|
|
835
|
+
}
|
|
813
836
|
),
|
|
814
|
-
}
|
|
837
|
+
}
|
|
815
838
|
),
|
|
816
839
|
]
|
|
817
840
|
},
|
|
@@ -24,12 +24,12 @@ const CNav = defineComponent({
|
|
|
24
24
|
/**
|
|
25
25
|
* Set the nav variant to tabs or pills.
|
|
26
26
|
*
|
|
27
|
-
* @values 'pills', 'tabs', 'underline', 'underline-border'
|
|
27
|
+
* @values 'enclosed', 'enclosed-pills', 'pills', 'tabs', 'underline', 'underline-border'
|
|
28
28
|
*/
|
|
29
29
|
variant: {
|
|
30
30
|
type: String,
|
|
31
31
|
validator: (value: string) => {
|
|
32
|
-
return ['pills', 'tabs', 'underline', 'underline-border'].includes(value)
|
|
32
|
+
return ['enclosed', 'enclosed-pills', 'pills', 'tabs', 'underline', 'underline-border'].includes(value)
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
35
|
},
|
|
@@ -40,6 +40,7 @@ const CNav = defineComponent({
|
|
|
40
40
|
{
|
|
41
41
|
class: [
|
|
42
42
|
'nav',
|
|
43
|
+
props.variant === 'enclosed-pills' && 'nav-enclosed',
|
|
43
44
|
{
|
|
44
45
|
[`nav-${props.layout}`]: props.layout,
|
|
45
46
|
[`nav-${props.variant}`]: props.variant,
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// CPasswordInput.ts
|
|
2
|
+
import { defineComponent, h, ref, toRefs, watch, computed } from 'vue'
|
|
3
|
+
import { CFormControlWrapper } from '../form/CFormControlWrapper'
|
|
4
|
+
|
|
5
|
+
export const CPasswordInput = defineComponent({
|
|
6
|
+
name: 'CPasswordInput',
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
props: {
|
|
9
|
+
/**
|
|
10
|
+
* Accessible label for the toggle visibility button.
|
|
11
|
+
*/
|
|
12
|
+
ariaLabelToggler: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: 'Toggle password visibility',
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Delay emitting `change` and `update:modelValue` events.
|
|
19
|
+
* `true` = 500ms delay, or specify custom delay in ms.
|
|
20
|
+
*/
|
|
21
|
+
delay: {
|
|
22
|
+
type: [Boolean, Number],
|
|
23
|
+
default: false,
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Disables the password input field. When `true`, the user cannot interact with the field.
|
|
28
|
+
*/
|
|
29
|
+
disabled: Boolean,
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* General feedback text shown below the input.
|
|
33
|
+
*/
|
|
34
|
+
feedback: String,
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Feedback text shown when input is invalid.
|
|
38
|
+
*/
|
|
39
|
+
feedbackInvalid: String,
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Feedback text shown when input is valid.
|
|
43
|
+
*/
|
|
44
|
+
feedbackValid: String,
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Class for the floating label wrapper.
|
|
48
|
+
*/
|
|
49
|
+
floatingClassName: String,
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Floating label text.
|
|
53
|
+
*/
|
|
54
|
+
floatingLabel: String,
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* ID of the input element.
|
|
58
|
+
*/
|
|
59
|
+
id: String,
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Marks the input as invalid.
|
|
63
|
+
*/
|
|
64
|
+
invalid: Boolean,
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Main label for the input.
|
|
68
|
+
*/
|
|
69
|
+
label: String,
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The current value of the password input, used with v-model.
|
|
73
|
+
*/
|
|
74
|
+
modelValue: String,
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Makes the input read-only, allowing text selection only.
|
|
78
|
+
*/
|
|
79
|
+
readOnly: Boolean,
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Controls the initial visibility of the password.
|
|
83
|
+
*/
|
|
84
|
+
showPassword: Boolean,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Sets the visual size of the input. Accepts `'sm'`, `'lg'`, or undefined.
|
|
88
|
+
*/
|
|
89
|
+
size: {
|
|
90
|
+
type: String as () => 'sm' | 'lg' | undefined,
|
|
91
|
+
default: undefined,
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Helper or hint text displayed below the input.
|
|
96
|
+
*/
|
|
97
|
+
text: String,
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Enables tooltip-style validation feedback messages.
|
|
101
|
+
*/
|
|
102
|
+
tooltipFeedback: Boolean,
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Marks the input as valid.
|
|
106
|
+
*/
|
|
107
|
+
valid: Boolean,
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Alternative to `modelValue`, mostly for manual `:value` binding.
|
|
111
|
+
*/
|
|
112
|
+
value: String,
|
|
113
|
+
},
|
|
114
|
+
emits: ['update:modelValue', 'change'],
|
|
115
|
+
setup(props, { emit, attrs }) {
|
|
116
|
+
const { delay, showPassword, size, invalid, valid } = toRefs(props)
|
|
117
|
+
|
|
118
|
+
const localValue = ref(props.modelValue ?? props.value ?? '')
|
|
119
|
+
const visible = ref(showPassword.value ?? false)
|
|
120
|
+
|
|
121
|
+
const inputType = computed(() => (visible.value ? 'text' : 'password'))
|
|
122
|
+
|
|
123
|
+
watch(
|
|
124
|
+
() => props.modelValue ?? props.value,
|
|
125
|
+
(val) => {
|
|
126
|
+
if (val !== localValue.value) {
|
|
127
|
+
localValue.value = val as string
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
let timeout: ReturnType<typeof setTimeout>
|
|
133
|
+
watch(localValue, (val) => {
|
|
134
|
+
if (delay.value) {
|
|
135
|
+
clearTimeout(timeout)
|
|
136
|
+
timeout = setTimeout(
|
|
137
|
+
() => {
|
|
138
|
+
emit('update:modelValue', val)
|
|
139
|
+
emit('change', val)
|
|
140
|
+
},
|
|
141
|
+
typeof delay.value === 'number' ? delay.value : 500
|
|
142
|
+
)
|
|
143
|
+
} else {
|
|
144
|
+
emit('update:modelValue', val)
|
|
145
|
+
emit('change', val)
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
const togglePassword = () => {
|
|
150
|
+
visible.value = !visible.value
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return () =>
|
|
154
|
+
h(
|
|
155
|
+
CFormControlWrapper,
|
|
156
|
+
{
|
|
157
|
+
describedby: attrs['aria-describedby'] as string,
|
|
158
|
+
feedback: props.feedback,
|
|
159
|
+
feedbackInvalid: props.feedbackInvalid,
|
|
160
|
+
feedbackValid: props.feedbackValid,
|
|
161
|
+
floatingClassName: props.floatingLabel
|
|
162
|
+
? ['form-password', props.floatingClassName].join(' ')
|
|
163
|
+
: props.floatingClassName,
|
|
164
|
+
floatingLabel: props.floatingLabel,
|
|
165
|
+
id: props.id,
|
|
166
|
+
invalid: props.invalid,
|
|
167
|
+
label: props.label,
|
|
168
|
+
text: props.text,
|
|
169
|
+
tooltipFeedback: props.tooltipFeedback,
|
|
170
|
+
valid: props.valid,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
default: () => {
|
|
174
|
+
const inputEl = h('input', {
|
|
175
|
+
...attrs,
|
|
176
|
+
id: props.id,
|
|
177
|
+
type: inputType.value,
|
|
178
|
+
class: [
|
|
179
|
+
'form-control',
|
|
180
|
+
{
|
|
181
|
+
[`form-control-${size.value}`]: size.value,
|
|
182
|
+
'is-invalid': invalid.value,
|
|
183
|
+
'is-valid': valid.value,
|
|
184
|
+
},
|
|
185
|
+
attrs.class,
|
|
186
|
+
],
|
|
187
|
+
value: localValue.value,
|
|
188
|
+
onInput: (e: Event) => {
|
|
189
|
+
localValue.value = (e.target as HTMLInputElement).value
|
|
190
|
+
},
|
|
191
|
+
disabled: props.disabled,
|
|
192
|
+
readOnly: props.readOnly,
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
const buttonEl = h(
|
|
196
|
+
'button',
|
|
197
|
+
{
|
|
198
|
+
type: 'button',
|
|
199
|
+
class: 'form-password-action',
|
|
200
|
+
'data-coreui-toggle': 'password',
|
|
201
|
+
'aria-label': props.ariaLabelToggler,
|
|
202
|
+
onClick: togglePassword,
|
|
203
|
+
},
|
|
204
|
+
[h('span', { class: 'form-password-action-icon' })]
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
const content = [inputEl, buttonEl]
|
|
208
|
+
|
|
209
|
+
return props.floatingLabel ? content : h('div', { class: 'form-password' }, content)
|
|
210
|
+
},
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
},
|
|
214
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { App } from 'vue'
|
|
2
|
+
import { CPasswordInput } from './CPasswordInput'
|
|
3
|
+
|
|
4
|
+
const CPasswordInputPlugin = {
|
|
5
|
+
install: (app: App): void => {
|
|
6
|
+
app.component(CPasswordInput.name as string, CPasswordInput)
|
|
7
|
+
},
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { CPasswordInput, CPasswordInputPlugin }
|