@nice2dev/ui 1.3.18 → 1.4.1
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/CHANGELOG.md +82 -0
- package/README.md +27 -0
- package/dist/{NiceDataGrid-CFibAGHt.cjs → NiceDataGrid-BT6iCUgP.cjs} +1 -1
- package/dist/{NiceForm-ChRj4r3f.cjs → NiceForm-Bysp66Ef.cjs} +1 -1
- package/dist/{NiceMention-DNx3d9L7.cjs → NiceMention-sc8W-DwH.cjs} +1 -1
- package/dist/NiceModuleLifecyclePanel-DBQPCa_V.cjs +1 -0
- package/dist/{NiceSavedQueryPanel-BuRAgrBk.cjs → NiceSavedQueryPanel-BbznsXFd.cjs} +1 -1
- package/dist/{NiceScheduler-DAoo1eyo.cjs → NiceScheduler-3Ez0zSQJ.cjs} +1 -1
- package/dist/{core-lazy-DohJQ33c.cjs → core-lazy-CL4ZIxF-.cjs} +1 -1
- package/dist/data.cjs +1 -1
- package/dist/editors/pickers/pickerCommons.mjs +284 -87
- package/dist/editors/pickers/themePickerHelpers.mjs +10 -8
- package/dist/editors.cjs +1 -1
- package/dist/index.cjs +166 -166
- package/dist/index.d.ts +142 -10
- package/dist/index.mjs +1517 -1488
- package/dist/navigation/sidebarColors.mjs +61 -50
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +7 -0
- package/dist/pickerCommons-CwcCc8Qi.cjs +1 -0
- package/dist/planning/NiceResourceAllocation.mjs +31 -31
- package/dist/style.css +4 -4
- package/dist/tools/NiceThemeDesigner.mjs +781 -708
- package/dist/tools/NiceThemePreview.mjs +344 -282
- package/dist/tools/themeCatalog.mjs +28 -44
- package/dist/tools/themeCatalogArchive.mjs +38 -0
- package/dist/tools/themeDesigner/ThemeSetEditors.mjs +400 -0
- package/dist/tools/themeDesigner/ThemeValueField.mjs +146 -0
- package/dist/tools/themeDesigner/themeDesignerPaths.mjs +105 -0
- package/package.json +4 -4
- package/dist/NiceModuleLifecyclePanel-D8Q081R6.cjs +0 -1
- package/dist/pickerCommons-BWglYl6J.cjs +0 -1
|
@@ -1,97 +1,108 @@
|
|
|
1
|
-
import { isDerivableColor as
|
|
2
|
-
const
|
|
1
|
+
import { isDerivableColor as g, nestingLevelColors as h } from "@nice2dev/ui-core";
|
|
2
|
+
const u = 10, x = 0.12, b = "var(--nice-text-on-warning, #0f172a)";
|
|
3
3
|
function s(e) {
|
|
4
|
-
return Math.min(Math.max(e, 1),
|
|
4
|
+
return Math.min(Math.max(e, 1), u);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
return
|
|
6
|
+
function v(e) {
|
|
7
|
+
return g(e) ? h(1, { palette: [e] }, e, b)[0] : {
|
|
8
8
|
bg: e,
|
|
9
9
|
text: "inherit",
|
|
10
10
|
hoverBg: `color-mix(in srgb, ${e} 88%, currentColor)`,
|
|
11
11
|
activeBg: `color-mix(in srgb, ${e} 76%, currentColor)`
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const
|
|
14
|
+
function d(e, r, n) {
|
|
15
|
+
const i = u - s(r) + 1;
|
|
16
16
|
if (e.length === 0)
|
|
17
17
|
return [];
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
{ palette: [
|
|
25
|
-
|
|
18
|
+
const o = e.slice(0, i).map(v), t = i - o.length;
|
|
19
|
+
if (t > 0) {
|
|
20
|
+
const c = e[e.length - 1];
|
|
21
|
+
if (g(c)) {
|
|
22
|
+
const l = h(
|
|
23
|
+
t + 1,
|
|
24
|
+
{ palette: [c], bgDerivation: n, bgStep: x },
|
|
25
|
+
c,
|
|
26
26
|
b
|
|
27
27
|
);
|
|
28
|
-
|
|
28
|
+
o.push(...l.slice(1));
|
|
29
29
|
} else
|
|
30
|
-
|
|
30
|
+
o.push(...Array.from({ length: t }, () => v(c)));
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return o;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function p(e, r) {
|
|
35
35
|
const n = {};
|
|
36
|
-
return e.forEach((
|
|
37
|
-
const
|
|
38
|
-
n[`--nice-sidebar-level-${
|
|
36
|
+
return e.forEach((i, o) => {
|
|
37
|
+
const t = s(r) + o;
|
|
38
|
+
n[`--nice-sidebar-level-${t}-bg`] = i.bg, n[`--nice-sidebar-level-${t}-text`] = i.text, n[`--nice-sidebar-level-${t}-hover-bg`] = i.hoverBg, n[`--nice-sidebar-level-${t}-active-bg`] = i.activeBg;
|
|
39
39
|
}), n;
|
|
40
40
|
}
|
|
41
41
|
function E(e, r) {
|
|
42
|
-
return e && e.length > 0 ? { colors:
|
|
42
|
+
return e && e.length > 0 ? { colors: d(e, 1, r), fromLevel: 1 } : { fromLevel: 1 };
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
44
|
+
function C(e, r, n, i) {
|
|
45
|
+
const o = r?.levelColors?.length ? r.levelColors : r?.color ? [r.color] : void 0;
|
|
46
|
+
if (!o)
|
|
47
47
|
return { scope: e };
|
|
48
|
-
const
|
|
48
|
+
const t = s(n), c = d(o, t, i);
|
|
49
49
|
return {
|
|
50
|
-
scope: { colors:
|
|
51
|
-
vars:
|
|
50
|
+
scope: { colors: c, fromLevel: t, branchColor: o[0] },
|
|
51
|
+
vars: p(c, t)
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function w(e, r) {
|
|
55
55
|
return e.colors?.[s(r) - e.fromLevel];
|
|
56
56
|
}
|
|
57
57
|
function S(e) {
|
|
58
|
-
return
|
|
58
|
+
return v(e);
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
function
|
|
62
|
-
const n = Math.min(e,
|
|
60
|
+
const f = 6, $ = "45%";
|
|
61
|
+
function a(e, r) {
|
|
62
|
+
const n = Math.min(e, f);
|
|
63
63
|
return `var(--nice-sidebar-level-${e}-${r}, var(--nice-sidebar-shade-${n}-${r}))`;
|
|
64
64
|
}
|
|
65
65
|
function B() {
|
|
66
66
|
return {
|
|
67
|
-
"--nice-source-head-bg":
|
|
68
|
-
"--nice-source-head-color":
|
|
69
|
-
|
|
67
|
+
"--nice-source-head-bg": a(1, "bg"),
|
|
68
|
+
"--nice-source-head-color": a(1, "text"),
|
|
69
|
+
// 1.4.0: the first level of the active path — the highlight over the header, at its weakest
|
|
70
|
+
"--nice-source-head-bg-active": m(1, a(1, "bg")),
|
|
70
71
|
"--nice-source-head-accent": "var(--nice-source-head-color)"
|
|
71
72
|
};
|
|
72
73
|
}
|
|
74
|
+
function m(e, r) {
|
|
75
|
+
const n = Math.min(e, f);
|
|
76
|
+
return `var(--nice-sidenav-path-${e}-bg, color-mix(in srgb, var(--nice-sidenav-highlight) var(--nice-sidenav-highlight-step-${n}), ${r}))`;
|
|
77
|
+
}
|
|
73
78
|
function V(e, r) {
|
|
74
|
-
const n = s(e),
|
|
79
|
+
const n = s(e), i = a(n, "bg"), o = a(n, "text"), t = r ? i : `var(--nice-bg-sidenav-item, color-mix(in srgb, ${i} var(--nice-sidenav-item-tint, ${$}), var(--nice-bg-primary)))`, c = r ? o : "var(--nice-text-sidenav-item, var(--nice-text-primary))", l = {
|
|
80
|
+
"--nice-row-path-bg": m(n, i),
|
|
81
|
+
"--nice-row-path-text": `var(--nice-sidenav-path-${n}-text, ${o})`,
|
|
82
|
+
"--nice-row-active-bg": "var(--nice-sidenav-highlight)",
|
|
83
|
+
"--nice-row-active-text": "var(--nice-text-sidenav-highlight)"
|
|
84
|
+
};
|
|
75
85
|
return {
|
|
76
|
-
"--nice-row-bg":
|
|
77
|
-
"--nice-row-text":
|
|
78
|
-
"--nice-row-hover-bg": `color-mix(in srgb, ${
|
|
79
|
-
"--nice-row-label":
|
|
80
|
-
"--nice-row-muted":
|
|
86
|
+
"--nice-row-bg": t,
|
|
87
|
+
"--nice-row-text": c,
|
|
88
|
+
"--nice-row-hover-bg": `color-mix(in srgb, ${t} 88%, ${c})`,
|
|
89
|
+
"--nice-row-label": c,
|
|
90
|
+
"--nice-row-muted": c,
|
|
81
91
|
// the active row's bar and label: the header's text on a header, the primary on a page
|
|
82
|
-
"--nice-row-accent": r ?
|
|
92
|
+
"--nice-row-accent": r ? c : "var(--nice-color-primary)",
|
|
93
|
+
...l
|
|
83
94
|
};
|
|
84
95
|
}
|
|
85
96
|
export {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
u as SIDEBAR_COLOR_LEVELS,
|
|
98
|
+
f as SIDEBAR_SHADE_LEVELS,
|
|
99
|
+
C as branchColorScope,
|
|
89
100
|
s as colorLevel,
|
|
90
101
|
S as colorsOf,
|
|
91
|
-
|
|
92
|
-
|
|
102
|
+
p as levelColorVars,
|
|
103
|
+
d as levelColorsFrom,
|
|
93
104
|
E as rootColorScope,
|
|
94
|
-
|
|
105
|
+
w as rowColors,
|
|
95
106
|
V as shadeRowVars,
|
|
96
107
|
B as shadeSourceHeadVars
|
|
97
108
|
};
|
package/dist/navigation.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./NiceModuleLifecyclePanel-D8Q081R6.cjs"),e=require("react/jsx-runtime"),i=require("@nice2dev/ui-core"),a=require("react"),z=require("./pickerCommons-BWglYl6J.cjs"),K=require("./NicePagination-D7XxeNFz.cjs"),E=[],W=Object.assign(a.forwardRef(({items:p=E,activeKey:f,collapsed:l=!1,width:x=240,collapsedWidth:d=52,onItemClick:y,onCollapseChange:A,header:g,footer:b,size:_="md",className:R,style:I,id:S,accessMode:D,...C},m)=>{const j=i.useControlId(S),M=i.useNiceAccessMode(D,S),[k,h]=a.useState(new Set),c=a.useCallback(n=>{h(t=>{const o=new Set(t);return o.has(n)?o.delete(n):o.add(n),o})},[]);if(M==="hidden")return null;const u=(n,t=0)=>{const o=n.children&&n.children.length>0,r=k.has(n.key),N=n.key===f;return e.jsxs("li",{className:"nice-sidebar-menu__item",children:[e.jsxs("button",{className:`nice-sidebar-menu__btn ${N?"nice-sidebar-menu__btn--active":""} ${n.disabled?"nice-sidebar-menu__btn--disabled":""}`,style:{paddingLeft:l?void 0:12+t*16},onClick:()=>o?c(n.key):y?.(n),disabled:n.disabled,title:l?n.text:void 0,type:"button",children:[n.icon&&e.jsx("span",{className:"nice-sidebar-menu__icon",children:n.icon}),!l&&e.jsx("span",{className:"nice-sidebar-menu__label",children:n.text}),!l&&n.badge!==void 0&&e.jsx("span",{className:"nice-sidebar-menu__badge",children:n.badge}),!l&&o&&e.jsx("span",{className:"nice-sidebar-menu__chevron",children:e.jsx(i.NiceIcon,{name:r?"chevron-down":"chevron-right",size:14})})]}),o&&r&&!l&&e.jsx("ul",{className:"nice-sidebar-menu__children",children:n.children.map($=>u($,t+1))})]},n.key)};return e.jsxs("nav",{ref:m,id:j,className:`nice-sidebar-menu nice-sidebar-menu--${_} ${l?"nice-sidebar-menu--collapsed":""} ${R??""}`,style:{...I,width:l?d:x},...C,children:[g&&e.jsx("div",{className:"nice-sidebar-menu__header",children:g}),e.jsx("ul",{className:"nice-sidebar-menu__list",role:"list",children:p.map(n=>u(n))}),b&&e.jsx("div",{className:"nice-sidebar-menu__footer",children:b})]})}),{displayName:"NiceSidebarMenu"}),q=Object.assign(a.forwardRef(({items:p=E,activeKey:f,onItemClick:l,brand:x,actions:d,size:y="md",className:A,style:g,id:b,accessMode:_,...R},I)=>{const S=i.useControlId(b),D=i.useNiceAccessMode(_,b),[C,m]=a.useState(null),[j,M]=a.useState(!1),k=a.useRef(null),h=a.useRef(null);i.useRovingFocus(k,{orientation:"horizontal",wrap:!0,typeahead:!0}),i.useRovingFocus(h,{orientation:"vertical",wrap:!0,typeahead:!0}),i.useOverlayFocus(h,{open:C!=null&&!j,modal:!1,onClose:()=>m(null)});const c=n=>{M(!1),m(n)},u=n=>{if(n.key!=="ArrowLeft"&&n.key!=="ArrowRight")return;n.preventDefault();const t=[...k.current?.querySelectorAll(".nice-top-menu__btn")??[]],o=t.findIndex(N=>N.getAttribute("aria-expanded")==="true"),r=t[(o+(n.key==="ArrowRight"?1:-1)+t.length)%t.length];m(null),r?.focus()};return D==="hidden"?null:e.jsxs("nav",{ref:I,id:S,className:`nice-top-menu nice-top-menu--${y} ${A??""}`,style:g,...R,children:[x&&e.jsx("div",{className:"nice-top-menu__brand",children:x}),e.jsx("ul",{className:"nice-top-menu__items",role:"menubar",ref:k,children:p.map(n=>{const t=n.children&&n.children.length>0,o=C===n.key;return e.jsxs("li",{className:"nice-top-menu__item",onMouseEnter:()=>{t&&(M(!0),m(n.key))},onMouseLeave:()=>t&&m(null),children:[e.jsxs("button",{className:`nice-top-menu__btn ${n.key===f?"nice-top-menu__btn--active":""}`,onClick:()=>t?o?m(null):c(n.key):l?.(n),onKeyDown:r=>{const N=r.nativeEvent.niceSource;t&&r.key==="ArrowDown"&&N!=="gamepad"&&(r.preventDefault(),c(n.key))},role:"menuitem","aria-haspopup":t,"aria-expanded":o,disabled:n.disabled,type:"button",children:[n.icon&&e.jsx("span",{children:n.icon}),e.jsx("span",{children:n.text}),t&&e.jsx("span",{className:"nice-top-menu__chevron",children:e.jsx(i.NiceIcon,{name:"chevron-down",size:14})})]}),t&&o&&e.jsx("ul",{className:"nice-top-menu__dropdown",role:"menu",ref:h,onKeyDown:u,children:n.children.map(r=>e.jsx("li",{children:e.jsxs("button",{className:`nice-top-menu__dropdown-btn ${r.key===f?"nice-top-menu__dropdown-btn--active":""}`,onClick:()=>{l?.(r),m(null)},disabled:r.disabled,role:"menuitem",type:"button",children:[r.icon&&e.jsx("span",{children:r.icon}),e.jsx("span",{children:r.text}),r.badge!==void 0&&e.jsx("span",{className:"nice-top-menu__badge",children:r.badge})]})},r.key))})]},n.key)})}),d&&e.jsx("div",{className:"nice-top-menu__actions",children:d})]})}),{displayName:"NiceTopMenu"}),U=[],H=Object.assign(a.forwardRef(({tabs:p=U,activeTab:f,onTabChange:l,onItemClick:x,minimized:d=!1,onMinimizeToggle:y,size:A="md",className:g,style:b,id:_,accessMode:R,...I},S)=>{const D=a.useRef(null);i.useRovingFocus(D,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const C=i.useControlId(_),m=i.useNiceAccessMode(R,_),{t:j}=i.useNiceTranslation(),[M,k]=a.useState(void 0),h=f??M??p[0]?.key,c=p.find(n=>n.key===h),u=a.useCallback(n=>{k(n),l?.(n)},[l]);return m==="hidden"?null:e.jsxs("div",{ref:S,id:C,className:`nice-ribbon-menu nice-ribbon-menu--${A} ${d?"nice-ribbon-menu--minimized":""} ${g??""}`,style:b,...I,children:[e.jsxs("div",{className:"nice-ribbon-menu__tabs",ref:D,role:"tablist",children:[p.map(n=>e.jsx("button",{className:`nice-ribbon-menu__tab ${n.key===h?"nice-ribbon-menu__tab--active":""}`,onClick:()=>u(n.key),role:"tab","aria-selected":n.key===h,type:"button",children:n.label},n.key)),e.jsx("button",{className:"nice-ribbon-menu__minimize",onClick:()=>y?.(!d),type:"button","aria-label":d?j("nav.expand","Expand"):j("nav.collapse","Collapse"),children:e.jsx(i.NiceIcon,{name:d?"chevron-down":"chevron-up",size:14})})]}),!d&&c&&e.jsx("div",{className:"nice-ribbon-menu__panel",role:"tabpanel",children:c.groups.map((n,t)=>e.jsxs("div",{className:"nice-ribbon-menu__group",children:[e.jsx("div",{className:"nice-ribbon-menu__group-items",children:n.items.map(o=>e.jsxs("button",{className:"nice-ribbon-menu__item",onClick:()=>x?.(o),disabled:o.disabled,type:"button",children:[o.icon&&e.jsx("span",{className:"nice-ribbon-menu__item-icon",children:o.icon}),e.jsx("span",{className:"nice-ribbon-menu__item-label",children:o.text})]},o.key))}),e.jsx("div",{className:"nice-ribbon-menu__group-label",children:n.label})]},t))})]})}),{displayName:"NiceRibbonMenu"}),V=Object.assign(a.forwardRef(({items:p=E,activeKey:f,onItemClick:l,position:x="bottom",autoHide:d=!1,iconSize:y=40,size:A="md",className:g,style:b,id:_,accessMode:R,...I},S)=>{const D=i.useControlId(_),C=i.useNiceAccessMode(R,_),[m,j]=a.useState(!1),[M,k]=a.useState(!1),h=!d||m||M;return C==="hidden"?null:e.jsx("div",{ref:S,id:D,className:`nice-dock-menu nice-dock-menu--${x} nice-dock-menu--${A} ${d&&!h?"nice-dock-menu--hidden":""} ${g??""}`,style:b,onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),onFocus:()=>k(!0),onBlur:c=>{c.currentTarget.contains(c.relatedTarget)||k(!1)},...I,children:e.jsx("div",{className:"nice-dock-menu__items",children:p.map(c=>e.jsxs("button",{className:`nice-dock-menu__item ${c.key===f?"nice-dock-menu__item--active":""}`,onClick:()=>l?.(c),disabled:c.disabled,title:c.text,"aria-label":c.text,type:"button",style:{width:y,height:y},children:[c.icon?e.jsx("span",{className:"nice-dock-menu__icon",children:c.icon}):e.jsx("span",{children:c.text[0]}),c.badge!==void 0&&e.jsx("span",{className:"nice-dock-menu__badge",children:c.badge})]},c.key))})})}),{displayName:"NiceDockMenu"}),Y=Object.assign(a.forwardRef(({items:p=E,activeKey:f,onItemClick:l,open:x,onOpenChange:d,position:y="left",panelWidth:A=280,header:g,footer:b,size:_="md",className:R,style:I,id:S,accessMode:D,...C},m)=>{const j=i.useControlId(S),M=i.useNiceAccessMode(D,S),{t:k}=i.useNiceTranslation(),[h,c]=a.useState(!1),u=x??h,n=a.useCallback(v=>{c(v),d?.(v)},[d]),t=a.useCallback(()=>n(!u),[u,n]),o=a.useCallback(v=>{l?.(v),n(!1)},[l,n]),r=a.useRef(null),N=a.useRef(null),$=a.useRef(null);return a.useLayoutEffect(()=>{$.current?.toggleAttribute("inert",!u)},[u]),i.useMenuButton(r,N,{open:u,onOpenChange:n,closeOnFocusOut:!1,closeOnOutsidePress:!1}),M==="hidden"?null:e.jsxs("div",{ref:m,id:j,className:`nice-hamburger-menu nice-hamburger-menu--${_} ${R??""}`,style:I,...C,children:[e.jsx("button",{ref:r,className:"nice-hamburger-menu__trigger",onClick:t,"aria-label":k("nav.menu","Menu"),"aria-haspopup":"menu","aria-expanded":u,type:"button",children:e.jsxs("span",{className:`nice-hamburger-menu__icon ${u?"nice-hamburger-menu__icon--open":""}`,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})}),u&&e.jsx("div",{className:"nice-hamburger-menu__backdrop",onClick:t,"aria-hidden":!0}),e.jsxs("div",{ref:$,className:`nice-hamburger-menu__panel nice-hamburger-menu__panel--${y} ${u?"nice-hamburger-menu__panel--open":""}`,style:{width:A},children:[g&&e.jsx("div",{className:"nice-hamburger-menu__header",children:g}),e.jsx("ul",{className:"nice-hamburger-menu__list",role:"menu",ref:N,children:p.map(v=>e.jsx("li",{children:e.jsxs("button",{className:`nice-hamburger-menu__item ${v.key===f?"nice-hamburger-menu__item--active":""}`,onClick:()=>o(v),disabled:v.disabled,role:"menuitem",type:"button",children:[v.icon&&e.jsx("span",{className:"nice-hamburger-menu__item-icon",children:v.icon}),e.jsx("span",{children:v.text}),v.badge!==void 0&&e.jsx("span",{className:"nice-hamburger-menu__item-badge",children:v.badge})]})},v.key))}),b&&e.jsx("div",{className:"nice-hamburger-menu__footer",children:b})]})]})}),{displayName:"NiceHamburgerMenu"}),J=Object.assign(a.forwardRef(({canGoBack:p=!1,canGoForward:f=!1,onBack:l,onForward:x,onRefresh:d,enableShortcuts:y=!0,showRefresh:A=!0,showStop:g=!0,isLoading:b=!1,onStop:_,size:R="md",variant:I="default",tooltipPosition:S="bottom",backIcon:D,forwardIcon:C,refreshIcon:m,stopIcon:j,className:M,style:k,id:h,accessMode:c,disabled:u,...n},t)=>{const o=i.useControlId(h),r=i.useNiceAccessMode(c,h),{t:N}=i.useNiceTranslation();if(a.useEffect(()=>{if(!y||u)return;const T=w=>{const O=w.altKey,B=w.ctrlKey||w.metaKey;O&&w.key==="ArrowLeft"?(w.preventDefault(),p&&l?.()):O&&w.key==="ArrowRight"?(w.preventDefault(),f&&x?.()):w.key==="F5"||B&&w.key==="r"?(w.preventDefault(),b?_?.():d?.()):w.key==="Escape"&&b&&(w.preventDefault(),_?.())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[y,u,p,f,b,l,x,d,_]),r==="hidden")return null;const $=r==="disabled"||u,v=D??e.jsx(i.NiceIcon,{name:"chevron-left",size:16}),F=C??e.jsx(i.NiceIcon,{name:"chevron-right",size:16}),L=m??e.jsx(i.NiceIcon,{name:"refresh",size:16}),P=j??e.jsx(i.NiceIcon,{name:"close",size:16});return e.jsxs("div",{ref:t,id:o,className:`nice-nav-controls nice-nav-controls--${R} nice-nav-controls--${I}${$?" nice-nav-controls--disabled":""}${M?` ${M}`:""}`,style:k,role:"navigation","aria-label":N("nav.controls","Navigation controls"),...n,children:[e.jsx("button",{type:"button",className:`nice-nav-controls__btn nice-nav-controls__btn--back${p?"":" nice-nav-controls__btn--disabled"}`,onClick:l,disabled:$||!p,"aria-label":N("nav.back","Back"),title:`${N("nav.back","Back")} (Alt+←)`,children:v}),e.jsx("button",{type:"button",className:`nice-nav-controls__btn nice-nav-controls__btn--forward${f?"":" nice-nav-controls__btn--disabled"}`,onClick:x,disabled:$||!f,"aria-label":N("nav.forward","Forward"),title:`${N("nav.forward","Forward")} (Alt+→)`,children:F}),(A||g&&b)&&(b?e.jsx("button",{type:"button",className:"nice-nav-controls__btn nice-nav-controls__btn--stop nice-nav-controls__btn--loading",onClick:_,disabled:$,"aria-label":N("nav.stop","Stop"),title:`${N("nav.stop","Stop")} (Esc)`,children:P}):e.jsx("button",{type:"button",className:"nice-nav-controls__btn nice-nav-controls__btn--refresh",onClick:d,disabled:$,"aria-label":N("nav.refresh","Refresh"),title:`${N("nav.refresh","Refresh")} (F5)`,children:L}))]})}),{displayName:"NiceNavigationControls"});exports.DEFAULT_SIDEBAR_PREFS=s.DEFAULT_SIDEBAR_PREFS;exports.DesktopContextMenu=s.DesktopContextMenu;exports.DesktopGrid=s.DesktopGrid;exports.DesktopStartMenu=s.DesktopStartMenu;exports.DesktopSystemTray=s.DesktopSystemTray;exports.DesktopTaskbar=s.DesktopTaskbar;exports.NiceAccordion=s.NiceAccordion;exports.NiceAppLayout=s.NiceAppLayout;exports.NiceAuthButtons=s.NiceAuthButtons;exports.NiceBreadcrumb=s.NiceBreadcrumb;exports.NiceCard=s.NiceCard;exports.NiceConsole=s.NiceConsole;exports.NiceContextMenu=s.NiceContextMenu;exports.NiceDashboardLayout=s.NiceDashboardLayout;exports.NiceDashboardShell=s.NiceDashboardShell;exports.NiceDesktop=s.NiceDesktop;exports.NiceDock=s.NiceDock;exports.NiceDynamicSidebar=s.NiceDynamicSidebar;exports.NiceHybridShell=s.NiceHybridShell;exports.NiceKioskShell=s.NiceKioskShell;exports.NiceMdiWorkspace=s.NiceMdiWorkspace;exports.NiceMenu=s.NiceMenu;exports.NiceMinimalShell=s.NiceMinimalShell;exports.NiceModeSelector=s.NiceModeSelector;exports.NiceModernShell=s.NiceModernShell;exports.NiceModuleLifecyclePanel=s.NiceModuleLifecyclePanel;exports.NiceNavMenu=s.NiceNavMenu;exports.NiceNavbar=s.NiceNavbar;exports.NiceOrganizationProfileForm=s.NiceOrganizationProfileForm;exports.NicePwaShell=s.NicePwaShell;exports.NiceSetupWizard=s.NiceSetupWizard;exports.NiceSidebarNav=s.NiceSidebarNav;exports.NiceSplitter=s.NiceSplitter;exports.NiceUserMenu=s.NiceUserMenu;exports.NiceWizard=s.NiceWizard;exports.SIDEBAR_DEFAULT_FAVORITE_LIST=s.SIDEBAR_DEFAULT_FAVORITE_LIST;exports.SIDEBAR_MODE_META=s.SIDEBAR_MODE_META;exports.findSidebarItemByRoute=s.findSidebarItemByRoute;exports.mapSidebarViews=s.mapSidebarViews;exports.sidebarModeLabel=s.sidebarModeLabel;exports.walkSidebarNav=s.walkSidebarNav;exports.NiceTabs=z.NiceTabs;exports.NicePagination=K.NicePagination;exports.NiceDockMenu=V;exports.NiceHamburgerMenu=Y;exports.NiceNavigationControls=J;exports.NiceRibbonMenu=H;exports.NiceSidebarMenu=W;exports.NiceTopMenu=q;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./NiceModuleLifecyclePanel-DBQPCa_V.cjs"),e=require("react/jsx-runtime"),i=require("@nice2dev/ui-core"),a=require("react"),z=require("./pickerCommons-CwcCc8Qi.cjs"),K=require("./NicePagination-D7XxeNFz.cjs"),E=[],W=Object.assign(a.forwardRef(({items:p=E,activeKey:f,collapsed:l=!1,width:x=240,collapsedWidth:d=52,onItemClick:y,onCollapseChange:A,header:g,footer:b,size:_="md",className:R,style:I,id:S,accessMode:D,...C},m)=>{const j=i.useControlId(S),M=i.useNiceAccessMode(D,S),[k,h]=a.useState(new Set),c=a.useCallback(n=>{h(t=>{const o=new Set(t);return o.has(n)?o.delete(n):o.add(n),o})},[]);if(M==="hidden")return null;const u=(n,t=0)=>{const o=n.children&&n.children.length>0,r=k.has(n.key),N=n.key===f;return e.jsxs("li",{className:"nice-sidebar-menu__item",children:[e.jsxs("button",{className:`nice-sidebar-menu__btn ${N?"nice-sidebar-menu__btn--active":""} ${n.disabled?"nice-sidebar-menu__btn--disabled":""}`,style:{paddingLeft:l?void 0:12+t*16},onClick:()=>o?c(n.key):y?.(n),disabled:n.disabled,title:l?n.text:void 0,type:"button",children:[n.icon&&e.jsx("span",{className:"nice-sidebar-menu__icon",children:n.icon}),!l&&e.jsx("span",{className:"nice-sidebar-menu__label",children:n.text}),!l&&n.badge!==void 0&&e.jsx("span",{className:"nice-sidebar-menu__badge",children:n.badge}),!l&&o&&e.jsx("span",{className:"nice-sidebar-menu__chevron",children:e.jsx(i.NiceIcon,{name:r?"chevron-down":"chevron-right",size:14})})]}),o&&r&&!l&&e.jsx("ul",{className:"nice-sidebar-menu__children",children:n.children.map($=>u($,t+1))})]},n.key)};return e.jsxs("nav",{ref:m,id:j,className:`nice-sidebar-menu nice-sidebar-menu--${_} ${l?"nice-sidebar-menu--collapsed":""} ${R??""}`,style:{...I,width:l?d:x},...C,children:[g&&e.jsx("div",{className:"nice-sidebar-menu__header",children:g}),e.jsx("ul",{className:"nice-sidebar-menu__list",role:"list",children:p.map(n=>u(n))}),b&&e.jsx("div",{className:"nice-sidebar-menu__footer",children:b})]})}),{displayName:"NiceSidebarMenu"}),q=Object.assign(a.forwardRef(({items:p=E,activeKey:f,onItemClick:l,brand:x,actions:d,size:y="md",className:A,style:g,id:b,accessMode:_,...R},I)=>{const S=i.useControlId(b),D=i.useNiceAccessMode(_,b),[C,m]=a.useState(null),[j,M]=a.useState(!1),k=a.useRef(null),h=a.useRef(null);i.useRovingFocus(k,{orientation:"horizontal",wrap:!0,typeahead:!0}),i.useRovingFocus(h,{orientation:"vertical",wrap:!0,typeahead:!0}),i.useOverlayFocus(h,{open:C!=null&&!j,modal:!1,onClose:()=>m(null)});const c=n=>{M(!1),m(n)},u=n=>{if(n.key!=="ArrowLeft"&&n.key!=="ArrowRight")return;n.preventDefault();const t=[...k.current?.querySelectorAll(".nice-top-menu__btn")??[]],o=t.findIndex(N=>N.getAttribute("aria-expanded")==="true"),r=t[(o+(n.key==="ArrowRight"?1:-1)+t.length)%t.length];m(null),r?.focus()};return D==="hidden"?null:e.jsxs("nav",{ref:I,id:S,className:`nice-top-menu nice-top-menu--${y} ${A??""}`,style:g,...R,children:[x&&e.jsx("div",{className:"nice-top-menu__brand",children:x}),e.jsx("ul",{className:"nice-top-menu__items",role:"menubar",ref:k,children:p.map(n=>{const t=n.children&&n.children.length>0,o=C===n.key;return e.jsxs("li",{className:"nice-top-menu__item",onMouseEnter:()=>{t&&(M(!0),m(n.key))},onMouseLeave:()=>t&&m(null),children:[e.jsxs("button",{className:`nice-top-menu__btn ${n.key===f?"nice-top-menu__btn--active":""}`,onClick:()=>t?o?m(null):c(n.key):l?.(n),onKeyDown:r=>{const N=r.nativeEvent.niceSource;t&&r.key==="ArrowDown"&&N!=="gamepad"&&(r.preventDefault(),c(n.key))},role:"menuitem","aria-haspopup":t,"aria-expanded":o,disabled:n.disabled,type:"button",children:[n.icon&&e.jsx("span",{children:n.icon}),e.jsx("span",{children:n.text}),t&&e.jsx("span",{className:"nice-top-menu__chevron",children:e.jsx(i.NiceIcon,{name:"chevron-down",size:14})})]}),t&&o&&e.jsx("ul",{className:"nice-top-menu__dropdown",role:"menu",ref:h,onKeyDown:u,children:n.children.map(r=>e.jsx("li",{children:e.jsxs("button",{className:`nice-top-menu__dropdown-btn ${r.key===f?"nice-top-menu__dropdown-btn--active":""}`,onClick:()=>{l?.(r),m(null)},disabled:r.disabled,role:"menuitem",type:"button",children:[r.icon&&e.jsx("span",{children:r.icon}),e.jsx("span",{children:r.text}),r.badge!==void 0&&e.jsx("span",{className:"nice-top-menu__badge",children:r.badge})]})},r.key))})]},n.key)})}),d&&e.jsx("div",{className:"nice-top-menu__actions",children:d})]})}),{displayName:"NiceTopMenu"}),U=[],H=Object.assign(a.forwardRef(({tabs:p=U,activeTab:f,onTabChange:l,onItemClick:x,minimized:d=!1,onMinimizeToggle:y,size:A="md",className:g,style:b,id:_,accessMode:R,...I},S)=>{const D=a.useRef(null);i.useRovingFocus(D,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const C=i.useControlId(_),m=i.useNiceAccessMode(R,_),{t:j}=i.useNiceTranslation(),[M,k]=a.useState(void 0),h=f??M??p[0]?.key,c=p.find(n=>n.key===h),u=a.useCallback(n=>{k(n),l?.(n)},[l]);return m==="hidden"?null:e.jsxs("div",{ref:S,id:C,className:`nice-ribbon-menu nice-ribbon-menu--${A} ${d?"nice-ribbon-menu--minimized":""} ${g??""}`,style:b,...I,children:[e.jsxs("div",{className:"nice-ribbon-menu__tabs",ref:D,role:"tablist",children:[p.map(n=>e.jsx("button",{className:`nice-ribbon-menu__tab ${n.key===h?"nice-ribbon-menu__tab--active":""}`,onClick:()=>u(n.key),role:"tab","aria-selected":n.key===h,type:"button",children:n.label},n.key)),e.jsx("button",{className:"nice-ribbon-menu__minimize",onClick:()=>y?.(!d),type:"button","aria-label":d?j("nav.expand","Expand"):j("nav.collapse","Collapse"),children:e.jsx(i.NiceIcon,{name:d?"chevron-down":"chevron-up",size:14})})]}),!d&&c&&e.jsx("div",{className:"nice-ribbon-menu__panel",role:"tabpanel",children:c.groups.map((n,t)=>e.jsxs("div",{className:"nice-ribbon-menu__group",children:[e.jsx("div",{className:"nice-ribbon-menu__group-items",children:n.items.map(o=>e.jsxs("button",{className:"nice-ribbon-menu__item",onClick:()=>x?.(o),disabled:o.disabled,type:"button",children:[o.icon&&e.jsx("span",{className:"nice-ribbon-menu__item-icon",children:o.icon}),e.jsx("span",{className:"nice-ribbon-menu__item-label",children:o.text})]},o.key))}),e.jsx("div",{className:"nice-ribbon-menu__group-label",children:n.label})]},t))})]})}),{displayName:"NiceRibbonMenu"}),V=Object.assign(a.forwardRef(({items:p=E,activeKey:f,onItemClick:l,position:x="bottom",autoHide:d=!1,iconSize:y=40,size:A="md",className:g,style:b,id:_,accessMode:R,...I},S)=>{const D=i.useControlId(_),C=i.useNiceAccessMode(R,_),[m,j]=a.useState(!1),[M,k]=a.useState(!1),h=!d||m||M;return C==="hidden"?null:e.jsx("div",{ref:S,id:D,className:`nice-dock-menu nice-dock-menu--${x} nice-dock-menu--${A} ${d&&!h?"nice-dock-menu--hidden":""} ${g??""}`,style:b,onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),onFocus:()=>k(!0),onBlur:c=>{c.currentTarget.contains(c.relatedTarget)||k(!1)},...I,children:e.jsx("div",{className:"nice-dock-menu__items",children:p.map(c=>e.jsxs("button",{className:`nice-dock-menu__item ${c.key===f?"nice-dock-menu__item--active":""}`,onClick:()=>l?.(c),disabled:c.disabled,title:c.text,"aria-label":c.text,type:"button",style:{width:y,height:y},children:[c.icon?e.jsx("span",{className:"nice-dock-menu__icon",children:c.icon}):e.jsx("span",{children:c.text[0]}),c.badge!==void 0&&e.jsx("span",{className:"nice-dock-menu__badge",children:c.badge})]},c.key))})})}),{displayName:"NiceDockMenu"}),Y=Object.assign(a.forwardRef(({items:p=E,activeKey:f,onItemClick:l,open:x,onOpenChange:d,position:y="left",panelWidth:A=280,header:g,footer:b,size:_="md",className:R,style:I,id:S,accessMode:D,...C},m)=>{const j=i.useControlId(S),M=i.useNiceAccessMode(D,S),{t:k}=i.useNiceTranslation(),[h,c]=a.useState(!1),u=x??h,n=a.useCallback(v=>{c(v),d?.(v)},[d]),t=a.useCallback(()=>n(!u),[u,n]),o=a.useCallback(v=>{l?.(v),n(!1)},[l,n]),r=a.useRef(null),N=a.useRef(null),$=a.useRef(null);return a.useLayoutEffect(()=>{$.current?.toggleAttribute("inert",!u)},[u]),i.useMenuButton(r,N,{open:u,onOpenChange:n,closeOnFocusOut:!1,closeOnOutsidePress:!1}),M==="hidden"?null:e.jsxs("div",{ref:m,id:j,className:`nice-hamburger-menu nice-hamburger-menu--${_} ${R??""}`,style:I,...C,children:[e.jsx("button",{ref:r,className:"nice-hamburger-menu__trigger",onClick:t,"aria-label":k("nav.menu","Menu"),"aria-haspopup":"menu","aria-expanded":u,type:"button",children:e.jsxs("span",{className:`nice-hamburger-menu__icon ${u?"nice-hamburger-menu__icon--open":""}`,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})}),u&&e.jsx("div",{className:"nice-hamburger-menu__backdrop",onClick:t,"aria-hidden":!0}),e.jsxs("div",{ref:$,className:`nice-hamburger-menu__panel nice-hamburger-menu__panel--${y} ${u?"nice-hamburger-menu__panel--open":""}`,style:{width:A},children:[g&&e.jsx("div",{className:"nice-hamburger-menu__header",children:g}),e.jsx("ul",{className:"nice-hamburger-menu__list",role:"menu",ref:N,children:p.map(v=>e.jsx("li",{children:e.jsxs("button",{className:`nice-hamburger-menu__item ${v.key===f?"nice-hamburger-menu__item--active":""}`,onClick:()=>o(v),disabled:v.disabled,role:"menuitem",type:"button",children:[v.icon&&e.jsx("span",{className:"nice-hamburger-menu__item-icon",children:v.icon}),e.jsx("span",{children:v.text}),v.badge!==void 0&&e.jsx("span",{className:"nice-hamburger-menu__item-badge",children:v.badge})]})},v.key))}),b&&e.jsx("div",{className:"nice-hamburger-menu__footer",children:b})]})]})}),{displayName:"NiceHamburgerMenu"}),J=Object.assign(a.forwardRef(({canGoBack:p=!1,canGoForward:f=!1,onBack:l,onForward:x,onRefresh:d,enableShortcuts:y=!0,showRefresh:A=!0,showStop:g=!0,isLoading:b=!1,onStop:_,size:R="md",variant:I="default",tooltipPosition:S="bottom",backIcon:D,forwardIcon:C,refreshIcon:m,stopIcon:j,className:M,style:k,id:h,accessMode:c,disabled:u,...n},t)=>{const o=i.useControlId(h),r=i.useNiceAccessMode(c,h),{t:N}=i.useNiceTranslation();if(a.useEffect(()=>{if(!y||u)return;const T=w=>{const O=w.altKey,B=w.ctrlKey||w.metaKey;O&&w.key==="ArrowLeft"?(w.preventDefault(),p&&l?.()):O&&w.key==="ArrowRight"?(w.preventDefault(),f&&x?.()):w.key==="F5"||B&&w.key==="r"?(w.preventDefault(),b?_?.():d?.()):w.key==="Escape"&&b&&(w.preventDefault(),_?.())};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[y,u,p,f,b,l,x,d,_]),r==="hidden")return null;const $=r==="disabled"||u,v=D??e.jsx(i.NiceIcon,{name:"chevron-left",size:16}),F=C??e.jsx(i.NiceIcon,{name:"chevron-right",size:16}),L=m??e.jsx(i.NiceIcon,{name:"refresh",size:16}),P=j??e.jsx(i.NiceIcon,{name:"close",size:16});return e.jsxs("div",{ref:t,id:o,className:`nice-nav-controls nice-nav-controls--${R} nice-nav-controls--${I}${$?" nice-nav-controls--disabled":""}${M?` ${M}`:""}`,style:k,role:"navigation","aria-label":N("nav.controls","Navigation controls"),...n,children:[e.jsx("button",{type:"button",className:`nice-nav-controls__btn nice-nav-controls__btn--back${p?"":" nice-nav-controls__btn--disabled"}`,onClick:l,disabled:$||!p,"aria-label":N("nav.back","Back"),title:`${N("nav.back","Back")} (Alt+←)`,children:v}),e.jsx("button",{type:"button",className:`nice-nav-controls__btn nice-nav-controls__btn--forward${f?"":" nice-nav-controls__btn--disabled"}`,onClick:x,disabled:$||!f,"aria-label":N("nav.forward","Forward"),title:`${N("nav.forward","Forward")} (Alt+→)`,children:F}),(A||g&&b)&&(b?e.jsx("button",{type:"button",className:"nice-nav-controls__btn nice-nav-controls__btn--stop nice-nav-controls__btn--loading",onClick:_,disabled:$,"aria-label":N("nav.stop","Stop"),title:`${N("nav.stop","Stop")} (Esc)`,children:P}):e.jsx("button",{type:"button",className:"nice-nav-controls__btn nice-nav-controls__btn--refresh",onClick:d,disabled:$,"aria-label":N("nav.refresh","Refresh"),title:`${N("nav.refresh","Refresh")} (F5)`,children:L}))]})}),{displayName:"NiceNavigationControls"});exports.DEFAULT_SIDEBAR_PREFS=s.DEFAULT_SIDEBAR_PREFS;exports.DesktopContextMenu=s.DesktopContextMenu;exports.DesktopGrid=s.DesktopGrid;exports.DesktopStartMenu=s.DesktopStartMenu;exports.DesktopSystemTray=s.DesktopSystemTray;exports.DesktopTaskbar=s.DesktopTaskbar;exports.NiceAccordion=s.NiceAccordion;exports.NiceAppLayout=s.NiceAppLayout;exports.NiceAuthButtons=s.NiceAuthButtons;exports.NiceBreadcrumb=s.NiceBreadcrumb;exports.NiceCard=s.NiceCard;exports.NiceConsole=s.NiceConsole;exports.NiceContextMenu=s.NiceContextMenu;exports.NiceDashboardLayout=s.NiceDashboardLayout;exports.NiceDashboardShell=s.NiceDashboardShell;exports.NiceDesktop=s.NiceDesktop;exports.NiceDock=s.NiceDock;exports.NiceDynamicSidebar=s.NiceDynamicSidebar;exports.NiceHybridShell=s.NiceHybridShell;exports.NiceKioskShell=s.NiceKioskShell;exports.NiceMdiWorkspace=s.NiceMdiWorkspace;exports.NiceMenu=s.NiceMenu;exports.NiceMinimalShell=s.NiceMinimalShell;exports.NiceModeSelector=s.NiceModeSelector;exports.NiceModernShell=s.NiceModernShell;exports.NiceModuleLifecyclePanel=s.NiceModuleLifecyclePanel;exports.NiceNavMenu=s.NiceNavMenu;exports.NiceNavbar=s.NiceNavbar;exports.NiceOrganizationProfileForm=s.NiceOrganizationProfileForm;exports.NicePwaShell=s.NicePwaShell;exports.NiceSetupWizard=s.NiceSetupWizard;exports.NiceSidebarNav=s.NiceSidebarNav;exports.NiceSplitter=s.NiceSplitter;exports.NiceUserMenu=s.NiceUserMenu;exports.NiceWizard=s.NiceWizard;exports.SIDEBAR_DEFAULT_FAVORITE_LIST=s.SIDEBAR_DEFAULT_FAVORITE_LIST;exports.SIDEBAR_MODE_META=s.SIDEBAR_MODE_META;exports.findSidebarItemByRoute=s.findSidebarItemByRoute;exports.mapSidebarViews=s.mapSidebarViews;exports.sidebarModeLabel=s.sidebarModeLabel;exports.walkSidebarNav=s.walkSidebarNav;exports.NiceTabs=z.NiceTabs;exports.NicePagination=K.NicePagination;exports.NiceDockMenu=V;exports.NiceHamburgerMenu=Y;exports.NiceNavigationControls=J;exports.NiceRibbonMenu=H;exports.NiceSidebarMenu=W;exports.NiceTopMenu=q;
|
package/dist/navigation.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { NiceSize } from '@nice2dev/ui-core';
|
|
|
13
13
|
import { NiceTabDescriptor } from '@nice2dev/ui-core';
|
|
14
14
|
import { NiceTenantInfo } from '@nice2dev/ui-core';
|
|
15
15
|
import { NiceTheme } from '@nice2dev/ui-core';
|
|
16
|
+
import { NiceThemePreviewRoles } from '@nice2dev/ui-core';
|
|
16
17
|
import { NiceTranslateFn } from '@nice2dev/ui-core';
|
|
17
18
|
import { NiceUserMenuResponse } from '@nice2dev/ui-core';
|
|
18
19
|
import { NiceWorkspaceState } from '@nice2dev/ui-core';
|
|
@@ -2706,6 +2707,12 @@ declare interface ThemePreviewColors {
|
|
|
2706
2707
|
textColor: string;
|
|
2707
2708
|
/** Border of the thumbnail and of the card (defaults to a translucent overlay). */
|
|
2708
2709
|
border?: string;
|
|
2710
|
+
/**
|
|
2711
|
+
* The layout's colours (1.4.0, `themePreviewRoles`) — top bar, sidebar with its header levels,
|
|
2712
|
+
* highlight, body, panel. With them `'swatch'` / `'columns'` draws a column per role and `'page'` /
|
|
2713
|
+
* `'layout'` a small app; without them the shapes draw as before.
|
|
2714
|
+
*/
|
|
2715
|
+
roles?: NiceThemePreviewRoles;
|
|
2709
2716
|
}
|
|
2710
2717
|
|
|
2711
2718
|
/** A menu item in the user menu. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),g=require("@nice2dev/ui-core"),y=require("react"),K=require("country-flag-icons/string/3x2");function U(f){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const i in f)if(i!=="default"){const r=Object.getOwnPropertyDescriptor(f,i);Object.defineProperty(n,i,r.get?r:{enumerable:!0,get:()=>f[i]})}}return n.default=f,Object.freeze(n)}const F=U(K),O=[],Z=({tabs:f=O,activeTab:n,onChange:i,variant:r="default",vertical:l,size:d="md",iconOnly:t=!1,centered:c="auto",countLocation:b="right",showHints:s,id:o,className:h,"data-testid":a,style:m,displayStyle:x})=>{const{t:p}=g.useNiceTranslation(),v=g.useControlId(o),_=c==="auto"?t:c,S=g.useComponentDisplayStyle("tab",x),T=g.useComponentDisplayClass("tab",x),[C,D]=y.useState(n||f[0]?.id),w=n??C,j=y.useRef(null),A=y.useRef(null),[R]=g.useInputPreferences(),k=g.useHintsVisible(),$=y.useCallback(u=>{D(u),i?.(u)},[i]);g.useRovingFocus(A,{orientation:l?"vertical":"horizontal",wrap:!0,onMove:u=>{const N=u.getAttribute("data-tab-id");N&&$(N)}}),g.useIntent(["sectionPrev","sectionNext"],u=>{const N=f.filter(I=>!I.disabled);if(N.length<2)return!1;const H=N.findIndex(I=>I.id===w),G=u.intent==="sectionNext"?1:-1,P=N[(H+G+N.length)%N.length];return $(P.id),[...A.current?.querySelectorAll("[data-tab-id]")??[]].find(I=>I.getAttribute("data-tab-id")===P.id)?.focus(),!0},{ref:j}),g.useInputHints(j,f.length>1?[{intent:"sectionPrev",label:p("input.intent.sectionPrev","Previous section")},{intent:"sectionNext",label:p("input.intent.sectionNext","Next section")}]:[]);const E=f.length>1&&k&&(s??R.hintDensity==="bar-and-controls"),L=f.find(u=>u.id===w)?.content;return e.jsxs("div",{ref:j,className:`nice-tabs nice-tabs--${d} ${l?"nice-tabs--vertical":""} ${t?"nice-tabs--icon-only":""} nice-tabs--ds-${T} ${h||""}`,style:{...S,...m},"data-testid":a,children:[e.jsxs("div",{ref:A,className:`nice-tabs__list ${r!=="default"?`nice-tabs__list--${r}`:""} ${l?"nice-tabs__list--vertical":""} ${_?"nice-tabs__list--centered":""}`,role:"tablist","aria-orientation":l?"vertical":"horizontal",children:[E&&e.jsx("span",{className:"nice-tabs__hint","aria-hidden":"true",children:e.jsx(g.NiceButtonPrompt,{intent:"sectionPrev",size:"sm"})}),f.map(u=>e.jsxs("button",{type:"button",role:"tab",id:`${v}-tab-${u.id}`,"data-tab-id":u.id,"aria-selected":w===u.id,"aria-controls":`${v}-panel`,"aria-label":t?u.label:void 0,title:t?u.label:void 0,className:`nice-tabs__tab ${w===u.id?"nice-tabs__tab--active":""} ${u.disabled?"nice-tabs__tab--disabled":""} ${b==="bottom"?"nice-tabs__tab--count-bottom":""}`,disabled:u.disabled,onClick:()=>$(u.id),children:[u.icon,!t&&e.jsx("span",{children:u.label}),u.badge!==void 0&&e.jsx("span",{className:`nice-tabs__badge${b==="bottom"?" nice-tabs__badge--pill":""}`,children:u.badge})]},u.id)),E&&e.jsx("span",{className:"nice-tabs__hint","aria-hidden":"true",children:e.jsx(g.NiceButtonPrompt,{intent:"sectionNext",size:"sm"})})]}),e.jsx("div",{className:"nice-tabs__panel",role:"tabpanel",id:`${v}-panel`,"aria-labelledby":w?`${v}-tab-${w}`:void 0,children:L})]})};function V(f,{open:n,onSelect:i,onClose:r,onOpen:l,loop:d=!1,pageSize:t=10,intentRef:c}){const[b,s]=y.useState(0);y.useEffect(()=>{s(a=>f.length===0?0:Math.min(Math.max(a,0),f.length-1))},[f.length]);const o=y.useCallback((a,m)=>s(x=>{const p=f.length;if(p===0)return 0;const v=a(x);return m?(v%p+p)%p:Math.min(Math.max(v,0),p-1)}),[f.length]),h=y.useCallback(a=>{if(!n){(a.key==="ArrowDown"||a.key==="ArrowUp")&&(a.preventDefault(),l?.());return}const m=a.target instanceof HTMLTextAreaElement||a.target instanceof HTMLInputElement&&a.target.type!=="checkbox";if(a.key==="ArrowDown")a.preventDefault(),o(x=>x+1,d);else if(a.key==="ArrowUp")a.preventDefault(),o(x=>x-1,d);else if(a.key==="PageDown")a.preventDefault(),o(x=>x+t,!1);else if(a.key==="PageUp")a.preventDefault(),o(x=>x-t,!1);else if(!m&&(a.key==="Home"||a.key==="End"))a.preventDefault(),o(()=>a.key==="Home"?0:f.length-1,!1);else if(a.key==="Enter"){const x=f[b];x!==void 0&&(a.preventDefault(),i(x,b))}else a.key==="Escape"&&r?.()},[n,f,b,d,t,o,i,r,l]);return g.useIntent(["navigate","activate"],a=>{if(a.source==="keyboard")return!1;if(a.intent==="activate"){const m=f[b];if(m===void 0)return!1;i(m,b);return}if(a.direction!=="up"&&a.direction!=="down")return!1;o(m=>m+(a.direction==="down"?1:-1),d)},{ref:c,enabled:n&&!!c}),{activeIndex:b,setActiveIndex:s,handleKeyDown:h}}const Y=Object.assign(y.forwardRef(({label:f,checked:n=!1,onChange:i,disabled:r,readOnly:l,loading:d,required:t,size:c="md",name:b,id:s,className:o,style:h,accessMode:a,displayStyle:m,showKeyboardHints:x,error:p,helperText:v,labelPlacement:_,errorPlacement:S,labelWidth:T,controlWidth:C,"data-testid":D},w)=>{const j=g.useNiceAccessMode(a,s),A=j==="hidden";(j==="disabled"||j==="readOnly")&&(r=!0);const{t:R}=g.useNiceTranslation(),k=g.useControlId(s);g.useComponentDisplayStyle("toggle",m);const $=g.useComponentDisplayClass("toggle",m),E=y.useMemo(()=>[{key:"Space",description:R("shortcuts.toggle","Toggle on/off")}],[R]);return A?null:e.jsxs("div",{className:`nice-field nice-field--inline nice-field--${c} ${_==="left"?"nice-field--label-left":""} ${d?"nice-field--loading":""} ${o||""}`,style:{...h,...T!=null&&{"--nice-field-label-width":typeof T=="number"?`${T}px`:T},...C!=null&&{"--nice-field-control-width":typeof C=="number"?`${C}px`:C}},"data-testid":D,"aria-busy":d||void 0,children:[_==="left"&&f&&e.jsx("span",{className:`nice-field__label ${t?"nice-field__label--required":""}`,children:f}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("label",{className:`nice-toggle nice-toggle--ds-${$} ${c!=="md"?`nice-toggle--${c}`:""} ${r||d?"nice-toggle--disabled":""}`,htmlFor:k,children:[e.jsx("input",{ref:w,id:k,type:"checkbox",className:"nice-toggle__input",name:b,checked:n,disabled:r||d,readOnly:l,role:"switch","aria-checked":n,"aria-invalid":!!p,onChange:L=>{l||d||i?.(L.target.checked)}}),e.jsx("span",{className:"nice-toggle__track",children:e.jsx("span",{className:"nice-toggle__thumb"})}),_!=="left"&&f&&e.jsx("span",{children:f}),x&&e.jsx(g.NiceKeyboardHint,{shortcuts:E,size:"sm"})]}),d&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),S==="right"&&p&&e.jsx("div",{id:`${k}-error`,className:"nice-field__error",role:"alert",children:p}),S==="right"&&!p&&v&&e.jsx("div",{id:`${k}-helper`,className:"nice-field__helper",children:v})]}),S!=="right"&&p&&e.jsx("div",{id:`${k}-error`,className:"nice-field__error",role:"alert",children:p}),S!=="right"&&!p&&v&&e.jsx("div",{id:`${k}-helper`,className:"nice-field__helper",children:v})]})}),{displayName:"NiceToggle"}),J=Object.freeze({AR:["#74acdf","#ffffff","#74acdf"],AT:["#ed2939","#ffffff","#ed2939"],AU:["#012169","#ffffff","#e4002b"],BE:["#000000","#fae042","#ed2939"],BR:["#009c3b","#ffdf00","#002776"],CA:["#ff0000","#ffffff","#ff0000"],CH:["#d52b1e","#ffffff","#d52b1e"],CN:["#de2910","#ffde00","#de2910"],CZ:["#11457e","#ffffff","#d7141a"],DE:["#000000","#dd0000","#ffce00"],DK:["#c8102e","#ffffff","#c8102e"],EE:["#0072ce","#000000","#ffffff"],EG:["#ce1126","#ffffff","#000000"],ES:["#aa151b","#f1bf00","#aa151b"],FI:["#ffffff","#003580","#ffffff"],FR:["#0055a4","#ffffff","#ef4135"],GB:["#012169","#ffffff","#c8102e"],GR:["#0d5eaf","#ffffff","#0d5eaf"],HR:["#171796","#ffffff","#ff0000"],HU:["#ce2939","#ffffff","#477050"],IE:["#169b62","#ffffff","#ff883e"],IL:["#ffffff","#0038b8","#ffffff"],IN:["#ff9933","#ffffff","#138808"],IS:["#02529c","#ffffff","#dc1e35"],IT:["#009246","#ffffff","#ce2b37"],JP:["#ffffff","#bc002d","#ffffff"],KR:["#ffffff","#cd2e3a","#0047a0"],LT:["#fdb913","#006a44","#c1272d"],LU:["#ed2939","#ffffff","#00a1de"],LV:["#9e3039","#ffffff","#9e3039"],MX:["#006847","#ffffff","#ce1126"],NL:["#ae1c28","#ffffff","#21468b"],NO:["#ef2b2d","#ffffff","#002868"],NZ:["#012169","#ffffff","#cc142b"],PL:["#ffffff","#dc143c"],PT:["#006600","#ff0000"],RO:["#002b7f","#fcd116","#ce1126"],RU:["#ffffff","#0039a6","#d52b1e"],SE:["#006aa7","#fecc00","#006aa7"],SK:["#ffffff","#0b4ea2","#ee1c25"],TR:["#e30a17","#ffffff","#e30a17"],UA:["#005bbb","#ffd500"],US:["#b22234","#ffffff","#3c3b6e"],VN:["#da251d","#ffff00","#da251d"],ZA:["#007a4d","#ffffff","#de3831"],AD:["#10069f","#fedf00","#d50032"],AE:["#00732f","#ffffff","#000000"],AF:["#000000","#d32011","#007a36"],AG:["#ce1126","#fcd116","#000000"],AL:["#e41e20","#000000","#e41e20"],AM:["#d90012","#0033a0","#f2a800"],AO:["#ce1126","#000000","#ffc500"],AZ:["#0092bc","#ed2939","#509e2f"],BA:["#002395","#fecb00","#ffffff"],BB:["#00267f","#ffc726","#00267f"],BD:["#006a4e","#f42a41","#006a4e"],BF:["#ef2b2d","#009e49","#fcd116"],BG:["#ffffff","#00966e","#d62612"],BH:["#ffffff","#ce1126","#ce1126"],BI:["#1eb53a","#ffffff","#ce1126"],BJ:["#008751","#fcd116","#e8112d"],BN:["#f7e017","#ffffff","#000000"],BO:["#d52b1e","#f9e300","#007934"],BS:["#00778b","#ffc72c","#000000"],BT:["#ffcc33","#ff4e12","#ffcc33"],BW:["#75aadb","#ffffff","#000000"],BY:["#c8313e","#007c30","#ffffff"],BZ:["#003f87","#ce1126","#003f87"],CD:["#007fff","#f7d618","#ce1021"],CF:["#003082","#ffffff","#289728"],CG:["#009543","#fbde4a","#dc241f"],CI:["#f77f00","#ffffff","#009e60"],CM:["#007a5e","#ce1126","#fcd116"],CO:["#fcd116","#003893","#ce1126"],CR:["#002b7f","#ffffff","#ce1126"],CU:["#002590","#ffffff","#cf142b"],CV:["#003893","#ffffff","#cf2027"],CY:["#ffffff","#d57800","#ffffff"],DJ:["#6ab2e7","#ffffff","#12ad2b"],DM:["#006b3f","#ffffff","#000000"],DO:["#002d62","#ffffff","#ce1126"],DZ:["#006233","#ffffff","#d21034"],EC:["#ffd100","#034ea2","#ed1c24"],ER:["#ea0437","#0084c9","#418fde"],ET:["#078930","#fcdd09","#da121a"],FJ:["#68bfe5","#cc0000","#ffffff"],GA:["#3a75c4","#ffe700","#009e60"],GD:["#ce1126","#fcd116","#007a5e"],GE:["#ffffff","#ff0000","#ffffff"],GH:["#ce1126","#fcd116","#006b3f"],GM:["#ce1126","#ffffff","#0c1c8c"],GN:["#ce1126","#fcd116","#009460"],GQ:["#3e9a00","#ffffff","#e32118"],GT:["#4997d0","#ffffff","#4997d0"],GW:["#ce1126","#fcd116","#009e49"],GY:["#009e49","#ffffff","#fcd116"],HK:["#de2910","#ffffff","#de2910"],HN:["#0073cf","#ffffff","#0073cf"],HT:["#00209f","#d21034","#00209f"],ID:["#ff0000","#ffffff","#ff0000"],IQ:["#ce1126","#ffffff","#000000"],IR:["#239f40","#ffffff","#da0000"],JM:["#000000","#fed100","#009b3a"],JO:["#000000","#ffffff","#007a3d"],KE:["#000000","#bb0000","#006600"],KG:["#ff0000","#fcd116","#ff0000"],KH:["#032ea1","#e00025","#032ea1"],KM:["#fcd116","#ffffff","#ce1126"],KP:["#024fa2","#ed1c27","#024fa2"],KW:["#007a3d","#ffffff","#ce1126"],KZ:["#00afca","#fec50c","#00afca"],LA:["#ce1126","#002868","#ce1126"],LB:["#ed1c24","#ffffff","#ed1c24"],LI:["#002780","#ce1126","#002780"],LK:["#ffbe29","#8d153a","#00534e"],LR:["#bf0a30","#ffffff","#002868"],LS:["#00209f","#ffffff","#009543"],LY:["#e70013","#000000","#239e46"],MA:["#c1272d","#006233","#c1272d"],MD:["#0046ae","#ffd200","#cc092f"],ME:["#d4af37","#cc0033","#d4af37"],MG:["#ffffff","#fc3d32","#007e3a"],MH:["#003893","#dd7500","#ffffff"],MK:["#d20000","#ffe600","#d20000"],ML:["#14b53a","#fcd116","#ce1126"],MM:["#fecb00","#34b233","#ea2839"],MN:["#c4272f","#015197","#c4272f"],MO:["#00785a","#ffd700","#ffffff"],MR:["#006233","#ffc400","#d01c1f"],MT:["#ffffff","#cf142b","#ffffff"],MU:["#ea2839","#1a206d","#00a04d"],MV:["#d21034","#007e3a","#ffffff"],MW:["#000000","#ce1126","#339e35"],MY:["#cc0000","#ffffff","#010066"],MZ:["#009a44","#ffffff","#000000"],NA:["#003580","#ffffff","#009543"],NE:["#ff8000","#ffffff","#0db02b"],NG:["#008753","#ffffff","#008753"],NI:["#0067c6","#ffffff","#0067c6"],NP:["#dc143c","#003893","#dc143c"],OM:["#dc241f","#ffffff","#008000"],PA:["#ffffff","#cc0033","#005aa7"],PE:["#d91023","#ffffff","#d91023"],PG:["#ce1126","#000000","#fcd116"],PH:["#0038a8","#ffffff","#ce1126"],PK:["#ffffff","#01411c","#01411c"],PS:["#000000","#ffffff","#007a3d"],PY:["#d52b1e","#ffffff","#0038a8"],QA:["#ffffff","#8a1538","#8a1538"],RS:["#c6363c","#0c4076","#ffffff"],RW:["#00a1de","#fad201","#00a651"],SA:["#006c35","#ffffff","#006c35"],SB:["#0051ba","#fcd116","#215b33"],SC:["#003f87","#fcd116","#d62828"],SD:["#d21034","#ffffff","#000000"],SG:["#ed2939","#ffffff","#ed2939"],SI:["#ffffff","#0000ff","#ff0000"],SL:["#1eb53a","#ffffff","#0072c6"],SM:["#ffffff","#5eb6e4","#ffffff"],SN:["#00853f","#fdef42","#e31b23"],SO:["#4189dd","#ffffff","#4189dd"],SR:["#377e3f","#ffffff","#b40a2d"],SS:["#000000","#ce1126","#078930"],ST:["#12ad2b","#ffce00","#d21034"],SV:["#0047ab","#ffffff","#0047ab"],SY:["#ce1126","#ffffff","#000000"],SZ:["#3e5eb9","#ffd900","#b10c0c"],TD:["#002664","#fecb00","#c60c30"],TG:["#006a4e","#fcd116","#d21034"],TH:["#ed1c24","#ffffff","#241d4f"],TJ:["#cc0000","#ffffff","#006600"],TL:["#dc241f","#ffc726","#000000"],TM:["#00853e","#ffffff","#cc0000"],TN:["#e70013","#ffffff","#e70013"],TO:["#ffffff","#c10000","#c10000"],TT:["#ce1126","#ffffff","#000000"],TW:["#fe0000","#000095","#fe0000"],TZ:["#1eb53a","#fcd116","#00a3dd"],UG:["#000000","#fcdc04","#d90000"],UY:["#ffffff","#0038a8","#ffffff"],UZ:["#1eb53a","#ffffff","#0099b5"],VA:["#ffe000","#ffffff","#ffe000"],VE:["#fcd116","#00247d","#cf142b"],VU:["#000000","#ce1126","#009543"],WS:["#002b7f","#ffffff","#cc0033"],YE:["#ce1126","#ffffff","#000000"],ZM:["#198a00","#de2010","#ef7d00"],ZW:["#078930","#fcd116","#cf2027"]}),B=["#cbd5e1","#94a3b8","#cbd5e1"];function q(f){return f?J[f.toUpperCase()]??B:B}const z=F,W=({code:f,size:n=22,className:i})=>{const{t:r}=g.useNiceTranslation(),l=f?.toUpperCase(),d=l?z[l]:void 0,t=n,c=Math.round(n*2/3);return d?e.jsx("span",{className:i,role:"img","aria-label":r("pickerCommons.flag","{upper} flag").replace("{upper}",String(l)),style:{display:"inline-block",width:t,height:c,boxSizing:"content-box",border:"1px solid var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",borderRadius:2,overflow:"hidden",flexShrink:0,verticalAlign:"middle",lineHeight:0},dangerouslySetInnerHTML:{__html:d.replace("<svg ",`<svg width="${t}" height="${c}" preserveAspectRatio="xMidYMid slice" `)}}):e.jsx(Q,{code:f,size:n,className:i})},Q=({code:f,size:n=18,className:i})=>{const{t:r}=g.useNiceTranslation(),l=q(f);return e.jsx("span",{className:i,role:"img","aria-label":r("pickerCommons.flag2","{code} flag").replace("{code}",String(f)),style:{display:"inline-flex",width:n,height:Math.round(n*.7),boxSizing:"content-box",border:"1px solid var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",borderRadius:2,overflow:"hidden",flexShrink:0,verticalAlign:"middle"},children:l.map((d,t)=>e.jsx("span",{style:{flex:1,background:d}},t))})};function X(f,n,i,r=280){const[l,d]=y.useState(i==="left"?"left":"right"),t=y.useCallback(()=>{if(i!=="auto"){d(i);return}const c=n.current;if(!c||typeof window>"u")return;const b=c.getBoundingClientRect(),o=window.innerWidth-b.left,h=b.right;o>=r&&o>h?d("left"):d("right")},[i,n,r]);return y.useEffect(()=>{if(f)return t(),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[f,t]),l}const M=(f,n)=>({backgroundColor:f,backgroundImage:n});function ff({roles:f,w:n,h:i,border:r,className:l,label:d}){const t=[{key:"side",style:M(f.sideNav,f.sideNavImage),stripes:f.headers},{key:"top",style:M(f.topNav,f.topNavImage)},{key:"body",style:M(f.body,f.bodyImage)},{key:"panel",style:M(f.panel,f.panelImage)},{key:"highlight",style:M(f.highlight)}];return e.jsx("span",{className:l,role:"img","aria-label":d,"data-preview":"columns",style:{display:"inline-flex",width:n,height:i,border:`1px solid ${r}`,borderRadius:Math.max(2,Math.round(i*.14)),overflow:"hidden",flexShrink:0,verticalAlign:"middle"},children:t.map(c=>e.jsx("span",{"data-role":c.key,style:{flex:1,display:"flex",flexDirection:"column",...c.style},children:c.stripes?.map((b,s)=>e.jsx("span",{style:{flex:"0 0 20%",background:b}},s))},c.key))})}function ef({roles:f,w:n,h:i,border:r,className:l,label:d}){const t=Math.max(3,Math.round(i*.18)),c=Math.max(4,Math.round(n*.28)),b=Math.max(2,Math.round((i-t)*.13)),s=Math.max(2,Math.round(n*.06)),o=Math.max(1,Math.round(i*.06)),h=a=>({position:"absolute",...a});return e.jsxs("span",{className:l,role:"img","aria-label":d,"data-preview":"layout",style:{position:"relative",display:"inline-block",width:n,height:i,boxSizing:"content-box",...M(f.body,f.bodyImage),border:`1px solid ${r}`,borderRadius:Math.max(2,Math.round(i*.08)),overflow:"hidden",flexShrink:0,verticalAlign:"middle"},children:[e.jsx("span",{style:h({top:0,left:0,right:0,height:t,...M(f.topNav,f.topNavImage)})}),e.jsx("span",{style:h({top:Math.round(t*.3),left:s,width:Math.round(t*.4),height:Math.round(t*.4),borderRadius:"50%",background:f.primary})}),e.jsx("span",{style:h({top:Math.round(t*.42),left:s+t,width:Math.round(n*.22),height:o,background:f.topNavText,opacity:.8})}),e.jsx("span",{style:h({top:t,bottom:0,left:0,width:c,...M(f.sideNav,f.sideNavImage)})}),f.headers.map((a,m)=>e.jsx("span",{style:h({top:t+m*b,left:0,width:c,height:b,background:a})},m)),e.jsx("span",{style:h({top:t+f.headers.length*b+Math.round(b*.4),left:0,width:c,height:b,background:f.highlight})}),e.jsx("span",{style:h({top:t+s,left:c+s,right:s,bottom:s,...M(f.panel,f.panelImage),border:`1px solid ${f.panelBorder}`,borderRadius:2})}),e.jsx("span",{style:h({top:t+s*2.2,left:c+s*2,right:s*3,height:o,background:f.text,opacity:.85})}),e.jsx("span",{style:h({top:t+s*2.2+o*2.5,left:c+s*2,width:Math.round((n-c)*.4),height:o,background:f.text,opacity:.55})}),e.jsx("span",{style:h({bottom:s*2,right:s*2,width:Math.round((n-c)*.22),height:Math.max(2,o*2),borderRadius:2,background:f.primary})})]})}const tf=({colors:f,size:n=28,shape:i="page",className:r})=>{const{t:l}=g.useNiceTranslation(),d=n,t=Math.round(n*.75),c=f.border??"color-mix(in srgb, currentColor 30%, transparent)",b=l("pickerCommons.themePreview","Theme preview");if(f.roles){const p={roles:f.roles,w:d,h:t,border:c,className:r,label:b};return i==="swatch"||i==="columns"?e.jsx(ff,{...p}):e.jsx(ef,{...p})}if(i==="swatch"||i==="columns"){const p=[f.primary,f.background,f.backgroundSecondary??f.background,f.textColor];return e.jsx("span",{className:r,role:"img","aria-label":l("pickerCommons.themePreview","Theme preview"),style:{display:"inline-flex",width:d,height:t,border:`1px solid ${c}`,borderRadius:2,overflow:"hidden",flexShrink:0,verticalAlign:"middle"},children:p.map((v,_)=>e.jsx("span",{style:{flex:1,background:v}},_))})}const s=Math.max(2,Math.round(t*.17)),o=Math.max(2,Math.round(d*.14)),h=d-o*2,a=Math.max(2,Math.round(h*.16)),m=Math.max(1,Math.round(t*.07)),x=t-s;return e.jsxs("span",{className:r,role:"img","aria-label":l("pickerCommons.themePreview","Theme preview"),style:{position:"relative",display:"inline-block",width:d,height:t,boxSizing:"content-box",background:f.backgroundSecondary??f.background,border:`1px solid ${c}`,borderRadius:2,overflow:"hidden",flexShrink:0,verticalAlign:"middle"},children:[e.jsx("span",{style:{position:"absolute",top:0,left:0,right:0,height:s,background:f.primary}}),e.jsx("span",{style:{position:"absolute",top:s,bottom:0,left:o,right:o,background:f.background,borderLeft:`1px solid ${c}`,borderRight:`1px solid ${c}`}}),e.jsx("span",{style:{position:"absolute",top:s+Math.round(x*.28),left:o+a,right:o+a,height:m,background:f.textColor}}),e.jsx("span",{style:{position:"absolute",top:s+Math.round(x*.55),left:o+a,width:Math.max(3,Math.round((h-a*2)*.6)),height:m,background:f.textColor}})]})};exports.FlagIcon=W;exports.NiceTabs=Z;exports.NiceToggle=Y;exports.ThemePreviewSwatch=tf;exports.useDropdownAlignment=X;exports.useListKeyboardNav=V;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { jsxs as c, jsx as t, Fragment as V } from "react/jsx-runtime";
|
|
2
|
-
import { useNiceTranslation as je, NiceIcon as
|
|
2
|
+
import { useNiceTranslation as je, NiceIcon as fe, clickOnActivationKey as be } from "@nice2dev/ui-core";
|
|
3
3
|
import G, { forwardRef as _e, useState as E, useMemo as w, useRef as $e, useCallback as N, useImperativeHandle as Fe } from "react";
|
|
4
4
|
import { NiceButton as A } from "../buttons/NiceButton.mjs";
|
|
5
5
|
import { NiceButtonGroup as ye } from "../buttons/NiceButtonGroup.mjs";
|
|
6
|
-
const Le = [], C = (
|
|
7
|
-
const d = new Date(
|
|
6
|
+
const Le = [], C = (m, h) => {
|
|
7
|
+
const d = new Date(m);
|
|
8
8
|
return d.setDate(d.getDate() + h), d;
|
|
9
|
-
}, xe = (
|
|
10
|
-
const h =
|
|
9
|
+
}, xe = (m, h) => m.getFullYear() === h.getFullYear() && m.getMonth() === h.getMonth() && m.getDate() === h.getDate(), q = (m, h, d = "short") => d === "day" ? h.toLocaleDateString(m, { weekday: "short" }) : d === "long" ? h.toLocaleDateString(m, { day: "numeric", month: "short", year: "numeric" }) : h.toLocaleDateString(m, { day: "numeric", month: "short" }), H = (m) => {
|
|
10
|
+
const h = m.getDay();
|
|
11
11
|
return h === 0 || h === 6;
|
|
12
|
-
}, Ye = (
|
|
12
|
+
}, Ye = (m, h) => Math.ceil((h.getTime() - m.getTime()) / (1e3 * 60 * 60 * 24)), we = {
|
|
13
13
|
planned: "var(--nice-color-primary, #3b82f6)",
|
|
14
14
|
"in-progress": "var(--nice-color-warning, #f59e0b)",
|
|
15
15
|
completed: "var(--nice-color-success, #22c55e)",
|
|
16
16
|
blocked: "var(--nice-color-error, #ef4444)"
|
|
17
17
|
}, Ke = /* @__PURE__ */ Object.assign(
|
|
18
18
|
/* @__PURE__ */ _e(
|
|
19
|
-
(
|
|
19
|
+
(m, h) => {
|
|
20
20
|
const { t: d, lang: P } = je(), {
|
|
21
21
|
resources: z = Le,
|
|
22
22
|
allocations: j,
|
|
@@ -47,7 +47,7 @@ const Le = [], C = (f, h) => {
|
|
|
47
47
|
className: Me,
|
|
48
48
|
style: Se,
|
|
49
49
|
...Ce
|
|
50
|
-
} =
|
|
50
|
+
} = m, [k, le] = E(De), [D, O] = E(() => {
|
|
51
51
|
const e = new Date(ke ?? Date.now());
|
|
52
52
|
return e.setHours(0, 0, 0, 0), e;
|
|
53
53
|
}), de = w(() => {
|
|
@@ -66,14 +66,14 @@ const Le = [], C = (f, h) => {
|
|
|
66
66
|
(e) => (e.allocations ?? []).map((r) => ({ ...r, resourceId: r.resourceId ?? e.id }))
|
|
67
67
|
), [j, z]), [a, ue] = E(null), [pe, ge] = E(
|
|
68
68
|
null
|
|
69
|
-
), Ie = $e(null),
|
|
69
|
+
), Ie = $e(null), f = w(() => {
|
|
70
70
|
const e = L ? z.filter(L) : [...z];
|
|
71
71
|
return ie === "name" && e.sort((r, n) => r.name.localeCompare(n.name)), e;
|
|
72
72
|
}, [z, L, ie]), U = w(() => {
|
|
73
73
|
if (Y === "none")
|
|
74
|
-
return [{ key: "", title: "", resources:
|
|
74
|
+
return [{ key: "", title: "", resources: f }];
|
|
75
75
|
const e = /* @__PURE__ */ new Map();
|
|
76
|
-
return
|
|
76
|
+
return f.forEach((r) => {
|
|
77
77
|
const n = (Y === "department" ? r.department : r.type) || "Inne", i = e.get(n) || [];
|
|
78
78
|
i.push(r), e.set(n, i);
|
|
79
79
|
}), Array.from(e.entries()).map(([r, n]) => ({
|
|
@@ -81,7 +81,7 @@ const Le = [], C = (f, h) => {
|
|
|
81
81
|
title: r,
|
|
82
82
|
resources: n
|
|
83
83
|
}));
|
|
84
|
-
}, [
|
|
84
|
+
}, [f, Y]), u = w(() => {
|
|
85
85
|
const e = [];
|
|
86
86
|
let r = new Date(D);
|
|
87
87
|
for (let n = 0; n < de; n++)
|
|
@@ -89,7 +89,7 @@ const Le = [], C = (f, h) => {
|
|
|
89
89
|
return e;
|
|
90
90
|
}, [D, de, ce]), B = w(() => {
|
|
91
91
|
const e = /* @__PURE__ */ new Map();
|
|
92
|
-
return
|
|
92
|
+
return f.forEach((r) => {
|
|
93
93
|
const n = /* @__PURE__ */ new Map(), i = r.capacity || Z;
|
|
94
94
|
u.forEach((s) => {
|
|
95
95
|
const o = s.toISOString().split("T")[0], v = S.filter(
|
|
@@ -108,9 +108,9 @@ const Le = [], C = (f, h) => {
|
|
|
108
108
|
});
|
|
109
109
|
}), e.set(r.id, n);
|
|
110
110
|
}), e;
|
|
111
|
-
}, [
|
|
111
|
+
}, [f, u, S, Z, se]), W = w(() => {
|
|
112
112
|
const e = [];
|
|
113
|
-
return
|
|
113
|
+
return f.forEach((r) => {
|
|
114
114
|
const n = S.filter((i) => i.resourceId === r.id).sort((i, s) => new Date(i.start).getTime() - new Date(s.start).getTime());
|
|
115
115
|
for (let i = 0; i < n.length; i++) {
|
|
116
116
|
const s = n[i], o = [s];
|
|
@@ -121,13 +121,13 @@ const Le = [], C = (f, h) => {
|
|
|
121
121
|
o.length > 1 && e.push(o);
|
|
122
122
|
}
|
|
123
123
|
}), e.length > 0 && ne?.(e.flat()), e;
|
|
124
|
-
}, [
|
|
124
|
+
}, [f, S, ne]), he = 200, p = k === "day" ? 100 : k === "week" ? 60 : 30, Re = u.length * p, R = U.reduce(
|
|
125
125
|
(e, r) => e + (r.title ? 30 : 0) + r.resources.length * x,
|
|
126
126
|
0
|
|
127
127
|
), X = N((e) => {
|
|
128
128
|
const r = new Date(e);
|
|
129
129
|
r.setHours(0, 0, 0, 0), O(r);
|
|
130
|
-
}, []),
|
|
130
|
+
}, []), me = N(
|
|
131
131
|
(e) => {
|
|
132
132
|
const r = k === "month" ? 30 : k === "week" ? 7 : 1;
|
|
133
133
|
O((n) => C(n, e * r));
|
|
@@ -181,12 +181,12 @@ const Le = [], C = (f, h) => {
|
|
|
181
181
|
const r = e.clientX - a.startX, n = e.clientY - a.startY, i = Math.round(r / p);
|
|
182
182
|
if (i !== 0 || n !== 0)
|
|
183
183
|
if (a.mode === "move") {
|
|
184
|
-
const s = C(a.originalStart, i), o = Math.round(n / x), l =
|
|
184
|
+
const s = C(a.originalStart, i), o = Math.round(n / x), l = f.findIndex(
|
|
185
185
|
(g) => g.id === a.originalResourceId
|
|
186
186
|
), v = Math.max(
|
|
187
187
|
0,
|
|
188
|
-
Math.min(
|
|
189
|
-
), y =
|
|
188
|
+
Math.min(f.length - 1, l + o)
|
|
189
|
+
), y = f[v]?.id || a.originalResourceId;
|
|
190
190
|
ee?.(a.allocation, y, s);
|
|
191
191
|
} else {
|
|
192
192
|
const s = a.mode === "resize-start" ? C(a.originalStart, i) : a.originalStart, o = a.mode === "resize-end" ? C(a.originalEnd, i) : a.originalEnd;
|
|
@@ -194,7 +194,7 @@ const Le = [], C = (f, h) => {
|
|
|
194
194
|
}
|
|
195
195
|
ue(null);
|
|
196
196
|
},
|
|
197
|
-
[a, p, x,
|
|
197
|
+
[a, p, x, f, ee, re]
|
|
198
198
|
);
|
|
199
199
|
Fe(
|
|
200
200
|
h,
|
|
@@ -244,13 +244,13 @@ const Le = [], C = (f, h) => {
|
|
|
244
244
|
/* @__PURE__ */ t(
|
|
245
245
|
A,
|
|
246
246
|
{
|
|
247
|
-
onClick: () =>
|
|
247
|
+
onClick: () => me(-1),
|
|
248
248
|
"aria-label": d("planning.previous", "Previous"),
|
|
249
|
-
children: /* @__PURE__ */ t(
|
|
249
|
+
children: /* @__PURE__ */ t(fe, { name: "chevron-left", size: 14 })
|
|
250
250
|
}
|
|
251
251
|
),
|
|
252
252
|
/* @__PURE__ */ t(A, { onClick: () => X(/* @__PURE__ */ new Date()), children: d("scheduling.today", "Today") }),
|
|
253
|
-
/* @__PURE__ */ t(A, { onClick: () =>
|
|
253
|
+
/* @__PURE__ */ t(A, { onClick: () => me(1), "aria-label": d("planning.next", "Next"), children: /* @__PURE__ */ t(fe, { name: "chevron-right", size: 14 }) })
|
|
254
254
|
] }),
|
|
255
255
|
/* @__PURE__ */ c("span", { className: "nice-resource-range", children: [
|
|
256
256
|
q(P, u[0], "long"),
|
|
@@ -616,23 +616,23 @@ const Le = [], C = (f, h) => {
|
|
|
616
616
|
.nice-resource-chart {
|
|
617
617
|
flex: 1;
|
|
618
618
|
overflow-x: auto;
|
|
619
|
-
scrollbar-color: var(--nice-border-color, #cbd5e1) transparent;
|
|
620
|
-
scrollbar-width: thin;
|
|
621
619
|
}
|
|
622
620
|
.nice-resource-chart::-webkit-scrollbar {
|
|
623
621
|
height: 10px;
|
|
624
622
|
width: 10px;
|
|
625
623
|
}
|
|
626
624
|
.nice-resource-chart::-webkit-scrollbar-track {
|
|
627
|
-
background: var(--nice-
|
|
625
|
+
background: var(--nice-scrollbar-track);
|
|
628
626
|
}
|
|
629
627
|
.nice-resource-chart::-webkit-scrollbar-thumb {
|
|
630
|
-
background: var(--nice-
|
|
631
|
-
|
|
632
|
-
border:
|
|
628
|
+
background-color: var(--nice-scrollbar-thumb);
|
|
629
|
+
background-image: var(--nice-scrollbar-thumb-image);
|
|
630
|
+
border-radius: var(--nice-scrollbar-radius);
|
|
631
|
+
border: 2px solid transparent;
|
|
632
|
+
background-clip: padding-box;
|
|
633
633
|
}
|
|
634
634
|
.nice-resource-chart::-webkit-scrollbar-thumb:hover {
|
|
635
|
-
background: var(--nice-
|
|
635
|
+
background-color: var(--nice-scrollbar-thumb-hover);
|
|
636
636
|
}
|
|
637
637
|
|
|
638
638
|
.nice-resource-dates {
|