@nice2dev/ui 1.3.9 → 1.3.11
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 +88 -0
- package/README.md +16 -18
- package/dist/NiceColorPicker-BLwYNSXJ.cjs +1 -0
- package/dist/NiceColorPicker-DS59tNkP.js +552 -0
- package/dist/NiceDataGrid-CL2_7fS7.cjs +10 -0
- package/dist/NiceDataGrid-CpJrRN_H.js +2269 -0
- package/dist/NiceForm-BQj-K7p7.cjs +1 -0
- package/dist/NiceForm-HQ4h7hX_.js +5023 -0
- package/dist/NiceGantt-BygumlaY.cjs +1 -0
- package/dist/NiceGantt-DTC7OH-v.js +334 -0
- package/dist/NiceHtmlEditor-BtpuaLln.js +901 -0
- package/dist/NiceHtmlEditor-C1OVtLQ6.cjs +10 -0
- package/dist/NiceMention-CVxxCVtQ.js +11668 -0
- package/dist/NiceMention-Te66Oid1.cjs +430 -0
- package/dist/NiceModuleLifecyclePanel-DCrFyUH8.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-Mt80MdET.js +7441 -0
- package/dist/NicePagination-CKsAP38Q.cjs +1 -0
- package/dist/NicePagination-zOed5QxG.js +202 -0
- package/dist/NicePivotGrid-Clue9FM5.js +1184 -0
- package/dist/NicePivotGrid-Cnkr9WkC.cjs +152 -0
- package/dist/NicePropertyGrid.doc-BWNyWrWq.cjs +7 -0
- package/dist/NicePropertyGrid.doc-C_I3F4w8.js +31 -0
- package/dist/NiceSavedQueryPanel-NgG58w6i.js +6226 -0
- package/dist/NiceSavedQueryPanel-lTWY2plm.cjs +587 -0
- package/dist/NiceScheduler-BWwqFKEc.js +1712 -0
- package/dist/NiceScheduler-DqWEJU7g.cjs +5 -0
- package/dist/NiceSelect-BNPXs6FQ.cjs +1 -0
- package/dist/NiceSelect-DEruWHan.js +495 -0
- package/dist/NiceWindow-D3V7A69Q.js +2247 -0
- package/dist/NiceWindow-pgR4c-kQ.cjs +1 -0
- package/dist/core-lazy-Bjdu111n.js +351 -0
- package/dist/core-lazy-Bx_8BOlG.cjs +1 -0
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +47 -6
- package/dist/data.mjs +3 -3
- package/dist/devops-CqhA0rjL.js +9130 -0
- package/dist/devops-cgRBnZVX.cjs +18 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.mjs +7 -7
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +1 -1
- package/dist/index.cjs +137 -151
- package/dist/index.css +1 -1
- package/dist/index.d.ts +113 -50
- package/dist/index.mjs +16556 -16423
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +15 -15
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +2 -0
- package/dist/navigation.mjs +3 -3
- package/dist/no-code-BQqK8mvU.cjs +331 -0
- package/dist/no-code-Cppb-xz3.js +8320 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.mjs +1 -1
- package/dist/pickerCommons-BA3-D5RC.js +663 -0
- package/dist/pickerCommons-KrBqCBDn.cjs +1 -0
- package/dist/style.css +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,93 @@
|
|
|
1
1
|
# [1.0.27] — 2026-06-07
|
|
2
2
|
|
|
3
|
+
## 1.3.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7fefbc7: **BREAKING: `@nice2dev/ui-designers` is no longer published.** It only re-exported designers of
|
|
8
|
+
`@nice2dev/ui`, so import them from there:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
// before
|
|
12
|
+
import { NiceWorkflowDesigner, NiceThemeDesigner } from '@nice2dev/ui-designers';
|
|
13
|
+
// after
|
|
14
|
+
import { NiceWorkflowDesigner, NiceThemeDesigner } from '@nice2dev/ui';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The same applies to `NiceBPMNDesigner` and the `NiceWorkflowDesigner*` / `NiceThemeDesigner*` types.
|
|
18
|
+
The last published version, 1.3.10, keeps working but gets no updates.
|
|
19
|
+
|
|
20
|
+
Also in `@nice2dev/ui`:
|
|
21
|
+
|
|
22
|
+
- `NiceThemeDesigner` now has its implementation under its own name; the internal
|
|
23
|
+
`NiceThemeBuilder` alias file is gone. The API, the `nice-theme-builder*` CSS classes and the
|
|
24
|
+
`themeBuilder.*` keys are unchanged.
|
|
25
|
+
- The unused `nice-configurator*` and `nice-view-builder*` rules leave `style.css`. They styled
|
|
26
|
+
NiceControlConfigurator and NiceViewBuilder, which were removed in 1.x.
|
|
27
|
+
|
|
28
|
+
- c8f46e7: **Views read the module's data: `query` and `entity` data sources.**
|
|
29
|
+
|
|
30
|
+
- **`NiceViewDataSourceRef.type`** gains two values:
|
|
31
|
+
- `'query'`, with `ref`: the `key` of a module `NiceDataSourceDef` built in
|
|
32
|
+
`NiceDataSourceBuilder`;
|
|
33
|
+
- `'entity'`, with `entity`: a module entity.
|
|
34
|
+
|
|
35
|
+
`validateViewDefinition` reports a `query` source without `ref` and an `entity` source without
|
|
36
|
+
`entity`.
|
|
37
|
+
|
|
38
|
+
- **`toViewDataSourceRef(def)`** turns a `NiceDataSourceDef` into the view source that reads it. The
|
|
39
|
+
builder's "maps to a view-standard data source" was not true until now: the view standard had no
|
|
40
|
+
query type.
|
|
41
|
+
- **`NiceViewEditor` gets a `dataSourceOptions` prop:** the module's data sources a `query` source can
|
|
42
|
+
pick from. For an `entity` source it offers the names from `entities`. Without them the editor
|
|
43
|
+
falls back to a text field.
|
|
44
|
+
- **Doc note:** `NiceModuleManifest` is the runtime manifest of front-end micro-modules, not the seed
|
|
45
|
+
`*.manifest.json` of an ERP module.
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [65fecd1]
|
|
48
|
+
- Updated dependencies [0d1d9dd]
|
|
49
|
+
- Updated dependencies [ea95d42]
|
|
50
|
+
- Updated dependencies [c8f46e7]
|
|
51
|
+
- @nice2dev/i18n@1.3.11
|
|
52
|
+
- @nice2dev/ui-core@1.3.11
|
|
53
|
+
|
|
54
|
+
## 1.3.10
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- e5b7da8: **NiceTreeGrid: lazy children, whole subtrees, own selection summary. Test ids on 61 more controls.**
|
|
59
|
+
|
|
60
|
+
- **`loadChildren` + `hasChildren`:** a row can get its children when it is first opened. While they
|
|
61
|
+
load, a "Loading…" row stands under it. A failed load shows a row with a retry button. The grid
|
|
62
|
+
keeps what it loaded.
|
|
63
|
+
- Flat rows can bring deeper levels along (`parentKeyField`), nested rows through
|
|
64
|
+
`childrenField`.
|
|
65
|
+
- A row that is checked before it loads checks its children when they arrive.
|
|
66
|
+
- `hasChildren` alone (without `loadChildren`) gives an expander and a loading row until the host
|
|
67
|
+
adds the children to `data`.
|
|
68
|
+
- **Whole subtrees:** `rowActions={['expandSubtree']}` adds a row button that opens everything below
|
|
69
|
+
a row (loading lazy rows on the way) and closes it all once it is open. Alt- or Shift-click on an
|
|
70
|
+
expander and Shift+→ / Shift+← do the same without the button.
|
|
71
|
+
- **`checkedSummary`:** `false` hides "{checked} of {total} selected"; a function renders your own
|
|
72
|
+
from `checked`, `total`, `leafKeys` and `rows`, e.g. to count an item that has a row under several
|
|
73
|
+
parents once.
|
|
74
|
+
- **Expanding while searching:** rows the user opens or closes during a search now go through
|
|
75
|
+
`onExpandedChange` and stay that way after the search. The rows the search opens by itself are
|
|
76
|
+
still not reported and close again.
|
|
77
|
+
- **Fix: `*` opened only the last sibling:** each sibling's change started from the same set. It now
|
|
78
|
+
opens all of them.
|
|
79
|
+
- **Test ids:** `NiceBaseProps` declares `data-testid`, and 61 controls built on it dropped it. Among
|
|
80
|
+
them are NiceCard, NiceCheckbox, NiceToggle, NiceTabs, NiceAccordion, NiceBreadcrumb,
|
|
81
|
+
NiceTreeView, NiceTreeList, NiceForm, NicePagination and NiceMenu. They all render it on their
|
|
82
|
+
root element now.
|
|
83
|
+
- `NiceCard` also takes `testId` and forwards `id` to the card element.
|
|
84
|
+
- The CI gate `Test ids on standard controls` now covers `NiceBaseProps` controls too, and
|
|
85
|
+
counts a `{...rest}` spread on an element as forwarding.
|
|
86
|
+
|
|
87
|
+
- Updated dependencies [e5b7da8]
|
|
88
|
+
- @nice2dev/i18n@1.3.10
|
|
89
|
+
- @nice2dev/ui-core@1.3.10
|
|
90
|
+
|
|
3
91
|
## 1.3.9
|
|
4
92
|
|
|
5
93
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -332,24 +332,22 @@ Form input components with consistent `NiceFormFieldProps` interface: `label`, `
|
|
|
332
332
|
| `NiceDiagram` | `nodes[]`, `edges[]`, `onNodeClick`, `onEdgeClick` | Node/edge diagram |
|
|
333
333
|
| `NiceStepper` | `steps[]`, `currentStep`, `onStepChange`, `vertical` | Step wizard |
|
|
334
334
|
|
|
335
|
-
### Tools (
|
|
336
|
-
|
|
337
|
-
| Component
|
|
338
|
-
|
|
|
339
|
-
| `NiceChat`
|
|
340
|
-
| `NiceDraggable`
|
|
341
|
-
| `NiceSortable`
|
|
342
|
-
| `NiceFileUploader`
|
|
343
|
-
| `NiceFileManager`
|
|
344
|
-
| `NiceFilterBuilder`
|
|
345
|
-
| `NiceGallery`
|
|
346
|
-
| `NiceMap`
|
|
347
|
-
| `NiceSpeechToText`
|
|
348
|
-
| `NiceThemeDesigner`
|
|
349
|
-
| `
|
|
350
|
-
| `
|
|
351
|
-
| `NiceViewBuilder` | `definition`, `onChange`, `controlRegistry` | Drag-and-drop view builder |
|
|
352
|
-
| `NiceShowcase` | `defaultTab`, `showAbout`, `packageName`, `version` | Embeddable component showcase & docs |
|
|
335
|
+
### Tools (13 components)
|
|
336
|
+
|
|
337
|
+
| Component | Key Props | Description |
|
|
338
|
+
| ------------------- | -------------------------------------------------------- | ---------------------------------------- |
|
|
339
|
+
| `NiceChat` | `messages[]`, `onSendMessage`, `currentUser` | Chat widget |
|
|
340
|
+
| `NiceDraggable` | `onDrag`, `ghostImage`, `children` | Drag source wrapper |
|
|
341
|
+
| `NiceSortable` | `items[]`, `onSort`, `direction` | Sortable list |
|
|
342
|
+
| `NiceFileUploader` | `onUpload`, `accept`, `multiple`, `maxSize`, `maxFiles` | File upload |
|
|
343
|
+
| `NiceFileManager` | `items[]`, `onDelete`, `onRename`, `onNavigate` | File browser |
|
|
344
|
+
| `NiceFilterBuilder` | `fields[]`, `onChange`, `value` | Visual filter/query builder |
|
|
345
|
+
| `NiceGallery` | `items[]`, `columns`, `gap`, `onItemClick` | Image gallery |
|
|
346
|
+
| `NiceMap` | `markers[]`, `center`, `zoom`, `onMarkerClick` | Map with markers |
|
|
347
|
+
| `NiceSpeechToText` | `onResult`, `language`, `continuous` | Speech recognition |
|
|
348
|
+
| `NiceThemeDesigner` | `theme`, `sections[]`, `onChange`, `onApply`, `onExport` | Theme editor with preview and CSS export |
|
|
349
|
+
| `NiceViewEditor` | `value`, `onChange`, `dataSourceOptions` | Visual view (form / grid) designer |
|
|
350
|
+
| `NiceShowcase` | `defaultTab`, `showAbout`, `packageName`, `version` | Embeddable component showcase & docs |
|
|
353
351
|
|
|
354
352
|
### Validation (3 components + 1 hook)
|
|
355
353
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),P=require("@nice2dev/ui-core"),k=require("react"),me=require("react-dom"),he=require("./devops-cgRBnZVX.cjs"),fe=["#ef4444","#f97316","#f59e0b","#84cc16","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#ec4899","#64748b","#1e293b"];function ge(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function ve(a){const u=/^#?([0-9a-f]{6})$/i.exec(a.trim());if(!u)return{r:0,g:0,b:0};const h=parseInt(u[1],16);return{r:h>>16&255,g:h>>8&255,b:h&255}}function be(a,u,h){const p=r=>Math.max(0,Math.min(255,Math.round(r))).toString(16).padStart(2,"0");return`#${p(a)}${p(u)}${p(h)}`}function xe(a,u,h){const p=a/255,r=u/255,i=h/255,n=Math.max(p,r,i),b=Math.min(p,r,i),d=(n+b)/2;let o=0,c=0;if(n!==b){const _=n-b;switch(c=d>.5?_/(2-n-b):_/(n+b),n){case p:o=(r-i)/_+(r<i?6:0);break;case r:o=(i-p)/_+2;break;case i:o=(p-r)/_+4;break}o*=60}return{h:Math.round(o),s:Math.round(c*100),l:Math.round(d*100)}}function _e(a,u,h){const p=u/100,r=h/100,i=(1-Math.abs(2*r-1))*p,n=i*(1-Math.abs(a/60%2-1)),b=r-i/2;let d=0,o=0,c=0;return a<60?[d,o,c]=[i,n,0]:a<120?[d,o,c]=[n,i,0]:a<180?[d,o,c]=[0,i,n]:a<240?[d,o,c]=[0,n,i]:a<300?[d,o,c]=[n,0,i]:[d,o,c]=[i,0,n],{r:Math.round((d+b)*255),g:Math.round((o+b)*255),b:Math.round((c+b)*255)}}function ke(a,u,h){const p=a/255,r=u/255,i=h/255,n=Math.max(p,r,i),b=Math.min(p,r,i),d=n-b;let o=0;d!==0&&(n===p?o=(r-i)/d%6:n===r?o=(i-p)/d+2:o=(p-r)/d+4,o*=60,o<0&&(o+=360));const c=n===0?0:d/n;return{h:Math.round(o),s:Math.round(c*100),v:Math.round(n*100)}}function ye(a,u,h){const p=u/100,r=h/100,i=r*p,n=i*(1-Math.abs(a/60%2-1)),b=r-i;let d=0,o=0,c=0;return a<60?[d,o,c]=[i,n,0]:a<120?[d,o,c]=[n,i,0]:a<180?[d,o,c]=[0,i,n]:a<240?[d,o,c]=[0,n,i]:a<300?[d,o,c]=[n,0,i]:[d,o,c]=[i,0,n],{r:Math.round((d+b)*255),g:Math.round((o+b)*255),b:Math.round((c+b)*255)}}function Ne(a){let u=a.trim();const h=/var\([^,]+,\s*(#[0-9a-fA-F]{3,8})\s*\)/.exec(u);h&&(u=h[1]);const p=/^#?([0-9a-f]{3})$/i.exec(u);p&&(u=`#${p[1].split("").map(n=>n+n).join("")}`);const r=/^#?([0-9a-f]{6})$/i.exec(u),i=/^#?([0-9a-f]{8})$/i.exec(u);if(i){const n=i[1];return{r:parseInt(n.slice(0,2),16),g:parseInt(n.slice(2,4),16),b:parseInt(n.slice(4,6),16),a:parseInt(n.slice(6,8),16)/255}}if(r){const n=parseInt(r[1],16);return{r:n>>16&255,g:n>>8&255,b:n&255,a:1}}return{r:0,g:0,b:0,a:1}}function je(a,u,h,p,r){const i=b=>Math.max(0,Math.min(255,Math.round(b))).toString(16).padStart(2,"0"),n=`#${i(a)}${i(u)}${i(h)}`;return r?`${n}${i(p*255)}`:n}const Me=Object.assign(k.forwardRef(({label:a,helperText:u,error:h,required:p,disabled:r,id:i,className:n,style:b,accessMode:d,displayStyle:o,value:c="#3b82f6",onChange:_,presets:B=fe,showInput:X=!1,showRandom:Y=!1,withAlpha:S=!1,compact:I=!1,showKeyboardHints:J,size:Q="md",labelPlacement:Z,errorPlacement:L,labelWidth:T,controlWidth:D,loading:O},F)=>{const A=P.useNiceAccessMode(d,i),W=A==="hidden";(A==="disabled"||A==="readOnly")&&(r=!0);const{t:v}=P.useNiceTranslation(),$=P.useControlId(i);P.useComponentDisplayClass("input",o);const ee=k.useCallback(()=>{r||_?.(ge())},[r,_]),[M,C]=k.useState(!1),[q,re]=k.useState(null),[K,ne]=k.useState(""),U=k.useRef(null),E=k.useRef(null);k.useLayoutEffect(()=>{if(!M||!E.current)return;ne(he.scopeThemeClass(E.current));const m=()=>{const l=E.current?.getBoundingClientRect();if(!l)return;const N=280,w=360;let x=l.left,j=l.bottom+6;x+N>window.innerWidth-8&&(x=Math.max(8,window.innerWidth-N-8)),j+w>window.innerHeight-8&&(j=Math.max(8,l.top-w-6)),re({left:x,top:j})};return m(),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}},[M]),k.useEffect(()=>{if(!M)return;const m=l=>{const N=l.target;U.current?.contains(N)||E.current?.contains(N)||C(!1)};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[M]),P.useOverlayFocus(U,{open:M,modal:!1,onClose:()=>C(!1)});const V=k.useRef(null);P.useRovingFocus(V,{orientation:"grid",itemSelector:".nice-color-picker__preset",wrap:!0});const te=k.useMemo(()=>[{key:"Enter",description:v("shortcuts.openPicker","Open color picker")},{key:"Arrow keys",description:v("shortcuts.navigatePresets","Navigate presets")}],[v]);return W?null:t.jsxs("div",{className:`nice-field nice-field--${Q} ${Z==="left"?"nice-field--label-left":""} ${I?"nice-color-picker--compact":""} ${O?"nice-field--loading":""} ${n||""}`,style:{...b,...T!=null&&{"--nice-field-label-width":typeof T=="number"?`${T}px`:T},...D!=null&&{"--nice-field-control-width":typeof D=="number"?`${D}px`:D}},"aria-busy":O||void 0,children:[a&&t.jsxs("label",{htmlFor:$,className:`nice-field__label ${p?"nice-field__label--required":""}`,children:[a,J&&t.jsx(P.NiceKeyboardHint,{shortcuts:te,size:"sm"})]}),t.jsx("div",{className:"nice-field__control",children:t.jsxs("div",{className:"nice-color-picker",children:[t.jsxs("div",{className:"nice-color-picker__preview-row",children:[t.jsx("div",{ref:E,className:"nice-color-picker__swatch",id:$,style:{background:c},onClick:m=>{m.stopPropagation(),r||C(l=>!l)},onKeyDown:m=>{!r&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),C(l=>!l))},role:"button",tabIndex:r?-1:0,"aria-disabled":r||void 0,"aria-label":v("colorPicker.openPalette","Open color palette"),"aria-haspopup":"dialog","aria-expanded":M,children:t.jsx("input",{ref:m=>{typeof F=="function"?F(m):F&&(F.current=m)},type:"hidden",value:c,disabled:r,readOnly:!0})}),X&&t.jsx("div",{className:"nice-input nice-input--sm",style:I?{flex:1,minWidth:0}:{width:100},children:t.jsx("input",{className:"nice-input__native",type:"text",value:c,disabled:r,onChange:m=>_?.(m.target.value),maxLength:S?9:7,"aria-label":v("colorPicker.hexValue","Hex value")})}),Y&&!I&&t.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-color-picker__random",onClick:ee,disabled:r,title:v("colorPicker.random","Random"),"aria-label":v("colorPicker.random","Random"),style:{fontSize:"0.65rem",textTransform:"uppercase",letterSpacing:"0.05em"},children:v("colorPicker.random","Random")}),O&&t.jsx("span",{className:"nice-field__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),L==="right"&&h&&t.jsx("div",{id:`${$}-error`,className:"nice-field__error",role:"alert",children:h}),L==="right"&&!h&&u&&t.jsx("div",{id:`${$}-helper`,className:"nice-field__helper",children:u})]}),M&&q&&typeof document<"u"&&me.createPortal(t.jsx("div",{ref:U,className:`nice-color-picker__popup nice-color-picker__popup--portal ${K}`,"data-theme":K==="nice-dark"?"dark":K==="nice-light"?"light":void 0,role:"dialog","aria-label":v("colorPicker.palette","Color palette"),style:{position:"fixed",left:q.left,top:q.top},onClick:m=>m.stopPropagation(),children:(()=>{const m=Ne(c),l={r:m.r,g:m.g,b:m.b},N=S?m.a:1,w=xe(l.r,l.g,l.b),x=ke(l.r,l.g,l.b),j=(e,f,g,s=N)=>_?.(je(e,f,g,s,S)),ie=(e,f,g)=>j(e,f,g),oe=(e,f,g)=>{const s=_e(e,f,g);j(s.r,s.g,s.b)},z=(e,f,g)=>{const s=ye(e,f,g);j(s.r,s.g,s.b)},G=e=>j(l.r,l.g,l.b,e),se=e=>{if(r)return;const f=e.currentTarget,g=y=>{const R=f.getBoundingClientRect(),le=Math.max(0,Math.min(R.width,y.clientX-R.left)),ue=Math.max(0,Math.min(R.height,y.clientY-R.top)),pe=Math.round(le/R.width*100),de=100-Math.round(ue/R.height*100);z(x.h,pe,de)};g(e);const s=()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",s)};document.addEventListener("pointermove",g),document.addEventListener("pointerup",s)},ae=`hsl(${x.h}, 100%, 50%)`,ce=e=>{if(r)return;const f=e.shiftKey?10:1;let{s:g,v:s}=x;if(e.key==="ArrowLeft")g-=f;else if(e.key==="ArrowRight")g+=f;else if(e.key==="ArrowDown")s-=f;else if(e.key==="ArrowUp")s+=f;else if(e.key==="PageDown")s-=10;else if(e.key==="PageUp")s+=10;else if(e.key==="Home")g=0;else if(e.key==="End")g=100;else return;e.preventDefault(),z(x.h,Math.max(0,Math.min(100,g)),Math.max(0,Math.min(100,s)))},H={h:v("colorPicker.hue","Hue"),s:v("colorPicker.saturation","Saturation"),l:v("colorPicker.lightness","Lightness"),r:v("colorPicker.red","Red"),g:v("colorPicker.green","Green"),b:v("colorPicker.blue","Blue")};return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"nice-color-picker__popup-header",children:t.jsx("input",{type:"text",className:"nice-input__native nice-color-picker__popup-hex",value:c,disabled:r,onChange:e=>_?.(e.target.value),maxLength:S?9:7,"aria-label":v("colorPicker.hexValue","Hex value")})}),t.jsx("input",{type:"range",min:0,max:360,value:x.h,disabled:r,onChange:e=>z(Number(e.target.value),x.s,x.v),className:"nice-color-picker__hue-slider","aria-label":v("colorPicker.hue","Hue")}),t.jsx("div",{className:"nice-color-picker__sv",style:{background:`linear-gradient(to top, var(--nice-text, #000), transparent), linear-gradient(to right, var(--nice-bg, #FFF), ${ae})`},onPointerDown:se,onKeyDown:ce,role:"slider",tabIndex:r?-1:0,"aria-label":v("colorPicker.svPalette","Saturation/value palette"),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":x.s,"aria-valuetext":`${H.s} ${x.s}%, ${v("colorPicker.brightness","Brightness")} ${x.v}%`,children:t.jsx("span",{className:"nice-color-picker__sv-marker",style:{left:`${x.s}%`,top:`${100-x.v}%`}})}),t.jsxs("div",{className:"nice-color-picker__sliders",children:[t.jsx("div",{className:"nice-color-picker__slider-col",children:["h","s","l"].map(e=>{const f=e==="h"?360:100,g=w[e],s=y=>oe(e==="h"?y:w.h,e==="s"?y:w.s,e==="l"?y:w.l);return t.jsxs("div",{className:"nice-color-picker__slider-row",children:[t.jsx("label",{className:"nice-color-picker__slider-label",children:e.toUpperCase()}),t.jsx("input",{type:"range",min:0,max:f,value:g,disabled:r,onChange:y=>s(Number(y.target.value)),"aria-label":H[e]}),t.jsx("input",{type:"number",min:0,max:f,value:g,disabled:r,onChange:y=>s(Number(y.target.value)||0),className:"nice-input__native nice-color-picker__slider-num","aria-label":H[e]})]},e)})}),t.jsx("div",{className:"nice-color-picker__slider-col",children:["r","g","b"].map(e=>{const f=l[e],g=s=>ie(e==="r"?s:l.r,e==="g"?s:l.g,e==="b"?s:l.b);return t.jsxs("div",{className:"nice-color-picker__slider-row",children:[t.jsx("label",{className:"nice-color-picker__slider-label",children:e.toUpperCase()}),t.jsx("input",{type:"range",min:0,max:255,value:f,disabled:r,onChange:s=>g(Number(s.target.value)),"aria-label":H[e]}),t.jsx("input",{type:"number",min:0,max:255,value:f,disabled:r,onChange:s=>g(Number(s.target.value)||0),className:"nice-input__native nice-color-picker__slider-num","aria-label":H[e]})]},e)})})]}),S&&t.jsxs("div",{className:"nice-color-picker__alpha-row",children:[t.jsx("label",{className:"nice-color-picker__slider-label",children:"A"}),t.jsx("input",{type:"range",min:0,max:100,value:Math.round(N*100),disabled:r,onChange:e=>G(Number(e.target.value)/100),className:"nice-color-picker__alpha-slider",style:{background:`linear-gradient(to right, transparent, rgb(${l.r},${l.g},${l.b}))`},"aria-label":v("colorPicker.alpha","Alpha")}),t.jsx("input",{type:"number",min:0,max:100,value:Math.round(N*100),disabled:r,onChange:e=>G((Number(e.target.value)||0)/100),className:"nice-input__native nice-color-picker__slider-num","aria-label":v("colorPicker.alpha","Alpha")})]}),B.length>0&&t.jsx("div",{ref:V,className:"nice-color-picker__popup-presets",role:"group","aria-label":v("colorPicker.presets","Preset colors"),children:B.map(e=>t.jsx("div",{className:`nice-color-picker__preset ${c===e?"nice-color-picker__preset--active":""}`,style:{background:e},onClick:()=>{_?.(e),C(!1)},role:"button","aria-label":e,"aria-pressed":c===e,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),_?.(e),C(!1))}},e))})]})})()}),document.body)]})}),L!=="right"&&h&&t.jsx("div",{id:`${$}-error`,className:"nice-field__error",role:"alert",children:h}),L!=="right"&&!h&&u&&t.jsx("div",{id:`${$}-helper`,className:"nice-field__helper",children:u})]})}),{displayName:"NiceColorPicker"});exports.NiceColorPicker=Me;exports.hexToRgb=ve;exports.rgbToHex=be;
|