@central-design-system/components 4.0.0-alpha.2 → 4.0.0-alpha.3
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/CHANGELOG.md +5 -1
- package/MIGRATION.md +1 -1
- package/dist/cjs/entry.js +10 -10
- package/dist/es/entry.js +173 -163
- package/dist/es/entry.js.map +1 -1
- package/dist/es/src/components/CdsList/CdsList.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/src/components/CdsList/CdsListGroup.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/src/components/CdsList/CdsListItem.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/src/components/CdsList/CdsListSubheader.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/src/components/CdsList/api/CdsList.constants.js +4 -4
- package/dist/es/src/components/CdsList/api/CdsList.props.js +2 -2
- package/dist/es/src/components/CdsList/index.js +1 -1
- package/dist/es/src/components/CdsOtpInput/CdsOtpField.js +2 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpField.js.map +1 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpField.vue_vue_type_script_setup_true_lang.js +62 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpField.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpGroup.js +2 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpGroup.js.map +1 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpGroup.vue_vue_type_script_setup_true_lang.js +51 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpGroup.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpInput.css +204 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpInput.js +2 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpInput.js.map +1 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpInput.vue_vue_type_script_setup_true_lang.js +338 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpInput.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpSeparator.js +2 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpSeparator.js.map +1 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpSeparator.vue_vue_type_script_setup_true_lang.js +34 -0
- package/dist/es/src/components/CdsOtpInput/CdsOtpSeparator.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/es/src/components/CdsOtpInput/api/CdsOtpInput.constants.js +16 -0
- package/dist/es/src/components/CdsOtpInput/api/CdsOtpInput.constants.js.map +1 -0
- package/dist/es/src/components/CdsOtpInput/api/CdsOtpInput.props.js +97 -0
- package/dist/es/src/components/CdsOtpInput/api/CdsOtpInput.props.js.map +1 -0
- package/dist/es/src/components/CdsOtpInput/api/CdsOtpInput.types.js +2 -0
- package/dist/es/src/components/CdsOtpInput/api/CdsOtpInput.types.js.map +1 -0
- package/dist/es/src/components/CdsOtpInput/composables/useOtpInput.js +329 -0
- package/dist/es/src/components/CdsOtpInput/composables/useOtpInput.js.map +1 -0
- package/dist/es/src/components/CdsOtpInput/index.js +17 -0
- package/dist/es/src/components/CdsOtpInput/index.js.map +1 -0
- package/dist/es/src/components/index.js +10 -0
- package/dist/es/src/components/index.js.map +1 -1
- package/dist/es/src/composables/useDisabled/index.js +1 -1
- package/dist/es/src/composables/useDisabled/index.js.map +1 -1
- package/dist/es/src/composables/useLoader/index.js +1 -1
- package/dist/es/src/composables/useLoader/index.js.map +1 -1
- package/dist/es/src/composables/useLocation/index.js +1 -1
- package/dist/es/src/composables/useLocation/index.js.map +1 -1
- package/dist/es/src/composables/useRouter/index.js +1 -1
- package/dist/es/src/composables/useRouter/index.js.map +1 -1
- package/dist/es/src/locales/ru.js +1 -0
- package/dist/es/src/locales/ru.js.map +1 -1
- package/dist/esm-node/entry.mjs +173 -163
- package/dist/esm-node/src/components/CdsOtpInput/CdsOtpField.mjs +2 -0
- package/dist/esm-node/src/components/CdsOtpInput/CdsOtpField.vue_vue_type_script_setup_true_lang.mjs +62 -0
- package/dist/esm-node/src/components/CdsOtpInput/CdsOtpGroup.mjs +2 -0
- package/dist/esm-node/src/components/CdsOtpInput/CdsOtpGroup.vue_vue_type_script_setup_true_lang.mjs +51 -0
- package/dist/esm-node/src/components/CdsOtpInput/CdsOtpInput.css +204 -0
- package/dist/esm-node/src/components/CdsOtpInput/CdsOtpInput.mjs +2 -0
- package/dist/esm-node/src/components/CdsOtpInput/CdsOtpInput.vue_vue_type_script_setup_true_lang.mjs +336 -0
- package/dist/esm-node/src/components/CdsOtpInput/CdsOtpSeparator.mjs +2 -0
- package/dist/esm-node/src/components/CdsOtpInput/CdsOtpSeparator.vue_vue_type_script_setup_true_lang.mjs +34 -0
- package/dist/esm-node/src/components/CdsOtpInput/api/CdsOtpInput.constants.mjs +16 -0
- package/dist/esm-node/src/components/CdsOtpInput/api/CdsOtpInput.props.mjs +97 -0
- package/dist/esm-node/src/components/CdsOtpInput/api/CdsOtpInput.types.mjs +2 -0
- package/dist/esm-node/src/components/CdsOtpInput/composables/useOtpInput.mjs +329 -0
- package/dist/esm-node/src/components/CdsOtpInput/index.mjs +17 -0
- package/dist/esm-node/src/components/index.mjs +10 -0
- package/dist/esm-node/src/composables/useLoader/index.mjs +1 -1
- package/dist/esm-node/src/composables/useLocation/index.mjs +1 -1
- package/dist/esm-node/src/composables/useRouter/index.mjs +1 -1
- package/dist/esm-node/src/locales/ru.mjs +1 -0
- package/dist/iife/entry.js +10 -10
- package/dist/styles.css +1 -1
- package/dist/types/components/CdsOtpInput/CdsOtpField.vue.d.ts +25 -0
- package/dist/types/components/CdsOtpInput/CdsOtpGroup.vue.d.ts +34 -0
- package/dist/types/components/CdsOtpInput/CdsOtpInput.vue.d.ts +222 -0
- package/dist/types/components/CdsOtpInput/CdsOtpSeparator.vue.d.ts +25 -0
- package/dist/types/components/CdsOtpInput/api/CdsOtpInput.constants.d.ts +9 -0
- package/dist/types/components/CdsOtpInput/api/CdsOtpInput.props.d.ts +340 -0
- package/dist/types/components/CdsOtpInput/api/CdsOtpInput.types.d.ts +47 -0
- package/dist/types/components/CdsOtpInput/composables/useOtpInput.d.ts +76 -0
- package/dist/types/components/CdsOtpInput/index.d.ts +529 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/entry.d.ts +5 -1
- package/dist/types/locales/en.d.ts +1 -0
- package/dist/types/locales/ru.d.ts +1 -0
- package/llms/llms-components.txt +512 -1
- package/llms/llms-full.txt +513 -2
- package/llms/llms-guides.txt +1 -1
- package/llms/llms-migration.txt +2 -2
- package/llms/llms-tokens.txt +1 -1
- package/llms/llms.txt +4 -3
- package/package.json +1 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
/*
|
|
3
|
+
* Easing component
|
|
4
|
+
* @type Map
|
|
5
|
+
*/
|
|
6
|
+
/*
|
|
7
|
+
* Get the transition-timing-function for a given easing and motion mode
|
|
8
|
+
* @param {String} $type - Can be `ease-in-out`, `ease-in`, or `ease-out`
|
|
9
|
+
* @param {String} $mode [basic] - Can be `basic` or `accent`
|
|
10
|
+
* @param {Map} $easing [$easing] - Easing's map
|
|
11
|
+
* @return {Function} CSS `cubic-bezier()` function
|
|
12
|
+
*/
|
|
13
|
+
/*
|
|
14
|
+
* Set the transition-timing-function for a given easing and motion mode
|
|
15
|
+
* @param {Number} $duration — The dynamic duration in ms
|
|
16
|
+
* @param {String} $type - The name of the easing curve to apply
|
|
17
|
+
* @param {String} $mode - The mode for the easing curve to use
|
|
18
|
+
*/
|
|
19
|
+
@layer cds-components {
|
|
20
|
+
.cds-otp-input {
|
|
21
|
+
position: relative;
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
}
|
|
26
|
+
.cds-otp-input--disabled {
|
|
27
|
+
pointer-events: none;
|
|
28
|
+
}
|
|
29
|
+
.cds-otp-input--size-xs .cds-otp-field {
|
|
30
|
+
min-width: calc(24px / var(--cds-base-unit) * 1rem);
|
|
31
|
+
}
|
|
32
|
+
.cds-otp-input--size-sm .cds-otp-field {
|
|
33
|
+
min-width: calc(28px / var(--cds-base-unit) * 1rem);
|
|
34
|
+
}
|
|
35
|
+
.cds-otp-input--size-md .cds-otp-field {
|
|
36
|
+
min-width: calc(32px / var(--cds-base-unit) * 1rem);
|
|
37
|
+
}
|
|
38
|
+
.cds-otp-input--size-lg .cds-otp-field {
|
|
39
|
+
min-width: calc(36px / var(--cds-base-unit) * 1rem);
|
|
40
|
+
}
|
|
41
|
+
.cds-otp-input--size-xl .cds-otp-field {
|
|
42
|
+
min-width: calc(40px / var(--cds-base-unit) * 1rem);
|
|
43
|
+
}
|
|
44
|
+
.cds-otp-input--size-xs .cds-otp-field__slot {
|
|
45
|
+
font-family: inherit;
|
|
46
|
+
font-size: var(--cds-font-size-300);
|
|
47
|
+
font-weight: var(--cds-font-weight-regular);
|
|
48
|
+
line-height: var(--cds-font-line-height-400);
|
|
49
|
+
letter-spacing: 0;
|
|
50
|
+
}
|
|
51
|
+
.cds-otp-input--size-sm .cds-otp-field__slot {
|
|
52
|
+
font-family: inherit;
|
|
53
|
+
font-size: var(--cds-font-size-400);
|
|
54
|
+
font-weight: var(--cds-font-weight-regular);
|
|
55
|
+
line-height: var(--cds-font-line-height-400);
|
|
56
|
+
letter-spacing: 0;
|
|
57
|
+
}
|
|
58
|
+
.cds-otp-input--size-md .cds-otp-field__slot {
|
|
59
|
+
font-family: inherit;
|
|
60
|
+
font-size: var(--cds-font-size-500);
|
|
61
|
+
font-weight: var(--cds-font-weight-regular);
|
|
62
|
+
line-height: var(--cds-font-line-height-500);
|
|
63
|
+
letter-spacing: 0;
|
|
64
|
+
}
|
|
65
|
+
.cds-otp-input--size-lg .cds-otp-field__slot {
|
|
66
|
+
font-family: inherit;
|
|
67
|
+
font-size: var(--cds-font-size-600);
|
|
68
|
+
font-weight: var(--cds-font-weight-regular);
|
|
69
|
+
line-height: var(--cds-font-line-height-600);
|
|
70
|
+
letter-spacing: 0;
|
|
71
|
+
}
|
|
72
|
+
.cds-otp-input--size-xl .cds-otp-field__slot {
|
|
73
|
+
font-family: inherit;
|
|
74
|
+
font-size: var(--cds-font-size-700);
|
|
75
|
+
font-weight: var(--cds-font-weight-regular);
|
|
76
|
+
line-height: var(--cds-font-line-height-700);
|
|
77
|
+
letter-spacing: 0;
|
|
78
|
+
}
|
|
79
|
+
.cds-otp-input__content {
|
|
80
|
+
position: relative;
|
|
81
|
+
display: flex;
|
|
82
|
+
gap: var(--cds-spacing-200);
|
|
83
|
+
align-items: stretch;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
width: 100%;
|
|
86
|
+
max-width: calc(320px / var(--cds-base-unit) * 1rem);
|
|
87
|
+
border-radius: var(--cds-border-radius-200);
|
|
88
|
+
}
|
|
89
|
+
.cds-otp-input--divided .cds-otp-input__content {
|
|
90
|
+
max-width: calc(360px / var(--cds-base-unit) * 1rem);
|
|
91
|
+
}
|
|
92
|
+
.cds-otp-input--merged .cds-otp-input__content {
|
|
93
|
+
gap: 0;
|
|
94
|
+
}
|
|
95
|
+
.cds-otp-input__input {
|
|
96
|
+
position: absolute;
|
|
97
|
+
inset-inline-start: 50%;
|
|
98
|
+
bottom: 0;
|
|
99
|
+
width: 1px;
|
|
100
|
+
height: 1px;
|
|
101
|
+
padding: 0;
|
|
102
|
+
margin: 0;
|
|
103
|
+
color: transparent;
|
|
104
|
+
pointer-events: none;
|
|
105
|
+
caret-color: transparent;
|
|
106
|
+
outline: none;
|
|
107
|
+
background: transparent;
|
|
108
|
+
border: 0;
|
|
109
|
+
opacity: 0;
|
|
110
|
+
}
|
|
111
|
+
.cds-otp-input__loader {
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
justify-content: center;
|
|
115
|
+
width: 100%;
|
|
116
|
+
height: 100%;
|
|
117
|
+
}
|
|
118
|
+
.cds-otp-group {
|
|
119
|
+
display: contents;
|
|
120
|
+
}
|
|
121
|
+
.cds-otp-group--merged {
|
|
122
|
+
display: flex;
|
|
123
|
+
gap: 0;
|
|
124
|
+
align-items: stretch;
|
|
125
|
+
border-radius: inherit;
|
|
126
|
+
}
|
|
127
|
+
.cds-otp-separator {
|
|
128
|
+
display: flex;
|
|
129
|
+
align-items: center;
|
|
130
|
+
justify-content: center;
|
|
131
|
+
margin-inline: var(--cds-spacing-100);
|
|
132
|
+
color: rgb(var(--cds-color-content-secondary));
|
|
133
|
+
}
|
|
134
|
+
.cds-otp-field {
|
|
135
|
+
flex: 1 1 0;
|
|
136
|
+
min-width: 0;
|
|
137
|
+
transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
138
|
+
transition-property: opacity, border-color, box-shadow;
|
|
139
|
+
}
|
|
140
|
+
.cds-otp-field--highlighted {
|
|
141
|
+
opacity: 0.5;
|
|
142
|
+
}
|
|
143
|
+
.cds-otp-group--merged .cds-otp-field {
|
|
144
|
+
border-radius: 0;
|
|
145
|
+
}
|
|
146
|
+
.cds-otp-group--merged .cds-otp-field:not(:first-child) {
|
|
147
|
+
margin-inline-start: calc(var(--cds-border-100) * -1);
|
|
148
|
+
}
|
|
149
|
+
.cds-otp-group--merged .cds-otp-field:first-child {
|
|
150
|
+
border-start-start-radius: var(--cds-border-radius-200);
|
|
151
|
+
border-end-start-radius: var(--cds-border-radius-200);
|
|
152
|
+
}
|
|
153
|
+
.cds-otp-group--merged .cds-otp-field:last-child {
|
|
154
|
+
border-start-end-radius: var(--cds-border-radius-200);
|
|
155
|
+
border-end-end-radius: var(--cds-border-radius-200);
|
|
156
|
+
}
|
|
157
|
+
.cds-otp-group--merged .cds-otp-field:hover {
|
|
158
|
+
z-index: 1;
|
|
159
|
+
}
|
|
160
|
+
.cds-otp-group--merged .cds-otp-field.cds-field--focused {
|
|
161
|
+
z-index: 2;
|
|
162
|
+
}
|
|
163
|
+
.cds-otp-field .cds-field__field {
|
|
164
|
+
justify-content: center;
|
|
165
|
+
}
|
|
166
|
+
.cds-otp-field__slot {
|
|
167
|
+
position: relative;
|
|
168
|
+
display: grid;
|
|
169
|
+
place-content: center;
|
|
170
|
+
place-items: center;
|
|
171
|
+
width: 100%;
|
|
172
|
+
height: 100%;
|
|
173
|
+
color: inherit;
|
|
174
|
+
}
|
|
175
|
+
.cds-otp-field__slot > * {
|
|
176
|
+
grid-area: 1/1;
|
|
177
|
+
}
|
|
178
|
+
.cds-otp-field__spacer {
|
|
179
|
+
display: block;
|
|
180
|
+
pointer-events: none;
|
|
181
|
+
opacity: 0;
|
|
182
|
+
}
|
|
183
|
+
.cds-otp-field__placeholder {
|
|
184
|
+
color: rgb(var(--cds-color-content-tertiary));
|
|
185
|
+
}
|
|
186
|
+
.cds-otp-field__composition {
|
|
187
|
+
color: rgb(var(--cds-color-content-secondary));
|
|
188
|
+
text-decoration: underline;
|
|
189
|
+
}
|
|
190
|
+
.cds-otp-field__caret {
|
|
191
|
+
width: var(--cds-border-100);
|
|
192
|
+
height: 1.2em;
|
|
193
|
+
background: currentcolor;
|
|
194
|
+
animation: cds-otp-blink 1000ms step-end infinite;
|
|
195
|
+
}
|
|
196
|
+
@keyframes cds-otp-blink {
|
|
197
|
+
0%, 100% {
|
|
198
|
+
opacity: 1;
|
|
199
|
+
}
|
|
200
|
+
50% {
|
|
201
|
+
opacity: 0;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
package/dist/esm-node/src/components/CdsOtpInput/CdsOtpInput.vue_vue_type_script_setup_true_lang.mjs
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { defineComponent, useSlots, useAttrs, ref, toRef, watch, unref, provide, createVNode, Fragment, mergeProps, withDirectives } from "vue";
|
|
2
|
+
import { C as CdsOverlay } from "../CdsOverlay/index.mjs";
|
|
3
|
+
import { C as CdsProgressCircle } from "../CdsProgressCircle/index.mjs";
|
|
4
|
+
import { u as useFocus, b as useAutofocus } from "../../composables/useFocus/useFocus.mjs";
|
|
5
|
+
import { a as useLocale, u as useRtl } from "../../composables/useLocale/useLocale.mjs";
|
|
6
|
+
import { p as provideTheme } from "../../composables/useTheme/useTheme.mjs";
|
|
7
|
+
import { u as useDefaults, p as provideDefaults } from "../../core/useDefaults.mjs";
|
|
8
|
+
import { u as useProxyModel } from "../../core/useProxyModel.mjs";
|
|
9
|
+
import { D as filterInputAttrs } from "../../utils/helpers.mjs";
|
|
10
|
+
import { c as classNames } from "../../utils/dom/classNames.mjs";
|
|
11
|
+
import { c as CdsOtpInputConstants, d as CdsOtpInputSymbol } from "./api/CdsOtpInput.constants.mjs";
|
|
12
|
+
import { c as defineCdsOtpInputProps } from "./api/CdsOtpInput.props.mjs";
|
|
13
|
+
import { _ as _sfc_main$2 } from "./CdsOtpField.vue_vue_type_script_setup_true_lang.mjs";
|
|
14
|
+
import { _ as _sfc_main$1 } from "./CdsOtpGroup.vue_vue_type_script_setup_true_lang.mjs";
|
|
15
|
+
import { _ as _sfc_main$3 } from "./CdsOtpSeparator.vue_vue_type_script_setup_true_lang.mjs";
|
|
16
|
+
import { u as useOtpInput } from "./composables/useOtpInput.mjs";
|
|
17
|
+
import { I as Intersect } from "../../directives/intersect/index.mjs";
|
|
18
|
+
import { u as useDimensions } from "../../composables/useDimensions/useDimensions.mjs";
|
|
19
|
+
import { u as useSize } from "../../composables/useSize/useSize.mjs";
|
|
20
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
21
|
+
...{
|
|
22
|
+
name: CdsOtpInputConstants.name,
|
|
23
|
+
inheritAttrs: false,
|
|
24
|
+
directives: {
|
|
25
|
+
vIntersect: Intersect
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
__name: "CdsOtpInput",
|
|
29
|
+
props: {
|
|
30
|
+
...defineCdsOtpInputProps()
|
|
31
|
+
},
|
|
32
|
+
emits: ["finish", "update:focused", "update:modelValue"],
|
|
33
|
+
setup(__props, {
|
|
34
|
+
expose: __expose,
|
|
35
|
+
emit: __emit
|
|
36
|
+
}) {
|
|
37
|
+
const _props = __props;
|
|
38
|
+
const props = useDefaults(_props);
|
|
39
|
+
const slots = useSlots();
|
|
40
|
+
const emit = __emit;
|
|
41
|
+
const attrs = useAttrs();
|
|
42
|
+
const {
|
|
43
|
+
themeClasses
|
|
44
|
+
} = provideTheme(props);
|
|
45
|
+
const {
|
|
46
|
+
dimensionStyles
|
|
47
|
+
} = useDimensions(props);
|
|
48
|
+
const {
|
|
49
|
+
sizeClasses
|
|
50
|
+
} = useSize(props);
|
|
51
|
+
const {
|
|
52
|
+
isFocused
|
|
53
|
+
} = useFocus(props);
|
|
54
|
+
const {
|
|
55
|
+
onIntersect
|
|
56
|
+
} = useAutofocus(props);
|
|
57
|
+
const {
|
|
58
|
+
t
|
|
59
|
+
} = useLocale();
|
|
60
|
+
const {
|
|
61
|
+
isRtl
|
|
62
|
+
} = useRtl();
|
|
63
|
+
const model = useProxyModel(props, "modelValue", "", (value) => value == null ? "" : String(value));
|
|
64
|
+
const inputRef = ref();
|
|
65
|
+
const length = toRef(() => Number(props.length));
|
|
66
|
+
let focusAtPending = false;
|
|
67
|
+
const otp = useOtpInput({
|
|
68
|
+
value: model,
|
|
69
|
+
length,
|
|
70
|
+
pattern: () => props.pattern,
|
|
71
|
+
type: () => props.type,
|
|
72
|
+
masked: () => props.masked,
|
|
73
|
+
placeholder: () => props.placeholder,
|
|
74
|
+
isFocused
|
|
75
|
+
});
|
|
76
|
+
function applySelection() {
|
|
77
|
+
const input = unref(inputRef);
|
|
78
|
+
const selection = unref(otp.selection);
|
|
79
|
+
if (!input || !selection) return;
|
|
80
|
+
input.setSelectionRange(selection.start, selection.end, selection.direction);
|
|
81
|
+
}
|
|
82
|
+
function syncDOM() {
|
|
83
|
+
const input = unref(inputRef);
|
|
84
|
+
if (!input) return;
|
|
85
|
+
if (input.value !== unref(otp.value)) input.value = unref(otp.value);
|
|
86
|
+
applySelection();
|
|
87
|
+
}
|
|
88
|
+
function onSelectionChange() {
|
|
89
|
+
const input = unref(inputRef);
|
|
90
|
+
if (!input) {
|
|
91
|
+
otp.clearSelection();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const result = otp.syncSelection({
|
|
95
|
+
value: input.value,
|
|
96
|
+
selectionStart: input.selectionStart,
|
|
97
|
+
selectionEnd: input.selectionEnd,
|
|
98
|
+
selectionDirection: input.selectionDirection,
|
|
99
|
+
maxLength: unref(length)
|
|
100
|
+
});
|
|
101
|
+
if (!result) return;
|
|
102
|
+
if (input.selectionStart !== result.start || input.selectionEnd !== result.end) {
|
|
103
|
+
input.setSelectionRange(result.start, result.end, result.direction);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function onInput(event) {
|
|
107
|
+
const inputEvent = event;
|
|
108
|
+
const target = event.target;
|
|
109
|
+
const composing = inputEvent.isComposing || unref(otp.isComposing);
|
|
110
|
+
if (composing && otp.isImeText(target.value)) return;
|
|
111
|
+
const next = otp.setValue(target.value);
|
|
112
|
+
if (target.value !== next) target.value = next;
|
|
113
|
+
}
|
|
114
|
+
function onCompositionstart() {
|
|
115
|
+
otp.startComposition();
|
|
116
|
+
}
|
|
117
|
+
function onCompositionupdate(event) {
|
|
118
|
+
otp.updateComposition(event.data ?? "");
|
|
119
|
+
}
|
|
120
|
+
function onCompositionend(event) {
|
|
121
|
+
otp.endComposition();
|
|
122
|
+
onInput(event);
|
|
123
|
+
}
|
|
124
|
+
function onFocus() {
|
|
125
|
+
isFocused.value = true;
|
|
126
|
+
if (focusAtPending) return;
|
|
127
|
+
if (!unref(inputRef)) return;
|
|
128
|
+
otp.selectAtEnd();
|
|
129
|
+
applySelection();
|
|
130
|
+
}
|
|
131
|
+
function onBlur() {
|
|
132
|
+
isFocused.value = false;
|
|
133
|
+
otp.clearSelection();
|
|
134
|
+
}
|
|
135
|
+
function onKeydown(event) {
|
|
136
|
+
if (event.shiftKey && (event.key === "ArrowLeft" || event.key === "ArrowRight")) {
|
|
137
|
+
const direction = (event.key === "ArrowLeft" ? -1 : 1) * (unref(isRtl) ? -1 : 1);
|
|
138
|
+
if (otp.extendSelection(direction)) {
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
syncDOM();
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (event.key !== "Backspace" && event.key !== "Delete") return;
|
|
145
|
+
if (!event.metaKey && !event.ctrlKey && !event.altKey) return;
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
otp.bulkDelete(event.key === "Backspace");
|
|
148
|
+
syncDOM();
|
|
149
|
+
}
|
|
150
|
+
function onBeforeinput(event) {
|
|
151
|
+
const pattern = unref(otp.effectivePattern);
|
|
152
|
+
if (event.inputType === "insertText" && event.data && pattern && !pattern.test(event.data)) {
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (event.inputType === "deleteContentForward") {
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
const input = unref(inputRef);
|
|
159
|
+
if (!input) return;
|
|
160
|
+
const selection = unref(otp.selection);
|
|
161
|
+
otp.deleteRange((selection == null ? void 0 : selection.start) ?? 0, (selection == null ? void 0 : selection.end) ?? input.value.length);
|
|
162
|
+
syncDOM();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const isBackward = ["deleteWordBackward", "deleteSoftLineBackward", "deleteHardLineBackward"].includes(event.inputType);
|
|
166
|
+
const isForward = ["deleteWordForward", "deleteSoftLineForward", "deleteHardLineForward"].includes(event.inputType);
|
|
167
|
+
if (!isBackward && !isForward) return;
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
otp.bulkDelete(isBackward);
|
|
170
|
+
syncDOM();
|
|
171
|
+
}
|
|
172
|
+
function onPaste(event) {
|
|
173
|
+
var _a;
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
const input = unref(inputRef);
|
|
176
|
+
if (!input) return;
|
|
177
|
+
const text = ((_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain").trim()) ?? "";
|
|
178
|
+
const selection = unref(otp.selection);
|
|
179
|
+
otp.insert(text, {
|
|
180
|
+
start: (selection == null ? void 0 : selection.start) ?? 0,
|
|
181
|
+
end: (selection == null ? void 0 : selection.end) ?? input.value.length
|
|
182
|
+
});
|
|
183
|
+
syncDOM();
|
|
184
|
+
}
|
|
185
|
+
function focusAt(index) {
|
|
186
|
+
const input = unref(inputRef);
|
|
187
|
+
if (!input) return;
|
|
188
|
+
focusAtPending = true;
|
|
189
|
+
input.focus();
|
|
190
|
+
focusAtPending = false;
|
|
191
|
+
otp.selectSlot(index);
|
|
192
|
+
applySelection();
|
|
193
|
+
}
|
|
194
|
+
function focus() {
|
|
195
|
+
var _a;
|
|
196
|
+
(_a = unref(inputRef)) == null ? void 0 : _a.focus();
|
|
197
|
+
}
|
|
198
|
+
function blur() {
|
|
199
|
+
var _a;
|
|
200
|
+
(_a = unref(inputRef)) == null ? void 0 : _a.blur();
|
|
201
|
+
}
|
|
202
|
+
watch(inputRef, (input, _previous, onCleanup) => {
|
|
203
|
+
if (!input) return;
|
|
204
|
+
input.addEventListener("selectionchange", onSelectionChange);
|
|
205
|
+
onCleanup(() => input.removeEventListener("selectionchange", onSelectionChange));
|
|
206
|
+
}, {
|
|
207
|
+
immediate: true
|
|
208
|
+
});
|
|
209
|
+
watch(model, (value) => {
|
|
210
|
+
if (unref(otp.isComposing)) return;
|
|
211
|
+
if (value.length === unref(length)) emit("finish", value);
|
|
212
|
+
});
|
|
213
|
+
provideDefaults({
|
|
214
|
+
CdsField: {
|
|
215
|
+
color: toRef(() => props.color),
|
|
216
|
+
baseColor: toRef(() => props.baseColor),
|
|
217
|
+
activeColor: toRef(() => props.activeColor),
|
|
218
|
+
bgColor: toRef(() => props.bgColor),
|
|
219
|
+
disabled: toRef(() => props.disabled),
|
|
220
|
+
error: toRef(() => props.error),
|
|
221
|
+
size: toRef(() => props.size)
|
|
222
|
+
}
|
|
223
|
+
}, {
|
|
224
|
+
scoped: true
|
|
225
|
+
});
|
|
226
|
+
provide(CdsOtpInputSymbol, {
|
|
227
|
+
otpSlots: otp.slots,
|
|
228
|
+
isFocused,
|
|
229
|
+
focusAll: toRef(() => props.focusAll),
|
|
230
|
+
divider: toRef(() => props.divider),
|
|
231
|
+
merged: toRef(() => props.merged),
|
|
232
|
+
focusAt
|
|
233
|
+
});
|
|
234
|
+
__expose({
|
|
235
|
+
/** Ref-ссылка на скрытый input, который принимает ввод кода */
|
|
236
|
+
inputRef,
|
|
237
|
+
/** Состояние фокуса поля */
|
|
238
|
+
isFocused,
|
|
239
|
+
/** Установить фокус на поле */
|
|
240
|
+
focus,
|
|
241
|
+
/** Снять фокус с поля */
|
|
242
|
+
blur,
|
|
243
|
+
/** Очистить введённый код */
|
|
244
|
+
reset: otp.reset
|
|
245
|
+
});
|
|
246
|
+
return () => {
|
|
247
|
+
var _a;
|
|
248
|
+
const {
|
|
249
|
+
rootClass
|
|
250
|
+
} = CdsOtpInputConstants;
|
|
251
|
+
const [rootAttrs, inputAttrs] = filterInputAttrs(attrs);
|
|
252
|
+
const count = unref(length);
|
|
253
|
+
const fields = props.merged ? createVNode(_sfc_main$1, {
|
|
254
|
+
"merged": true
|
|
255
|
+
}, {
|
|
256
|
+
default: () => [Array.from({
|
|
257
|
+
length: count
|
|
258
|
+
}, (_, index) => createVNode(_sfc_main$2, {
|
|
259
|
+
"key": index,
|
|
260
|
+
"index": index
|
|
261
|
+
}, null))]
|
|
262
|
+
}) : Array.from({
|
|
263
|
+
length: count
|
|
264
|
+
}, (_, index) => createVNode(Fragment, null, [(props.divider || slots.divider) && index !== 0 && createVNode(_sfc_main$3, {
|
|
265
|
+
"key": `divider-${index}`
|
|
266
|
+
}, {
|
|
267
|
+
default: () => {
|
|
268
|
+
var _a2;
|
|
269
|
+
return [((_a2 = slots.divider) == null ? void 0 : _a2.call(slots, {
|
|
270
|
+
index: index - 1
|
|
271
|
+
})) ?? props.divider];
|
|
272
|
+
}
|
|
273
|
+
}), createVNode(_sfc_main$2, {
|
|
274
|
+
"key": index,
|
|
275
|
+
"index": index
|
|
276
|
+
}, null)]));
|
|
277
|
+
return createVNode("div", mergeProps({
|
|
278
|
+
"class": classNames(rootClass, {
|
|
279
|
+
[`${rootClass}--divided`]: !!props.divider || !!slots.divider,
|
|
280
|
+
[`${rootClass}--merged`]: props.merged,
|
|
281
|
+
[`${rootClass}--disabled`]: !!props.disabled,
|
|
282
|
+
[`${rootClass}--error`]: props.error
|
|
283
|
+
}, unref(themeClasses), unref(sizeClasses), props.class),
|
|
284
|
+
"style": [props.style]
|
|
285
|
+
}, rootAttrs), [createVNode("div", {
|
|
286
|
+
"class": `${rootClass}__content`,
|
|
287
|
+
"style": [unref(dimensionStyles)],
|
|
288
|
+
"dir": unref(isRtl) ? "rtl" : "ltr"
|
|
289
|
+
}, [slots.fields ? slots.fields() : fields, withDirectives(createVNode("input", mergeProps({
|
|
290
|
+
"ref": inputRef,
|
|
291
|
+
"class": `${rootClass}__input`,
|
|
292
|
+
"type": "text",
|
|
293
|
+
"inputmode": unref(otp.inputMode),
|
|
294
|
+
"dir": unref(isRtl) ? "rtl" : "ltr",
|
|
295
|
+
"autocomplete": "one-time-code",
|
|
296
|
+
"autocorrect": "off",
|
|
297
|
+
"autocapitalize": "off",
|
|
298
|
+
"spellcheck": false,
|
|
299
|
+
"disabled": !!props.disabled,
|
|
300
|
+
"aria-label": t(props.label),
|
|
301
|
+
"value": unref(model)
|
|
302
|
+
}, inputAttrs, {
|
|
303
|
+
"onInput": onInput,
|
|
304
|
+
"onKeydown": onKeydown,
|
|
305
|
+
"onBeforeinput": onBeforeinput,
|
|
306
|
+
"onFocus": onFocus,
|
|
307
|
+
"onBlur": onBlur,
|
|
308
|
+
"onPaste": onPaste,
|
|
309
|
+
"onCompositionstart": onCompositionstart,
|
|
310
|
+
"onCompositionupdate": onCompositionupdate,
|
|
311
|
+
"onCompositionend": onCompositionend
|
|
312
|
+
}), null), [[Intersect, onIntersect, null, {
|
|
313
|
+
once: true
|
|
314
|
+
}]]), createVNode(CdsOverlay, {
|
|
315
|
+
"contained": true,
|
|
316
|
+
"persistent": true,
|
|
317
|
+
"contentClass": `${rootClass}__loader`,
|
|
318
|
+
"modelValue": !!props.loading
|
|
319
|
+
}, {
|
|
320
|
+
default: () => {
|
|
321
|
+
var _a2;
|
|
322
|
+
return [((_a2 = slots.loader) == null ? void 0 : _a2.call(slots)) ?? createVNode(CdsProgressCircle, {
|
|
323
|
+
"color": typeof props.loading === "boolean" ? void 0 : props.loading,
|
|
324
|
+
"indeterminate": true,
|
|
325
|
+
"size": 24,
|
|
326
|
+
"width": 2
|
|
327
|
+
}, null)];
|
|
328
|
+
}
|
|
329
|
+
}), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
export {
|
|
334
|
+
_sfc_main as _
|
|
335
|
+
};
|
|
336
|
+
//# sourceMappingURL=CdsOtpInput.vue_vue_type_script_setup_true_lang.mjs.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { defineComponent, useSlots, createVNode } from "vue";
|
|
2
|
+
import { u as useDefaults } from "../../core/useDefaults.mjs";
|
|
3
|
+
import { c as classNames } from "../../utils/dom/classNames.mjs";
|
|
4
|
+
import { b as CdsOtpSeparatorConstants } from "./api/CdsOtpInput.constants.mjs";
|
|
5
|
+
import { b as defineCdsOtpSeparatorProps } from "./api/CdsOtpInput.props.mjs";
|
|
6
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
|
+
...{
|
|
8
|
+
name: CdsOtpSeparatorConstants.name
|
|
9
|
+
},
|
|
10
|
+
__name: "CdsOtpSeparator",
|
|
11
|
+
props: {
|
|
12
|
+
...defineCdsOtpSeparatorProps()
|
|
13
|
+
},
|
|
14
|
+
setup(__props) {
|
|
15
|
+
const _props = __props;
|
|
16
|
+
const props = useDefaults(_props);
|
|
17
|
+
const slots = useSlots();
|
|
18
|
+
return () => {
|
|
19
|
+
var _a;
|
|
20
|
+
const {
|
|
21
|
+
rootClass
|
|
22
|
+
} = CdsOtpSeparatorConstants;
|
|
23
|
+
return createVNode("div", {
|
|
24
|
+
"class": classNames(rootClass, props.class),
|
|
25
|
+
"style": [props.style],
|
|
26
|
+
"aria-hidden": "true"
|
|
27
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export {
|
|
32
|
+
_sfc_main as _
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=CdsOtpSeparator.vue_vue_type_script_setup_true_lang.mjs.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { d as defineConstants } from "../../../core/defineConstants.mjs";
|
|
2
|
+
const CdsOtpInputConstants = defineConstants("CdsOtpInput", {
|
|
3
|
+
types: ["text", "password", "number"]
|
|
4
|
+
});
|
|
5
|
+
const CdsOtpFieldConstants = defineConstants("CdsOtpField");
|
|
6
|
+
const CdsOtpGroupConstants = defineConstants("CdsOtpGroup");
|
|
7
|
+
const CdsOtpSeparatorConstants = defineConstants("CdsOtpSeparator");
|
|
8
|
+
const CdsOtpInputSymbol = Symbol.for("cds:otp-input");
|
|
9
|
+
export {
|
|
10
|
+
CdsOtpFieldConstants as C,
|
|
11
|
+
CdsOtpGroupConstants as a,
|
|
12
|
+
CdsOtpSeparatorConstants as b,
|
|
13
|
+
CdsOtpInputConstants as c,
|
|
14
|
+
CdsOtpInputSymbol as d
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=CdsOtpInput.constants.mjs.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { d as defineDisabledProps } from "../../../composables/useDisabled/useDisabled.mjs";
|
|
2
|
+
import { d as defineFocusProps, a as defineAutofocusProps } from "../../../composables/useFocus/useFocus.mjs";
|
|
3
|
+
import { d as defineLoaderProps } from "../../../composables/useLoader/useLoader.mjs";
|
|
4
|
+
import { d as defineThemeProps } from "../../../composables/useTheme/useTheme.mjs";
|
|
5
|
+
import { d as defineComponentProps } from "../../../core/defineComponent.mjs";
|
|
6
|
+
import { p as propsFactory } from "../../../core/propsFactory.mjs";
|
|
7
|
+
import { C as CdsOtpFieldConstants, a as CdsOtpGroupConstants, b as CdsOtpSeparatorConstants, c as CdsOtpInputConstants } from "./CdsOtpInput.constants.mjs";
|
|
8
|
+
import { d as defineSizeProps } from "../../../composables/useSize/useSize.mjs";
|
|
9
|
+
import { d as defineDimensionsProps } from "../../../composables/useDimensions/useDimensions.mjs";
|
|
10
|
+
import { d as defineColorProps } from "../../../composables/useColor/useColor.mjs";
|
|
11
|
+
const defineCdsOtpInputProps = propsFactory(
|
|
12
|
+
{
|
|
13
|
+
/** Символ-разделитель, который ставится между ячейками кода */
|
|
14
|
+
divider: String,
|
|
15
|
+
/** Подсвечивать все ячейки, пока поле находится в фокусе, а не только активную */
|
|
16
|
+
focusAll: Boolean,
|
|
17
|
+
/** Слитный вид: ячейки объединяются в одно поле без промежутков между ними */
|
|
18
|
+
merged: Boolean,
|
|
19
|
+
/** Доступное имя поля (`aria-label`). Принимает ключ локализации вида `$cds.input.otp` */
|
|
20
|
+
label: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: "$cds.input.otp"
|
|
23
|
+
},
|
|
24
|
+
/** Количество ячеек кода */
|
|
25
|
+
length: {
|
|
26
|
+
type: [Number, String],
|
|
27
|
+
default: 6
|
|
28
|
+
},
|
|
29
|
+
/** Скрывать введённые символы точками */
|
|
30
|
+
masked: Boolean,
|
|
31
|
+
/** Значение компонента v-model */
|
|
32
|
+
modelValue: {
|
|
33
|
+
type: [Number, String],
|
|
34
|
+
default: void 0
|
|
35
|
+
},
|
|
36
|
+
/** Допустимые символы: имя готового паттерна (`numeric`, `alpha`, `alphanumeric`, `unicode-alpha`, `unicode-alphanumeric`) или собственное регулярное выражение */
|
|
37
|
+
pattern: {
|
|
38
|
+
type: [String, Object],
|
|
39
|
+
default: void 0
|
|
40
|
+
},
|
|
41
|
+
/** Символ-заполнитель, который показывается в пустой ячейке */
|
|
42
|
+
placeholder: String,
|
|
43
|
+
/** Тип вводимого кода. `number` ограничивает ввод цифрами, `password` скрывает символы */
|
|
44
|
+
type: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "number",
|
|
47
|
+
validator: (value) => CdsOtpInputConstants.types.includes(value)
|
|
48
|
+
},
|
|
49
|
+
/** Состояние ошибки */
|
|
50
|
+
error: Boolean,
|
|
51
|
+
...defineAutofocusProps(),
|
|
52
|
+
...defineColorProps(),
|
|
53
|
+
...defineComponentProps(),
|
|
54
|
+
...defineDimensionsProps(),
|
|
55
|
+
...defineDisabledProps(),
|
|
56
|
+
...defineFocusProps(),
|
|
57
|
+
...defineLoaderProps(),
|
|
58
|
+
...defineSizeProps(),
|
|
59
|
+
...defineThemeProps()
|
|
60
|
+
},
|
|
61
|
+
CdsOtpInputConstants.name
|
|
62
|
+
);
|
|
63
|
+
const defineCdsOtpFieldProps = propsFactory(
|
|
64
|
+
{
|
|
65
|
+
/** Порядковый номер ячейки, начиная с нуля */
|
|
66
|
+
index: {
|
|
67
|
+
type: Number,
|
|
68
|
+
required: true
|
|
69
|
+
},
|
|
70
|
+
...defineComponentProps()
|
|
71
|
+
},
|
|
72
|
+
CdsOtpFieldConstants.name
|
|
73
|
+
);
|
|
74
|
+
const defineCdsOtpGroupProps = propsFactory(
|
|
75
|
+
{
|
|
76
|
+
/** Слитный вид группы. По умолчанию наследуется от родительского `CdsOtpInput` */
|
|
77
|
+
merged: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: null
|
|
80
|
+
},
|
|
81
|
+
...defineComponentProps()
|
|
82
|
+
},
|
|
83
|
+
CdsOtpGroupConstants.name
|
|
84
|
+
);
|
|
85
|
+
const defineCdsOtpSeparatorProps = propsFactory(
|
|
86
|
+
{
|
|
87
|
+
...defineComponentProps()
|
|
88
|
+
},
|
|
89
|
+
CdsOtpSeparatorConstants.name
|
|
90
|
+
);
|
|
91
|
+
export {
|
|
92
|
+
defineCdsOtpGroupProps as a,
|
|
93
|
+
defineCdsOtpSeparatorProps as b,
|
|
94
|
+
defineCdsOtpInputProps as c,
|
|
95
|
+
defineCdsOtpFieldProps as d
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=CdsOtpInput.props.mjs.map
|