@neut/ui 0.0.1 → 0.0.2
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/README.md +7 -6
- package/dist/components/accordion/Accordion/Accordion.context.d.ts +9 -10
- package/dist/components/accordion/Accordion/Accordion.context.js +21 -25
- package/dist/components/accordion/Accordion/Accordion.d.ts +1 -1
- package/dist/components/accordion/Accordion/Accordion.js +22 -20
- package/dist/components/accordion/Accordion/Accordion.types.d.ts +8 -7
- package/dist/components/accordion/Accordion/index.d.ts +2 -0
- package/dist/components/accordion/Accordion/useAccordion.d.ts +3 -0
- package/dist/components/accordion/Accordion/useAccordion.js +32 -0
- package/dist/components/accordion/AccordionContent/AccordionContent.js +22 -31
- package/dist/components/accordion/AccordionItem/AccordionItem.context.d.ts +5 -7
- package/dist/components/accordion/AccordionItem/AccordionItem.context.js +4 -20
- package/dist/components/accordion/AccordionItem/AccordionItem.d.ts +1 -1
- package/dist/components/accordion/AccordionItem/AccordionItem.js +17 -18
- package/dist/components/accordion/AccordionItem/AccordionItem.types.d.ts +4 -3
- package/dist/components/accordion/AccordionTrigger/AccordionTrigger.js +15 -20
- package/dist/components/scroll-area/ScrollArea/ScrollArea.context.d.ts +1 -1
- package/dist/components/scroll-area/ScrollArea/ScrollArea.js +29 -29
- package/dist/components/sidebar/SidebarMenuButton/SidebarMenuButton.styles.js +6 -5
- package/dist/components/sidebar/SidebarMenuButton/SidebarMenuButton.types.d.ts +1 -1
- package/dist/components/tooltip/TooltipContent/TooltipContent.js +8 -8
- package/dist/components/tooltip/TooltipContent/useTooltipContent.js +28 -28
- package/dist/components/tooltip/TooltipTrigger/TooltipTrigger.d.ts +2 -2
- package/dist/components/tooltip/TooltipTrigger/TooltipTrigger.js +1 -1
- package/dist/components/tooltip/TooltipTrigger/useTooltipTrigger.js +11 -10
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useFontLoader.d.ts +86 -0
- package/dist/hooks/useFontLoader.js +87 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/ui.css +3 -0
- package/package.json +8 -8
- package/dist/styles/animate.css +0 -250
- package/dist/styles/index.css +0 -100
- package/dist/styles/toast.css +0 -745
|
@@ -3,63 +3,63 @@ import { ScrollBar as t } from "../ScrollBar/ScrollBar.js";
|
|
|
3
3
|
import { ScrollAreaContext as n } from "./ScrollArea.context.js";
|
|
4
4
|
import { computeMetrics as r } from "./ScrollArea.utils.js";
|
|
5
5
|
import { className as i, createComponent as a, effect as o, insert as s, mergeProps as c, setAttribute as l, spread as u, template as d, use as f } from "solid-js/web";
|
|
6
|
-
import { createSignal as p, onCleanup as m,
|
|
6
|
+
import { createSignal as p, onCleanup as m, splitProps as h } from "solid-js";
|
|
7
7
|
//#region src/components/scroll-area/ScrollArea/ScrollArea.tsx
|
|
8
|
-
var
|
|
9
|
-
let
|
|
8
|
+
var g = /* @__PURE__ */ d("<div data-slot=scroll-area-viewport role=region>"), _ = /* @__PURE__ */ d("<div data-slot=scroll-area>"), v = (d) => {
|
|
9
|
+
let v, [y, b] = h(d, [
|
|
10
10
|
"orientation",
|
|
11
11
|
"class",
|
|
12
12
|
"classList",
|
|
13
13
|
"children",
|
|
14
14
|
"aria-label"
|
|
15
|
-
]), [
|
|
15
|
+
]), [x, S] = p(!1), [C, w] = p(null), [T, E] = p({
|
|
16
16
|
thumbRatio: 1,
|
|
17
17
|
thumbOffset: 0,
|
|
18
18
|
scrollable: !1
|
|
19
|
-
}), [
|
|
19
|
+
}), [D, O] = p({
|
|
20
20
|
thumbRatio: 1,
|
|
21
21
|
thumbOffset: 0,
|
|
22
22
|
scrollable: !1
|
|
23
23
|
});
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
e && (D(r(e.clientHeight, e.scrollTop, e.scrollHeight)), k(r(e.clientWidth, e.scrollLeft, e.scrollWidth)));
|
|
24
|
+
function k(e) {
|
|
25
|
+
E(r(e.clientHeight, e.scrollTop, e.scrollHeight)), O(r(e.clientWidth, e.scrollLeft, e.scrollWidth));
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let e = new ResizeObserver(
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
function A(e) {
|
|
28
|
+
v = e, k(e);
|
|
29
|
+
let t = () => k(e), n = new ResizeObserver(t);
|
|
30
|
+
n.observe(e), e.firstElementChild && n.observe(e.firstElementChild), e.addEventListener("scroll", t, { passive: !0 }), m(() => {
|
|
31
|
+
n.disconnect(), e.removeEventListener("scroll", t);
|
|
33
32
|
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
}
|
|
34
|
+
return (() => {
|
|
35
|
+
var r = _();
|
|
36
|
+
return r.addEventListener("mouseleave", () => S(!1)), r.addEventListener("mouseenter", () => S(!0)), u(r, c({ get class() {
|
|
37
|
+
return e("relative", y.class);
|
|
38
|
+
} }, b), !1, !0), s(r, a(n.Provider, {
|
|
39
39
|
value: {
|
|
40
|
-
hovering:
|
|
41
|
-
viewportRef: () =>
|
|
42
|
-
dragging:
|
|
43
|
-
setDragging:
|
|
44
|
-
vertical:
|
|
45
|
-
horizontal:
|
|
40
|
+
hovering: x,
|
|
41
|
+
viewportRef: () => v,
|
|
42
|
+
dragging: C,
|
|
43
|
+
setDragging: w,
|
|
44
|
+
vertical: T,
|
|
45
|
+
horizontal: D
|
|
46
46
|
},
|
|
47
47
|
get children() {
|
|
48
48
|
return [(() => {
|
|
49
|
-
var t =
|
|
50
|
-
return typeof n == "function" ? f(n, t) :
|
|
51
|
-
var r =
|
|
49
|
+
var t = g(), n = A;
|
|
50
|
+
return typeof n == "function" ? f(n, t) : A = t, s(t, () => y.children), o((n) => {
|
|
51
|
+
var r = y["aria-label"] ?? "Scrollable content", a = e("size-full rounded-[inherit] outline-none", "[scrollbar-width:none] [&::-webkit-scrollbar]:hidden", "focus-visible:ring-2 focus-visible:ring-offset-1", "focus-visible:ring-neutral-400/70 dark:focus-visible:ring-neutral-500/70", y.orientation === "vertical" ? "overflow-y-scroll overflow-x-hidden" : y.orientation === "horizontal" ? "overflow-x-scroll overflow-y-hidden" : "overflow-scroll");
|
|
52
52
|
return r !== n.e && l(t, "aria-label", n.e = r), a !== n.t && i(t, n.t = a), n;
|
|
53
53
|
}, {
|
|
54
54
|
e: void 0,
|
|
55
55
|
t: void 0
|
|
56
56
|
}), t;
|
|
57
57
|
})(), a(t, { get orientation() {
|
|
58
|
-
return
|
|
58
|
+
return y.orientation;
|
|
59
59
|
} })];
|
|
60
60
|
}
|
|
61
61
|
})), r;
|
|
62
62
|
})();
|
|
63
63
|
};
|
|
64
64
|
//#endregion
|
|
65
|
-
export {
|
|
65
|
+
export { v as ScrollArea };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { clsx as e } from "../../../lib/utils/clsx.js";
|
|
2
|
+
import { cva as t } from "class-variance-authority";
|
|
2
3
|
//#region src/components/sidebar/SidebarMenuButton/SidebarMenuButton.styles.ts
|
|
3
|
-
var
|
|
4
|
+
var n = t(e("peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:font-medium [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate", "ring-neutral-400 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100 active:text-neutral-900 data-open:hover:bg-neutral-100 data-open:hover:text-neutral-900 data-[active=true]:bg-neutral-100 data-[active=true]:text-neutral-900", "dark:ring-neutral-500 dark:hover:bg-neutral-800 dark:hover:text-neutral-50 dark:active:bg-neutral-800 dark:active:text-neutral-50 dark:data-open:hover:bg-neutral-800 dark:data-open:hover:text-neutral-50 dark:data-[active=true]:bg-neutral-800 dark:data-[active=true]:text-neutral-50"), {
|
|
4
5
|
variants: {
|
|
5
6
|
variant: {
|
|
6
|
-
ghost: "hover:bg-
|
|
7
|
-
outline: "bg-
|
|
7
|
+
ghost: "hover:bg-neutral-100 hover:text-neutral-900 dark:hover:bg-neutral-800 dark:hover:text-neutral-50",
|
|
8
|
+
outline: e("bg-white shadow-[0_0_0_1px_(var(--color-neutral-200)] hover:bg-neutral-100 hover:text-neutral-900 hover:shadow-[0_0_0_1px_var(--color-neutral-100)]", "dark:bg-neutral-950 dark:shadow-[0_0_0_1px_hsl(var(--sidebar-border))] dark:hover:bg-neutral-800 dark:hover:text-neutral-50 dark:hover:shadow-[0_0_0_1px_--alpha(var(--color-white) / 10%)]]")
|
|
8
9
|
},
|
|
9
10
|
size: {
|
|
10
11
|
md: "h-8 text-sm",
|
|
@@ -18,4 +19,4 @@ var t = e("peer/menu-button group/menu-button flex w-full items-center gap-2 ove
|
|
|
18
19
|
}
|
|
19
20
|
});
|
|
20
21
|
//#endregion
|
|
21
|
-
export {
|
|
22
|
+
export { n as sidebarMenuButtonVariants };
|
|
@@ -6,4 +6,4 @@ import { ValidComponent } from 'solid-js';
|
|
|
6
6
|
export type SidebarMenuButtonProps<T extends ValidComponent> = PolymorphicProps<T, BaseProps & {
|
|
7
7
|
isActive?: boolean;
|
|
8
8
|
tooltip?: string | TooltipContentProps;
|
|
9
|
-
} & VariantProps<typeof sidebarMenuButtonVariants
|
|
9
|
+
} & VariantProps<typeof sidebarMenuButtonVariants>>;
|
|
@@ -6,7 +6,7 @@ import { Portal as i, createComponent as a, insert as o, mergeProps as s, spread
|
|
|
6
6
|
import { Show as d, mergeProps as f, splitProps as p } from "solid-js";
|
|
7
7
|
//#region src/components/tooltip/TooltipContent/TooltipContent.tsx
|
|
8
8
|
var m = /* @__PURE__ */ l("<div data-slot=tooltip-content role=tooltip>"), h = (l) => {
|
|
9
|
-
let
|
|
9
|
+
let h = t(), [g, _] = p(f({
|
|
10
10
|
side: "top",
|
|
11
11
|
align: "center",
|
|
12
12
|
alignOffset: 0,
|
|
@@ -19,7 +19,7 @@ var m = /* @__PURE__ */ l("<div data-slot=tooltip-content role=tooltip>"), h = (
|
|
|
19
19
|
"class",
|
|
20
20
|
"classList",
|
|
21
21
|
"children"
|
|
22
|
-
]),
|
|
22
|
+
]), v, { shouldRender: y, position: b } = r(() => v, () => g);
|
|
23
23
|
return a(d, {
|
|
24
24
|
get when() {
|
|
25
25
|
return y();
|
|
@@ -29,10 +29,10 @@ var m = /* @__PURE__ */ l("<div data-slot=tooltip-content role=tooltip>"), h = (
|
|
|
29
29
|
var t = m(), r = v;
|
|
30
30
|
return typeof r == "function" ? u(r, t) : v = t, c(t, s({
|
|
31
31
|
get "data-open"() {
|
|
32
|
-
return
|
|
32
|
+
return h.open() ? "" : void 0;
|
|
33
33
|
},
|
|
34
34
|
get "data-closed"() {
|
|
35
|
-
return
|
|
35
|
+
return h.open() ? void 0 : "";
|
|
36
36
|
},
|
|
37
37
|
get "data-align"() {
|
|
38
38
|
return b.align;
|
|
@@ -41,10 +41,10 @@ var m = /* @__PURE__ */ l("<div data-slot=tooltip-content role=tooltip>"), h = (
|
|
|
41
41
|
return b.side;
|
|
42
42
|
},
|
|
43
43
|
get id() {
|
|
44
|
-
return
|
|
44
|
+
return h.contentId;
|
|
45
45
|
},
|
|
46
46
|
get class() {
|
|
47
|
-
return e("fixed z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-neutral-950 dark:bg-neutral-50 px-3 py-1.5 text-xs text-white dark:text-neutral-950 has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
47
|
+
return e("fixed z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-neutral-950 dark:bg-neutral-50 px-3 py-1.5 text-xs text-white dark:text-neutral-950 has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", g.class);
|
|
48
48
|
},
|
|
49
49
|
get style() {
|
|
50
50
|
return {
|
|
@@ -52,10 +52,10 @@ var m = /* @__PURE__ */ l("<div data-slot=tooltip-content role=tooltip>"), h = (
|
|
|
52
52
|
left: `${b.left}px`
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
},
|
|
55
|
+
}, _), !1, !0), o(t, a(n.Provider, {
|
|
56
56
|
value: { side: () => b.side },
|
|
57
57
|
get children() {
|
|
58
|
-
return
|
|
58
|
+
return g.children;
|
|
59
59
|
}
|
|
60
60
|
})), t;
|
|
61
61
|
} });
|
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
import { useTooltipContext as e } from "../Tooltip/Tooltip.context.js";
|
|
2
2
|
import { computePosition as t } from "./TooltipContent.utils.js";
|
|
3
|
-
import { createEffect as n, createSignal as r, onCleanup as i, onMount as a } from "solid-js";
|
|
4
|
-
import { createStore as
|
|
3
|
+
import { createEffect as n, createSignal as r, onCleanup as i, onMount as a, untrack as o } from "solid-js";
|
|
4
|
+
import { createStore as s } from "solid-js/store";
|
|
5
5
|
//#region src/components/tooltip/TooltipContent/useTooltipContent.ts
|
|
6
|
-
var
|
|
7
|
-
let { open:
|
|
6
|
+
var c = (c, l) => {
|
|
7
|
+
let { open: u, triggerRef: d } = e(), [f, p] = s({
|
|
8
8
|
top: -9999,
|
|
9
9
|
left: -9999,
|
|
10
|
-
side:
|
|
11
|
-
align:
|
|
12
|
-
}), [
|
|
13
|
-
let e =
|
|
14
|
-
if (!e || !
|
|
15
|
-
let { top:
|
|
16
|
-
|
|
17
|
-
top:
|
|
18
|
-
left:
|
|
19
|
-
side:
|
|
20
|
-
align:
|
|
10
|
+
side: o(() => l().side),
|
|
11
|
+
align: o(() => l().align)
|
|
12
|
+
}), [m, h] = r(o(u)), g, _ = () => {
|
|
13
|
+
let e = d(), n = c();
|
|
14
|
+
if (!e || !n) return;
|
|
15
|
+
let { top: r, left: i, side: a, align: o } = t(e, n, l().side, l().align, l().alignOffset, l().sideOffset);
|
|
16
|
+
p({
|
|
17
|
+
top: r,
|
|
18
|
+
left: i,
|
|
19
|
+
side: a,
|
|
20
|
+
align: o
|
|
21
21
|
});
|
|
22
|
-
},
|
|
22
|
+
}, v = () => {
|
|
23
23
|
requestAnimationFrame(() => {
|
|
24
|
-
requestAnimationFrame(
|
|
24
|
+
requestAnimationFrame(_);
|
|
25
25
|
});
|
|
26
26
|
};
|
|
27
27
|
return a(() => {
|
|
28
|
-
window.addEventListener("scroll",
|
|
28
|
+
window.addEventListener("scroll", _), window.addEventListener("resize", _), v();
|
|
29
29
|
}), i(() => {
|
|
30
|
-
window.removeEventListener("scroll",
|
|
30
|
+
window.removeEventListener("scroll", _), window.removeEventListener("resize", _);
|
|
31
31
|
}), n(() => {
|
|
32
|
-
if (
|
|
32
|
+
if (u()) v(), h(!0);
|
|
33
33
|
else {
|
|
34
|
-
let e =
|
|
34
|
+
let e = c();
|
|
35
35
|
if (e) {
|
|
36
36
|
e.setAttribute("data-closed", ""), e.removeAttribute("data-open");
|
|
37
37
|
let t = () => {
|
|
38
|
-
|
|
38
|
+
h(!1), e.removeEventListener("animationend", t), e.removeEventListener("transitionend", t);
|
|
39
39
|
};
|
|
40
|
-
e.addEventListener("animationend", t), e.addEventListener("transitionend", t),
|
|
41
|
-
} else
|
|
40
|
+
e.addEventListener("animationend", t), e.addEventListener("transitionend", t), g = setTimeout(() => h(!1), 300);
|
|
41
|
+
} else h(!1);
|
|
42
42
|
}
|
|
43
43
|
}), i(() => {
|
|
44
|
-
|
|
44
|
+
g && clearTimeout(g);
|
|
45
45
|
}), {
|
|
46
|
-
shouldRender:
|
|
47
|
-
position:
|
|
46
|
+
shouldRender: m,
|
|
47
|
+
position: f
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
//#endregion
|
|
51
|
-
export {
|
|
51
|
+
export { c as useTooltipContent };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ParentProps } from 'solid-js';
|
|
2
|
-
export declare const TooltipTrigger: (props: ParentProps) =>
|
|
1
|
+
import { JSXElement, ParentProps } from 'solid-js';
|
|
2
|
+
export declare const TooltipTrigger: (props: ParentProps) => JSXElement;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { useTooltipContext as e } from "../Tooltip/Tooltip.context.js";
|
|
2
|
-
import {
|
|
2
|
+
import { createEffect as t, onCleanup as n } from "solid-js";
|
|
3
3
|
//#region src/components/tooltip/TooltipTrigger/useTooltipTrigger.ts
|
|
4
4
|
var r = (r) => {
|
|
5
|
-
let { setOpen: i, openDelay: a, closeDelay: o, setTriggerRef: s } = e(), c, l, u = () => {
|
|
5
|
+
let { setOpen: i, openDelay: a, closeDelay: o, setTriggerRef: s } = e(), c, l, u, d = () => {
|
|
6
6
|
clearTimeout(l), c = setTimeout(() => i(!0), a);
|
|
7
|
-
},
|
|
7
|
+
}, f = () => {
|
|
8
8
|
clearTimeout(c), l = setTimeout(() => i(!1), o);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
e
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
};
|
|
10
|
+
t(() => {
|
|
11
|
+
if (u = r(), !u) return;
|
|
12
|
+
let e = () => d(), t = () => f(), i = () => f();
|
|
13
|
+
s(u), u.addEventListener("mouseenter", e), u.addEventListener("mouseleave", t), u.addEventListener("mousedown", i), u.addEventListener("blur", t), n(() => {
|
|
14
|
+
u.removeEventListener("mouseenter", e), u.removeEventListener("mouseleave", t), u.removeEventListener("mousedown", i), u.removeEventListener("blur", t);
|
|
15
|
+
});
|
|
16
|
+
}), n(() => {
|
|
16
17
|
clearTimeout(c), clearTimeout(l);
|
|
17
18
|
});
|
|
18
19
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useFontLoader';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
declare const FONT_MAP: {
|
|
2
|
+
readonly en: {
|
|
3
|
+
readonly family: "Inter";
|
|
4
|
+
readonly weights: "400;500;700";
|
|
5
|
+
};
|
|
6
|
+
readonly fr: {
|
|
7
|
+
readonly family: "Inter";
|
|
8
|
+
readonly weights: "400;500;700";
|
|
9
|
+
};
|
|
10
|
+
readonly de: {
|
|
11
|
+
readonly family: "Inter";
|
|
12
|
+
readonly weights: "400;500;700";
|
|
13
|
+
};
|
|
14
|
+
readonly ru: {
|
|
15
|
+
readonly family: "Noto+Sans";
|
|
16
|
+
readonly weights: "400;500;700";
|
|
17
|
+
};
|
|
18
|
+
readonly "zh-hans": {
|
|
19
|
+
readonly family: "Noto+Sans+SC";
|
|
20
|
+
readonly weights: "400;500;700";
|
|
21
|
+
};
|
|
22
|
+
readonly "zh-hant": {
|
|
23
|
+
readonly family: "Noto+Sans+TC";
|
|
24
|
+
readonly weights: "400;500;700";
|
|
25
|
+
};
|
|
26
|
+
readonly ja: {
|
|
27
|
+
readonly family: "Noto+Sans+JP";
|
|
28
|
+
readonly weights: "400;500;700";
|
|
29
|
+
};
|
|
30
|
+
readonly ko: {
|
|
31
|
+
readonly family: "Noto+Sans+KR";
|
|
32
|
+
readonly weights: "400;500;700";
|
|
33
|
+
};
|
|
34
|
+
readonly hi: {
|
|
35
|
+
readonly family: "Noto+Sans+Devanagari";
|
|
36
|
+
readonly weights: "400;500;700";
|
|
37
|
+
};
|
|
38
|
+
readonly th: {
|
|
39
|
+
readonly family: "Noto+Sans+Thai";
|
|
40
|
+
readonly weights: "400;500;700";
|
|
41
|
+
};
|
|
42
|
+
readonly bn: {
|
|
43
|
+
readonly family: "Noto+Sans+Bengali";
|
|
44
|
+
readonly weights: "400;500;700";
|
|
45
|
+
};
|
|
46
|
+
readonly ar: {
|
|
47
|
+
readonly family: "Noto+Sans+Arabic";
|
|
48
|
+
readonly weights: "400;500;700";
|
|
49
|
+
};
|
|
50
|
+
readonly he: {
|
|
51
|
+
readonly family: "Noto+Sans+Hebrew";
|
|
52
|
+
readonly weights: "400;500;700";
|
|
53
|
+
};
|
|
54
|
+
readonly fa: {
|
|
55
|
+
readonly family: "Noto+Sans+Arabic";
|
|
56
|
+
readonly weights: "400;500;700";
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export type Lang = keyof typeof FONT_MAP;
|
|
60
|
+
export interface UseFontLoaderOptions {
|
|
61
|
+
/**
|
|
62
|
+
* 要加载的字体对应的语言
|
|
63
|
+
*
|
|
64
|
+
* 默认为`en`
|
|
65
|
+
*/
|
|
66
|
+
langs?: Lang | Lang[];
|
|
67
|
+
/**
|
|
68
|
+
* 指定 data-lang 写入的目标元素。
|
|
69
|
+
* - 传入 ref:仅在该元素上生效,适合局部语言切换。
|
|
70
|
+
* - 不传(undefined):写入 ,全局生效。
|
|
71
|
+
* 卸载时自动恢复目标元素的原始 data-lang 值。
|
|
72
|
+
*
|
|
73
|
+
* apply 为 false 时此选项无效。
|
|
74
|
+
*/
|
|
75
|
+
targetRef?: HTMLElement;
|
|
76
|
+
/**
|
|
77
|
+
* 是否将 data-lang 写入目标元素以应用字体样式。
|
|
78
|
+
* - true(默认):写入 data-lang,字体立即生效。
|
|
79
|
+
* - false:仅预加载字体资源,不修改任何 DOM,
|
|
80
|
+
* 适合提前预热用户可能切换到的语言字体。
|
|
81
|
+
* @default
|
|
82
|
+
*/
|
|
83
|
+
apply?: boolean;
|
|
84
|
+
}
|
|
85
|
+
export declare function useFontLoader(options?: UseFontLoaderOptions): void;
|
|
86
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createEffect as e, onCleanup as t } from "solid-js";
|
|
2
|
+
//#region src/hooks/useFontLoader.ts
|
|
3
|
+
var n = {
|
|
4
|
+
en: {
|
|
5
|
+
family: "Inter",
|
|
6
|
+
weights: "400;500;700"
|
|
7
|
+
},
|
|
8
|
+
fr: {
|
|
9
|
+
family: "Inter",
|
|
10
|
+
weights: "400;500;700"
|
|
11
|
+
},
|
|
12
|
+
de: {
|
|
13
|
+
family: "Inter",
|
|
14
|
+
weights: "400;500;700"
|
|
15
|
+
},
|
|
16
|
+
ru: {
|
|
17
|
+
family: "Noto+Sans",
|
|
18
|
+
weights: "400;500;700"
|
|
19
|
+
},
|
|
20
|
+
"zh-hans": {
|
|
21
|
+
family: "Noto+Sans+SC",
|
|
22
|
+
weights: "400;500;700"
|
|
23
|
+
},
|
|
24
|
+
"zh-hant": {
|
|
25
|
+
family: "Noto+Sans+TC",
|
|
26
|
+
weights: "400;500;700"
|
|
27
|
+
},
|
|
28
|
+
ja: {
|
|
29
|
+
family: "Noto+Sans+JP",
|
|
30
|
+
weights: "400;500;700"
|
|
31
|
+
},
|
|
32
|
+
ko: {
|
|
33
|
+
family: "Noto+Sans+KR",
|
|
34
|
+
weights: "400;500;700"
|
|
35
|
+
},
|
|
36
|
+
hi: {
|
|
37
|
+
family: "Noto+Sans+Devanagari",
|
|
38
|
+
weights: "400;500;700"
|
|
39
|
+
},
|
|
40
|
+
th: {
|
|
41
|
+
family: "Noto+Sans+Thai",
|
|
42
|
+
weights: "400;500;700"
|
|
43
|
+
},
|
|
44
|
+
bn: {
|
|
45
|
+
family: "Noto+Sans+Bengali",
|
|
46
|
+
weights: "400;500;700"
|
|
47
|
+
},
|
|
48
|
+
ar: {
|
|
49
|
+
family: "Noto+Sans+Arabic",
|
|
50
|
+
weights: "400;500;700"
|
|
51
|
+
},
|
|
52
|
+
he: {
|
|
53
|
+
family: "Noto+Sans+Hebrew",
|
|
54
|
+
weights: "400;500;700"
|
|
55
|
+
},
|
|
56
|
+
fa: {
|
|
57
|
+
family: "Noto+Sans+Arabic",
|
|
58
|
+
weights: "400;500;700"
|
|
59
|
+
}
|
|
60
|
+
}, r = /* @__PURE__ */ new Set();
|
|
61
|
+
function i(e) {
|
|
62
|
+
return e.filter((e) => e in n ? !0 : (process.env.NODE_ENV !== "production" && console.warn(`[useFontLoader] unsupported lang: "${e}". Supported values: ${Object.keys(n).join(", ")}`), !1));
|
|
63
|
+
}
|
|
64
|
+
function a(e) {
|
|
65
|
+
let t = e.filter((e) => !r.has(n[e].family));
|
|
66
|
+
if (t.length === 0) return;
|
|
67
|
+
let i = [...new Set(t.map((e) => {
|
|
68
|
+
let { family: t, weights: r } = n[e];
|
|
69
|
+
return `family=${t}:wght@${r}`;
|
|
70
|
+
}))], a = document.createElement("link");
|
|
71
|
+
a.rel = "stylesheet", a.href = `https://fonts.googleapis.com/css2?${i.join("&")}&display=swap`, document.head.appendChild(a);
|
|
72
|
+
for (let e of t) r.add(n[e].family);
|
|
73
|
+
}
|
|
74
|
+
function o(n) {
|
|
75
|
+
let { langs: r = "en", targetRef: o = document.documentElement, apply: s = !0 } = n ?? {}, c = i(Array.isArray(r) ? r : [r]);
|
|
76
|
+
e(() => {
|
|
77
|
+
a(c);
|
|
78
|
+
}), e(() => {
|
|
79
|
+
if (!s || c.length === 0) return;
|
|
80
|
+
let e = o ?? document.documentElement, n = c[0], r = e.getAttribute("data-lang");
|
|
81
|
+
e.setAttribute("data-lang", n), t(() => {
|
|
82
|
+
r === null ? e.removeAttribute("data-lang") : e.setAttribute("data-lang", r);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { o as useFontLoader };
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* empty css */
|
|
1
2
|
import { Accordion as e } from "./components/accordion/Accordion/Accordion.js";
|
|
2
3
|
import { AccordionContent as t } from "./components/accordion/AccordionContent/AccordionContent.js";
|
|
3
4
|
import { AccordionItem as n } from "./components/accordion/AccordionItem/AccordionItem.js";
|
|
@@ -101,4 +102,5 @@ import { toast as Ke } from "./components/toast/state.js";
|
|
|
101
102
|
import { useSonner as qe } from "./components/toast/hooks.js";
|
|
102
103
|
import { Toast as Je } from "./components/toast/components/Toast.js";
|
|
103
104
|
import { Toaster as Ye } from "./components/toast/components/Toaster.js";
|
|
104
|
-
|
|
105
|
+
import { useFontLoader as Xe } from "./hooks/useFontLoader.js";
|
|
106
|
+
export { e as Accordion, t as AccordionContent, n as AccordionItem, r as AccordionTrigger, i as AspectRatio, a as Avatar, c as AvatarBadge, s as AvatarFallback, l as AvatarGroup, u as AvatarGroupCount, o as AvatarImage, d as Badge, f as Button, p as ButtonGroup, h as ButtonGroupSeparator, g as ButtonGroupText, _ as Card, v as CardAction, y as CardContent, b as CardDescription, x as CardFooter, S as CardHeader, C as CardTitle, w as Carousel, T as CarouselContent, E as CarouselDots, D as CarouselItem, O as CarouselNext, k as CarouselPrevious, N as Field, P as FieldContent, z as FieldDescription, R as FieldError, M as FieldGroup, I as FieldLabel, j as FieldLegend, B as FieldSeparator, A as FieldSet, L as FieldTitle, V as Image, H as Input, U as InputGroup, W as InputGroupAddon, G as InputGroupButton, q as InputGroupInput, K as InputGroupText, Y as InputGroupTextarea, Q as Item, re as ItemActions, ee as ItemContent, ne as ItemDescription, ae as ItemFooter, X as ItemGroup, ie as ItemHeader, $ as ItemMedia, Z as ItemSeparator, te as ItemTitle, oe as Kbd, se as KbdGroup, F as Label, ce as Pagination, le as PaginationContent, me as PaginationEllipsis, ue as PaginationItem, de as PaginationLink, pe as PaginationNext, fe as PaginationPrevious, ge as ScrollArea, he as ScrollBar, m as Separator, ve as Sidebar, Ee as SidebarContent, we as SidebarFooter, De as SidebarGroup, ke as SidebarGroupAction, Ae as SidebarGroupContent, Oe as SidebarGroupLabel, Ce as SidebarHeader, Se as SidebarInput, xe as SidebarInset, je as SidebarMenu, Re as SidebarMenuBadge, Le as SidebarMenuButton, Me as SidebarMenuItem, Be as SidebarMenuSkeleton, Ve as SidebarMenuSub, Ue as SidebarMenuSubButton, He as SidebarMenuSubItem, _e as SidebarProvider, be as SidebarRail, Te as SidebarSeparator, ye as SidebarTrigger, ze as Skeleton, We as Spinner, Ge as Switch, J as Textarea, Je as Toast, Ye as Toaster, Ne as Tooltip, Ie as TooltipArrow, Fe as TooltipContent, Pe as TooltipTrigger, Ke as toast, Xe as useFontLoader, qe as useSonner };
|