@editora/ui-react 0.1.27 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/SplitButton.cjs.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
2
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const ae=require("react");require("@editora/ui-core/split-button");const le=require("react-dom"),se=i=>i&&i.__esModule?i:{default:i},e=se(ae),O="editora-split-button-styles",de=`
|
|
3
3
|
.ed-split-button {
|
|
4
4
|
--ed-split-radius: 12px;
|
|
5
5
|
--ed-split-bg: var(--ui-color-primary, #2563eb);
|
|
6
6
|
--ed-split-bg-hover: color-mix(in srgb, var(--ed-split-bg) 84%, #0f172a 16%);
|
|
7
7
|
--ed-split-border: 1px solid color-mix(in srgb, var(--ui-color-border, #cbd5e1) 70%, transparent);
|
|
8
|
-
--ed-split-text: #ffffff;
|
|
8
|
+
--ed-split-text: var(--ui-color-foreground-on-primary, #ffffff);
|
|
9
9
|
--ed-split-shadow: 0 1px 2px rgba(2, 6, 23, 0.12), 0 8px 18px color-mix(in srgb, var(--ed-split-bg) 20%, transparent);
|
|
10
10
|
--ed-split-menu-bg: var(--ui-color-surface, #ffffff);
|
|
11
11
|
--ed-split-menu-text: var(--ui-color-text, #0f172a);
|
|
12
|
-
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text)
|
|
12
|
+
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text) 74%, transparent);
|
|
13
13
|
--ed-split-menu-border: 1px solid color-mix(in srgb, var(--ui-color-border, #cbd5e1) 64%, transparent);
|
|
14
14
|
--ed-split-menu-shadow: 0 22px 44px rgba(2, 6, 23, 0.16), 0 2px 8px rgba(2, 6, 23, 0.08);
|
|
15
15
|
--ed-split-menu-radius: 14px;
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
--ed-split-menu-accent-strong: color-mix(in srgb, var(--ed-split-bg) 18%, transparent);
|
|
22
22
|
--ed-split-menu-accent-border: color-mix(in srgb, var(--ed-split-bg) 24%, transparent);
|
|
23
23
|
--ed-split-menu-danger: var(--ui-color-danger, #dc2626);
|
|
24
|
+
--ed-split-menu-danger-text: var(--ui-color-danger-text, var(--ed-split-menu-danger));
|
|
24
25
|
display: inline-flex;
|
|
25
26
|
position: relative;
|
|
26
27
|
min-width: 0;
|
|
@@ -152,7 +153,7 @@
|
|
|
152
153
|
--ed-split-bg: var(--ui-color-primary, #2563eb);
|
|
153
154
|
--ed-split-menu-bg: var(--ui-color-surface, #ffffff);
|
|
154
155
|
--ed-split-menu-text: var(--ui-color-text, #0f172a);
|
|
155
|
-
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text)
|
|
156
|
+
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text) 74%, transparent);
|
|
156
157
|
--ed-split-menu-border: 1px solid color-mix(in srgb, var(--ui-color-border, #cbd5e1) 64%, transparent);
|
|
157
158
|
--ed-split-menu-shadow: 0 22px 44px rgba(2, 6, 23, 0.16), 0 2px 8px rgba(2, 6, 23, 0.08);
|
|
158
159
|
--ed-split-menu-radius: 14px;
|
|
@@ -164,6 +165,7 @@
|
|
|
164
165
|
--ed-split-menu-accent-strong: color-mix(in srgb, var(--ed-split-bg) 18%, transparent);
|
|
165
166
|
--ed-split-menu-accent-border: color-mix(in srgb, var(--ed-split-bg) 24%, transparent);
|
|
166
167
|
--ed-split-menu-danger: var(--ui-color-danger, #dc2626);
|
|
168
|
+
--ed-split-menu-danger-text: var(--ui-color-danger-text, var(--ed-split-menu-danger));
|
|
167
169
|
position: fixed;
|
|
168
170
|
z-index: 1600;
|
|
169
171
|
display: grid;
|
|
@@ -189,7 +191,8 @@
|
|
|
189
191
|
--ed-split-bg: #2563eb;
|
|
190
192
|
--ed-split-menu-bg: #ffffff;
|
|
191
193
|
--ed-split-menu-text: #0f172a;
|
|
192
|
-
--ed-split-menu-
|
|
194
|
+
--ed-split-menu-danger-text: #b91c1c;
|
|
195
|
+
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text) 74%, transparent);
|
|
193
196
|
--ed-split-menu-border: 1px solid color-mix(in srgb, #0f172a 12%, transparent);
|
|
194
197
|
--ed-split-menu-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
|
|
195
198
|
}
|
|
@@ -198,7 +201,8 @@
|
|
|
198
201
|
--ed-split-bg: #2563eb;
|
|
199
202
|
--ed-split-menu-bg: #ffffff;
|
|
200
203
|
--ed-split-menu-text: #0f172a;
|
|
201
|
-
--ed-split-menu-
|
|
204
|
+
--ed-split-menu-danger-text: #b91c1c;
|
|
205
|
+
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text) 74%, transparent);
|
|
202
206
|
--ed-split-menu-border: 1px solid #dbe4f0;
|
|
203
207
|
--ed-split-menu-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
|
|
204
208
|
--ed-split-menu-accent: #eef4ff;
|
|
@@ -210,7 +214,8 @@
|
|
|
210
214
|
--ed-split-bg: #2563eb;
|
|
211
215
|
--ed-split-menu-bg: #111827;
|
|
212
216
|
--ed-split-menu-text: #f8fafc;
|
|
213
|
-
--ed-split-menu-
|
|
217
|
+
--ed-split-menu-danger-text: #fca5a5;
|
|
218
|
+
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text) 74%, transparent);
|
|
214
219
|
--ed-split-menu-border: 1px solid #334155;
|
|
215
220
|
--ed-split-menu-shadow: 0 18px 36px rgba(15, 23, 42, 0.3), 0 2px 8px rgba(15, 23, 42, 0.2);
|
|
216
221
|
}
|
|
@@ -329,11 +334,11 @@
|
|
|
329
334
|
}
|
|
330
335
|
|
|
331
336
|
.ed-split-button__item--danger {
|
|
332
|
-
color:
|
|
337
|
+
color: var(--ed-split-menu-danger-text);
|
|
333
338
|
}
|
|
334
339
|
|
|
335
340
|
.ed-split-button__item--danger .ed-split-button__itemDescription {
|
|
336
|
-
color:
|
|
341
|
+
color: var(--ed-split-menu-danger-text);
|
|
337
342
|
}
|
|
338
343
|
|
|
339
344
|
.ed-split-button__item--danger:hover,
|
|
@@ -394,4 +399,4 @@
|
|
|
394
399
|
transform: none;
|
|
395
400
|
}
|
|
396
401
|
}
|
|
397
|
-
`;function pe(){if(typeof document>"u"||document.getElementById(O))return;const i=document.createElement("style");i.id=O,i.textContent=de,document.head.appendChild(i)}function N(...i){return i.filter(Boolean).join(" ")}function R(i){return i.findIndex(d=>!d.disabled)}function V(i,d,v){if(!i.length)return-1;let
|
|
402
|
+
`;function pe(){if(typeof document>"u"||document.getElementById(O))return;const i=document.createElement("style");i.id=O,i.textContent=de,document.head.appendChild(i)}function N(...i){return i.filter(Boolean).join(" ")}function R(i){return i.findIndex(d=>!d.disabled)}function V(i,d,v){if(!i.length)return-1;let s=d;for(let u=0;u<i.length;u+=1)if(s=(s+v+i.length)%i.length,!i[s]?.disabled)return s;return-1}function G(i,d){const s=(d==="first"?i:[...i].reverse()).findIndex(u=>!u.disabled);return s<0?-1:d==="first"?s:i.length-1-s}const C=e.default.forwardRef(function({children:d,className:v,label:s="Run action",menuLabel:u="Open action menu",menuHeading:h,menuDescription:y,variant:w="primary",density:D="default",shape:L="default",menuDensity:P="default",menuShape:F="default",disabled:m=!1,items:o=[],onPrimaryAction:J,onSelect:W,style:Q,...X},Z){const I=e.default.useRef(null),q=e.default.useRef(null),S=e.default.useRef(null),b=e.default.useRef(null),A=e.default.useRef([]),[l,k]=e.default.useState(!1),[a,p]=e.default.useState(-1),[f,T]=e.default.useState(null),$=e.default.useId(),H=e.default.useId();e.default.useImperativeHandle(Z,()=>I.current),e.default.useLayoutEffect(()=>{pe()},[]);const g=e.default.useCallback(()=>{const t=q.current,n=b.current;if(!t||!n)return;const r=t.getBoundingClientRect(),U=window.innerWidth||document.documentElement.clientWidth||0,z=window.innerHeight||document.documentElement.clientHeight||0,j=Math.max(260,Math.round(r.width));n.style.minWidth=`${j}px`;const c=n.getBoundingClientRect(),K=Math.max(0,z-r.bottom-8),oe=Math.max(0,r.top-8),Y=K<c.height&&oe>K;let x=Y?r.top-c.height-6:r.bottom+6,_=r.left;_+c.width>U-8&&(_=U-c.width-8),_<8&&(_=8),x<8&&(x=8),x+c.height>z-8&&(x=Math.max(8,z-c.height-8)),T({top:Math.round(x),left:Math.round(_),minWidth:j,placement:Y?"top":"bottom"})},[]);e.default.useEffect(()=>{if(!l){T(null);return}const t=a>=0&&!o[a]?.disabled?a:R(o);p(t)},[l,o,a]),e.default.useLayoutEffect(()=>{if(!l)return;g();const t=requestAnimationFrame(()=>{g();try{b.current?.focus({preventScroll:!0})}catch{b.current?.focus()}}),n=()=>g(),r=()=>g();return window.addEventListener("resize",n,{passive:!0}),window.addEventListener("scroll",r,{passive:!0,capture:!0}),()=>{cancelAnimationFrame(t),window.removeEventListener("resize",n),window.removeEventListener("scroll",r,!0)}},[l,g]),e.default.useEffect(()=>{if(!l)return;const t=n=>{const r=n.target;r&&I.current?.contains(r)||r&&b.current?.contains(r)||k(!1)};return document.addEventListener("pointerdown",t,!0),()=>document.removeEventListener("pointerdown",t,!0)},[l]),e.default.useEffect(()=>{l||queueMicrotask(()=>{try{S.current?.focus({preventScroll:!0})}catch{S.current?.focus()}})},[l]),e.default.useEffect(()=>{if(!l||a<0)return;const t=A.current[a];!t||typeof t.scrollIntoView!="function"||t.scrollIntoView({block:"nearest"})},[l,a]);const M=e.default.useCallback(t=>{const n=o[t];!n||n.disabled||(W?.({index:t,value:n.value,label:n.label}),k(!1))},[o,W]),B=e.default.useCallback(()=>{m||o.length===0||k(!0)},[m,o.length]),E=e.default.useCallback(()=>{k(!1)},[]),ee=e.default.useCallback(t=>{(t.key==="ArrowDown"||t.key==="Enter"||t.key===" ")&&(t.preventDefault(),B())},[B]),te=e.default.useCallback(t=>{switch(t.key){case"Escape":t.preventDefault(),E();return;case"Tab":E();return;case"ArrowDown":{t.preventDefault();const n=a>=0?a:R(o)-1,r=V(o,n,1);r>=0&&p(r);return}case"ArrowUp":{t.preventDefault();const n=a>=0?a:R(o)+1,r=V(o,n,-1);r>=0&&p(r);return}case"Home":{t.preventDefault();const n=G(o,"first");n>=0&&p(n);return}case"End":{t.preventDefault();const n=G(o,"last");n>=0&&p(n);return}case"Enter":case" ":{t.preventDefault(),a>=0&&M(a);return}default:return}},[a,E,o,M]),ne=N("ed-split-button",w!=="primary"&&`ed-split-button--${w}`,D!=="default"&&`ed-split-button--${D}`,L!=="default"&&`ed-split-button--${L}`,v),ie=N("ed-split-button__menu",w!=="primary"&&`ed-split-button__menu--${w}`,P!=="default"&&`ed-split-button__menu--${P}`,F!=="default"&&`ed-split-button__menu--${F}`),re=l&&typeof document<"u"?le.createPortal(e.default.createElement("div",{ref:b,className:ie,role:"menu",tabIndex:-1,"aria-labelledby":h?$:void 0,"aria-describedby":y?H:void 0,"data-placement":f?.placement||"bottom",onKeyDown:te,style:{top:f?.top??-9999,left:f?.left??-9999,minWidth:f?.minWidth,visibility:f?"visible":"hidden"}},h||y?e.default.createElement("div",{className:"ed-split-button__menuHeader"},h?e.default.createElement("p",{id:$,className:"ed-split-button__menuHeading"},h):null,y?e.default.createElement("p",{id:H,className:"ed-split-button__menuDescription"},y):null):null,e.default.createElement("div",{className:"ed-split-button__list"},o.map((t,n)=>e.default.createElement("button",{key:t.value,ref:r=>{A.current[n]=r},type:"button",role:"menuitem",className:N("ed-split-button__item",t.tone==="danger"&&"ed-split-button__item--danger"),"data-active":n===a?"true":void 0,"aria-disabled":t.disabled?"true":void 0,disabled:t.disabled,onPointerMove:()=>{t.disabled||p(n)},onFocus:()=>{t.disabled||p(n)},onClick:()=>M(n)},e.default.createElement("span",{className:"ed-split-button__itemText"},e.default.createElement("span",{className:"ed-split-button__itemLabel"},t.label),t.description?e.default.createElement("span",{className:"ed-split-button__itemDescription"},t.description):null),t.shortcut?e.default.createElement("span",{className:"ed-split-button__itemShortcut"},t.shortcut):null)),d)),document.body):null;return e.default.createElement(e.default.Fragment,null,e.default.createElement("div",{...X,ref:I,className:ne,style:Q,"aria-disabled":m?"true":void 0,"data-open":l?"true":void 0},e.default.createElement("div",{ref:q,className:"ed-split-button__group"},e.default.createElement("button",{type:"button",className:"ed-split-button__primary",disabled:m,onClick:()=>J?.()},s),e.default.createElement("button",{ref:S,type:"button",className:"ed-split-button__toggle","aria-label":u,"aria-haspopup":"menu","aria-expanded":l?"true":"false",disabled:m||o.length===0,onClick:()=>{l?E():B()},onKeyDown:ee},e.default.createElement("svg",{className:"ed-split-button__toggleIcon",viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false"},e.default.createElement("path",{d:"m5 8 5 5 5-5",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}))))),re)});C.displayName="SplitButton";exports.SplitButton=C;exports.default=C;
|
package/dist/SplitButton.esm.js
CHANGED
|
@@ -8,11 +8,11 @@ const j = "editora-split-button-styles", se = `
|
|
|
8
8
|
--ed-split-bg: var(--ui-color-primary, #2563eb);
|
|
9
9
|
--ed-split-bg-hover: color-mix(in srgb, var(--ed-split-bg) 84%, #0f172a 16%);
|
|
10
10
|
--ed-split-border: 1px solid color-mix(in srgb, var(--ui-color-border, #cbd5e1) 70%, transparent);
|
|
11
|
-
--ed-split-text: #ffffff;
|
|
11
|
+
--ed-split-text: var(--ui-color-foreground-on-primary, #ffffff);
|
|
12
12
|
--ed-split-shadow: 0 1px 2px rgba(2, 6, 23, 0.12), 0 8px 18px color-mix(in srgb, var(--ed-split-bg) 20%, transparent);
|
|
13
13
|
--ed-split-menu-bg: var(--ui-color-surface, #ffffff);
|
|
14
14
|
--ed-split-menu-text: var(--ui-color-text, #0f172a);
|
|
15
|
-
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text)
|
|
15
|
+
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text) 74%, transparent);
|
|
16
16
|
--ed-split-menu-border: 1px solid color-mix(in srgb, var(--ui-color-border, #cbd5e1) 64%, transparent);
|
|
17
17
|
--ed-split-menu-shadow: 0 22px 44px rgba(2, 6, 23, 0.16), 0 2px 8px rgba(2, 6, 23, 0.08);
|
|
18
18
|
--ed-split-menu-radius: 14px;
|
|
@@ -24,6 +24,7 @@ const j = "editora-split-button-styles", se = `
|
|
|
24
24
|
--ed-split-menu-accent-strong: color-mix(in srgb, var(--ed-split-bg) 18%, transparent);
|
|
25
25
|
--ed-split-menu-accent-border: color-mix(in srgb, var(--ed-split-bg) 24%, transparent);
|
|
26
26
|
--ed-split-menu-danger: var(--ui-color-danger, #dc2626);
|
|
27
|
+
--ed-split-menu-danger-text: var(--ui-color-danger-text, var(--ed-split-menu-danger));
|
|
27
28
|
display: inline-flex;
|
|
28
29
|
position: relative;
|
|
29
30
|
min-width: 0;
|
|
@@ -155,7 +156,7 @@ const j = "editora-split-button-styles", se = `
|
|
|
155
156
|
--ed-split-bg: var(--ui-color-primary, #2563eb);
|
|
156
157
|
--ed-split-menu-bg: var(--ui-color-surface, #ffffff);
|
|
157
158
|
--ed-split-menu-text: var(--ui-color-text, #0f172a);
|
|
158
|
-
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text)
|
|
159
|
+
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text) 74%, transparent);
|
|
159
160
|
--ed-split-menu-border: 1px solid color-mix(in srgb, var(--ui-color-border, #cbd5e1) 64%, transparent);
|
|
160
161
|
--ed-split-menu-shadow: 0 22px 44px rgba(2, 6, 23, 0.16), 0 2px 8px rgba(2, 6, 23, 0.08);
|
|
161
162
|
--ed-split-menu-radius: 14px;
|
|
@@ -167,6 +168,7 @@ const j = "editora-split-button-styles", se = `
|
|
|
167
168
|
--ed-split-menu-accent-strong: color-mix(in srgb, var(--ed-split-bg) 18%, transparent);
|
|
168
169
|
--ed-split-menu-accent-border: color-mix(in srgb, var(--ed-split-bg) 24%, transparent);
|
|
169
170
|
--ed-split-menu-danger: var(--ui-color-danger, #dc2626);
|
|
171
|
+
--ed-split-menu-danger-text: var(--ui-color-danger-text, var(--ed-split-menu-danger));
|
|
170
172
|
position: fixed;
|
|
171
173
|
z-index: 1600;
|
|
172
174
|
display: grid;
|
|
@@ -192,7 +194,8 @@ const j = "editora-split-button-styles", se = `
|
|
|
192
194
|
--ed-split-bg: #2563eb;
|
|
193
195
|
--ed-split-menu-bg: #ffffff;
|
|
194
196
|
--ed-split-menu-text: #0f172a;
|
|
195
|
-
--ed-split-menu-
|
|
197
|
+
--ed-split-menu-danger-text: #b91c1c;
|
|
198
|
+
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text) 74%, transparent);
|
|
196
199
|
--ed-split-menu-border: 1px solid color-mix(in srgb, #0f172a 12%, transparent);
|
|
197
200
|
--ed-split-menu-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
|
|
198
201
|
}
|
|
@@ -201,7 +204,8 @@ const j = "editora-split-button-styles", se = `
|
|
|
201
204
|
--ed-split-bg: #2563eb;
|
|
202
205
|
--ed-split-menu-bg: #ffffff;
|
|
203
206
|
--ed-split-menu-text: #0f172a;
|
|
204
|
-
--ed-split-menu-
|
|
207
|
+
--ed-split-menu-danger-text: #b91c1c;
|
|
208
|
+
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text) 74%, transparent);
|
|
205
209
|
--ed-split-menu-border: 1px solid #dbe4f0;
|
|
206
210
|
--ed-split-menu-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
|
|
207
211
|
--ed-split-menu-accent: #eef4ff;
|
|
@@ -213,7 +217,8 @@ const j = "editora-split-button-styles", se = `
|
|
|
213
217
|
--ed-split-bg: #2563eb;
|
|
214
218
|
--ed-split-menu-bg: #111827;
|
|
215
219
|
--ed-split-menu-text: #f8fafc;
|
|
216
|
-
--ed-split-menu-
|
|
220
|
+
--ed-split-menu-danger-text: #fca5a5;
|
|
221
|
+
--ed-split-menu-muted: color-mix(in srgb, var(--ed-split-menu-text) 74%, transparent);
|
|
217
222
|
--ed-split-menu-border: 1px solid #334155;
|
|
218
223
|
--ed-split-menu-shadow: 0 18px 36px rgba(15, 23, 42, 0.3), 0 2px 8px rgba(15, 23, 42, 0.2);
|
|
219
224
|
}
|
|
@@ -332,11 +337,11 @@ const j = "editora-split-button-styles", se = `
|
|
|
332
337
|
}
|
|
333
338
|
|
|
334
339
|
.ed-split-button__item--danger {
|
|
335
|
-
color:
|
|
340
|
+
color: var(--ed-split-menu-danger-text);
|
|
336
341
|
}
|
|
337
342
|
|
|
338
343
|
.ed-split-button__item--danger .ed-split-button__itemDescription {
|
|
339
|
-
color:
|
|
344
|
+
color: var(--ed-split-menu-danger-text);
|
|
340
345
|
}
|
|
341
346
|
|
|
342
347
|
.ed-split-button__item--danger:hover,
|
|
@@ -398,7 +403,7 @@ const j = "editora-split-button-styles", se = `
|
|
|
398
403
|
}
|
|
399
404
|
}
|
|
400
405
|
`;
|
|
401
|
-
function
|
|
406
|
+
function ae() {
|
|
402
407
|
if (typeof document > "u" || document.getElementById(j)) return;
|
|
403
408
|
const r = document.createElement("style");
|
|
404
409
|
r.id = j, r.textContent = se, document.head.appendChild(r);
|
|
@@ -411,19 +416,19 @@ function R(r) {
|
|
|
411
416
|
}
|
|
412
417
|
function O(r, d, v) {
|
|
413
418
|
if (!r.length) return -1;
|
|
414
|
-
let
|
|
419
|
+
let l = d;
|
|
415
420
|
for (let u = 0; u < r.length; u += 1)
|
|
416
|
-
if (
|
|
421
|
+
if (l = (l + v + r.length) % r.length, !r[l]?.disabled) return l;
|
|
417
422
|
return -1;
|
|
418
423
|
}
|
|
419
424
|
function V(r, d) {
|
|
420
|
-
const
|
|
421
|
-
return
|
|
425
|
+
const l = (d === "first" ? r : [...r].reverse()).findIndex((u) => !u.disabled);
|
|
426
|
+
return l < 0 ? -1 : d === "first" ? l : r.length - 1 - l;
|
|
422
427
|
}
|
|
423
|
-
const
|
|
428
|
+
const le = e.forwardRef(function({
|
|
424
429
|
children: d,
|
|
425
430
|
className: v,
|
|
426
|
-
label:
|
|
431
|
+
label: l = "Run action",
|
|
427
432
|
menuLabel: u = "Open action menu",
|
|
428
433
|
menuHeading: h,
|
|
429
434
|
menuDescription: y,
|
|
@@ -439,9 +444,9 @@ const ae = e.forwardRef(function({
|
|
|
439
444
|
style: J,
|
|
440
445
|
...Q
|
|
441
446
|
}, X) {
|
|
442
|
-
const I = e.useRef(null), W = e.useRef(null), S = e.useRef(null), b = e.useRef(null), A = e.useRef([]), [
|
|
447
|
+
const I = e.useRef(null), W = e.useRef(null), S = e.useRef(null), b = e.useRef(null), A = e.useRef([]), [a, k] = e.useState(!1), [s, p] = e.useState(-1), [f, $] = e.useState(null), H = e.useId(), T = e.useId();
|
|
443
448
|
e.useImperativeHandle(X, () => I.current), e.useLayoutEffect(() => {
|
|
444
|
-
|
|
449
|
+
ae();
|
|
445
450
|
}, []);
|
|
446
451
|
const g = e.useCallback(() => {
|
|
447
452
|
const t = W.current, n = b.current;
|
|
@@ -458,14 +463,14 @@ const ae = e.forwardRef(function({
|
|
|
458
463
|
});
|
|
459
464
|
}, []);
|
|
460
465
|
e.useEffect(() => {
|
|
461
|
-
if (!
|
|
466
|
+
if (!a) {
|
|
462
467
|
$(null);
|
|
463
468
|
return;
|
|
464
469
|
}
|
|
465
470
|
const t = s >= 0 && !o[s]?.disabled ? s : R(o);
|
|
466
471
|
p(t);
|
|
467
|
-
}, [
|
|
468
|
-
if (!
|
|
472
|
+
}, [a, o, s]), e.useLayoutEffect(() => {
|
|
473
|
+
if (!a) return;
|
|
469
474
|
g();
|
|
470
475
|
const t = requestAnimationFrame(() => {
|
|
471
476
|
g();
|
|
@@ -478,26 +483,26 @@ const ae = e.forwardRef(function({
|
|
|
478
483
|
return window.addEventListener("resize", n, { passive: !0 }), window.addEventListener("scroll", i, { passive: !0, capture: !0 }), () => {
|
|
479
484
|
cancelAnimationFrame(t), window.removeEventListener("resize", n), window.removeEventListener("scroll", i, !0);
|
|
480
485
|
};
|
|
481
|
-
}, [
|
|
482
|
-
if (!
|
|
486
|
+
}, [a, g]), e.useEffect(() => {
|
|
487
|
+
if (!a) return;
|
|
483
488
|
const t = (n) => {
|
|
484
489
|
const i = n.target;
|
|
485
490
|
i && I.current?.contains(i) || i && b.current?.contains(i) || k(!1);
|
|
486
491
|
};
|
|
487
492
|
return document.addEventListener("pointerdown", t, !0), () => document.removeEventListener("pointerdown", t, !0);
|
|
488
|
-
}, [
|
|
489
|
-
|
|
493
|
+
}, [a]), e.useEffect(() => {
|
|
494
|
+
a || queueMicrotask(() => {
|
|
490
495
|
try {
|
|
491
496
|
S.current?.focus({ preventScroll: !0 });
|
|
492
497
|
} catch {
|
|
493
498
|
S.current?.focus();
|
|
494
499
|
}
|
|
495
500
|
});
|
|
496
|
-
}, [
|
|
497
|
-
if (!
|
|
501
|
+
}, [a]), e.useEffect(() => {
|
|
502
|
+
if (!a || s < 0) return;
|
|
498
503
|
const t = A.current[s];
|
|
499
504
|
!t || typeof t.scrollIntoView != "function" || t.scrollIntoView({ block: "nearest" });
|
|
500
|
-
}, [
|
|
505
|
+
}, [a, s]);
|
|
501
506
|
const M = e.useCallback((t) => {
|
|
502
507
|
const n = o[t];
|
|
503
508
|
!n || n.disabled || (F?.({
|
|
@@ -562,7 +567,7 @@ const ae = e.forwardRef(function({
|
|
|
562
567
|
w !== "primary" && `ed-split-button__menu--${w}`,
|
|
563
568
|
L !== "default" && `ed-split-button__menu--${L}`,
|
|
564
569
|
P !== "default" && `ed-split-button__menu--${P}`
|
|
565
|
-
), ie =
|
|
570
|
+
), ie = a && typeof document < "u" ? oe(
|
|
566
571
|
/* @__PURE__ */ e.createElement(
|
|
567
572
|
"div",
|
|
568
573
|
{
|
|
@@ -620,7 +625,7 @@ const ae = e.forwardRef(function({
|
|
|
620
625
|
className: te,
|
|
621
626
|
style: J,
|
|
622
627
|
"aria-disabled": m ? "true" : void 0,
|
|
623
|
-
"data-open":
|
|
628
|
+
"data-open": a ? "true" : void 0
|
|
624
629
|
},
|
|
625
630
|
/* @__PURE__ */ e.createElement("div", { ref: W, className: "ed-split-button__group" }, /* @__PURE__ */ e.createElement(
|
|
626
631
|
"button",
|
|
@@ -630,7 +635,7 @@ const ae = e.forwardRef(function({
|
|
|
630
635
|
disabled: m,
|
|
631
636
|
onClick: () => G?.()
|
|
632
637
|
},
|
|
633
|
-
|
|
638
|
+
l
|
|
634
639
|
), /* @__PURE__ */ e.createElement(
|
|
635
640
|
"button",
|
|
636
641
|
{
|
|
@@ -639,10 +644,10 @@ const ae = e.forwardRef(function({
|
|
|
639
644
|
className: "ed-split-button__toggle",
|
|
640
645
|
"aria-label": u,
|
|
641
646
|
"aria-haspopup": "menu",
|
|
642
|
-
"aria-expanded":
|
|
647
|
+
"aria-expanded": a ? "true" : "false",
|
|
643
648
|
disabled: m || o.length === 0,
|
|
644
649
|
onClick: () => {
|
|
645
|
-
|
|
650
|
+
a ? E() : B();
|
|
646
651
|
},
|
|
647
652
|
onKeyDown: Z
|
|
648
653
|
},
|
|
@@ -650,8 +655,8 @@ const ae = e.forwardRef(function({
|
|
|
650
655
|
))
|
|
651
656
|
), ie);
|
|
652
657
|
});
|
|
653
|
-
|
|
658
|
+
le.displayName = "SplitButton";
|
|
654
659
|
export {
|
|
655
|
-
|
|
656
|
-
|
|
660
|
+
le as SplitButton,
|
|
661
|
+
le as default
|
|
657
662
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SplitButton.d.ts","sourceRoot":"","sources":["../../src/components/SplitButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"SplitButton.d.ts","sourceRoot":"","sources":["../../src/components/SplitButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,+BAA+B,CAAC;AAgavC,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC,GAAG;IACnF,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;IACtD,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,aAAa,CAAC;IAChD,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC7B,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IAC7C,SAAS,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAChF,CAAC;AAkCF,eAAO,MAAM,WAAW;eAhDX,KAAK,CAAC,SAAS;YAClB,MAAM;gBACF,MAAM;kBACJ,MAAM;sBACF,MAAM;cACd,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU;cAC3C,SAAS,GAAG,SAAS,GAAG,aAAa;YACvC,SAAS,GAAG,QAAQ;kBACd,SAAS,GAAG,SAAS,GAAG,MAAM;gBAChC,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ;eACvC,OAAO;YACV,eAAe,EAAE;sBACP,MAAM,IAAI;eACjB,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI;qCAyX9E,CAAC;AAIH,eAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editora/ui-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"description": "Enterprise React component library with SaaS UI components, modern design system patterns, and wrappers for Editora UI Core.",
|
|
5
5
|
"homepage": "https://editora-ecosystem.netlify.app/docs/ui-react",
|
|
6
6
|
"bugs": {
|
|
@@ -854,7 +854,7 @@
|
|
|
854
854
|
},
|
|
855
855
|
"dependencies": {
|
|
856
856
|
"@editora/toast": "^2.0.10",
|
|
857
|
-
"@editora/ui-core": "^0.2.
|
|
857
|
+
"@editora/ui-core": "^0.2.1"
|
|
858
858
|
},
|
|
859
859
|
"keywords": [
|
|
860
860
|
"editora",
|