@quidgest/ui 0.17.9 → 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/json/api.json +169 -17
- package/dist/manifest/components.json +2 -0
- package/dist/ui.css +231 -25
- package/dist/ui.esm.js +573 -608
- package/dist/ui.js +457 -493
- package/dist/ui.min.css +1 -1
- package/dist/ui.min.js +457 -493
- package/dist/ui.scss +225 -27
- package/esm/components/QAccordion/QAccordionItem.vue.js +1 -0
- package/esm/components/QCarousel/QCarousel.vue.js +1 -1
- package/esm/components/QCheckbox/QCheckbox.d.ts.map +1 -1
- package/esm/components/QCheckbox/QCheckbox.vue.js +2 -0
- package/esm/components/QCollapsible/QCollapsible.d.ts +2 -1
- package/esm/components/QCollapsible/QCollapsible.d.ts.map +1 -1
- package/esm/components/QCollapsible/QCollapsible.vue.js +50 -47
- package/esm/components/QCollapsible/constants.d.ts +6 -0
- package/esm/components/QCollapsible/constants.d.ts.map +1 -1
- package/esm/components/QCollapsible/constants.js +3 -2
- package/esm/components/QCollapsible/index.d.ts +6 -0
- package/esm/components/QCollapsible/index.d.ts.map +1 -1
- package/esm/components/QCollapsible/types.d.ts +11 -1
- package/esm/components/QCollapsible/types.d.ts.map +1 -1
- package/esm/components/QDateTimePicker/QDateTimePicker.d.ts.map +1 -1
- package/esm/components/QDateTimePicker/QDateTimePicker.vue.js +505 -597
- package/esm/components/QDropdownMenu/QDropdownMenuContent.d.ts +32 -16
- package/esm/components/QDropdownMenu/QDropdownMenuContent.d.ts.map +1 -1
- package/esm/components/QDropdownMenu/QDropdownMenuContent.vue.js +179 -86
- package/esm/components/QDropdownMenu/types.d.ts +6 -0
- package/esm/components/QDropdownMenu/types.d.ts.map +1 -1
- package/esm/components/QField/types.d.ts +3 -0
- package/esm/components/QField/types.d.ts.map +1 -1
- package/esm/components/QLabel/QLabel.d.ts.map +1 -1
- package/esm/components/QLabel/QLabel.vue.js +19 -17
- package/esm/components/QLabel/types.d.ts +3 -0
- package/esm/components/QLabel/types.d.ts.map +1 -1
- package/esm/components/QTabs/QTab.d.ts +172 -0
- package/esm/components/QTabs/QTab.d.ts.map +1 -0
- package/esm/components/QTabs/QTab.vue.js +122 -0
- package/esm/components/QTabs/QTab2.vue.js +5 -0
- package/esm/components/QTabs/QTabs.d.ts +35 -0
- package/esm/components/QTabs/QTabs.d.ts.map +1 -0
- package/esm/components/QTabs/QTabs.vue.js +83 -0
- package/esm/components/QTabs/QTabs2.vue.js +5 -0
- package/esm/components/QTabs/constants.d.ts +5 -0
- package/esm/components/QTabs/constants.d.ts.map +1 -0
- package/esm/components/QTabs/context.d.ts +78 -0
- package/esm/components/QTabs/context.d.ts.map +1 -0
- package/esm/components/QTabs/context.js +4 -0
- package/esm/components/QTabs/index.d.ts +164 -0
- package/esm/components/QTabs/index.d.ts.map +1 -0
- package/esm/components/QTabs/index.js +7 -0
- package/esm/components/QTabs/types.d.ts +106 -0
- package/esm/components/QTabs/types.d.ts.map +1 -0
- package/esm/components/__internal__/QRequiredIndicator/QRequiredIndicator.d.ts +7 -0
- package/esm/components/__internal__/QRequiredIndicator/QRequiredIndicator.d.ts.map +1 -0
- package/esm/components/__internal__/QRequiredIndicator/QRequiredIndicator.vue.js +24 -0
- package/esm/components/__internal__/QRequiredIndicator/QRequiredIndicator2.vue.js +5 -0
- package/esm/components/__internal__/QRequiredIndicator/constants.d.ts +7 -0
- package/esm/components/__internal__/QRequiredIndicator/constants.d.ts.map +1 -0
- package/esm/components/__internal__/QRequiredIndicator/constants.js +4 -0
- package/esm/components/__internal__/QRequiredIndicator/index.d.ts +6 -0
- package/esm/components/__internal__/QRequiredIndicator/index.d.ts.map +1 -0
- package/esm/components/__internal__/QRequiredIndicator/index.js +6 -0
- package/esm/components/__internal__/QRequiredIndicator/types.d.ts +18 -0
- package/esm/components/__internal__/QRequiredIndicator/types.d.ts.map +1 -0
- package/esm/components/__internal__/QSafeTriangle/QSafeTriangle.d.ts +10 -0
- package/esm/components/__internal__/QSafeTriangle/QSafeTriangle.d.ts.map +1 -0
- package/esm/components/__internal__/QSafeTriangle/QSafeTriangle.vue.js +31 -0
- package/esm/components/__internal__/QSafeTriangle/QSafeTriangle2.vue.js +5 -0
- package/esm/components/__internal__/QSafeTriangle/index.d.ts +10 -0
- package/esm/components/__internal__/QSafeTriangle/index.d.ts.map +1 -0
- package/esm/components/__internal__/QSafeTriangle/index.js +6 -0
- package/esm/components/__internal__/QSafeTriangle/types.d.ts +33 -0
- package/esm/components/__internal__/QSafeTriangle/types.d.ts.map +1 -0
- package/esm/components/index.d.ts +1 -0
- package/esm/components/index.d.ts.map +1 -1
- package/esm/components/index.js +17 -14
- package/esm/composables/useSafeTriangle/index.d.ts +31 -0
- package/esm/composables/useSafeTriangle/index.d.ts.map +1 -0
- package/esm/composables/useSafeTriangle/index.js +87 -0
- package/esm/index.d.ts +2 -0
- package/esm/utils/date.d.ts +36 -1
- package/esm/utils/date.d.ts.map +1 -1
- package/esm/utils/date.js +90 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +30 -24
- package/esm/utils/mask.d.ts +17 -0
- package/esm/utils/mask.d.ts.map +1 -0
- package/esm/utils/mask.js +154 -0
- package/esm/utils/safeTriangle.d.ts +68 -0
- package/esm/utils/safeTriangle.d.ts.map +1 -0
- package/esm/utils/safeTriangle.js +83 -0
- package/package.json +6 -6
- package/esm/composables/useInputMask/index.d.ts +0 -50
- package/esm/composables/useInputMask/index.d.ts.map +0 -1
- package/esm/composables/useInputMask/index.js +0 -408
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//#region src/utils/safeTriangle.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
return e >= n.left && e <= n.right && t >= n.top && t <= n.bottom;
|
|
4
|
+
}
|
|
5
|
+
function t(e, t, n, r, i) {
|
|
6
|
+
let a = (e, t, n, r, i, a) => (e - i) * (r - a) - (n - i) * (t - a), o = a(e, t, n.x, n.y, r.x, r.y), s = a(e, t, r.x, r.y, i.x, i.y), c = a(e, t, i.x, i.y, n.x, n.y);
|
|
7
|
+
return !((o < 0 || s < 0 || c < 0) && (o > 0 || s > 0 || c > 0));
|
|
8
|
+
}
|
|
9
|
+
function n(e, t, n) {
|
|
10
|
+
if (!t || !n) return e;
|
|
11
|
+
let r = (t.left + t.right) / 2, i = (n.left + n.right) / 2 >= r ? "right" : "left", a = e.split("-")[1];
|
|
12
|
+
return a ? `${i}-${a}` : i;
|
|
13
|
+
}
|
|
14
|
+
function r(e, t, n, r) {
|
|
15
|
+
switch (e.split("-")[0]) {
|
|
16
|
+
case "right": return {
|
|
17
|
+
a: {
|
|
18
|
+
x: t.left,
|
|
19
|
+
y: t.top
|
|
20
|
+
},
|
|
21
|
+
b: {
|
|
22
|
+
x: t.left,
|
|
23
|
+
y: t.bottom
|
|
24
|
+
},
|
|
25
|
+
c: {
|
|
26
|
+
x: n,
|
|
27
|
+
y: r
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
case "left": return {
|
|
31
|
+
a: {
|
|
32
|
+
x: t.right,
|
|
33
|
+
y: t.top
|
|
34
|
+
},
|
|
35
|
+
b: {
|
|
36
|
+
x: t.right,
|
|
37
|
+
y: t.bottom
|
|
38
|
+
},
|
|
39
|
+
c: {
|
|
40
|
+
x: n,
|
|
41
|
+
y: r
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
default: return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function i(e, t, n, r) {
|
|
48
|
+
let i = e.split("-")[0];
|
|
49
|
+
if (i === "right") {
|
|
50
|
+
if (n >= t.left) return null;
|
|
51
|
+
let e = n, i = t.top, a = t.left - n, o = t.height;
|
|
52
|
+
return a <= 0 || o <= 0 ? null : {
|
|
53
|
+
left: e,
|
|
54
|
+
top: i,
|
|
55
|
+
width: a,
|
|
56
|
+
height: o,
|
|
57
|
+
path: `M 0, ${r - i} L ${a}, ${o} L ${a}, 0 z`
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (i === "left") {
|
|
61
|
+
if (n <= t.right) return null;
|
|
62
|
+
let e = t.right, i = t.top, a = n - t.right, o = t.height;
|
|
63
|
+
return a <= 0 || o <= 0 ? null : {
|
|
64
|
+
left: e,
|
|
65
|
+
top: i,
|
|
66
|
+
width: a,
|
|
67
|
+
height: o,
|
|
68
|
+
path: `M ${a}, ${r - i} L 0, ${o} L 0, 0 z`
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
function a(t, n, r) {
|
|
74
|
+
return r ? Array.from(r.querySelectorAll(".q-dropdown-menu__body")).some((r) => e(t, n, r.getBoundingClientRect())) : !1;
|
|
75
|
+
}
|
|
76
|
+
function o(n, i, o, s, c, l, u) {
|
|
77
|
+
if (o && e(n, i, o) || s && e(n, i, s) || u && a(n, i, u)) return !0;
|
|
78
|
+
if (!s || !l) return !1;
|
|
79
|
+
let d = r(c, s, l.x, l.y);
|
|
80
|
+
return d ? t(n, i, d.a, d.b, d.c) : !1;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { i as getSafeTriangleGeometry, r as getSafeTriangleVertices, e as isPointInRect, t as isPointInTriangle, a as isPointerInsideMenuTree, o as isPointerMovingTowardSubmenu, n as resolveSafeTrianglePlacement };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quidgest/ui",
|
|
3
3
|
"description": "Quidgest's UI framework",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.18.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Quidgest",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@fortawesome/fontawesome-free": "^6.7.2",
|
|
48
|
-
"@storybook/addon-docs": "^10.5.
|
|
49
|
-
"@storybook/addon-links": "^10.5.
|
|
50
|
-
"@storybook/vue3": "^10.5.
|
|
51
|
-
"@storybook/vue3-vite": "^10.5.
|
|
48
|
+
"@storybook/addon-docs": "^10.5.6",
|
|
49
|
+
"@storybook/addon-links": "^10.5.6",
|
|
50
|
+
"@storybook/vue3": "^10.5.6",
|
|
51
|
+
"@storybook/vue3-vite": "^10.5.6",
|
|
52
52
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
53
53
|
"@vue/test-utils": "^2.4.6",
|
|
54
54
|
"acorn": "^8.15.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"autoprefixer": "^10.4.20",
|
|
57
57
|
"cssnano": "^7.0.6",
|
|
58
58
|
"postcss": "^8.5.1",
|
|
59
|
-
"storybook": "^10.5.
|
|
59
|
+
"storybook": "^10.5.6",
|
|
60
60
|
"terser": "^5.44.0",
|
|
61
61
|
"vite": "^8.1.0",
|
|
62
62
|
"vite-plugin-dts": "^4.5.0",
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
type MaskPatternSource = string | (() => string);
|
|
2
|
-
/**
|
|
3
|
-
* Composable for handling input masking on text inputs.
|
|
4
|
-
* Attaches `input` and `keydown` handlers to enforce a mask pattern.
|
|
5
|
-
* @param getInputEl Getter for the input element reference to bind events to.
|
|
6
|
-
* @param maskPattern Mask grammar string or getter from `convertDatePatternToMask`.
|
|
7
|
-
*/
|
|
8
|
-
export declare function useInputMask(getInputEl: () => HTMLInputElement | null | undefined, maskPattern: MaskPatternSource): void;
|
|
9
|
-
/**
|
|
10
|
-
* Applies a mask pattern to an input value.
|
|
11
|
-
* The mask supports:
|
|
12
|
-
* - `#` / `n`: single numeric digit
|
|
13
|
-
* - `A`: single alphabetic character, normalized to uppercase
|
|
14
|
-
* - `a`: single alphabetic character, normalized to lowercase
|
|
15
|
-
* - `p`: meridiem token (`AM` or `PM` only)
|
|
16
|
-
* - `W`: variable-width alphabetic segment
|
|
17
|
-
* - any other character: fixed separator/literal
|
|
18
|
-
* @param value Raw user input.
|
|
19
|
-
* @param maskPattern Mask to apply.
|
|
20
|
-
* @returns Masked value normalized to the provided pattern.
|
|
21
|
-
* @example
|
|
22
|
-
* applyMask('1234567', '##/##/####') => '12/34/567'
|
|
23
|
-
*/
|
|
24
|
-
export declare function applyMask(value: string, maskPattern: string): string;
|
|
25
|
-
/**
|
|
26
|
-
* Maps a cursor index from a source string to the equivalent position in a masked value.
|
|
27
|
-
* Counts alphanumeric content so auto-inserted separators do not desync the caret.
|
|
28
|
-
* @param sourceValue Value before masking or normalization.
|
|
29
|
-
* @param targetValue Value after masking or normalization.
|
|
30
|
-
* @param sourceCursor Cursor index in the source value.
|
|
31
|
-
* @returns Cursor index in the target value.
|
|
32
|
-
*/
|
|
33
|
-
export declare function resolveCursorPosition(sourceValue: string, targetValue: string, sourceCursor: number): number;
|
|
34
|
-
/**
|
|
35
|
-
* Clamps fully-typed numeric segments to valid ranges for the provided format.
|
|
36
|
-
* @param value Masked user input.
|
|
37
|
-
* @param format Date/time format pattern.
|
|
38
|
-
* @returns Input with out-of-range numeric segments normalized.
|
|
39
|
-
*/
|
|
40
|
-
export declare function clampNumericSegments(value: string, format: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Replaces the next editable character after `cursor` instead of inserting.
|
|
43
|
-
* Keeps the masked value length unchanged when editing in the middle of existing text.
|
|
44
|
-
*/
|
|
45
|
-
export declare function overwriteMaskedChar(value: string, cursor: number, char: string, visualMask: string[], maskPattern: string): {
|
|
46
|
-
value: string;
|
|
47
|
-
cursor: number;
|
|
48
|
-
} | null;
|
|
49
|
-
export {};
|
|
50
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composables/useInputMask/index.ts"],"names":[],"mappings":"AAEA,KAAK,iBAAiB,GAAG,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAA;AAMhD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC3B,UAAU,EAAE,MAAM,gBAAgB,GAAG,IAAI,GAAG,SAAS,EACrD,WAAW,EAAE,iBAAiB,QAwI9B;AAgBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CA6FpE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GAClB,MAAM,CAgBR;AAyBD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAoE1E;AA2JD;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAAE,EACpB,WAAW,EAAE,MAAM,GACjB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA+B1C"}
|
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
import { watch as e } from "vue";
|
|
2
|
-
//#region src/composables/useInputMask/index.ts
|
|
3
|
-
function t(e) {
|
|
4
|
-
return typeof e == "function" ? e() : e;
|
|
5
|
-
}
|
|
6
|
-
function n(n, o) {
|
|
7
|
-
e(n, (e, n, s) => {
|
|
8
|
-
let c = r(e);
|
|
9
|
-
if (!c) return;
|
|
10
|
-
let l = (e) => {
|
|
11
|
-
let n = e.target;
|
|
12
|
-
if (n.readOnly || n.disabled) return;
|
|
13
|
-
let r = t(o), s = n.value, c = n.selectionStart ?? s.length, l = i(s, r);
|
|
14
|
-
if (s !== l) {
|
|
15
|
-
let e = a(s, l, c);
|
|
16
|
-
n.value = l, n.setSelectionRange(e, e), n.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
17
|
-
}
|
|
18
|
-
}, u = (e) => {
|
|
19
|
-
let n = e.target;
|
|
20
|
-
if (n.readOnly || n.disabled) return;
|
|
21
|
-
let r = t(o), a = f(r);
|
|
22
|
-
if (e.ctrlKey || e.metaKey || e.altKey || [
|
|
23
|
-
"ArrowLeft",
|
|
24
|
-
"ArrowRight",
|
|
25
|
-
"Delete",
|
|
26
|
-
"Tab",
|
|
27
|
-
"Enter"
|
|
28
|
-
].includes(e.key)) return;
|
|
29
|
-
if (e.key === "Backspace") {
|
|
30
|
-
g(e, n, a, r);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (!e.key || e.key.length !== 1) return;
|
|
34
|
-
let s = n.selectionStart ?? 0, c = n.selectionEnd ?? 0;
|
|
35
|
-
if (r.includes("W")) return;
|
|
36
|
-
if (s === c && s < n.value.length) {
|
|
37
|
-
let t = h(n.value, s, e.key, a, r);
|
|
38
|
-
if (t) {
|
|
39
|
-
e.preventDefault(), n.value = t.value, n.setSelectionRange(t.cursor, t.cursor), n.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
let l = p(a, s);
|
|
44
|
-
if (l === void 0) {
|
|
45
|
-
if (w(e.key, r, s, n.value, s)) return;
|
|
46
|
-
e.preventDefault();
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (l === "p") {
|
|
50
|
-
let t = b(n.value, r, s), a = e.key.toUpperCase();
|
|
51
|
-
if (t === "AM" || t === "PM") {
|
|
52
|
-
e.preventDefault();
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (!t && (a === "A" || a === "P")) {
|
|
56
|
-
e.preventDefault();
|
|
57
|
-
let t = y(n.value, r), o = i(`${t >= 0 ? n.value.slice(0, t) : n.value}${a}M`, r);
|
|
58
|
-
n.value = o, n.setSelectionRange(o.length, o.length), n.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
x(e.key, t) || e.preventDefault();
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
!S(e.key, l) && !w(e.key, r, s, n.value, s) && e.preventDefault();
|
|
65
|
-
};
|
|
66
|
-
c.addEventListener("input", l), c.addEventListener("keydown", u), s(() => {
|
|
67
|
-
c.removeEventListener("input", l), c.removeEventListener("keydown", u);
|
|
68
|
-
});
|
|
69
|
-
}, { flush: "post" });
|
|
70
|
-
}
|
|
71
|
-
function r(e) {
|
|
72
|
-
return e instanceof HTMLInputElement ? e : typeof e == "object" && e && "value" in e && e.value instanceof HTMLInputElement ? e.value : null;
|
|
73
|
-
}
|
|
74
|
-
function i(e, t) {
|
|
75
|
-
let n = "", r = 0, i = 0;
|
|
76
|
-
for (; i < t.length && r < e.length;) {
|
|
77
|
-
let a = t[i], o = e[r];
|
|
78
|
-
if (a === "!") {
|
|
79
|
-
let e = t[i + 1];
|
|
80
|
-
if (!e) break;
|
|
81
|
-
o === e ? (n += e, r++) : n += e, i += 2;
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (a === "#" || a === "n") if (/\d/.test(o)) n += o, r++;
|
|
85
|
-
else {
|
|
86
|
-
r++;
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
else if (a === "A" || a === "a") if (T(o)) n += a === "A" ? o.toUpperCase() : o.toLowerCase(), r++;
|
|
90
|
-
else {
|
|
91
|
-
r++;
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
else if (a === "p") {
|
|
95
|
-
let t = _(e, r);
|
|
96
|
-
if (t.consumed === 0) break;
|
|
97
|
-
r += t.consumed, t.text && (n += t.text), i++;
|
|
98
|
-
continue;
|
|
99
|
-
} else if (a === "W") {
|
|
100
|
-
let a = t[i + 1], o = !1;
|
|
101
|
-
for (; r < e.length;) {
|
|
102
|
-
let t = e[r];
|
|
103
|
-
if (a && t === a && o) break;
|
|
104
|
-
if (T(t)) {
|
|
105
|
-
n += t, r++, o = !0;
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
if (a && t === a) break;
|
|
109
|
-
r++;
|
|
110
|
-
}
|
|
111
|
-
} else if (o === a) n += a, r++;
|
|
112
|
-
else if (/\d/.test(o)) n += a;
|
|
113
|
-
else if (w(o, t, i + 1, e, r)) {
|
|
114
|
-
n += a, i++;
|
|
115
|
-
continue;
|
|
116
|
-
} else r++;
|
|
117
|
-
i++;
|
|
118
|
-
}
|
|
119
|
-
return n;
|
|
120
|
-
}
|
|
121
|
-
function a(e, t, n) {
|
|
122
|
-
let r = (e.slice(0, n).match(/[\da-z]/gi) ?? []).length;
|
|
123
|
-
if (r === 0) return 0;
|
|
124
|
-
let i = 0;
|
|
125
|
-
for (let e = 0; e < t.length; e++) if (/[\da-z]/i.test(t[e] ?? "") && (i++, i === r)) return e + 1;
|
|
126
|
-
return t.length;
|
|
127
|
-
}
|
|
128
|
-
function o(e, t, n) {
|
|
129
|
-
if (n.startsWith("'")) {
|
|
130
|
-
let r = n.slice(1, -1).replace(/''/g, "'");
|
|
131
|
-
return e.slice(t).startsWith(r) ? t + r.length : null;
|
|
132
|
-
}
|
|
133
|
-
if (n === "a") {
|
|
134
|
-
let n = e.slice(t), r = n.match(/^\s*(AM|PM)/i);
|
|
135
|
-
return r ? t + r[0].length : n.startsWith(" ") ? t + 1 : null;
|
|
136
|
-
}
|
|
137
|
-
return t >= e.length || e[t] !== n ? null : t + 1;
|
|
138
|
-
}
|
|
139
|
-
function s(e, t) {
|
|
140
|
-
let n = t.match(/yyyy|yy|MMMM|MMM|MM|M|dd|d|EEEE|EEE|HH|H|hh|h|mm|m|ss|s|SSS|S|a|'(?:''|[^'])*'|./g) ?? [], r = e, i = 0;
|
|
141
|
-
for (let e of n) {
|
|
142
|
-
if (e.startsWith("'")) {
|
|
143
|
-
let t = o(r, i, e);
|
|
144
|
-
if (t === null) break;
|
|
145
|
-
i = t;
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
let t = e === "yyyy" ? 4 : e === "yy" ? 2 : e === "SSS" ? 3 : e === "S" ? 1 : [
|
|
149
|
-
"MM",
|
|
150
|
-
"dd",
|
|
151
|
-
"HH",
|
|
152
|
-
"hh",
|
|
153
|
-
"mm",
|
|
154
|
-
"ss",
|
|
155
|
-
"M",
|
|
156
|
-
"d",
|
|
157
|
-
"H",
|
|
158
|
-
"h",
|
|
159
|
-
"m",
|
|
160
|
-
"s"
|
|
161
|
-
].includes(e) ? 2 : 0;
|
|
162
|
-
if (t === 0) {
|
|
163
|
-
let t = o(r, i, e);
|
|
164
|
-
if (t === null) break;
|
|
165
|
-
i = t;
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
let n = r.slice(i).match(/^\d+/)?.[0]?.slice(0, t) ?? "";
|
|
169
|
-
if (!n) continue;
|
|
170
|
-
let a = i + n.length;
|
|
171
|
-
if (!(n.length === t || a < r.length && !/\d/.test(r[a]))) continue;
|
|
172
|
-
let s = Number.parseInt(n, 10);
|
|
173
|
-
if (Number.isNaN(s)) continue;
|
|
174
|
-
let c = l(e, n, s);
|
|
175
|
-
r = `${r.slice(0, i)}${c}${r.slice(a)}`, i += c.length;
|
|
176
|
-
}
|
|
177
|
-
return u(r, n);
|
|
178
|
-
}
|
|
179
|
-
function c(e, t = 2) {
|
|
180
|
-
return String(e).padStart(t, "0");
|
|
181
|
-
}
|
|
182
|
-
function l(e, t, n) {
|
|
183
|
-
let r = n;
|
|
184
|
-
return (e === "MM" || e === "M") && (r = Math.min(12, Math.max(1, n))), (e === "dd" || e === "d") && (r = Math.min(31, Math.max(1, n))), (e === "HH" || e === "H") && (r = Math.min(23, Math.max(0, n))), (e === "hh" || e === "h") && (r = Math.min(12, Math.max(1, n))), (e === "mm" || e === "m" || e === "ss" || e === "s") && (r = Math.min(59, Math.max(0, n))), t.length > 1 ? c(r, t.length) : r === 0 && (e === "hh" || e === "h" || e === "MM" || e === "M" || e === "dd" || e === "d") ? "1" : String(r);
|
|
185
|
-
}
|
|
186
|
-
function u(e, t) {
|
|
187
|
-
let n = null, r = null, i = -1, a = 0, s = null, l = 0;
|
|
188
|
-
for (let c of t) {
|
|
189
|
-
if (c.startsWith("'")) {
|
|
190
|
-
let t = o(e, l, c);
|
|
191
|
-
if (t === null) break;
|
|
192
|
-
l = t;
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
let t = c === "yyyy" ? 4 : c === "yy" || [
|
|
196
|
-
"MM",
|
|
197
|
-
"dd",
|
|
198
|
-
"M",
|
|
199
|
-
"d"
|
|
200
|
-
].includes(c) ? 2 : 0;
|
|
201
|
-
if (t === 0) {
|
|
202
|
-
let t = o(e, l, c);
|
|
203
|
-
if (t === null) break;
|
|
204
|
-
l = t;
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
let u = e.slice(l).match(/^\d+/)?.[0]?.slice(0, t) ?? "";
|
|
208
|
-
if (!u) continue;
|
|
209
|
-
let d = l + u.length;
|
|
210
|
-
if (!(u.length === t || d < e.length && !/\d/.test(e[d]))) continue;
|
|
211
|
-
let f = Number.parseInt(u, 10);
|
|
212
|
-
Number.isNaN(f) || ((c === "MM" || c === "M") && (n = Math.min(12, Math.max(1, f))), c === "yyyy" && (r = f), c === "yy" && (r = f < 50 ? 2e3 + f : 1900 + f), (c === "dd" || c === "d") && (i = l, a = u.length, s = Math.max(1, f)), l = d);
|
|
213
|
-
}
|
|
214
|
-
if (i < 0 || s === null) return e;
|
|
215
|
-
let u = d(n, r);
|
|
216
|
-
if (s <= u) return e;
|
|
217
|
-
let f = a > 1 ? c(u, a) : String(u);
|
|
218
|
-
return `${e.slice(0, i)}${f}${e.slice(i + a)}`;
|
|
219
|
-
}
|
|
220
|
-
function d(e, t) {
|
|
221
|
-
if (!e || [
|
|
222
|
-
1,
|
|
223
|
-
3,
|
|
224
|
-
5,
|
|
225
|
-
7,
|
|
226
|
-
8,
|
|
227
|
-
10,
|
|
228
|
-
12
|
|
229
|
-
].includes(e)) return 31;
|
|
230
|
-
if ([
|
|
231
|
-
4,
|
|
232
|
-
6,
|
|
233
|
-
9,
|
|
234
|
-
11
|
|
235
|
-
].includes(e)) return 30;
|
|
236
|
-
let n = t ?? (/* @__PURE__ */ new Date()).getFullYear();
|
|
237
|
-
return n % 4 == 0 && n % 100 != 0 || n % 400 == 0 ? 29 : 28;
|
|
238
|
-
}
|
|
239
|
-
function f(e) {
|
|
240
|
-
let t = [];
|
|
241
|
-
for (let n = 0; n < e.length; n++) {
|
|
242
|
-
if (e[n] === "!") {
|
|
243
|
-
n + 1 < e.length && (t.push(e[n + 1]), n++);
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
t.push(e[n]);
|
|
247
|
-
}
|
|
248
|
-
return t;
|
|
249
|
-
}
|
|
250
|
-
function p(e, t) {
|
|
251
|
-
let n = m(e, t);
|
|
252
|
-
return n === void 0 ? void 0 : e[n];
|
|
253
|
-
}
|
|
254
|
-
function m(e, t) {
|
|
255
|
-
for (let n = t; n < e.length; n++) {
|
|
256
|
-
let t = e[n];
|
|
257
|
-
if (t === "#" || t === "n" || t === "A" || t === "a" || t === "W" || t === "p") return n;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
function h(e, t, n, r, a) {
|
|
261
|
-
let o = m(r, t);
|
|
262
|
-
if (o === void 0 || o >= e.length) return null;
|
|
263
|
-
let s = r[o];
|
|
264
|
-
if (!s) return null;
|
|
265
|
-
if (s === "p") {
|
|
266
|
-
if (!x(n, b(e, a, o))) return null;
|
|
267
|
-
} else if (!S(n, s)) return null;
|
|
268
|
-
let c = s === "A" ? n.toUpperCase() : s === "a" ? n.toLowerCase() : s === "p" ? n.toUpperCase() : n, l = i(`${e.slice(0, o)}${c}${e.slice(o + 1)}`, a);
|
|
269
|
-
return l.length === e.length ? {
|
|
270
|
-
value: l,
|
|
271
|
-
cursor: m(r, o + 1) ?? l.length
|
|
272
|
-
} : null;
|
|
273
|
-
}
|
|
274
|
-
function g(e, t, n, r) {
|
|
275
|
-
let a = t.selectionStart, o = t.selectionEnd;
|
|
276
|
-
if (a === null || o === null || a !== o || a <= 0) return;
|
|
277
|
-
let s = y(t.value, r);
|
|
278
|
-
if (s >= 0 && a > s) {
|
|
279
|
-
e.preventDefault();
|
|
280
|
-
let n = v(t.value, s), a = s;
|
|
281
|
-
a > 0 && t.value[a - 1] === " " && --a, t.value = i(`${t.value.slice(0, a)}${t.value.slice(n)}`, r), t.setSelectionRange(a, a), t.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
if (s >= 0 && a === s && a > 0 && t.value[a - 1] === " ") {
|
|
285
|
-
e.preventDefault(), t.value = i(`${t.value.slice(0, a - 1)}${t.value.slice(a)}`, r), t.setSelectionRange(a - 1, a - 1), t.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
let c = n[a - 1];
|
|
289
|
-
if (c === void 0 || !(c !== "#" && c !== "n" && c !== "A" && c !== "a" && c !== "W" && c !== "p")) return;
|
|
290
|
-
let l = a - 1;
|
|
291
|
-
for (; l > 0;) {
|
|
292
|
-
let e = n[l - 1];
|
|
293
|
-
if (e === "#" || e === "n" || e === "A" || e === "a" || e === "W") {
|
|
294
|
-
--l;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
--l;
|
|
298
|
-
}
|
|
299
|
-
e.preventDefault(), t.value = i(`${t.value.slice(0, l)}${t.value.slice(a)}`, r), t.setSelectionRange(l, l), t.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
300
|
-
}
|
|
301
|
-
function _(e, t) {
|
|
302
|
-
let n = t;
|
|
303
|
-
for (; n < e.length && e[n] === " ";) n += 1;
|
|
304
|
-
let r = "", i = n;
|
|
305
|
-
for (; i < e.length && /[A-Za-z]/.test(e[i] ?? "");) {
|
|
306
|
-
let t = (e[i] ?? "").toUpperCase();
|
|
307
|
-
if (r.length === 0) {
|
|
308
|
-
if (t === "A" || t === "P") {
|
|
309
|
-
r = `${t}M`, i += 1, i < e.length && (e[i] ?? "").toUpperCase() === "M" && (i += 1);
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
} else if (r.length === 1 && t === "M") {
|
|
313
|
-
r += "M", i += 1;
|
|
314
|
-
break;
|
|
315
|
-
}
|
|
316
|
-
i += 1;
|
|
317
|
-
}
|
|
318
|
-
for (; i < e.length && /[A-Za-z]/.test(e[i] ?? "");) i += 1;
|
|
319
|
-
return {
|
|
320
|
-
consumed: i - t,
|
|
321
|
-
text: r
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
function v(e, t) {
|
|
325
|
-
return t + _(e, t).consumed;
|
|
326
|
-
}
|
|
327
|
-
function y(e, t) {
|
|
328
|
-
let n = 0, r = 0;
|
|
329
|
-
for (; r < t.length;) {
|
|
330
|
-
let i = t[r];
|
|
331
|
-
if (i === "p") return n;
|
|
332
|
-
if (i === "!") {
|
|
333
|
-
let i = t[r + 1];
|
|
334
|
-
i && e[n] === i && (n += 1), r += 2;
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
if (i === "#" || i === "n") {
|
|
338
|
-
if (/\d/.test(e[n] ?? "")) {
|
|
339
|
-
n += 1, r += 1;
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
return -1;
|
|
343
|
-
}
|
|
344
|
-
if (i === "A" || i === "a") {
|
|
345
|
-
if (T(e[n] ?? "")) {
|
|
346
|
-
n += 1, r += 1;
|
|
347
|
-
continue;
|
|
348
|
-
}
|
|
349
|
-
return -1;
|
|
350
|
-
}
|
|
351
|
-
if (i === "W") {
|
|
352
|
-
let i = t[r + 1];
|
|
353
|
-
if (T(e[n] ?? "") && e[n] !== i) {
|
|
354
|
-
n += 1;
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
r += 1;
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
if (e[n] === i) {
|
|
361
|
-
n += 1, r += 1;
|
|
362
|
-
continue;
|
|
363
|
-
}
|
|
364
|
-
if (i === " " && t[r + 1] === "p") {
|
|
365
|
-
let i = e[n];
|
|
366
|
-
if ((i === void 0 || i === " " || /[A-Za-z]/.test(i)) && (r += 1, t[r] === "p")) return n;
|
|
367
|
-
}
|
|
368
|
-
return -1;
|
|
369
|
-
}
|
|
370
|
-
return -1;
|
|
371
|
-
}
|
|
372
|
-
function b(e, t, n) {
|
|
373
|
-
let r = y(e, t);
|
|
374
|
-
return r < 0 || n <= r ? "" : _(e.slice(0, n), r).text;
|
|
375
|
-
}
|
|
376
|
-
function x(e, t) {
|
|
377
|
-
let n = t.toUpperCase();
|
|
378
|
-
if (n === "AM" || n === "PM") return !1;
|
|
379
|
-
let r = e.toUpperCase();
|
|
380
|
-
return t ? n.length === 1 && (n === "A" || n === "P") ? r === "M" : !1 : r === "A" || r === "P";
|
|
381
|
-
}
|
|
382
|
-
function S(e, t) {
|
|
383
|
-
return t === "#" || t === "n" ? /\d/.test(e) : t === "p" ? x(e, "") : t === "A" || t === "a" || t === "W" ? T(e) : e === t;
|
|
384
|
-
}
|
|
385
|
-
function C(e, t) {
|
|
386
|
-
let n = t;
|
|
387
|
-
for (; n < e.length;) {
|
|
388
|
-
let t = e[n];
|
|
389
|
-
if (t === "!") {
|
|
390
|
-
n += 2;
|
|
391
|
-
continue;
|
|
392
|
-
}
|
|
393
|
-
if (t === "#" || t === "n" || t === "A" || t === "a" || t === "W" || t === "p") return n;
|
|
394
|
-
n += 1;
|
|
395
|
-
}
|
|
396
|
-
return -1;
|
|
397
|
-
}
|
|
398
|
-
function w(e, t, n, r, i) {
|
|
399
|
-
let a = C(t, n);
|
|
400
|
-
if (a < 0) return !1;
|
|
401
|
-
let o = t[a];
|
|
402
|
-
return !o || o === "!" ? !1 : o === "p" ? x(e, r !== void 0 && i !== void 0 ? b(r, t, i) : "") : S(e, o);
|
|
403
|
-
}
|
|
404
|
-
function T(e) {
|
|
405
|
-
return /[\p{L}\s.'-]/u.test(e);
|
|
406
|
-
}
|
|
407
|
-
//#endregion
|
|
408
|
-
export { i as applyMask, s as clampNumericSegments, h as overwriteMaskedChar, a as resolveCursorPosition, n as useInputMask };
|