@alphakits/ui 2.6.2 → 2.7.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,45 +1,56 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
var
|
|
4
|
-
const
|
|
1
|
+
import { jsx as A } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as C, useState as g, useCallback as u, useEffect as k, useContext as w } from "react";
|
|
3
|
+
var x = /* @__PURE__ */ ((e) => (e.DARK = "dark", e.LIGHT = "light", e))(x || {});
|
|
4
|
+
const E = C({
|
|
5
5
|
setTheme: () => {
|
|
6
6
|
},
|
|
7
7
|
currentTheme: void 0
|
|
8
|
-
}),
|
|
9
|
-
|
|
8
|
+
}), v = "theme", i = "theme-styles", _ = "data-theme", b = () => {
|
|
9
|
+
try {
|
|
10
|
+
return window.localStorage?.getItem(v) || void 0;
|
|
11
|
+
} catch {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
}, S = (e) => {
|
|
15
|
+
try {
|
|
16
|
+
window.localStorage?.setItem(v, e);
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
}, j = ({
|
|
20
|
+
children: e,
|
|
10
21
|
themes: c,
|
|
11
|
-
selectedTheme:
|
|
22
|
+
selectedTheme: s
|
|
12
23
|
}) => {
|
|
13
|
-
const [
|
|
14
|
-
document?.documentElement.setAttribute(
|
|
15
|
-
}, []),
|
|
16
|
-
let o = document.getElementById(
|
|
17
|
-
o || (o = document.createElement("style"), o.id =
|
|
18
|
-
|
|
19
|
-
const h =
|
|
20
|
-
Object.keys(h).forEach((
|
|
21
|
-
const
|
|
22
|
-
Object.keys(
|
|
23
|
-
|
|
24
|
+
const [f, y] = g(), n = u((t) => {
|
|
25
|
+
document?.documentElement.setAttribute(_, t), S(t), y(t);
|
|
26
|
+
}, []), a = u((t) => {
|
|
27
|
+
let o = document.getElementById(i), r = "";
|
|
28
|
+
o || (o = document.createElement("style"), o.id = i, document.head.appendChild(o)), Object.keys(t).forEach((m) => {
|
|
29
|
+
r += `html[data-theme='${m}'] {`;
|
|
30
|
+
const h = t[m];
|
|
31
|
+
Object.keys(h).forEach((d) => {
|
|
32
|
+
const T = h[d];
|
|
33
|
+
Object.keys(T).forEach((l) => {
|
|
34
|
+
r += `--color-${d}-${l}: ${T[l]};
|
|
24
35
|
`;
|
|
25
36
|
});
|
|
26
|
-
}),
|
|
27
|
-
`, o.textContent =
|
|
37
|
+
}), r += `}
|
|
38
|
+
`, o.textContent = r;
|
|
28
39
|
});
|
|
29
40
|
}, []);
|
|
30
|
-
return
|
|
31
|
-
const
|
|
32
|
-
n(
|
|
33
|
-
}, [c,
|
|
34
|
-
},
|
|
35
|
-
const { setTheme:
|
|
36
|
-
return { setTheme:
|
|
41
|
+
return k(() => {
|
|
42
|
+
const t = b(), o = window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
43
|
+
n(s || t || o), a(c);
|
|
44
|
+
}, [c, s, n, a]), /* @__PURE__ */ A(E.Provider, { value: { setTheme: n, currentTheme: f }, children: e });
|
|
45
|
+
}, p = () => {
|
|
46
|
+
const { setTheme: e, currentTheme: c } = w(E);
|
|
47
|
+
return { setTheme: e, currentTheme: c };
|
|
37
48
|
};
|
|
38
49
|
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
v as LOACAL_STORAGE_THEME_KEY,
|
|
51
|
+
i as STYLE_TAG_ID,
|
|
52
|
+
x as THEME,
|
|
53
|
+
_ as THEME_DATA_ATTR,
|
|
54
|
+
j as ThemeProvider,
|
|
55
|
+
p as useTheme
|
|
45
56
|
};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { currency as R } from "../data/currency-codes.js";
|
|
2
|
-
import { getCurrencySymbol as
|
|
3
|
-
import { splitAmount as
|
|
4
|
-
const
|
|
5
|
-
const r =
|
|
2
|
+
import { getCurrencySymbol as S } from "../get-currency-symbol/util.js";
|
|
3
|
+
import { splitAmount as _ } from "../split-amount/util.js";
|
|
4
|
+
const C = 3, O = 4, T = "−", f = " ", e = ",", l = (t) => t === "USD" || t === "CHF" || t === "GBP" || t === "CAD" || t === "AUD" || t === "NZD" || t === "ARS" || t === "BRL" || t === "TWD" || t === "MXN" || t === "JPY" || t === "SGD" || t === "TRY" || t === "GEL" || t === "ILS" || t === "UAH", h = (t, o, i) => o ? t ? l(i) ? `${o}${f}${t}` : `${t}${f}${o}` : "" : t, N = (t) => t ? t.length > 2 ? t.slice(0, 2) : t.length < 2 ? `${t}0` : t : "00", U = (t, o, i) => {
|
|
5
|
+
const r = N(t);
|
|
6
6
|
return !i && r === "00" ? null : !i && r[1] === "0" ? r.slice(0, 1) : r === "00" && !o ? null : r;
|
|
7
|
+
}, p = (t) => {
|
|
8
|
+
const o = Math.abs(Math.round(t));
|
|
9
|
+
return [`${Math.floor(o / 100)}`, `${o % 100}`.padStart(2, "0")];
|
|
7
10
|
}, $ = ({
|
|
8
11
|
value: t,
|
|
9
12
|
currency: o,
|
|
10
13
|
showMinorPart: i,
|
|
11
14
|
type: r
|
|
12
15
|
}) => {
|
|
13
|
-
const m = !!o && !!R.CURRENCY_SYMBOLS[o], n = m ?
|
|
16
|
+
const m = !!o && !!R.CURRENCY_SYMBOLS[o], n = m ? S(o) : o;
|
|
14
17
|
if (t === null)
|
|
15
18
|
return {
|
|
16
19
|
majorPart: "",
|
|
@@ -19,19 +22,19 @@ const O = 3, S = 4, T = "−", a = " ", e = ",", l = (t) => t === "USD" || t =
|
|
|
19
22
|
currencySymbol: n,
|
|
20
23
|
formattedWithCurrency: ""
|
|
21
24
|
};
|
|
22
|
-
const [
|
|
23
|
-
`${Math.abs(+
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
),
|
|
25
|
+
const [P, s] = r === "default" ? `${t}`.split(".") : p(t), M = _(
|
|
26
|
+
`${Math.abs(+P || 0)}`,
|
|
27
|
+
C,
|
|
28
|
+
f,
|
|
29
|
+
O
|
|
30
|
+
), a = t < 0 ? T + M : M, A = s ? a + e + s : a;
|
|
28
31
|
return {
|
|
29
|
-
majorPart:
|
|
30
|
-
minorPart:
|
|
32
|
+
majorPart: a,
|
|
33
|
+
minorPart: U(s, i, m),
|
|
31
34
|
currencySymbol: n,
|
|
32
|
-
formatted:
|
|
33
|
-
formattedWithCurrency:
|
|
34
|
-
|
|
35
|
+
formatted: A,
|
|
36
|
+
formattedWithCurrency: h(
|
|
37
|
+
A,
|
|
35
38
|
n || "",
|
|
36
39
|
o
|
|
37
40
|
)
|
|
@@ -39,7 +42,7 @@ const O = 3, S = 4, T = "−", a = " ", e = ",", l = (t) => t === "USD" || t =
|
|
|
39
42
|
};
|
|
40
43
|
export {
|
|
41
44
|
e as AMOUNT_MAJOR_MINOR_PARTS_SEPARATOR,
|
|
42
|
-
|
|
45
|
+
f as THINSP,
|
|
43
46
|
$ as formatAmount,
|
|
44
47
|
l as isCurrencyFirst
|
|
45
48
|
};
|