@lax-wp/design-system 0.14.39 → 0.14.41
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/data-display/infinite-table/context.cjs.js +1 -1
- package/dist/components/data-display/infinite-table/context.cjs.js.map +1 -1
- package/dist/components/data-display/infinite-table/context.d.ts +0 -1
- package/dist/components/data-display/infinite-table/context.es.js +2 -3
- package/dist/components/data-display/infinite-table/context.es.js.map +1 -1
- package/dist/components/data-display/infinite-table/head/cell/index.cjs.js +1 -1
- package/dist/components/data-display/infinite-table/head/cell/index.cjs.js.map +1 -1
- package/dist/components/data-display/infinite-table/head/cell/index.es.js +19 -21
- package/dist/components/data-display/infinite-table/head/cell/index.es.js.map +1 -1
- package/dist/components/data-display/infinite-table/index.cjs.js +1 -1
- package/dist/components/data-display/infinite-table/index.cjs.js.map +1 -1
- package/dist/components/data-display/infinite-table/index.es.js +396 -400
- package/dist/components/data-display/infinite-table/index.es.js.map +1 -1
- package/dist/components/navigation/tabs/TabSwitch.cjs.js +1 -1
- package/dist/components/navigation/tabs/TabSwitch.cjs.js.map +1 -1
- package/dist/components/navigation/tabs/TabSwitch.d.ts +3 -1
- package/dist/components/navigation/tabs/TabSwitch.es.js +88 -67
- package/dist/components/navigation/tabs/TabSwitch.es.js.map +1 -1
- package/dist/components/navigation/tabs/Tabs.cjs.js +1 -1
- package/dist/components/navigation/tabs/Tabs.cjs.js.map +1 -1
- package/dist/components/navigation/tabs/Tabs.d.ts +1 -1
- package/dist/components/navigation/tabs/Tabs.es.js +339 -325
- package/dist/components/navigation/tabs/Tabs.es.js.map +1 -1
- package/dist/components/navigation/tabs/types.cjs.js.map +1 -1
- package/dist/components/navigation/tabs/types.d.ts +13 -0
- package/dist/components/navigation/tabs/types.es.js.map +1 -1
- package/dist/utils/table.cjs.js +1 -1
- package/dist/utils/table.cjs.js.map +1 -1
- package/dist/utils/table.d.ts +1 -0
- package/dist/utils/table.es.js +26 -25
- package/dist/utils/table.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,92 +1,113 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { Children as
|
|
4
|
-
import { useTranslation as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { jsxs as v, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import a from "../../../_virtual/index.es.js";
|
|
3
|
+
import { Children as d } from "./Children.es.js";
|
|
4
|
+
import { useTranslation as A } from "react-i18next";
|
|
5
|
+
import E from "../../tooltip/Tooltip.es.js";
|
|
6
|
+
import { LockFilledIcon as F } from "../../icon/icons.generated.es.js";
|
|
7
|
+
const z = "You don’t have permission to access this tab content.", G = ({
|
|
8
|
+
showCounts: N = !0,
|
|
9
|
+
title: t,
|
|
10
|
+
icon: w,
|
|
11
|
+
suffixRecord: u,
|
|
12
|
+
classValue: T,
|
|
13
|
+
isSelected: i,
|
|
14
|
+
selectedClassValue: I,
|
|
15
|
+
textClassValue: $,
|
|
16
|
+
selectedId: C,
|
|
17
|
+
iconsOnly: m,
|
|
18
|
+
draggingTab: h,
|
|
19
|
+
disableAnimation: K,
|
|
20
|
+
tabOptions: y,
|
|
21
|
+
color: b = "light",
|
|
22
|
+
isLocked: k = !1,
|
|
23
|
+
lockedTooltip: L,
|
|
24
|
+
href: o,
|
|
25
|
+
onClick: p,
|
|
26
|
+
role: D,
|
|
27
|
+
ariaSelected: P,
|
|
28
|
+
tabIndex: _,
|
|
29
|
+
onKeyDown: j
|
|
26
30
|
}) => {
|
|
27
|
-
const { t:
|
|
28
|
-
selectedId:
|
|
29
|
-
isSelected:
|
|
30
|
-
selectedClassValue:
|
|
31
|
-
textClassValue:
|
|
32
|
-
disableAnimation:
|
|
33
|
-
},
|
|
34
|
-
role:
|
|
35
|
-
"aria-selected":
|
|
36
|
-
tabIndex:
|
|
37
|
-
onKeyDown:
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
/* @__PURE__ */ r("div", { className:
|
|
41
|
-
|
|
31
|
+
const { t: g } = A(), c = {
|
|
32
|
+
selectedId: C,
|
|
33
|
+
isSelected: i,
|
|
34
|
+
selectedClassValue: I,
|
|
35
|
+
textClassValue: $,
|
|
36
|
+
disableAnimation: K
|
|
37
|
+
}, s = {
|
|
38
|
+
role: D,
|
|
39
|
+
"aria-selected": P,
|
|
40
|
+
tabIndex: _,
|
|
41
|
+
onKeyDown: j
|
|
42
|
+
}, x = k ? /* @__PURE__ */ r(F, { size: 16 }) : w, e = /* @__PURE__ */ v("div", { className: a("flex items-center text-center", "opacity-100", m ? "" : "gap-1.5"), children: [
|
|
43
|
+
x ? /* @__PURE__ */ r("div", { className: i ? "opacity-100" : `opacity-40 ${b === "dark" ? "dark:opacity-100 dark:text-black-100" : ""}`, children: x }) : null,
|
|
44
|
+
/* @__PURE__ */ r("div", { className: i ? "opacity-100" : "opacity-80", children: m ? null : g(t || "") }),
|
|
45
|
+
t !== "More..." && u?.[t || ""] !== void 0 && N ? /* @__PURE__ */ r(
|
|
42
46
|
"span",
|
|
43
47
|
{
|
|
44
|
-
className:
|
|
48
|
+
className: a(
|
|
45
49
|
"ml-2 text-xs leading-4 font-normal border rounded-full pr-2 pl-2 border-1",
|
|
46
|
-
|
|
50
|
+
i ? a(
|
|
47
51
|
"text-primary-700 border-primary-200 dark:!border-primary-600 border-1",
|
|
48
|
-
|
|
49
|
-
) :
|
|
52
|
+
b === "dark" ? "text-white bg-primary-700" : "bg-neutral-100 dark:bg-primary-700 dark:text-white"
|
|
53
|
+
) : a(
|
|
50
54
|
"text-neutral-500 dark:text-neutral-400 border-neutral-300 dark:border-neutral-500 border-1",
|
|
51
|
-
|
|
55
|
+
b === "dark" ? "bg-neutral-800 dark:bg-neutral-700 dark:border-neutral-800" : "bg-neutral-100 dark:bg-transparent"
|
|
52
56
|
)
|
|
53
57
|
),
|
|
54
|
-
children: String(
|
|
58
|
+
children: String(u?.[t || ""] ?? "0")
|
|
55
59
|
}
|
|
56
60
|
) : null
|
|
57
|
-
] }),
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
] }), l = a(
|
|
62
|
+
T,
|
|
63
|
+
h ? "opacity-0 cursor-grabbing" : "",
|
|
60
64
|
"focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:outline-none"
|
|
61
|
-
)
|
|
62
|
-
|
|
65
|
+
);
|
|
66
|
+
if (k)
|
|
67
|
+
return /* @__PURE__ */ r(E, { title: g(L || z), placement: "bottom", children: /* @__PURE__ */ r(
|
|
68
|
+
"button",
|
|
69
|
+
{
|
|
70
|
+
id: `btn-tabs-tabswitch-${t}`,
|
|
71
|
+
className: a(
|
|
72
|
+
l,
|
|
73
|
+
"cursor-not-allowed opacity-60 hover:opacity-100 hover:bg-neutral-100 dark:hover:bg-black-700"
|
|
74
|
+
),
|
|
75
|
+
type: "button",
|
|
76
|
+
"aria-disabled": !0,
|
|
77
|
+
...s,
|
|
78
|
+
children: /* @__PURE__ */ r(d, { ...c, children: e })
|
|
79
|
+
}
|
|
80
|
+
) });
|
|
81
|
+
const f = (n) => {
|
|
82
|
+
n.metaKey || n.ctrlKey || n.shiftKey || n.button !== 0 || (n.preventDefault(), p?.());
|
|
63
83
|
};
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
] }) }) }) :
|
|
84
|
+
return y ? /* @__PURE__ */ r("div", { id: `btn-tabs-tabswitch-${t}`, className: l, ...s, children: /* @__PURE__ */ r(d, { ...c, children: /* @__PURE__ */ v("div", { className: "flex items-center gap-1", children: [
|
|
85
|
+
o ? /* @__PURE__ */ r("a", { href: o, onClick: f, className: "contents uppercase", tabIndex: -1, children: e }) : /* @__PURE__ */ r("button", { type: "button", onClick: p, className: "contents uppercase", tabIndex: -1, children: e }),
|
|
86
|
+
y
|
|
87
|
+
] }) }) }) : o ? /* @__PURE__ */ r(
|
|
68
88
|
"a",
|
|
69
89
|
{
|
|
70
|
-
id: `btn-tabs-tabswitch-${
|
|
71
|
-
href:
|
|
72
|
-
className:
|
|
73
|
-
onClick:
|
|
74
|
-
...
|
|
75
|
-
children: /* @__PURE__ */ r(
|
|
90
|
+
id: `btn-tabs-tabswitch-${t}`,
|
|
91
|
+
href: o,
|
|
92
|
+
className: l,
|
|
93
|
+
onClick: f,
|
|
94
|
+
...s,
|
|
95
|
+
children: /* @__PURE__ */ r(d, { ...c, children: e })
|
|
76
96
|
}
|
|
77
97
|
) : /* @__PURE__ */ r(
|
|
78
98
|
"button",
|
|
79
99
|
{
|
|
80
|
-
id: `btn-tabs-tabswitch-${
|
|
81
|
-
className:
|
|
100
|
+
id: `btn-tabs-tabswitch-${t}`,
|
|
101
|
+
className: l,
|
|
82
102
|
type: "button",
|
|
83
|
-
onClick:
|
|
84
|
-
...
|
|
85
|
-
children: /* @__PURE__ */ r(
|
|
103
|
+
onClick: p,
|
|
104
|
+
...s,
|
|
105
|
+
children: /* @__PURE__ */ r(d, { ...c, children: e })
|
|
86
106
|
}
|
|
87
107
|
);
|
|
88
108
|
};
|
|
89
109
|
export {
|
|
90
|
-
|
|
110
|
+
z as DEFAULT_LOCKED_TAB_TOOLTIP,
|
|
111
|
+
G as TabSwitch
|
|
91
112
|
};
|
|
92
113
|
//# sourceMappingURL=TabSwitch.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabSwitch.es.js","sources":["../../../../src/components/navigation/tabs/TabSwitch.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport type { MouseEvent } from 'react';\nimport { Children } from './Children';\nimport { useTranslation } from 'react-i18next'\nimport type { TabSwitchProps } from './types';\n\nexport const TabSwitch = ({\n showCounts = true,\n title,\n icon,\n suffixRecord,\n classValue,\n isSelected,\n selectedClassValue,\n textClassValue,\n selectedId,\n iconsOnly,\n draggingTab,\n disableAnimation,\n tabOptions,\n color = 'light',\n href,\n onClick,\n role,\n ariaSelected,\n tabIndex,\n onKeyDown,\n}: TabSwitchProps) => {\n const { t } = useTranslation();\n const childrenProps = {\n selectedId,\n isSelected,\n selectedClassValue,\n textClassValue,\n disableAnimation,\n };\n\n const ariaProps = {\n role,\n 'aria-selected': ariaSelected,\n tabIndex,\n onKeyDown,\n };\n\n const text = (\n <div className={classNames('flex items-center text-center', draggingTab ? 'opacity-100' : 'opacity-100', !iconsOnly ? 'gap-1.5' : '')}>\n {
|
|
1
|
+
{"version":3,"file":"TabSwitch.es.js","sources":["../../../../src/components/navigation/tabs/TabSwitch.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport type { MouseEvent } from 'react';\nimport { Children } from './Children';\nimport { useTranslation } from 'react-i18next'\nimport { LockFilledIcon } from '../../icon';\nimport Tooltip from '../../tooltip/Tooltip';\nimport type { TabSwitchProps } from './types';\n\n/** Default message shown when a tab is locked */\nexport const DEFAULT_LOCKED_TAB_TOOLTIP =\n 'You don\\u2019t have permission to access this tab content.';\n\nexport const TabSwitch = ({\n showCounts = true,\n title,\n icon,\n suffixRecord,\n classValue,\n isSelected,\n selectedClassValue,\n textClassValue,\n selectedId,\n iconsOnly,\n draggingTab,\n disableAnimation,\n tabOptions,\n color = 'light',\n isLocked = false,\n lockedTooltip,\n href,\n onClick,\n role,\n ariaSelected,\n tabIndex,\n onKeyDown,\n}: TabSwitchProps) => {\n const { t } = useTranslation();\n const childrenProps = {\n selectedId,\n isSelected,\n selectedClassValue,\n textClassValue,\n disableAnimation,\n };\n\n const ariaProps = {\n role,\n 'aria-selected': ariaSelected,\n tabIndex,\n onKeyDown,\n };\n\n const leadingIcon = isLocked ? <LockFilledIcon size={16} /> : icon;\n\n const text = (\n <div className={classNames('flex items-center text-center', draggingTab ? 'opacity-100' : 'opacity-100', !iconsOnly ? 'gap-1.5' : '')}>\n {leadingIcon ? (\n <div className={isSelected ? 'opacity-100' : `opacity-40 ${color === 'dark' ? 'dark:opacity-100 dark:text-black-100' : ''}`}>\n {leadingIcon}\n </div>\n ) : null}\n <div className={isSelected ? 'opacity-100' : 'opacity-80'}>\n {iconsOnly ? null : t(title || '')}\n </div>\n {title !== 'More...' && suffixRecord?.[title || ''] !== undefined && showCounts ? (\n <span\n className={classNames(\n 'ml-2 text-xs leading-4 font-normal border rounded-full pr-2 pl-2 border-1',\n isSelected\n ? classNames(\n 'text-primary-700 border-primary-200 dark:!border-primary-600 border-1',\n color === 'dark'\n ? 'text-white bg-primary-700'\n : 'bg-neutral-100 dark:bg-primary-700 dark:text-white',\n )\n : classNames(\n 'text-neutral-500 dark:text-neutral-400 border-neutral-300 dark:border-neutral-500 border-1',\n color === 'dark'\n ? 'bg-neutral-800 dark:bg-neutral-700 dark:border-neutral-800'\n : 'bg-neutral-100 dark:bg-transparent',\n ),\n )}\n >\n {String(suffixRecord?.[title || ''] ?? '0')}\n </span>\n ) : null}\n </div>\n );\n\n const sharedClassName = classNames(\n classValue,\n draggingTab ? 'opacity-0 cursor-grabbing' : '',\n 'focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:outline-none',\n );\n\n if (isLocked) {\n return (\n <Tooltip title={t(lockedTooltip || DEFAULT_LOCKED_TAB_TOOLTIP)} placement=\"bottom\">\n <button\n id={`btn-tabs-tabswitch-${title}`}\n className={classNames(\n sharedClassName,\n 'cursor-not-allowed opacity-60 hover:opacity-100 hover:bg-neutral-100 dark:hover:bg-black-700',\n )}\n type=\"button\"\n aria-disabled\n {...ariaProps}\n >\n <Children {...childrenProps}>{text}</Children>\n </button>\n </Tooltip>\n );\n }\n\n const handleLinkClick = (e: MouseEvent<HTMLAnchorElement>) => {\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return;\n e.preventDefault();\n onClick?.();\n };\n\n if (tabOptions) {\n return (\n <div id={`btn-tabs-tabswitch-${title}`} className={sharedClassName} {...ariaProps}>\n <Children {...childrenProps}>\n <div className=\"flex items-center gap-1\">\n {href ? (\n <a href={href} onClick={handleLinkClick} className=\"contents uppercase\" tabIndex={-1}>\n {text}\n </a>\n ) : (\n <button type=\"button\" onClick={onClick} className=\"contents uppercase\" tabIndex={-1}>\n {text}\n </button>\n )}\n {tabOptions}\n </div>\n </Children>\n </div>\n );\n }\n\n if (href) {\n return (\n <a\n id={`btn-tabs-tabswitch-${title}`}\n href={href}\n className={sharedClassName}\n onClick={handleLinkClick}\n {...ariaProps}\n >\n <Children {...childrenProps}>{text}</Children>\n </a>\n );\n }\n\n return (\n <button\n id={`btn-tabs-tabswitch-${title}`}\n className={sharedClassName}\n type='button'\n onClick={onClick}\n {...ariaProps}\n >\n <Children {...childrenProps}>{text}</Children>\n </button>\n );\n};\n"],"names":["DEFAULT_LOCKED_TAB_TOOLTIP","TabSwitch","showCounts","title","icon","suffixRecord","classValue","isSelected","selectedClassValue","textClassValue","selectedId","iconsOnly","draggingTab","disableAnimation","tabOptions","color","isLocked","lockedTooltip","href","onClick","role","ariaSelected","tabIndex","onKeyDown","t","useTranslation","childrenProps","ariaProps","leadingIcon","jsx","LockFilledIcon","text","jsxs","classNames","sharedClassName","Tooltip","Children","handleLinkClick","e"],"mappings":";;;;;;AASO,MAAMA,IACX,yDAEWC,IAAY,CAAC;AAAA,EACxB,YAAAC,IAAa;AAAA,EACb,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,cAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,UAAAC,IAAW;AAAA,EACX,eAAAC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AACF,MAAsB;AACpB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAA,GACRC,IAAgB;AAAA,IACpB,YAAAhB;AAAA,IACA,YAAAH;AAAA,IACA,oBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,kBAAAI;AAAA,EAAA,GAGIc,IAAY;AAAA,IAChB,MAAAP;AAAA,IACA,iBAAiBC;AAAA,IACjB,UAAAC;AAAA,IACA,WAAAC;AAAA,EAAA,GAGIK,IAAcZ,IAAW,gBAAAa,EAACC,GAAA,EAAe,MAAM,IAAI,IAAK1B,GAExD2B,IACJ,gBAAAC,EAAC,OAAA,EAAI,WAAWC,EAAW,iCAA+C,eAAgCtB,IAAwB,KAAZ,SAAc,GACjI,UAAA;AAAA,IAAAiB,IACC,gBAAAC,EAAC,OAAA,EAAI,WAAWtB,IAAa,gBAAgB,cAAcQ,MAAU,SAAS,yCAAyC,EAAE,IACtH,UAAAa,EAAA,CACH,IACE;AAAA,IACJ,gBAAAC,EAAC,OAAA,EAAI,WAAWtB,IAAa,gBAAgB,cAC1C,UAAAI,IAAY,OAAOa,EAAErB,KAAS,EAAE,EAAA,CACnC;AAAA,IACCA,MAAU,aAAaE,IAAeF,KAAS,EAAE,MAAM,UAAaD,IACnE,gBAAA2B;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWI;AAAAA,UACT;AAAA,UACA1B,IACI0B;AAAAA,YACA;AAAA,YACAlB,MAAU,SACN,8BACA;AAAA,UAAA,IAEJkB;AAAAA,YACA;AAAA,YACAlB,MAAU,SACN,+DACA;AAAA,UAAA;AAAA,QACN;AAAA,QAGH,UAAA,OAAOV,IAAeF,KAAS,EAAE,KAAK,GAAG;AAAA,MAAA;AAAA,IAAA,IAE1C;AAAA,EAAA,GACN,GAGI+B,IAAkBD;AAAAA,IACtB3B;AAAA,IACAM,IAAc,8BAA8B;AAAA,IAC5C;AAAA,EAAA;AAGF,MAAII;AACF,WACE,gBAAAa,EAACM,KAAQ,OAAOX,EAAEP,KAAiBjB,CAA0B,GAAG,WAAU,UACxE,UAAA,gBAAA6B;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI,sBAAsB1B,CAAK;AAAA,QAC/B,WAAW8B;AAAAA,UACTC;AAAA,UACA;AAAA,QAAA;AAAA,QAEF,MAAK;AAAA,QACL,iBAAa;AAAA,QACZ,GAAGP;AAAA,QAEJ,UAAA,gBAAAE,EAACO,GAAA,EAAU,GAAGV,GAAgB,UAAAK,EAAA,CAAK;AAAA,MAAA;AAAA,IAAA,GAEvC;AAIJ,QAAMM,IAAkB,CAACC,MAAqC;AAC5D,IAAIA,EAAE,WAAWA,EAAE,WAAWA,EAAE,YAAYA,EAAE,WAAW,MACzDA,EAAE,eAAA,GACFnB,IAAA;AAAA,EACF;AAEA,SAAIL,sBAEC,OAAA,EAAI,IAAI,sBAAsBX,CAAK,IAAI,WAAW+B,GAAkB,GAAGP,GACtE,4BAACS,GAAA,EAAU,GAAGV,GACZ,UAAA,gBAAAM,EAAC,OAAA,EAAI,WAAU,2BACZ,UAAA;AAAA,IAAAd,IACC,gBAAAW,EAAC,OAAE,MAAAX,GAAY,SAASmB,GAAiB,WAAU,sBAAqB,UAAU,IAC/E,UAAAN,EAAA,CACH,IAEA,gBAAAF,EAAC,UAAA,EAAO,MAAK,UAAS,SAAAV,GAAkB,WAAU,sBAAqB,UAAU,IAC9E,UAAAY,EAAA,CACH;AAAA,IAEDjB;AAAA,EAAA,EAAA,CACH,GACF,GACF,IAIAI,IAEA,gBAAAW;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAI,sBAAsB1B,CAAK;AAAA,MAC/B,MAAAe;AAAA,MACA,WAAWgB;AAAA,MACX,SAASG;AAAA,MACR,GAAGV;AAAA,MAEJ,UAAA,gBAAAE,EAACO,GAAA,EAAU,GAAGV,GAAgB,UAAAK,EAAA,CAAK;AAAA,IAAA;AAAA,EAAA,IAMvC,gBAAAF;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAI,sBAAsB1B,CAAK;AAAA,MAC/B,WAAW+B;AAAA,MACX,MAAK;AAAA,MACL,SAAAf;AAAA,MACC,GAAGQ;AAAA,MAEJ,UAAA,gBAAAE,EAACO,GAAA,EAAU,GAAGV,GAAgB,UAAAK,EAAA,CAAK;AAAA,IAAA;AAAA,EAAA;AAGzC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),v=require("@dnd-kit/core"),ne=require("@dnd-kit/sortable"),we=require("antd"),c=require("../../../_virtual/index.cjs.js"),a=require("react"),Dt=require("react-i18next"),Je=require("@mui/icons-material/MoreHorizOutlined"),Vt=require("./types.cjs.js"),Mt=require("../../../utils/formatters.cjs.js"),Lt=require("../../../providers/design-system-provider/hooks.cjs.js"),qt=require("../../../hooks/useTextWidth.cjs.js"),Rt=require("../../button/IconButton.cjs.js"),S=require("../../buttons/option-button/OptionButton.cjs.js"),Bt=require("../../forms/search-bar/SearchBar.cjs.js"),ke=require("../../tooltip/Tooltip.cjs.js"),Ht=require("../../icons/EditIcon.cjs.js"),Ut=require("react-toastify"),ye=require("./TabSwitch.cjs.js"),k=require("../../icon/icons.generated.cjs.js"),Qe=require("./SortableTab.cjs.js"),Wt=require("./DropableWrapper.cjs.js"),Pt=require("./MoreButton.cjs.js"),Ft=require("./TabOptions.cjs.js"),zt=require("./TabDragOverlay.cjs.js"),$t=()=>Math.random().toString(16).slice(2,13),se=["[&_.ant-dropdown-menu-item]:!outline-none","[&_.ant-dropdown-menu-submenu-title]:!outline-none","[&_.ant-dropdown-menu-item:focus-visible_.option-button-inner]:ring-2","[&_.ant-dropdown-menu-item:focus-visible_.option-button-inner]:ring-primary-500","[&_.ant-dropdown-menu-item:focus-visible_.option-button-inner]:bg-gray-50","[&_.ant-dropdown-menu-item:focus-visible_.option-button-inner]:dark:bg-black-600","[&_.ant-dropdown-menu-submenu-title:focus-visible_.option-button-inner]:ring-2","[&_.ant-dropdown-menu-submenu-title:focus-visible_.option-button-inner]:ring-primary-500","[&_.ant-dropdown-menu-submenu-title:focus-visible_.option-button-inner]:bg-gray-50","[&_.ant-dropdown-menu-submenu-title:focus-visible_.option-button-inner]:dark:bg-black-600"].join(" ");let Se=null;const Te=T=>{T?(Se=document.activeElement,setTimeout(()=>{document.querySelector(".row-option-cell .ant-dropdown-menu-item:not(.ant-dropdown-menu-item-disabled), .row-option-cell .ant-dropdown-menu-submenu-title")?.focus()},50)):setTimeout(()=>{Se?.focus(),Se=null},0)},d={SELECT:"Select",MOVE_LEFT:"MoveLeft",MOVE_RIGHT:"MoveRight",HIDE:"Hide",UNHIDE:"Unhide",COPY_LINK:"CopyLink",DELETE:"Delete",PIN:"Pin",UNPIN:"Unpin",EDIT:"Edit"},At=({variant:T="default",tabs:O=[],activeTab:r,onTabClick:Xe,suffixRecord:F,isLoading:Ze,size:_="md",className:Ce,draggable:E=!1,showAllItems:z=!1,copyLink:Ke=!1,isDisabled:et=!1,color:ae="light",iconsOnly:tt=!1,tabIcons:oe={},height:nt="h-6",fullWidth:ie=!1,fitContentWidth:st=!1,disableAnimation:at=!1,onEdit:je,onDelete:Ie,onCopyLink:Ne,allowPin:C=!1,isFullWidth:$=!1,rightSection:L,initialTabs:ot,tabConfig:it,onTabConfigChange:ve,onTabsChange:Oe,parentContainer:rt=document.body,tabKey:j,linkConfig:x,showTabOptions:lt=!0})=>{const g=Lt.useTabConfig(),_e=j?g?.getTabSettings(j):void 0,re=ot??_e?.tab_items,A=it??_e?.tab_options,[le,ct]=a.useState(""),[N,G]=a.useState(!1),[q,dt]=a.useState(0),[u,ce]=a.useState([]),[Y,ut]=a.useState([]),[pt,J]=a.useState(null),[D,Q]=a.useState(null),[xt,Ee]=a.useState(!1),[De,Ve]=a.useState(A??Vt.INITIAL_TAB_OPTION_CONFIG),[de,bt]=a.useState(""),[Me,mt]=a.useState("contains"),{showCounts:y,lockOrder:R,sortOrder:ue}=De,{t:p}=Dt.useTranslation(),X=a.useRef(null),ht=a.useRef(null),Le=a.useRef(q),{measureText:B}=qt.useTextWidth(),H=a.useMemo(()=>$t(),[]),ft=v.useSensors(v.useSensor(v.MouseSensor,{activationConstraint:{distance:5}}),v.useSensor(v.TouchSensor,{activationConstraint:{delay:300,tolerance:5}})),b=a.useMemo(()=>F&&Object.fromEntries(Object.entries(F).map(([e,t])=>[e,Mt.formatCount(t)])),[F]),qe=a.useMemo(()=>Y.filter(({is_hidden:e})=>!e),[Y]),V=a.useMemo(()=>Y.filter(({is_hidden:e})=>e),[Y]),Re=a.useMemo(()=>qe.filter(({name:e})=>{if(!de)return!0;const t=(e??"").toLowerCase(),s=de.toLowerCase();return Me==="contains"?t.includes(s):!t.includes(s)}),[qe,de,Me]),i=a.useMemo(()=>[...Re].sort((e,t)=>e.is_pinned&&!t.is_pinned?-1:!e.is_pinned&&t.is_pinned?1:0),[Re]),gt=q<i.length,Z=z?i.length:gt?q:i.length,Be=i.findIndex(e=>e.name===r)>=Z,He=u.length-Z-(Be?1:0);Le.current=q;const U=a.useCallback(e=>{ce(e),Oe?.(e),j&&g?.persistTabSettings&&g.persistTabSettings({tab_type:j,tab_items:e})},[Oe,j,g]),wt=a.useCallback(e=>{Ve(e),ve?.(e),j&&g?.persistTabSettings&&g.persistTabSettings({tab_type:j,tab_options:e})},[ve,j,g]),Ue=e=>e.is_pinned?32:0,pe=a.useCallback(e=>{if(!e)return;const t=E?30:0,s=y?190:84,l=_==="sm"?4:8,o=32;let m=0,ee=0,w=0;const h=e-(L?.width||0)-t,ze=Le.current,$e=ze<i.length,Ae=V.length>0;for(let f=0;f<i.length;f++){const I=i[f],te=b?.[I.name]?String(b?.[I.name]):"",he=y&&te?B(te,{fontSize:"16px",fontWeight:"500",fontFamily:"Inter, system-ui, -apple-system, sans-serif"})+18+2:0,fe=B(I?.name||"",{fontSize:"16px",fontWeight:"600",fontFamily:"Inter, system-ui, -apple-system, sans-serif"}),ge=C?Ue(I):0,Ye=fe+he+o+l+ge;if(I.name===r&&(ee=Ye),m+=Ye,h>m+($e||Ae?s:0)+f*25)w=f+1;else break}const Ge=i.length-w;if(Ge+V.length===1&&V.length===0&&Ge===1&&w<i.length){const f=i[w];if(f){const I=b?.[f.name]?String(b?.[f.name]):"",te=y&&I?B(I,{fontSize:"16px",fontWeight:"500",fontFamily:"Inter, system-ui, -apple-system, sans-serif"})+18+2:0,he=B(f?.name||"",{fontSize:"16px",fontWeight:"600",fontFamily:"Inter, system-ui, -apple-system, sans-serif"}),fe=C?Ue(f):0,ge=he+te+o+l+fe;h>=m+ge&&(w+=1)}}const Et=z?i.length:w;i.findIndex(f=>f.name===r)>=Et&&(m+=ee,h<m+($e||Ae?s:0)&&(w=Math.max(w-1,0))),w!==ze&&dt(w)},[i,y,z,C,b,L?.width,r,_,E,V.length,B]),xe=a.useCallback(()=>{if(typeof window<"u")return new URLSearchParams(window.location.search);if(x&&g?.getSearchParam){const e=new URLSearchParams,t=g.getSearchParam(x.key);return t&&e.set(x.key,t),e}return new URLSearchParams},[x,g]),be=a.useCallback((e,t)=>(x&&(t===x.defaultLink?e.delete(x.key):e.set(x.key,t),x.onResolve?.(e)),e),[x]),W=a.useCallback(e=>x?`?${be(xe(),e).toString()}`:void 0,[be,xe,x]),kt=Ke||!!x,yt=a.useCallback(async e=>{const t=W(e),s=typeof window<"u"?window.location.origin:"",l=typeof window<"u"?window.location.pathname:"",o=t?`${s}${l}${t}`:`${s}${l}`;await navigator.clipboard.writeText(o),Ut.toast.success(p("Link copied to clipboard"),{toastId:"Link copied to clipboard"}),Ne?.(e,o)},[W,p,Ne]),P=e=>{if(G(!1),Xe?.(e),x&&g?.navigate){const t=be(xe(),e);g.navigate(`?${t.toString()}`)}},We=e=>{if(i.length<=1)return;const t=u.map(o=>o.name===e?{...o,is_hidden:!0}:o),s=i.findIndex(o=>o.name===e),l=s===0?1:s-1;P(i[l].name),U(t)},St=e=>{const t=u.map(s=>s.name===e?{...s,is_hidden:!1}:s);G(!1),U(t)},K=e=>{if(!C)return;const t=u.map(s=>s.name===e?{...s,is_pinned:!s.is_pinned}:s);U(t)},Pe=(e,t)=>{const s=u.findIndex(({name:o})=>o===e),l=t==="left"?s-(u[s-1]?.name===r?2:1):s+1;U(ne.arrayMove(u,s,l))},Fe=()=>G(!N),Tt=e=>Q(e.active.id),Ct=e=>{const{active:t,over:s}=e;if(s?.id==="more-tabs"){We(t.id),Q(null),J(null);return}const l=u.findIndex(({name:m})=>m===t.id),o=u.findIndex(({name:m})=>m===s?.id);U(ne.arrayMove(u,l,o)),Q(null),J(null)},jt=()=>{Q(null),J(null)},It=e=>{J(e.over?.id==="more-tabs"?"more-tabs":null)},Nt=()=>{},vt=(e,t)=>{bt(e),mt(t)},me=(e,t=!1,s=!1)=>{const o=u.find(h=>h.name===e)?.is_pinned,m=[{label:n.jsx(S.OptionButton,{icon:n.jsx(k.ArrowOutwardIcon,{className:"w-icon h-icon text-inherit dark:text-inherit"}),text:p("Select Tab"),className:"text-black-900 dark:text-white"}),key:d.SELECT,onClick:()=>P(e)},{label:n.jsx(S.OptionButton,{icon:n.jsx(k.ArrowUpwardIcon,{className:"w-icon h-icon text-inherit dark:text-inherit"}),text:p("Move Up"),isDisabled:R,className:"text-black-900 dark:text-white"}),key:d.MOVE_LEFT,disabled:R,onClick:()=>Pe(e,"left")},{label:n.jsx(S.OptionButton,{icon:n.jsx(k.ArrowDownwardIcon,{className:"w-icon h-icon text-inherit dark:text-inherit"}),text:p("Move Down"),isDisabled:R,className:"text-black-900 dark:text-white"}),key:d.MOVE_RIGHT,disabled:R,onClick:()=>Pe(e,"right")},{label:n.jsx(S.OptionButton,{icon:n.jsx(k.ContentCopyIcon,{className:"w-icon h-icon text-inherit dark:text-inherit"}),text:p("Copy Link"),className:"text-black-900 dark:text-white"}),key:d.COPY_LINK,onClick:()=>yt(e)},{label:n.jsx(S.OptionButton,{icon:n.jsx(k.VisibilityOffIcon,{className:"w-icon h-icon text-inherit dark:text-inherit"}),text:p("Hide"),className:"text-black-900 dark:text-white"}),key:d.HIDE,onClick:()=>We(e)},{label:n.jsx(S.OptionButton,{icon:n.jsx(k.VisibilityIcon,{className:"w-icon h-icon text-inherit dark:text-inherit"}),text:p("Unhide"),className:"text-black-900 dark:text-white"}),key:d.UNHIDE,onClick:()=>St(e)},{label:n.jsx(S.OptionButton,{icon:o?n.jsx(k.UnpinFilledIcon,{className:"w-icon h-icon rotate-12 text-inherit dark:text-inherit"}):n.jsx(k.PinIcon,{className:"w-icon h-icon rotate-45 text-inherit dark:text-inherit"}),text:p(o?"Unpin":"Pin"),className:"text-black-900 dark:text-white",notVisible:!C}),key:o?d.UNPIN:d.PIN,onClick:()=>K(e)},{label:n.jsx(S.OptionButton,{className:"text-black-900 dark:text-white",icon:n.jsx(Ht.EditIcon,{className:"w-icon h-icon"}),text:p("Edit"),notVisible:!je}),key:d.EDIT,onClick:()=>je?.(e)},{label:n.jsx(S.OptionButton,{className:"text-error-600 dark:text-error-600",icon:n.jsx(k.DeleteIcon,{className:"w-icon h-icon text-error-600 dark:text-error-600"}),text:p("Delete"),notVisible:!Ie}),key:d.DELETE,onClick:()=>Ie?.(e)}],ee=[d.HIDE,d.UNHIDE],w=[d.SELECT,d.MOVE_LEFT,d.MOVE_RIGHT,d.UNHIDE];return m.filter(h=>t?h.key===d.UNHIDE:s?!ee.includes(h.key):!w.includes(h.key)).filter(h=>kt?!0:h.key!==d.COPY_LINK).filter(h=>i.length===1?h.key!==d.HIDE:!0)},M=(e,t)=>({classValue:{default:c("relative inline-flex pt-2 pb-3 px-2 pl-3 sm:px-2 rounded-t-sm group"),secondary:c("flex w-full sm:w-auto relative rounded-lg font-sans font-semibold text-center cursor-pointer uppercase",_==="sm"?"py-1 px-3 text-sm":"py-2 px-4 text-base")},selectedClassValue:{default:c("absolute left-0 bottom-0 w-full h-[3px] bg-primary-600"),secondary:c("absolute inset-0 bg-primary-50 dark:bg-primary-975 rounded-lg")},textClassValue:{default:c("relative uppercase font-sans font-semibold text-sm whitespace-nowrap",t?"text-primary-600 dark:text-primary-500":"text-neutral-400 hover:text-neutral-500 dark:text-neutral-100 dark:hover:text-white"),secondary:c("relative whitespace-nowrap text-sm",t?"text-primary-600 dark:text-primary-500":"text-neutral-400 dark:text-neutral-400")}})[e][T];a.useEffect(()=>{if(!X.current||T==="switch")return;const e=new ResizeObserver(t=>{const s=t[0].contentRect.width;pe(s)});return e.observe(X.current),pe(X.current.clientWidth),()=>e.disconnect()},[pe,T]);const Ot=JSON.stringify(O),_t=JSON.stringify(re?.map(({name:e})=>e));return a.useEffect(()=>{if(re?.length){let e=[...re];O.forEach(t=>{e.find(s=>s.name===t)||e.push({name:t,is_default:!1,is_hidden:!1,is_pinned:!1})}),e=e.filter((t,s,l)=>O.includes(t.name)&&s===l.findIndex(o=>o.name===t.name)),ce(e)}else ce(O.map(e=>({name:e,is_default:!1,is_hidden:!1,is_pinned:!1})).filter((e,t,s)=>t===s.findIndex(l=>l.name===e.name)))},[Ot,_t]),a.useEffect(()=>{A&&Ve(A)},[A]),a.useEffect(()=>{if(!u.length)return;const e=[...u];ue==="asc"?e.sort((t,s)=>t.name.localeCompare(s.name)):ue==="desc"&&e.sort((t,s)=>s.name.localeCompare(t.name)),ut(e)},[u,ue]),a.useEffect(()=>{Te(N)},[N]),T==="switch"?n.jsx("div",{className:c("inline",Ce),children:n.jsx("ul",{role:"tablist","aria-orientation":"horizontal",className:c("inline-flex grow-0 p-1 rounded-lg",ae==="dark"?"border-[1.5px] border-neutral-800 bg-neutral-800 dark:border-black-800":"bg-neutral-100 dark:bg-black-700",ie?"w-full":"w-auto"),children:O.map(e=>{const t=r===e,s=oe?.[e],l=u.find(m=>m.name===e),o=C&&l?.is_pinned;return n.jsx("li",{role:"presentation",className:c("inline-flex",ie?"w-full":"w-auto"),children:n.jsx(ye.TabSwitch,{title:e,showCounts:y,role:"tab",ariaSelected:t,tabIndex:0,icon:o?n.jsx(ke,{title:"Unpin",children:n.jsx("span",{onClick:()=>K(e),children:n.jsx(k.PinIcon,{className:"rotate-45 w-icon h-icon text-inherit dark:text-inherit"})})}):s,iconsOnly:tt,classValue:c("relative py-0.5 border-gray-200",nt,ie?"w-full flex items-center justify-center":"px-2"),selectedClassValue:c("absolute inset-0 rounded-md z-0",ae==="dark"?"bg-neutral-900":"bg-white dark:bg-black-800"),textClassValue:c("relative text-xs font-semibold font-sans whitespace-nowrap",t?"text-neutral-900 dark:text-neutral-100":"text-neutral-700 dark:text-neutral-100"),isSelected:t,href:W(e),onClick:et?void 0:()=>P(e),suffixRecord:b,selectedId:H,color:ae,disableAnimation:at})},e)})})}):n.jsx("div",{ref:X,className:c(st?"w-fit":"w-full"),onMouseEnter:()=>Ee(!0),onMouseLeave:()=>Ee(!1),children:n.jsxs(v.DndContext,{sensors:ft,onDragEnd:Ct,onDragStart:Tt,onDragCancel:jt,collisionDetection:v.closestCenter,onDragOver:It,children:[n.jsxs("ul",{role:"tablist","aria-orientation":"horizontal",className:c("flex items-center w-full",Ce,$?"gap-0":_==="sm"?"gap-1":"gap-2"),ref:ht,children:[Ze?n.jsx("div",{className:"skeleton bg-neutral-300 dark:bg-black-700 animate-pulse h-10 min-w-[100px] w-full rounded"}):n.jsxs(ne.SortableContext,{items:i.map(({name:e})=>e),strategy:ne.horizontalListSortingStrategy,id:"sortable",disabled:!E||R,children:[i.slice(0,Z).map(({name:e,is_pinned:t})=>{const s=r===e&&!N,l=C&&t;return n.jsx(Qe.SortableTab,{title:e,isDragging:D===e,className:$?"flex-1 flex justify-center":"",children:n.jsx("li",{role:"presentation",className:c($?"w-full flex":"sm:mr-2"),children:n.jsx(ye.TabSwitch,{showCounts:y,title:e,role:"tab",ariaSelected:s,tabIndex:0,classValue:c(M("classValue",s),$?"w-full justify-center":""),selectedClassValue:M("selectedClassValue",s),textClassValue:M("textClassValue",s),isSelected:s,tabOptions:s&&E?n.jsx(we.Dropdown,{menu:{items:me(e),className:se},trigger:["click"],onOpenChange:Te,overlayClassName:"row-option-cell",rootClassName:"",openClassName:"max-h-[350px] overflow-y-auto",placement:"bottom",children:n.jsx(Rt,{tooltip:p("More"),variant:"ghost",className:"!text-primary-500 hover:!bg-primary-100 dark:hover:!bg-primary-900",children:n.jsx(Je,{sx:{fontSize:20}})})}):null,draggingTab:D===e,href:W(e),onClick:()=>P(e),suffixRecord:b,selectedId:H,icon:l?n.jsx(ke,{title:p("Unpin"),children:n.jsx("span",{onClick:()=>K(e),children:n.jsx(k.PinIcon,{size:20,className:"rotate-45 text-inherit dark:text-inherit"})})}):oe?.[e]??null})},e)},e)}),r&&Be?n.jsx(Qe.SortableTab,{title:r,isDragging:D===r,children:n.jsx("li",{role:"presentation",className:c("sm:mr-2"),children:n.jsx(ye.TabSwitch,{showCounts:y,title:r,role:"tab",ariaSelected:!0,tabIndex:0,classValue:M("classValue",!0),selectedClassValue:M("selectedClassValue",!0),textClassValue:M("textClassValue",!0),isSelected:!0,tabOptions:E?n.jsx(we.Dropdown,{menu:{items:me(r),className:se},trigger:["click"],onOpenChange:Te,overlayClassName:"row-option-cell",rootClassName:"",openClassName:"max-h-[350px] overflow-y-auto",placement:"bottom",children:n.jsx(Je,{sx:{fontSize:20},className:"text-primary-600"})}):null,draggingTab:D===r,href:W(r),suffixRecord:b,selectedId:H,icon:C&&u.find(e=>e.name===r)?.is_pinned?n.jsx(ke,{title:p("Pinned"),children:n.jsx("span",{onClick:()=>K(r),children:n.jsx(k.PinIcon,{size:20,className:"rotate-45 text-inherit dark:text-inherit"})})}):oe?.[r]??null})},r)},r):null,(q<i.length&&!z||V.length>0)&&He>0?n.jsx(Wt.DropableWrapper,{id:"more-tabs",children:n.jsx(we.Dropdown,{overlayStyle:{maxHeight:"calc(100vh - 350px)",overflow:"auto",marginTop:"8px",scrollbarWidth:"none",borderRadius:8,boxShadow:"0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)"},onOpenChange:()=>Fe(),open:N,menu:{items:[{key:"Search",disabled:!0,style:{minWidth:"190px",marginBottom:"8px"},label:n.jsx("div",{className:"px-2 bg-white dark:bg-black-800",children:n.jsx(Bt.SearchBar,{id:"search-bar-more-tabs",value:le,classValues:"!rounded-lg",onChange:e=>ct(e)})})},...i.slice(Z).filter(e=>e.name!==r).concat(V).filter(({name:e})=>typeof e=="string"&&(e??"").toLowerCase().includes(le.toLowerCase())).map(({name:e,is_hidden:t})=>({key:e,label:n.jsx(S.OptionButton,{className:c("uppercase",t?"text-neutral-400 dark:text-neutral-500":"text-black-900 dark:text-black-200"),text:e,suffixRecord:y?b:{},highlight:le,truncateText:!0,isDisabled:t,onClick:t?void 0:()=>{P(e),G(!1)}}),popupClassName:se,children:N?me(e,t,!0):null}))],className:se},openClassName:"max-h-[350px] overflow-y-auto",trigger:["click"],overlayClassName:"row-option-cell",placement:"bottomRight",getPopupContainer:e=>e.parentElement,children:n.jsx(Pt.MoreButton,{title:`${y?He:""} MORE...`,variant:T,size:_,draggingOver:pt,suffixRecord:b,handleShowMoreDropdown:Fe,selectedId:H,showMoreDropdown:N})})}):null]}),L?n.jsx("div",{className:c(L?.className),children:n.jsx("li",{children:L.component})}):null,E&<&&n.jsx("li",{className:c(xt?"opacity-100":"opacity-0","transition-opacity duration-300"),children:n.jsx(Ft.TabOptions,{hasSuffixRecord:!!(b&&Object.keys(b).length>0),savedConfig:De,onApplyFilter:e=>wt(e),setUnsavedChanges:()=>{},handleTabSort:Nt,onSearchChange:vt})})]}),D?n.jsx(zt.TabDragOverlay,{draggingTab:D,suffixRecord:b,size:_,variant:T,selectedId:H,parentContainer:rt}):null]})})};exports.Tabs=At;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),_=require("@dnd-kit/core"),se=require("@dnd-kit/sortable"),ye=require("antd"),c=require("../../../_virtual/index.cjs.js"),o=require("react"),Lt=require("react-i18next"),Ze=require("@mui/icons-material/MoreHorizOutlined"),qt=require("./types.cjs.js"),Rt=require("../../../utils/formatters.cjs.js"),Bt=require("../../../providers/design-system-provider/hooks.cjs.js"),Ut=require("../../../hooks/useTextWidth.cjs.js"),Ht=require("../../button/IconButton.cjs.js"),S=require("../../buttons/option-button/OptionButton.cjs.js"),Wt=require("../../forms/search-bar/SearchBar.cjs.js"),Se=require("../../tooltip/Tooltip.cjs.js"),Pt=require("../../icons/EditIcon.cjs.js"),Ft=require("react-toastify"),Te=require("./TabSwitch.cjs.js"),k=require("../../icon/icons.generated.cjs.js"),Ke=require("./SortableTab.cjs.js"),zt=require("./DropableWrapper.cjs.js"),$t=require("./MoreButton.cjs.js"),At=require("./TabOptions.cjs.js"),Gt=require("./TabDragOverlay.cjs.js"),Yt=()=>Math.random().toString(16).slice(2,13),oe=["[&_.ant-dropdown-menu-item]:!outline-none","[&_.ant-dropdown-menu-submenu-title]:!outline-none","[&_.ant-dropdown-menu-item:focus-visible_.option-button-inner]:ring-2","[&_.ant-dropdown-menu-item:focus-visible_.option-button-inner]:ring-primary-500","[&_.ant-dropdown-menu-item:focus-visible_.option-button-inner]:bg-gray-50","[&_.ant-dropdown-menu-item:focus-visible_.option-button-inner]:dark:bg-black-600","[&_.ant-dropdown-menu-submenu-title:focus-visible_.option-button-inner]:ring-2","[&_.ant-dropdown-menu-submenu-title:focus-visible_.option-button-inner]:ring-primary-500","[&_.ant-dropdown-menu-submenu-title:focus-visible_.option-button-inner]:bg-gray-50","[&_.ant-dropdown-menu-submenu-title:focus-visible_.option-button-inner]:dark:bg-black-600"].join(" ");let Ce=null;const je=C=>{C?(Ce=document.activeElement,setTimeout(()=>{document.querySelector(".row-option-cell .ant-dropdown-menu-item:not(.ant-dropdown-menu-item-disabled), .row-option-cell .ant-dropdown-menu-submenu-title")?.focus()},50)):setTimeout(()=>{Ce?.focus(),Ce=null},0)},d={SELECT:"Select",MOVE_LEFT:"MoveLeft",MOVE_RIGHT:"MoveRight",HIDE:"Hide",UNHIDE:"Unhide",COPY_LINK:"CopyLink",DELETE:"Delete",PIN:"Pin",UNPIN:"Unpin",EDIT:"Edit"},Jt=({variant:C="default",tabs:O=[],activeTab:r,onTabClick:et,suffixRecord:z,isLoading:tt,size:E="md",className:Ie,draggable:D=!1,showAllItems:$=!1,copyLink:nt=!1,isDisabled:st=!1,color:ae="light",iconsOnly:ot=!1,tabIcons:ie={},height:at="h-6",fullWidth:re=!1,fitContentWidth:it=!1,disableAnimation:rt=!1,onEdit:ve,onDelete:Ne,onCopyLink:_e,allowPin:j=!1,isFullWidth:A=!1,rightSection:q,initialTabs:lt,tabConfig:ct,onTabConfigChange:Oe,onTabsChange:Ee,parentContainer:dt=document.body,tabKey:I,linkConfig:x,showTabOptions:ut=!0,lockedTabs:De,lockedTabTooltip:le})=>{const g=Bt.useTabConfig(),Ve=I?g?.getTabSettings(I):void 0,ce=lt??Ve?.tab_items,G=ct??Ve?.tab_options,[de,pt]=o.useState(""),[N,Y]=o.useState(!1),[R,xt]=o.useState(0),[u,ue]=o.useState([]),[J,bt]=o.useState([]),[ht,Q]=o.useState(null),[V,X]=o.useState(null),[mt,Me]=o.useState(!1),[Le,qe]=o.useState(G??qt.INITIAL_TAB_OPTION_CONFIG),[pe,ft]=o.useState(""),[Re,gt]=o.useState("contains"),{showCounts:y,lockOrder:B,sortOrder:xe}=Le,{t:p}=Lt.useTranslation(),Z=o.useRef(null),wt=o.useRef(null),Be=o.useRef(R),{measureText:U}=Ut.useTextWidth(),H=o.useMemo(()=>Yt(),[]),kt=_.useSensors(_.useSensor(_.MouseSensor,{activationConstraint:{distance:5}}),_.useSensor(_.TouchSensor,{activationConstraint:{delay:300,tolerance:5}})),b=o.useMemo(()=>z&&Object.fromEntries(Object.entries(z).map(([e,t])=>[e,Rt.formatCount(t)])),[z]),Ue=o.useMemo(()=>J.filter(({is_hidden:e})=>!e),[J]),M=o.useMemo(()=>J.filter(({is_hidden:e})=>e),[J]),He=o.useMemo(()=>Ue.filter(({name:e})=>{if(!pe)return!0;const t=(e??"").toLowerCase(),s=pe.toLowerCase();return Re==="contains"?t.includes(s):!t.includes(s)}),[Ue,pe,Re]),l=o.useMemo(()=>[...He].sort((e,t)=>e.is_pinned&&!t.is_pinned?-1:!e.is_pinned&&t.is_pinned?1:0),[He]),yt=R<l.length,K=$?l.length:yt?R:l.length,We=l.findIndex(e=>e.name===r)>=K,Pe=u.length-K-(We?1:0);Be.current=R;const W=o.useCallback(e=>{ue(e),Ee?.(e),I&&g?.persistTabSettings&&g.persistTabSettings({tab_type:I,tab_items:e})},[Ee,I,g]),St=o.useCallback(e=>{qe(e),Oe?.(e),I&&g?.persistTabSettings&&g.persistTabSettings({tab_type:I,tab_options:e})},[Oe,I,g]),Fe=e=>e.is_pinned?32:0,be=o.useCallback(e=>{if(!e)return;const t=D?30:0,s=y?190:84,a=E==="sm"?4:8,i=32;let h=0,te=0,w=0;const m=e-(q?.width||0)-t,Ge=Be.current,Ye=Ge<l.length,Je=M.length>0;for(let f=0;f<l.length;f++){const v=l[f],ne=b?.[v.name]?String(b?.[v.name]):"",ge=y&&ne?U(ne,{fontSize:"16px",fontWeight:"500",fontFamily:"Inter, system-ui, -apple-system, sans-serif"})+18+2:0,we=U(v?.name||"",{fontSize:"16px",fontWeight:"600",fontFamily:"Inter, system-ui, -apple-system, sans-serif"}),ke=j?Fe(v):0,Xe=we+ge+i+a+ke;if(v.name===r&&(te=Xe),h+=Xe,m>h+(Ye||Je?s:0)+f*25)w=f+1;else break}const Qe=l.length-w;if(Qe+M.length===1&&M.length===0&&Qe===1&&w<l.length){const f=l[w];if(f){const v=b?.[f.name]?String(b?.[f.name]):"",ne=y&&v?U(v,{fontSize:"16px",fontWeight:"500",fontFamily:"Inter, system-ui, -apple-system, sans-serif"})+18+2:0,ge=U(f?.name||"",{fontSize:"16px",fontWeight:"600",fontFamily:"Inter, system-ui, -apple-system, sans-serif"}),we=j?Fe(f):0,ke=ge+ne+i+a+we;m>=h+ke&&(w+=1)}}const Mt=$?l.length:w;l.findIndex(f=>f.name===r)>=Mt&&(h+=te,m<h+(Ye||Je?s:0)&&(w=Math.max(w-1,0))),w!==Ge&&xt(w)},[l,y,$,j,b,q?.width,r,E,D,M.length,U]),he=o.useCallback(()=>{if(typeof window<"u")return new URLSearchParams(window.location.search);if(x&&g?.getSearchParam){const e=new URLSearchParams,t=g.getSearchParam(x.key);return t&&e.set(x.key,t),e}return new URLSearchParams},[x,g]),me=o.useCallback((e,t)=>(x&&(t===x.defaultLink?e.delete(x.key):e.set(x.key,t),x.onResolve?.(e)),e),[x]),P=o.useCallback(e=>x?`?${me(he(),e).toString()}`:void 0,[me,he,x]),Tt=nt||!!x,Ct=o.useCallback(async e=>{const t=P(e),s=typeof window<"u"?window.location.origin:"",a=typeof window<"u"?window.location.pathname:"",i=t?`${s}${a}${t}`:`${s}${a}`;await navigator.clipboard.writeText(i),Ft.toast.success(p("Link copied to clipboard"),{toastId:"Link copied to clipboard"}),_e?.(e,i)},[P,p,_e]),T=o.useCallback(e=>!!De?.includes(e),[De]),F=e=>{if(!T(e)&&(Y(!1),et?.(e),x&&g?.navigate)){const t=me(he(),e);g.navigate(`?${t.toString()}`)}},ze=e=>{if(l.length<=1)return;const t=u.map(i=>i.name===e?{...i,is_hidden:!0}:i),s=l.findIndex(i=>i.name===e),a=s===0?1:s-1;F(l[a].name),W(t)},jt=e=>{const t=u.map(s=>s.name===e?{...s,is_hidden:!1}:s);Y(!1),W(t)},ee=e=>{if(!j)return;const t=u.map(s=>s.name===e?{...s,is_pinned:!s.is_pinned}:s);W(t)},$e=(e,t)=>{const s=u.findIndex(({name:i})=>i===e),a=t==="left"?s-(u[s-1]?.name===r?2:1):s+1;W(se.arrayMove(u,s,a))},Ae=()=>Y(!N),It=e=>X(e.active.id),vt=e=>{const{active:t,over:s}=e;if(s?.id==="more-tabs"){ze(t.id),X(null),Q(null);return}const a=u.findIndex(({name:h})=>h===t.id),i=u.findIndex(({name:h})=>h===s?.id);W(se.arrayMove(u,a,i)),X(null),Q(null)},Nt=()=>{X(null),Q(null)},_t=e=>{Q(e.over?.id==="more-tabs"?"more-tabs":null)},Ot=()=>{},Et=(e,t)=>{ft(e),gt(t)},fe=(e,t=!1,s=!1)=>{const i=u.find(m=>m.name===e)?.is_pinned,h=[{label:n.jsx(S.OptionButton,{icon:n.jsx(k.ArrowOutwardIcon,{className:"w-icon h-icon text-inherit dark:text-inherit"}),text:p("Select Tab"),className:"text-black-900 dark:text-white"}),key:d.SELECT,onClick:()=>F(e)},{label:n.jsx(S.OptionButton,{icon:n.jsx(k.ArrowUpwardIcon,{className:"w-icon h-icon text-inherit dark:text-inherit"}),text:p("Move Up"),isDisabled:B,className:"text-black-900 dark:text-white"}),key:d.MOVE_LEFT,disabled:B,onClick:()=>$e(e,"left")},{label:n.jsx(S.OptionButton,{icon:n.jsx(k.ArrowDownwardIcon,{className:"w-icon h-icon text-inherit dark:text-inherit"}),text:p("Move Down"),isDisabled:B,className:"text-black-900 dark:text-white"}),key:d.MOVE_RIGHT,disabled:B,onClick:()=>$e(e,"right")},{label:n.jsx(S.OptionButton,{icon:n.jsx(k.ContentCopyIcon,{className:"w-icon h-icon text-inherit dark:text-inherit"}),text:p("Copy Link"),className:"text-black-900 dark:text-white"}),key:d.COPY_LINK,onClick:()=>Ct(e)},{label:n.jsx(S.OptionButton,{icon:n.jsx(k.VisibilityOffIcon,{className:"w-icon h-icon text-inherit dark:text-inherit"}),text:p("Hide"),className:"text-black-900 dark:text-white"}),key:d.HIDE,onClick:()=>ze(e)},{label:n.jsx(S.OptionButton,{icon:n.jsx(k.VisibilityIcon,{className:"w-icon h-icon text-inherit dark:text-inherit"}),text:p("Unhide"),className:"text-black-900 dark:text-white"}),key:d.UNHIDE,onClick:()=>jt(e)},{label:n.jsx(S.OptionButton,{icon:i?n.jsx(k.UnpinFilledIcon,{className:"w-icon h-icon rotate-12 text-inherit dark:text-inherit"}):n.jsx(k.PinIcon,{className:"w-icon h-icon rotate-45 text-inherit dark:text-inherit"}),text:p(i?"Unpin":"Pin"),className:"text-black-900 dark:text-white",notVisible:!j}),key:i?d.UNPIN:d.PIN,onClick:()=>ee(e)},{label:n.jsx(S.OptionButton,{className:"text-black-900 dark:text-white",icon:n.jsx(Pt.EditIcon,{className:"w-icon h-icon"}),text:p("Edit"),notVisible:!ve}),key:d.EDIT,onClick:()=>ve?.(e)},{label:n.jsx(S.OptionButton,{className:"text-error-600 dark:text-error-600",icon:n.jsx(k.DeleteIcon,{className:"w-icon h-icon text-error-600 dark:text-error-600"}),text:p("Delete"),notVisible:!Ne}),key:d.DELETE,onClick:()=>Ne?.(e)}],te=[d.HIDE,d.UNHIDE],w=[d.SELECT,d.MOVE_LEFT,d.MOVE_RIGHT,d.UNHIDE];return h.filter(m=>t?m.key===d.UNHIDE:s?!te.includes(m.key):!w.includes(m.key)).filter(m=>Tt?!0:m.key!==d.COPY_LINK).filter(m=>l.length===1?m.key!==d.HIDE:!0)},L=(e,t)=>({classValue:{default:c("relative inline-flex pt-2 pb-3 px-2 pl-3 sm:px-2 rounded-t-sm group"),secondary:c("flex w-full sm:w-auto relative rounded-lg font-sans font-semibold text-center cursor-pointer uppercase",E==="sm"?"py-1 px-3 text-sm":"py-2 px-4 text-base")},selectedClassValue:{default:c("absolute left-0 bottom-0 w-full h-[3px] bg-primary-600"),secondary:c("absolute inset-0 bg-primary-50 dark:bg-primary-975 rounded-lg")},textClassValue:{default:c("relative uppercase font-sans font-semibold text-sm whitespace-nowrap",t?"text-primary-600 dark:text-primary-500":"text-neutral-400 hover:text-neutral-500 dark:text-neutral-100 dark:hover:text-white"),secondary:c("relative whitespace-nowrap text-sm",t?"text-primary-600 dark:text-primary-500":"text-neutral-400 dark:text-neutral-400")}})[e][C];o.useEffect(()=>{if(!Z.current||C==="switch")return;const e=new ResizeObserver(t=>{const s=t[0].contentRect.width;be(s)});return e.observe(Z.current),be(Z.current.clientWidth),()=>e.disconnect()},[be,C]);const Dt=JSON.stringify(O),Vt=JSON.stringify(ce?.map(({name:e})=>e));return o.useEffect(()=>{if(ce?.length){let e=[...ce];O.forEach(t=>{e.find(s=>s.name===t)||e.push({name:t,is_default:!1,is_hidden:!1,is_pinned:!1})}),e=e.filter((t,s,a)=>O.includes(t.name)&&s===a.findIndex(i=>i.name===t.name)),ue(e)}else ue(O.map(e=>({name:e,is_default:!1,is_hidden:!1,is_pinned:!1})).filter((e,t,s)=>t===s.findIndex(a=>a.name===e.name)))},[Dt,Vt]),o.useEffect(()=>{G&&qe(G)},[G]),o.useEffect(()=>{if(!u.length)return;const e=[...u];xe==="asc"?e.sort((t,s)=>t.name.localeCompare(s.name)):xe==="desc"&&e.sort((t,s)=>s.name.localeCompare(t.name)),bt(e)},[u,xe]),o.useEffect(()=>{je(N)},[N]),C==="switch"?n.jsx("div",{className:c("inline",Ie),children:n.jsx("ul",{role:"tablist","aria-orientation":"horizontal",className:c("inline-flex grow-0 p-1 rounded-lg",ae==="dark"?"border-[1.5px] border-neutral-800 bg-neutral-800 dark:border-black-800":"bg-neutral-100 dark:bg-black-700",re?"w-full":"w-auto"),children:O.map(e=>{const t=r===e,s=ie?.[e],a=u.find(h=>h.name===e),i=j&&a?.is_pinned;return n.jsx("li",{role:"presentation",className:c("inline-flex",re?"w-full":"w-auto"),children:n.jsx(Te.TabSwitch,{title:e,showCounts:y,role:"tab",ariaSelected:t,tabIndex:0,icon:i?n.jsx(Se,{title:"Unpin",children:n.jsx("span",{onClick:()=>ee(e),children:n.jsx(k.PinIcon,{className:"rotate-45 w-icon h-icon text-inherit dark:text-inherit"})})}):s,iconsOnly:ot,classValue:c("relative py-0.5 border-gray-200",at,re?"w-full flex items-center justify-center":"px-2"),selectedClassValue:c("absolute inset-0 rounded-md z-0",ae==="dark"?"bg-neutral-900":"bg-white dark:bg-black-800"),textClassValue:c("relative text-xs font-semibold font-sans whitespace-nowrap",t?"text-neutral-900 dark:text-neutral-100":"text-neutral-700 dark:text-neutral-100"),isSelected:t,isLocked:T(e),lockedTooltip:le,href:T(e)?void 0:P(e),onClick:!st&&!T(e)?()=>F(e):void 0,suffixRecord:b,selectedId:H,color:ae,disableAnimation:rt})},e)})})}):n.jsx("div",{ref:Z,className:c(it?"w-fit":"w-full"),onMouseEnter:()=>Me(!0),onMouseLeave:()=>Me(!1),children:n.jsxs(_.DndContext,{sensors:kt,onDragEnd:vt,onDragStart:It,onDragCancel:Nt,collisionDetection:_.closestCenter,onDragOver:_t,children:[n.jsxs("ul",{role:"tablist","aria-orientation":"horizontal",className:c("flex items-center w-full",Ie,A?"gap-0":E==="sm"?"gap-1":"gap-2"),ref:wt,children:[tt?n.jsx("div",{className:"skeleton bg-neutral-300 dark:bg-black-700 animate-pulse h-10 min-w-[100px] w-full rounded"}):n.jsxs(se.SortableContext,{items:l.map(({name:e})=>e),strategy:se.horizontalListSortingStrategy,id:"sortable",disabled:!D||B,children:[l.slice(0,K).map(({name:e,is_pinned:t})=>{const s=r===e&&!N,a=j&&t;return n.jsx(Ke.SortableTab,{title:e,isDragging:V===e,className:A?"flex-1 flex justify-center":"",children:n.jsx("li",{role:"presentation",className:c(A?"w-full flex":"sm:mr-2"),children:n.jsx(Te.TabSwitch,{showCounts:y,title:e,role:"tab",ariaSelected:s,tabIndex:0,classValue:c(L("classValue",s),A?"w-full justify-center":""),selectedClassValue:L("selectedClassValue",s),textClassValue:L("textClassValue",s),isSelected:s,tabOptions:s&&D?n.jsx(ye.Dropdown,{menu:{items:fe(e),className:oe},trigger:["click"],onOpenChange:je,overlayClassName:"row-option-cell",rootClassName:"",openClassName:"max-h-[350px] overflow-y-auto",placement:"bottom",children:n.jsx(Ht,{tooltip:p("More"),variant:"ghost",className:"!text-primary-500 hover:!bg-primary-100 dark:hover:!bg-primary-900",children:n.jsx(Ze,{sx:{fontSize:20}})})}):null,draggingTab:V===e,isLocked:T(e),lockedTooltip:le,href:T(e)?void 0:P(e),onClick:()=>F(e),suffixRecord:b,selectedId:H,icon:a?n.jsx(Se,{title:p("Unpin"),children:n.jsx("span",{onClick:()=>ee(e),children:n.jsx(k.PinIcon,{size:20,className:"rotate-45 text-inherit dark:text-inherit"})})}):ie?.[e]??null})},e)},e)}),r&&We?n.jsx(Ke.SortableTab,{title:r,isDragging:V===r,children:n.jsx("li",{role:"presentation",className:c("sm:mr-2"),children:n.jsx(Te.TabSwitch,{showCounts:y,title:r,role:"tab",ariaSelected:!0,tabIndex:0,classValue:L("classValue",!0),selectedClassValue:L("selectedClassValue",!0),textClassValue:L("textClassValue",!0),isSelected:!0,tabOptions:D?n.jsx(ye.Dropdown,{menu:{items:fe(r),className:oe},trigger:["click"],onOpenChange:je,overlayClassName:"row-option-cell",rootClassName:"",openClassName:"max-h-[350px] overflow-y-auto",placement:"bottom",children:n.jsx(Ze,{sx:{fontSize:20},className:"text-primary-600"})}):null,draggingTab:V===r,isLocked:T(r),lockedTooltip:le,href:T(r)?void 0:P(r),suffixRecord:b,selectedId:H,icon:j&&u.find(e=>e.name===r)?.is_pinned?n.jsx(Se,{title:p("Pinned"),children:n.jsx("span",{onClick:()=>ee(r),children:n.jsx(k.PinIcon,{size:20,className:"rotate-45 text-inherit dark:text-inherit"})})}):ie?.[r]??null})},r)},r):null,(R<l.length&&!$||M.length>0)&&Pe>0?n.jsx(zt.DropableWrapper,{id:"more-tabs",children:n.jsx(ye.Dropdown,{overlayStyle:{maxHeight:"calc(100vh - 350px)",overflow:"auto",marginTop:"8px",scrollbarWidth:"none",borderRadius:8,boxShadow:"0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)"},onOpenChange:()=>Ae(),open:N,menu:{items:[{key:"Search",disabled:!0,style:{minWidth:"190px",marginBottom:"8px"},label:n.jsx("div",{className:"px-2 bg-white dark:bg-black-800",children:n.jsx(Wt.SearchBar,{id:"search-bar-more-tabs",value:de,classValues:"!rounded-lg",onChange:e=>pt(e)})})},...l.slice(K).filter(e=>e.name!==r).concat(M).filter(({name:e})=>typeof e=="string"&&(e??"").toLowerCase().includes(de.toLowerCase())).map(({name:e,is_hidden:t})=>{const s=T(e),a=t||s;return{key:e,label:n.jsx(S.OptionButton,{className:c("uppercase",a?"text-neutral-400 dark:text-neutral-500":"text-black-900 dark:text-black-200"),text:e,suffixRecord:y?b:{},highlight:de,truncateText:!0,isDisabled:a,onClick:a?void 0:()=>{F(e),Y(!1)}}),popupClassName:oe,children:N?fe(e,t,!0):null}})],className:oe},openClassName:"max-h-[350px] overflow-y-auto",trigger:["click"],overlayClassName:"row-option-cell",placement:"bottomRight",getPopupContainer:e=>e.parentElement,children:n.jsx($t.MoreButton,{title:`${y?Pe:""} MORE...`,variant:C,size:E,draggingOver:ht,suffixRecord:b,handleShowMoreDropdown:Ae,selectedId:H,showMoreDropdown:N})})}):null]}),q?n.jsx("div",{className:c(q?.className),children:n.jsx("li",{children:q.component})}):null,D&&ut&&n.jsx("li",{className:c(mt?"opacity-100":"opacity-0","transition-opacity duration-300"),children:n.jsx(At.TabOptions,{hasSuffixRecord:!!(b&&Object.keys(b).length>0),savedConfig:Le,onApplyFilter:e=>St(e),setUnsavedChanges:()=>{},handleTabSort:Ot,onSearchChange:Et})})]}),V?n.jsx(Gt.TabDragOverlay,{draggingTab:V,suffixRecord:b,size:E,variant:C,selectedId:H,parentContainer:dt}):null]})})};exports.Tabs=Jt;
|
|
2
2
|
//# sourceMappingURL=Tabs.cjs.js.map
|