wimui 0.60.1 → 0.62.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.
- package/dist/components/_internal/useInlineFloating.cjs +1 -1
- package/dist/components/_internal/useInlineFloating.js +2 -2
- package/dist/components/ai/ModelSelector/ModelSelector.cjs +1 -1
- package/dist/components/ai/ModelSelector/ModelSelector.js +72 -69
- package/dist/components/form/SplitButton/SplitButton.cjs +1 -1
- package/dist/components/form/SplitButton/SplitButton.js +35 -31
- package/dist/components/navigation/Anchor/Anchor.cjs +1 -1
- package/dist/components/navigation/Anchor/Anchor.d.ts +5 -1
- package/dist/components/navigation/Anchor/Anchor.js +32 -29
- package/dist/components/navigation/CommandPalette/CommandPalette.cjs +1 -1
- package/dist/components/navigation/CommandPalette/CommandPalette.d.ts +5 -1
- package/dist/components/navigation/CommandPalette/CommandPalette.js +15 -13
- package/dist/components/navigation/Menubar/Menubar.cjs +1 -1
- package/dist/components/navigation/Menubar/Menubar.js +102 -92
- package/dist/components/navigation/Menubar/menubar.module.cjs +1 -1
- package/dist/components/navigation/Menubar/menubar.module.js +1 -1
- package/dist/components/overlay/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/overlay/BottomSheet/BottomSheet.d.ts +7 -1
- package/dist/components/overlay/BottomSheet/BottomSheet.js +7 -6
- package/dist/components/overlay/HoverCard/HoverCard.cjs +1 -1
- package/dist/components/overlay/HoverCard/HoverCard.js +49 -43
- package/dist/components/overlay/HoverCard/hover-card.module.cjs +1 -1
- package/dist/components/overlay/HoverCard/hover-card.module.js +1 -1
- package/dist/llms-full.txt +3 -1
- package/dist/llms.txt +1 -1
- package/dist/styles.css +1 -1
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +2 -2
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
let e=require("react");var t=typeof window<`u`?e.useLayoutEffect:e.useEffect,n=10,r=8,i=`--wim-floating-shift-x`,a=e=>{let t=e.viewportHeight-e.referenceBottom,n=e.referenceTop;return e.floatingHeight+r>t&&n>t?`top`:`bottom`},o=(e,t,r)=>{if(t>r){let i=r-n-t;return e+i<0?-e:i}if(e<0){let i=n-e;return t+i>r?r-t:i}return 0},s=({open:n})=>{let[r,s]=(0,e.useState)(null),[c,l]=(0,e.useState)(null),[u,d]=(0,e.useState)({side:`bottom`,shiftX:0}),f=(0,e.useCallback)(()=>{if(!r||!c)return;let e=c.ownerDocument.documentElement,t=r.getBoundingClientRect(),n=c.getBoundingClientRect(),s=a({referenceTop:t.top,referenceBottom:t.bottom,floatingHeight:n.height,viewportHeight:e.clientHeight}),l=parseFloat(c.style.getPropertyValue(i))||0,u=Math.round(o(n.left-l,n.right-l,e.clientWidth));d(e=>e.side===s&&e.shiftX===u?e:{side:s,shiftX:u})},[r,c]);t(()=>{if(!n||!r||!c)return;f();let e=c.ownerDocument.defaultView;if(!e)return;e.addEventListener(`resize`,f),e.addEventListener(`scroll`,f,!0);let t=typeof ResizeObserver<`u`?new ResizeObserver(f):null;return t?.observe(c),t?.observe(r),()=>{e.removeEventListener(`resize`,f),e.removeEventListener(`scroll`,f,!0),t?.disconnect()}},[n,r,c,f]);let p=n?u.side:`bottom`,m=n?u.shiftX:0;return{setReference:s,setFloating:l,floatingProps:{"data-side":p,style:m?{[i]:`${m}px`}:void 0}}};exports.computeInlineShift=o,exports.computeInlineSide=a,exports.useInlineFloating=s;
|
|
2
|
+
let e=require("react");var t=typeof window<`u`?e.useLayoutEffect:e.useEffect,n=10,r=8,i=`--wim-floating-shift-x`,a=e=>{let t=e.viewportHeight-e.referenceBottom,n=e.referenceTop;return e.floatingHeight+r>t&&n>t?`top`:`bottom`},o=(e,t,r)=>{if(t>r){let i=r-n-t;return e+i<0?-e:i}if(e<0){let i=n-e;return t+i>r?r-t:i}return 0},s=({open:n})=>{let[r,s]=(0,e.useState)(null),[c,l]=(0,e.useState)(null),[u,d]=(0,e.useState)({side:`bottom`,shiftX:0}),f=(0,e.useCallback)(()=>{if(!r||!c)return;let e=c.ownerDocument.documentElement,t=r.getBoundingClientRect(),n=c.getBoundingClientRect(),s=a({referenceTop:t.top,referenceBottom:t.bottom,floatingHeight:n.height,viewportHeight:e.clientHeight}),l=parseFloat(c.style.getPropertyValue(i))||0,u=Math.round(o(n.left-l,n.right-l,e.clientWidth));d(e=>e.side===s&&e.shiftX===u?e:{side:s,shiftX:u})},[r,c]);t(()=>{if(!n||!r||!c)return;f();let e=c.ownerDocument.defaultView;if(!e)return;e.addEventListener(`resize`,f),e.addEventListener(`scroll`,f,!0);let t=typeof ResizeObserver<`u`?new ResizeObserver(f):null;return t?.observe(c),t?.observe(r),c.addEventListener(`animationend`,f),()=>{c.removeEventListener(`animationend`,f),e.removeEventListener(`resize`,f),e.removeEventListener(`scroll`,f,!0),t?.disconnect()}},[n,r,c,f]);let p=n?u.side:`bottom`,m=n?u.shiftX:0;return{setReference:s,setFloating:l,floatingProps:{"data-side":p,style:m?{[i]:`${m}px`}:void 0}}};exports.computeInlineShift=o,exports.computeInlineSide=a,exports.useInlineFloating=s;
|
|
@@ -38,8 +38,8 @@ var i = typeof window < "u" ? n : t, a = 10, o = 8, s = "--wim-floating-shift-x"
|
|
|
38
38
|
if (!e) return;
|
|
39
39
|
e.addEventListener("resize", p), e.addEventListener("scroll", p, !0);
|
|
40
40
|
let r = typeof ResizeObserver < "u" ? new ResizeObserver(p) : null;
|
|
41
|
-
return r?.observe(o), r?.observe(n), () => {
|
|
42
|
-
e.removeEventListener("resize", p), e.removeEventListener("scroll", p, !0), r?.disconnect();
|
|
41
|
+
return r?.observe(o), r?.observe(n), o.addEventListener("animationend", p), () => {
|
|
42
|
+
o.removeEventListener("animationend", p), e.removeEventListener("resize", p), e.removeEventListener("scroll", p, !0), r?.disconnect();
|
|
43
43
|
};
|
|
44
44
|
}, [
|
|
45
45
|
t,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../../hooks/useMergedRef.cjs"),i=require("../../layout/Transition/Transition.cjs"),a=require("../../../icon/check.cjs"),o=require("../../../icon/chevron-down.cjs"),s=require("../../media/Icon/Icon.cjs"),c=require("../../_internal/useInlineFloating.cjs"),l=require("./model-selector.module.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("classnames");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p=e=>e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}K`:String(e),m=(e,t=`$`)=>`${t}${e}`,h=u.default.forwardRef(({models:e,value:h,defaultValue:g,onChange:_,size:v=`md`,disabled:y=!1,fullWidth:b=!1,showPricing:x=!0,showContext:S=!0,labels:C,className:w,...
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../../hooks/useMergedRef.cjs"),i=require("../../layout/Transition/Transition.cjs"),a=require("../../../icon/check.cjs"),o=require("../../../icon/chevron-down.cjs"),s=require("../../media/Icon/Icon.cjs"),c=require("../../_internal/useInlineFloating.cjs"),l=require("./model-selector.module.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("classnames");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p=e=>e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}K`:String(e),m=(e,t=`$`)=>`${t}${e}`,h=u.default.forwardRef(({models:e,value:h,defaultValue:g,onChange:_,size:v=`md`,disabled:y=!1,fullWidth:b=!1,showPricing:x=!0,showContext:S=!0,labels:C,className:w,"aria-label":T,"aria-labelledby":E,"aria-describedby":D,...O},k)=>{let{t:A}=t.useWimTranslation(n.commonNs),{placeholder:j=A(`modelSelector.placeholder`),contextLabel:M=A(`modelSelector.context`),inputLabel:N=A(`modelSelector.input`),outputLabel:P=A(`modelSelector.output`),perTokensLabel:F=`/1M`,triggerAriaLabel:I=A(`modelSelector.placeholder`)}=C??{},L=h!==void 0,[R,z]=(0,u.useState)(g),B=L?h:R,V=e.find(e=>e.id===B),[H,U]=(0,u.useState)(!1),[W,G]=(0,u.useState)(-1),K=(0,u.useRef)(null),q=(0,u.useRef)(null),J=(0,u.useId)(),Y=`${J}-listbox`,X=(0,u.useCallback)(e=>{K.current=e,typeof k==`function`?k(e):k&&(k.current=e)},[k]);(0,u.useEffect)(()=>{if(!H)return;let e=e=>{K.current&&!K.current.contains(e.target)&&U(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[H]);let Z=e=>{e.disabled||(L||z(e.id),_?.(e.id,e),U(!1))},Q=(t,n)=>{let r=t;for(let t=0;t<e.length;t++){if(!e[r]?.disabled)return r;r=(r+n+e.length)%e.length}return-1},$=t=>{let n=e.findIndex(e=>e.id===B);G(t??(n>=0?n:Q(0,1))),U(!0)},ee=t=>{G(n=>{let r=n;for(let n=0;n<e.length&&(r=(r+t+e.length)%e.length,e[r]?.disabled);n++);return r})},te=t=>{if(!y)switch(t.key){case`ArrowDown`:case`ArrowUp`:t.preventDefault(),H?ee(t.key===`ArrowDown`?1:-1):$();break;case`Home`:case`End`:t.preventDefault(),t.key===`Home`?H?G(Q(0,1)):$(Q(0,1)):H?G(Q(e.length-1,-1)):$(Q(e.length-1,-1));break;case`Enter`:case` `:if(t.preventDefault(),!H)$();else{let t=e[W];t&&Z(t)}break;case`Escape`:H&&(t.preventDefault(),U(!1));break;case`Tab`:U(!1)}};(0,u.useEffect)(()=>{H&&W>=0&&(q.current?.querySelectorAll(`[role="option"]`)?.[W])?.scrollIntoView({block:`nearest`})},[W,H]);let ne=e=>{let t=[];if(S&&e.contextLength&&t.push((0,f.jsxs)(`span`,{className:l.default.meta,children:[M,` `,p(e.contextLength)]},`ctx`)),x&&e.pricing){let{input:n,output:r,currency:i}=e.pricing;n!==void 0&&t.push((0,f.jsxs)(`span`,{className:l.default.meta,children:[N,` `,m(n,i),F]},`in`)),r!==void 0&&t.push((0,f.jsxs)(`span`,{className:l.default.meta,children:[P,` `,m(r,i),F]},`out`))}if(t.length===0)return null;let n=t.flatMap((e,t)=>t===0?[e]:[` `,e]);return(0,f.jsx)(`span`,{className:l.default.metaRow,children:n})},{setReference:re,setFloating:ie,floatingProps:ae}=c.useInlineFloating({open:H}),oe=r.useMergedRef(X,re);return(0,f.jsxs)(`div`,{ref:oe,className:(0,d.default)(`wim-model-selector`,l.default.root,l.default[v],b&&l.default.fullWidth,y&&l.default.disabled,w),...O,children:[(0,f.jsxs)(`button`,{type:`button`,role:`combobox`,className:l.default.trigger,"aria-haspopup":`listbox`,"aria-expanded":H,"aria-controls":H?Y:void 0,"aria-activedescendant":H&&W>=0?`${J}-opt-${W}`:void 0,"aria-label":E?void 0:T??I,"aria-labelledby":E,"aria-describedby":D,disabled:y,onClick:()=>{y||(H?U(!1):$())},onKeyDown:te,onKeyUp:e=>{e.key===` `&&e.preventDefault()},children:[(0,f.jsx)(`span`,{className:l.default.triggerLabel,children:V?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`span`,{className:l.default.triggerName,children:V.name}),` `,V.badge&&(0,f.jsx)(`span`,{className:l.default.badge,children:V.badge})]}):(0,f.jsx)(`span`,{className:l.default.placeholder,children:j})}),(0,f.jsx)(s.Icon,{component:o.default,size:`sm`,className:(0,d.default)(l.default.chevron,H&&l.default.chevronOpen)})]}),(0,f.jsx)(i.Transition,{show:H,preset:`scale`,unmount:!0,className:l.default.dropdownWrapper,ref:ie,...ae,children:(0,f.jsx)(`ul`,{ref:q,id:Y,role:`listbox`,"aria-label":E?void 0:T??I,"aria-labelledby":E,tabIndex:-1,className:l.default.dropdown,onMouseDown:e=>e.preventDefault(),children:e.map((e,t)=>{let n=e.id===B;return(0,f.jsxs)(`li`,{id:`${J}-opt-${t}`,role:`option`,"aria-selected":n,"aria-disabled":e.disabled||void 0,className:(0,d.default)(l.default.option,t===W&&l.default.active,e.disabled&&l.default.optionDisabled),onMouseEnter:()=>G(t),onClick:()=>Z(e),children:[(0,f.jsx)(`span`,{className:l.default.check,"aria-hidden":`true`,children:n&&(0,f.jsx)(s.Icon,{component:a.default,size:`sm`})}),(0,f.jsxs)(`span`,{className:l.default.optionBody,children:[(0,f.jsxs)(`span`,{className:l.default.optionHeader,children:[(0,f.jsx)(`span`,{className:l.default.optionName,children:e.name}),` `,e.badge&&(0,f.jsx)(`span`,{className:l.default.badge,children:e.badge})]}),` `,e.description&&(0,f.jsx)(`span`,{className:l.default.description,children:e.description}),` `,ne(e)]})]},e.id)})})})]})});h.displayName=`ModelSelector`,exports.ModelSelector=h;
|
|
@@ -6,57 +6,57 @@ import { Transition as r } from "../../layout/Transition/Transition.js";
|
|
|
6
6
|
import i from "../../../icon/check.js";
|
|
7
7
|
import a from "../../../icon/chevron-down.js";
|
|
8
8
|
import { Icon as o } from "../../media/Icon/Icon.js";
|
|
9
|
-
import { useInlineFloating as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
9
|
+
import { useInlineFloating as ee } from "../../_internal/useInlineFloating.js";
|
|
10
|
+
import s from "./model-selector.module.js";
|
|
11
|
+
import c, { useCallback as l, useEffect as u, useId as d, useRef as f, useState as p } from "react";
|
|
12
12
|
import m from "classnames";
|
|
13
13
|
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
14
14
|
//#region src/components/ai/ModelSelector/ModelSelector.tsx
|
|
15
|
-
var
|
|
16
|
-
let { t:
|
|
17
|
-
K.current = e, typeof
|
|
18
|
-
}, [
|
|
19
|
-
|
|
15
|
+
var te = (e) => e >= 1e6 ? `${(e / 1e6).toFixed(e % 1e6 == 0 ? 0 : 1)}M` : e >= 1e3 ? `${(e / 1e3).toFixed(e % 1e3 == 0 ? 0 : 1)}K` : String(e), v = (e, t = "$") => `${t}${e}`, y = c.forwardRef(({ models: c, value: y, defaultValue: b, onChange: x, size: S = "md", disabled: C = !1, fullWidth: ne = !1, showPricing: re = !0, showContext: w = !0, labels: T, className: E, "aria-label": D, "aria-labelledby": O, "aria-describedby": k, ...A }, j) => {
|
|
16
|
+
let { t: M } = e(t), { placeholder: ie = M("modelSelector.placeholder"), contextLabel: ae = M("modelSelector.context"), inputLabel: N = M("modelSelector.input"), outputLabel: P = M("modelSelector.output"), perTokensLabel: F = "/1M", triggerAriaLabel: I = M("modelSelector.placeholder") } = T ?? {}, L = y !== void 0, [R, z] = p(b), B = L ? y : R, V = c.find((e) => e.id === B), [H, U] = p(!1), [W, G] = p(-1), K = f(null), q = f(null), J = d(), Y = `${J}-listbox`, oe = l((e) => {
|
|
17
|
+
K.current = e, typeof j == "function" ? j(e) : j && (j.current = e);
|
|
18
|
+
}, [j]);
|
|
19
|
+
u(() => {
|
|
20
20
|
if (!H) return;
|
|
21
21
|
let e = (e) => {
|
|
22
22
|
K.current && !K.current.contains(e.target) && U(!1);
|
|
23
23
|
};
|
|
24
24
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
25
25
|
}, [H]);
|
|
26
|
-
let
|
|
27
|
-
e.disabled || (L || z(e.id),
|
|
28
|
-
},
|
|
26
|
+
let X = (e) => {
|
|
27
|
+
e.disabled || (L || z(e.id), x?.(e.id, e), U(!1));
|
|
28
|
+
}, Z = (e, t) => {
|
|
29
29
|
let n = e;
|
|
30
|
-
for (let e = 0; e <
|
|
31
|
-
if (!
|
|
32
|
-
n = (n + t +
|
|
30
|
+
for (let e = 0; e < c.length; e++) {
|
|
31
|
+
if (!c[n]?.disabled) return n;
|
|
32
|
+
n = (n + t + c.length) % c.length;
|
|
33
33
|
}
|
|
34
34
|
return -1;
|
|
35
|
-
},
|
|
36
|
-
let t =
|
|
37
|
-
G(e ?? (t >= 0 ? t :
|
|
38
|
-
},
|
|
35
|
+
}, Q = (e) => {
|
|
36
|
+
let t = c.findIndex((e) => e.id === B);
|
|
37
|
+
G(e ?? (t >= 0 ? t : Z(0, 1))), U(!0);
|
|
38
|
+
}, se = (e) => {
|
|
39
39
|
G((t) => {
|
|
40
40
|
let n = t;
|
|
41
|
-
for (let t = 0; t <
|
|
41
|
+
for (let t = 0; t < c.length && (n = (n + e + c.length) % c.length, c[n]?.disabled); t++);
|
|
42
42
|
return n;
|
|
43
43
|
});
|
|
44
|
-
},
|
|
44
|
+
}, ce = (e) => {
|
|
45
45
|
if (!C) switch (e.key) {
|
|
46
46
|
case "ArrowDown":
|
|
47
47
|
case "ArrowUp":
|
|
48
|
-
e.preventDefault(), H ?
|
|
48
|
+
e.preventDefault(), H ? se(e.key === "ArrowDown" ? 1 : -1) : Q();
|
|
49
49
|
break;
|
|
50
50
|
case "Home":
|
|
51
51
|
case "End":
|
|
52
|
-
e.preventDefault(), e.key === "Home" ? H ? G(
|
|
52
|
+
e.preventDefault(), e.key === "Home" ? H ? G(Z(0, 1)) : Q(Z(0, 1)) : H ? G(Z(c.length - 1, -1)) : Q(Z(c.length - 1, -1));
|
|
53
53
|
break;
|
|
54
54
|
case "Enter":
|
|
55
55
|
case " ":
|
|
56
|
-
if (e.preventDefault(), !H)
|
|
56
|
+
if (e.preventDefault(), !H) Q();
|
|
57
57
|
else {
|
|
58
|
-
let e =
|
|
59
|
-
e &&
|
|
58
|
+
let e = c[W];
|
|
59
|
+
e && X(e);
|
|
60
60
|
}
|
|
61
61
|
break;
|
|
62
62
|
case "Escape":
|
|
@@ -65,34 +65,34 @@ var v = (e) => e >= 1e6 ? `${(e / 1e6).toFixed(e % 1e6 == 0 ? 0 : 1)}M` : e >= 1
|
|
|
65
65
|
case "Tab": U(!1);
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
-
|
|
68
|
+
u(() => {
|
|
69
69
|
H && W >= 0 && (q.current?.querySelectorAll("[role=\"option\"]")?.[W])?.scrollIntoView({ block: "nearest" });
|
|
70
70
|
}, [W, H]);
|
|
71
|
-
let
|
|
71
|
+
let $ = (e) => {
|
|
72
72
|
let t = [];
|
|
73
|
-
if (
|
|
74
|
-
className:
|
|
73
|
+
if (w && e.contextLength && t.push(/* @__PURE__ */ _("span", {
|
|
74
|
+
className: s.meta,
|
|
75
75
|
children: [
|
|
76
|
-
|
|
76
|
+
ae,
|
|
77
77
|
" ",
|
|
78
|
-
|
|
78
|
+
te(e.contextLength)
|
|
79
79
|
]
|
|
80
|
-
}, "ctx")),
|
|
80
|
+
}, "ctx")), re && e.pricing) {
|
|
81
81
|
let { input: n, output: r, currency: i } = e.pricing;
|
|
82
82
|
n !== void 0 && t.push(/* @__PURE__ */ _("span", {
|
|
83
|
-
className:
|
|
83
|
+
className: s.meta,
|
|
84
84
|
children: [
|
|
85
|
-
|
|
85
|
+
N,
|
|
86
86
|
" ",
|
|
87
|
-
|
|
87
|
+
v(n, i),
|
|
88
88
|
F
|
|
89
89
|
]
|
|
90
90
|
}, "in")), r !== void 0 && t.push(/* @__PURE__ */ _("span", {
|
|
91
|
-
className:
|
|
91
|
+
className: s.meta,
|
|
92
92
|
children: [
|
|
93
93
|
P,
|
|
94
94
|
" ",
|
|
95
|
-
|
|
95
|
+
v(r, i),
|
|
96
96
|
F
|
|
97
97
|
]
|
|
98
98
|
}, "out"));
|
|
@@ -100,108 +100,111 @@ var v = (e) => e >= 1e6 ? `${(e / 1e6).toFixed(e % 1e6 == 0 ? 0 : 1)}M` : e >= 1
|
|
|
100
100
|
if (t.length === 0) return null;
|
|
101
101
|
let n = t.flatMap((e, t) => t === 0 ? [e] : [" ", e]);
|
|
102
102
|
return /* @__PURE__ */ g("span", {
|
|
103
|
-
className:
|
|
103
|
+
className: s.metaRow,
|
|
104
104
|
children: n
|
|
105
105
|
});
|
|
106
|
-
}, { setReference:
|
|
106
|
+
}, { setReference: le, setFloating: ue, floatingProps: de } = ee({ open: H }), fe = n(oe, le);
|
|
107
107
|
return /* @__PURE__ */ _("div", {
|
|
108
|
-
ref:
|
|
109
|
-
className: m("wim-model-selector",
|
|
110
|
-
...
|
|
108
|
+
ref: fe,
|
|
109
|
+
className: m("wim-model-selector", s.root, s[S], ne && s.fullWidth, C && s.disabled, E),
|
|
110
|
+
...A,
|
|
111
111
|
children: [/* @__PURE__ */ _("button", {
|
|
112
112
|
type: "button",
|
|
113
113
|
role: "combobox",
|
|
114
|
-
className:
|
|
114
|
+
className: s.trigger,
|
|
115
115
|
"aria-haspopup": "listbox",
|
|
116
116
|
"aria-expanded": H,
|
|
117
117
|
"aria-controls": H ? Y : void 0,
|
|
118
118
|
"aria-activedescendant": H && W >= 0 ? `${J}-opt-${W}` : void 0,
|
|
119
|
-
"aria-label": I,
|
|
119
|
+
"aria-label": O ? void 0 : D ?? I,
|
|
120
|
+
"aria-labelledby": O,
|
|
121
|
+
"aria-describedby": k,
|
|
120
122
|
disabled: C,
|
|
121
123
|
onClick: () => {
|
|
122
|
-
C || (H ? U(!1) :
|
|
124
|
+
C || (H ? U(!1) : Q());
|
|
123
125
|
},
|
|
124
|
-
onKeyDown:
|
|
126
|
+
onKeyDown: ce,
|
|
125
127
|
onKeyUp: (e) => {
|
|
126
128
|
e.key === " " && e.preventDefault();
|
|
127
129
|
},
|
|
128
130
|
children: [/* @__PURE__ */ g("span", {
|
|
129
|
-
className:
|
|
131
|
+
className: s.triggerLabel,
|
|
130
132
|
children: V ? /* @__PURE__ */ _(h, { children: [
|
|
131
133
|
/* @__PURE__ */ g("span", {
|
|
132
|
-
className:
|
|
134
|
+
className: s.triggerName,
|
|
133
135
|
children: V.name
|
|
134
136
|
}),
|
|
135
137
|
" ",
|
|
136
138
|
V.badge && /* @__PURE__ */ g("span", {
|
|
137
|
-
className:
|
|
139
|
+
className: s.badge,
|
|
138
140
|
children: V.badge
|
|
139
141
|
})
|
|
140
142
|
] }) : /* @__PURE__ */ g("span", {
|
|
141
|
-
className:
|
|
142
|
-
children:
|
|
143
|
+
className: s.placeholder,
|
|
144
|
+
children: ie
|
|
143
145
|
})
|
|
144
146
|
}), /* @__PURE__ */ g(o, {
|
|
145
147
|
component: a,
|
|
146
148
|
size: "sm",
|
|
147
|
-
className: m(
|
|
149
|
+
className: m(s.chevron, H && s.chevronOpen)
|
|
148
150
|
})]
|
|
149
151
|
}), /* @__PURE__ */ g(r, {
|
|
150
152
|
show: H,
|
|
151
153
|
preset: "scale",
|
|
152
154
|
unmount: !0,
|
|
153
|
-
className:
|
|
154
|
-
ref:
|
|
155
|
-
...
|
|
155
|
+
className: s.dropdownWrapper,
|
|
156
|
+
ref: ue,
|
|
157
|
+
...de,
|
|
156
158
|
children: /* @__PURE__ */ g("ul", {
|
|
157
159
|
ref: q,
|
|
158
160
|
id: Y,
|
|
159
161
|
role: "listbox",
|
|
160
|
-
"aria-label": I,
|
|
162
|
+
"aria-label": O ? void 0 : D ?? I,
|
|
163
|
+
"aria-labelledby": O,
|
|
161
164
|
tabIndex: -1,
|
|
162
|
-
className:
|
|
165
|
+
className: s.dropdown,
|
|
163
166
|
onMouseDown: (e) => e.preventDefault(),
|
|
164
|
-
children:
|
|
167
|
+
children: c.map((e, t) => {
|
|
165
168
|
let n = e.id === B;
|
|
166
169
|
return /* @__PURE__ */ _("li", {
|
|
167
170
|
id: `${J}-opt-${t}`,
|
|
168
171
|
role: "option",
|
|
169
172
|
"aria-selected": n,
|
|
170
173
|
"aria-disabled": e.disabled || void 0,
|
|
171
|
-
className: m(
|
|
174
|
+
className: m(s.option, t === W && s.active, e.disabled && s.optionDisabled),
|
|
172
175
|
onMouseEnter: () => G(t),
|
|
173
|
-
onClick: () =>
|
|
176
|
+
onClick: () => X(e),
|
|
174
177
|
children: [/* @__PURE__ */ g("span", {
|
|
175
|
-
className:
|
|
178
|
+
className: s.check,
|
|
176
179
|
"aria-hidden": "true",
|
|
177
180
|
children: n && /* @__PURE__ */ g(o, {
|
|
178
181
|
component: i,
|
|
179
182
|
size: "sm"
|
|
180
183
|
})
|
|
181
184
|
}), /* @__PURE__ */ _("span", {
|
|
182
|
-
className:
|
|
185
|
+
className: s.optionBody,
|
|
183
186
|
children: [
|
|
184
187
|
/* @__PURE__ */ _("span", {
|
|
185
|
-
className:
|
|
188
|
+
className: s.optionHeader,
|
|
186
189
|
children: [
|
|
187
190
|
/* @__PURE__ */ g("span", {
|
|
188
|
-
className:
|
|
191
|
+
className: s.optionName,
|
|
189
192
|
children: e.name
|
|
190
193
|
}),
|
|
191
194
|
" ",
|
|
192
195
|
e.badge && /* @__PURE__ */ g("span", {
|
|
193
|
-
className:
|
|
196
|
+
className: s.badge,
|
|
194
197
|
children: e.badge
|
|
195
198
|
})
|
|
196
199
|
]
|
|
197
200
|
}),
|
|
198
201
|
" ",
|
|
199
202
|
e.description && /* @__PURE__ */ g("span", {
|
|
200
|
-
className:
|
|
203
|
+
className: s.description,
|
|
201
204
|
children: e.description
|
|
202
205
|
}),
|
|
203
206
|
" ",
|
|
204
|
-
|
|
207
|
+
$(e)
|
|
205
208
|
]
|
|
206
209
|
})]
|
|
207
210
|
}, e.id);
|
|
@@ -210,6 +213,6 @@ var v = (e) => e >= 1e6 ? `${(e / 1e6).toFixed(e % 1e6 == 0 ? 0 : 1)}M` : e >= 1
|
|
|
210
213
|
})]
|
|
211
214
|
});
|
|
212
215
|
});
|
|
213
|
-
|
|
216
|
+
y.displayName = "ModelSelector";
|
|
214
217
|
//#endregion
|
|
215
|
-
export {
|
|
218
|
+
export { y as ModelSelector };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../media/Icon/Icon.cjs"),n=require("../Button/Button.cjs"),r=require("../../overlay/Dropdown/Dropdown.cjs"),i=require("./split-button.module.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=a.default.forwardRef(({children:e,onClick:a,actions:c,variant:l=`solid`,intent:u=`default`,size:d=`md`,disabled:f=!1,loading:p=!1,toggleLabel:m,className:h,...g},_)=>(0,s.jsxs)(`div`,{ref:_,className:(0,o.default)(`wim-split-button`,i.default.root,i.default[d],i.default[l],h),...g,children:[(0,s.jsx)(n.Button,{className:i.default.main,variant:l,intent:u,size:d,disabled:f,loading:p,onClick:a,children:e}),(0,s.jsxs)(r.Dropdown,{children:[(0,s.jsx)(r.DropdownTrigger,{asChild:!0,children:(0,s.jsx)(n.Button,{className:i.default.toggle,variant:l,intent:u,size:d,disabled:f,"aria-label":m,children:(0,s.jsx)(t.Icon,{name:`ChevronDownIcon`,className:i.default.chevron})})}),(0,s.jsx)(r.DropdownMenu,{children:c.map((e,t)=>(0,s.jsxs)(r.DropdownItem,{disabled:e.disabled,onClick:e.onSelect,children:[e.icon&&(0,s.jsx)(`span`,{className:i.default.itemIcon,children:e.icon}),e.label]},t))})]})]}));c.displayName=`SplitButton`,exports.SplitButton=c;
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../media/Icon/Icon.cjs"),n=require("../Button/Button.cjs"),r=require("../../overlay/Dropdown/Dropdown.cjs"),i=require("./split-button.module.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=a.default.forwardRef(({children:e,onClick:a,actions:c,variant:l=`solid`,intent:u=`default`,size:d=`md`,disabled:f=!1,loading:p=!1,toggleLabel:m,className:h,...g},_)=>{let v=g.role??(g[`aria-label`]||g[`aria-labelledby`]?`group`:void 0);return(0,s.jsxs)(`div`,{ref:_,role:v,className:(0,o.default)(`wim-split-button`,i.default.root,i.default[d],i.default[l],h),...g,children:[(0,s.jsx)(n.Button,{className:i.default.main,variant:l,intent:u,size:d,disabled:f,loading:p,onClick:a,children:e}),(0,s.jsxs)(r.Dropdown,{children:[(0,s.jsx)(r.DropdownTrigger,{asChild:!0,children:(0,s.jsx)(n.Button,{className:i.default.toggle,variant:l,intent:u,size:d,disabled:f,"aria-label":m,children:(0,s.jsx)(t.Icon,{name:`ChevronDownIcon`,className:i.default.chevron})})}),(0,s.jsx)(r.DropdownMenu,{children:c.map((e,t)=>(0,s.jsxs)(r.DropdownItem,{disabled:e.disabled,onClick:e.onSelect,children:[e.icon&&(0,s.jsx)(`span`,{className:i.default.itemIcon,children:e.icon}),e.label]},t))})]})]})});c.displayName=`SplitButton`,exports.SplitButton=c;
|
|
@@ -7,42 +7,46 @@ import s from "react";
|
|
|
7
7
|
import c from "classnames";
|
|
8
8
|
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
9
9
|
//#region src/components/form/SplitButton/SplitButton.tsx
|
|
10
|
-
var d = s.forwardRef(({ children: s, onClick: d, actions: f, variant: p = "solid", intent: m = "default", size: h = "md", disabled: g = !1, loading: _ = !1, toggleLabel: v, className: y, ...b }, x) =>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
className: o.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
disabled: g,
|
|
20
|
-
loading: _,
|
|
21
|
-
onClick: d,
|
|
22
|
-
children: s
|
|
23
|
-
}), /* @__PURE__ */ u(n, { children: [/* @__PURE__ */ l(a, {
|
|
24
|
-
asChild: !0,
|
|
25
|
-
children: /* @__PURE__ */ l(t, {
|
|
26
|
-
className: o.toggle,
|
|
10
|
+
var d = s.forwardRef(({ children: s, onClick: d, actions: f, variant: p = "solid", intent: m = "default", size: h = "md", disabled: g = !1, loading: _ = !1, toggleLabel: v, className: y, ...b }, x) => {
|
|
11
|
+
let S = b.role ?? (b["aria-label"] || b["aria-labelledby"] ? "group" : void 0);
|
|
12
|
+
return /* @__PURE__ */ u("div", {
|
|
13
|
+
ref: x,
|
|
14
|
+
role: S,
|
|
15
|
+
className: c("wim-split-button", o.root, o[h], o[p], y),
|
|
16
|
+
...b,
|
|
17
|
+
children: [/* @__PURE__ */ l(t, {
|
|
18
|
+
className: o.main,
|
|
27
19
|
variant: p,
|
|
28
20
|
intent: m,
|
|
29
21
|
size: h,
|
|
30
22
|
disabled: g,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
loading: _,
|
|
24
|
+
onClick: d,
|
|
25
|
+
children: s
|
|
26
|
+
}), /* @__PURE__ */ u(n, { children: [/* @__PURE__ */ l(a, {
|
|
27
|
+
asChild: !0,
|
|
28
|
+
children: /* @__PURE__ */ l(t, {
|
|
29
|
+
className: o.toggle,
|
|
30
|
+
variant: p,
|
|
31
|
+
intent: m,
|
|
32
|
+
size: h,
|
|
33
|
+
disabled: g,
|
|
34
|
+
"aria-label": v,
|
|
35
|
+
children: /* @__PURE__ */ l(e, {
|
|
36
|
+
name: "ChevronDownIcon",
|
|
37
|
+
className: o.chevron
|
|
38
|
+
})
|
|
35
39
|
})
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
})
|
|
40
|
+
}), /* @__PURE__ */ l(i, { children: f.map((e, t) => /* @__PURE__ */ u(r, {
|
|
41
|
+
disabled: e.disabled,
|
|
42
|
+
onClick: e.onSelect,
|
|
43
|
+
children: [e.icon && /* @__PURE__ */ l("span", {
|
|
44
|
+
className: o.itemIcon,
|
|
45
|
+
children: e.icon
|
|
46
|
+
}), e.label]
|
|
47
|
+
}, t)) })] })]
|
|
48
|
+
});
|
|
49
|
+
});
|
|
46
50
|
d.displayName = "SplitButton";
|
|
47
51
|
//#endregion
|
|
48
52
|
export { d as SplitButton };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("./anchor.module.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("classnames");r=e.__toESM(r,1);let i=require("react/jsx-runtime");var a=({items:e=[],bounds:a=5,offset:o=0,direction:s=`vertical`,className:c,style:l})=>{let[
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("./anchor.module.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("classnames");r=e.__toESM(r,1);let i=require("react/jsx-runtime");var a=({items:e=[],bounds:a=5,offset:o=0,direction:s=`vertical`,className:c,style:l,"aria-label":u,"aria-labelledby":d})=>{let[f,p]=(0,n.useState)(``),[m,h]=(0,n.useState)({}),g=(0,n.useRef)(null),_=(e,t)=>{e.preventDefault();let n=t.replace(`#`,``),r=document.getElementById(n);r&&(window.scrollTo({top:r.offsetTop-o,behavior:`smooth`}),p(t))};(0,n.useLayoutEffect)(()=>{let t=()=>{let t=(e,n)=>{let r=[];return e.forEach(e=>{r.push({href:e.href,parentHref:n}),e.children&&(r=r.concat(t(e.children,n||e.href)))}),r},n=t(e),r=``,i=window.scrollY||document.documentElement.scrollTop,c=document.documentElement.scrollHeight,l=document.documentElement.clientHeight;if(i>0&&Math.ceil(i+l)>=c&&n.length>0){let e=n[n.length-1];r=s===`horizontal`&&e.parentHref?e.parentHref:e.href}else for(let e of n){let t=e.href.replace(`#`,``),n=document.getElementById(t);if(n){if(n.getBoundingClientRect().top<=o+a)r=s===`horizontal`&&e.parentHref?e.parentHref:e.href;else break}}r&&r!==f&&p(r)};return window.addEventListener(`scroll`,t),t(),()=>window.removeEventListener(`scroll`,t)},[e,o,a,f,s]);let v=(0,n.useCallback)(()=>{if(!f||!g.current)return;let e=g.current.querySelector(`a[href="${f}"]`);if(e){let n=g.current.getBoundingClientRect();if(s===`vertical`){let t=e.getBoundingClientRect();h({top:t.top-n.top,height:t.height,opacity:1})}else{let r=g.current.querySelector(`.${t.default.list}`);if(r){let t=e.getBoundingClientRect(),i=r.getBoundingClientRect(),a=t.left-i.left+r.scrollLeft,o=a-i.width/2+t.width/2,s=r.scrollWidth-i.width,c=Math.max(0,Math.min(o,s)),l=a-c+(i.left-n.left);h({left:l,width:t.width,opacity:1}),r.scrollTo({left:c,behavior:`smooth`})}else{let t=e.getBoundingClientRect();h({left:t.left-g.current.getBoundingClientRect().left,width:t.width,opacity:1})}}}else h({opacity:0})},[f,s]);(0,n.useLayoutEffect)(()=>{v()},[v]),(0,n.useEffect)(()=>{let e=g.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>v());return t.observe(e),e.querySelectorAll(`a`).forEach(e=>t.observe(e)),()=>t.disconnect()},[v,e]);let y=e=>(0,i.jsx)(`ul`,{className:(0,r.default)(t.default.list,t.default[s]),children:e.map(e=>(0,i.jsxs)(`li`,{className:(0,r.default)(t.default.item,f===e.href&&t.default.active),children:[(0,i.jsx)(`a`,{href:e.href,className:t.default.link,"aria-current":f===e.href?`location`:void 0,onClick:t=>_(t,e.href),title:typeof e.title==`string`?e.title:void 0,children:e.title}),e.children&&s===`vertical`&&y(e.children)]},e.key))});return(0,i.jsxs)(`div`,{className:(0,r.default)(`wim-anchor`,t.default.root,t.default[s],c),style:l,ref:g,role:u||d?`navigation`:void 0,"aria-label":d?void 0:u,"aria-labelledby":d,children:[(0,i.jsx)(`div`,{className:t.default.ink,children:(0,i.jsx)(`span`,{className:t.default.inkBall,style:m})}),y(e)]})};exports.Anchor=a,exports.default=a;
|
|
@@ -22,6 +22,10 @@ export interface AnchorProps {
|
|
|
22
22
|
className?: string;
|
|
23
23
|
/** Style attribute */
|
|
24
24
|
style?: React.CSSProperties;
|
|
25
|
+
/** Accessible name. When set, the anchor is exposed as a navigation landmark with this name. */
|
|
26
|
+
"aria-label"?: string;
|
|
27
|
+
/** ID of the element that labels the anchor. Takes precedence over `aria-label`. */
|
|
28
|
+
"aria-labelledby"?: string;
|
|
25
29
|
}
|
|
26
|
-
export declare const Anchor: ({ items, bounds, offset, direction, className, style, }: AnchorProps) => React.JSX.Element;
|
|
30
|
+
export declare const Anchor: ({ items, bounds, offset, direction, className, style, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }: AnchorProps) => React.JSX.Element;
|
|
27
31
|
export default Anchor;
|
|
@@ -4,14 +4,14 @@ import { useCallback as t, useEffect as n, useLayoutEffect as r, useRef as i, us
|
|
|
4
4
|
import o from "classnames";
|
|
5
5
|
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/navigation/Anchor/Anchor.tsx
|
|
7
|
-
var l = ({ items: l = [], bounds: u = 5, offset: d = 0, direction: f = "vertical", className: p, style: m }) => {
|
|
8
|
-
let [
|
|
7
|
+
var l = ({ items: l = [], bounds: u = 5, offset: d = 0, direction: f = "vertical", className: p, style: m, "aria-label": h, "aria-labelledby": g }) => {
|
|
8
|
+
let [_, v] = a(""), [y, b] = a({}), x = i(null), S = (e, t) => {
|
|
9
9
|
e.preventDefault();
|
|
10
10
|
let n = t.replace("#", ""), r = document.getElementById(n);
|
|
11
11
|
r && (window.scrollTo({
|
|
12
12
|
top: r.offsetTop - d,
|
|
13
13
|
behavior: "smooth"
|
|
14
|
-
}),
|
|
14
|
+
}), v(t));
|
|
15
15
|
};
|
|
16
16
|
r(() => {
|
|
17
17
|
let e = () => {
|
|
@@ -34,33 +34,33 @@ var l = ({ items: l = [], bounds: u = 5, offset: d = 0, direction: f = "vertical
|
|
|
34
34
|
else break;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
n && n !==
|
|
37
|
+
n && n !== _ && v(n);
|
|
38
38
|
};
|
|
39
39
|
return window.addEventListener("scroll", e), e(), () => window.removeEventListener("scroll", e);
|
|
40
40
|
}, [
|
|
41
41
|
l,
|
|
42
42
|
d,
|
|
43
43
|
u,
|
|
44
|
-
|
|
44
|
+
_,
|
|
45
45
|
f
|
|
46
46
|
]);
|
|
47
|
-
let
|
|
48
|
-
if (!
|
|
49
|
-
let t =
|
|
47
|
+
let C = t(() => {
|
|
48
|
+
if (!_ || !x.current) return;
|
|
49
|
+
let t = x.current.querySelector(`a[href="${_}"]`);
|
|
50
50
|
if (t) {
|
|
51
|
-
let n =
|
|
51
|
+
let n = x.current.getBoundingClientRect();
|
|
52
52
|
if (f === "vertical") {
|
|
53
53
|
let e = t.getBoundingClientRect();
|
|
54
|
-
|
|
54
|
+
b({
|
|
55
55
|
top: e.top - n.top,
|
|
56
56
|
height: e.height,
|
|
57
57
|
opacity: 1
|
|
58
58
|
});
|
|
59
59
|
} else {
|
|
60
|
-
let r =
|
|
60
|
+
let r = x.current.querySelector(`.${e.list}`);
|
|
61
61
|
if (r) {
|
|
62
62
|
let e = t.getBoundingClientRect(), i = r.getBoundingClientRect(), a = e.left - i.left + r.scrollLeft, o = a - i.width / 2 + e.width / 2, s = r.scrollWidth - i.width, c = Math.max(0, Math.min(o, s)), l = a - c + (i.left - n.left);
|
|
63
|
-
|
|
63
|
+
b({
|
|
64
64
|
left: l,
|
|
65
65
|
width: e.width,
|
|
66
66
|
opacity: 1
|
|
@@ -70,48 +70,51 @@ var l = ({ items: l = [], bounds: u = 5, offset: d = 0, direction: f = "vertical
|
|
|
70
70
|
});
|
|
71
71
|
} else {
|
|
72
72
|
let e = t.getBoundingClientRect();
|
|
73
|
-
|
|
74
|
-
left: e.left -
|
|
73
|
+
b({
|
|
74
|
+
left: e.left - x.current.getBoundingClientRect().left,
|
|
75
75
|
width: e.width,
|
|
76
76
|
opacity: 1
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
} else
|
|
81
|
-
}, [
|
|
80
|
+
} else b({ opacity: 0 });
|
|
81
|
+
}, [_, f]);
|
|
82
82
|
r(() => {
|
|
83
|
-
|
|
84
|
-
}, [
|
|
85
|
-
let e =
|
|
83
|
+
C();
|
|
84
|
+
}, [C]), n(() => {
|
|
85
|
+
let e = x.current;
|
|
86
86
|
if (!e || typeof ResizeObserver > "u") return;
|
|
87
|
-
let t = new ResizeObserver(() =>
|
|
87
|
+
let t = new ResizeObserver(() => C());
|
|
88
88
|
return t.observe(e), e.querySelectorAll("a").forEach((e) => t.observe(e)), () => t.disconnect();
|
|
89
|
-
}, [
|
|
90
|
-
let
|
|
89
|
+
}, [C, l]);
|
|
90
|
+
let w = (t) => /* @__PURE__ */ s("ul", {
|
|
91
91
|
className: o(e.list, e[f]),
|
|
92
92
|
children: t.map((t) => /* @__PURE__ */ c("li", {
|
|
93
|
-
className: o(e.item,
|
|
93
|
+
className: o(e.item, _ === t.href && e.active),
|
|
94
94
|
children: [/* @__PURE__ */ s("a", {
|
|
95
95
|
href: t.href,
|
|
96
96
|
className: e.link,
|
|
97
|
-
"aria-current":
|
|
98
|
-
onClick: (e) =>
|
|
97
|
+
"aria-current": _ === t.href ? "location" : void 0,
|
|
98
|
+
onClick: (e) => S(e, t.href),
|
|
99
99
|
title: typeof t.title == "string" ? t.title : void 0,
|
|
100
100
|
children: t.title
|
|
101
|
-
}), t.children && f === "vertical" &&
|
|
101
|
+
}), t.children && f === "vertical" && w(t.children)]
|
|
102
102
|
}, t.key))
|
|
103
103
|
});
|
|
104
104
|
return /* @__PURE__ */ c("div", {
|
|
105
105
|
className: o("wim-anchor", e.root, e[f], p),
|
|
106
106
|
style: m,
|
|
107
|
-
ref:
|
|
107
|
+
ref: x,
|
|
108
|
+
role: h || g ? "navigation" : void 0,
|
|
109
|
+
"aria-label": g ? void 0 : h,
|
|
110
|
+
"aria-labelledby": g,
|
|
108
111
|
children: [/* @__PURE__ */ s("div", {
|
|
109
112
|
className: e.ink,
|
|
110
113
|
children: /* @__PURE__ */ s("span", {
|
|
111
114
|
className: e.inkBall,
|
|
112
|
-
style:
|
|
115
|
+
style: y
|
|
113
116
|
})
|
|
114
|
-
}),
|
|
117
|
+
}), w(l)]
|
|
115
118
|
});
|
|
116
119
|
};
|
|
117
120
|
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../overlay/Portal/Portal.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../overlay/FocusTrap/FocusTrap.cjs"),a=require("../../../i18n/generated/components.cjs"),o=require("../../../icon/search.cjs"),s=require("../../media/Icon/Icon.cjs"),c=require("../../_internal/BaseListItem/BaseListItem.cjs"),l=require("./command-palette.module.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("classnames");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p=(0,u.createContext)(void 0),m=()=>{let e=(0,u.useContext)(p);if(!e)throw Error(`CommandPalette sub-components must be used within a CommandPalette`);return e},h=({children:e,open:t,onOpenChange:n})=>{let[r,i]=(0,u.useState)(!1),[a,o]=(0,u.useState)(``),[s,c]=(0,u.useState)(0),[l,d]=(0,u.useState)(!1),m=(0,u.useRef)(0),h=t!==void 0,g=h?t:r,_=(0,u.useCallback)(e=>{h||i(e),n?.(e),e||(o(``),c(0))},[h,n]),v=(0,u.useCallback)(()=>{let e=m.current;return m.current+=1,e},[]),y=(0,u.useCallback)(()=>{--m.current},[]);m.current=0,(0,u.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),d(!0),_(!g)),e.key===`Escape`&&g&&_(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,_]);let b=u.default.useMemo(()=>({open:g,onOpenChange:_,search:a,setSearch:o,activeIndex:s,setActiveIndex:c,registerItem:v,unregisterItem:y,isKeyboardNavigating:l,setIsKeyboardNavigating:d}),[g,_,a,s,v,y,l]);return(0,f.jsx)(p.Provider,{value:b,children:e})},g=({children:e,asChild:t,className:n})=>{let{onOpenChange:r,setIsKeyboardNavigating:i}=m(),a=e=>{i(e.detail===0),r(!0)};return t&&u.default.isValidElement(e)?u.default.cloneElement(e,{onClick:t=>{e.props.onClick?.(t),a(t)},className:(0,d.default)(n,e.props.className)}):(0,f.jsx)(`button`,{className:(0,d.default)(l.default.trigger,n),onClick:a,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&i(!0)},children:e})},_=({children:e,className:o,"aria-label":s})=>{let{t:
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../overlay/Portal/Portal.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../overlay/FocusTrap/FocusTrap.cjs"),a=require("../../../i18n/generated/components.cjs"),o=require("../../../icon/search.cjs"),s=require("../../media/Icon/Icon.cjs"),c=require("../../_internal/BaseListItem/BaseListItem.cjs"),l=require("./command-palette.module.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("classnames");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p=(0,u.createContext)(void 0),m=()=>{let e=(0,u.useContext)(p);if(!e)throw Error(`CommandPalette sub-components must be used within a CommandPalette`);return e},h=({children:e,open:t,onOpenChange:n})=>{let[r,i]=(0,u.useState)(!1),[a,o]=(0,u.useState)(``),[s,c]=(0,u.useState)(0),[l,d]=(0,u.useState)(!1),m=(0,u.useRef)(0),h=t!==void 0,g=h?t:r,_=(0,u.useCallback)(e=>{h||i(e),n?.(e),e||(o(``),c(0))},[h,n]),v=(0,u.useCallback)(()=>{let e=m.current;return m.current+=1,e},[]),y=(0,u.useCallback)(()=>{--m.current},[]);m.current=0,(0,u.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),d(!0),_(!g)),e.key===`Escape`&&g&&_(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,_]);let b=u.default.useMemo(()=>({open:g,onOpenChange:_,search:a,setSearch:o,activeIndex:s,setActiveIndex:c,registerItem:v,unregisterItem:y,isKeyboardNavigating:l,setIsKeyboardNavigating:d}),[g,_,a,s,v,y,l]);return(0,f.jsx)(p.Provider,{value:b,children:e})},g=({children:e,asChild:t,className:n})=>{let{onOpenChange:r,setIsKeyboardNavigating:i}=m(),a=e=>{i(e.detail===0),r(!0)};return t&&u.default.isValidElement(e)?u.default.cloneElement(e,{onClick:t=>{e.props.onClick?.(t),a(t)},className:(0,d.default)(n,e.props.className)}):(0,f.jsx)(`button`,{className:(0,d.default)(l.default.trigger,n),onClick:a,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&i(!0)},children:e})},_=({children:e,className:o,"aria-label":s,"aria-labelledby":c,"aria-describedby":p})=>{let{t:h}=t.useWimTranslation(a.componentsNs),{open:g,onOpenChange:_,activeIndex:v,setActiveIndex:y,isKeyboardNavigating:b,setIsKeyboardNavigating:x}=m(),S=(0,u.useRef)(null);return(0,f.jsx)(n.Portal,{children:(0,f.jsx)(r.Transition,{show:g,preset:`fade`,children:(0,f.jsx)(`div`,{role:`presentation`,className:l.default.overlay,onClick:e=>{e.target===e.currentTarget&&_(!1)},children:(0,f.jsx)(r.Transition,{show:g,preset:`scale`,children:(0,f.jsx)(i.FocusTrap,{active:g,children:(0,f.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":c?void 0:s??h(`command_palette.label`),"aria-labelledby":c,"aria-describedby":p,className:(0,d.default)(`wim-command-palette`,l.default.content,o),onClick:e=>e.stopPropagation(),onMouseMove:e=>{if(!S.current){S.current={x:e.clientX,y:e.clientY};return}Math.sqrt((e.clientX-S.current.x)**2+(e.clientY-S.current.y)**2)>10&&x(!1),S.current={x:e.clientX,y:e.clientY}},"data-keyboard-nav":b,onKeyDown:e=>{x(!0);let t=e.currentTarget.querySelectorAll(`.${l.default.item}:not([aria-disabled="true"])`).length;t!==0&&(e.key===`ArrowDown`?(e.preventDefault(),y(e=>(e+1)%t)):e.key===`ArrowUp`?(e.preventDefault(),y(e=>(e-1+t)%t)):e.key===`Home`?(e.preventDefault(),y(0)):e.key===`End`?(e.preventDefault(),y(t-1)):e.key===`Enter`&&(e.preventDefault(),document.getElementById(`wim-command-palette-item-${v}`)?.click()))},children:e})})})})})})},v=({placeholder:e,value:t,onChange:n,rightSection:r})=>{let{search:i,setSearch:a,setActiveIndex:c,activeIndex:d}=m(),p=(0,u.useRef)(null);return(0,u.useEffect)(()=>{p.current?.focus()},[]),(0,f.jsxs)(`div`,{className:l.default.inputWrapper,children:[(0,f.jsx)(s.Icon,{component:o.default,size:`sm`}),(0,f.jsx)(`input`,{ref:p,className:l.default.input,placeholder:e,value:t??i,onChange:e=>{let t=e.target.value;a(t),c(0),n?.(t)},role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":!0,"aria-controls":`wim-command-palette-listbox`,"aria-activedescendant":`wim-command-palette-item-${d}`}),r&&(0,f.jsx)(`div`,{className:l.default.inputRight,children:r})]})},y=({children:e,"aria-label":n,"aria-labelledby":r})=>{let{t:i}=t.useWimTranslation(a.componentsNs);return(0,f.jsx)(`div`,{className:l.default.list,role:`listbox`,id:`wim-command-palette-listbox`,"aria-label":r?void 0:n??i(`command_palette.label`),"aria-labelledby":r,children:e})},b=({children:e,heading:t})=>{let n=u.default.useId();return(0,f.jsxs)(`div`,{className:l.default.group,role:`group`,"aria-labelledby":t?n:void 0,children:[t&&(0,f.jsx)(`div`,{id:n,className:l.default.groupHeading,"aria-hidden":`true`,children:t}),e]})},x=({children:e,onSelect:t,icon:n,shortcut:r,disabled:i})=>{let{activeIndex:a,setActiveIndex:o,registerItem:s,onOpenChange:d}=m(),[p]=(0,u.useState)(()=>s()),h=a===p;return(0,u.useEffect)(()=>{h&&!i&&document.getElementById(`wim-command-palette-item-${p}`)?.scrollIntoView({block:`nearest`})},[h,i,p]),(0,f.jsx)(c.BaseListItem,{role:`option`,id:`wim-command-palette-item-${p}`,"aria-selected":h,className:l.default.item,active:h,disabled:i,icon:n,rightSection:r&&(0,f.jsx)(`div`,{className:l.default.shortcut,children:r.map(e=>(0,f.jsx)(`kbd`,{className:l.default.kbd,children:e},e))}),onMouseEnter:()=>!i&&o(p),onClick:()=>{i||(t?.(),d(!1))},children:e})},S=({children:e})=>{let{t:n}=t.useWimTranslation(a.componentsNs),r=e??n(`command_palette.no_results`),{open:i,search:o}=m(),[s,c]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{if(i){let e=setTimeout(()=>{let e=document.querySelectorAll(`.${l.default.item}`);c(e.length===0)},0);return()=>clearTimeout(e)}},[i,o]),!i||!s?null:(0,f.jsx)(`div`,{className:l.default.empty,children:r})},C=({children:e})=>(0,f.jsx)(`div`,{className:l.default.footer,children:e});exports.CommandPalette=h,exports.CommandPaletteContent=_,exports.CommandPaletteEmpty=S,exports.CommandPaletteFooter=C,exports.CommandPaletteGroup=b,exports.CommandPaletteInput=v,exports.CommandPaletteItem=x,exports.CommandPaletteList=y,exports.CommandPaletteTrigger=g;
|