@privyid/persona 0.17.0 → 0.18.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/components/avatar/utils/create-image.mjs +1 -1
- package/dist/components/banner/Banner.vue +3 -3
- package/dist/components/breadcrumbs/BreadcrumbItem.vue +1 -1
- package/dist/components/breadcrumbs/BreadcrumbItemDropdown.vue +1 -1
- package/dist/components/button/Button.vue +24 -11
- package/dist/components/button/Button.vue.d.ts +17 -7
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/calendar/Calendar.vue +8 -4
- package/dist/components/camera/Camera.vue +3 -3
- package/dist/components/card/Card.vue +9 -3
- package/dist/components/checkbox/index.mjs +1 -1
- package/dist/components/collapse/Collapse.vue +12 -1
- package/dist/components/contextual-bar/ContextualBar.vue +1 -1
- package/dist/components/cropper/Cropper.vue +4 -4
- package/dist/components/datepicker/Datepicker.vue +19 -4
- package/dist/components/datepicker/Datepicker.vue.d.ts +10 -0
- package/dist/components/dropdown/Dropdown.vue +13 -7
- package/dist/components/dropdown/Dropdown.vue.d.ts +1 -0
- package/dist/components/dropdown/DropdownItem.vue +10 -0
- package/dist/components/dropdown/DropdownItem.vue.d.ts +9 -0
- package/dist/components/dropdown/utils/use-focus.d.ts +1 -1
- package/dist/components/dropdown/utils/use-focus.mjs +2 -2
- package/dist/components/dropdown-subitem/DropdownSubitem.vue +2 -2
- package/dist/components/filterbar/pinned/PinnedDate.vue +4 -7
- package/dist/components/filterbar/pinned/PinnedMultiselect.vue +4 -7
- package/dist/components/filterbar/pinned/PinnedSelect.vue +5 -7
- package/dist/components/form-group/FormGroup.vue +1 -1
- package/dist/components/global/router.d.ts +2 -1
- package/dist/components/input/Input.vue +22 -4
- package/dist/components/input/Input.vue.d.ts +20 -0
- package/dist/components/input/index.d.ts +1 -0
- package/dist/components/input/index.mjs +5 -0
- package/dist/components/input/utils/accept.d.ts +26 -0
- package/dist/components/input/utils/accept.mjs +81 -0
- package/dist/components/input-file/InputFile.vue.d.ts +1 -1
- package/dist/components/input-password/InputPassword.vue +4 -1
- package/dist/components/input-password/InputPassword.vue.d.ts +7 -3
- package/dist/components/input-pin/InputPin.vue +45 -30
- package/dist/components/input-pin/InputPin.vue.d.ts +24 -5
- package/dist/components/input-pin/index.d.ts +6 -0
- package/dist/components/input-pin/index.mjs +3 -0
- package/dist/components/input-range/InputRange.vue +5 -5
- package/dist/components/label/Label.vue +1 -1
- package/dist/components/list-group/ListGroup.vue +25 -0
- package/dist/components/list-group/ListGroup.vue.d.ts +18 -0
- package/dist/components/main/Main.vue +44 -44
- package/dist/components/modal/Modal.vue +5 -2
- package/dist/components/nav/NavItem.vue +19 -6
- package/dist/components/nav/NavItem.vue.d.ts +6 -3
- package/dist/components/navbar/NavbarToggle.vue +2 -2
- package/dist/components/pagination/Pagination.vue +2 -2
- package/dist/components/pagination/Pagination.vue.d.ts +1 -1
- package/dist/components/pdf-object/PdfObject.vue.d.ts +2 -2
- package/dist/components/pdf-viewer/PdfNavigation.vue +4 -4
- package/dist/components/pdf-viewer/PdfViewer.vue +1 -2
- package/dist/components/pdf-viewer/PdfViewer.vue.d.ts +2 -2
- package/dist/components/radio/Radio.vue +1 -1
- package/dist/components/select/Select.vue +60 -30
- package/dist/components/select/Select.vue.d.ts +21 -3
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.mjs +4 -0
- package/dist/components/sidebar/SidebarNav.vue +2 -0
- package/dist/components/sidebar-menu/SidebarMenu.vue +68 -48
- package/dist/components/sidebar-menu/index.d.ts +95 -2
- package/dist/components/sidebar-menu/index.mjs +41 -0
- package/dist/components/signature-draw/SignatureDrawMobile.vue +3 -7
- package/dist/components/spinner/Spinner.vue +28 -12
- package/dist/components/spinner/SpinnerRing.vue +14 -7
- package/dist/components/spinner/SpinnerRinggo.vue +62 -0
- package/dist/components/spinner/SpinnerRinggo.vue.d.ts +6 -0
- package/dist/components/steps/Step.vue +3 -0
- package/dist/components/steps/Step.vue.d.ts +1 -0
- package/dist/components/steps/Steps.vue +1 -0
- package/dist/components/steps/index.d.ts +2 -0
- package/dist/components/steps/index.mjs +1 -0
- package/dist/components/table/Table.vue +2 -2
- package/dist/components/tabs/Tabs.vue +4 -2
- package/dist/components/textarea/Textarea.vue +10 -1
- package/dist/components/textarea/Textarea.vue.d.ts +12 -0
- package/dist/components/toast/Toast.vue +5 -5
- package/dist/components/toast/ToastContainer.vue +6 -6
- package/dist/components/toggle/Toggle.vue +1 -1
- package/dist/components/tooltip/TooltipContainer.vue +18 -3
- package/dist/components/tooltip/index.d.ts +3 -0
- package/dist/components/tooltip/index.mjs +29 -4
- package/dist/components/tooltip/utils/parse-bindings.d.ts +2 -1
- package/dist/components/tooltip/utils/parse-bindings.mjs +2 -0
- package/dist/components/tour/TourDialog.vue +1 -1
- package/dist/components/truncate/Truncate.vue +9 -1
- package/dist/components/truncate/Truncate.vue.d.ts +9 -0
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.mjs +7 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/package.json +14 -14
|
@@ -9,12 +9,9 @@
|
|
|
9
9
|
<template #button-content>
|
|
10
10
|
{{ value ? value : schema.label }}
|
|
11
11
|
</template>
|
|
12
|
-
<
|
|
13
|
-
class="px-4 pt-4 pb-1"
|
|
14
|
-
weight="medium"
|
|
15
|
-
overline>
|
|
12
|
+
<DropdownHeader>
|
|
16
13
|
{{ schema.label }}
|
|
17
|
-
</
|
|
14
|
+
</DropdownHeader>
|
|
18
15
|
|
|
19
16
|
<Calendar
|
|
20
17
|
v-model="model"
|
|
@@ -31,15 +28,15 @@ import {
|
|
|
31
28
|
defineComponent,
|
|
32
29
|
ref
|
|
33
30
|
} from "vue-demi";
|
|
34
|
-
import Subheading from "../../subheading/Subheading.vue";
|
|
35
31
|
import Calendar from "../../calendar/Calendar.vue";
|
|
36
32
|
import Dropdown from "../../dropdown/Dropdown.vue";
|
|
33
|
+
import DropdownHeader from "../../dropdown/DropdownHeader.vue";
|
|
37
34
|
import { useVModel } from "../../input";
|
|
38
35
|
import { isDate, format as formatDate } from "date-fns";
|
|
39
36
|
export default defineComponent({
|
|
40
37
|
components: {
|
|
41
|
-
Subheading,
|
|
42
38
|
Dropdown,
|
|
39
|
+
DropdownHeader,
|
|
43
40
|
Calendar
|
|
44
41
|
},
|
|
45
42
|
props: {
|
|
@@ -22,12 +22,9 @@
|
|
|
22
22
|
</template>
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
|
-
<
|
|
26
|
-
class="px-4 pt-4 pb-1"
|
|
27
|
-
weight="medium"
|
|
28
|
-
overline>
|
|
25
|
+
<DropdownHeader>
|
|
29
26
|
{{ schema.label }}
|
|
30
|
-
</
|
|
27
|
+
</DropdownHeader>
|
|
31
28
|
<template
|
|
32
29
|
v-for="(item, i) in items"
|
|
33
30
|
:key="i">
|
|
@@ -48,8 +45,8 @@ import {
|
|
|
48
45
|
ref
|
|
49
46
|
} from "vue-demi";
|
|
50
47
|
import Badge from "../../badge/Badge.vue";
|
|
51
|
-
import Subheading from "../../subheading/Subheading.vue";
|
|
52
48
|
import Dropdown from "../../dropdown/Dropdown.vue";
|
|
49
|
+
import DropdownHeader from "../../dropdown/DropdownHeader.vue";
|
|
53
50
|
import Checkbox from "../../checkbox/Checkbox.vue";
|
|
54
51
|
import { useOptionsProp } from "../../select/adapter/adapter";
|
|
55
52
|
import { useVModel } from "../../input";
|
|
@@ -57,8 +54,8 @@ import { isEqual } from "../../utils/value";
|
|
|
57
54
|
export default defineComponent({
|
|
58
55
|
components: {
|
|
59
56
|
Badge,
|
|
60
|
-
Subheading,
|
|
61
57
|
Dropdown,
|
|
58
|
+
DropdownHeader,
|
|
62
59
|
Checkbox
|
|
63
60
|
},
|
|
64
61
|
props: {
|
|
@@ -10,12 +10,10 @@
|
|
|
10
10
|
<template #button-content>
|
|
11
11
|
{{ selected ? selected.text : schema.label }}
|
|
12
12
|
</template>
|
|
13
|
-
<
|
|
14
|
-
class="px-4 pt-4 pb-1"
|
|
15
|
-
weight="medium"
|
|
16
|
-
overline>
|
|
13
|
+
<DropdownHeader>
|
|
17
14
|
{{ schema.label }}
|
|
18
|
-
</
|
|
15
|
+
</DropdownHeader>
|
|
16
|
+
|
|
19
17
|
<template
|
|
20
18
|
v-for="(item, i) in items"
|
|
21
19
|
:key="i">
|
|
@@ -36,16 +34,16 @@ import {
|
|
|
36
34
|
defineComponent,
|
|
37
35
|
ref
|
|
38
36
|
} from "vue-demi";
|
|
39
|
-
import Subheading from "../../subheading/Subheading.vue";
|
|
40
37
|
import Dropdown from "../../dropdown/Dropdown.vue";
|
|
38
|
+
import DropdownHeader from "../../dropdown/DropdownHeader.vue";
|
|
41
39
|
import Radio from "../../radio/Radio.vue";
|
|
42
40
|
import { useOptionsProp } from "../../select/adapter/adapter";
|
|
43
41
|
import { useVModel } from "../../input";
|
|
44
42
|
import { isEqual } from "../../utils/value";
|
|
45
43
|
export default defineComponent({
|
|
46
44
|
components: {
|
|
47
|
-
Subheading,
|
|
48
45
|
Dropdown,
|
|
46
|
+
DropdownHeader,
|
|
49
47
|
Radio
|
|
50
48
|
},
|
|
51
49
|
props: {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
</template>
|
|
43
43
|
|
|
44
44
|
<script>
|
|
45
|
-
import IconInfo from "@
|
|
45
|
+
import IconInfo from "@privyid/persona-icon/vue/information-circle-solid/20.vue";
|
|
46
46
|
import pCaption from "../caption/Caption.vue";
|
|
47
47
|
import { pTooltip } from "../tooltip";
|
|
48
48
|
import { computed, defineComponent } from "vue-demi";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RouteLocationRaw } from 'vue-router';
|
|
1
2
|
/**
|
|
2
3
|
* Universal router which compatible in many enviroment
|
|
3
4
|
*/
|
|
@@ -5,7 +6,7 @@ interface RouterCompat {
|
|
|
5
6
|
/**
|
|
6
7
|
* redirect to URL
|
|
7
8
|
*/
|
|
8
|
-
toURL: (url:
|
|
9
|
+
toURL: (url: RouteLocationRaw) => unknown | Promise<unknown>;
|
|
9
10
|
/**
|
|
10
11
|
* Get current URL
|
|
11
12
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
3
|
class="input"
|
|
4
|
+
:class="containerClass"
|
|
4
5
|
data-testid="input-container">
|
|
5
6
|
<span
|
|
6
7
|
v-if="$slots.prepend"
|
|
@@ -14,7 +15,8 @@
|
|
|
14
15
|
:disabled="disabled"
|
|
15
16
|
:readonly="readonly"
|
|
16
17
|
:class="classNames"
|
|
17
|
-
v-bind="$attrs"
|
|
18
|
+
v-bind="$attrs"
|
|
19
|
+
@beforeinput="checkOnInput(accept, $event)">
|
|
18
20
|
<IconClear
|
|
19
21
|
v-show="(clearable && model)"
|
|
20
22
|
class="input__clear"
|
|
@@ -35,8 +37,11 @@ import {
|
|
|
35
37
|
inject
|
|
36
38
|
} from "vue-demi";
|
|
37
39
|
import { useVModel } from ".";
|
|
38
|
-
import IconClear from "@
|
|
40
|
+
import IconClear from "@privyid/persona-icon/vue/close-circle-solid/20.vue";
|
|
39
41
|
import { INPUTGROUP_SETTING } from "../input-group";
|
|
42
|
+
import {
|
|
43
|
+
checkOnInput
|
|
44
|
+
} from "./utils/accept";
|
|
40
45
|
export default defineComponent({
|
|
41
46
|
components: { IconClear },
|
|
42
47
|
inheritAttrs: false,
|
|
@@ -64,6 +69,18 @@ export default defineComponent({
|
|
|
64
69
|
clearable: {
|
|
65
70
|
type: Boolean,
|
|
66
71
|
default: false
|
|
72
|
+
},
|
|
73
|
+
containerClass: {
|
|
74
|
+
type: [
|
|
75
|
+
String,
|
|
76
|
+
Array,
|
|
77
|
+
Object
|
|
78
|
+
],
|
|
79
|
+
default: void 0
|
|
80
|
+
},
|
|
81
|
+
accept: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: void 0
|
|
67
84
|
}
|
|
68
85
|
},
|
|
69
86
|
models: {
|
|
@@ -102,7 +119,8 @@ export default defineComponent({
|
|
|
102
119
|
return {
|
|
103
120
|
classNames,
|
|
104
121
|
model,
|
|
105
|
-
clear
|
|
122
|
+
clear,
|
|
123
|
+
checkOnInput
|
|
106
124
|
};
|
|
107
125
|
}
|
|
108
126
|
});
|
|
@@ -155,7 +173,7 @@ export default defineComponent({
|
|
|
155
173
|
}
|
|
156
174
|
|
|
157
175
|
.input__clear {
|
|
158
|
-
@apply text-default/30 cursor-pointer hover:text-danger z-
|
|
176
|
+
@apply text-default/30 cursor-pointer hover:text-danger z-[2];
|
|
159
177
|
@apply dark:text-dark-default/30 hover:dark:text-dark-danger;
|
|
160
178
|
}
|
|
161
179
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PropType } from 'vue-demi';
|
|
2
2
|
import { SizeVariant } from '../button';
|
|
3
|
+
import { AcceptVariant, checkOnInput } from './utils/accept';
|
|
3
4
|
declare const _default: import("vue-demi").DefineComponent<{
|
|
4
5
|
modelValue: {
|
|
5
6
|
type: (NumberConstructor | StringConstructor)[];
|
|
@@ -25,10 +26,19 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
25
26
|
type: BooleanConstructor;
|
|
26
27
|
default: boolean;
|
|
27
28
|
};
|
|
29
|
+
containerClass: {
|
|
30
|
+
type: (StringConstructor | ArrayConstructor | ObjectConstructor)[];
|
|
31
|
+
default: undefined;
|
|
32
|
+
};
|
|
33
|
+
accept: {
|
|
34
|
+
type: PropType<AcceptVariant>;
|
|
35
|
+
default: undefined;
|
|
36
|
+
};
|
|
28
37
|
}, {
|
|
29
38
|
classNames: import("vue-demi").ComputedRef<string[]>;
|
|
30
39
|
model: import("vue-demi").Ref<string | number | undefined>;
|
|
31
40
|
clear: (event: MouseEvent) => void;
|
|
41
|
+
checkOnInput: typeof checkOnInput;
|
|
32
42
|
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, ("update:modelValue" | "clear")[], "update:modelValue" | "clear", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
33
43
|
modelValue: {
|
|
34
44
|
type: (NumberConstructor | StringConstructor)[];
|
|
@@ -54,6 +64,14 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
54
64
|
type: BooleanConstructor;
|
|
55
65
|
default: boolean;
|
|
56
66
|
};
|
|
67
|
+
containerClass: {
|
|
68
|
+
type: (StringConstructor | ArrayConstructor | ObjectConstructor)[];
|
|
69
|
+
default: undefined;
|
|
70
|
+
};
|
|
71
|
+
accept: {
|
|
72
|
+
type: PropType<AcceptVariant>;
|
|
73
|
+
default: undefined;
|
|
74
|
+
};
|
|
57
75
|
}>> & {
|
|
58
76
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
59
77
|
onClear?: ((...args: any[]) => any) | undefined;
|
|
@@ -63,6 +81,8 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
63
81
|
modelValue: string | number;
|
|
64
82
|
disabled: boolean;
|
|
65
83
|
readonly: boolean;
|
|
84
|
+
accept: AcceptVariant;
|
|
66
85
|
clearable: boolean;
|
|
86
|
+
containerClass: string | Record<string, any> | unknown[];
|
|
67
87
|
}, {}>;
|
|
68
88
|
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LiteralUnion } from 'type-fest';
|
|
2
|
+
export declare const AcceptPresets: {
|
|
3
|
+
readonly num: string;
|
|
4
|
+
readonly numeric: string;
|
|
5
|
+
readonly digit: string;
|
|
6
|
+
readonly alpha: string;
|
|
7
|
+
readonly 'alpha-num': string;
|
|
8
|
+
readonly 'alpha-num-space': string;
|
|
9
|
+
readonly 'alpha-num-space-symbol': string;
|
|
10
|
+
readonly 'alpha-numeric': string;
|
|
11
|
+
readonly 'alpha-numeric-space': string;
|
|
12
|
+
readonly 'alpha-numeric-space-symbol': string;
|
|
13
|
+
readonly 'alpha-space': string;
|
|
14
|
+
readonly 'alpha-space-symbol': string;
|
|
15
|
+
readonly 'num-space': string;
|
|
16
|
+
readonly 'num-space-symbol': string;
|
|
17
|
+
readonly 'numeric-space': string;
|
|
18
|
+
readonly 'numeric-space-symbol': string;
|
|
19
|
+
readonly 'non-numeric': string;
|
|
20
|
+
readonly 'non-alpha': string;
|
|
21
|
+
readonly text: string;
|
|
22
|
+
};
|
|
23
|
+
export type AcceptVariant = LiteralUnion<keyof typeof AcceptPresets, string>;
|
|
24
|
+
export declare function isAccepted(accept: AcceptVariant | undefined, text: string): boolean;
|
|
25
|
+
export declare function removeUnaccepted(accept: AcceptVariant | undefined, text: string): string;
|
|
26
|
+
export declare function checkOnInput(accept: AcceptVariant | undefined, event: Event): void;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const ALPHA = "A-Za-z";
|
|
2
|
+
const NUMERIC = "\\d";
|
|
3
|
+
const SPACE = "\\s";
|
|
4
|
+
const SYMBOL = "!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-";
|
|
5
|
+
const REGEX_ALPHA = `${ALPHA}`;
|
|
6
|
+
const REGEX_NUMERIC = `${NUMERIC}`;
|
|
7
|
+
const REGEX_ALPHA_NUMERIC = `${ALPHA}${NUMERIC}`;
|
|
8
|
+
const REGEX_ALPHA_NUMERIC_SPACE = `${ALPHA}${NUMERIC}${SPACE}`;
|
|
9
|
+
const REGEX_ALPHA_NUMERIC_SPACE_SYMBOL = `${ALPHA}${NUMERIC}${SPACE}${SYMBOL}`;
|
|
10
|
+
const REGEX_ALPHA_SPACE = `${ALPHA}${SPACE}`;
|
|
11
|
+
const REGEX_ALPHA_SPACE_SYMBOL = `${ALPHA}${SPACE}${SYMBOL}`;
|
|
12
|
+
const REGEX_NUMERIC_SPACE = `${NUMERIC}${SPACE}`;
|
|
13
|
+
const REGEX_NUMERIC_SPACE_SYMBOL = `${NUMERIC}${SPACE}${SYMBOL}`;
|
|
14
|
+
export const AcceptPresets = {
|
|
15
|
+
"num": REGEX_NUMERIC,
|
|
16
|
+
"numeric": REGEX_NUMERIC,
|
|
17
|
+
"digit": REGEX_NUMERIC,
|
|
18
|
+
"alpha": REGEX_ALPHA,
|
|
19
|
+
"alpha-num": REGEX_ALPHA_NUMERIC,
|
|
20
|
+
"alpha-num-space": REGEX_ALPHA_NUMERIC_SPACE,
|
|
21
|
+
"alpha-num-space-symbol": REGEX_ALPHA_NUMERIC_SPACE_SYMBOL,
|
|
22
|
+
"alpha-numeric": REGEX_ALPHA_NUMERIC,
|
|
23
|
+
"alpha-numeric-space": REGEX_ALPHA_NUMERIC_SPACE,
|
|
24
|
+
"alpha-numeric-space-symbol": REGEX_ALPHA_NUMERIC_SPACE_SYMBOL,
|
|
25
|
+
"alpha-space": REGEX_ALPHA_SPACE,
|
|
26
|
+
"alpha-space-symbol": REGEX_ALPHA_SPACE_SYMBOL,
|
|
27
|
+
"num-space": REGEX_NUMERIC_SPACE,
|
|
28
|
+
"num-space-symbol": REGEX_NUMERIC_SPACE_SYMBOL,
|
|
29
|
+
"numeric-space": REGEX_NUMERIC_SPACE,
|
|
30
|
+
"numeric-space-symbol": REGEX_NUMERIC_SPACE_SYMBOL,
|
|
31
|
+
"non-numeric": REGEX_ALPHA_SPACE_SYMBOL,
|
|
32
|
+
"non-alpha": REGEX_NUMERIC_SPACE_SYMBOL,
|
|
33
|
+
"text": REGEX_ALPHA_NUMERIC_SPACE_SYMBOL
|
|
34
|
+
};
|
|
35
|
+
export function isAccepted(accept, text) {
|
|
36
|
+
if (!accept)
|
|
37
|
+
return true;
|
|
38
|
+
try {
|
|
39
|
+
const regexStr = AcceptPresets[accept.toLowerCase()] ?? accept;
|
|
40
|
+
const regex = new RegExp(`^[${regexStr}]+$`);
|
|
41
|
+
return regex.test(text);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (import.meta.env.DEV)
|
|
44
|
+
console.error(error);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function removeUnaccepted(accept, text) {
|
|
49
|
+
if (!accept)
|
|
50
|
+
return text;
|
|
51
|
+
try {
|
|
52
|
+
const regexStr = AcceptPresets[accept.toLowerCase()] ?? accept;
|
|
53
|
+
const regex = new RegExp(`[^${regexStr}]+`, "g");
|
|
54
|
+
return text.replaceAll(regex, "");
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (import.meta.env.DEV)
|
|
57
|
+
console.error(error);
|
|
58
|
+
return text;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function checkOnInput(accept, event) {
|
|
62
|
+
if (event.data && !isAccepted(accept, event.data)) {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
if (event.inputType === "insertFromPaste") {
|
|
65
|
+
const target = event.target;
|
|
66
|
+
const oldValue = target.value;
|
|
67
|
+
const value = removeUnaccepted(accept, event.data);
|
|
68
|
+
const ss = target.selectionStart;
|
|
69
|
+
const se = target.selectionEnd;
|
|
70
|
+
const nextValue = `${oldValue.slice(0, ss)}${value}${oldValue.slice(se)}`;
|
|
71
|
+
try {
|
|
72
|
+
target.value = nextValue;
|
|
73
|
+
target.dispatchEvent(new InputEvent("input"));
|
|
74
|
+
target.setSelectionRange(value.length + ss, value.length + ss);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
if (import.meta.env.DEV)
|
|
77
|
+
console.error(error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -124,8 +124,8 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
124
124
|
disabled: boolean;
|
|
125
125
|
readonly: boolean;
|
|
126
126
|
modelModifiers: ModelModifier;
|
|
127
|
-
multiple: boolean | MultipleType;
|
|
128
127
|
placeholder: string;
|
|
128
|
+
multiple: boolean | MultipleType;
|
|
129
129
|
maxlength: string | number;
|
|
130
130
|
accept: string;
|
|
131
131
|
clearOnCancel: boolean;
|
|
@@ -19,7 +19,10 @@
|
|
|
19
19
|
import pInput from "../input/Input.vue";
|
|
20
20
|
import IconShow from "@privyid/persona-icon/vue/view/20.vue";
|
|
21
21
|
import IconHide from "@privyid/persona-icon/vue/view-off/20.vue";
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
ref,
|
|
24
|
+
defineComponent
|
|
25
|
+
} from "vue-demi";
|
|
23
26
|
export default defineComponent({
|
|
24
27
|
components: {
|
|
25
28
|
pInput,
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Ref } from 'vue-demi';
|
|
2
|
+
type Bindings = {
|
|
3
|
+
isShow: Ref<boolean>;
|
|
3
4
|
toggle: () => void;
|
|
4
|
-
}
|
|
5
|
+
};
|
|
6
|
+
declare const _default: import("vue-demi").DefineComponent<any, Bindings, {}, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, {}, string, import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<any>, {} | {
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
}, {}>;
|
|
5
9
|
export default _default;
|
|
@@ -10,16 +10,15 @@
|
|
|
10
10
|
maxlength="1"
|
|
11
11
|
v-bind="$attrs"
|
|
12
12
|
:model-value="getValue(i - 1)"
|
|
13
|
+
:size="size"
|
|
13
14
|
:clearable="false"
|
|
14
15
|
:readonly="readonly"
|
|
15
16
|
:disabled="disabled"
|
|
16
17
|
:error="error"
|
|
17
|
-
@
|
|
18
|
-
@
|
|
19
|
-
@keyup.delete.stop.prevent="onDelete"
|
|
18
|
+
@keydown="onKeyDown($event)"
|
|
19
|
+
@beforeinput.prevent="setValue(i - 1, $event)"
|
|
20
20
|
@keyup.left.stop.prevent="prevFocus"
|
|
21
|
-
@keyup.right.stop.prevent="nextFocus"
|
|
22
|
-
@paste.passive="onPaste" />
|
|
21
|
+
@keyup.right.stop.prevent="nextFocus" />
|
|
23
22
|
</div>
|
|
24
23
|
</template>
|
|
25
24
|
|
|
@@ -37,6 +36,11 @@ import {
|
|
|
37
36
|
useToNumber
|
|
38
37
|
} from "@vueuse/core";
|
|
39
38
|
import { useFocus } from "../dropdown/utils/use-focus";
|
|
39
|
+
import {
|
|
40
|
+
isAccepted,
|
|
41
|
+
removeUnaccepted
|
|
42
|
+
} from "../input";
|
|
43
|
+
import { toArray } from ".";
|
|
40
44
|
export default defineComponent({
|
|
41
45
|
components: { pInput },
|
|
42
46
|
inheritAttrs: false,
|
|
@@ -45,6 +49,10 @@ export default defineComponent({
|
|
|
45
49
|
type: String,
|
|
46
50
|
default: void 0
|
|
47
51
|
},
|
|
52
|
+
size: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "md"
|
|
55
|
+
},
|
|
48
56
|
length: {
|
|
49
57
|
type: [Number, String],
|
|
50
58
|
default: 5
|
|
@@ -60,17 +68,21 @@ export default defineComponent({
|
|
|
60
68
|
error: {
|
|
61
69
|
type: Boolean,
|
|
62
70
|
default: false
|
|
71
|
+
},
|
|
72
|
+
accept: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: void 0
|
|
63
75
|
}
|
|
64
76
|
},
|
|
65
77
|
models: {
|
|
66
78
|
prop: "modelValue",
|
|
67
79
|
event: "update:modelValue"
|
|
68
80
|
},
|
|
69
|
-
emits: ["update:modelValue", "
|
|
81
|
+
emits: ["update:modelValue", "change"],
|
|
70
82
|
setup(props, { emit }) {
|
|
71
83
|
const root = templateRef("root");
|
|
72
84
|
const num = useToNumber(toRef(props, "length"));
|
|
73
|
-
const localModel = ref(
|
|
85
|
+
const localModel = ref(toArray(props.modelValue, num.value));
|
|
74
86
|
const classNames = computed(() => {
|
|
75
87
|
const result = [];
|
|
76
88
|
if (props.disabled)
|
|
@@ -84,37 +96,42 @@ export default defineComponent({
|
|
|
84
96
|
const { next: nextFocus, prev: prevFocus } = useFocus(root, false);
|
|
85
97
|
const model = computed({
|
|
86
98
|
get() {
|
|
87
|
-
return
|
|
99
|
+
return toArray(props.modelValue, num.value);
|
|
88
100
|
},
|
|
89
101
|
set(value) {
|
|
90
102
|
const text = value.map((val) => val || " ").join("").trimEnd();
|
|
103
|
+
emit("change", text);
|
|
91
104
|
emit("update:modelValue", text);
|
|
92
105
|
}
|
|
93
106
|
});
|
|
94
|
-
syncRef(localModel, model, { deep: true });
|
|
107
|
+
syncRef(localModel, model, { deep: true, immediate: false });
|
|
95
108
|
function getValue(index) {
|
|
96
109
|
return localModel.value.at(index);
|
|
97
110
|
}
|
|
98
111
|
function setValue(index, event) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (value)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
if (event.inputType === "insertFromPaste")
|
|
113
|
+
localModel.value = toArray(removeUnaccepted(props.accept, event.data), num.value);
|
|
114
|
+
else if (!event.data || isAccepted(props.accept, event.data)) {
|
|
115
|
+
localModel.value[index] = event.data;
|
|
116
|
+
if (root.value) {
|
|
117
|
+
if (event.inputType === "deleteContentBackward")
|
|
118
|
+
prevFocus();
|
|
119
|
+
if (event.inputType === "insertText")
|
|
120
|
+
nextFocus();
|
|
121
|
+
}
|
|
107
122
|
}
|
|
108
123
|
}
|
|
109
|
-
function
|
|
110
|
-
event.target
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
function onKeyDown(event) {
|
|
125
|
+
const target = event.target;
|
|
126
|
+
if (props.readonly || props.disabled)
|
|
127
|
+
return;
|
|
128
|
+
if (target.value && [...event.key].length === 1 && !event.ctrlKey && !event.metaKey) {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
target.dispatchEvent(new InputEvent("beforeinput", { inputType: "insertText", data: event.key }));
|
|
131
|
+
} else if (event.key === "Backspace") {
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
target.dispatchEvent(new InputEvent("beforeinput", { inputType: "deleteContentBackward" }));
|
|
134
|
+
}
|
|
118
135
|
}
|
|
119
136
|
return {
|
|
120
137
|
classNames,
|
|
@@ -122,11 +139,9 @@ export default defineComponent({
|
|
|
122
139
|
localModel,
|
|
123
140
|
getValue,
|
|
124
141
|
setValue,
|
|
125
|
-
onFocus,
|
|
126
|
-
onDelete,
|
|
127
|
-
onPaste,
|
|
128
142
|
nextFocus,
|
|
129
|
-
prevFocus
|
|
143
|
+
prevFocus,
|
|
144
|
+
onKeyDown
|
|
130
145
|
};
|
|
131
146
|
}
|
|
132
147
|
});
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import { PropType } from 'vue-demi';
|
|
2
|
+
import { AcceptVariant } from '../input';
|
|
3
|
+
import { SizeVariant } from '../button';
|
|
1
4
|
declare const _default: import("vue-demi").DefineComponent<{
|
|
2
5
|
modelValue: {
|
|
3
6
|
type: StringConstructor;
|
|
4
7
|
default: undefined;
|
|
5
8
|
};
|
|
9
|
+
size: {
|
|
10
|
+
type: PropType<SizeVariant>;
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
6
13
|
length: {
|
|
7
14
|
type: (NumberConstructor | StringConstructor)[];
|
|
8
15
|
default: number;
|
|
@@ -19,22 +26,28 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
19
26
|
type: BooleanConstructor;
|
|
20
27
|
default: boolean;
|
|
21
28
|
};
|
|
29
|
+
accept: {
|
|
30
|
+
type: PropType<AcceptVariant>;
|
|
31
|
+
default: undefined;
|
|
32
|
+
};
|
|
22
33
|
}, {
|
|
23
34
|
classNames: import("vue-demi").ComputedRef<string[]>;
|
|
24
35
|
num: import("vue-demi").ComputedRef<number>;
|
|
25
36
|
localModel: import("vue-demi").Ref<string[]>;
|
|
26
37
|
getValue: (index: number) => string;
|
|
27
38
|
setValue: (index: number, event: InputEvent) => void;
|
|
28
|
-
onFocus: (event: InputEvent) => void;
|
|
29
|
-
onDelete: (event: InputEvent) => void;
|
|
30
|
-
onPaste: (event: ClipboardEvent) => void;
|
|
31
39
|
nextFocus: () => void;
|
|
32
40
|
prevFocus: () => void;
|
|
33
|
-
|
|
41
|
+
onKeyDown: (event: KeyboardEvent) => void;
|
|
42
|
+
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
34
43
|
modelValue: {
|
|
35
44
|
type: StringConstructor;
|
|
36
45
|
default: undefined;
|
|
37
46
|
};
|
|
47
|
+
size: {
|
|
48
|
+
type: PropType<SizeVariant>;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
38
51
|
length: {
|
|
39
52
|
type: (NumberConstructor | StringConstructor)[];
|
|
40
53
|
default: number;
|
|
@@ -51,14 +64,20 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
51
64
|
type: BooleanConstructor;
|
|
52
65
|
default: boolean;
|
|
53
66
|
};
|
|
67
|
+
accept: {
|
|
68
|
+
type: PropType<AcceptVariant>;
|
|
69
|
+
default: undefined;
|
|
70
|
+
};
|
|
54
71
|
}>> & {
|
|
72
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
55
73
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
56
|
-
onClear?: ((...args: any[]) => any) | undefined;
|
|
57
74
|
}, {
|
|
58
75
|
error: boolean;
|
|
59
76
|
length: string | number;
|
|
77
|
+
size: SizeVariant;
|
|
60
78
|
modelValue: string;
|
|
61
79
|
disabled: boolean;
|
|
62
80
|
readonly: boolean;
|
|
81
|
+
accept: AcceptVariant;
|
|
63
82
|
}, {}>;
|
|
64
83
|
export default _default;
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
data-testid="track-lower"
|
|
13
13
|
class="input-range__track input-range__track-lower"
|
|
14
14
|
:style="lowerStyle"
|
|
15
|
-
@click="onClickLowerTrack" />
|
|
15
|
+
@click.capture="onClickLowerTrack" />
|
|
16
16
|
<!-- Active Track -->
|
|
17
17
|
<div
|
|
18
18
|
ref="track-active"
|
|
19
19
|
data-testid="track-active"
|
|
20
20
|
class="input-range__track input-range__track-active"
|
|
21
21
|
:style="upperStyle"
|
|
22
|
-
@click="onClickActiveTrack">
|
|
22
|
+
@click.capture="onClickActiveTrack">
|
|
23
23
|
<div
|
|
24
24
|
v-show="multiple"
|
|
25
25
|
ref="thumb-start"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
<div
|
|
35
35
|
data-testid="track-upper"
|
|
36
36
|
class="input-range__track input-range__track-upper"
|
|
37
|
-
@click="onClickUpperTrack" />
|
|
37
|
+
@click.capture="onClickUpperTrack" />
|
|
38
38
|
</div>
|
|
39
39
|
</div>
|
|
40
40
|
</template>
|
|
@@ -203,8 +203,8 @@ export default defineComponent({
|
|
|
203
203
|
if (!props.disabled && !props.readonly)
|
|
204
204
|
end.value = getValue(event);
|
|
205
205
|
});
|
|
206
|
-
syncRef(start, vStart);
|
|
207
|
-
syncRef(end, vEnd);
|
|
206
|
+
syncRef(start, vStart, { immediate: false });
|
|
207
|
+
syncRef(end, vEnd, { immediate: false });
|
|
208
208
|
watch([start, end], ([startVal, endVal]) => {
|
|
209
209
|
localStart.value = startVal;
|
|
210
210
|
localEnd.value = endVal;
|