@onereach/ui-components-common 20.2.0-beta.5195.0 → 20.2.0-beta.5208.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.
@@ -1,22 +1,23 @@
1
1
  import r from "lodash/get";
2
2
  import n from "lodash/isElement";
3
- const s = typeof window < "u" ? window : null, g = (s == null ? void 0 : s.MutationObserver) || (s == null ? void 0 : s.WebKitMutationObserver) || (s == null ? void 0 : s.MozMutationObserver) || null, A = ((s == null ? void 0 : s.requestAnimationFrame) || (s == null ? void 0 : s.webkitRequestAnimationFrame) || (s == null ? void 0 : s.mozRequestAnimationFrame) || (s == null ? void 0 : s.msRequestAnimationFrame) || (s == null ? void 0 : s.oRequestAnimationFrame) || // Fallback, but not a true polyfill
3
+ const s = typeof window < "u" ? window : null, g = (s == null ? void 0 : s.MutationObserver) || (s == null ? void 0 : s.WebKitMutationObserver) || (s == null ? void 0 : s.MozMutationObserver) || null, b = ((s == null ? void 0 : s.requestAnimationFrame) || (s == null ? void 0 : s.webkitRequestAnimationFrame) || (s == null ? void 0 : s.mozRequestAnimationFrame) || (s == null ? void 0 : s.msRequestAnimationFrame) || (s == null ? void 0 : s.oRequestAnimationFrame) || // Fallback, but not a true polyfill
4
4
  // Only needed for Opera Mini
5
- ((t) => setTimeout(t, 16))).bind(s), y = ((s == null ? void 0 : s.cancelAnimationFrame) || (s == null ? void 0 : s.mozCancelAnimationFrame)).bind(s), b = (t) => {
5
+ ((t) => setTimeout(t, 16))).bind(s), A = ((s == null ? void 0 : s.requestIdleCallback) || // Fallback, but not a true polyfill
6
+ ((t) => setTimeout(t, 1))).bind(s), y = ((s == null ? void 0 : s.cancelAnimationFrame) || (s == null ? void 0 : s.mozCancelAnimationFrame)).bind(s), w = (t) => {
6
7
  t && t.parentNode && t.parentNode.removeChild(t);
7
- }, w = (t) => r(t, ["offsetHeight"], null), F = (t, e) => [...(e && n(e) ? e : document).querySelectorAll(t)], h = (t, e) => (e && n(e) ? e : document).querySelector(t) || null, v = (t, e) => t && typeof t.contains == "function" ? t.contains(e) : !1, C = (t) => document.getElementById(/^#/.test(t) ? t.slice(1) : t) || null, S = (t, e) => {
8
+ }, C = (t) => r(t, ["offsetHeight"], null), F = (t, e) => [...(e && n(e) ? e : document).querySelectorAll(t)], h = (t, e) => (e && n(e) ? e : document).querySelector(t) || null, q = (t, e) => t && typeof t.contains == "function" ? t.contains(e) : !1, v = (t) => document.getElementById(/^#/.test(t) ? t.slice(1) : t) || null, S = (t, e) => {
8
9
  e && n(t) && t.classList && t.classList.add(e);
9
- }, q = (t, e) => {
10
+ }, x = (t, e) => {
10
11
  e && n(t) && t.classList && t.classList.remove(e);
11
12
  }, E = (t, e) => e && n(t) && t.classList ? t.classList.contains(e) : !1, L = (t, e, o) => {
12
13
  e && n(t) && t.setAttribute(e, o);
13
- }, x = (t, e) => {
14
+ }, M = (t, e) => {
14
15
  e && n(t) && t.removeAttribute(e);
15
- }, M = (t, e) => e && n(t) ? t.getAttribute(e) : null, R = (t, e) => e && n(t) ? t.hasAttribute(e) : null, z = (t, e, o) => {
16
+ }, R = (t, e) => e && n(t) ? t.getAttribute(e) : null, T = (t, e) => e && n(t) ? t.hasAttribute(e) : null, z = (t, e, o) => {
16
17
  e && n(t) && (t.style[e] = o);
17
- }, T = (t, e) => {
18
+ }, B = (t, e) => {
18
19
  e && n(t) && (t.style[e] = "");
19
- }, B = (t, e) => e && n(t) && t.style[e] || null, m = (t) => n(t) ? t.getBoundingClientRect() : null, c = (t) => r(s, "getComputedStyle", null) && n(t) ? getComputedStyle(t) : {}, u = (t) => {
20
+ }, k = (t, e) => e && n(t) && t.style[e] || null, m = (t) => n(t) ? t.getBoundingClientRect() : null, c = (t) => r(s, "getComputedStyle", null) && n(t) ? getComputedStyle(t) : {}, u = (t) => {
20
21
  const e = {
21
22
  top: 0,
22
23
  left: 0
@@ -45,14 +46,14 @@ const s = typeof window < "u" ? window : null, g = (s == null ? void 0 : s.Mutat
45
46
  e = m(t) || e;
46
47
  else {
47
48
  e = u(t);
48
- const f = t.ownerDocument;
49
- let a = t.offsetParent || f.documentElement;
50
- for (; a && (a === f.body || a === f.documentElement) && c(a).position === "static"; )
49
+ const l = t.ownerDocument;
50
+ let a = t.offsetParent || l.documentElement;
51
+ for (; a && (a === l.body || a === l.documentElement) && c(a).position === "static"; )
51
52
  a = a.parentNode;
52
53
  if (a && a !== t && a.nodeType === Node.ELEMENT_NODE) {
53
54
  o = u(a);
54
- const l = c(a);
55
- o.top += parseFloat(l.borderTopWidth), o.left += parseFloat(l.borderLeftWidth);
55
+ const f = c(a);
56
+ o.top += parseFloat(f.borderTopWidth), o.left += parseFloat(f.borderLeftWidth);
56
57
  }
57
58
  }
58
59
  return {
@@ -69,27 +70,28 @@ const s = typeof window < "u" ? window : null, g = (s == null ? void 0 : s.Mutat
69
70
  };
70
71
  export {
71
72
  g as M,
72
- b as a,
73
+ A as a,
73
74
  w as b,
74
75
  y as c,
75
- h as d,
76
- v as e,
77
- S as f,
78
- C as g,
79
- q as h,
80
- E as i,
81
- L as j,
82
- x as k,
76
+ C as d,
77
+ h as e,
78
+ q as f,
79
+ v as g,
80
+ S as h,
81
+ x as i,
82
+ E as j,
83
+ L as k,
83
84
  M as l,
84
85
  R as m,
85
- z as n,
86
- T as o,
86
+ T as n,
87
+ z as o,
87
88
  B as p,
88
- m as q,
89
- A as r,
89
+ k as q,
90
+ b as r,
90
91
  F as s,
91
- c as t,
92
- u,
93
- P as v,
94
- _ as w
92
+ m as t,
93
+ c as u,
94
+ u as v,
95
+ P as w,
96
+ _ as x
95
97
  };
@@ -1,4 +1,4 @@
1
- import "./dom-CwV-xS38.js";
1
+ import "./dom-DzNS5tBj.js";
2
2
  import { i as O } from "./isUndefined-B5qXrATz.js";
3
3
  const R = {
4
4
  h: {
@@ -0,0 +1,16 @@
1
+ function i(e) {
2
+ return e.offsetWidth > 0 && e.offsetHeight > 0;
3
+ }
4
+ function l(e) {
5
+ const s = document.body.querySelectorAll("*"), n = [];
6
+ for (const t of s)
7
+ if (!t.isEqualNode(e) && i(t)) {
8
+ const o = getComputedStyle(t, null).getPropertyValue("z-index");
9
+ o !== null && o !== "auto" && n.push(parseInt(o));
10
+ }
11
+ return n;
12
+ }
13
+ export {
14
+ l as g,
15
+ i
16
+ };
package/dist/helpers.js CHANGED
@@ -1,4 +1,4 @@
1
- import { g as s, a as t, s as m } from "./searchItemsByLabel-BhinsABA.js";
1
+ import { g as s, a as t, s as m } from "./searchItemsByLabel-CPGAoUEr.js";
2
2
  export {
3
3
  s as getItemByValue,
4
4
  t as getItemsByValue,
package/dist/hooks.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a, b as u, c as t, d as o, e as r, f as i, g as l, h as m, i as n, j as b, k as d, l as v, m as T, u as f, n as g } from "./useValidationAttributes-DxhcSj_h.js";
1
+ import { a, b as u, c as t, d as o, e as r, f as i, g as l, h as m, i as n, j as b, k as d, l as v, m as T, u as f, n as g } from "./useValidationAttributes-Cilw02AC.js";
2
2
  export {
3
3
  a as useControlAttributes,
4
4
  u as useDateFormat,
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
1
  import { D as e, a as E } from "./dropdown-open-k6cFnrqA.js";
2
- import { g as t, a as R, s as T } from "./searchItemsByLabel-BhinsABA.js";
3
- import { D as r, L as A, T as O, a as C, b as i, c as D, d as l, e as S, f as N, g as m, h as X, i as n, j as u, k as P, l as L, m as M, u as I, n as g } from "./useValidationAttributes-DxhcSj_h.js";
2
+ import { g as _, a as R, s as T } from "./searchItemsByLabel-CPGAoUEr.js";
3
+ import { D as r, L as A, T as C, a as O, b as i, c as l, d as D, e as S, f as N, g as m, h as X, i as n, j as u, k as P, l as L, m as M, u as g, n as I } from "./useValidationAttributes-Cilw02AC.js";
4
4
  import { DateFormat as f, TimeFormat as p } from "./types.js";
5
- import { C as F, a as c, b as x, c as b, d as B, e as y, f as G, g as h, h as v, i as U, j as V, k, l as w, m as j, H as W, p as q, o as K, t as Y, s as z, r as Q, q as Z, n as J, P as $, Q as aa, R as sa, u as ea, S as Ea, T as _a, v as ta, W as Ra, X as Ta, w as oa, x as ra, y as Aa, V as Oa, z as Ca, A as ia, _ as Da, B as la, D as Sa, E as Na, Y as ma, F as Xa, Z as na, G as ua, I as Pa, J as La, K as Ma, U as Ia, L as ga, M as da, N as fa, O as pa, $ as Ha, am as Fa, a5 as ca, a4 as xa, a2 as ba, a9 as Ba, a6 as ya, a0 as Ga, a3 as ha, aa as va, ab as Ua, ac as Va, ad as ka, ae as wa, af as ja, ag as Wa, ah as qa, ai as Ka, aj as Ya, ak as za, a7 as Qa, a8 as Za, a1 as Ja, al as $a } from "./extractCssVarName-IHa2pGlF.js";
6
- import { M as ss, f as es, c as Es, e as _s, l as ts, q as Rs, g as Ts, t as os, w as rs, p as As, m as Os, i as Cs, u as is, v as Ds, b as ls, k as Ss, h as Ns, a as ms, o as Xs, r as ns, d as us, s as Ps, j as Ls, n as Ms } from "./dom-CwV-xS38.js";
7
- import { i as gs } from "./isUndefined-B5qXrATz.js";
8
- import { i as fs } from "./isVisible-BuGrjvTY.js";
5
+ import { C as x, a as F, b as c, c as b, d as B, e as v, f as y, g as G, h, i as U, j as V, k, l as w, m as j, H as q, p as W, o as K, t as Y, s as z, r as Q, q as Z, n as J, P as $, Q as aa, R as sa, u as ea, S as Ea, T as ta, v as _a, W as Ra, X as Ta, w as oa, x as ra, y as Aa, V as Ca, z as Oa, A as ia, _ as la, B as Da, D as Sa, E as Na, Y as ma, F as Xa, Z as na, G as ua, I as Pa, J as La, K as Ma, U as ga, L as Ia, M as da, N as fa, O as pa, $ as Ha, am as xa, a5 as Fa, a4 as ca, a2 as ba, a9 as Ba, a6 as va, a0 as ya, a3 as Ga, aa as ha, ab as Ua, ac as Va, ad as ka, ae as wa, af as ja, ag as qa, ah as Wa, ai as Ka, aj as Ya, ak as za, a7 as Qa, a8 as Za, a1 as Ja, al as $a } from "./extractCssVarName-FgXy_HI0.js";
6
+ import { M as ss, h as es, c as Es, f as ts, m as _s, t as Rs, g as Ts, u as os, x as rs, q as As, n as Cs, j as Os, v as is, w as ls, d as Ds, l as Ss, i as Ns, b as ms, p as Xs, r as ns, a as us, e as Ps, s as Ls, k as Ms, o as gs } from "./dom-DzNS5tBj.js";
7
+ import { i as ds } from "./isUndefined-B5qXrATz.js";
8
+ import { g as ps, i as Hs } from "./getPageElevations-BuZyM94T.js";
9
9
  export {
10
- F as CODE_BACKSPACE,
11
- c as CODE_BREAK,
12
- x as CODE_DELETE,
10
+ x as CODE_BACKSPACE,
11
+ F as CODE_BREAK,
12
+ c as CODE_DELETE,
13
13
  b as CODE_DOWN,
14
14
  B as CODE_END,
15
- y as CODE_ENTER,
16
- G as CODE_ESC,
17
- h as CODE_HOME,
18
- v as CODE_LEFT,
15
+ v as CODE_ENTER,
16
+ y as CODE_ESC,
17
+ G as CODE_HOME,
18
+ h as CODE_LEFT,
19
19
  U as CODE_PAGEDOWN,
20
20
  V as CODE_PAGEUP,
21
21
  k as CODE_RIGHT,
@@ -25,10 +25,10 @@ export {
25
25
  f as DateFormat,
26
26
  e as DropdownClose,
27
27
  E as DropdownOpen,
28
- W as HSL_LIMITS,
28
+ q as HSL_LIMITS,
29
29
  A as LOCALE,
30
30
  ss as MutationObs,
31
- q as PLACEMENT_BOTTOM_END,
31
+ W as PLACEMENT_BOTTOM_END,
32
32
  K as PLACEMENT_BOTTOM_START,
33
33
  Y as PLACEMENT_LEFT_END,
34
34
  z as PLACEMENT_LEFT_START,
@@ -40,18 +40,18 @@ export {
40
40
  sa as RX_ARRAY_NOTATION,
41
41
  ea as RX_BV_PREFIX,
42
42
  Ea as RX_DATE,
43
- _a as RX_DATE_SPLIT,
44
- ta as RX_DIGITS,
43
+ ta as RX_DATE_SPLIT,
44
+ _a as RX_DIGITS,
45
45
  Ra as RX_ENCODED_COMMA,
46
46
  Ta as RX_ENCODE_REVERSE,
47
47
  oa as RX_EXTENSION,
48
48
  ra as RX_HASH,
49
49
  Aa as RX_HASH_ID,
50
- Oa as RX_HREF,
51
- Ca as RX_HTML_TAGS,
50
+ Ca as RX_HREF,
51
+ Oa as RX_HTML_TAGS,
52
52
  ia as RX_HYPHENATE,
53
- Da as RX_LONG_COLOR,
54
- la as RX_LOWER_UPPER,
53
+ la as RX_LONG_COLOR,
54
+ Da as RX_LOWER_UPPER,
55
55
  Sa as RX_NUMBER,
56
56
  Na as RX_PLUS,
57
57
  ma as RX_QUERY_START,
@@ -61,69 +61,71 @@ export {
61
61
  Pa as RX_SPACE_SPLIT,
62
62
  La as RX_STAR,
63
63
  Ma as RX_START_SPACE_WORD,
64
- Ia as RX_TIME,
65
- ga as RX_TRIM_LEFT,
64
+ ga as RX_TIME,
65
+ Ia as RX_TRIM_LEFT,
66
66
  da as RX_TRIM_RIGHT,
67
67
  fa as RX_UNDERSCORE,
68
68
  pa as RX_UN_KEBAB,
69
- O as TIME_FORMAT,
69
+ C as TIME_FORMAT,
70
70
  p as TimeFormat,
71
71
  es as addClass,
72
72
  Es as cancelAF,
73
- _s as contains,
73
+ ts as contains,
74
74
  Ha as exclude,
75
- Fa as extractCssVarName,
76
- ca as flattenDeep,
77
- xa as generateColorFromString,
75
+ xa as extractCssVarName,
76
+ Fa as flattenDeep,
77
+ ca as generateColorFromString,
78
78
  ba as generateHslFromString,
79
79
  Ba as getAbbreviation,
80
- ts as getAttr,
80
+ _s as getAttr,
81
81
  Rs as getBCR,
82
82
  Ts as getById,
83
83
  os as getCS,
84
- ya as getHashOfString,
85
- t as getItemByValue,
84
+ va as getHashOfString,
85
+ _ as getItemByValue,
86
86
  R as getItemsByValue,
87
87
  rs as getMaxZIndex,
88
+ ps as getPageElevations,
88
89
  As as getStyle,
89
- Os as hasAttr,
90
- Cs as hasClass,
91
- Ga as hexToRgb,
92
- ha as hslToColorString,
93
- va as include,
90
+ Cs as hasAttr,
91
+ Os as hasClass,
92
+ ya as hexToRgb,
93
+ Ga as hslToColorString,
94
+ ha as include,
94
95
  Ua as isAncestor,
95
96
  Va as isArray,
96
97
  ka as isDescendant,
97
98
  wa as isEmpty,
98
99
  ja as isEqual,
99
- Wa as isNil,
100
- qa as isNull,
100
+ qa as isNil,
101
+ Wa as isNull,
101
102
  Ka as isNumber,
102
103
  Ya as isObject,
103
104
  za as isString,
104
- gs as isUndefined,
105
- fs as isVisible,
105
+ ds as isUndefined,
106
+ Hs as isVisible,
106
107
  Qa as normalize,
107
108
  is as offset,
108
- Ds as position,
109
+ ls as position,
109
110
  Za as pxToRem,
110
- ls as reflow,
111
+ Ds as reflow,
111
112
  Ss as removeAttr,
112
113
  Ns as removeClass,
113
114
  ms as removeNode,
114
115
  Xs as removeStyle,
115
116
  ns as requestAF,
117
+ us as requestIC,
116
118
  Ja as rgbToHex,
117
119
  T as searchItemsByLabel,
118
- us as select,
119
- Ps as selectAll,
120
- Ls as setAttr,
121
- Ms as setStyle,
120
+ Ps as select,
121
+ Ls as selectAll,
122
+ Ms as setAttr,
123
+ gs as setStyle,
122
124
  $a as toArray,
123
- C as useControlAttributes,
125
+ O as useControlAttributes,
124
126
  i as useDateFormat,
125
- D as useDateMask,
126
- l as useElevation,
127
+ l as useDateMask,
128
+ D as useElevation,
127
129
  S as useIdAttribute,
128
130
  N as useLocale,
129
131
  m as useOverflow,
@@ -133,6 +135,6 @@ export {
133
135
  P as useTheme,
134
136
  L as useTimeFormat,
135
137
  M as useTimeMask,
136
- I as useToggle,
137
- g as useValidationAttributes
138
+ g as useToggle,
139
+ I as useValidationAttributes
138
140
  };
@@ -1,4 +1,4 @@
1
- import "./dom-CwV-xS38.js";
1
+ import "./dom-DzNS5tBj.js";
2
2
  import { i as s } from "./isUndefined-B5qXrATz.js";
3
3
  const a = (t, r) => {
4
4
  const e = r.find((n) => t === n.value);
@@ -0,0 +1,214 @@
1
+ import { useAttrs as h, computed as u, inject as g, isRef as p, ref as c, watch as v, getCurrentInstance as M, onMounted as R } from "vue";
2
+ import { DateFormat as x, TimeFormat as b } from "./types.js";
3
+ import { r as C } from "./dom-DzNS5tBj.js";
4
+ import { g as E } from "./getPageElevations-BuZyM94T.js";
5
+ import { useMutationObserver as $, useResizeObserver as F, refDebounced as S, useMediaQuery as P } from "@vueuse/core";
6
+ import O from "@onereach/styles/screens.json";
7
+ import { isVue3 as Y } from "@/constants";
8
+ import L from "@onereach/styles/tailwind.config.json";
9
+ const k = () => {
10
+ const e = h();
11
+ return {
12
+ readonly: u(() => e.readonly),
13
+ disabled: u(() => e.disabled),
14
+ "force-state": u(() => e["force-state"])
15
+ };
16
+ }, V = Symbol(), U = Symbol(), q = Symbol(), G = (e) => u(() => e.value ?? g(V, x.Short)), J = (e, t) => u(() => typeof e.value != "function" ? new Intl.DateTimeFormat(t.value, {
17
+ dateStyle: e.value,
18
+ timeZone: "UTC"
19
+ }).formatToParts(Date.UTC(1, 0, 1, 1, 1)).reduce((r, n) => {
20
+ switch (n.type) {
21
+ case "year":
22
+ return r + n.value.replace(/^\d{2}$/, "YY").replace(/^\d{4}$/, "YYYY");
23
+ case "month":
24
+ switch (e.value) {
25
+ case "short":
26
+ return r + n.value.replace(/^\d{1}$/, "M").replace(/^\d{2}$/, "MM");
27
+ case "medium":
28
+ return r + "MMM";
29
+ case "long":
30
+ return r + "MMMM";
31
+ default:
32
+ throw new Error("[useDateMask]: `format` has an invalid value.");
33
+ }
34
+ case "day":
35
+ return r + n.value.replace(/^\d{1}$/, "D").replace(/^\d{2}$/, "DD");
36
+ default:
37
+ return r + n.value;
38
+ }
39
+ }, "") : e.value(void 0, t.value)), K = (e, t) => {
40
+ const o = p(e) ? e : c(e), r = p(t) ? t : c();
41
+ function n(a) {
42
+ a.style.zIndex = String(Math.max(0, ...E(a)) + 1);
43
+ }
44
+ v([o, r], ([a]) => {
45
+ a && n(a);
46
+ }, { immediate: !0 });
47
+ }, N = () => {
48
+ const e = h(), t = M();
49
+ return u(() => e.id ?? (t == null ? void 0 : t.uid.toString()));
50
+ }, X = (e) => u(() => e.value ?? g(U, navigator.language)), ee = (e, t = {}) => {
51
+ const { hide: o = !0, threshold: r = 0 } = t, n = p(e) ? e : c(e), a = c([]), l = c([]);
52
+ function s() {
53
+ const i = n.value;
54
+ if (i) {
55
+ const d = [...i.children].reduce(({ innerItems: m, outerItems: y }, T) => {
56
+ const f = T, { x: D, width: I } = f.getBoundingClientRect(), { x: w, width: A } = i.getBoundingClientRect();
57
+ return D + I > w + A + r ? (o && f.style.setProperty("visibility", "hidden"), {
58
+ innerItems: m,
59
+ outerItems: [...y, f]
60
+ }) : (o && f.style.removeProperty("visibility"), {
61
+ innerItems: [...m, f],
62
+ outerItems: y
63
+ });
64
+ }, {
65
+ innerItems: [],
66
+ outerItems: []
67
+ });
68
+ a.value = d.innerItems, l.value = d.outerItems;
69
+ } else
70
+ a.value = [], l.value = [];
71
+ }
72
+ return v(n, s, {
73
+ immediate: !0
74
+ }), $(n, s, {
75
+ childList: !0
76
+ }), F(n, () => C(s)), {
77
+ innerItems: a,
78
+ outerItems: l
79
+ };
80
+ }, te = (e, t, o = {}) => {
81
+ const r = c(e.value ? "open" : "closed");
82
+ v(e, (i) => {
83
+ r.value = i ? "open" : "closed";
84
+ });
85
+ const n = S(r, o.debounce ?? 0);
86
+ v(n, (i) => {
87
+ switch (t("update:state", i), i) {
88
+ case "open":
89
+ t("open");
90
+ break;
91
+ case "closed":
92
+ t("close");
93
+ break;
94
+ }
95
+ });
96
+ function a() {
97
+ r.value = "open";
98
+ }
99
+ function l() {
100
+ r.value = "closed";
101
+ }
102
+ function s() {
103
+ r.value = r.value === "open" ? "closed" : "open";
104
+ }
105
+ return {
106
+ state: n,
107
+ open: a,
108
+ close: l,
109
+ toggle: s
110
+ };
111
+ };
112
+ function re(e, t, o = {}) {
113
+ const { defaultValue: r } = o;
114
+ return r ? u({
115
+ get: () => e.value ?? r.value,
116
+ set: (n) => {
117
+ t("update:modelValue", n);
118
+ }
119
+ }) : u({
120
+ get: () => e.value,
121
+ set: (n) => {
122
+ t("update:modelValue", n);
123
+ }
124
+ });
125
+ }
126
+ function ne(e) {
127
+ const t = M(), o = c();
128
+ e ? v(e, (s) => {
129
+ o.value = s;
130
+ }) : R(() => {
131
+ if (t) {
132
+ const s = t.vnode[Y ? "el" : "elm"];
133
+ s instanceof Element && (o.value = s);
134
+ }
135
+ });
136
+ const r = u(() => l(o.value) || a.value), n = u(() => !r.value), a = P(`(min-width: ${O.md})`);
137
+ function l(s) {
138
+ var d;
139
+ if (!s)
140
+ return !1;
141
+ const i = (d = s.getAttribute("force-screen")) == null ? void 0 : d.split(/\s+/);
142
+ return i != null && i.some((m) => ["md", "lg", "xl"].includes(m)) ? !0 : l(s.parentElement ?? void 0);
143
+ }
144
+ return {
145
+ isDesktop: r,
146
+ isMobile: n
147
+ };
148
+ }
149
+ const ue = () => L.theme, oe = (e) => u(() => e.value ?? g(q, b.Auto)), se = (e, t) => u(() => typeof e.value != "function" ? new Intl.DateTimeFormat(t.value, {
150
+ timeStyle: "short",
151
+ hourCycle: e.value !== b.Auto ? e.value : void 0,
152
+ timeZone: "UTC"
153
+ }).formatToParts(Date.UTC(1, 0, 1, 1, 1)).reduce((r, n) => {
154
+ switch (n.type) {
155
+ case "hour":
156
+ return r + n.value.replace(/^\d{1}$/, "H").replace(/^\d{2}$/, "HH");
157
+ case "minute":
158
+ return r + n.value.replace(/^\d{1}$/, "M").replace(/^\d{2}$/, "MM");
159
+ case "dayPeriod":
160
+ return r + "A";
161
+ default:
162
+ return r + n.value;
163
+ }
164
+ }, "") : e.value(void 0, t.value));
165
+ function ae(e = !1) {
166
+ const t = c(e);
167
+ function o() {
168
+ t.value = !0;
169
+ }
170
+ function r() {
171
+ t.value = !1;
172
+ }
173
+ function n() {
174
+ t.value = !t.value;
175
+ }
176
+ return {
177
+ isActiveToggle: t,
178
+ show: o,
179
+ hide: r,
180
+ toggle: n
181
+ };
182
+ }
183
+ const ie = () => {
184
+ const e = h();
185
+ return {
186
+ required: u(() => e.required),
187
+ minlength: u(() => e.minlength),
188
+ maxlength: u(() => e.maxlength),
189
+ pattern: u(() => e.pattern),
190
+ min: u(() => e.min),
191
+ max: u(() => e.max),
192
+ step: u(() => e.step)
193
+ };
194
+ };
195
+ export {
196
+ V as D,
197
+ U as L,
198
+ q as T,
199
+ k as a,
200
+ G as b,
201
+ J as c,
202
+ K as d,
203
+ N as e,
204
+ X as f,
205
+ ee as g,
206
+ te as h,
207
+ re as i,
208
+ ne as j,
209
+ ue as k,
210
+ oe as l,
211
+ se as m,
212
+ ie as n,
213
+ ae as u
214
+ };
@@ -1,5 +1,6 @@
1
1
  export declare const MutationObs: MutationObserver;
2
2
  export declare const requestAF: any;
3
+ export declare const requestIC: (((callback: IdleRequestCallback, options?: IdleRequestOptions | undefined) => number) & typeof requestIdleCallback) | ((cb: () => void) => number);
3
4
  export declare const cancelAF: any;
4
5
  export declare const removeNode: (el: HTMLElement) => void;
5
6
  export declare const reflow: (el: HTMLElement) => number | null;
@@ -0,0 +1 @@
1
+ export declare function getPageElevations(currentElement: HTMLElement): number[];
@@ -24,3 +24,4 @@ export * from './isUndefined';
24
24
  export * from './isVisible';
25
25
  export * from './toArray';
26
26
  export * from './extractCssVarName';
27
+ export * from './getPageElevations';
@@ -1 +1 @@
1
- export declare const isVisible: (element: Element) => boolean;
1
+ export declare function isVisible(element: HTMLElement): boolean;
package/dist/utils.js CHANGED
@@ -1,12 +1,12 @@
1
- import { C as E, a as _, b as R, c as e, d as T, e as t, f as A, g as C, h as O, i as r, j as S, k as o, l as N, m as i, H as D, p as X, o as P, t as l, s as L, r as n, q as M, n as I, P as g, Q as H, R as m, u as c, S as d, T as f, v as B, W as x, X as F, w as G, x as b, y as p, V as U, z as u, A as h, _ as y, B as v, D as V, E as W, Y as j, F as q, Z as K, G as Y, I as k, J as w, K as z, U as Q, L as Z, M as J, N as $, O as aa, $ as sa, am as Ea, a5 as _a, a4 as Ra, a2 as ea, a9 as Ta, a6 as ta, a0 as Aa, a3 as Ca, aa as Oa, ab as ra, ac as Sa, ad as oa, ae as Na, af as ia, ag as Da, ah as Xa, ai as Pa, aj as la, ak as La, a7 as na, a8 as Ma, a1 as Ia, al as ga } from "./extractCssVarName-IHa2pGlF.js";
2
- import { M as ma, f as ca, c as da, e as fa, l as Ba, q as xa, g as Fa, t as Ga, w as ba, p as pa, m as Ua, i as ua, u as ha, v as ya, b as va, k as Va, h as Wa, a as ja, o as qa, r as Ka, d as Ya, s as ka, j as wa, n as za } from "./dom-CwV-xS38.js";
3
- import { i as Za } from "./isUndefined-B5qXrATz.js";
4
- import { i as $a } from "./isVisible-BuGrjvTY.js";
1
+ import { C as E, a as _, b as e, c as R, d as T, e as t, f as A, g as C, h as O, i as r, j as S, k as o, l as i, m as N, H as D, p as X, o as P, t as l, s as n, r as L, q as I, n as M, P as g, Q as H, R as m, u as c, S as d, T as f, v as x, W as B, X as F, w as G, x as b, y as p, V as u, z as U, A as h, _ as v, B as y, D as V, E as q, Y as W, F as j, Z as K, G as Y, I as k, J as w, K as z, U as Q, L as Z, M as J, N as $, O as aa, $ as sa, am as Ea, a5 as _a, a4 as ea, a2 as Ra, a9 as Ta, a6 as ta, a0 as Aa, a3 as Ca, aa as Oa, ab as ra, ac as Sa, ad as oa, ae as ia, af as Na, ag as Da, ah as Xa, ai as Pa, aj as la, ak as na, a7 as La, a8 as Ia, a1 as Ma, al as ga } from "./extractCssVarName-FgXy_HI0.js";
2
+ import { M as ma, h as ca, c as da, f as fa, m as xa, t as Ba, g as Fa, u as Ga, x as ba, q as pa, n as ua, j as Ua, v as ha, w as va, d as ya, l as Va, i as qa, b as Wa, p as ja, r as Ka, a as Ya, e as ka, s as wa, k as za, o as Qa } from "./dom-DzNS5tBj.js";
3
+ import { i as Ja } from "./isUndefined-B5qXrATz.js";
4
+ import { g as as, i as ss } from "./getPageElevations-BuZyM94T.js";
5
5
  export {
6
6
  E as CODE_BACKSPACE,
7
7
  _ as CODE_BREAK,
8
- R as CODE_DELETE,
9
- e as CODE_DOWN,
8
+ e as CODE_DELETE,
9
+ R as CODE_DOWN,
10
10
  T as CODE_END,
11
11
  t as CODE_ENTER,
12
12
  A as CODE_ESC,
@@ -15,38 +15,38 @@ export {
15
15
  r as CODE_PAGEDOWN,
16
16
  S as CODE_PAGEUP,
17
17
  o as CODE_RIGHT,
18
- N as CODE_SPACE,
19
- i as CODE_UP,
18
+ i as CODE_SPACE,
19
+ N as CODE_UP,
20
20
  D as HSL_LIMITS,
21
21
  ma as MutationObs,
22
22
  X as PLACEMENT_BOTTOM_END,
23
23
  P as PLACEMENT_BOTTOM_START,
24
24
  l as PLACEMENT_LEFT_END,
25
- L as PLACEMENT_LEFT_START,
26
- n as PLACEMENT_RIGHT_END,
27
- M as PLACEMENT_RIGHT_START,
28
- I as PLACEMENT_TOP_END,
25
+ n as PLACEMENT_LEFT_START,
26
+ L as PLACEMENT_RIGHT_END,
27
+ I as PLACEMENT_RIGHT_START,
28
+ M as PLACEMENT_TOP_END,
29
29
  g as PLACEMENT_TOP_START,
30
30
  H as RX_ABBREVIATION_FROM_STRING,
31
31
  m as RX_ARRAY_NOTATION,
32
32
  c as RX_BV_PREFIX,
33
33
  d as RX_DATE,
34
34
  f as RX_DATE_SPLIT,
35
- B as RX_DIGITS,
36
- x as RX_ENCODED_COMMA,
35
+ x as RX_DIGITS,
36
+ B as RX_ENCODED_COMMA,
37
37
  F as RX_ENCODE_REVERSE,
38
38
  G as RX_EXTENSION,
39
39
  b as RX_HASH,
40
40
  p as RX_HASH_ID,
41
- U as RX_HREF,
42
- u as RX_HTML_TAGS,
41
+ u as RX_HREF,
42
+ U as RX_HTML_TAGS,
43
43
  h as RX_HYPHENATE,
44
- y as RX_LONG_COLOR,
45
- v as RX_LOWER_UPPER,
44
+ v as RX_LONG_COLOR,
45
+ y as RX_LOWER_UPPER,
46
46
  V as RX_NUMBER,
47
- W as RX_PLUS,
48
- j as RX_QUERY_START,
49
- q as RX_REGEXP_REPLACE,
47
+ q as RX_PLUS,
48
+ W as RX_QUERY_START,
49
+ j as RX_REGEXP_REPLACE,
50
50
  K as RX_SHORT_COLOR,
51
51
  Y as RX_SPACES,
52
52
  k as RX_SPACE_SPLIT,
@@ -63,47 +63,49 @@ export {
63
63
  sa as exclude,
64
64
  Ea as extractCssVarName,
65
65
  _a as flattenDeep,
66
- Ra as generateColorFromString,
67
- ea as generateHslFromString,
66
+ ea as generateColorFromString,
67
+ Ra as generateHslFromString,
68
68
  Ta as getAbbreviation,
69
- Ba as getAttr,
70
- xa as getBCR,
69
+ xa as getAttr,
70
+ Ba as getBCR,
71
71
  Fa as getById,
72
72
  Ga as getCS,
73
73
  ta as getHashOfString,
74
74
  ba as getMaxZIndex,
75
+ as as getPageElevations,
75
76
  pa as getStyle,
76
- Ua as hasAttr,
77
- ua as hasClass,
77
+ ua as hasAttr,
78
+ Ua as hasClass,
78
79
  Aa as hexToRgb,
79
80
  Ca as hslToColorString,
80
81
  Oa as include,
81
82
  ra as isAncestor,
82
83
  Sa as isArray,
83
84
  oa as isDescendant,
84
- Na as isEmpty,
85
- ia as isEqual,
85
+ ia as isEmpty,
86
+ Na as isEqual,
86
87
  Da as isNil,
87
88
  Xa as isNull,
88
89
  Pa as isNumber,
89
90
  la as isObject,
90
- La as isString,
91
- Za as isUndefined,
92
- $a as isVisible,
93
- na as normalize,
91
+ na as isString,
92
+ Ja as isUndefined,
93
+ ss as isVisible,
94
+ La as normalize,
94
95
  ha as offset,
95
- ya as position,
96
- Ma as pxToRem,
97
- va as reflow,
96
+ va as position,
97
+ Ia as pxToRem,
98
+ ya as reflow,
98
99
  Va as removeAttr,
99
- Wa as removeClass,
100
- ja as removeNode,
101
- qa as removeStyle,
100
+ qa as removeClass,
101
+ Wa as removeNode,
102
+ ja as removeStyle,
102
103
  Ka as requestAF,
103
- Ia as rgbToHex,
104
- Ya as select,
105
- ka as selectAll,
106
- wa as setAttr,
107
- za as setStyle,
104
+ Ya as requestIC,
105
+ Ma as rgbToHex,
106
+ ka as select,
107
+ wa as selectAll,
108
+ za as setAttr,
109
+ Qa as setStyle,
108
110
  ga as toArray
109
111
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/ui-components-common",
3
- "version": "20.2.0-beta.5195.0",
3
+ "version": "20.2.0-beta.5208.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -59,7 +59,7 @@
59
59
  "prepare": "pnpm build"
60
60
  },
61
61
  "dependencies": {
62
- "@onereach/styles": "^20.1.2",
62
+ "@onereach/styles": "^20.1.4",
63
63
  "@vueuse/core": "9.13.0",
64
64
  "lodash": "^4.17.21"
65
65
  },
@@ -13,3 +13,4 @@ export * from './useTimeFormat';
13
13
  export * from './useTimeMask';
14
14
  export { default as useToggle } from './useToggle';
15
15
  export * from './useValidationAttributes';
16
+
@@ -1,6 +1,6 @@
1
1
  import { MaybeElementRef } from '@vueuse/core';
2
2
  import { isRef, Ref, ref, watch } from 'vue';
3
- import { isVisible } from '../utils';
3
+ import { getPageElevations } from '../utils';
4
4
 
5
5
  export const useElevation = (
6
6
  element: MaybeElementRef<HTMLElement | undefined>,
@@ -9,15 +9,6 @@ export const useElevation = (
9
9
  const elementRef = isRef(element) ? element : ref(element);
10
10
  const triggerRef = isRef(trigger) ? trigger : ref();
11
11
 
12
- // Functions
13
- function getPageElevations(currentElement: HTMLElement): number[] {
14
- return ([...document.body.querySelectorAll('*')] as HTMLElement[])
15
- .filter(isVisible)
16
- .filter(element => !element.isEqualNode(currentElement))
17
- .map((element) => getComputedStyle(element))
18
- .map((style) => Number(style.zIndex))
19
- .filter((zIndex) => !isNaN(zIndex));
20
- }
21
12
 
22
13
  function setElementElevation(element: HTMLElement): void {
23
14
  element.style.zIndex = String(Math.max(0, ...getPageElevations(element)) + 1);
@@ -20,6 +20,12 @@ export const requestAF = (
20
20
  ((cb: () => void) => setTimeout(cb, 16))
21
21
  ).bind(WINDOW);
22
22
 
23
+ export const requestIC = (
24
+ WINDOW?.requestIdleCallback ||
25
+ // Fallback, but not a true polyfill
26
+ ((cb: () => void) => setTimeout(cb, 1))
27
+ ).bind(WINDOW);
28
+
23
29
  // eslint-disable-next-line no-unsafe-optional-chaining
24
30
  export const cancelAF = (WINDOW?.cancelAnimationFrame || (WINDOW as any)?.mozCancelAnimationFrame).bind(WINDOW);
25
31
 
@@ -0,0 +1,17 @@
1
+ import { isVisible } from './isVisible';
2
+
3
+ export function getPageElevations(currentElement: HTMLElement): number[] {
4
+ const elements = document.body.querySelectorAll('*');
5
+ const elevations: number[] = [];
6
+
7
+ for (const element of elements) {
8
+ if (!element.isEqualNode(currentElement) && isVisible(element as HTMLElement)) {
9
+ const zIndex = getComputedStyle(element, null).getPropertyValue('z-index');
10
+ if (zIndex !== null && zIndex !== 'auto') {
11
+ elevations.push(parseInt(zIndex));
12
+ }
13
+ }
14
+ }
15
+
16
+ return elevations;
17
+ }
@@ -26,3 +26,4 @@ export * from './isUndefined';
26
26
  export * from './isVisible';
27
27
  export * from './toArray';
28
28
  export * from './extractCssVarName';
29
+ export * from './getPageElevations';
@@ -1,3 +1,3 @@
1
- export const isVisible = (element: Element): boolean => {
2
- return element.getClientRects().length > 0;
3
- };
1
+ export function isVisible(element: HTMLElement): boolean {
2
+ return element.offsetWidth > 0 && element.offsetHeight > 0;
3
+ }
@@ -1,4 +0,0 @@
1
- const t = (e) => e.getClientRects().length > 0;
2
- export {
3
- t as i
4
- };
@@ -1,217 +0,0 @@
1
- import { useAttrs as h, computed as o, inject as g, isRef as p, ref as c, watch as m, getCurrentInstance as b, onMounted as R } from "vue";
2
- import { DateFormat as x, TimeFormat as M } from "./types.js";
3
- import { r as C } from "./dom-CwV-xS38.js";
4
- import { i as E } from "./isVisible-BuGrjvTY.js";
5
- import { useMutationObserver as S, useResizeObserver as $, refDebounced as F, useMediaQuery as P } from "@vueuse/core";
6
- import O from "@onereach/styles/screens.json";
7
- import { isVue3 as V } from "@/constants";
8
- import Y from "@onereach/styles/tailwind.config.json";
9
- const _ = () => {
10
- const e = h();
11
- return {
12
- readonly: o(() => e.readonly),
13
- disabled: o(() => e.disabled),
14
- "force-state": o(() => e["force-state"])
15
- };
16
- }, q = Symbol(), L = Symbol(), N = Symbol(), k = (e) => o(() => e.value ?? g(q, x.Short)), G = (e, t) => o(() => typeof e.value != "function" ? new Intl.DateTimeFormat(t.value, {
17
- dateStyle: e.value,
18
- timeZone: "UTC"
19
- }).formatToParts(Date.UTC(1, 0, 1, 1, 1)).reduce((r, n) => {
20
- switch (n.type) {
21
- case "year":
22
- return r + n.value.replace(/^\d{2}$/, "YY").replace(/^\d{4}$/, "YYYY");
23
- case "month":
24
- switch (e.value) {
25
- case "short":
26
- return r + n.value.replace(/^\d{1}$/, "M").replace(/^\d{2}$/, "MM");
27
- case "medium":
28
- return r + "MMM";
29
- case "long":
30
- return r + "MMMM";
31
- default:
32
- throw new Error("[useDateMask]: `format` has an invalid value.");
33
- }
34
- case "day":
35
- return r + n.value.replace(/^\d{1}$/, "D").replace(/^\d{2}$/, "DD");
36
- default:
37
- return r + n.value;
38
- }
39
- }, "") : e.value(void 0, t.value)), J = (e, t) => {
40
- const s = p(e) ? e : c(e), r = p(t) ? t : c();
41
- function n(a) {
42
- return [...document.body.querySelectorAll("*")].filter(E).filter((u) => !u.isEqualNode(a)).map((u) => getComputedStyle(u)).map((u) => Number(u.zIndex)).filter((u) => !isNaN(u));
43
- }
44
- function l(a) {
45
- a.style.zIndex = String(Math.max(0, ...n(a)) + 1);
46
- }
47
- m([s, r], ([a]) => {
48
- a && l(a);
49
- }, { immediate: !0 });
50
- }, K = () => {
51
- const e = h(), t = b();
52
- return o(() => e.id ?? (t == null ? void 0 : t.uid.toString()));
53
- }, X = (e) => o(() => e.value ?? g(L, navigator.language)), ee = (e, t = {}) => {
54
- const { hide: s = !0, threshold: r = 0 } = t, n = p(e) ? e : c(e), l = c([]), a = c([]);
55
- function u() {
56
- const i = n.value;
57
- if (i) {
58
- const d = [...i.children].reduce(({ innerItems: v, outerItems: y }, T) => {
59
- const f = T, { x: D, width: I } = f.getBoundingClientRect(), { x: A, width: w } = i.getBoundingClientRect();
60
- return D + I > A + w + r ? (s && f.style.setProperty("visibility", "hidden"), {
61
- innerItems: v,
62
- outerItems: [...y, f]
63
- }) : (s && f.style.removeProperty("visibility"), {
64
- innerItems: [...v, f],
65
- outerItems: y
66
- });
67
- }, {
68
- innerItems: [],
69
- outerItems: []
70
- });
71
- l.value = d.innerItems, a.value = d.outerItems;
72
- } else
73
- l.value = [], a.value = [];
74
- }
75
- return m(n, u, {
76
- immediate: !0
77
- }), S(n, u, {
78
- childList: !0
79
- }), $(n, () => C(u)), {
80
- innerItems: l,
81
- outerItems: a
82
- };
83
- }, te = (e, t, s = {}) => {
84
- const r = c(e.value ? "open" : "closed");
85
- m(e, (i) => {
86
- r.value = i ? "open" : "closed";
87
- });
88
- const n = F(r, s.debounce ?? 0);
89
- m(n, (i) => {
90
- switch (t("update:state", i), i) {
91
- case "open":
92
- t("open");
93
- break;
94
- case "closed":
95
- t("close");
96
- break;
97
- }
98
- });
99
- function l() {
100
- r.value = "open";
101
- }
102
- function a() {
103
- r.value = "closed";
104
- }
105
- function u() {
106
- r.value = r.value === "open" ? "closed" : "open";
107
- }
108
- return {
109
- state: n,
110
- open: l,
111
- close: a,
112
- toggle: u
113
- };
114
- };
115
- function re(e, t, s = {}) {
116
- const { defaultValue: r } = s;
117
- return r ? o({
118
- get: () => e.value ?? r.value,
119
- set: (n) => {
120
- t("update:modelValue", n);
121
- }
122
- }) : o({
123
- get: () => e.value,
124
- set: (n) => {
125
- t("update:modelValue", n);
126
- }
127
- });
128
- }
129
- function ne(e) {
130
- const t = b(), s = c();
131
- e ? m(e, (u) => {
132
- s.value = u;
133
- }) : R(() => {
134
- if (t) {
135
- const u = t.vnode[V ? "el" : "elm"];
136
- u instanceof Element && (s.value = u);
137
- }
138
- });
139
- const r = o(() => a(s.value) || l.value), n = o(() => !r.value), l = P(`(min-width: ${O.md})`);
140
- function a(u) {
141
- var d;
142
- if (!u)
143
- return !1;
144
- const i = (d = u.getAttribute("force-screen")) == null ? void 0 : d.split(/\s+/);
145
- return i != null && i.some((v) => ["md", "lg", "xl"].includes(v)) ? !0 : a(u.parentElement ?? void 0);
146
- }
147
- return {
148
- isDesktop: r,
149
- isMobile: n
150
- };
151
- }
152
- const ue = () => Y.theme, oe = (e) => o(() => e.value ?? g(N, M.Auto)), se = (e, t) => o(() => typeof e.value != "function" ? new Intl.DateTimeFormat(t.value, {
153
- timeStyle: "short",
154
- hourCycle: e.value !== M.Auto ? e.value : void 0,
155
- timeZone: "UTC"
156
- }).formatToParts(Date.UTC(1, 0, 1, 1, 1)).reduce((r, n) => {
157
- switch (n.type) {
158
- case "hour":
159
- return r + n.value.replace(/^\d{1}$/, "H").replace(/^\d{2}$/, "HH");
160
- case "minute":
161
- return r + n.value.replace(/^\d{1}$/, "M").replace(/^\d{2}$/, "MM");
162
- case "dayPeriod":
163
- return r + "A";
164
- default:
165
- return r + n.value;
166
- }
167
- }, "") : e.value(void 0, t.value));
168
- function ae(e = !1) {
169
- const t = c(e);
170
- function s() {
171
- t.value = !0;
172
- }
173
- function r() {
174
- t.value = !1;
175
- }
176
- function n() {
177
- t.value = !t.value;
178
- }
179
- return {
180
- isActiveToggle: t,
181
- show: s,
182
- hide: r,
183
- toggle: n
184
- };
185
- }
186
- const ie = () => {
187
- const e = h();
188
- return {
189
- required: o(() => e.required),
190
- minlength: o(() => e.minlength),
191
- maxlength: o(() => e.maxlength),
192
- pattern: o(() => e.pattern),
193
- min: o(() => e.min),
194
- max: o(() => e.max),
195
- step: o(() => e.step)
196
- };
197
- };
198
- export {
199
- q as D,
200
- L,
201
- N as T,
202
- _ as a,
203
- k as b,
204
- G as c,
205
- J as d,
206
- K as e,
207
- X as f,
208
- ee as g,
209
- te as h,
210
- re as i,
211
- ne as j,
212
- ue as k,
213
- oe as l,
214
- se as m,
215
- ie as n,
216
- ae as u
217
- };