@teselia/password 0.0.0-stage → 1.0.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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +61 -2
- package/dist/TesPassword.vue.d.ts +27 -0
- package/dist/composables/use-caps-lock.d.ts +11 -0
- package/dist/composables/use-field-options.d.ts +7 -0
- package/dist/composables/use-public-events.d.ts +5 -0
- package/dist/composables/use-requirements.d.ts +20 -0
- package/dist/composables/use-reveal.d.ts +16 -0
- package/dist/composables/use-validation.d.ts +17 -0
- package/dist/composables/use-value-sync.d.ts +10 -0
- package/dist/core/changes.d.ts +7 -0
- package/dist/core/ids.d.ts +1 -0
- package/dist/core/purpose.d.ts +4 -0
- package/dist/core/rules.d.ts +23 -0
- package/dist/core/validation.d.ts +17 -0
- package/dist/element.d.ts +40 -0
- package/dist/index.d.ts +9 -0
- package/dist/props.d.ts +58 -0
- package/dist/styles.d.ts +2 -0
- package/dist/tes-password.iife.js +2 -0
- package/dist/tes-password.iife.js.map +1 -0
- package/dist/tes-password.js +622 -0
- package/dist/tes-password.js.map +1 -0
- package/package.json +60 -3
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, defineComponent as a, defineCustomElement as o, mergeDefaults as s, normalizeClass as c, onBeforeUnmount as l, onMounted as u, openBlock as d, reactive as f, ref as p, renderList as m, toDisplayString as h, unref as g, useAttrs as _, useHost as ee, useTemplateRef as te, watch as v, watchEffect as y, withModifiers as b } from "vue";
|
|
2
|
+
//#region ../shared/src/use-announcer.ts
|
|
3
|
+
var x = 500, S = 100;
|
|
4
|
+
function C() {
|
|
5
|
+
let e = p(""), t;
|
|
6
|
+
function n() {
|
|
7
|
+
clearTimeout(t), e.value = "";
|
|
8
|
+
}
|
|
9
|
+
function r(r) {
|
|
10
|
+
n(), t = setTimeout(() => {
|
|
11
|
+
e.value = r;
|
|
12
|
+
}, S);
|
|
13
|
+
}
|
|
14
|
+
function i(r) {
|
|
15
|
+
n(), t = setTimeout(() => {
|
|
16
|
+
e.value = r();
|
|
17
|
+
}, x);
|
|
18
|
+
}
|
|
19
|
+
return l(() => clearTimeout(t)), {
|
|
20
|
+
announcement: e,
|
|
21
|
+
announceNow: r,
|
|
22
|
+
announceOnceTypingPauses: i,
|
|
23
|
+
clear: n
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region ../shared/src/use-custom-states.ts
|
|
28
|
+
function ne(e, t) {
|
|
29
|
+
y(() => {
|
|
30
|
+
let n = e.states;
|
|
31
|
+
if (n) for (let [e, r] of Object.entries(t())) r ? n.add(e) : n.delete(e);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/composables/use-caps-lock.ts
|
|
36
|
+
function re({ props: e, announceNow: t }) {
|
|
37
|
+
let n = p(!1);
|
|
38
|
+
function r(r) {
|
|
39
|
+
let i = r.getModifierState("CapsLock");
|
|
40
|
+
i && !n.value && t(e.textCapsLock), n.value = i;
|
|
41
|
+
}
|
|
42
|
+
function i() {
|
|
43
|
+
n.value = !1;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
capsLockOn: n,
|
|
47
|
+
readCapsLock: r,
|
|
48
|
+
forgetCapsLock: i
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/core/purpose.ts
|
|
53
|
+
var w = {
|
|
54
|
+
current: "current-password",
|
|
55
|
+
new: "new-password"
|
|
56
|
+
};
|
|
57
|
+
function T(e) {
|
|
58
|
+
return e === "current" || e === "new";
|
|
59
|
+
}
|
|
60
|
+
function E(e) {
|
|
61
|
+
return T(e) ? e : "current";
|
|
62
|
+
}
|
|
63
|
+
function D(e, t) {
|
|
64
|
+
return t?.trim() ? t : w[e];
|
|
65
|
+
}
|
|
66
|
+
var O = [
|
|
67
|
+
"lowercase",
|
|
68
|
+
"uppercase",
|
|
69
|
+
"digit",
|
|
70
|
+
"symbol"
|
|
71
|
+
], k = {
|
|
72
|
+
lowercase: /\p{Ll}/u,
|
|
73
|
+
uppercase: /[\p{Lu}\p{Lt}]/u,
|
|
74
|
+
digit: /\p{Nd}/u,
|
|
75
|
+
symbol: /[^\p{L}\p{N}\s]/u
|
|
76
|
+
}, A = {
|
|
77
|
+
lowercase: "lower",
|
|
78
|
+
uppercase: "upper",
|
|
79
|
+
digit: "digit",
|
|
80
|
+
symbol: "special"
|
|
81
|
+
};
|
|
82
|
+
function j(e) {
|
|
83
|
+
if (e == null || e === "") return null;
|
|
84
|
+
let t = Number(e);
|
|
85
|
+
return Number.isInteger(t) && t > 0 ? t : null;
|
|
86
|
+
}
|
|
87
|
+
function M(e) {
|
|
88
|
+
return O.includes(e);
|
|
89
|
+
}
|
|
90
|
+
function N(e) {
|
|
91
|
+
let t = j(e.minlength) ?? 8, n = j(e.maxlength), r = String(e.requirements ?? "").toLowerCase().split(/[\s,]+/).filter(Boolean);
|
|
92
|
+
return {
|
|
93
|
+
minLength: t,
|
|
94
|
+
maxLength: n !== null && n >= t ? n : null,
|
|
95
|
+
classes: O.filter((e) => r.includes(e)),
|
|
96
|
+
unknown: [...new Set(r.filter((e) => !M(e)))]
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function P(e) {
|
|
100
|
+
return [...e].length;
|
|
101
|
+
}
|
|
102
|
+
function F(e, t) {
|
|
103
|
+
return [{
|
|
104
|
+
requirement: "length",
|
|
105
|
+
met: P(e) >= t.minLength
|
|
106
|
+
}, ...t.classes.map((t) => ({
|
|
107
|
+
requirement: t,
|
|
108
|
+
met: k[t].test(e)
|
|
109
|
+
}))];
|
|
110
|
+
}
|
|
111
|
+
function I(e, t) {
|
|
112
|
+
return F(e, t).every((e) => e.met);
|
|
113
|
+
}
|
|
114
|
+
function L(e, t) {
|
|
115
|
+
return t.maxLength !== null && P(e) > t.maxLength;
|
|
116
|
+
}
|
|
117
|
+
function R(e) {
|
|
118
|
+
return [
|
|
119
|
+
`minlength: ${e.minLength};`,
|
|
120
|
+
e.maxLength !== null && `maxlength: ${e.maxLength};`,
|
|
121
|
+
...e.classes.map((e) => `required: ${A[e]};`),
|
|
122
|
+
"allowed: lower, upper, digit, special;"
|
|
123
|
+
].filter(Boolean).join(" ");
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/composables/use-field-options.ts
|
|
127
|
+
function ie(e) {
|
|
128
|
+
let n = t(() => E(e.purpose)), r = t(() => n.value === "new" ? N({
|
|
129
|
+
minlength: e.minlength,
|
|
130
|
+
maxlength: e.maxlength,
|
|
131
|
+
requirements: e.requirements
|
|
132
|
+
}) : null);
|
|
133
|
+
return {
|
|
134
|
+
purpose: n,
|
|
135
|
+
ruleOptions: r,
|
|
136
|
+
autocomplete: t(() => D(n.value, e.autocomplete)),
|
|
137
|
+
rulesForPasswordManagers: t(() => r.value ? R(r.value) : void 0)
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/composables/use-public-events.ts
|
|
142
|
+
function ae(e) {
|
|
143
|
+
function t(t) {
|
|
144
|
+
let n = {
|
|
145
|
+
value: e.value,
|
|
146
|
+
requirementsMet: e.requirementsMet
|
|
147
|
+
};
|
|
148
|
+
e.dispatchEvent(new CustomEvent(t, {
|
|
149
|
+
bubbles: !0,
|
|
150
|
+
composed: !0,
|
|
151
|
+
detail: n
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
dispatchInput: () => t("input"),
|
|
156
|
+
dispatchChange: () => t("change")
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/core/changes.ts
|
|
161
|
+
function z(e, t) {
|
|
162
|
+
let n = new Map(e.map((e) => [e.requirement, e.met])), r = t.filter((e) => n.get(e.requirement) !== e.met);
|
|
163
|
+
return r.length === 0 ? null : {
|
|
164
|
+
met: r.filter((e) => e.met).map((e) => e.requirement),
|
|
165
|
+
unmet: r.filter((e) => !e.met).map((e) => e.requirement),
|
|
166
|
+
allMet: t.every((e) => e.met)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/composables/use-requirements.ts
|
|
171
|
+
function oe({ host: e, props: n, ruleOptions: r, announceOnceTypingPauses: i }) {
|
|
172
|
+
let a = t(() => r.value ? F(e.state.value, r.value) : []), o = t(() => a.value.map((e) => ({
|
|
173
|
+
...e,
|
|
174
|
+
text: l(e.requirement)
|
|
175
|
+
}))), s = a.value, c = !1;
|
|
176
|
+
function l(e) {
|
|
177
|
+
return {
|
|
178
|
+
length: n.textRuleLength.replaceAll("{minlength}", String(r.value?.minLength ?? "")),
|
|
179
|
+
lowercase: n.textRuleLowercase,
|
|
180
|
+
uppercase: n.textRuleUppercase,
|
|
181
|
+
digit: n.textRuleDigit,
|
|
182
|
+
symbol: n.textRuleSymbol
|
|
183
|
+
}[e];
|
|
184
|
+
}
|
|
185
|
+
function u(e) {
|
|
186
|
+
return e.allMet ? n.textAllMet : a.value.filter((t) => e.met.includes(t.requirement) || e.unmet.includes(t.requirement)).map((e) => `${l(e.requirement)}, ${e.met ? n.textRuleMet : n.textRuleUnmet}`).join(". ");
|
|
187
|
+
}
|
|
188
|
+
function d() {
|
|
189
|
+
r.value && (c = !0, i(() => {
|
|
190
|
+
c = !1;
|
|
191
|
+
let e = z(s, a.value);
|
|
192
|
+
return s = a.value, e ? u(e) : "";
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
return v(a, (e) => {
|
|
196
|
+
c || (s = e);
|
|
197
|
+
}), {
|
|
198
|
+
requirementItems: o,
|
|
199
|
+
reportUserChange: d
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/composables/use-reveal.ts
|
|
204
|
+
function se({ host: e, props: n, input: r, announceNow: i }) {
|
|
205
|
+
let a = t(() => e.state.revealed), o = t(() => a.value ? "text" : "password"), s = t(() => a.value ? n.textHideLabel : n.textShowLabel);
|
|
206
|
+
function c() {
|
|
207
|
+
e.revealed = !e.revealed, i(e.revealed ? n.textShown : n.textHidden);
|
|
208
|
+
}
|
|
209
|
+
function d() {
|
|
210
|
+
e.revealed = !1;
|
|
211
|
+
}
|
|
212
|
+
function f(e) {
|
|
213
|
+
e.target === r.value?.form && d();
|
|
214
|
+
}
|
|
215
|
+
return u(() => {
|
|
216
|
+
window.addEventListener("submit", f, !0), window.addEventListener("reset", f, !0), window.addEventListener("pagehide", d);
|
|
217
|
+
}), l(() => {
|
|
218
|
+
window.removeEventListener("submit", f, !0), window.removeEventListener("reset", f, !0), window.removeEventListener("pagehide", d);
|
|
219
|
+
}), {
|
|
220
|
+
revealed: a,
|
|
221
|
+
inputType: o,
|
|
222
|
+
toggleLabel: s,
|
|
223
|
+
toggleByUser: c
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region src/core/validation.ts
|
|
228
|
+
function B({ value: e, required: t, ruleOptions: n, customError: r }, i) {
|
|
229
|
+
return r ? {
|
|
230
|
+
flag: "customError",
|
|
231
|
+
message: r
|
|
232
|
+
} : e === "" ? t ? {
|
|
233
|
+
flag: "valueMissing",
|
|
234
|
+
message: i.required
|
|
235
|
+
} : null : n ? L(e, n) ? {
|
|
236
|
+
flag: "tooLong",
|
|
237
|
+
message: i.tooLong.replaceAll("{maxlength}", String(n.maxLength))
|
|
238
|
+
} : I(e, n) ? null : {
|
|
239
|
+
flag: "unmet",
|
|
240
|
+
message: i.unmet
|
|
241
|
+
} : null;
|
|
242
|
+
}
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/composables/use-validation.ts
|
|
245
|
+
function ce({ host: e, props: n, input: r, ruleOptions: i }) {
|
|
246
|
+
let { state: a } = e, o = t(() => B({
|
|
247
|
+
value: a.value,
|
|
248
|
+
required: n.required,
|
|
249
|
+
ruleOptions: i.value,
|
|
250
|
+
customError: a.customError
|
|
251
|
+
}, {
|
|
252
|
+
required: n.textRequired,
|
|
253
|
+
unmet: n.textUnmet,
|
|
254
|
+
tooLong: n.textTooLong
|
|
255
|
+
})), s = t(() => a.errorsVisible ? o.value : null);
|
|
256
|
+
function c() {
|
|
257
|
+
a.edited = !0, a.customError = "";
|
|
258
|
+
}
|
|
259
|
+
function d() {
|
|
260
|
+
a.errorsVisible = !0;
|
|
261
|
+
}
|
|
262
|
+
function f() {
|
|
263
|
+
a.edited && d();
|
|
264
|
+
}
|
|
265
|
+
function p(e) {
|
|
266
|
+
e.target === r.value?.form && (a.edited = !1, a.errorsVisible = !1, a.customError = "");
|
|
267
|
+
}
|
|
268
|
+
return y(() => r.value?.setCustomValidity(o.value?.message ?? ""), { flush: "sync" }), u(() => window.addEventListener("reset", p, !0)), l(() => window.removeEventListener("reset", p, !0)), {
|
|
269
|
+
visibleError: s,
|
|
270
|
+
markEdited: c,
|
|
271
|
+
revealErrors: d,
|
|
272
|
+
revealErrorsIfEdited: f
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/composables/use-value-sync.ts
|
|
277
|
+
function V({ host: e, input: t }) {
|
|
278
|
+
function n() {
|
|
279
|
+
t.value && (e.state.value = t.value.value);
|
|
280
|
+
}
|
|
281
|
+
function r(e) {
|
|
282
|
+
e.target === t.value?.form && setTimeout(n);
|
|
283
|
+
}
|
|
284
|
+
return u(() => {
|
|
285
|
+
n(), window.addEventListener("reset", r, !0);
|
|
286
|
+
}), l(() => window.removeEventListener("reset", r, !0)), { syncFromInput: n };
|
|
287
|
+
}
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/core/ids.ts
|
|
290
|
+
var H = 0;
|
|
291
|
+
function U(e) {
|
|
292
|
+
return H += 1, `${e}-${H}`;
|
|
293
|
+
}
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/props.ts
|
|
296
|
+
var W = {
|
|
297
|
+
required: !1,
|
|
298
|
+
disabled: !1,
|
|
299
|
+
readonly: !1,
|
|
300
|
+
textShow: "Show",
|
|
301
|
+
textHide: "Hide",
|
|
302
|
+
textShowLabel: "Show password",
|
|
303
|
+
textHideLabel: "Hide password",
|
|
304
|
+
textShown: "Your password is shown",
|
|
305
|
+
textHidden: "Your password is hidden",
|
|
306
|
+
textRequirements: "Your password must have:",
|
|
307
|
+
textRuleLength: "At least {minlength} characters",
|
|
308
|
+
textRuleLowercase: "A lowercase letter",
|
|
309
|
+
textRuleUppercase: "An uppercase letter",
|
|
310
|
+
textRuleDigit: "A number",
|
|
311
|
+
textRuleSymbol: "A symbol, like ! or #",
|
|
312
|
+
textRuleMet: "done",
|
|
313
|
+
textRuleUnmet: "not yet",
|
|
314
|
+
textAllMet: "All requirements met",
|
|
315
|
+
textCapsLock: "Caps Lock is on",
|
|
316
|
+
textRequired: "Enter a password",
|
|
317
|
+
textUnmet: "Your password does not meet all the requirements",
|
|
318
|
+
textTooLong: "Use {maxlength} characters or fewer"
|
|
319
|
+
}, le = { class: "tes-password__field" }, ue = ["for"], de = [
|
|
320
|
+
"id",
|
|
321
|
+
"type",
|
|
322
|
+
"name",
|
|
323
|
+
"^value",
|
|
324
|
+
"autocomplete",
|
|
325
|
+
"passwordrules",
|
|
326
|
+
"aria-describedby",
|
|
327
|
+
"aria-invalid",
|
|
328
|
+
"required",
|
|
329
|
+
"disabled",
|
|
330
|
+
"readonly"
|
|
331
|
+
], fe = ["aria-label"], pe = { class: "tes-password__requirements-title" }, me = { class: "tes-password__requirements-list" }, he = {
|
|
332
|
+
key: 0,
|
|
333
|
+
class: "tes-password__icon tes-password__icon--met",
|
|
334
|
+
viewBox: "0 0 16 16",
|
|
335
|
+
"aria-hidden": "true",
|
|
336
|
+
focusable: "false"
|
|
337
|
+
}, ge = {
|
|
338
|
+
key: 1,
|
|
339
|
+
class: "tes-password__icon tes-password__icon--unmet",
|
|
340
|
+
viewBox: "0 0 16 16",
|
|
341
|
+
"aria-hidden": "true",
|
|
342
|
+
focusable: "false"
|
|
343
|
+
}, G = { class: "tes-password__visually-hidden" }, _e = {
|
|
344
|
+
role: "status",
|
|
345
|
+
class: "tes-password__visually-hidden"
|
|
346
|
+
}, K = o(/* @__PURE__ */ a({
|
|
347
|
+
inheritAttrs: !1,
|
|
348
|
+
__name: "TesPassword",
|
|
349
|
+
props: /*@__PURE__*/ s({
|
|
350
|
+
label: {},
|
|
351
|
+
name: {},
|
|
352
|
+
hint: {},
|
|
353
|
+
required: { type: Boolean },
|
|
354
|
+
disabled: { type: Boolean },
|
|
355
|
+
readonly: { type: Boolean },
|
|
356
|
+
purpose: {},
|
|
357
|
+
minlength: {},
|
|
358
|
+
maxlength: {},
|
|
359
|
+
requirements: {},
|
|
360
|
+
autocomplete: {},
|
|
361
|
+
textShow: {},
|
|
362
|
+
textHide: {},
|
|
363
|
+
textShowLabel: {},
|
|
364
|
+
textHideLabel: {},
|
|
365
|
+
textShown: {},
|
|
366
|
+
textHidden: {},
|
|
367
|
+
textRequirements: {},
|
|
368
|
+
textRuleLength: {},
|
|
369
|
+
textRuleLowercase: {},
|
|
370
|
+
textRuleUppercase: {},
|
|
371
|
+
textRuleDigit: {},
|
|
372
|
+
textRuleSymbol: {},
|
|
373
|
+
textRuleMet: {},
|
|
374
|
+
textRuleUnmet: {},
|
|
375
|
+
textAllMet: {},
|
|
376
|
+
textCapsLock: {},
|
|
377
|
+
textRequired: {},
|
|
378
|
+
textUnmet: {},
|
|
379
|
+
textTooLong: {}
|
|
380
|
+
}, W),
|
|
381
|
+
setup(a) {
|
|
382
|
+
let o = a, s = _(), l = ee(), u = te("input"), f = U("tes-password"), p = `${f}-requirements`, y = `${f}-caps-lock`, x = `${f}-hint`, S = `${f}-error`, w = t(() => typeof s.value == "string" ? s.value : void 0), { announcement: T, announceNow: E, announceOnceTypingPauses: D } = C(), { ruleOptions: O, autocomplete: k, rulesForPasswordManagers: A } = ie(o), { revealed: j, inputType: M, toggleLabel: N, toggleByUser: P } = se({
|
|
383
|
+
host: l,
|
|
384
|
+
props: o,
|
|
385
|
+
input: u,
|
|
386
|
+
announceNow: E
|
|
387
|
+
}), { syncFromInput: F } = V({
|
|
388
|
+
host: l,
|
|
389
|
+
input: u
|
|
390
|
+
}), { requirementItems: I, reportUserChange: L } = oe({
|
|
391
|
+
host: l,
|
|
392
|
+
props: o,
|
|
393
|
+
ruleOptions: O,
|
|
394
|
+
announceOnceTypingPauses: D
|
|
395
|
+
}), { capsLockOn: R, readCapsLock: z, forgetCapsLock: B } = re({
|
|
396
|
+
props: o,
|
|
397
|
+
announceNow: E
|
|
398
|
+
}), { visibleError: H, markEdited: W, revealErrors: K, revealErrorsIfEdited: q } = ce({
|
|
399
|
+
host: l,
|
|
400
|
+
props: o,
|
|
401
|
+
input: u,
|
|
402
|
+
ruleOptions: O
|
|
403
|
+
}), J = t(() => {
|
|
404
|
+
let e = [
|
|
405
|
+
o.hint && x,
|
|
406
|
+
I.value.length > 0 && p,
|
|
407
|
+
R.value && y,
|
|
408
|
+
H.value && S
|
|
409
|
+
].filter(Boolean);
|
|
410
|
+
return e.length > 0 ? e.join(" ") : void 0;
|
|
411
|
+
}), { dispatchInput: Y, dispatchChange: X } = ae(l);
|
|
412
|
+
function Z() {
|
|
413
|
+
W(), F(), L(), Y();
|
|
414
|
+
}
|
|
415
|
+
v(() => o.disabled, (e) => {
|
|
416
|
+
e && (l.revealed = !1);
|
|
417
|
+
}), ne(l.internals, () => ({
|
|
418
|
+
invalid: H.value !== null,
|
|
419
|
+
empty: l.state.value === "",
|
|
420
|
+
revealed: j.value,
|
|
421
|
+
"requirements-met": I.value.length > 0 && I.value.every((e) => e.met),
|
|
422
|
+
"caps-lock": R.value
|
|
423
|
+
}));
|
|
424
|
+
function Q() {
|
|
425
|
+
B(), q();
|
|
426
|
+
}
|
|
427
|
+
return (t, o) => (d(), r("div", le, [
|
|
428
|
+
i("label", {
|
|
429
|
+
for: g(f),
|
|
430
|
+
class: "tes-password__label"
|
|
431
|
+
}, h(a.label), 9, ue),
|
|
432
|
+
i("div", { class: c(["tes-password__control", { "tes-password__control--invalid": g(H) }]) }, [i("input", {
|
|
433
|
+
id: g(f),
|
|
434
|
+
ref_key: "input",
|
|
435
|
+
ref: u,
|
|
436
|
+
class: "tes-password__input",
|
|
437
|
+
type: g(M),
|
|
438
|
+
name: a.name,
|
|
439
|
+
"^value": w.value,
|
|
440
|
+
autocomplete: g(k),
|
|
441
|
+
passwordrules: g(A),
|
|
442
|
+
"aria-describedby": J.value,
|
|
443
|
+
"aria-invalid": g(H) ? "true" : void 0,
|
|
444
|
+
required: a.required,
|
|
445
|
+
disabled: a.disabled,
|
|
446
|
+
readonly: a.readonly,
|
|
447
|
+
spellcheck: "false",
|
|
448
|
+
autocapitalize: "off",
|
|
449
|
+
autocorrect: "off",
|
|
450
|
+
onInput: b(Z, ["stop"]),
|
|
451
|
+
onChange: o[0] ||= b((...e) => g(X) && g(X)(...e), ["stop"]),
|
|
452
|
+
onKeydown: o[1] ||= (...e) => g(z) && g(z)(...e),
|
|
453
|
+
onKeyup: o[2] ||= (...e) => g(z) && g(z)(...e),
|
|
454
|
+
onPointerdown: o[3] ||= (...e) => g(z) && g(z)(...e),
|
|
455
|
+
onBlur: Q,
|
|
456
|
+
onInvalid: o[4] ||= (...e) => g(K) && g(K)(...e)
|
|
457
|
+
}, null, 40, de), i("button", {
|
|
458
|
+
type: "button",
|
|
459
|
+
class: "tes-password__toggle",
|
|
460
|
+
"aria-label": g(N),
|
|
461
|
+
onClick: o[5] ||= (...e) => g(P) && g(P)(...e)
|
|
462
|
+
}, [i("span", { class: c(["tes-password__toggle-text", { "tes-password__toggle-text--inactive": g(j) }]) }, h(a.textShow), 3), i("span", { class: c(["tes-password__toggle-text", { "tes-password__toggle-text--inactive": !g(j) }]) }, h(a.textHide), 3)], 8, fe)], 2),
|
|
463
|
+
a.hint ? (d(), r("p", {
|
|
464
|
+
key: 0,
|
|
465
|
+
id: x,
|
|
466
|
+
class: "tes-password__hint"
|
|
467
|
+
}, h(a.hint), 1)) : n("", !0),
|
|
468
|
+
g(R) ? (d(), r("p", {
|
|
469
|
+
key: 1,
|
|
470
|
+
id: y,
|
|
471
|
+
class: "tes-password__caps-lock"
|
|
472
|
+
}, h(a.textCapsLock), 1)) : n("", !0),
|
|
473
|
+
g(I).length ? (d(), r("div", {
|
|
474
|
+
key: 2,
|
|
475
|
+
id: p,
|
|
476
|
+
class: "tes-password__requirements"
|
|
477
|
+
}, [i("p", pe, h(a.textRequirements), 1), i("ul", me, [(d(!0), r(e, null, m(g(I), (e) => (d(), r("li", {
|
|
478
|
+
key: e.requirement,
|
|
479
|
+
class: c(["tes-password__requirement", { "tes-password__requirement--met": e.met }])
|
|
480
|
+
}, [
|
|
481
|
+
e.met ? (d(), r("svg", he, [...o[6] ||= [i("path", { d: "M3.5 8.5l3 3 6-7" }, null, -1)]])) : (d(), r("svg", ge, [...o[7] ||= [i("circle", {
|
|
482
|
+
cx: "8",
|
|
483
|
+
cy: "8",
|
|
484
|
+
r: "5"
|
|
485
|
+
}, null, -1)]])),
|
|
486
|
+
i("span", null, h(e.text), 1),
|
|
487
|
+
i("span", G, ", " + h(e.met ? a.textRuleMet : a.textRuleUnmet), 1)
|
|
488
|
+
], 2))), 128))])])) : n("", !0),
|
|
489
|
+
i("p", {
|
|
490
|
+
id: S,
|
|
491
|
+
class: "tes-password__error",
|
|
492
|
+
"aria-live": "polite"
|
|
493
|
+
}, h(g(H)?.message), 1),
|
|
494
|
+
i("div", _e, h(g(T)), 1)
|
|
495
|
+
]));
|
|
496
|
+
}
|
|
497
|
+
}), { shadowRoot: !1 }), q = class extends K {
|
|
498
|
+
state = f({
|
|
499
|
+
revealed: !1,
|
|
500
|
+
value: "",
|
|
501
|
+
edited: !1,
|
|
502
|
+
errorsVisible: !1,
|
|
503
|
+
customError: ""
|
|
504
|
+
});
|
|
505
|
+
internals;
|
|
506
|
+
pendingValue = null;
|
|
507
|
+
constructor(e) {
|
|
508
|
+
super(e), this.internals = this.attachInternals();
|
|
509
|
+
}
|
|
510
|
+
get revealed() {
|
|
511
|
+
return this.state.revealed;
|
|
512
|
+
}
|
|
513
|
+
set revealed(e) {
|
|
514
|
+
e !== this.state.revealed && (this.state.revealed = e, this.syncInputType(), this.dispatchEvent(new CustomEvent("revealchange", {
|
|
515
|
+
bubbles: !0,
|
|
516
|
+
composed: !0,
|
|
517
|
+
detail: { revealed: e }
|
|
518
|
+
})));
|
|
519
|
+
}
|
|
520
|
+
get value() {
|
|
521
|
+
return this.input?.value ?? this.pendingValue ?? this.defaultValue;
|
|
522
|
+
}
|
|
523
|
+
set value(e) {
|
|
524
|
+
let t = this.input;
|
|
525
|
+
t ? t.value = e : this.pendingValue = e, this.state.value = e;
|
|
526
|
+
}
|
|
527
|
+
get requirementsMet() {
|
|
528
|
+
if (E(this.getAttribute("purpose")) !== "new") return !0;
|
|
529
|
+
let e = N({
|
|
530
|
+
minlength: this.getAttribute("minlength"),
|
|
531
|
+
maxlength: this.getAttribute("maxlength"),
|
|
532
|
+
requirements: this.getAttribute("requirements")
|
|
533
|
+
});
|
|
534
|
+
return I(this.state.value, e);
|
|
535
|
+
}
|
|
536
|
+
get defaultValue() {
|
|
537
|
+
return this.getAttribute("value") ?? "";
|
|
538
|
+
}
|
|
539
|
+
set defaultValue(e) {
|
|
540
|
+
this.setAttribute("value", e);
|
|
541
|
+
}
|
|
542
|
+
get minLength() {
|
|
543
|
+
return N({ minlength: this.getAttribute("minlength") }).minLength;
|
|
544
|
+
}
|
|
545
|
+
set minLength(e) {
|
|
546
|
+
this.setAttribute("minlength", String(e));
|
|
547
|
+
}
|
|
548
|
+
get maxLength() {
|
|
549
|
+
return N({
|
|
550
|
+
minlength: 1,
|
|
551
|
+
maxlength: this.getAttribute("maxlength")
|
|
552
|
+
}).maxLength ?? -1;
|
|
553
|
+
}
|
|
554
|
+
set maxLength(e) {
|
|
555
|
+
this.setAttribute("maxlength", String(e));
|
|
556
|
+
}
|
|
557
|
+
get readOnly() {
|
|
558
|
+
return this.hasAttribute("readonly");
|
|
559
|
+
}
|
|
560
|
+
set readOnly(e) {
|
|
561
|
+
this.toggleAttribute("readonly", e);
|
|
562
|
+
}
|
|
563
|
+
get form() {
|
|
564
|
+
return this.input?.form ?? null;
|
|
565
|
+
}
|
|
566
|
+
get validity() {
|
|
567
|
+
return (this.input ?? document.createElement("input")).validity;
|
|
568
|
+
}
|
|
569
|
+
get validationMessage() {
|
|
570
|
+
return this.input?.validationMessage ?? "";
|
|
571
|
+
}
|
|
572
|
+
get willValidate() {
|
|
573
|
+
return this.input?.willValidate ?? !1;
|
|
574
|
+
}
|
|
575
|
+
setCustomValidity(e) {
|
|
576
|
+
this.state.customError = e, e && (this.state.errorsVisible = !0);
|
|
577
|
+
}
|
|
578
|
+
checkValidity() {
|
|
579
|
+
return this.input?.checkValidity() ?? !0;
|
|
580
|
+
}
|
|
581
|
+
reportValidity() {
|
|
582
|
+
return this.input?.reportValidity() ?? !0;
|
|
583
|
+
}
|
|
584
|
+
connectedCallback() {
|
|
585
|
+
super.connectedCallback(), this.applyPendingValue();
|
|
586
|
+
}
|
|
587
|
+
focus(e) {
|
|
588
|
+
this.input?.focus(e);
|
|
589
|
+
}
|
|
590
|
+
get input() {
|
|
591
|
+
return this.querySelector(".tes-password__input");
|
|
592
|
+
}
|
|
593
|
+
syncInputType() {
|
|
594
|
+
let e = this.input;
|
|
595
|
+
e && (e.type = this.state.revealed ? "text" : "password");
|
|
596
|
+
}
|
|
597
|
+
applyPendingValue() {
|
|
598
|
+
let e = this.input;
|
|
599
|
+
e && this.pendingValue !== null && (e.value = this.pendingValue, this.state.value = this.pendingValue, this.pendingValue = null);
|
|
600
|
+
}
|
|
601
|
+
}, J = ":where(tes-password){--_text:var(--tes-color-text,var(--lightningcss-light,#1f2328)var(--lightningcss-dark,#e8eaee));--_muted:var(--tes-color-muted,var(--lightningcss-light,#59636e)var(--lightningcss-dark,#a3adba));--_bg:var(--tes-color-bg,var(--lightningcss-light,#fff)var(--lightningcss-dark,#16181d));--_border:var(--tes-color-border,var(--lightningcss-light,#7d8590)var(--lightningcss-dark,#7f8a99));--_accent:var(--tes-color-accent,var(--lightningcss-light,#0b5fcc)var(--lightningcss-dark,#7aa7ff));--_on-accent:var(--tes-color-on-accent,var(--lightningcss-light,#fff)var(--lightningcss-dark,#0d1117));--_hover:var(--tes-color-hover,var(--lightningcss-light,#eef3fb)var(--lightningcss-dark,#232a36));--_focus:var(--tes-color-focus,var(--lightningcss-light,#0b5fcc)var(--lightningcss-dark,#7aa7ff));--_error:var(--tes-color-error,var(--lightningcss-light,#c4232b)var(--lightningcss-dark,#ff8a80));--_success:var(--tes-color-success,var(--lightningcss-light,#1f7a3a)var(--lightningcss-dark,#4cc26a));--_radius:var(--tes-radius,.375rem);--_space:var(--tes-space,.5rem);--_control-height:2.75rem;color:var(--_text);font-family:var(--tes-font-family);font-size:var(--tes-font-size);display:inline-block}:where(tes-password[hidden]){display:none}:where(.tes-password__field){gap:calc(var(--_space) / 2);grid-template-columns:minmax(0,1fr);display:grid}:where(.tes-password__label){font-weight:500}:where(.tes-password__control){box-sizing:border-box;block-size:var(--_control-height);border:1px solid var(--_border);border-radius:var(--_radius);background:var(--_bg);display:flex}:where(.tes-password__control--invalid){border:2px solid var(--_error)}:where(.tes-password__control:has(.tes-password__input:focus-visible)){outline:2px solid var(--_focus);outline-offset:2px}:where(.tes-password__input){box-sizing:border-box;border-radius:var(--_radius);min-inline-size:0;color:var(--_text);font:inherit;background:0 0;border:0;outline:none;flex:1;margin:0;padding-inline:.75rem;font-size:max(1em,16px)}:where(.tes-password__toggle){border-radius:var(--_radius);min-inline-size:2.75rem;color:var(--_accent);font:inherit;cursor:pointer;background:0 0;border:0;flex:none;place-items:center;margin:0;padding-inline:.75rem;font-weight:500;display:grid}:where(.tes-password__control:has(.tes-password__input:disabled)){background:color-mix(in srgb, var(--_muted) 12%, var(--_bg))}:where(.tes-password__input:disabled){color:var(--_muted);cursor:not-allowed}:where(.tes-password__input:disabled~.tes-password__toggle){display:none}:where(.tes-password__toggle-text){grid-area:1/1}:where(.tes-password__toggle-text--inactive){visibility:hidden}:where(.tes-password__toggle:hover){background:var(--_hover)}:where(.tes-password__toggle:focus-visible){outline:2px solid var(--_focus);outline-offset:-2px}:where(.tes-password__hint){color:var(--_muted);margin:0;padding-block-start:.25rem;font-size:.875em}:where(.tes-password__caps-lock){margin:0;padding-block-start:.25rem;font-size:.875em;font-weight:500}:where(.tes-password__requirements){color:var(--_muted);padding-block-start:.25rem;font-size:.875em}:where(.tes-password__requirements-title){margin:0}:where(.tes-password__requirements-list){gap:.125rem;margin:.25rem 0 0;padding:0;list-style:none;display:grid}:where(.tes-password__requirement){align-items:center;gap:.375rem;margin:0;display:flex}:where(.tes-password__requirement--met){color:var(--_text)}:where(.tes-password__icon){fill:none;stroke:currentColor;stroke-width:1.5px;stroke-linecap:round;stroke-linejoin:round;flex:none;block-size:1em;inline-size:1em}:where(.tes-password__icon--met){stroke:var(--_success);stroke-width:2px}:where(.tes-password__error){color:var(--_error);margin:0;font-size:.875em;font-weight:500}:where(.tes-password__error:empty){display:none}:where(.tes-password__visually-hidden){clip-path:inset(50%);white-space:nowrap;border:0;block-size:1px;inline-size:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}@media (forced-colors:active){:where(.tes-password__control:has(.tes-password__input:focus-visible)),:where(.tes-password__toggle:focus-visible){outline-color:highlight}:where(.tes-password__input:disabled){color:graytext}}", Y = ":where(tes-password";
|
|
602
|
+
function X(e) {
|
|
603
|
+
return J.replaceAll(Y, `:where(${e}`);
|
|
604
|
+
}
|
|
605
|
+
function Z(e) {
|
|
606
|
+
if (typeof document > "u" || typeof CSSStyleSheet > "u") return;
|
|
607
|
+
let t = new CSSStyleSheet();
|
|
608
|
+
t.replaceSync(X(e)), document.adoptedStyleSheets = [...document.adoptedStyleSheets, t];
|
|
609
|
+
}
|
|
610
|
+
//#endregion
|
|
611
|
+
//#region src/index.ts
|
|
612
|
+
var Q = "tes-password";
|
|
613
|
+
function $(e = Q) {
|
|
614
|
+
if (typeof customElements > "u" || customElements.get(e)) return;
|
|
615
|
+
let t = class extends q {};
|
|
616
|
+
customElements.define(e, e === "tes-password" ? q : t), Z(e);
|
|
617
|
+
}
|
|
618
|
+
$();
|
|
619
|
+
//#endregion
|
|
620
|
+
export { Q as TAG_NAME, q as TesPasswordElement, $ as define };
|
|
621
|
+
|
|
622
|
+
//# sourceMappingURL=tes-password.js.map
|