@elementor/editor-ui 3.33.0-99 → 3.34.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/dist/index.d.mts +57 -10
- package/dist/index.d.ts +57 -10
- package/dist/index.js +223 -76
- package/dist/index.mjs +227 -73
- package/package.json +4 -4
- package/src/components/form.tsx +30 -0
- package/src/components/global-dialog/__tests__/global-dialog.test.tsx +272 -0
- package/src/components/global-dialog/__tests__/subscribers.test.ts +90 -0
- package/src/components/global-dialog/components/global-dialog.tsx +30 -0
- package/src/components/global-dialog/index.ts +2 -0
- package/src/components/global-dialog/subscribers.ts +36 -0
- package/src/components/menu-item.tsx +20 -6
- package/src/components/popover/__tests__/menu-list.test.tsx +106 -0
- package/src/components/popover/body.tsx +3 -1
- package/src/components/popover/index.ts +0 -1
- package/src/components/popover/menu-list.tsx +25 -15
- package/src/components/save-changes-dialog.tsx +106 -0
- package/src/components/{popover/search.tsx → search-field.tsx} +6 -4
- package/src/components/warning-infotip.tsx +11 -2
- package/src/hooks/__tests__/use-editable.test.tsx +255 -0
- package/src/hooks/use-editable.ts +15 -4
- package/src/index.ts +5 -0
- package/src/hooks/__tests__/use-editable.test.ts +0 -209
package/dist/index.mjs
CHANGED
|
@@ -152,7 +152,11 @@ function ThemeProvider({ children }) {
|
|
|
152
152
|
// src/components/menu-item.tsx
|
|
153
153
|
import * as React6 from "react";
|
|
154
154
|
import { forwardRef as forwardRef4 } from "react";
|
|
155
|
-
import {
|
|
155
|
+
import {
|
|
156
|
+
Infotip,
|
|
157
|
+
MenuItem,
|
|
158
|
+
MenuItemText
|
|
159
|
+
} from "@elementor/ui";
|
|
156
160
|
|
|
157
161
|
// src/components/info-alert.tsx
|
|
158
162
|
import * as React5 from "react";
|
|
@@ -171,7 +175,12 @@ var InfoAlert = (props) => /* @__PURE__ */ React5.createElement(
|
|
|
171
175
|
);
|
|
172
176
|
|
|
173
177
|
// src/components/menu-item.tsx
|
|
174
|
-
var MenuListItem = ({
|
|
178
|
+
var MenuListItem = ({
|
|
179
|
+
children,
|
|
180
|
+
menuItemTextProps,
|
|
181
|
+
primaryTypographyProps = { variant: "caption" },
|
|
182
|
+
...props
|
|
183
|
+
}) => {
|
|
175
184
|
return /* @__PURE__ */ React6.createElement(
|
|
176
185
|
MenuItem,
|
|
177
186
|
{
|
|
@@ -185,9 +194,8 @@ var MenuListItem = ({ children, ...props }) => {
|
|
|
185
194
|
MenuItemText,
|
|
186
195
|
{
|
|
187
196
|
primary: children,
|
|
188
|
-
primaryTypographyProps
|
|
189
|
-
|
|
190
|
-
}
|
|
197
|
+
primaryTypographyProps,
|
|
198
|
+
...menuItemTextProps
|
|
191
199
|
}
|
|
192
200
|
)
|
|
193
201
|
);
|
|
@@ -232,7 +240,7 @@ import { forwardRef as forwardRef5 } from "react";
|
|
|
232
240
|
import * as React8 from "react";
|
|
233
241
|
import { Alert as Alert2, AlertTitle, Infotip as Infotip2 } from "@elementor/ui";
|
|
234
242
|
var WarningInfotip = forwardRef5(
|
|
235
|
-
({ children, open, title, text, placement, width, offset }, ref) => {
|
|
243
|
+
({ children, open, title, text, placement, width, offset, hasError = true }, ref) => {
|
|
236
244
|
return /* @__PURE__ */ React8.createElement(
|
|
237
245
|
Infotip2,
|
|
238
246
|
{
|
|
@@ -247,22 +255,129 @@ var WarningInfotip = forwardRef5(
|
|
|
247
255
|
modifiers: offset ? [{ name: "offset", options: { offset } }] : []
|
|
248
256
|
},
|
|
249
257
|
arrow: false,
|
|
250
|
-
content: /* @__PURE__ */ React8.createElement(
|
|
258
|
+
content: /* @__PURE__ */ React8.createElement(
|
|
259
|
+
Alert2,
|
|
260
|
+
{
|
|
261
|
+
color: hasError ? "error" : "secondary",
|
|
262
|
+
severity: "warning",
|
|
263
|
+
variant: "standard",
|
|
264
|
+
size: "small"
|
|
265
|
+
},
|
|
266
|
+
title ? /* @__PURE__ */ React8.createElement(AlertTitle, null, title) : null,
|
|
267
|
+
text
|
|
268
|
+
)
|
|
251
269
|
},
|
|
252
270
|
children
|
|
253
271
|
);
|
|
254
272
|
}
|
|
255
273
|
);
|
|
256
274
|
|
|
257
|
-
// src/components/
|
|
275
|
+
// src/components/global-dialog/components/global-dialog.tsx
|
|
276
|
+
import { useEffect as useEffect3, useState as useState4 } from "react";
|
|
258
277
|
import * as React9 from "react";
|
|
259
|
-
import {
|
|
278
|
+
import { Dialog as Dialog2 } from "@elementor/ui";
|
|
279
|
+
|
|
280
|
+
// src/components/global-dialog/subscribers.ts
|
|
281
|
+
var currentDialogState = null;
|
|
282
|
+
var stateSubscribers = /* @__PURE__ */ new Set();
|
|
283
|
+
var subscribeToDialogState = (callback) => {
|
|
284
|
+
stateSubscribers.add(callback);
|
|
285
|
+
callback(currentDialogState);
|
|
286
|
+
return () => stateSubscribers.delete(callback);
|
|
287
|
+
};
|
|
288
|
+
var notifySubscribers = () => {
|
|
289
|
+
stateSubscribers.forEach((callback) => callback(currentDialogState));
|
|
290
|
+
};
|
|
291
|
+
var openDialog = ({ component }) => {
|
|
292
|
+
currentDialogState = { component };
|
|
293
|
+
notifySubscribers();
|
|
294
|
+
};
|
|
295
|
+
var closeDialog = () => {
|
|
296
|
+
currentDialogState = null;
|
|
297
|
+
notifySubscribers();
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// src/components/global-dialog/components/global-dialog.tsx
|
|
301
|
+
var GlobalDialog = () => {
|
|
302
|
+
const [content, setContent] = useState4(null);
|
|
303
|
+
useEffect3(() => {
|
|
304
|
+
const unsubscribe = subscribeToDialogState(setContent);
|
|
305
|
+
return () => {
|
|
306
|
+
unsubscribe();
|
|
307
|
+
};
|
|
308
|
+
}, []);
|
|
309
|
+
if (!content) {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
return /* @__PURE__ */ React9.createElement(ThemeProvider, null, /* @__PURE__ */ React9.createElement(Dialog2, { role: "dialog", open: true, onClose: closeDialog, maxWidth: "sm", fullWidth: true }, content.component));
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
// src/components/search-field.tsx
|
|
316
|
+
import * as React10 from "react";
|
|
317
|
+
import { useRef } from "react";
|
|
318
|
+
import { SearchIcon, XIcon } from "@elementor/icons";
|
|
319
|
+
import { Box as Box4, IconButton, InputAdornment, TextField } from "@elementor/ui";
|
|
320
|
+
import { __ as __2 } from "@wordpress/i18n";
|
|
321
|
+
var SIZE = "tiny";
|
|
322
|
+
var SearchField = ({ value, onSearch, placeholder, id, sx }) => {
|
|
323
|
+
const inputRef = useRef(null);
|
|
324
|
+
const handleClear = () => {
|
|
325
|
+
onSearch("");
|
|
326
|
+
inputRef.current?.focus();
|
|
327
|
+
};
|
|
328
|
+
const handleInputChange = (event) => {
|
|
329
|
+
onSearch(event.target.value);
|
|
330
|
+
};
|
|
331
|
+
return /* @__PURE__ */ React10.createElement(Box4, { sx: { px: 2, pb: 1.5, ...sx } }, /* @__PURE__ */ React10.createElement(
|
|
332
|
+
TextField,
|
|
333
|
+
{
|
|
334
|
+
autoFocus: true,
|
|
335
|
+
fullWidth: true,
|
|
336
|
+
id,
|
|
337
|
+
size: SIZE,
|
|
338
|
+
value,
|
|
339
|
+
inputRef,
|
|
340
|
+
onChange: handleInputChange,
|
|
341
|
+
placeholder,
|
|
342
|
+
InputProps: {
|
|
343
|
+
startAdornment: /* @__PURE__ */ React10.createElement(InputAdornment, { position: "start" }, /* @__PURE__ */ React10.createElement(SearchIcon, { fontSize: SIZE })),
|
|
344
|
+
endAdornment: value && /* @__PURE__ */ React10.createElement(IconButton, { size: SIZE, onClick: handleClear, "aria-label": __2("Clear", "elementor") }, /* @__PURE__ */ React10.createElement(XIcon, { color: "action", fontSize: SIZE }))
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
));
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
// src/components/form.tsx
|
|
351
|
+
import * as React11 from "react";
|
|
352
|
+
import { useRef as useRef2 } from "react";
|
|
353
|
+
var Form = ({ children, onSubmit }) => {
|
|
354
|
+
const formRef = useRef2(null);
|
|
355
|
+
const handleSubmit = (e) => {
|
|
356
|
+
e.preventDefault();
|
|
357
|
+
onSubmit?.();
|
|
358
|
+
};
|
|
359
|
+
const handleKeyDown = (e) => {
|
|
360
|
+
const { target } = e;
|
|
361
|
+
if (e.key === "Enter" && target instanceof HTMLInputElement && target.type !== "submit") {
|
|
362
|
+
e.preventDefault();
|
|
363
|
+
formRef.current?.requestSubmit();
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
return (
|
|
367
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
368
|
+
/* @__PURE__ */ React11.createElement("form", { onSubmit: handleSubmit, ref: formRef, onKeyDown: handleKeyDown }, children)
|
|
369
|
+
);
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
// src/components/popover/body.tsx
|
|
373
|
+
import * as React12 from "react";
|
|
374
|
+
import { Box as Box5 } from "@elementor/ui";
|
|
260
375
|
var SECTION_PADDING_INLINE = 32;
|
|
261
376
|
var DEFAULT_POPOVER_HEIGHT = 348;
|
|
262
377
|
var FALLBACK_POPOVER_WIDTH = 220;
|
|
263
|
-
var PopoverBody = ({ children, height = DEFAULT_POPOVER_HEIGHT, width }) => {
|
|
264
|
-
return /* @__PURE__ */
|
|
265
|
-
|
|
378
|
+
var PopoverBody = ({ children, height = DEFAULT_POPOVER_HEIGHT, width, id }) => {
|
|
379
|
+
return /* @__PURE__ */ React12.createElement(
|
|
380
|
+
Box5,
|
|
266
381
|
{
|
|
267
382
|
display: "flex",
|
|
268
383
|
flexDirection: "column",
|
|
@@ -271,16 +386,17 @@ var PopoverBody = ({ children, height = DEFAULT_POPOVER_HEIGHT, width }) => {
|
|
|
271
386
|
overflow: "hidden",
|
|
272
387
|
width: `${width ? width - SECTION_PADDING_INLINE : FALLBACK_POPOVER_WIDTH}px`,
|
|
273
388
|
maxWidth: 496
|
|
274
|
-
}
|
|
389
|
+
},
|
|
390
|
+
id
|
|
275
391
|
},
|
|
276
392
|
children
|
|
277
393
|
);
|
|
278
394
|
};
|
|
279
395
|
|
|
280
396
|
// src/components/popover/header.tsx
|
|
281
|
-
import * as
|
|
397
|
+
import * as React13 from "react";
|
|
282
398
|
import { CloseButton, Stack, Typography as Typography3 } from "@elementor/ui";
|
|
283
|
-
var
|
|
399
|
+
var SIZE2 = "tiny";
|
|
284
400
|
var PopoverHeader = ({ title, onClose, icon, actions }) => {
|
|
285
401
|
const paddingAndSizing = {
|
|
286
402
|
pl: 2,
|
|
@@ -288,23 +404,23 @@ var PopoverHeader = ({ title, onClose, icon, actions }) => {
|
|
|
288
404
|
py: 1.5,
|
|
289
405
|
maxHeight: 36
|
|
290
406
|
};
|
|
291
|
-
return /* @__PURE__ */
|
|
407
|
+
return /* @__PURE__ */ React13.createElement(Stack, { direction: "row", alignItems: "center", ...paddingAndSizing, sx: { columnGap: 0.5 } }, icon, /* @__PURE__ */ React13.createElement(Typography3, { variant: "subtitle2", sx: { fontSize: "12px", mt: 0.25 } }, title), /* @__PURE__ */ React13.createElement(Stack, { direction: "row", sx: { ml: "auto" } }, actions, /* @__PURE__ */ React13.createElement(CloseButton, { slotProps: { icon: { fontSize: SIZE2 } }, sx: { ml: "auto" }, onClick: onClose })));
|
|
292
408
|
};
|
|
293
409
|
|
|
294
410
|
// src/components/popover/menu-list.tsx
|
|
295
|
-
import * as
|
|
296
|
-
import { useMemo, useRef } from "react";
|
|
297
|
-
import { Box as
|
|
411
|
+
import * as React14 from "react";
|
|
412
|
+
import { useMemo, useRef as useRef3 } from "react";
|
|
413
|
+
import { Box as Box6, ListItem, MenuList, MenuSubheader, styled as styled2 } from "@elementor/ui";
|
|
298
414
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
299
415
|
|
|
300
416
|
// src/hooks/use-scroll-to-selected.ts
|
|
301
|
-
import { useEffect as
|
|
417
|
+
import { useEffect as useEffect4 } from "react";
|
|
302
418
|
var useScrollToSelected = ({
|
|
303
419
|
selectedValue,
|
|
304
420
|
items,
|
|
305
421
|
virtualizer
|
|
306
422
|
}) => {
|
|
307
|
-
|
|
423
|
+
useEffect4(() => {
|
|
308
424
|
if (!selectedValue || items.length === 0) {
|
|
309
425
|
return;
|
|
310
426
|
}
|
|
@@ -316,10 +432,10 @@ var useScrollToSelected = ({
|
|
|
316
432
|
};
|
|
317
433
|
|
|
318
434
|
// src/hooks/use-scroll-top.ts
|
|
319
|
-
import { useEffect as
|
|
435
|
+
import { useEffect as useEffect5, useState as useState5 } from "react";
|
|
320
436
|
var useScrollTop = ({ containerRef }) => {
|
|
321
|
-
const [scrollTop, setScrollTop] =
|
|
322
|
-
|
|
437
|
+
const [scrollTop, setScrollTop] = useState5(0);
|
|
438
|
+
useEffect5(() => {
|
|
323
439
|
const container = containerRef.current;
|
|
324
440
|
if (!container) {
|
|
325
441
|
return;
|
|
@@ -358,7 +474,7 @@ var PopoverMenuList = ({
|
|
|
358
474
|
noResultsComponent,
|
|
359
475
|
menuListTemplate: CustomMenuList
|
|
360
476
|
}) => {
|
|
361
|
-
const containerRef =
|
|
477
|
+
const containerRef = useRef3(null);
|
|
362
478
|
const scrollTop = useScrollTop({ containerRef });
|
|
363
479
|
const MenuListComponent = CustomMenuList || StyledMenuList;
|
|
364
480
|
const stickyIndices = useMemo(
|
|
@@ -392,14 +508,15 @@ var PopoverMenuList = ({
|
|
|
392
508
|
onChange
|
|
393
509
|
});
|
|
394
510
|
useScrollToSelected({ selectedValue, items, virtualizer });
|
|
395
|
-
|
|
511
|
+
const virtualItems = virtualizer.getVirtualItems();
|
|
512
|
+
return /* @__PURE__ */ React14.createElement(Box6, { ref: containerRef, sx: { height: "100%", overflowY: "auto" } }, items.length === 0 && noResultsComponent ? noResultsComponent : /* @__PURE__ */ React14.createElement(
|
|
396
513
|
MenuListComponent,
|
|
397
514
|
{
|
|
398
515
|
role: "listbox",
|
|
399
516
|
style: { height: `${virtualizer.getTotalSize()}px` },
|
|
400
517
|
"data-testid": dataTestId
|
|
401
518
|
},
|
|
402
|
-
|
|
519
|
+
virtualItems.map((virtualRow) => {
|
|
403
520
|
const item = items[virtualRow.index];
|
|
404
521
|
const isLast = virtualRow.index === items.length - 1;
|
|
405
522
|
const isFirst = items[0]?.type === "category" ? virtualRow.index === 1 : virtualRow.index === 0;
|
|
@@ -410,7 +527,7 @@ var PopoverMenuList = ({
|
|
|
410
527
|
}
|
|
411
528
|
if (item.type === "category") {
|
|
412
529
|
const shouldStick = virtualRow.start + MENU_LIST_PADDING_TOP <= scrollTop;
|
|
413
|
-
return /* @__PURE__ */
|
|
530
|
+
return /* @__PURE__ */ React14.createElement(
|
|
414
531
|
MenuSubheader,
|
|
415
532
|
{
|
|
416
533
|
key: virtualRow.key,
|
|
@@ -420,13 +537,15 @@ var PopoverMenuList = ({
|
|
|
420
537
|
item.label || item.value
|
|
421
538
|
);
|
|
422
539
|
}
|
|
423
|
-
|
|
424
|
-
|
|
540
|
+
const isDisabled = item.disabled;
|
|
541
|
+
return /* @__PURE__ */ React14.createElement(
|
|
542
|
+
ListItem,
|
|
425
543
|
{
|
|
426
544
|
key: virtualRow.key,
|
|
427
545
|
role: "option",
|
|
428
546
|
"aria-selected": isSelected,
|
|
429
|
-
|
|
547
|
+
"aria-disabled": isDisabled,
|
|
548
|
+
onClick: isDisabled ? void 0 : (e) => {
|
|
430
549
|
if (e.target.closest("button")) {
|
|
431
550
|
return;
|
|
432
551
|
}
|
|
@@ -434,7 +553,7 @@ var PopoverMenuList = ({
|
|
|
434
553
|
onClose();
|
|
435
554
|
},
|
|
436
555
|
onKeyDown: (event) => {
|
|
437
|
-
if (event.key === "Enter") {
|
|
556
|
+
if (event.key === "Enter" && !isDisabled) {
|
|
438
557
|
onSelect(item.value);
|
|
439
558
|
onClose();
|
|
440
559
|
}
|
|
@@ -448,7 +567,7 @@ var PopoverMenuList = ({
|
|
|
448
567
|
}
|
|
449
568
|
},
|
|
450
569
|
tabIndex: isSelected ? 0 : tabIndexFallback,
|
|
451
|
-
|
|
570
|
+
sx: {
|
|
452
571
|
transform: `translateY(${virtualRow.start + MENU_LIST_PADDING_TOP}px)`,
|
|
453
572
|
...itemStyle ? itemStyle(item) : {}
|
|
454
573
|
}
|
|
@@ -475,6 +594,9 @@ var StyledMenuList = styled2(MenuList)(({ theme }) => ({
|
|
|
475
594
|
'&[aria-selected="true"]': {
|
|
476
595
|
backgroundColor: theme.palette.action.selected
|
|
477
596
|
},
|
|
597
|
+
'&[aria-disabled="true"]': {
|
|
598
|
+
color: theme.palette.text.disabled
|
|
599
|
+
},
|
|
478
600
|
cursor: "pointer",
|
|
479
601
|
textOverflow: "ellipsis",
|
|
480
602
|
position: "absolute",
|
|
@@ -485,58 +607,75 @@ var StyledMenuList = styled2(MenuList)(({ theme }) => ({
|
|
|
485
607
|
position: "relative"
|
|
486
608
|
}));
|
|
487
609
|
|
|
488
|
-
// src/components/
|
|
489
|
-
import * as
|
|
490
|
-
import {
|
|
491
|
-
import {
|
|
492
|
-
import {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
610
|
+
// src/components/save-changes-dialog.tsx
|
|
611
|
+
import * as React15 from "react";
|
|
612
|
+
import { useState as useState6 } from "react";
|
|
613
|
+
import { AlertTriangleFilledIcon, XIcon as XIcon2 } from "@elementor/icons";
|
|
614
|
+
import {
|
|
615
|
+
Button as Button3,
|
|
616
|
+
Dialog as Dialog3,
|
|
617
|
+
DialogActions as DialogActions2,
|
|
618
|
+
DialogContent,
|
|
619
|
+
DialogContentText,
|
|
620
|
+
DialogTitle as DialogTitle2,
|
|
621
|
+
IconButton as IconButton2,
|
|
622
|
+
Stack as Stack2
|
|
623
|
+
} from "@elementor/ui";
|
|
624
|
+
var TITLE_ID = "save-changes-dialog";
|
|
625
|
+
var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React15.createElement(Dialog3, { open: true, onClose, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, children);
|
|
626
|
+
var SaveChangesDialogTitle = ({ children, onClose }) => /* @__PURE__ */ React15.createElement(
|
|
627
|
+
DialogTitle2,
|
|
628
|
+
{
|
|
629
|
+
id: TITLE_ID,
|
|
630
|
+
display: "flex",
|
|
631
|
+
alignItems: "center",
|
|
632
|
+
gap: 1,
|
|
633
|
+
sx: { lineHeight: 1, justifyContent: "space-between" }
|
|
634
|
+
},
|
|
635
|
+
/* @__PURE__ */ React15.createElement(Stack2, { direction: "row", alignItems: "center", gap: 1 }, /* @__PURE__ */ React15.createElement(AlertTriangleFilledIcon, { color: "secondary" }), children),
|
|
636
|
+
onClose && /* @__PURE__ */ React15.createElement(IconButton2, { onClick: onClose, size: "small" }, /* @__PURE__ */ React15.createElement(XIcon2, null))
|
|
637
|
+
);
|
|
638
|
+
var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React15.createElement(DialogContent, null, children);
|
|
639
|
+
var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React15.createElement(DialogContentText, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
|
|
640
|
+
var SaveChangesDialogActions = ({ actions }) => {
|
|
641
|
+
const [isConfirming, setIsConfirming] = useState6(false);
|
|
642
|
+
const { cancel, confirm, discard } = actions;
|
|
643
|
+
const onConfirm = async () => {
|
|
644
|
+
setIsConfirming(true);
|
|
645
|
+
await confirm.action();
|
|
646
|
+
setIsConfirming(false);
|
|
503
647
|
};
|
|
504
|
-
return /* @__PURE__ */
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
startAdornment: /* @__PURE__ */ React12.createElement(InputAdornment, { position: "start" }, /* @__PURE__ */ React12.createElement(SearchIcon, { fontSize: SIZE2 })),
|
|
516
|
-
endAdornment: value && /* @__PURE__ */ React12.createElement(IconButton, { size: SIZE2, onClick: handleClear, "aria-label": __2("Clear", "elementor") }, /* @__PURE__ */ React12.createElement(XIcon, { color: "action", fontSize: SIZE2 }))
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
));
|
|
648
|
+
return /* @__PURE__ */ React15.createElement(DialogActions2, null, cancel && /* @__PURE__ */ React15.createElement(Button3, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), discard && /* @__PURE__ */ React15.createElement(Button3, { variant: "text", color: "secondary", onClick: discard.action }, discard.label), /* @__PURE__ */ React15.createElement(Button3, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
|
|
649
|
+
};
|
|
650
|
+
SaveChangesDialog.Title = SaveChangesDialogTitle;
|
|
651
|
+
SaveChangesDialog.Content = SaveChangesDialogContent;
|
|
652
|
+
SaveChangesDialog.ContentText = SaveChangesDialogContentText;
|
|
653
|
+
SaveChangesDialog.Actions = SaveChangesDialogActions;
|
|
654
|
+
var useDialog = () => {
|
|
655
|
+
const [isOpen, setIsOpen] = useState6(false);
|
|
656
|
+
const open = () => setIsOpen(true);
|
|
657
|
+
const close = () => setIsOpen(false);
|
|
658
|
+
return { isOpen, open, close };
|
|
520
659
|
};
|
|
521
660
|
|
|
522
661
|
// src/hooks/use-editable.ts
|
|
523
|
-
import { useEffect as
|
|
662
|
+
import { useEffect as useEffect6, useRef as useRef4, useState as useState7 } from "react";
|
|
524
663
|
var useEditable = ({ value, onSubmit, validation, onClick, onError }) => {
|
|
525
|
-
const [isEditing, setIsEditing] =
|
|
526
|
-
const [error, setError] =
|
|
664
|
+
const [isEditing, setIsEditing] = useState7(false);
|
|
665
|
+
const [error, setError] = useState7(null);
|
|
527
666
|
const ref = useSelection(isEditing);
|
|
528
667
|
const isDirty = (newValue) => newValue !== value;
|
|
529
668
|
const openEditMode = () => {
|
|
530
669
|
setIsEditing(true);
|
|
531
670
|
};
|
|
532
671
|
const closeEditMode = () => {
|
|
533
|
-
ref.current?.blur();
|
|
534
672
|
setError(null);
|
|
535
673
|
onError?.(null);
|
|
536
674
|
setIsEditing(false);
|
|
537
675
|
};
|
|
538
676
|
const submit = (newValue) => {
|
|
539
677
|
if (!isDirty(newValue)) {
|
|
678
|
+
closeEditMode();
|
|
540
679
|
return;
|
|
541
680
|
}
|
|
542
681
|
if (!error) {
|
|
@@ -562,7 +701,9 @@ var useEditable = ({ value, onSubmit, validation, onClick, onError }) => {
|
|
|
562
701
|
}
|
|
563
702
|
if (["Enter"].includes(event.key)) {
|
|
564
703
|
event.preventDefault();
|
|
565
|
-
|
|
704
|
+
if (!error) {
|
|
705
|
+
ref.current?.blur();
|
|
706
|
+
}
|
|
566
707
|
}
|
|
567
708
|
};
|
|
568
709
|
const handleClick = (event) => {
|
|
@@ -571,11 +712,18 @@ var useEditable = ({ value, onSubmit, validation, onClick, onError }) => {
|
|
|
571
712
|
}
|
|
572
713
|
onClick?.(event);
|
|
573
714
|
};
|
|
715
|
+
const handleBlur = () => {
|
|
716
|
+
if (error) {
|
|
717
|
+
closeEditMode();
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
submit(ref.current.innerText);
|
|
721
|
+
};
|
|
574
722
|
const listeners = {
|
|
575
723
|
onClick: handleClick,
|
|
576
724
|
onKeyDown: handleKeyDown,
|
|
577
725
|
onInput: onChange,
|
|
578
|
-
onBlur:
|
|
726
|
+
onBlur: handleBlur
|
|
579
727
|
};
|
|
580
728
|
const attributes = {
|
|
581
729
|
value,
|
|
@@ -596,8 +744,8 @@ var useEditable = ({ value, onSubmit, validation, onClick, onError }) => {
|
|
|
596
744
|
};
|
|
597
745
|
};
|
|
598
746
|
var useSelection = (isEditing) => {
|
|
599
|
-
const ref =
|
|
600
|
-
|
|
747
|
+
const ref = useRef4(null);
|
|
748
|
+
useEffect6(() => {
|
|
601
749
|
if (isEditing) {
|
|
602
750
|
selectAll(ref.current);
|
|
603
751
|
}
|
|
@@ -617,6 +765,8 @@ var selectAll = (el) => {
|
|
|
617
765
|
export {
|
|
618
766
|
EditableField,
|
|
619
767
|
EllipsisWithTooltip,
|
|
768
|
+
Form,
|
|
769
|
+
GlobalDialog,
|
|
620
770
|
ITEM_HEIGHT,
|
|
621
771
|
InfoAlert,
|
|
622
772
|
InfoTipCard,
|
|
@@ -626,10 +776,14 @@ export {
|
|
|
626
776
|
PopoverBody,
|
|
627
777
|
PopoverHeader,
|
|
628
778
|
PopoverMenuList,
|
|
629
|
-
|
|
779
|
+
SaveChangesDialog,
|
|
780
|
+
SearchField,
|
|
630
781
|
StyledMenuList,
|
|
631
782
|
ThemeProvider,
|
|
632
783
|
WarningInfotip,
|
|
784
|
+
closeDialog,
|
|
785
|
+
openDialog,
|
|
786
|
+
useDialog,
|
|
633
787
|
useEditable
|
|
634
788
|
};
|
|
635
789
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-ui",
|
|
3
3
|
"description": "Elementor Editor UI",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.34.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"react-dom": "^18.3.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@elementor/editor-v1-adapters": "3.
|
|
41
|
-
"@elementor/icons": "1.
|
|
42
|
-
"@elementor/ui": "1.36.
|
|
40
|
+
"@elementor/editor-v1-adapters": "3.34.2",
|
|
41
|
+
"@elementor/icons": "^1.61.0",
|
|
42
|
+
"@elementor/ui": "1.36.17",
|
|
43
43
|
"@tanstack/react-virtual": "^3.13.3",
|
|
44
44
|
"@wordpress/i18n": "^5.13.0"
|
|
45
45
|
},
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type FormEvent as FormEvent, type KeyboardEvent, type PropsWithChildren, useRef } from 'react';
|
|
3
|
+
|
|
4
|
+
type Props = PropsWithChildren< {
|
|
5
|
+
onSubmit?: () => void;
|
|
6
|
+
} >;
|
|
7
|
+
export const Form = ( { children, onSubmit }: Props ) => {
|
|
8
|
+
const formRef = useRef< HTMLFormElement >( null );
|
|
9
|
+
|
|
10
|
+
const handleSubmit = ( e: FormEvent< HTMLFormElement > | SubmitEvent ) => {
|
|
11
|
+
e.preventDefault();
|
|
12
|
+
onSubmit?.();
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const handleKeyDown = ( e: KeyboardEvent< HTMLFormElement > ) => {
|
|
16
|
+
const { target } = e;
|
|
17
|
+
if ( e.key === 'Enter' && target instanceof HTMLInputElement && target.type !== 'submit' ) {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
|
|
20
|
+
formRef.current?.requestSubmit();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
26
|
+
<form onSubmit={ handleSubmit } ref={ formRef } onKeyDown={ handleKeyDown }>
|
|
27
|
+
{ children }
|
|
28
|
+
</form>
|
|
29
|
+
);
|
|
30
|
+
};
|