highsoft-ui 1.0.88 → 1.0.90
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/components/Header/index.js +375 -325
- package/dist/components/Notification/index.d.ts +4 -2
- package/dist/components/Notification/index.js +72 -52
- package/dist/components/ThemeLoader/index.d.ts +2 -0
- package/dist/components/ThemeLoader/index.js +29 -0
- package/dist/highsoft-ui.css +1 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.js +18 -15
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
export type NotificationVariant = '
|
|
1
|
+
export type NotificationVariant = 'brand' | 'success' | 'danger' | 'attention';
|
|
2
2
|
export interface NotificationItem {
|
|
3
3
|
title?: string;
|
|
4
4
|
description?: string;
|
|
5
5
|
url?: string;
|
|
6
|
+
tag?: 'new';
|
|
6
7
|
}
|
|
7
|
-
export declare function Notification({ content, variant, closable, onClose }: {
|
|
8
|
+
export declare function Notification({ id, content, variant, closable, onClose }: {
|
|
9
|
+
id?: string;
|
|
8
10
|
content: NotificationItem | Array<NotificationItem>;
|
|
9
11
|
variant?: NotificationVariant;
|
|
10
12
|
closable?: boolean;
|
|
@@ -1,74 +1,94 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { X as
|
|
4
|
-
import { c as
|
|
5
|
-
import { Button as
|
|
6
|
-
import { Container as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsx as s, jsxs as l, Fragment as w } from "react/jsx-runtime";
|
|
2
|
+
import { useState as d, useEffect as C } from "react";
|
|
3
|
+
import { X as F } from "../../XClose-CCu1vrNS.js";
|
|
4
|
+
import { c as m } from "../../clsx-OuTLNxxd.js";
|
|
5
|
+
import { Button as y } from "../Button/index.js";
|
|
6
|
+
import { Container as A } from "../Container/index.js";
|
|
7
|
+
import { NewTag as B } from "../NewTag/index.js";
|
|
8
|
+
const E = "MhRkRW_active", j = "MhRkRW_attention", H = "MhRkRW_carousel", L = "MhRkRW_close", P = "MhRkRW_container", X = "MhRkRW_content", $ = "MhRkRW_danger", z = "MhRkRW_description", D = "MhRkRW_notification", S = "MhRkRW_slide", U = "MhRkRW_success", q = "MhRkRW_title", G = "MhRkRW_titleText", e = {
|
|
9
|
+
active: E,
|
|
10
|
+
attention: j,
|
|
11
|
+
carousel: H,
|
|
12
|
+
close: L,
|
|
13
|
+
container: P,
|
|
14
|
+
content: X,
|
|
15
|
+
danger: $,
|
|
15
16
|
default: "MhRkRW_default",
|
|
16
|
-
description:
|
|
17
|
-
notification:
|
|
18
|
-
slide:
|
|
19
|
-
success:
|
|
20
|
-
title:
|
|
17
|
+
description: z,
|
|
18
|
+
notification: D,
|
|
19
|
+
slide: S,
|
|
20
|
+
success: U,
|
|
21
|
+
title: q,
|
|
22
|
+
titleText: G
|
|
21
23
|
};
|
|
22
|
-
function
|
|
24
|
+
function et({
|
|
25
|
+
id: v,
|
|
23
26
|
content: c,
|
|
24
|
-
variant:
|
|
25
|
-
closable:
|
|
26
|
-
onClose:
|
|
27
|
+
variant: r = "brand",
|
|
28
|
+
closable: M = !0,
|
|
29
|
+
onClose: g
|
|
27
30
|
}) {
|
|
28
|
-
const n = Array.isArray(c) ? c : [c], [
|
|
31
|
+
const n = Array.isArray(c) ? c : [c], [h, k] = d(
|
|
29
32
|
() => n.length > 1 ? Math.floor(Math.random() * n.length) : 0
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
if (n.length <= 1) return;
|
|
33
|
+
), [W, u] = d(!1), [_, f] = d(!1), R = W || _, i = n[h]?.url, N = i ? "a" : "div";
|
|
34
|
+
C(() => {
|
|
35
|
+
if (n.length <= 1 || R) return;
|
|
33
36
|
const t = window.setInterval(() => {
|
|
34
|
-
|
|
37
|
+
k((o) => (o + 1) % n.length);
|
|
35
38
|
}, 15e3);
|
|
36
39
|
return () => window.clearInterval(t);
|
|
37
|
-
}, [n.length]);
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
}, [n.length, R]);
|
|
41
|
+
const x = () => u(!0), I = (t) => {
|
|
42
|
+
t.currentTarget.contains(t.relatedTarget) || u(!1);
|
|
43
|
+
}, b = () => f(!0), T = () => f(!1), p = (t, o = !0) => {
|
|
44
|
+
const a = /* @__PURE__ */ l(w, { children: [
|
|
45
|
+
t.title && /* @__PURE__ */ l("span", { className: e.title, children: [
|
|
46
|
+
t.tag === "new" && /* @__PURE__ */ s(B, { variant: r, icon: !1 }),
|
|
47
|
+
/* @__PURE__ */ s("span", { className: e.titleText, children: t.title })
|
|
48
|
+
] }),
|
|
49
|
+
t.description && /* @__PURE__ */ s("span", { className: e.description, children: t.description })
|
|
42
50
|
] });
|
|
43
|
-
return
|
|
51
|
+
return /* @__PURE__ */ s("div", { className: e.content, "aria-hidden": !o, children: a });
|
|
44
52
|
};
|
|
45
|
-
return n.length ? /* @__PURE__ */
|
|
46
|
-
|
|
53
|
+
return n.length ? /* @__PURE__ */ s(
|
|
54
|
+
N,
|
|
47
55
|
{
|
|
48
|
-
className:
|
|
56
|
+
className: m(e.notification, e[r]),
|
|
49
57
|
"data-theme": "light",
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
...i ? {
|
|
59
|
+
href: i,
|
|
60
|
+
"data-track": "header-banner",
|
|
61
|
+
"data-track-action": "click",
|
|
62
|
+
"data-track-label": v || i
|
|
63
|
+
} : {},
|
|
64
|
+
onFocus: x,
|
|
65
|
+
onBlur: I,
|
|
66
|
+
onMouseEnter: b,
|
|
67
|
+
onMouseLeave: T,
|
|
68
|
+
children: /* @__PURE__ */ l(A, { className: e.container, children: [
|
|
69
|
+
n.length > 1 ? /* @__PURE__ */ s("div", { className: e.carousel, "aria-live": "polite", children: n.map((t, o) => {
|
|
70
|
+
const a = o === h;
|
|
71
|
+
return /* @__PURE__ */ s(
|
|
54
72
|
"div",
|
|
55
73
|
{
|
|
56
|
-
className:
|
|
57
|
-
"aria-hidden": !
|
|
58
|
-
children:
|
|
74
|
+
className: m(e.slide, { [e.active]: a }),
|
|
75
|
+
"aria-hidden": !a,
|
|
76
|
+
children: p(t, a)
|
|
59
77
|
},
|
|
60
|
-
`${t.title ?? t.description ?? "item"}-${
|
|
78
|
+
`${t.title ?? t.description ?? "item"}-${o}`
|
|
61
79
|
);
|
|
62
|
-
}) }) :
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
}) }) : p(n[0]),
|
|
81
|
+
M && /* @__PURE__ */ s(
|
|
82
|
+
y,
|
|
65
83
|
{
|
|
66
|
-
variant:
|
|
84
|
+
variant: r === "brand" ? "brand" : "transparent",
|
|
67
85
|
size: 100,
|
|
68
86
|
className: e.close,
|
|
69
87
|
"aria-label": "Close notification",
|
|
70
|
-
onClick: () =>
|
|
71
|
-
|
|
88
|
+
onClick: (t) => {
|
|
89
|
+
t.preventDefault(), t.stopPropagation(), g?.();
|
|
90
|
+
},
|
|
91
|
+
children: /* @__PURE__ */ s(F, {})
|
|
72
92
|
}
|
|
73
93
|
)
|
|
74
94
|
] })
|
|
@@ -76,5 +96,5 @@ function q({
|
|
|
76
96
|
) : null;
|
|
77
97
|
}
|
|
78
98
|
export {
|
|
79
|
-
|
|
99
|
+
et as Notification
|
|
80
100
|
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const themeLoaderScript = "(() => {\n const THEME_KEY = 'theme';\n const cookie = document.cookie\n .split('; ')\n .find((row) => row.startsWith(`${THEME_KEY}=`));\n\n if (!cookie) return;\n\n const value = decodeURIComponent(cookie.split('=')[1] || '');\n if (!value) return;\n\n try {\n const current = localStorage.getItem(THEME_KEY);\n if (current !== value) {\n localStorage.setItem(THEME_KEY, value);\n }\n } catch (error) {}\n\n document.documentElement.setAttribute('data-theme', value);\n document.documentElement.classList.add(value);\n})();";
|
|
2
|
+
export declare function ThemeLoader(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
const t = `(() => {
|
|
3
|
+
const THEME_KEY = 'theme';
|
|
4
|
+
const cookie = document.cookie
|
|
5
|
+
.split('; ')
|
|
6
|
+
.find((row) => row.startsWith(\`\${THEME_KEY}=\`));
|
|
7
|
+
|
|
8
|
+
if (!cookie) return;
|
|
9
|
+
|
|
10
|
+
const value = decodeURIComponent(cookie.split('=')[1] || '');
|
|
11
|
+
if (!value) return;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const current = localStorage.getItem(THEME_KEY);
|
|
15
|
+
if (current !== value) {
|
|
16
|
+
localStorage.setItem(THEME_KEY, value);
|
|
17
|
+
}
|
|
18
|
+
} catch (error) {}
|
|
19
|
+
|
|
20
|
+
document.documentElement.setAttribute('data-theme', value);
|
|
21
|
+
document.documentElement.classList.add(value);
|
|
22
|
+
})();`;
|
|
23
|
+
function r() {
|
|
24
|
+
return /* @__PURE__ */ e("script", { dangerouslySetInnerHTML: { __html: t } });
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
r as ThemeLoader,
|
|
28
|
+
t as themeLoaderScript
|
|
29
|
+
};
|