bitboss-ui 2.1.14 → 2.1.15

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.
Files changed (176) hide show
  1. package/dist/index106.js +9 -9
  2. package/dist/index111.js +1 -1
  3. package/dist/index113.js +1 -1
  4. package/dist/index121.js +12 -12
  5. package/dist/index129.js +1 -1
  6. package/dist/index13.js +1 -1
  7. package/dist/index131.js +4 -4
  8. package/dist/index133.js +1 -1
  9. package/dist/index136.js +1 -1
  10. package/dist/index138.js +1 -1
  11. package/dist/index139.js +2 -2
  12. package/dist/index15.js +8 -8
  13. package/dist/index17.js +3 -3
  14. package/dist/index19.js +8 -8
  15. package/dist/index207.js +2 -2
  16. package/dist/index208.js +2 -2
  17. package/dist/index209.js +2 -86
  18. package/dist/index21.js +16 -16
  19. package/dist/{index213.js → index210.js} +4 -4
  20. package/dist/index211.js +13 -25
  21. package/dist/index212.js +106 -17
  22. package/dist/index214.js +100 -15
  23. package/dist/index216.js +72 -12
  24. package/dist/index218.js +13 -34
  25. package/dist/index219.js +2 -4
  26. package/dist/index220.js +2 -13
  27. package/dist/index221.js +2 -11
  28. package/dist/index222.js +2 -20
  29. package/dist/index223.js +3 -197
  30. package/dist/index224.js +9 -0
  31. package/dist/index225.js +7 -66
  32. package/dist/index226.js +7 -0
  33. package/dist/index227.js +5 -13
  34. package/dist/index228.js +5 -114
  35. package/dist/index229.js +7 -0
  36. package/dist/index23.js +15 -15
  37. package/dist/index230.js +5 -2
  38. package/dist/index231.js +5 -3
  39. package/dist/index232.js +5 -2
  40. package/dist/index233.js +8 -2
  41. package/dist/index234.js +250 -7
  42. package/dist/index235.js +52 -2
  43. package/dist/index236.js +44 -7
  44. package/dist/index237.js +5 -4
  45. package/dist/index238.js +60 -2
  46. package/dist/index239.js +12 -105
  47. package/dist/index240.js +6 -0
  48. package/dist/index241.js +11 -100
  49. package/dist/index242.js +22 -0
  50. package/dist/index243.js +197 -2
  51. package/dist/index245.js +114 -5
  52. package/dist/index247.js +10 -5
  53. package/dist/index248.js +3 -5
  54. package/dist/index249.js +4 -5
  55. package/dist/index25.js +3 -3
  56. package/dist/index250.js +86 -2
  57. package/dist/index252.js +29 -5
  58. package/dist/index253.js +16 -5
  59. package/dist/index254.js +15 -8
  60. package/dist/index255.js +12 -250
  61. package/dist/index256.js +12 -51
  62. package/dist/index257.js +3 -44
  63. package/dist/index258.js +4 -4
  64. package/dist/index259.js +2 -60
  65. package/dist/index260.js +33 -12
  66. package/dist/index261.js +16 -7
  67. package/dist/index262.js +12 -23
  68. package/dist/index263.js +6 -18
  69. package/dist/index264.js +231 -12
  70. package/dist/index265.js +183 -6
  71. package/dist/index266.js +2 -231
  72. package/dist/index267.js +9 -10
  73. package/dist/index268.js +8 -3
  74. package/dist/index269.js +9 -6
  75. package/dist/index27.js +1 -1
  76. package/dist/index270.js +23 -16
  77. package/dist/index271.js +6 -3
  78. package/dist/index272.js +16 -9
  79. package/dist/index273.js +3 -9
  80. package/dist/index274.js +9 -8
  81. package/dist/index275.js +67 -2
  82. package/dist/index276.js +2 -67
  83. package/dist/index277.js +5 -5
  84. package/dist/index278.js +4 -7
  85. package/dist/index279.js +8 -5
  86. package/dist/index280.js +1 -1
  87. package/dist/index281.js +3 -17
  88. package/dist/index282.js +3 -28
  89. package/dist/index284.js +7 -3
  90. package/dist/index285.js +17 -3
  91. package/dist/index286.js +6 -0
  92. package/dist/index287.js +28 -7
  93. package/dist/index288.js +1 -1
  94. package/dist/index289.js +3 -7
  95. package/dist/index29.js +4 -4
  96. package/dist/index290.js +7 -11
  97. package/dist/index291.js +10 -3
  98. package/dist/index292.js +4 -5
  99. package/dist/index293.js +280 -4
  100. package/dist/index294.js +2 -3
  101. package/dist/index295.js +16 -3
  102. package/dist/index296.js +2 -280
  103. package/dist/index297.js +16 -2
  104. package/dist/index298.js +2 -125
  105. package/dist/index299.js +19 -2
  106. package/dist/index300.js +2 -15
  107. package/dist/index301.js +15 -2
  108. package/dist/index302.js +2 -16
  109. package/dist/index303.js +19 -2
  110. package/dist/index304.js +2 -16
  111. package/dist/index305.js +27 -2
  112. package/dist/index306.js +2 -19
  113. package/dist/index307.js +2 -2
  114. package/dist/index308.js +2 -6
  115. package/dist/index309.js +2 -19
  116. package/dist/index31.js +2 -2
  117. package/dist/index310.js +2 -2
  118. package/dist/index311.js +22 -27
  119. package/dist/index313.js +6 -2
  120. package/dist/index314.js +3 -2
  121. package/dist/index315.js +5 -2
  122. package/dist/index316.js +1 -1
  123. package/dist/index317.js +125 -22
  124. package/dist/index318.js +4 -0
  125. package/dist/index319.js +1 -1
  126. package/dist/index320.js +1 -1
  127. package/dist/index324.js +1 -1
  128. package/dist/index325.js +7 -128
  129. package/dist/index326.js +5 -368
  130. package/dist/index327.js +7 -32
  131. package/dist/index328.js +128 -27
  132. package/dist/index329.js +371 -0
  133. package/dist/index33.js +8 -8
  134. package/dist/index330.js +6 -6
  135. package/dist/index331.js +6 -18
  136. package/dist/index332.js +18 -57
  137. package/dist/index333.js +33 -33
  138. package/dist/index334.js +58 -7
  139. package/dist/index335.js +1 -1
  140. package/dist/index336.js +32 -7
  141. package/dist/index337.js +28 -6
  142. package/dist/index340.js +1 -1
  143. package/dist/{index344.js → index342.js} +1 -1
  144. package/dist/index343.js +127 -3
  145. package/dist/index345.js +3 -127
  146. package/dist/index35.js +4 -4
  147. package/dist/index37.js +20 -20
  148. package/dist/index39.js +8 -8
  149. package/dist/index41.js +2 -2
  150. package/dist/index43.js +8 -8
  151. package/dist/index45.js +8 -8
  152. package/dist/index47.js +2 -2
  153. package/dist/index49.js +3 -3
  154. package/dist/index53.js +1 -1
  155. package/dist/index55.js +1 -1
  156. package/dist/index57.js +2 -2
  157. package/dist/index61.js +3 -3
  158. package/dist/index67.js +1 -1
  159. package/dist/index79.js +4 -4
  160. package/dist/index81.js +1 -1
  161. package/dist/index83.js +2 -2
  162. package/dist/index85.js +1 -1
  163. package/dist/index87.js +1 -1
  164. package/dist/index90.js +3 -3
  165. package/dist/index92.js +2 -2
  166. package/dist/index94.js +3 -3
  167. package/dist/index96.js +1 -1
  168. package/package.json +2 -2
  169. package/dist/index215.js +0 -5
  170. package/dist/index217.js +0 -18
  171. package/dist/index244.js +0 -7
  172. package/dist/index246.js +0 -7
  173. package/dist/index251.js +0 -185
  174. package/dist/index283.js +0 -4
  175. package/dist/index312.js +0 -4
  176. package/dist/index338.js +0 -10
