@nice2dev/ui 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/dist/NiceCodeEditor-DhdjnDLV.cjs +289 -0
- package/dist/{NiceDataGrid-BT6iCUgP.cjs → NiceDataGrid-CrKDzMM1.cjs} +1 -1
- package/dist/{NiceForm-Bysp66Ef.cjs → NiceForm-CT9hEXpc.cjs} +1 -1
- package/dist/NiceLoginForm-C2-WgRn0.cjs +1 -0
- package/dist/NiceMention-BZEHqPrf.cjs +432 -0
- package/dist/NiceModuleLifecyclePanel-DKlqKPy2.cjs +1 -0
- package/dist/{NiceSavedQueryPanel-BbznsXFd.cjs → NiceSavedQueryPanel-C5Ab_NWx.cjs} +1 -1
- package/dist/NiceScheduler-BZQAKEVF.cjs +5 -0
- package/dist/{NiceWindow-pgR4c-kQ.cjs → NiceWindow-BklnkBpu.cjs} +1 -1
- package/dist/charts/NiceLinearGauge.mjs +96 -83
- package/dist/charts/NicePolarChart.mjs +47 -47
- package/dist/charts-BzlvCCg9.cjs +768 -0
- package/dist/charts.cjs +1 -1
- package/dist/{core-lazy-CL4ZIxF-.cjs → core-lazy-VTd5zfoZ.cjs} +1 -1
- package/dist/data.cjs +1 -1
- package/dist/display/NiceAvatar.mjs +40 -24
- package/dist/editors/pickers/NiceDateRangeBox.mjs +92 -92
- package/dist/editors/pickers/NiceDateTimePicker.mjs +173 -173
- package/dist/editors/rich/NiceCodeEditor.mjs +645 -584
- package/dist/editors/rich/NiceDocumentEditor.mjs +277 -254
- package/dist/editors.cjs +1 -1
- package/dist/feedback/NiceDrawer.mjs +15 -15
- package/dist/feedback.cjs +1 -1
- package/dist/index.cjs +202 -202
- package/dist/index.d.ts +18 -0
- package/dist/lazy.cjs +1 -1
- package/dist/navigation/NiceNavShell.mjs +646 -593
- package/dist/navigation/NiceSidebarNav.mjs +844 -823
- package/dist/navigation.cjs +1 -1
- package/dist/overlays/NiceWindow.mjs +91 -91
- package/dist/overlays.cjs +1 -1
- package/dist/planning/NiceScheduler.mjs +170 -169
- package/dist/planning/NiceSchedulerViews.mjs +242 -233
- package/dist/style.css +2 -2
- package/dist/utility/intlNames.mjs +26 -16
- package/package.json +4 -4
- package/dist/NiceCodeEditor-D0QZW88r.cjs +0 -268
- package/dist/NiceLoginForm-FGf32sro.cjs +0 -1
- package/dist/NiceMention-sc8W-DwH.cjs +0 -430
- package/dist/NiceModuleLifecyclePanel-DBQPCa_V.cjs +0 -1
- package/dist/NiceScheduler-3Ez0zSQJ.cjs +0 -5
- package/dist/charts-B0tHOpJ7.cjs +0 -768
package/dist/charts.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./charts-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./charts-BzlvCCg9.cjs");exports.CHART_COLORS=e.CHART_COLORS;exports.NiceBarGauge=e.NiceBarGauge;exports.NiceBullet=e.NiceBullet;exports.NiceChart=e.NiceChart;exports.NiceChartAI=e.NiceChartAI;exports.NiceCircularGauge=e.NiceCircularGauge;exports.NiceForecastChart=e.NiceForecastChart;exports.NiceFunnel=e.NiceFunnel;exports.NiceHeatMap=e.NiceHeatMap;exports.NiceLinearGauge=e.NiceLinearGauge;exports.NiceLiveChart=e.NiceLiveChart;exports.NiceOrganizationChart=e.NiceOrganizationChart;exports.NicePieChart=e.NicePieChart;exports.NicePolarChart=e.NicePolarChart;exports.NiceRangeSelector=e.NiceRangeSelector;exports.NiceSankey=e.NiceSankey;exports.NiceSparkline=e.NiceSparkline;exports.NiceStockChart=e.NiceStockChart;exports.NiceTreeMap=e.NiceTreeMap;exports.NiceVectorMap=e.NiceVectorMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("react/jsx-runtime"),C=require("@nice2dev/ui-core"),o=require("react"),f=({height:e=200})=>r.jsx("div",{className:"ntd-lazy-loading",style:{display:"flex",alignItems:"center",justifyContent:"center",height:e,background:"var(--ntd-color-surface, #f5f5f5)",borderRadius:"var(--ntd-radius, 8px)",animation:"ntd-pulse 1.5s ease-in-out infinite"},children:r.jsx("div",{className:"ntd-lazy-loading-spinner",style:{width:24,height:24,border:"2px solid var(--ntd-color-border, #ddd)",borderTopColor:"var(--ntd-color-primary, #6366f1)",borderRadius:"50%",animation:"ntd-spin 0.8s linear infinite"}})}),L=(e,t)=>{const{t:a}=C.useNiceTranslation();return r.jsxs("div",{className:"ntd-lazy-error",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:24,background:"var(--ntd-color-error-bg, #fee2e2)",borderRadius:"var(--ntd-radius, 8px)",color:"var(--ntd-color-error, #dc2626)"},children:[r.jsx(C.NiceIcon,{name:"error",size:32}),r.jsx("p",{style:{margin:"12px 0 8px",fontWeight:500},children:a("lazy.failedToLoadComponent","Failed to load component")}),r.jsx("p",{style:{margin:0,fontSize:"0.875em",opacity:.8},children:e.message}),r.jsx("button",{onClick:t,style:{marginTop:16,padding:"8px 16px",border:"none",borderRadius:"var(--ntd-radius, 8px)",background:"var(--ntd-color-error, #dc2626)",color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:"0.875em"},children:a("lazy.retry","Retry")})]})};class D extends o.Component{constructor(){super(...arguments),this.state={error:null},this.handleRetry=()=>{this.setState({error:null})}}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?this.props.fallback(this.state.error,this.handleRetry):this.props.children}}function i(e,t={}){const{fallback:a=r.jsx(f,{}),preloadOnMount:l=!1,preloadOnHover:p=!1,preloadAfterIdle:n,minLoadingTime:m=0,ssrFallback:c,errorFallback:S=L,displayName:P}=t;let b=null,h=!1;const y=async()=>{if(b)return b;const x=Date.now();b=e();const v=await b;if(m>0){const w=Date.now()-x;w<m&&await new Promise(u=>setTimeout(u,m-w))}return h=!0,v},I=o.lazy(y),q=x=>{const v=o.useRef(null);return o.useEffect(()=>{l&&!h&&y()},[]),o.useEffect(()=>{if(n&&!h){const u="requestIdleCallback"in window?window.requestIdleCallback(()=>y(),{timeout:n}):setTimeout(()=>y(),n);return()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(u):clearTimeout(u)}}},[]),o.useEffect(()=>{if(!p||h)return;const u=v.current;if(!u)return;const N=()=>{h||y()};return u.addEventListener("mouseenter",N,{once:!0}),()=>u.removeEventListener("mouseenter",N)},[]),typeof window>"u"&&c?r.jsx(r.Fragment,{children:c}):r.jsx("div",{ref:v,className:"ntd-lazy-wrapper",children:r.jsx(D,{fallback:S,children:r.jsx(o.Suspense,{fallback:a,children:r.jsx(I,{...x})})})})},R=async()=>{h||await y()},k=q;return k.preload=R,k.displayName=P||"LazyComponent",k}function G(e=.1,t="100px"){const a=o.useRef(null),[l,p]=o.useState(!1);return o.useEffect(()=>{if(!a.current||l)return;const n=new IntersectionObserver(([m])=>{m.isIntersecting&&(p(!0),n.disconnect())},{threshold:e,rootMargin:t});return n.observe(a.current),()=>n.disconnect()},[e,t,l]),[a,l]}function V(e,t=2e3){o.useEffect(()=>{if("requestIdleCallback"in window){const a=window.requestIdleCallback(()=>{e.forEach(l=>l())},{timeout:t});return()=>window.cancelIdleCallback(a)}else{const a=setTimeout(()=>{e.forEach(l=>l())},t);return()=>clearTimeout(a)}},[])}function T(e,t){const a=o.useRef(new Set);o.useEffect(()=>{const l=document.querySelectorAll("a[href]"),p=n=>{const c=n.currentTarget.getAttribute("href");c&&e[c]&&!a.current.has(c)&&(e[c](),a.current.add(c))};return l.forEach(n=>{n.addEventListener("mouseenter",p)}),()=>{l.forEach(n=>{n.removeEventListener("mouseenter",p)})}},[t,e])}const z=()=>r.jsx(f,{height:400}),g=()=>r.jsx(f,{height:300}),j=()=>r.jsx(f,{height:500}),E=()=>r.jsx(f,{height:600}),d=e=>e,s={CodeEditor:i(d(()=>Promise.resolve().then(()=>require("./NiceCodeEditor-
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),C=require("@nice2dev/ui-core"),o=require("react"),f=({height:e=200})=>r.jsx("div",{className:"ntd-lazy-loading",style:{display:"flex",alignItems:"center",justifyContent:"center",height:e,background:"var(--ntd-color-surface, #f5f5f5)",borderRadius:"var(--ntd-radius, 8px)",animation:"ntd-pulse 1.5s ease-in-out infinite"},children:r.jsx("div",{className:"ntd-lazy-loading-spinner",style:{width:24,height:24,border:"2px solid var(--ntd-color-border, #ddd)",borderTopColor:"var(--ntd-color-primary, #6366f1)",borderRadius:"50%",animation:"ntd-spin 0.8s linear infinite"}})}),L=(e,t)=>{const{t:a}=C.useNiceTranslation();return r.jsxs("div",{className:"ntd-lazy-error",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:24,background:"var(--ntd-color-error-bg, #fee2e2)",borderRadius:"var(--ntd-radius, 8px)",color:"var(--ntd-color-error, #dc2626)"},children:[r.jsx(C.NiceIcon,{name:"error",size:32}),r.jsx("p",{style:{margin:"12px 0 8px",fontWeight:500},children:a("lazy.failedToLoadComponent","Failed to load component")}),r.jsx("p",{style:{margin:0,fontSize:"0.875em",opacity:.8},children:e.message}),r.jsx("button",{onClick:t,style:{marginTop:16,padding:"8px 16px",border:"none",borderRadius:"var(--ntd-radius, 8px)",background:"var(--ntd-color-error, #dc2626)",color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:"0.875em"},children:a("lazy.retry","Retry")})]})};class D extends o.Component{constructor(){super(...arguments),this.state={error:null},this.handleRetry=()=>{this.setState({error:null})}}static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?this.props.fallback(this.state.error,this.handleRetry):this.props.children}}function i(e,t={}){const{fallback:a=r.jsx(f,{}),preloadOnMount:l=!1,preloadOnHover:p=!1,preloadAfterIdle:n,minLoadingTime:m=0,ssrFallback:c,errorFallback:S=L,displayName:P}=t;let b=null,h=!1;const y=async()=>{if(b)return b;const x=Date.now();b=e();const v=await b;if(m>0){const w=Date.now()-x;w<m&&await new Promise(u=>setTimeout(u,m-w))}return h=!0,v},I=o.lazy(y),q=x=>{const v=o.useRef(null);return o.useEffect(()=>{l&&!h&&y()},[]),o.useEffect(()=>{if(n&&!h){const u="requestIdleCallback"in window?window.requestIdleCallback(()=>y(),{timeout:n}):setTimeout(()=>y(),n);return()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(u):clearTimeout(u)}}},[]),o.useEffect(()=>{if(!p||h)return;const u=v.current;if(!u)return;const N=()=>{h||y()};return u.addEventListener("mouseenter",N,{once:!0}),()=>u.removeEventListener("mouseenter",N)},[]),typeof window>"u"&&c?r.jsx(r.Fragment,{children:c}):r.jsx("div",{ref:v,className:"ntd-lazy-wrapper",children:r.jsx(D,{fallback:S,children:r.jsx(o.Suspense,{fallback:a,children:r.jsx(I,{...x})})})})},R=async()=>{h||await y()},k=q;return k.preload=R,k.displayName=P||"LazyComponent",k}function G(e=.1,t="100px"){const a=o.useRef(null),[l,p]=o.useState(!1);return o.useEffect(()=>{if(!a.current||l)return;const n=new IntersectionObserver(([m])=>{m.isIntersecting&&(p(!0),n.disconnect())},{threshold:e,rootMargin:t});return n.observe(a.current),()=>n.disconnect()},[e,t,l]),[a,l]}function V(e,t=2e3){o.useEffect(()=>{if("requestIdleCallback"in window){const a=window.requestIdleCallback(()=>{e.forEach(l=>l())},{timeout:t});return()=>window.cancelIdleCallback(a)}else{const a=setTimeout(()=>{e.forEach(l=>l())},t);return()=>clearTimeout(a)}},[])}function T(e,t){const a=o.useRef(new Set);o.useEffect(()=>{const l=document.querySelectorAll("a[href]"),p=n=>{const c=n.currentTarget.getAttribute("href");c&&e[c]&&!a.current.has(c)&&(e[c](),a.current.add(c))};return l.forEach(n=>{n.addEventListener("mouseenter",p)}),()=>{l.forEach(n=>{n.removeEventListener("mouseenter",p)})}},[t,e])}const z=()=>r.jsx(f,{height:400}),g=()=>r.jsx(f,{height:300}),j=()=>r.jsx(f,{height:500}),E=()=>r.jsx(f,{height:600}),d=e=>e,s={CodeEditor:i(d(()=>Promise.resolve().then(()=>require("./NiceCodeEditor-DhdjnDLV.cjs")).then(e=>({default:e.NiceCodeEditor}))),{fallback:r.jsx(z,{}),preloadOnHover:!0,displayName:"LazyCodeEditor"}),HtmlEditor:i(d(()=>Promise.resolve().then(()=>require("./NiceHtmlEditor-C1OVtLQ6.cjs")).then(e=>({default:e.NiceHtmlEditor}))),{fallback:r.jsx(z,{}),preloadOnHover:!0,displayName:"LazyHtmlEditor"}),DocumentViewer:i(d(()=>Promise.resolve().then(()=>require("./NiceDocumentViewer-CDXAmPp7.cjs")).then(e=>({default:e.NiceDocumentViewer}))),{fallback:r.jsx(f,{height:600}),displayName:"LazyDocumentViewer"}),Chart:i(d(()=>Promise.resolve().then(()=>require("./charts-BzlvCCg9.cjs")).then(e=>e.NiceChart$1).then(e=>({default:e.NiceChart}))),{fallback:r.jsx(g,{}),preloadAfterIdle:3e3,displayName:"LazyChart"}),VectorMap:i(d(()=>Promise.resolve().then(()=>require("./charts-BzlvCCg9.cjs")).then(e=>e.NiceVectorMap$1).then(e=>({default:e.NiceVectorMap}))),{fallback:r.jsx(f,{height:400}),displayName:"LazyVectorMap"}),Sankey:i(d(()=>Promise.resolve().then(()=>require("./charts-BzlvCCg9.cjs")).then(e=>e.NiceSankey$1).then(e=>({default:e.NiceSankey}))),{fallback:r.jsx(g,{}),displayName:"LazySankey"}),Scheduler:i(d(()=>Promise.resolve().then(()=>require("./NiceScheduler-BZQAKEVF.cjs")).then(e=>e.NiceScheduler$1).then(e=>({default:e.NiceScheduler}))),{fallback:r.jsx(E,{}),displayName:"LazyScheduler"}),Gantt:i(d(()=>Promise.resolve().then(()=>require("./NiceGantt-BygumlaY.cjs")).then(e=>({default:e.NiceGantt}))),{fallback:r.jsx(E,{}),displayName:"LazyGantt"}),PivotGrid:i(d(()=>Promise.resolve().then(()=>require("./NicePivotGrid-Cnkr9WkC.cjs")).then(e=>e.NicePivotGrid$1).then(e=>({default:e.NicePivotGrid}))),{fallback:r.jsx(j,{}),displayName:"LazyPivotGrid"}),DataGrid:i(d(()=>Promise.resolve().then(()=>require("./NiceDataGrid-CrKDzMM1.cjs")).then(e=>e.NiceDataGrid$1).then(e=>({default:e.NiceDataGrid}))),{fallback:r.jsx(j,{}),preloadAfterIdle:2e3,displayName:"LazyDataGrid"})};async function H(){await Promise.all([s.CodeEditor.preload(),s.HtmlEditor.preload(),s.DocumentViewer.preload(),s.Chart.preload(),s.VectorMap.preload(),s.Sankey.preload(),s.Scheduler.preload(),s.Gantt.preload(),s.PivotGrid.preload()])}async function O(e){await Promise.all(e.map(t=>s[t].preload()))}exports.DefaultErrorFallback=L;exports.DefaultLoadingFallback=f;exports.LazyComponents=s;exports.createLazyComponent=i;exports.preloadAllHeavyComponents=H;exports.preloadComponents=O;exports.useLazyOnVisible=G;exports.usePreloadOnIdle=V;exports.usePreloadOnRouteHint=T;
|
package/dist/data.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./NiceDataGrid-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./NiceDataGrid-CrKDzMM1.cjs"),e=require("./NiceSavedQueryPanel-C5Ab_NWx.cjs"),r=require("./NicePivotGrid-Cnkr9WkC.cjs");exports.NiceDataGrid=i.NiceDataGrid;exports.applyColumnOrder=i.applyColumnOrder;exports.buildColumnGroupSegments=i.buildColumnGroupSegments;exports.buildGridState=i.buildGridState;exports.computeAggregate=i.computeAggregate;exports.escapeCsvField=i.escapeCsvField;exports.formatNumberPattern=i.formatNumberPattern;exports.measureColumnContentWidth=i.measureColumnContentWidth;exports.readStoredGridState=i.readStoredGridState;exports.writeStoredGridState=i.writeStoredGridState;exports.NiceDataGridAI=e.NiceDataGridAI;exports.NiceKanbanBoard=e.NiceKanbanBoard;exports.NiceList=e.NiceList;exports.NiceModuleGrid=e.NiceModuleGrid;exports.NiceReconciliationView=e.NiceReconciliationView;exports.NiceSavedQueryPanel=e.NiceSavedQueryPanel;exports.NiceSpreadsheet=e.NiceSpreadsheet;exports.NiceTable=e.NiceTable;exports.NiceTileView=e.NiceTileView;exports.NiceTreeGrid=e.NiceTreeGrid;exports.NiceTreeList=e.NiceTreeList;exports.NiceTreeView=e.NiceTreeView;exports.NicePivotGrid=r.NicePivotGrid;exports.NicePivotGridFieldChooser=r.NicePivotGridFieldChooser;
|
|
@@ -1,29 +1,45 @@
|
|
|
1
|
-
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { NiceIcon as
|
|
3
|
-
function
|
|
4
|
-
return
|
|
1
|
+
import { jsx as e, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import { NiceIcon as f } from "@nice2dev/ui-core";
|
|
3
|
+
function _(i) {
|
|
4
|
+
return i.split(" ").map((t) => t[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
|
|
5
5
|
}
|
|
6
|
-
const
|
|
7
|
-
src:
|
|
8
|
-
alt:
|
|
9
|
-
name:
|
|
10
|
-
size:
|
|
11
|
-
square:
|
|
6
|
+
const h = ({
|
|
7
|
+
src: i,
|
|
8
|
+
alt: t,
|
|
9
|
+
name: n,
|
|
10
|
+
size: v = "md",
|
|
11
|
+
square: d,
|
|
12
12
|
color: r,
|
|
13
|
-
|
|
13
|
+
badge: a,
|
|
14
|
+
badgePosition: m = "bottom-right",
|
|
15
|
+
className: c,
|
|
14
16
|
style: l,
|
|
15
|
-
testId:
|
|
16
|
-
"data-testid":
|
|
17
|
-
}) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
testId: s,
|
|
18
|
+
"data-testid": o
|
|
19
|
+
}) => {
|
|
20
|
+
const u = /* @__PURE__ */ e(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
className: `nice-avatar nice-avatar--${v} ${d ? "nice-avatar--square" : ""} ${a == null && c || ""}`,
|
|
24
|
+
style: a == null ? { ...l, ...r ? { background: r } : {} } : r ? { background: r } : void 0,
|
|
25
|
+
"aria-label": t || n,
|
|
26
|
+
"data-testid": a == null ? o ?? s : void 0,
|
|
27
|
+
children: i ? /* @__PURE__ */ e("img", { src: i, alt: t || n || "" }) : n ? _(n) : /* @__PURE__ */ e(f, { name: "user", size: "md", className: "nice-avatar__fallback-icon" })
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
return a == null ? u : /* @__PURE__ */ p(
|
|
31
|
+
"span",
|
|
32
|
+
{
|
|
33
|
+
className: `nice-avatar-wrap ${c || ""}`,
|
|
34
|
+
style: l,
|
|
35
|
+
"data-testid": o ?? s,
|
|
36
|
+
children: [
|
|
37
|
+
u,
|
|
38
|
+
/* @__PURE__ */ e("span", { className: `nice-avatar__badge nice-avatar__badge--${m}`, children: a })
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
};
|
|
27
43
|
export {
|
|
28
|
-
|
|
44
|
+
h as NiceAvatar
|
|
29
45
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsxs as v, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { useNiceAccessMode as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { createPortal as
|
|
5
|
-
import { scopeThemeClass as
|
|
6
|
-
import { NiceCalendar as
|
|
7
|
-
import { getDefaultLocale as
|
|
8
|
-
function
|
|
2
|
+
import { useNiceAccessMode as He, useControlId as Ke, useNiceTranslation as Oe, useControllableState as he, COMMON_SHORTCUTS as je, NiceThemeContext as Ye, useOverlayFocus as Fe, NiceKeyboardHint as Ge, NiceIcon as ye } from "@nice2dev/ui-core";
|
|
3
|
+
import { useMemo as ve, useRef as _e, useState as X, useContext as Ue, useLayoutEffect as Je, useEffect as Qe } from "react";
|
|
4
|
+
import { createPortal as Xe } from "react-dom";
|
|
5
|
+
import { scopeThemeClass as Ze } from "../../utility/scopeThemeClass.mjs";
|
|
6
|
+
import { NiceCalendar as Pe } from "./NiceCalendar.mjs";
|
|
7
|
+
import { getDefaultLocale as We, NiceDateTimePicker as Ne } from "./NiceDateTimePicker.mjs";
|
|
8
|
+
function P(t) {
|
|
9
9
|
return t?.startsWith("datetime") ? "datetime" : t === "week" ? "week" : t?.startsWith("month") ? "month" : "date";
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
const c = /* @__PURE__ */ new Date(), r = `${c.getFullYear()}-${String(c.getMonth() + 1).padStart(2, "0")}-${String(c.getDate()).padStart(2, "0")}`, l =
|
|
11
|
+
function et(t) {
|
|
12
|
+
const c = /* @__PURE__ */ new Date(), r = `${c.getFullYear()}-${String(c.getMonth() + 1).padStart(2, "0")}-${String(c.getDate()).padStart(2, "0")}`, l = P(t);
|
|
13
13
|
return l === "datetime" ? `${r}T00:00` : l === "month" ? r.slice(0, 7) : r;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function be(t, c) {
|
|
16
16
|
if (!t)
|
|
17
17
|
return t;
|
|
18
18
|
const r = new Date(t.length <= 10 ? `${t}T00:00` : t);
|
|
@@ -25,13 +25,13 @@ function Ne(t, c) {
|
|
|
25
25
|
function V(...t) {
|
|
26
26
|
return t.filter(Boolean).sort().pop();
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function Z(t, c, r) {
|
|
29
29
|
if (!t)
|
|
30
30
|
return "";
|
|
31
31
|
const l = new Date(t.length <= 10 ? `${t}T00:00` : t);
|
|
32
32
|
if (Number.isNaN(l.getTime()))
|
|
33
33
|
return t;
|
|
34
|
-
const x =
|
|
34
|
+
const x = P(r);
|
|
35
35
|
return x === "month" ? l.toLocaleDateString(c, { year: "numeric", month: "2-digit" }) : x === "datetime" ? l.toLocaleString(c, {
|
|
36
36
|
year: "numeric",
|
|
37
37
|
month: "2-digit",
|
|
@@ -40,7 +40,7 @@ function X(t, c, r) {
|
|
|
40
40
|
minute: "2-digit"
|
|
41
41
|
}) : l.toLocaleDateString(c, { year: "numeric", month: "2-digit", day: "2-digit" });
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function we(t) {
|
|
44
44
|
let c = 0;
|
|
45
45
|
for (const r of t)
|
|
46
46
|
c += /[\p{L}\p{N}]/u.test(r) ? 1 : 0.5;
|
|
@@ -52,67 +52,67 @@ const st = ({
|
|
|
52
52
|
defaultStartDate: r,
|
|
53
53
|
defaultEndDate: l,
|
|
54
54
|
onStartChange: x,
|
|
55
|
-
onEndChange:
|
|
56
|
-
min:
|
|
55
|
+
onEndChange: $e,
|
|
56
|
+
min: g,
|
|
57
57
|
max: q,
|
|
58
58
|
clearable: S,
|
|
59
|
-
startPlaceholder:
|
|
60
|
-
endPlaceholder:
|
|
61
|
-
startLabel:
|
|
62
|
-
endLabel:
|
|
63
|
-
layout:
|
|
59
|
+
startPlaceholder: W,
|
|
60
|
+
endPlaceholder: De,
|
|
61
|
+
startLabel: xe,
|
|
62
|
+
endLabel: Se,
|
|
63
|
+
layout: ee = "horizontal",
|
|
64
64
|
separator: h = "–",
|
|
65
|
-
gap:
|
|
65
|
+
gap: Ce = 12,
|
|
66
66
|
fullWidth: C = !1,
|
|
67
|
-
dateFormatPreset:
|
|
67
|
+
dateFormatPreset: m,
|
|
68
68
|
locale: A,
|
|
69
|
-
timeSelectorType:
|
|
69
|
+
timeSelectorType: te,
|
|
70
70
|
endCondition: _ = "greater-or-equal",
|
|
71
71
|
startCondition: N = "today-or-greater",
|
|
72
|
-
singleField:
|
|
72
|
+
singleField: ne = !1,
|
|
73
73
|
label: H,
|
|
74
74
|
error: K,
|
|
75
|
-
helperText:
|
|
76
|
-
required:
|
|
75
|
+
helperText: T,
|
|
76
|
+
required: Te,
|
|
77
77
|
disabled: ke,
|
|
78
78
|
size: b = "md",
|
|
79
|
-
id:
|
|
80
|
-
className:
|
|
81
|
-
style:
|
|
82
|
-
accessMode:
|
|
83
|
-
showKeyboardHints:
|
|
84
|
-
labelPlacement:
|
|
79
|
+
id: ae,
|
|
80
|
+
className: Ee,
|
|
81
|
+
style: Le,
|
|
82
|
+
accessMode: Re,
|
|
83
|
+
showKeyboardHints: Me,
|
|
84
|
+
labelPlacement: k,
|
|
85
85
|
errorPlacement: E,
|
|
86
86
|
labelWidth: y,
|
|
87
87
|
controlWidth: L,
|
|
88
88
|
loading: R,
|
|
89
89
|
readOnly: f
|
|
90
90
|
}) => {
|
|
91
|
-
const O =
|
|
91
|
+
const O = He(Re, ae), j = Ke(ae), { t: o } = Oe(), d = O === "disabled" || O === "readOnly" || !!ke, [a, Y] = he({
|
|
92
92
|
value: t,
|
|
93
93
|
defaultValue: r,
|
|
94
94
|
fallbackValue: "",
|
|
95
95
|
onChange: x,
|
|
96
96
|
componentName: "NiceDateRangeBox"
|
|
97
|
-
}), [s, M] =
|
|
97
|
+
}), [s, M] = he({
|
|
98
98
|
value: c,
|
|
99
99
|
defaultValue: l,
|
|
100
100
|
fallbackValue: "",
|
|
101
|
-
onChange:
|
|
101
|
+
onChange: $e,
|
|
102
102
|
componentName: "NiceDateRangeBox"
|
|
103
|
-
}),
|
|
103
|
+
}), Ie = ve(
|
|
104
104
|
() => [
|
|
105
105
|
{ key: "Tab", description: o("shortcuts.switchField", "Switch between start/end") },
|
|
106
|
-
|
|
106
|
+
je.cancel
|
|
107
107
|
],
|
|
108
108
|
[o]
|
|
109
|
-
), w =
|
|
110
|
-
|
|
109
|
+
), w = _e(null), F = _e(null), [u, I] = X(!1), [G, re] = X(null), [ie, Be] = X(""), U = Ue(Ye), oe = U?.portalTarget ?? (typeof document < "u" ? document.body : null);
|
|
110
|
+
Je(() => {
|
|
111
111
|
if (!u)
|
|
112
112
|
return;
|
|
113
113
|
const e = w.current?.getBoundingClientRect();
|
|
114
|
-
e && (
|
|
115
|
-
}, [u]),
|
|
114
|
+
e && (re({ left: e.left, top: e.bottom + 6 }), Be(U?.portalTarget ? "" : Ze(w.current)));
|
|
115
|
+
}, [u, U?.portalTarget]), Qe(() => {
|
|
116
116
|
if (!u)
|
|
117
117
|
return;
|
|
118
118
|
const e = (D) => {
|
|
@@ -120,18 +120,18 @@ const st = ({
|
|
|
120
120
|
w.current?.contains(me) || F.current?.contains(me) || I(!1);
|
|
121
121
|
}, i = () => {
|
|
122
122
|
const D = w.current?.getBoundingClientRect();
|
|
123
|
-
D &&
|
|
123
|
+
D && re({ left: D.left, top: D.bottom + 6 });
|
|
124
124
|
};
|
|
125
125
|
return document.addEventListener("mousedown", e), window.addEventListener("scroll", i, !0), window.addEventListener("resize", i), () => {
|
|
126
126
|
document.removeEventListener("mousedown", e), window.removeEventListener("scroll", i, !0), window.removeEventListener("resize", i);
|
|
127
127
|
};
|
|
128
|
-
}, [u]),
|
|
128
|
+
}, [u]), Fe(F, {
|
|
129
129
|
open: u,
|
|
130
130
|
modal: !1,
|
|
131
131
|
initialFocus: '.nice-calendar__grid [tabindex="0"]',
|
|
132
132
|
onClose: () => I(!1)
|
|
133
133
|
});
|
|
134
|
-
const $ =
|
|
134
|
+
const $ = et(m), ce = N === "today-or-greater" ? V(g, $) : N === "greater-than-today" ? V(g, be($, 1)) : g, ze = _ === "greater-or-equal" ? V(g, a) : _ === "greater" ? V(g, a ? be(a, 1) : void 0) : g, p = ve(() => {
|
|
135
135
|
if (K)
|
|
136
136
|
return K;
|
|
137
137
|
if (a && s) {
|
|
@@ -149,24 +149,24 @@ const st = ({
|
|
|
149
149
|
}, [K, a, s, N, _, $, o]);
|
|
150
150
|
if (O === "hidden")
|
|
151
151
|
return null;
|
|
152
|
-
const
|
|
152
|
+
const Ve = (e) => {
|
|
153
153
|
Y(e), e && s && e > s && M(e);
|
|
154
|
-
}, B =
|
|
155
|
-
const e =
|
|
156
|
-
return `${(Math.max(
|
|
157
|
-
})(),
|
|
158
|
-
Y(e ?
|
|
159
|
-
},
|
|
154
|
+
}, B = ee === "horizontal", se = P(m), J = A || We(), le = typeof h == "string" && h !== "" ? h : "–", de = Z(a, J, m), ue = Z(s, J, m), pe = de || ue ? `${de || "…"} ${le} ${ue || "…"}` : "", qe = (() => {
|
|
155
|
+
const e = Z("2026-12-30T22:58", J, m), i = `${e} ${le} ${e}`;
|
|
156
|
+
return `${(Math.max(we(i), we(pe)) + 1.5).toFixed(1)}ch`;
|
|
157
|
+
})(), fe = (e, i) => se === "datetime" ? i && i.length > 10 ? `${e}${i.slice(10)}` : `${e}T00:00` : se === "month" ? e.slice(0, 7) : e, Ae = ({ start: e, end: i }) => {
|
|
158
|
+
Y(e ? fe(e, a) : ""), M(i ? fe(i, s) : ""), e && i && I(!1);
|
|
159
|
+
}, ge = () => {
|
|
160
160
|
Y(""), M("");
|
|
161
|
-
},
|
|
161
|
+
}, Q = () => {
|
|
162
162
|
!d && !f && I((e) => !e);
|
|
163
163
|
}, z = (e) => e && e.length >= 10 ? e.slice(0, 10) : e || void 0;
|
|
164
164
|
return /* @__PURE__ */ v(
|
|
165
165
|
"div",
|
|
166
166
|
{
|
|
167
|
-
className: `nice-field nice-field--${b} nice-daterange nice-daterange--${
|
|
167
|
+
className: `nice-field nice-field--${b} nice-daterange nice-daterange--${ee} ${k === "left" ? "nice-field--label-left" : ""} ${p ? "nice-field--error" : ""} ${R ? "nice-field--loading" : ""} ${Ee || ""}`,
|
|
168
168
|
style: {
|
|
169
|
-
...
|
|
169
|
+
...Le,
|
|
170
170
|
...y != null && {
|
|
171
171
|
"--nice-field-label-width": typeof y == "number" ? `${y}px` : y
|
|
172
172
|
},
|
|
@@ -178,11 +178,11 @@ const st = ({
|
|
|
178
178
|
children: [
|
|
179
179
|
H && /* @__PURE__ */ v("label", { className: "nice-field__label", htmlFor: j, children: [
|
|
180
180
|
H,
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
Te && /* @__PURE__ */ n("span", { className: "nice-field__required", children: "*" }),
|
|
182
|
+
Me && /* @__PURE__ */ n(Ge, { shortcuts: Ie, size: "sm" })
|
|
183
183
|
] }),
|
|
184
184
|
/* @__PURE__ */ v("div", { className: "nice-field__control", children: [
|
|
185
|
-
|
|
185
|
+
ne ? /* @__PURE__ */ v(
|
|
186
186
|
"div",
|
|
187
187
|
{
|
|
188
188
|
ref: w,
|
|
@@ -196,21 +196,21 @@ const st = ({
|
|
|
196
196
|
className: "nice-input__native",
|
|
197
197
|
type: "text",
|
|
198
198
|
readOnly: !0,
|
|
199
|
-
value:
|
|
200
|
-
placeholder:
|
|
199
|
+
value: pe,
|
|
200
|
+
placeholder: W || o("controls.startDate", "Start date"),
|
|
201
201
|
disabled: d || R,
|
|
202
202
|
autoComplete: "off",
|
|
203
203
|
"aria-invalid": !!p,
|
|
204
204
|
"aria-label": H ? void 0 : o("controls.startDate", "Start date"),
|
|
205
205
|
"aria-haspopup": "dialog",
|
|
206
206
|
"aria-expanded": u,
|
|
207
|
-
onClick:
|
|
207
|
+
onClick: Q,
|
|
208
208
|
onKeyDown: (e) => {
|
|
209
209
|
const i = !!e.nativeEvent.niceSource;
|
|
210
|
-
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown" && !i) && (e.preventDefault(), u ||
|
|
210
|
+
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown" && !i) && (e.preventDefault(), u || Q());
|
|
211
211
|
},
|
|
212
212
|
style: {
|
|
213
|
-
width: C ? "100%" :
|
|
213
|
+
width: C ? "100%" : qe,
|
|
214
214
|
cursor: d || f ? void 0 : "pointer"
|
|
215
215
|
}
|
|
216
216
|
}
|
|
@@ -220,11 +220,11 @@ const st = ({
|
|
|
220
220
|
{
|
|
221
221
|
type: "button",
|
|
222
222
|
className: "nice-input__clear",
|
|
223
|
-
onClick:
|
|
223
|
+
onClick: ge,
|
|
224
224
|
disabled: !a && !s || d || f,
|
|
225
225
|
"aria-label": o("controls.clear", "Clear"),
|
|
226
226
|
tabIndex: (a || s) && !d && !f ? 0 : -1,
|
|
227
|
-
children: /* @__PURE__ */ n(
|
|
227
|
+
children: /* @__PURE__ */ n(ye, { name: "close", size: 14 })
|
|
228
228
|
}
|
|
229
229
|
),
|
|
230
230
|
/* @__PURE__ */ n(
|
|
@@ -232,12 +232,12 @@ const st = ({
|
|
|
232
232
|
{
|
|
233
233
|
type: "button",
|
|
234
234
|
className: "nice-input__picker-trigger",
|
|
235
|
-
onClick:
|
|
235
|
+
onClick: Q,
|
|
236
236
|
"aria-label": o("controls.openPicker", "Open picker"),
|
|
237
237
|
"aria-expanded": u,
|
|
238
238
|
tabIndex: -1,
|
|
239
239
|
disabled: d || f,
|
|
240
|
-
children: /* @__PURE__ */ n(
|
|
240
|
+
children: /* @__PURE__ */ n(ye, { name: "calendar", size: 16 })
|
|
241
241
|
}
|
|
242
242
|
)
|
|
243
243
|
]
|
|
@@ -252,31 +252,31 @@ const st = ({
|
|
|
252
252
|
// With inline labels (labelPlacement="left") the fields align on
|
|
253
253
|
// their center; otherwise bottom-align so the separator sits on the
|
|
254
254
|
// input baseline.
|
|
255
|
-
alignItems: B ?
|
|
256
|
-
gap:
|
|
255
|
+
alignItems: B ? k === "left" ? "center" : "flex-end" : "stretch",
|
|
256
|
+
gap: Ce,
|
|
257
257
|
// Horizontal means one line — don't wrap (wrapping made `layout`
|
|
258
258
|
// look dead inside a width-capped container).
|
|
259
259
|
flexWrap: B ? "nowrap" : "wrap"
|
|
260
260
|
},
|
|
261
261
|
children: [
|
|
262
262
|
/* @__PURE__ */ n("div", { style: { flex: C ? "1 1 0" : void 0, minWidth: 0 }, children: /* @__PURE__ */ n(
|
|
263
|
-
|
|
263
|
+
Ne,
|
|
264
264
|
{
|
|
265
265
|
id: j,
|
|
266
|
-
dateFormatPreset:
|
|
266
|
+
dateFormatPreset: m,
|
|
267
267
|
displayLocale: A,
|
|
268
|
-
timeSelectorType:
|
|
269
|
-
label:
|
|
268
|
+
timeSelectorType: te,
|
|
269
|
+
label: xe,
|
|
270
270
|
value: a,
|
|
271
|
-
onChange:
|
|
272
|
-
min:
|
|
271
|
+
onChange: Ve,
|
|
272
|
+
min: ce,
|
|
273
273
|
max: s || q,
|
|
274
|
-
placeholder:
|
|
274
|
+
placeholder: W || o("controls.startDate", "Start date"),
|
|
275
275
|
disabled: d,
|
|
276
276
|
readOnly: f,
|
|
277
277
|
size: b,
|
|
278
278
|
clearable: S,
|
|
279
|
-
labelPlacement:
|
|
279
|
+
labelPlacement: k,
|
|
280
280
|
labelWidth: y
|
|
281
281
|
}
|
|
282
282
|
) }),
|
|
@@ -290,34 +290,34 @@ const st = ({
|
|
|
290
290
|
}
|
|
291
291
|
),
|
|
292
292
|
/* @__PURE__ */ n("div", { style: { flex: C ? "1 1 0" : void 0, minWidth: 0 }, children: /* @__PURE__ */ n(
|
|
293
|
-
|
|
293
|
+
Ne,
|
|
294
294
|
{
|
|
295
|
-
dateFormatPreset:
|
|
295
|
+
dateFormatPreset: m,
|
|
296
296
|
displayLocale: A,
|
|
297
|
-
timeSelectorType:
|
|
298
|
-
label:
|
|
297
|
+
timeSelectorType: te,
|
|
298
|
+
label: Se,
|
|
299
299
|
value: s,
|
|
300
300
|
onChange: (e) => M(e),
|
|
301
|
-
min:
|
|
301
|
+
min: ze || a || g,
|
|
302
302
|
max: q,
|
|
303
|
-
placeholder:
|
|
303
|
+
placeholder: De || o("controls.endDate", "End date"),
|
|
304
304
|
disabled: d,
|
|
305
305
|
readOnly: f,
|
|
306
306
|
size: b,
|
|
307
307
|
clearable: S,
|
|
308
|
-
labelPlacement:
|
|
308
|
+
labelPlacement: k,
|
|
309
309
|
labelWidth: y
|
|
310
310
|
}
|
|
311
311
|
) })
|
|
312
312
|
]
|
|
313
313
|
}
|
|
314
314
|
),
|
|
315
|
-
|
|
315
|
+
ne && u && G && oe && Xe(
|
|
316
316
|
/* @__PURE__ */ v(
|
|
317
317
|
"div",
|
|
318
318
|
{
|
|
319
319
|
ref: F,
|
|
320
|
-
className: `nice-datetime-popup${
|
|
320
|
+
className: `nice-datetime-popup${ie ? ` ${ie}` : ""}`,
|
|
321
321
|
style: {
|
|
322
322
|
position: "fixed",
|
|
323
323
|
left: G.left,
|
|
@@ -328,13 +328,13 @@ const st = ({
|
|
|
328
328
|
"aria-label": o("controls.openPicker", "Open picker"),
|
|
329
329
|
children: [
|
|
330
330
|
/* @__PURE__ */ n("div", { className: "nice-datetime-popup__body", children: /* @__PURE__ */ n("div", { className: "nice-datetime-popup__col nice-datetime-popup__col--date", children: /* @__PURE__ */ n(
|
|
331
|
-
|
|
331
|
+
Pe,
|
|
332
332
|
{
|
|
333
333
|
selectionMode: "range",
|
|
334
334
|
rangeStart: z(a),
|
|
335
335
|
rangeEnd: z(s),
|
|
336
|
-
onRangeChange:
|
|
337
|
-
min: z(
|
|
336
|
+
onRangeChange: Ae,
|
|
337
|
+
min: z(ce),
|
|
338
338
|
max: z(q),
|
|
339
339
|
size: b
|
|
340
340
|
}
|
|
@@ -344,7 +344,7 @@ const st = ({
|
|
|
344
344
|
{
|
|
345
345
|
type: "button",
|
|
346
346
|
className: "nice-datetime-popup__btn",
|
|
347
|
-
onClick:
|
|
347
|
+
onClick: ge,
|
|
348
348
|
disabled: !a && !s,
|
|
349
349
|
children: o("controls.clear", "Clear")
|
|
350
350
|
}
|
|
@@ -352,14 +352,14 @@ const st = ({
|
|
|
352
352
|
]
|
|
353
353
|
}
|
|
354
354
|
),
|
|
355
|
-
|
|
355
|
+
oe
|
|
356
356
|
),
|
|
357
357
|
R && /* @__PURE__ */ n("span", { className: "nice-field__spinner", children: /* @__PURE__ */ n("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
358
358
|
E === "right" && p && /* @__PURE__ */ n("div", { className: "nice-field__error", role: "alert", children: p }),
|
|
359
|
-
E === "right" && !p &&
|
|
359
|
+
E === "right" && !p && T && /* @__PURE__ */ n("div", { className: "nice-field__helper", children: T })
|
|
360
360
|
] }),
|
|
361
361
|
E !== "right" && p && /* @__PURE__ */ n("div", { className: "nice-field__error", children: p }),
|
|
362
|
-
E !== "right" && !p &&
|
|
362
|
+
E !== "right" && !p && T && /* @__PURE__ */ n("div", { className: "nice-field__hint", children: T })
|
|
363
363
|
]
|
|
364
364
|
}
|
|
365
365
|
);
|