@nice2dev/ui 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +253 -207
- package/dist/NiceButton-B5RXLDwI.cjs +1 -0
- package/dist/NiceButton-DmTHNHet.js +450 -0
- package/dist/NiceErrorBoundary-D1hh5GGe.js +732 -0
- package/dist/NiceErrorBoundary-Dta4TGee.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-BapdidD6.js +4776 -0
- package/dist/NiceModuleLifecyclePanel-CsFsm534.cjs +1 -0
- package/dist/NicePinCodeInput-4q8yULuo.js +13359 -0
- package/dist/NicePinCodeInput-eD2q8nGa.cjs +692 -0
- package/dist/NicePinCodeInput.css +1 -0
- package/dist/NiceSavedQueryPanel-DUw8plYP.js +5666 -0
- package/dist/NiceSavedQueryPanel-xpk09zy1.cjs +596 -0
- package/dist/NiceSavedQueryPanel.css +1 -0
- package/dist/NiceStockChart-CHlOnWzN.cjs +287 -0
- package/dist/NiceStockChart-Cpmv9_Cc.js +2341 -0
- package/dist/NiceStockChart.css +1 -0
- package/dist/NiceToggle-C1UKGXmJ.js +209 -0
- package/dist/NiceToggle-lVi-ETi0.cjs +1 -0
- package/dist/NiceWindow-D1awkyFl.js +1636 -0
- package/dist/NiceWindow-yARTUJsg.cjs +1 -0
- package/dist/charts.cjs +1 -0
- package/dist/charts.d.ts +1043 -0
- package/dist/charts.mjs +23 -0
- package/dist/core-CfXsl755.js +16305 -0
- package/dist/core-DGJSUW64.cjs +96 -0
- package/dist/data.cjs +1 -0
- package/dist/data.d.ts +2003 -0
- package/dist/data.mjs +21 -0
- package/dist/editors.cjs +1 -0
- package/dist/editors.d.ts +2728 -0
- package/dist/editors.mjs +66 -0
- package/dist/feedback.cjs +1 -0
- package/dist/feedback.d.ts +339 -0
- package/dist/feedback.mjs +16 -0
- package/dist/index-C853adw1.cjs +6199 -0
- package/dist/index-CNwVELPJ.js +62857 -0
- package/dist/index-CUx_-gKK.cjs +1 -0
- package/dist/index-x8mRM4Jc.js +17 -0
- package/dist/index.cjs +1 -7866
- package/dist/index.css +1 -0
- package/dist/index.d.ts +1160 -2
- package/dist/index.mjs +972 -105889
- package/dist/navigation.cjs +1 -0
- package/dist/navigation.d.ts +1862 -0
- package/dist/navigation.mjs +519 -0
- package/dist/overlays.cjs +1 -0
- package/dist/overlays.d.ts +706 -0
- package/dist/overlays.mjs +26 -0
- package/package.json +31 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),i=require("react"),n=require("./core-DGJSUW64.cjs"),re=i.forwardRef(({label:j,helperText:v,error:t,required:T,disabled:r,readOnly:o,size:q="md",name:w,id:g,className:R,style:y,accessMode:h,displayStyle:k,value:_,defaultValue:m,onChange:$,onBlur:d,onKeyDown:x,placeholder:M,type:D="text",maxLength:A,prefix:I,suffix:B,clearable:l,autoFocus:G,submitOnEnter:S,onSubmit:E,showKeyboardHints:J,...z},Z)=>{const H=n.useNiceAccessMode(h,g);if(H==="hidden")return null;H==="disabled"&&(r=!0),H==="readOnly"&&(o=!0);const{t:O}=n.useNiceTranslation(),u=n.useControlId(g),ee=n.useComponentDisplayStyle("input",k),se=n.useComponentDisplayClass("input",k),Q=i.useCallback(()=>$?.(""),[$]),C=n.useSubmitOnEnter({enabled:S,onSubmit:E}),F=i.useCallback(p=>{C(p),x?.(p)},[C,x]),L=i.useMemo(()=>{const p=[];return S&&p.push({key:"Enter",description:O("shortcuts.submit","Submit")}),l&&p.push({key:"Escape",description:O("shortcuts.clear","Clear")}),p},[S,l,O]);return e.jsxs("div",{className:`nice-field ${R||""}`,style:y,children:[j&&e.jsxs("label",{htmlFor:u,className:`nice-field__label ${T?"nice-field__label--required":""}`,children:[j,J&&L.length>0&&e.jsx(n.NiceKeyboardHint,{shortcuts:L,size:"sm"})]}),e.jsxs("div",{className:`nice-input nice-input--${q} nice-input--ds-${se} ${t?"nice-input--error":""} ${r?"nice-input--disabled":""} ${o?"nice-input--readonly":""}`,style:ee,children:[I&&e.jsx("span",{className:"nice-input__icon",children:I}),e.jsx("input",{ref:Z,id:u,className:"nice-input__native",type:D,name:w,value:_,defaultValue:m,placeholder:M,disabled:r,readOnly:o,maxLength:A,autoFocus:G,"aria-invalid":!!t,"aria-describedby":t?`${u}-error`:v?`${u}-helper`:void 0,onChange:p=>$?.(p.target.value),onBlur:d,onKeyDown:F,...z}),l&&_&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:Q,"aria-label":O("controls.clear","Clear"),children:"✕"}),B&&e.jsx("span",{className:"nice-input__icon",children:B})]}),t&&e.jsx("div",{id:`${u}-error`,className:"nice-field__error",role:"alert",children:t}),!t&&v&&e.jsx("div",{id:`${u}-helper`,className:"nice-field__helper",children:v})]})});re.displayName="NiceTextInput";const ae=i.forwardRef(({label:j,helperText:v,error:t,required:T,disabled:r,size:o="md",name:q,id:w,className:g,style:R,accessMode:y,displayStyle:h,options:k,value:_,onChange:m,placeholder:$,multiple:d=!1,searchable:x=!1,clearable:M=!1,emptyText:D,maxHeight:A=240,optionsSource:I,valueField:B,labelField:l,virtualScroll:G,optionHeight:S=36,onSearch:E,loading:J,renderOption:z,showKeyboardHints:Z},H)=>{const O=n.useNiceAccessMode(y,w);if(O==="hidden")return null;(O==="disabled"||O==="readOnly")&&(r=!0);const{t:u}=n.useNiceTranslation(),ee=n.useComponentDisplayStyle("input",h),se=n.useComponentDisplayClass("input",h),Q=n.useControlId(w),[C,F]=i.useState(!1),[L,p]=i.useState(""),[K,W]=i.useState(-1),[ie,ue]=i.useState(0),ce=i.useRef(null),pe=n.useNiceLookupSource(I??null,B??I?.keyField??"id",l??"name"),P=I?pe.options:k??[];n.useClickOutside(ce,()=>{F(!1),p("")});const f=i.useMemo(()=>_?Array.isArray(_)?_:[_]:[],[_]),N=i.useMemo(()=>{if(!L&&!E||E)return P;const s=L.toLowerCase();return P.filter(a=>a.label.toLowerCase().includes(s)||String(a.value).toLowerCase().includes(s))},[P,L,E]),le=i.useMemo(()=>{const s=new Map;for(const a of N){const c=a.group||"";s.has(c)||s.set(c,[]),s.get(c).push(a)}return s},[N]),V=i.useCallback(s=>{if(d){const a=f.includes(s)?f.filter(c=>c!==s):[...f,s];m?.(a)}else m?.(s),F(!1),p("")},[d,f,m]),he=i.useCallback(s=>{if(s.key==="Escape"){F(!1),p("");return}if(s.key==="Enter"||s.key===" "){if(!C){F(!0),s.preventDefault();return}K>=0&&N[K]&&(V(N[K].value),s.preventDefault());return}s.key==="ArrowDown"&&(s.preventDefault(),W(a=>Math.min(a+1,N.length-1))),s.key==="ArrowUp"&&(s.preventDefault(),W(a=>Math.max(a-1,0)))},[C,K,N,V]),te=i.useMemo(()=>f.length===0?null:d?f.map(s=>P.find(a=>a.value===s)?.label||s).join(", "):P.find(s=>s.value===f[0])?.label||f[0],[f,P,d]),_e=i.useCallback(s=>{s.stopPropagation(),m?.(d?[]:"")},[m,d]),me=i.useMemo(()=>[{key:"Enter",description:u("shortcuts.select","Select")},{key:"Space",description:u("shortcuts.openDropdown","Open dropdown")},n.COMMON_SHORTCUTS.moveUp,n.COMMON_SHORTCUTS.moveDown,n.COMMON_SHORTCUTS.cancel],[u]);return e.jsxs("div",{className:`nice-field ${g||""}`,style:R,children:[j&&e.jsxs("label",{htmlFor:Q,className:`nice-field__label ${T?"nice-field__label--required":""}`,children:[j,Z&&e.jsx(n.NiceKeyboardHint,{shortcuts:me,size:"sm"})]}),e.jsxs("div",{className:"nice-select",ref:ce,children:[e.jsxs("button",{ref:H,type:"button",id:Q,role:"combobox","aria-expanded":C,"aria-haspopup":"listbox","aria-invalid":!!t,className:`nice-select__trigger nice-select__trigger--${o} nice-select--ds-${se} ${C?"nice-select__trigger--open":""} ${t?"nice-select__trigger--error":""} ${r?"nice-select__trigger--disabled":""}`,style:ee,disabled:r,onClick:()=>F(!C),onKeyDown:he,children:[te?e.jsx("span",{children:te}):e.jsx("span",{className:"nice-select__placeholder",children:$||u("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[M&&f.length>0&&e.jsx("span",{className:"nice-input__clear",onClick:_e,role:"button","aria-label":u("controls.clear","Clear"),children:"✕"}),e.jsx("svg",{className:`nice-select__chevron ${C?"nice-select__chevron--open":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),C&&e.jsxs("div",{className:"nice-select__dropdown",role:"listbox",style:{maxHeight:A},onScroll:G?s=>ue(s.currentTarget.scrollTop):void 0,children:[(x||E)&&e.jsx("div",{className:"nice-select__search",children:e.jsx("input",{type:"text",value:L,onChange:s=>{p(s.target.value),W(0),E?.(s.target.value)},placeholder:u("controls.search","Search..."),autoFocus:!0})}),J&&e.jsx("div",{className:"nice-select__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm",style:{margin:"8px auto"}})}),!J&&N.length===0?e.jsx("div",{className:"nice-select__empty",children:D||u("controls.noResults","No results found")}):G&&!Array.from(le.keys()).some(s=>s!=="")?(()=>{const a=N.length*S,c=Math.max(0,Math.floor(ie/S)-3),U=Math.min(N.length,Math.ceil((ie+A)/S)+3),X=N.slice(c,U);return e.jsx("div",{style:{height:a,position:"relative"},children:X.map((b,xe)=>{const ne=c+xe,Y=f.includes(b.value);return e.jsx("div",{role:"option","aria-selected":Y,className:`nice-select__option ${Y?"nice-select__option--selected":""} ${ne===K?"nice-select__option--highlighted":""} ${b.disabled?"nice-select__option--disabled":""}`,style:{position:"absolute",top:ne*S,left:0,right:0,height:S,display:"flex",alignItems:"center",padding:"0 12px"},onClick:()=>!b.disabled&&V(String(b.value)),onMouseEnter:()=>W(ne),children:z?z(b,Y):e.jsxs(e.Fragment,{children:[b.icon&&e.jsx("span",{children:b.icon}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{children:b.label}),b.description&&e.jsx("div",{className:"nice-select__option-desc",children:b.description})]}),Y&&e.jsx("svg",{className:"nice-select__option-check",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})]})},b.value)})})})():Array.from(le.entries()).map(([s,a])=>e.jsxs(i.Fragment,{children:[s&&e.jsx("div",{className:"nice-select__group-label",children:s}),a.map(c=>{const U=f.includes(c.value),X=N.indexOf(c);return e.jsx("div",{role:"option","aria-selected":U,className:`nice-select__option ${U?"nice-select__option--selected":""} ${X===K?"nice-select__option--highlighted":""} ${c.disabled?"nice-select__option--disabled":""}`,onClick:()=>!c.disabled&&V(String(c.value)),onMouseEnter:()=>W(X),children:z?z(c,U):e.jsxs(e.Fragment,{children:[c.icon&&e.jsx("span",{children:c.icon}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{children:c.label}),c.description&&e.jsx("div",{className:"nice-select__option-desc",children:c.description})]}),U&&e.jsx("svg",{className:"nice-select__option-check",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})]})},c.value)})]},s))]})]}),t&&e.jsx("div",{className:"nice-field__error",role:"alert",children:t}),!t&&v&&e.jsx("div",{className:"nice-field__helper",children:v})]})});ae.displayName="NiceSelect";const fe=["#ef4444","#f97316","#f59e0b","#84cc16","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#ec4899","#64748b","#1e293b"];function ve(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}const oe=i.forwardRef(({label:j,helperText:v,error:t,required:T,disabled:r,id:o,className:q,style:w,accessMode:g,displayStyle:R,value:y="#3b82f6",onChange:h,presets:k=fe,showInput:_=!0,showRandom:m=!0,showKeyboardHints:$},d)=>{const x=n.useNiceAccessMode(g,o);if(x==="hidden")return null;(x==="disabled"||x==="readOnly")&&(r=!0);const{t:M}=n.useNiceTranslation(),D=n.useControlId(o);n.useComponentDisplayClass("input",R);const A=i.useRef(null),I=i.useCallback(()=>{r||h?.(ve())},[r,h]),B=i.useMemo(()=>[{key:"Enter",description:M("shortcuts.openPicker","Open color picker")},{key:"Arrow keys",description:M("shortcuts.navigatePresets","Navigate presets")}],[M]);return e.jsxs("div",{className:`nice-field ${q||""}`,style:w,children:[j&&e.jsxs("label",{htmlFor:D,className:`nice-field__label ${T?"nice-field__label--required":""}`,children:[j,$&&e.jsx(n.NiceKeyboardHint,{shortcuts:B,size:"sm"})]}),e.jsxs("div",{className:"nice-color-picker",children:[e.jsxs("div",{className:"nice-color-picker__preview-row",children:[e.jsx("div",{className:"nice-color-picker__swatch",style:{background:y},onClick:()=>A.current?.click(),role:"button",tabIndex:0,"aria-label":"Pick color",children:e.jsx("input",{ref:l=>{A.current=l,typeof d=="function"?d(l):d&&(d.current=l)},type:"color",className:"nice-color-picker__native",id:D,value:y,disabled:r,onChange:l=>h?.(l.target.value)})}),_&&e.jsx("div",{className:"nice-input nice-input--sm",style:{width:100},children:e.jsx("input",{className:"nice-input__native",type:"text",value:y,disabled:r,onChange:l=>h?.(l.target.value),maxLength:7})}),m&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-color-picker__random",onClick:I,disabled:r,title:"Random color","aria-label":"Random color",children:"🎲"})]}),k.length>0&&e.jsx("div",{className:"nice-color-picker__presets",children:k.map(l=>e.jsx("div",{className:`nice-color-picker__preset ${y===l?"nice-color-picker__preset--active":""}`,style:{background:l},onClick:()=>h?.(l),role:"button",tabIndex:0,"aria-label":l},l))})]}),t&&e.jsx("div",{className:"nice-field__error",role:"alert",children:t}),!t&&v&&e.jsx("div",{className:"nice-field__helper",children:v})]})});oe.displayName="NiceColorPicker";const de=i.forwardRef(({children:j,variant:v="primary",size:t="md",type:T="button",disabled:r,loading:o,fullWidth:q,onClick:w,leftIcon:g,rightIcon:R,className:y,style:h,id:k,accessMode:_,displayStyle:m,...$},d)=>{const x=n.useNiceAccessMode(_,k);if(x==="hidden")return null;(x==="disabled"||x==="readOnly")&&(r=!0);const M=n.useComponentDisplayStyle("button",m),D=n.useComponentDisplayClass("button",m);return e.jsxs("button",{ref:d,type:T,id:k,className:`nice-btn nice-btn--${v} nice-btn--${t} nice-btn--ds-${D} ${q?"nice-btn--full-width":""} ${o?"nice-btn--loading":""} ${y||""}`,style:{...M,...h},disabled:r||o,"aria-busy":o||void 0,"aria-disabled":r||o||void 0,onClick:w,...$,children:[o&&e.jsx("svg",{className:"nice-btn__spinner",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3","aria-hidden":"true",children:e.jsx("circle",{cx:"12",cy:"12",r:"10",strokeDasharray:"31.4 31.4",strokeLinecap:"round"})}),!o&&g&&e.jsx("span",{"aria-hidden":"true",children:g}),e.jsx("span",{children:j}),!o&&R&&e.jsx("span",{"aria-hidden":"true",children:R})]})});de.displayName="NiceButton";exports.NiceButton=de;exports.NiceColorPicker=oe;exports.NiceSelect=ae;exports.NiceTextInput=re;
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import { jsxs as l, jsx as e, Fragment as ve } from "react/jsx-runtime";
|
|
2
|
+
import Ce, { forwardRef as ne, useCallback as W, useMemo as z, useState as ee, useRef as be } from "react";
|
|
3
|
+
import { a as ie, b as oe, u as de, c as ue, d as ce, e as we, N as pe, f as Se, g as Me, C as ae } from "./core-CfXsl755.js";
|
|
4
|
+
const Re = ne(({
|
|
5
|
+
label: y,
|
|
6
|
+
helperText: v,
|
|
7
|
+
error: t,
|
|
8
|
+
required: A,
|
|
9
|
+
disabled: s,
|
|
10
|
+
readOnly: a,
|
|
11
|
+
size: B = "md",
|
|
12
|
+
name: M,
|
|
13
|
+
id: x,
|
|
14
|
+
className: R,
|
|
15
|
+
style: k,
|
|
16
|
+
accessMode: p,
|
|
17
|
+
displayStyle: g,
|
|
18
|
+
value: h,
|
|
19
|
+
defaultValue: _,
|
|
20
|
+
onChange: C,
|
|
21
|
+
onBlur: o,
|
|
22
|
+
onKeyDown: m,
|
|
23
|
+
placeholder: w,
|
|
24
|
+
type: D = "text",
|
|
25
|
+
maxLength: F,
|
|
26
|
+
prefix: I,
|
|
27
|
+
suffix: q,
|
|
28
|
+
clearable: c,
|
|
29
|
+
autoFocus: J,
|
|
30
|
+
submitOnEnter: S,
|
|
31
|
+
onSubmit: L,
|
|
32
|
+
showKeyboardHints: Q,
|
|
33
|
+
...K
|
|
34
|
+
}, le) => {
|
|
35
|
+
const G = ie(p, x);
|
|
36
|
+
if (G === "hidden") return null;
|
|
37
|
+
G === "disabled" && (s = !0), G === "readOnly" && (a = !0);
|
|
38
|
+
const { t: E } = oe(), d = de(x), te = ue("input", g), se = ce("input", g), V = W(() => C?.(""), [C]), $ = we({
|
|
39
|
+
enabled: S,
|
|
40
|
+
onSubmit: L
|
|
41
|
+
}), O = W((u) => {
|
|
42
|
+
$(u), m?.(u);
|
|
43
|
+
}, [$, m]), P = z(() => {
|
|
44
|
+
const u = [];
|
|
45
|
+
return S && u.push({ key: "Enter", description: E("shortcuts.submit", "Submit") }), c && u.push({ key: "Escape", description: E("shortcuts.clear", "Clear") }), u;
|
|
46
|
+
}, [S, c, E]);
|
|
47
|
+
return /* @__PURE__ */ l("div", { className: `nice-field ${R || ""}`, style: k, children: [
|
|
48
|
+
y && /* @__PURE__ */ l("label", { htmlFor: d, className: `nice-field__label ${A ? "nice-field__label--required" : ""}`, children: [
|
|
49
|
+
y,
|
|
50
|
+
Q && P.length > 0 && /* @__PURE__ */ e(pe, { shortcuts: P, size: "sm" })
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ l("div", { className: `nice-input nice-input--${B} nice-input--ds-${se} ${t ? "nice-input--error" : ""} ${s ? "nice-input--disabled" : ""} ${a ? "nice-input--readonly" : ""}`, style: te, children: [
|
|
53
|
+
I && /* @__PURE__ */ e("span", { className: "nice-input__icon", children: I }),
|
|
54
|
+
/* @__PURE__ */ e(
|
|
55
|
+
"input",
|
|
56
|
+
{
|
|
57
|
+
ref: le,
|
|
58
|
+
id: d,
|
|
59
|
+
className: "nice-input__native",
|
|
60
|
+
type: D,
|
|
61
|
+
name: M,
|
|
62
|
+
value: h,
|
|
63
|
+
defaultValue: _,
|
|
64
|
+
placeholder: w,
|
|
65
|
+
disabled: s,
|
|
66
|
+
readOnly: a,
|
|
67
|
+
maxLength: F,
|
|
68
|
+
autoFocus: J,
|
|
69
|
+
"aria-invalid": !!t,
|
|
70
|
+
"aria-describedby": t ? `${d}-error` : v ? `${d}-helper` : void 0,
|
|
71
|
+
onChange: (u) => C?.(u.target.value),
|
|
72
|
+
onBlur: o,
|
|
73
|
+
onKeyDown: O,
|
|
74
|
+
...K
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
c && h && /* @__PURE__ */ e("button", { type: "button", className: "nice-input__clear", onClick: V, "aria-label": E("controls.clear", "Clear"), children: "✕" }),
|
|
78
|
+
q && /* @__PURE__ */ e("span", { className: "nice-input__icon", children: q })
|
|
79
|
+
] }),
|
|
80
|
+
t && /* @__PURE__ */ e("div", { id: `${d}-error`, className: "nice-field__error", role: "alert", children: t }),
|
|
81
|
+
!t && v && /* @__PURE__ */ e("div", { id: `${d}-helper`, className: "nice-field__helper", children: v })
|
|
82
|
+
] });
|
|
83
|
+
});
|
|
84
|
+
Re.displayName = "NiceTextInput";
|
|
85
|
+
const De = ne(({
|
|
86
|
+
label: y,
|
|
87
|
+
helperText: v,
|
|
88
|
+
error: t,
|
|
89
|
+
required: A,
|
|
90
|
+
disabled: s,
|
|
91
|
+
size: a = "md",
|
|
92
|
+
name: B,
|
|
93
|
+
id: M,
|
|
94
|
+
className: x,
|
|
95
|
+
style: R,
|
|
96
|
+
accessMode: k,
|
|
97
|
+
displayStyle: p,
|
|
98
|
+
options: g,
|
|
99
|
+
value: h,
|
|
100
|
+
onChange: _,
|
|
101
|
+
placeholder: C,
|
|
102
|
+
multiple: o = !1,
|
|
103
|
+
searchable: m = !1,
|
|
104
|
+
clearable: w = !1,
|
|
105
|
+
emptyText: D,
|
|
106
|
+
maxHeight: F = 240,
|
|
107
|
+
optionsSource: I,
|
|
108
|
+
valueField: q,
|
|
109
|
+
labelField: c,
|
|
110
|
+
virtualScroll: J,
|
|
111
|
+
optionHeight: S = 36,
|
|
112
|
+
onSearch: L,
|
|
113
|
+
loading: Q,
|
|
114
|
+
renderOption: K,
|
|
115
|
+
showKeyboardHints: le
|
|
116
|
+
}, G) => {
|
|
117
|
+
const E = ie(k, M);
|
|
118
|
+
if (E === "hidden") return null;
|
|
119
|
+
(E === "disabled" || E === "readOnly") && (s = !0);
|
|
120
|
+
const { t: d } = oe(), te = ue("input", p), se = ce("input", p), V = de(M), [$, O] = ee(!1), [P, u] = ee(""), [U, H] = ee(-1), [he, Ne] = ee(0), _e = be(null), ye = Se(
|
|
121
|
+
I ?? null,
|
|
122
|
+
q ?? I?.keyField ?? "id",
|
|
123
|
+
c ?? "name"
|
|
124
|
+
), T = I ? ye.options : g ?? [];
|
|
125
|
+
Me(_e, () => {
|
|
126
|
+
O(!1), u("");
|
|
127
|
+
});
|
|
128
|
+
const f = z(() => h ? Array.isArray(h) ? h : [h] : [], [h]), b = z(() => {
|
|
129
|
+
if (!P && !L || L) return T;
|
|
130
|
+
const n = P.toLowerCase();
|
|
131
|
+
return T.filter((r) => r.label.toLowerCase().includes(n) || String(r.value).toLowerCase().includes(n));
|
|
132
|
+
}, [T, P, L]), me = z(() => {
|
|
133
|
+
const n = /* @__PURE__ */ new Map();
|
|
134
|
+
for (const r of b) {
|
|
135
|
+
const i = r.group || "";
|
|
136
|
+
n.has(i) || n.set(i, []), n.get(i).push(r);
|
|
137
|
+
}
|
|
138
|
+
return n;
|
|
139
|
+
}, [b]), X = W((n) => {
|
|
140
|
+
if (o) {
|
|
141
|
+
const r = f.includes(n) ? f.filter((i) => i !== n) : [...f, n];
|
|
142
|
+
_?.(r);
|
|
143
|
+
} else
|
|
144
|
+
_?.(n), O(!1), u("");
|
|
145
|
+
}, [o, f, _]), ke = W((n) => {
|
|
146
|
+
if (n.key === "Escape") {
|
|
147
|
+
O(!1), u("");
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (n.key === "Enter" || n.key === " ") {
|
|
151
|
+
if (!$) {
|
|
152
|
+
O(!0), n.preventDefault();
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
U >= 0 && b[U] && (X(b[U].value), n.preventDefault());
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
n.key === "ArrowDown" && (n.preventDefault(), H((r) => Math.min(r + 1, b.length - 1))), n.key === "ArrowUp" && (n.preventDefault(), H((r) => Math.max(r - 1, 0)));
|
|
159
|
+
}, [$, U, b, X]), fe = z(() => f.length === 0 ? null : o ? f.map((n) => T.find((r) => r.value === n)?.label || n).join(", ") : T.find((n) => n.value === f[0])?.label || f[0], [f, T, o]), ge = W((n) => {
|
|
160
|
+
n.stopPropagation(), _?.(o ? [] : "");
|
|
161
|
+
}, [_, o]), $e = z(() => [
|
|
162
|
+
{ key: "Enter", description: d("shortcuts.select", "Select") },
|
|
163
|
+
{ key: "Space", description: d("shortcuts.openDropdown", "Open dropdown") },
|
|
164
|
+
ae.moveUp,
|
|
165
|
+
ae.moveDown,
|
|
166
|
+
ae.cancel
|
|
167
|
+
], [d]);
|
|
168
|
+
return /* @__PURE__ */ l("div", { className: `nice-field ${x || ""}`, style: R, children: [
|
|
169
|
+
y && /* @__PURE__ */ l("label", { htmlFor: V, className: `nice-field__label ${A ? "nice-field__label--required" : ""}`, children: [
|
|
170
|
+
y,
|
|
171
|
+
le && /* @__PURE__ */ e(pe, { shortcuts: $e, size: "sm" })
|
|
172
|
+
] }),
|
|
173
|
+
/* @__PURE__ */ l("div", { className: "nice-select", ref: _e, children: [
|
|
174
|
+
/* @__PURE__ */ l(
|
|
175
|
+
"button",
|
|
176
|
+
{
|
|
177
|
+
ref: G,
|
|
178
|
+
type: "button",
|
|
179
|
+
id: V,
|
|
180
|
+
role: "combobox",
|
|
181
|
+
"aria-expanded": $,
|
|
182
|
+
"aria-haspopup": "listbox",
|
|
183
|
+
"aria-invalid": !!t,
|
|
184
|
+
className: `nice-select__trigger nice-select__trigger--${a} nice-select--ds-${se} ${$ ? "nice-select__trigger--open" : ""} ${t ? "nice-select__trigger--error" : ""} ${s ? "nice-select__trigger--disabled" : ""}`,
|
|
185
|
+
style: te,
|
|
186
|
+
disabled: s,
|
|
187
|
+
onClick: () => O(!$),
|
|
188
|
+
onKeyDown: ke,
|
|
189
|
+
children: [
|
|
190
|
+
fe ? /* @__PURE__ */ e("span", { children: fe }) : /* @__PURE__ */ e("span", { className: "nice-select__placeholder", children: C || d("controls.select", "Select...") }),
|
|
191
|
+
/* @__PURE__ */ l("span", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
|
|
192
|
+
w && f.length > 0 && /* @__PURE__ */ e("span", { className: "nice-input__clear", onClick: ge, role: "button", "aria-label": d("controls.clear", "Clear"), children: "✕" }),
|
|
193
|
+
/* @__PURE__ */ e("svg", { className: `nice-select__chevron ${$ ? "nice-select__chevron--open" : ""}`, viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ e("path", { fillRule: "evenodd", d: "M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z", clipRule: "evenodd" }) })
|
|
194
|
+
] })
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
),
|
|
198
|
+
$ && /* @__PURE__ */ l(
|
|
199
|
+
"div",
|
|
200
|
+
{
|
|
201
|
+
className: "nice-select__dropdown",
|
|
202
|
+
role: "listbox",
|
|
203
|
+
style: { maxHeight: F },
|
|
204
|
+
onScroll: J ? (n) => Ne(n.currentTarget.scrollTop) : void 0,
|
|
205
|
+
children: [
|
|
206
|
+
(m || L) && /* @__PURE__ */ e("div", { className: "nice-select__search", children: /* @__PURE__ */ e(
|
|
207
|
+
"input",
|
|
208
|
+
{
|
|
209
|
+
type: "text",
|
|
210
|
+
value: P,
|
|
211
|
+
onChange: (n) => {
|
|
212
|
+
u(n.target.value), H(0), L?.(n.target.value);
|
|
213
|
+
},
|
|
214
|
+
placeholder: d("controls.search", "Search..."),
|
|
215
|
+
autoFocus: !0
|
|
216
|
+
}
|
|
217
|
+
) }),
|
|
218
|
+
Q && /* @__PURE__ */ e("div", { className: "nice-select__loading", children: /* @__PURE__ */ e("div", { className: "nice-spinner nice-spinner--sm", style: { margin: "8px auto" } }) }),
|
|
219
|
+
!Q && b.length === 0 ? /* @__PURE__ */ e("div", { className: "nice-select__empty", children: D || d("controls.noResults", "No results found") }) : J && !Array.from(me.keys()).some((n) => n !== "") ? (() => {
|
|
220
|
+
const r = b.length * S, i = Math.max(0, Math.floor(he / S) - 3), j = Math.min(b.length, Math.ceil((he + F) / S) + 3), Y = b.slice(i, j);
|
|
221
|
+
return /* @__PURE__ */ e("div", { style: { height: r, position: "relative" }, children: Y.map((N, xe) => {
|
|
222
|
+
const re = i + xe, Z = f.includes(N.value);
|
|
223
|
+
return /* @__PURE__ */ e(
|
|
224
|
+
"div",
|
|
225
|
+
{
|
|
226
|
+
role: "option",
|
|
227
|
+
"aria-selected": Z,
|
|
228
|
+
className: `nice-select__option ${Z ? "nice-select__option--selected" : ""} ${re === U ? "nice-select__option--highlighted" : ""} ${N.disabled ? "nice-select__option--disabled" : ""}`,
|
|
229
|
+
style: { position: "absolute", top: re * S, left: 0, right: 0, height: S, display: "flex", alignItems: "center", padding: "0 12px" },
|
|
230
|
+
onClick: () => !N.disabled && X(String(N.value)),
|
|
231
|
+
onMouseEnter: () => H(re),
|
|
232
|
+
children: K ? K(N, Z) : /* @__PURE__ */ l(ve, { children: [
|
|
233
|
+
N.icon && /* @__PURE__ */ e("span", { children: N.icon }),
|
|
234
|
+
/* @__PURE__ */ l("div", { style: { flex: 1 }, children: [
|
|
235
|
+
/* @__PURE__ */ e("div", { children: N.label }),
|
|
236
|
+
N.description && /* @__PURE__ */ e("div", { className: "nice-select__option-desc", children: N.description })
|
|
237
|
+
] }),
|
|
238
|
+
Z && /* @__PURE__ */ e("svg", { className: "nice-select__option-check", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ e("path", { fillRule: "evenodd", d: "M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z", clipRule: "evenodd" }) })
|
|
239
|
+
] })
|
|
240
|
+
},
|
|
241
|
+
N.value
|
|
242
|
+
);
|
|
243
|
+
}) });
|
|
244
|
+
})() : Array.from(me.entries()).map(([n, r]) => /* @__PURE__ */ l(Ce.Fragment, { children: [
|
|
245
|
+
n && /* @__PURE__ */ e("div", { className: "nice-select__group-label", children: n }),
|
|
246
|
+
r.map((i) => {
|
|
247
|
+
const j = f.includes(i.value), Y = b.indexOf(i);
|
|
248
|
+
return /* @__PURE__ */ e(
|
|
249
|
+
"div",
|
|
250
|
+
{
|
|
251
|
+
role: "option",
|
|
252
|
+
"aria-selected": j,
|
|
253
|
+
className: `nice-select__option ${j ? "nice-select__option--selected" : ""} ${Y === U ? "nice-select__option--highlighted" : ""} ${i.disabled ? "nice-select__option--disabled" : ""}`,
|
|
254
|
+
onClick: () => !i.disabled && X(String(i.value)),
|
|
255
|
+
onMouseEnter: () => H(Y),
|
|
256
|
+
children: K ? K(i, j) : /* @__PURE__ */ l(ve, { children: [
|
|
257
|
+
i.icon && /* @__PURE__ */ e("span", { children: i.icon }),
|
|
258
|
+
/* @__PURE__ */ l("div", { style: { flex: 1 }, children: [
|
|
259
|
+
/* @__PURE__ */ e("div", { children: i.label }),
|
|
260
|
+
i.description && /* @__PURE__ */ e("div", { className: "nice-select__option-desc", children: i.description })
|
|
261
|
+
] }),
|
|
262
|
+
j && /* @__PURE__ */ e("svg", { className: "nice-select__option-check", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ e("path", { fillRule: "evenodd", d: "M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z", clipRule: "evenodd" }) })
|
|
263
|
+
] })
|
|
264
|
+
},
|
|
265
|
+
i.value
|
|
266
|
+
);
|
|
267
|
+
})
|
|
268
|
+
] }, n))
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
] }),
|
|
273
|
+
t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
|
|
274
|
+
!t && v && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: v })
|
|
275
|
+
] });
|
|
276
|
+
});
|
|
277
|
+
De.displayName = "NiceSelect";
|
|
278
|
+
const Ie = [
|
|
279
|
+
"#ef4444",
|
|
280
|
+
"#f97316",
|
|
281
|
+
"#f59e0b",
|
|
282
|
+
"#84cc16",
|
|
283
|
+
"#10b981",
|
|
284
|
+
"#06b6d4",
|
|
285
|
+
"#3b82f6",
|
|
286
|
+
"#6366f1",
|
|
287
|
+
"#8b5cf6",
|
|
288
|
+
"#ec4899",
|
|
289
|
+
"#64748b",
|
|
290
|
+
"#1e293b"
|
|
291
|
+
];
|
|
292
|
+
function Ee() {
|
|
293
|
+
return "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0");
|
|
294
|
+
}
|
|
295
|
+
const Ae = ne(({
|
|
296
|
+
label: y,
|
|
297
|
+
helperText: v,
|
|
298
|
+
error: t,
|
|
299
|
+
required: A,
|
|
300
|
+
disabled: s,
|
|
301
|
+
id: a,
|
|
302
|
+
className: B,
|
|
303
|
+
style: M,
|
|
304
|
+
accessMode: x,
|
|
305
|
+
displayStyle: R,
|
|
306
|
+
value: k = "#3b82f6",
|
|
307
|
+
onChange: p,
|
|
308
|
+
presets: g = Ie,
|
|
309
|
+
showInput: h = !0,
|
|
310
|
+
showRandom: _ = !0,
|
|
311
|
+
showKeyboardHints: C
|
|
312
|
+
}, o) => {
|
|
313
|
+
const m = ie(x, a);
|
|
314
|
+
if (m === "hidden") return null;
|
|
315
|
+
(m === "disabled" || m === "readOnly") && (s = !0);
|
|
316
|
+
const { t: w } = oe(), D = de(a);
|
|
317
|
+
ce("input", R);
|
|
318
|
+
const F = be(null), I = W(() => {
|
|
319
|
+
s || p?.(Ee());
|
|
320
|
+
}, [s, p]), q = z(() => [
|
|
321
|
+
{ key: "Enter", description: w("shortcuts.openPicker", "Open color picker") },
|
|
322
|
+
{ key: "Arrow keys", description: w("shortcuts.navigatePresets", "Navigate presets") }
|
|
323
|
+
], [w]);
|
|
324
|
+
return /* @__PURE__ */ l("div", { className: `nice-field ${B || ""}`, style: M, children: [
|
|
325
|
+
y && /* @__PURE__ */ l("label", { htmlFor: D, className: `nice-field__label ${A ? "nice-field__label--required" : ""}`, children: [
|
|
326
|
+
y,
|
|
327
|
+
C && /* @__PURE__ */ e(pe, { shortcuts: q, size: "sm" })
|
|
328
|
+
] }),
|
|
329
|
+
/* @__PURE__ */ l("div", { className: "nice-color-picker", children: [
|
|
330
|
+
/* @__PURE__ */ l("div", { className: "nice-color-picker__preview-row", children: [
|
|
331
|
+
/* @__PURE__ */ e(
|
|
332
|
+
"div",
|
|
333
|
+
{
|
|
334
|
+
className: "nice-color-picker__swatch",
|
|
335
|
+
style: { background: k },
|
|
336
|
+
onClick: () => F.current?.click(),
|
|
337
|
+
role: "button",
|
|
338
|
+
tabIndex: 0,
|
|
339
|
+
"aria-label": "Pick color",
|
|
340
|
+
children: /* @__PURE__ */ e(
|
|
341
|
+
"input",
|
|
342
|
+
{
|
|
343
|
+
ref: (c) => {
|
|
344
|
+
F.current = c, typeof o == "function" ? o(c) : o && (o.current = c);
|
|
345
|
+
},
|
|
346
|
+
type: "color",
|
|
347
|
+
className: "nice-color-picker__native",
|
|
348
|
+
id: D,
|
|
349
|
+
value: k,
|
|
350
|
+
disabled: s,
|
|
351
|
+
onChange: (c) => p?.(c.target.value)
|
|
352
|
+
}
|
|
353
|
+
)
|
|
354
|
+
}
|
|
355
|
+
),
|
|
356
|
+
h && /* @__PURE__ */ e("div", { className: "nice-input nice-input--sm", style: { width: 100 }, children: /* @__PURE__ */ e(
|
|
357
|
+
"input",
|
|
358
|
+
{
|
|
359
|
+
className: "nice-input__native",
|
|
360
|
+
type: "text",
|
|
361
|
+
value: k,
|
|
362
|
+
disabled: s,
|
|
363
|
+
onChange: (c) => p?.(c.target.value),
|
|
364
|
+
maxLength: 7
|
|
365
|
+
}
|
|
366
|
+
) }),
|
|
367
|
+
_ && /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--outline nice-btn--sm nice-color-picker__random", onClick: I, disabled: s, title: "Random color", "aria-label": "Random color", children: "🎲" })
|
|
368
|
+
] }),
|
|
369
|
+
g.length > 0 && /* @__PURE__ */ e("div", { className: "nice-color-picker__presets", children: g.map((c) => /* @__PURE__ */ e(
|
|
370
|
+
"div",
|
|
371
|
+
{
|
|
372
|
+
className: `nice-color-picker__preset ${k === c ? "nice-color-picker__preset--active" : ""}`,
|
|
373
|
+
style: { background: c },
|
|
374
|
+
onClick: () => p?.(c),
|
|
375
|
+
role: "button",
|
|
376
|
+
tabIndex: 0,
|
|
377
|
+
"aria-label": c
|
|
378
|
+
},
|
|
379
|
+
c
|
|
380
|
+
)) })
|
|
381
|
+
] }),
|
|
382
|
+
t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
|
|
383
|
+
!t && v && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: v })
|
|
384
|
+
] });
|
|
385
|
+
});
|
|
386
|
+
Ae.displayName = "NiceColorPicker";
|
|
387
|
+
const Fe = ne(
|
|
388
|
+
({
|
|
389
|
+
children: y,
|
|
390
|
+
variant: v = "primary",
|
|
391
|
+
size: t = "md",
|
|
392
|
+
type: A = "button",
|
|
393
|
+
disabled: s,
|
|
394
|
+
loading: a,
|
|
395
|
+
fullWidth: B,
|
|
396
|
+
onClick: M,
|
|
397
|
+
leftIcon: x,
|
|
398
|
+
rightIcon: R,
|
|
399
|
+
className: k,
|
|
400
|
+
style: p,
|
|
401
|
+
id: g,
|
|
402
|
+
accessMode: h,
|
|
403
|
+
displayStyle: _,
|
|
404
|
+
...C
|
|
405
|
+
}, o) => {
|
|
406
|
+
const m = ie(h, g);
|
|
407
|
+
if (m === "hidden") return null;
|
|
408
|
+
(m === "disabled" || m === "readOnly") && (s = !0);
|
|
409
|
+
const w = ue("button", _), D = ce("button", _);
|
|
410
|
+
return /* @__PURE__ */ l(
|
|
411
|
+
"button",
|
|
412
|
+
{
|
|
413
|
+
ref: o,
|
|
414
|
+
type: A,
|
|
415
|
+
id: g,
|
|
416
|
+
className: `nice-btn nice-btn--${v} nice-btn--${t} nice-btn--ds-${D} ${B ? "nice-btn--full-width" : ""} ${a ? "nice-btn--loading" : ""} ${k || ""}`,
|
|
417
|
+
style: { ...w, ...p },
|
|
418
|
+
disabled: s || a,
|
|
419
|
+
"aria-busy": a || void 0,
|
|
420
|
+
"aria-disabled": s || a || void 0,
|
|
421
|
+
onClick: M,
|
|
422
|
+
...C,
|
|
423
|
+
children: [
|
|
424
|
+
a && /* @__PURE__ */ e(
|
|
425
|
+
"svg",
|
|
426
|
+
{
|
|
427
|
+
className: "nice-btn__spinner",
|
|
428
|
+
viewBox: "0 0 24 24",
|
|
429
|
+
fill: "none",
|
|
430
|
+
stroke: "currentColor",
|
|
431
|
+
strokeWidth: "3",
|
|
432
|
+
"aria-hidden": "true",
|
|
433
|
+
children: /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10", strokeDasharray: "31.4 31.4", strokeLinecap: "round" })
|
|
434
|
+
}
|
|
435
|
+
),
|
|
436
|
+
!a && x && /* @__PURE__ */ e("span", { "aria-hidden": "true", children: x }),
|
|
437
|
+
/* @__PURE__ */ e("span", { children: y }),
|
|
438
|
+
!a && R && /* @__PURE__ */ e("span", { "aria-hidden": "true", children: R })
|
|
439
|
+
]
|
|
440
|
+
}
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
);
|
|
444
|
+
Fe.displayName = "NiceButton";
|
|
445
|
+
export {
|
|
446
|
+
Ae as N,
|
|
447
|
+
De as a,
|
|
448
|
+
Re as b,
|
|
449
|
+
Fe as c
|
|
450
|
+
};
|