package/dist/index260.js CHANGED
@@ -1,15 +1,36 @@
1
- const c = (t, r) => {
2
- if (typeof t == "string") {
3
- const e = /^(\d+)([a-zA-Z%]+)?$/, n = t.match(e);
4
- if (n) {
5
- const [, o, a] = n;
6
- return a ? t : o + "px";
7
- } else if (t in r)
8
- return r[t] + "px";
9
- throw new Error(`Invalid size: ${t}`);
1
+ import { defineComponent as p, getCurrentInstance as a, resolveComponent as u, createBlock as f, openBlock as k, resolveDynamicComponent as g, unref as d, withCtx as b, renderSlot as x } from "vue";
2
+ import { _config as e } from "./index4.js";
3
+ import { useLogger as l } from "./index233.js";
4
+ const $ = /* @__PURE__ */ p({
5
+ __name: "RouterComponent",
6
+ setup(y) {
7
+ var o, i, r, s;
8
+ const m = !!((i = (o = a()) == null ? void 0 : o.proxy) != null && i.$inertia), c = !!((s = (r = a()) == null ? void 0 : r.proxy) != null && s.$nuxt);
9
+ let t;
10
+ if (m) {
11
+ if (t = u(e.inertiaLinkName), typeof t == "string") {
12
+ const { warn: n } = l();
13
+ n(
14
+ `Inertia link component "${e.inertiaLinkName}" could not be resolved. Ensure you app registers a link component with the name "${e.inertiaLinkName}" or set bitboss-ui config key "inertiaLinkName" to the correct value globally. Please visit ${e.documentationURL}/getting-started to resolve setup issues in bitboss-ui.`
15
+ );
16
+ }
17
+ } else if (c) {
18
+ if (t = u(e.nuxtLinkName), typeof t == "string") {
19
+ const { warn: n } = l();
20
+ n(
21
+ `Nuxt link component "${e.nuxtLinkName}" could not be resolved. Ensure you app registers a link component with the name "${e.nuxtLinkName}" or set bitboss-ui config key "nuxtLinkName" to the correct value globally. Please visit ${e.documentationURL}/getting-started to resolve setup issues in bitboss-ui.`
22
+ );
23
+ }
24
+ } else
25
+ t = "router-link";
26
+ return (n, L) => (k(), f(g(d(t)), null, {
27
+ default: b(() => [
28
+ x(n.$slots, "default")
29
+ ]),
30
+ _: 3
31
+ }));
10
32
  }
11
- return t + "px";
12
- };
33
+ });
13
34
  export {
14
- c as parseSize
35
+ $ as default
15
36
  };
package/dist/index261.js CHANGED
@@ -1,11 +1,20 @@
1
- const o = (n, t) => {
2
- for (let e = n.length - 1; e >= 0; e--) {
3
- const i = n[e];
4
- if (t(i, e, n))
5
- return e;
1
+ import { isNil as c } from "./index222.js";
2
+ const a = (t, r) => {
3
+ if (!Object.prototype.hasOwnProperty.call(t, r))
4
+ throw new Error(
5
+ `Object ${JSON.stringify(t, null, 2)} has no property named "${r.toString()}"`
6
+ );
7
+ }, l = (t) => typeof t == "string" ? t.toLocaleLowerCase() : JSON.stringify(t).toLowerCase(), y = (t, r, s) => {
8
+ const i = s.toLocaleLowerCase();
9
+ for (let e = 0; e < r.length; e++) {
10
+ const n = r[e];
11
+ a(t, n);
12
+ const o = t[n];
13
+ if (c(o)) continue;
14
+ if (l(o).includes(i)) return !0;
6
15
  }
7
- return -1;
16
+ return !1;
8
17
  };
9
18
  export {
10
- o as findRightIndex
19
+ y as matchAnyKey
11
20
  };
package/dist/index262.js CHANGED
@@ -1,25 +1,14 @@
1
- const e = {
2
- inert: ":not([inert]):not([inert] *)",
3
- negTabIndex: ':not([tabindex^="-"])',
4
- disabled: ":not(:disabled)"
5
- }, n = [
6
- `a[href]${e.inert}${e.negTabIndex}`,
7
- `area[href]${e.inert}${e.negTabIndex}`,
8
- `input:not([type="hidden"]):not([type="radio"])${e.inert}${e.negTabIndex}${e.disabled}`,
9
- `input[type="radio"]${e.inert}${e.negTabIndex}${e.disabled}`,
10
- `select${e.inert}${e.negTabIndex}${e.disabled}`,
11
- `textarea${e.inert}${e.negTabIndex}${e.disabled}`,
12
- `button${e.inert}${e.negTabIndex}${e.disabled}`,
13
- `details${e.inert} > summary:first-of-type${e.negTabIndex}`,
14
- // Discard until Firefox supports `:has()`
15
- // See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
16
- // `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
17
- `iframe${e.inert}${e.negTabIndex}`,
18
- `audio[controls]${e.inert}${e.negTabIndex}`,
19
- `video[controls]${e.inert}${e.negTabIndex}`,
20
- `[contenteditable]${e.inert}${e.negTabIndex}`,
21
- `[tabindex]${e.inert}${e.negTabIndex}`
22
- ];
1
+ import { ref as t } from "vue";
2
+ const n = () => {
3
+ const e = t([]);
4
+ return { array: e, set: (...r) => {
5
+ e.value = r;
6
+ }, add: (...r) => {
7
+ e.value.push(...r);
8
+ }, remove: (r) => {
9
+ e.value = e.value.filter(r);
10
+ } };
11
+ };
23
12
  export {
24
- n as default
13
+ n as useArray
25
14
  };
package/dist/index263.js CHANGED
@@ -1,20 +1,8 @@
1
- import { isNil as c } from "./index230.js";
2
- const a = (t, r) => {
3
- if (!Object.prototype.hasOwnProperty.call(t, r))
4
- throw new Error(
5
- `Object ${JSON.stringify(t, null, 2)} has no property named "${r.toString()}"`
6
- );
7
- }, l = (t) => typeof t == "string" ? t.toLocaleLowerCase() : JSON.stringify(t).toLowerCase(), y = (t, r, s) => {
8
- const i = s.toLocaleLowerCase();
9
- for (let e = 0; e < r.length; e++) {
10
- const n = r[e];
11
- a(t, n);
12
- const o = t[n];
13
- if (c(o)) continue;
14
- if (l(o).includes(i)) return !0;
15
- }
16
- return !1;
17
- };
1
+ const o = (e, t = 50) => new Promise((r) => {
2
+ const n = setInterval(() => {
3
+ e() && (clearInterval(n), r());
4
+ }, t);
5
+ });
18
6
  export {
19
- y as matchAnyKey
7
+ o as waitFor
20
8
  };
package/dist/index264.js CHANGED
@@ -1,14 +1,233 @@
1
- import { ref as t } from "vue";
2
- const n = () => {
3
- const e = t([]);
4
- return { array: e, set: (...r) => {
5
- e.value = r;
6
- }, add: (...r) => {
7
- e.value.push(...r);
8
- }, remove: (r) => {
9
- e.value = e.value.filter(r);
10
- } };
11
- };
1
+ import { defineComponent as U, ref as f, computed as x, watch as D, createElementBlock as d, openBlock as p, withModifiers as X, normalizeStyle as h, normalizeClass as $, createElementVNode as c, renderSlot as m, createTextVNode as z, toDisplayString as g, unref as H, Fragment as Z, renderList as ee } from "vue";
2
+ import { isNil as b } from "./index222.js";
3
+ import { useVirtualizer as te } from "./index339.js";
4
+ import { isNotNil as oe } from "./index140.js";
5
+ import { hash as L } from "./index223.js";
6
+ import { useLocale as ne } from "./index239.js";
7
+ const le = { class: "bb-listbox__outer-container scrollbar-border" }, ie = {
8
+ key: 0,
9
+ class: "bb-listbox__loading"
10
+ }, se = {
11
+ key: 1,
12
+ class: "bb-listbox__no-data"
13
+ }, ae = ["aria-selected", "data-index"], ue = { class: "autocomplete-option__content" }, re = { class: "autocomplete-option__label" }, xe = /* @__PURE__ */ U({
14
+ __name: "ListBox",
15
+ props: {
16
+ compact: { type: Boolean },
17
+ options: {},
18
+ open: { type: Boolean },
19
+ loading: { type: Boolean },
20
+ multiple: { type: Boolean },
21
+ transitionDuration: { default: 250 },
22
+ loadingText: {},
23
+ noDataText: {}
24
+ },
25
+ emits: ["option:selected", "option:unselected"],
26
+ setup(N, { expose: V, emit: O }) {
27
+ const o = N, _ = O, { t: y } = ne(), s = f(null), C = (e) => "option_" + JSON.stringify(e).replace(/\W/g, "_"), i = x(
28
+ () => o.options.map((e) => ({ ...e, id: C(e.value) }))
29
+ ), v = te({
30
+ get count() {
31
+ return o.options.length;
32
+ },
33
+ getScrollElement: () => s.value ? s.value : null,
34
+ estimateSize: () => o.compact ? 33 : 41,
35
+ overscan: 5,
36
+ measureElement: () => o.compact ? 33 : 41,
37
+ useAnimationFrameWithResizeObserver: !0
38
+ }), F = (e) => {
39
+ e && v.value.measureElement(e);
40
+ }, M = x(() => v.value.getVirtualItems()), A = x(() => v.value.getTotalSize()), n = f(null), a = x(
41
+ () => o.open && o.options.some((e) => !e.disabled)
42
+ ), I = (e = 1) => {
43
+ const l = b(n.value) ? -1 : n.value;
44
+ let t = (l + e) % o.options.length;
45
+ for (; o.options[t].disabled && t !== l; )
46
+ t = I(e + 1);
47
+ return t;
48
+ }, R = () => {
49
+ if (!a.value) return;
50
+ const e = I();
51
+ n.value = e, u();
52
+ }, S = (e = 1) => {
53
+ const l = b(n.value) ? 0 : n.value;
54
+ let t = (l - e + o.options.length) % o.options.length;
55
+ for (; o.options[t].disabled && t !== l; )
56
+ t = S(e + 1);
57
+ return t;
58
+ }, P = async () => {
59
+ if (!a.value) return;
60
+ const e = S();
61
+ n.value = e, u();
62
+ }, W = () => {
63
+ if (!a.value) return;
64
+ let e = 0;
65
+ for (; o.options[e].disabled; )
66
+ e++;
67
+ n.value = e, u();
68
+ }, q = () => {
69
+ if (!a.value) return;
70
+ let e = o.options.length - 1;
71
+ for (; o.options[e].disabled && e !== 0; )
72
+ e--;
73
+ n.value = e, u();
74
+ }, J = () => {
75
+ if (!a.value) return;
76
+ let e = 0;
77
+ for (; o.options[e] && !o.options[e].selected && o.options.length !== e; )
78
+ e++;
79
+ n.value = e % o.options.length, u();
80
+ }, Y = () => {
81
+ if (!a.value) return;
82
+ let e = o.options.length - 1;
83
+ for (; o.options[e].selected && e > 0; )
84
+ e--;
85
+ n.value = e === -1 ? o.options.length - 1 : e, u();
86
+ }, j = (e) => {
87
+ if (!a.value) return;
88
+ const l = o.options.findIndex(
89
+ (t) => t.valueHash === e
90
+ );
91
+ l >= 0 && (n.value = l), u();
92
+ }, k = () => {
93
+ n.value = null;
94
+ }, u = () => {
95
+ s.value && oe(n.value) && v.value.scrollToIndex(n.value, {
96
+ align: "center",
97
+ behavior: "smooth"
98
+ });
99
+ }, w = () => {
100
+ if (b(n.value) || !o.open) return;
101
+ const e = o.options[n.value];
102
+ e.selected ? _("option:unselected", e) : _("option:selected", e);
103
+ }, B = f(0), E = () => {
104
+ s.value && (B.value = s.value.scrollHeight);
105
+ }, G = (e) => !e.disabled, K = (e) => {
106
+ if (e.preventDefault(), s.value && e.target && e.target instanceof HTMLElement) {
107
+ if (!s.value.querySelector('[role="listbox"]'))
108
+ throw new Error("Could not find listbox in DOM tree.");
109
+ let t = e.target, r = t.dataset.index;
110
+ for (; b(r) && t.parentElement; )
111
+ t = t.parentElement, r = t.dataset.index;
112
+ if (r) {
113
+ const T = o.options[+r];
114
+ T && G(T) && (n.value = +r, w());
115
+ }
116
+ }
117
+ }, Q = () => b(n.value) ? void 0 : o.options[n.value];
118
+ return D(
119
+ () => o.open,
120
+ () => {
121
+ E();
122
+ },
123
+ { flush: "post" }
124
+ ), D(
125
+ () => o.options,
126
+ (e, l) => {
127
+ L(e.map((t) => t.valueHash)) !== L(l.map((t) => t.valueHash)) && (v.value.calculateRange(), E(), k());
128
+ },
129
+ {
130
+ flush: "post"
131
+ }
132
+ ), V({
133
+ focusNext: R,
134
+ focusPrevious: P,
135
+ focusFirst: W,
136
+ focusFirstSelected: J,
137
+ focusLast: q,
138
+ focusLastSelected: Y,
139
+ blur: k,
140
+ confirmOption: w,
141
+ focusByHash: j,
142
+ getHighlighted: Q
143
+ }), (e, l) => (p(), d("span", {
144
+ class: $(["bb-listbox", {
145
+ "bb-listbox--compact": e.compact,
146
+ "bb-listbox--loading": e.loading,
147
+ "bb-listbox--multiple": e.multiple,
148
+ "bb-listbox--no-data": !i.value.length,
149
+ "bb-listbox--open": e.open
150
+ }]),
151
+ style: h({
152
+ "--transition-duration": `${e.transitionDuration}ms`,
153
+ "--overlay-min-height": `${B.value}px`
154
+ }),
155
+ onClick: X(K, ["stop"])
156
+ }, [
157
+ c("span", le, [
158
+ c("span", {
159
+ ref_key: "inner",
160
+ ref: s,
161
+ class: "bb-listbox__inner-container",
162
+ tabindex: "-1"
163
+ }, [
164
+ m(e.$slots, "options:prepend"),
165
+ e.loading && !e.options.length ? (p(), d("span", ie, [
166
+ m(e.$slots, "loading", {}, () => [
167
+ z(g(e.loadingText || H(y)("common.loadingText").value), 1)
168
+ ])
169
+ ])) : e.options.length ? (p(), d("span", {
170
+ key: 2,
171
+ role: "listbox",
172
+ style: h({
173
+ height: `${A.value}px`
174
+ }),
175
+ tabindex: "-1"
176
+ }, [
177
+ (p(!0), d(Z, null, ee(M.value, (t, r) => (p(), d("span", {
178
+ key: i.value[t.index].value,
179
+ ref_for: !0,
180
+ ref: F,
181
+ "aria-selected": n.value === r ? !0 : void 0,
182
+ class: $({
183
+ "bb-listbox__option autocomplete-option": !0,
184
+ "autocomplete-option--focused": n.value === t.index,
185
+ "autocomplete-option--selected": i.value[t.index].selected,
186
+ "autocomplete-option--disabled": i.value[t.index].disabled
187
+ }),
188
+ "data-index": t.index,
189
+ role: "option",
190
+ style: h({
191
+ transform: `translateY(${t.start}px)`
192
+ })
193
+ }, [
194
+ c("span", ue, [
195
+ m(e.$slots, "option", {
196
+ disabled: !!i.value[t.index].disabled,
197
+ focused: n.value === t.index,
198
+ index: t.index,
199
+ item: i.value[t.index].item,
200
+ selected: !!i.value[t.index].selected,
201
+ text: i.value[t.index].text,
202
+ value: i.value[t.index].value
203
+ }, () => [
204
+ l[0] || (l[0] = c("svg", {
205
+ class: "autocomplete-option__checkbox",
206
+ role: "presentation",
207
+ viewBox: "276.411 158.834 114.971 114.97"
208
+ }, [
209
+ c("path", {
210
+ d: "M 297.574 224.786 L 318.309 243.134 L 371.568 189.232",
211
+ fill: "none",
212
+ "stroke-linecap": "round",
213
+ "stroke-width": "14px"
214
+ })
215
+ ], -1)),
216
+ c("span", re, g(i.value[t.index].text), 1)
217
+ ])
218
+ ])
219
+ ], 14, ae))), 128))
220
+ ], 4)) : (p(), d("span", se, [
221
+ m(e.$slots, "no-data", {}, () => [
222
+ z(g(e.noDataText || H(y)("common.noDataText").value), 1)
223
+ ])
224
+ ])),
225
+ m(e.$slots, "options:append")
226
+ ], 512)
227
+ ])
228
+ ], 6));
229
+ }
230
+ });
12
231
  export {
13
- n as useArray
232
+ xe as default
14
233
  };
package/dist/index265.js CHANGED
@@ -1,8 +1,185 @@
1
- const o = (e, t = 50) => new Promise((r) => {
2
- const n = setInterval(() => {
3
- e() && (clearInterval(n), r());
4
- }, t);
5
- });
1
+ var w = Object.defineProperty, C = (a, e, t) => e in a ? w(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, A = (a, e, t) => C(a, typeof e != "symbol" ? e + "" : e, t);
2
+ const R = {
3
+ "#": { pattern: /[0-9]/ },
4
+ "@": { pattern: /[a-zA-Z]/ },
5
+ "*": { pattern: /[a-zA-Z0-9]/ }
6
+ }, N = (a, e, t) => a.replaceAll(e, "").replace(t, ".").replace("..", ".").replace(/[^.\d]/g, ""), I = (a, e, t) => {
7
+ var s;
8
+ return new Intl.NumberFormat(((s = t.number) == null ? void 0 : s.locale) ?? "en", {
9
+ minimumFractionDigits: a,
10
+ maximumFractionDigits: e,
11
+ roundingMode: "trunc"
12
+ });
13
+ }, P = (a, e = !0, t) => {
14
+ var s, r, n, l;
15
+ const u = ((s = t.number) == null ? void 0 : s.unsigned) !== !0 && a.startsWith("-") ? "-" : "", p = ((r = t.number) == null ? void 0 : r.fraction) ?? 0;
16
+ let o = I(0, p, t);
17
+ const k = o.formatToParts(1000.12), m = ((n = k.find((i) => i.type === "group")) == null ? void 0 : n.value) ?? " ", f = ((l = k.find((i) => i.type === "decimal")) == null ? void 0 : l.value) ?? ".", c = N(a, m, f);
18
+ if (Number.isNaN(parseFloat(c))) return u;
19
+ const v = c.split(".");
20
+ if (v[1] != null && v[1].length >= 1) {
21
+ const i = v[1].length <= p ? v[1].length : p;
22
+ o = I(i, p, t);
23
+ }
24
+ let d = o.format(parseFloat(c));
25
+ return e ? p > 0 && c.endsWith(".") && !c.slice(0, -1).includes(".") && (d += f) : d = N(d, m, f), u + d;
26
+ };
27
+ class T {
28
+ constructor(e = {}) {
29
+ A(this, "opts", {}), A(this, "memo", /* @__PURE__ */ new Map());
30
+ const t = { ...e };
31
+ if (t.tokens != null) {
32
+ t.tokens = t.tokensReplace ? { ...t.tokens } : { ...R, ...t.tokens };
33
+ for (const s of Object.values(t.tokens))
34
+ typeof s.pattern == "string" && (s.pattern = new RegExp(s.pattern));
35
+ } else
36
+ t.tokens = R;
37
+ Array.isArray(t.mask) && (t.mask.length > 1 ? t.mask = [...t.mask].sort((s, r) => s.length - r.length) : t.mask = t.mask[0] ?? ""), t.mask === "" && (t.mask = null), this.opts = t;
38
+ }
39
+ masked(e) {
40
+ return this.process(String(e), this.findMask(String(e)));
41
+ }
42
+ unmasked(e) {
43
+ return this.process(String(e), this.findMask(String(e)), !1);
44
+ }
45
+ isEager() {
46
+ return this.opts.eager === !0;
47
+ }
48
+ isReversed() {
49
+ return this.opts.reversed === !0;
50
+ }
51
+ completed(e) {
52
+ const t = this.findMask(String(e));
53
+ if (this.opts.mask == null || t == null) return !1;
54
+ const s = this.process(String(e), t).length;
55
+ return typeof this.opts.mask == "string" ? s >= this.opts.mask.length : s >= t.length;
56
+ }
57
+ findMask(e) {
58
+ const t = this.opts.mask;
59
+ if (t == null)
60
+ return null;
61
+ if (typeof t == "string")
62
+ return t;
63
+ if (typeof t == "function")
64
+ return t(e);
65
+ const s = this.process(e, t.slice(-1).pop() ?? "", !1);
66
+ return t.find((r) => this.process(e, r, !1).length >= s.length) ?? "";
67
+ }
68
+ escapeMask(e) {
69
+ const t = [], s = [];
70
+ return e.split("").forEach((r, n) => {
71
+ r === "!" && e[n - 1] !== "!" ? s.push(n - s.length) : t.push(r);
72
+ }), { mask: t.join(""), escaped: s };
73
+ }
74
+ process(e, t, s = !0) {
75
+ if (this.opts.number != null) return P(e, s, this.opts);
76
+ if (t == null) return e;
77
+ const r = `v=${e},mr=${t},m=${s ? 1 : 0}`;
78
+ if (this.memo.has(r)) return this.memo.get(r);
79
+ const { mask: n, escaped: l } = this.escapeMask(t), u = [], p = this.opts.tokens != null ? this.opts.tokens : {}, o = this.isReversed() ? -1 : 1, k = this.isReversed() ? "unshift" : "push", m = this.isReversed() ? 0 : n.length - 1, f = this.isReversed() ? () => i > -1 && h > -1 : () => i < n.length && h < e.length, c = (b) => !this.isReversed() && b <= m || this.isReversed() && b >= m;
80
+ let v, d = -1, i = this.isReversed() ? n.length - 1 : 0, h = this.isReversed() ? e.length - 1 : 0, M = !1;
81
+ for (; f(); ) {
82
+ const b = n.charAt(i), g = p[b], y = (g == null ? void 0 : g.transform) != null ? g.transform(e.charAt(h)) : e.charAt(h);
83
+ if (!l.includes(i) && g != null ? (y.match(g.pattern) != null ? (u[k](y), g.repeated ? (d === -1 ? d = i : i === m && i !== d && (i = d - o), m === d && (i -= o)) : g.multiple && (M = !0, i -= o), i += o) : g.multiple ? M && (i += o, h -= o, M = !1) : y === v ? v = void 0 : g.optional && (i += o, h -= o), h += o) : (s && !this.isEager() && u[k](b), y === b && !this.isEager() ? h += o : v = b, this.isEager() || (i += o)), this.isEager())
84
+ for (; c(i) && (p[n.charAt(i)] == null || l.includes(i)); ) {
85
+ if (s) {
86
+ if (u[k](n.charAt(i)), e.charAt(h) === n.charAt(i)) {
87
+ i += o, h += o;
88
+ continue;
89
+ }
90
+ } else n.charAt(i) === e.charAt(h) && (h += o);
91
+ i += o;
92
+ }
93
+ }
94
+ return this.memo.set(r, u.join("")), this.memo.get(r);
95
+ }
96
+ }
97
+ const S = (a) => JSON.parse(a.replaceAll("'", '"')), F = (a, e = {}) => {
98
+ const t = { ...e };
99
+ a.dataset.maska != null && a.dataset.maska !== "" && (t.mask = W(a.dataset.maska)), a.dataset.maskaEager != null && (t.eager = E(a.dataset.maskaEager)), a.dataset.maskaReversed != null && (t.reversed = E(a.dataset.maskaReversed)), a.dataset.maskaTokensReplace != null && (t.tokensReplace = E(a.dataset.maskaTokensReplace)), a.dataset.maskaTokens != null && (t.tokens = x(a.dataset.maskaTokens));
100
+ const s = {};
101
+ return a.dataset.maskaNumberLocale != null && (s.locale = a.dataset.maskaNumberLocale), a.dataset.maskaNumberFraction != null && (s.fraction = parseInt(a.dataset.maskaNumberFraction)), a.dataset.maskaNumberUnsigned != null && (s.unsigned = E(a.dataset.maskaNumberUnsigned)), (a.dataset.maskaNumber != null || Object.values(s).length > 0) && (t.number = s), t;
102
+ }, E = (a) => a !== "" ? !!JSON.parse(a) : !0, W = (a) => a.startsWith("[") && a.endsWith("]") ? S(a) : a, x = (a) => {
103
+ if (a.startsWith("{") && a.endsWith("}"))
104
+ return S(a);
105
+ const e = {};
106
+ return a.split("|").forEach((t) => {
107
+ const s = t.split(":");
108
+ e[s[0]] = {
109
+ pattern: new RegExp(s[1]),
110
+ optional: s[2] === "optional",
111
+ multiple: s[2] === "multiple",
112
+ repeated: s[2] === "repeated"
113
+ };
114
+ }), e;
115
+ };
116
+ class O {
117
+ constructor(e, t = {}) {
118
+ A(this, "items", /* @__PURE__ */ new Map()), A(this, "eventAbortController"), A(this, "onInput", (s) => {
119
+ if (s instanceof CustomEvent && s.type === "input" && !s.isTrusted && !s.bubbles)
120
+ return;
121
+ const r = s.target, n = this.items.get(r);
122
+ if (n === void 0) return;
123
+ const l = "inputType" in s && s.inputType.startsWith("delete"), u = n.isEager(), p = l && u && n.unmasked(r.value) === "" ? "" : r.value;
124
+ this.fixCursor(r, l, () => this.setValue(r, p));
125
+ }), this.options = t, this.eventAbortController = new AbortController(), this.init(this.getInputs(e));
126
+ }
127
+ update(e = {}) {
128
+ this.options = { ...e }, this.init(Array.from(this.items.keys()));
129
+ }
130
+ updateValue(e) {
131
+ var t;
132
+ e.value !== "" && e.value !== ((t = this.processInput(e)) == null ? void 0 : t.masked) && this.setValue(e, e.value);
133
+ }
134
+ destroy() {
135
+ this.eventAbortController.abort(), this.items.clear();
136
+ }
137
+ init(e) {
138
+ const t = this.getOptions(this.options);
139
+ for (const s of e) {
140
+ if (!this.items.has(s)) {
141
+ const { signal: n } = this.eventAbortController;
142
+ s.addEventListener("input", this.onInput, { capture: !0, signal: n });
143
+ }
144
+ const r = new T(F(s, t));
145
+ this.items.set(s, r), queueMicrotask(() => this.updateValue(s)), s.selectionStart === null && r.isEager() && console.warn("Maska: input of `%s` type is not supported", s.type);
146
+ }
147
+ }
148
+ getInputs(e) {
149
+ return typeof e == "string" ? Array.from(document.querySelectorAll(e)) : "length" in e ? Array.from(e) : [e];
150
+ }
151
+ getOptions(e) {
152
+ const { onMaska: t, preProcess: s, postProcess: r, ...n } = e;
153
+ return n;
154
+ }
155
+ fixCursor(e, t, s) {
156
+ var r, n;
157
+ const l = e.selectionStart, u = e.value;
158
+ if (s(), l === null || l === u.length && !t) return;
159
+ const p = e.value, o = u.slice(0, l), k = p.slice(0, l), m = (r = this.processInput(e, o)) == null ? void 0 : r.unmasked, f = (n = this.processInput(e, k)) == null ? void 0 : n.unmasked;
160
+ if (m === void 0 || f === void 0) return;
161
+ let c = l;
162
+ o !== k && (c += t ? p.length - u.length : m.length - f.length), e.setSelectionRange(c, c);
163
+ }
164
+ setValue(e, t) {
165
+ const s = this.processInput(e, t);
166
+ s !== void 0 && (e.value = s.masked, this.options.onMaska != null && (Array.isArray(this.options.onMaska) ? this.options.onMaska.forEach((r) => r(s)) : this.options.onMaska(s)), e.dispatchEvent(new CustomEvent("maska", { detail: s })), e.dispatchEvent(new CustomEvent("input", { detail: s.masked })));
167
+ }
168
+ processInput(e, t) {
169
+ const s = this.items.get(e);
170
+ if (s === void 0) return;
171
+ let r = t ?? e.value;
172
+ this.options.preProcess != null && (r = this.options.preProcess(r));
173
+ let n = s.masked(r);
174
+ return this.options.postProcess != null && (n = this.options.postProcess(n)), {
175
+ masked: n,
176
+ unmasked: s.unmasked(r),
177
+ completed: s.completed(r)
178
+ };
179
+ }
180
+ }
6
181
  export {
7
- o as waitFor
182
+ T as Mask,
183
+ O as MaskInput,
184
+ R as tokens
8
185
  };