@elementor/editor-ui 0.4.3 → 0.5.1

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @elementor/editor-ui@0.4.3 build
2
+ > @elementor/editor-ui@0.5.1 build
3
3
  > tsup --config=../../tsup.build.ts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -10,13 +10,13 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- ESM dist/index.mjs 5.55 KB
14
- ESM dist/index.mjs.map 10.96 KB
15
- ESM ⚡️ Build success in 173ms
16
- CJS dist/index.js 7.44 KB
17
- CJS dist/index.js.map 11.24 KB
18
- CJS ⚡️ Build success in 163ms
13
+ ESM dist/index.mjs 7.57 KB
14
+ ESM dist/index.mjs.map 14.92 KB
15
+ ESM ⚡️ Build success in 149ms
16
+ CJS dist/index.js 9.64 KB
17
+ CJS dist/index.js.map 15.26 KB
18
+ CJS ⚡️ Build success in 135ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 42627ms
21
- DTS dist/index.d.mts 1.75 KB
22
- DTS dist/index.d.ts 1.75 KB
20
+ DTS ⚡️ Build success in 17237ms
21
+ DTS dist/index.d.mts 2.09 KB
22
+ DTS dist/index.d.ts 2.09 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @elementor/editor-ui
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 666ffdd: Change theme provider styles for editing panel and class manager panel
8
+
9
+ ## 0.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 50938e4: Change controls menus text style
14
+
3
15
  ## 0.4.3
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as React$1 from 'react';
2
+ import { MenuItemProps } from '@elementor/ui';
2
3
 
3
4
  type EllipsisWithTooltipProps<T extends React$1.ElementType> = {
4
5
  maxWidth?: React$1.CSSProperties['maxWidth'];
@@ -12,10 +13,20 @@ declare const EditableField: React$1.ForwardRefExoticComponent<Omit<any, "ref">
12
13
  type IntroductionModalProps = {
13
14
  open: boolean;
14
15
  handleClose: (shouldShowAgain: boolean) => void;
15
- title: string;
16
+ title?: string;
16
17
  content: React$1.ReactNode;
18
+ image?: {
19
+ src: string;
20
+ alt: string;
21
+ };
17
22
  };
18
- declare const IntroductionModal: ({ open, handleClose, title, content }: IntroductionModalProps) => React$1.JSX.Element;
23
+ declare const IntroductionModal: ({ open, handleClose, title, content, image }: IntroductionModalProps) => React$1.JSX.Element;
24
+
25
+ declare function ThemeProvider({ children }: {
26
+ children: React$1.ReactNode;
27
+ }): React$1.JSX.Element;
28
+
29
+ declare const MenuListItem: ({ children, ...props }: MenuItemProps) => React$1.JSX.Element;
19
30
 
20
31
  type UseEditableParams = {
21
32
  value: string;
@@ -42,4 +53,4 @@ declare const useEditable: ({ value, onSubmit, validation, onClick }: UseEditabl
42
53
  };
43
54
  };
44
55
 
45
- export { EditableField, EllipsisWithTooltip, IntroductionModal, useEditable };
56
+ export { EditableField, EllipsisWithTooltip, IntroductionModal, MenuListItem, ThemeProvider, useEditable };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as React$1 from 'react';
2
+ import { MenuItemProps } from '@elementor/ui';
2
3
 
3
4
  type EllipsisWithTooltipProps<T extends React$1.ElementType> = {
4
5
  maxWidth?: React$1.CSSProperties['maxWidth'];
@@ -12,10 +13,20 @@ declare const EditableField: React$1.ForwardRefExoticComponent<Omit<any, "ref">
12
13
  type IntroductionModalProps = {
13
14
  open: boolean;
14
15
  handleClose: (shouldShowAgain: boolean) => void;
15
- title: string;
16
+ title?: string;
16
17
  content: React$1.ReactNode;
18
+ image?: {
19
+ src: string;
20
+ alt: string;
21
+ };
17
22
  };
18
- declare const IntroductionModal: ({ open, handleClose, title, content }: IntroductionModalProps) => React$1.JSX.Element;
23
+ declare const IntroductionModal: ({ open, handleClose, title, content, image }: IntroductionModalProps) => React$1.JSX.Element;
24
+
25
+ declare function ThemeProvider({ children }: {
26
+ children: React$1.ReactNode;
27
+ }): React$1.JSX.Element;
28
+
29
+ declare const MenuListItem: ({ children, ...props }: MenuItemProps) => React$1.JSX.Element;
19
30
 
20
31
  type UseEditableParams = {
21
32
  value: string;
@@ -42,4 +53,4 @@ declare const useEditable: ({ value, onSubmit, validation, onClick }: UseEditabl
42
53
  };
43
54
  };
44
55
 
45
- export { EditableField, EllipsisWithTooltip, IntroductionModal, useEditable };
56
+ export { EditableField, EllipsisWithTooltip, IntroductionModal, MenuListItem, ThemeProvider, useEditable };
package/dist/index.js CHANGED
@@ -33,6 +33,8 @@ __export(index_exports, {
33
33
  EditableField: () => EditableField,
34
34
  EllipsisWithTooltip: () => EllipsisWithTooltip,
35
35
  IntroductionModal: () => IntroductionModal,
36
+ MenuListItem: () => MenuListItem,
37
+ ThemeProvider: () => ThemeProvider,
36
38
  useEditable: () => useEditable
37
39
  });
38
40
  module.exports = __toCommonJS(index_exports);
@@ -103,7 +105,7 @@ var import_react3 = require("react");
103
105
  var import_ui3 = require("@elementor/ui");
104
106
  var import_i18n = require("@wordpress/i18n");
105
107
  var OPEN_DELAY = 1e3;
106
- var IntroductionModal = ({ open, handleClose, title, content }) => {
108
+ var IntroductionModal = ({ open, handleClose, title, content, image }) => {
107
109
  const [shouldShowAgain, setShouldShowAgain] = (0, import_react3.useState)(true);
108
110
  return /* @__PURE__ */ React3.createElement(
109
111
  import_ui3.Dialog,
@@ -116,7 +118,8 @@ var IntroductionModal = ({ open, handleClose, title, content }) => {
116
118
  style: { transitionDelay: open ? `${OPEN_DELAY}ms` : "0ms" }
117
119
  }
118
120
  },
119
- /* @__PURE__ */ React3.createElement(import_ui3.DialogHeader, { logo: false }, /* @__PURE__ */ React3.createElement(import_ui3.DialogTitle, null, title)),
121
+ title && /* @__PURE__ */ React3.createElement(import_ui3.DialogHeader, { logo: false }, /* @__PURE__ */ React3.createElement(import_ui3.DialogTitle, null, title)),
122
+ image && /* @__PURE__ */ React3.createElement(import_ui3.Image, { sx: { width: "100%" }, src: image.src, alt: image.alt }),
120
123
  content,
121
124
  /* @__PURE__ */ React3.createElement(import_ui3.DialogActions, null, /* @__PURE__ */ React3.createElement(
122
125
  import_ui3.FormControlLabel,
@@ -129,17 +132,76 @@ var IntroductionModal = ({ open, handleClose, title, content }) => {
129
132
  onChange: () => setShouldShowAgain(!shouldShowAgain)
130
133
  }
131
134
  ),
132
- label: (0, import_i18n.__)("Don't show this again", "elementor")
135
+ label: /* @__PURE__ */ React3.createElement(import_ui3.Typography, { variant: "body2" }, (0, import_i18n.__)("Don't show this again", "elementor"))
133
136
  }
134
137
  ), /* @__PURE__ */ React3.createElement(import_ui3.Button, { size: "medium", onClick: () => handleClose(shouldShowAgain), variant: "contained" }, (0, import_i18n.__)("Got it", "elementor")))
135
138
  );
136
139
  };
137
140
 
138
- // src/hooks/use-editable.ts
141
+ // src/components/theme-provider.tsx
142
+ var React4 = __toESM(require("react"));
143
+ var import_ui4 = require("@elementor/ui");
144
+
145
+ // src/hooks/use-color-scheme.ts
139
146
  var import_react4 = require("react");
147
+ var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
148
+ function useColorScheme() {
149
+ const [colorScheme, setColorScheme] = (0, import_react4.useState)(() => getV1ColorScheme());
150
+ (0, import_react4.useEffect)(() => {
151
+ return (0, import_editor_v1_adapters.__privateListenTo)((0, import_editor_v1_adapters.v1ReadyEvent)(), () => setColorScheme(getV1ColorScheme()));
152
+ }, []);
153
+ (0, import_react4.useEffect)(() => {
154
+ return (0, import_editor_v1_adapters.__privateListenTo)((0, import_editor_v1_adapters.commandEndEvent)("document/elements/settings"), (e) => {
155
+ const event = e;
156
+ const isColorScheme = event.args?.settings && "ui_theme" in event.args.settings;
157
+ if (isColorScheme) {
158
+ setColorScheme(getV1ColorScheme());
159
+ }
160
+ });
161
+ }, []);
162
+ return colorScheme;
163
+ }
164
+ function getV1ColorScheme() {
165
+ return window.elementor?.getPreferences?.("ui_theme") || "auto";
166
+ }
167
+
168
+ // src/components/theme-provider.tsx
169
+ var EDITOR_PALLETTE = "unstable";
170
+ function ThemeProvider({ children }) {
171
+ const colorScheme = useColorScheme();
172
+ return /* @__PURE__ */ React4.createElement(import_ui4.ThemeProvider, { colorScheme, palette: EDITOR_PALLETTE }, children);
173
+ }
174
+
175
+ // src/components/menu-item.tsx
176
+ var React5 = __toESM(require("react"));
177
+ var import_ui5 = require("@elementor/ui");
178
+ var MenuListItem = ({ children, ...props }) => {
179
+ return /* @__PURE__ */ React5.createElement(
180
+ import_ui5.MenuItem,
181
+ {
182
+ dense: true,
183
+ ...props,
184
+ sx: {
185
+ ...props.sx ?? {}
186
+ }
187
+ },
188
+ /* @__PURE__ */ React5.createElement(
189
+ import_ui5.MenuItemText,
190
+ {
191
+ primary: children,
192
+ primaryTypographyProps: {
193
+ variant: "caption"
194
+ }
195
+ }
196
+ )
197
+ );
198
+ };
199
+
200
+ // src/hooks/use-editable.ts
201
+ var import_react5 = require("react");
140
202
  var useEditable = ({ value, onSubmit, validation, onClick }) => {
141
- const [isEditing, setIsEditing] = (0, import_react4.useState)(false);
142
- const [error, setError] = (0, import_react4.useState)(null);
203
+ const [isEditing, setIsEditing] = (0, import_react5.useState)(false);
204
+ const [error, setError] = (0, import_react5.useState)(null);
143
205
  const ref = useSelection(isEditing);
144
206
  const isDirty = (newValue) => newValue !== value;
145
207
  const openEditMode = () => {
@@ -209,8 +271,8 @@ var useEditable = ({ value, onSubmit, validation, onClick }) => {
209
271
  };
210
272
  };
211
273
  var useSelection = (isEditing) => {
212
- const ref = (0, import_react4.useRef)(null);
213
- (0, import_react4.useEffect)(() => {
274
+ const ref = (0, import_react5.useRef)(null);
275
+ (0, import_react5.useEffect)(() => {
214
276
  if (isEditing) {
215
277
  selectAll(ref.current);
216
278
  }
@@ -232,6 +294,8 @@ var selectAll = (el) => {
232
294
  EditableField,
233
295
  EllipsisWithTooltip,
234
296
  IntroductionModal,
297
+ MenuListItem,
298
+ ThemeProvider,
235
299
  useEditable
236
300
  });
237
301
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/components/ellipsis-with-tooltip.tsx","../src/components/editable-field.tsx","../src/components/introduction-modal.tsx","../src/hooks/use-editable.ts"],"sourcesContent":["// components\nexport { EllipsisWithTooltip } from './components/ellipsis-with-tooltip';\nexport { EditableField } from './components/editable-field';\nexport { IntroductionModal } from './components/introduction-modal';\n\n// hooks\nexport { useEditable } from './hooks/use-editable';\n","import * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport { Box, Tooltip } from '@elementor/ui';\n\ntype EllipsisWithTooltipProps< T extends React.ElementType > = {\n\tmaxWidth?: React.CSSProperties[ 'maxWidth' ];\n\ttitle: string;\n\tas?: T;\n} & React.ComponentProps< T >;\n\nexport const EllipsisWithTooltip = < T extends React.ElementType >( {\n\tmaxWidth,\n\ttitle,\n\tas,\n\t...props\n}: EllipsisWithTooltipProps< T > ) => {\n\tconst [ setRef, isOverflowing ] = useIsOverflowing();\n\n\tif ( isOverflowing ) {\n\t\treturn (\n\t\t\t<Tooltip title={ title } placement=\"top\">\n\t\t\t\t<Content maxWidth={ maxWidth } ref={ setRef } as={ as } { ...props }>\n\t\t\t\t\t{ title }\n\t\t\t\t</Content>\n\t\t\t</Tooltip>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Content maxWidth={ maxWidth } ref={ setRef } as={ as } { ...props }>\n\t\t\t{ title }\n\t\t</Content>\n\t);\n};\n\ntype ContentProps< T extends React.ElementType > = React.PropsWithChildren<\n\tOmit< EllipsisWithTooltipProps< T >, 'title' >\n>;\n\nconst Content = React.forwardRef(\n\t< T extends React.ElementType >(\n\t\t{ maxWidth, as: Component = Box, ...props }: ContentProps< T >,\n\t\t// forwardRef loses the typing when using generic components.\n\t\tref: unknown\n\t) => (\n\t\t<Component\n\t\t\tref={ ref }\n\t\t\tposition=\"relative\"\n\t\t\t{ ...props }\n\t\t\tstyle={ { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', maxWidth } }\n\t\t/>\n\t)\n);\n\nconst useIsOverflowing = () => {\n\tconst [ el, setEl ] = useState< HTMLElement | null >( null );\n\tconst [ isOverflowing, setIsOverflown ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst observer = new ResizeObserver( ( [ { target } ] ) => {\n\t\t\tsetIsOverflown( target.scrollWidth > target.clientWidth );\n\t\t} );\n\n\t\tif ( el ) {\n\t\t\tobserver.observe( el );\n\t\t}\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ el ] );\n\n\treturn [ setEl, isOverflowing ] as const;\n};\n","import * as React from 'react';\nimport { forwardRef } from 'react';\nimport { Box, styled, Tooltip } from '@elementor/ui';\n\ntype EditableFieldProps< T extends React.ElementType > = {\n\tvalue: string;\n\terror?: string;\n\tas?: T;\n} & React.ComponentPropsWithRef< T >;\n\nexport const EditableField = forwardRef(\n\t< T extends React.ElementType >(\n\t\t{ value, error, as = 'span', sx, ...props }: EditableFieldProps< T >,\n\t\tref: unknown\n\t) => {\n\t\treturn (\n\t\t\t<Tooltip title={ error } open={ !! error } placement=\"top\">\n\t\t\t\t<StyledField ref={ ref } component={ as } { ...props }>\n\t\t\t\t\t{ value }\n\t\t\t\t</StyledField>\n\t\t\t</Tooltip>\n\t\t);\n\t}\n);\n\nconst StyledField = styled( Box )`\n\twidth: 100%;\n\t&:focus {\n\t\toutline: none;\n\t}\n`;\n","import * as React from 'react';\nimport { useState } from 'react';\nimport { Button, Checkbox, Dialog, DialogActions, DialogHeader, DialogTitle, FormControlLabel } from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\ntype IntroductionModalProps = {\n\topen: boolean;\n\thandleClose: ( shouldShowAgain: boolean ) => void;\n\ttitle: string;\n\tcontent: React.ReactNode;\n};\n\nconst OPEN_DELAY = 1000;\n\nexport const IntroductionModal = ( { open, handleClose, title, content }: IntroductionModalProps ) => {\n\tconst [ shouldShowAgain, setShouldShowAgain ] = useState( true );\n\n\treturn (\n\t\t<Dialog\n\t\t\topen={ open }\n\t\t\tonClose={ handleClose }\n\t\t\tmaxWidth={ 'sm' }\n\t\t\tTransitionProps={ {\n\t\t\t\ttimeout: 700,\n\t\t\t\tstyle: { transitionDelay: open ? `${ OPEN_DELAY }ms` : '0ms' },\n\t\t\t} }\n\t\t>\n\t\t\t<DialogHeader logo={ false }>\n\t\t\t\t<DialogTitle>{ title }</DialogTitle>\n\t\t\t</DialogHeader>\n\t\t\t{ content }\n\t\t\t<DialogActions>\n\t\t\t\t<FormControlLabel\n\t\t\t\t\tsx={ { marginRight: 'auto' } }\n\t\t\t\t\tcontrol={\n\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\tchecked={ ! shouldShowAgain }\n\t\t\t\t\t\t\tonChange={ () => setShouldShowAgain( ! shouldShowAgain ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\tlabel={ __( \"Don't show this again\", 'elementor' ) }\n\t\t\t\t/>\n\t\t\t\t<Button size={ 'medium' } onClick={ () => handleClose( shouldShowAgain ) } variant=\"contained\">\n\t\t\t\t\t{ __( 'Got it', 'elementor' ) }\n\t\t\t\t</Button>\n\t\t\t</DialogActions>\n\t\t</Dialog>\n\t);\n};\n","import { useEffect, useRef, useState } from 'react';\n\ntype UseEditableParams = {\n\tvalue: string;\n\tonSubmit: ( value: string ) => unknown;\n\tvalidation?: ( value: string ) => string | null;\n\tonClick?: ( event: React.MouseEvent< HTMLDivElement > ) => void;\n};\n\nexport const useEditable = ( { value, onSubmit, validation, onClick }: UseEditableParams ) => {\n\tconst [ isEditing, setIsEditing ] = useState( false );\n\tconst [ error, setError ] = useState< string | null >( null );\n\n\tconst ref = useSelection( isEditing );\n\n\tconst isDirty = ( newValue: string ) => newValue !== value;\n\n\tconst openEditMode = () => {\n\t\tsetIsEditing( true );\n\t};\n\n\tconst closeEditMode = () => {\n\t\tref.current?.blur();\n\n\t\tsetError( null );\n\t\tsetIsEditing( false );\n\t};\n\n\tconst submit = ( newValue: string ) => {\n\t\tif ( ! isDirty( newValue ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! error ) {\n\t\t\ttry {\n\t\t\t\tonSubmit( newValue );\n\t\t\t} finally {\n\t\t\t\tcloseEditMode();\n\t\t\t}\n\t\t}\n\t};\n\n\tconst onChange = ( event: React.ChangeEvent< HTMLSpanElement > ) => {\n\t\tconst { innerText: newValue } = event.target;\n\n\t\tif ( validation ) {\n\t\t\tsetError( isDirty( newValue ) ? validation( newValue ) : null );\n\t\t}\n\t};\n\n\tconst handleKeyDown = ( event: React.KeyboardEvent ) => {\n\t\tevent.stopPropagation();\n\n\t\tif ( [ 'Escape' ].includes( event.key ) ) {\n\t\t\treturn closeEditMode();\n\t\t}\n\n\t\tif ( [ 'Enter' ].includes( event.key ) ) {\n\t\t\tevent.preventDefault();\n\t\t\treturn submit( ( event.target as HTMLElement ).innerText );\n\t\t}\n\t};\n\n\tconst handleClick = ( event: React.MouseEvent< HTMLDivElement > ) => {\n\t\tif ( isEditing ) {\n\t\t\tevent.stopPropagation();\n\t\t}\n\n\t\tonClick?.( event );\n\t};\n\n\tconst listeners = {\n\t\tonClick: handleClick,\n\t\tonKeyDown: handleKeyDown,\n\t\tonInput: onChange,\n\t\tonBlur: closeEditMode,\n\t} as const;\n\n\tconst attributes = {\n\t\tvalue,\n\t\trole: 'textbox',\n\t\tcontentEditable: isEditing,\n\t\t...( isEditing && {\n\t\t\tsuppressContentEditableWarning: true,\n\t\t} ),\n\t} as const;\n\n\treturn {\n\t\tref,\n\t\tisEditing,\n\t\topenEditMode,\n\t\tcloseEditMode,\n\t\tvalue,\n\t\terror,\n\t\tgetProps: () => ( { ...listeners, ...attributes } ),\n\t} as const;\n};\n\nconst useSelection = ( isEditing: boolean ) => {\n\tconst ref = useRef< HTMLElement | null >( null );\n\n\tuseEffect( () => {\n\t\tif ( isEditing ) {\n\t\t\tselectAll( ref.current );\n\t\t}\n\t}, [ isEditing ] );\n\n\treturn ref;\n};\n\nconst selectAll = ( el: HTMLElement | null ) => {\n\tconst selection = getSelection();\n\n\tif ( ! selection || ! el ) {\n\t\treturn;\n\t}\n\n\tconst range = document.createRange();\n\trange.selectNodeContents( el );\n\n\tselection.removeAllRanges();\n\tselection.addRange( range );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,mBAAoC;AACpC,gBAA6B;AAQtB,IAAM,sBAAsB,CAAiC;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,MAAsC;AACrC,QAAM,CAAE,QAAQ,aAAc,IAAI,iBAAiB;AAEnD,MAAK,eAAgB;AACpB,WACC,oCAAC,qBAAQ,OAAgB,WAAU,SAClC,oCAAC,WAAQ,UAAsB,KAAM,QAAS,IAAY,GAAG,SAC1D,KACH,CACD;AAAA,EAEF;AAEA,SACC,oCAAC,WAAQ,UAAsB,KAAM,QAAS,IAAY,GAAG,SAC1D,KACH;AAEF;AAMA,IAAM,UAAgB;AAAA,EACrB,CACC,EAAE,UAAU,IAAI,YAAY,eAAK,GAAG,MAAM,GAE1C,QAEA;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,UAAS;AAAA,MACP,GAAG;AAAA,MACL,OAAQ,EAAE,UAAU,UAAU,cAAc,YAAY,YAAY,UAAU,SAAS;AAAA;AAAA,EACxF;AAEF;AAEA,IAAM,mBAAmB,MAAM;AAC9B,QAAM,CAAE,IAAI,KAAM,QAAI,uBAAgC,IAAK;AAC3D,QAAM,CAAE,eAAe,cAAe,QAAI,uBAAU,KAAM;AAE1D,8BAAW,MAAM;AAChB,UAAM,WAAW,IAAI,eAAgB,CAAE,CAAE,EAAE,OAAO,CAAE,MAAO;AAC1D,qBAAgB,OAAO,cAA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,aAAO,OAAU,MAAM,OAAwB,SAAU;AAAA,IAC1D;AAAA,EACD;AAEA,QAAM,cAAc,CAAE,UAA+C;AACpE,QAAK,WAAY;AAChB,YAAM,gBAAgB;AAAA,IACvB;AAEA,cAAW,KAAM;AAAA,EAClB;AAEA,QAAM,YAAY;AAAA,IACjB,SAAS;AAAA,IACT,WAAW;AAAA,IACX,SAAS;AAAA,IACT,QAAQ;AAAA,EACT;AAEA,QAAM,aAAa;AAAA,IAClB;AAAA,IACA,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,GAAK,aAAa;AAAA,MACjB,gCAAgC;AAAA,IACjC;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,OAAQ,EAAE,GAAG,WAAW,GAAG,WAAW;AAAA,EACjD;AACD;AAEA,IAAM,eAAe,CAAE,cAAwB;AAC9C,QAAM,UAAM,sBAA8B,IAAK;AAE/C,+BAAW,MAAM;AAChB,QAAK,WAAY;AAChB,gBAAW,IAAI,OAAQ;AAAA,IACxB;AAAA,EACD,GAAG,CAAE,SAAU,CAAE;AAEjB,SAAO;AACR;AAEA,IAAM,YAAY,CAAE,OAA4B;AAC/C,QAAM,YAAY,aAAa;AAE/B,MAAK,CAAE,aAAa,CAAE,IAAK;AAC1B;AAAA,EACD;AAEA,QAAM,QAAQ,SAAS,YAAY;AACnC,QAAM,mBAAoB,EAAG;AAE7B,YAAU,gBAAgB;AAC1B,YAAU,SAAU,KAAM;AAC3B;","names":["React","import_react","import_ui","React","import_react","import_ui","import_react"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/components/ellipsis-with-tooltip.tsx","../src/components/editable-field.tsx","../src/components/introduction-modal.tsx","../src/components/theme-provider.tsx","../src/hooks/use-color-scheme.ts","../src/components/menu-item.tsx","../src/hooks/use-editable.ts"],"sourcesContent":["// components\nexport { EllipsisWithTooltip } from './components/ellipsis-with-tooltip';\nexport { EditableField } from './components/editable-field';\nexport { IntroductionModal } from './components/introduction-modal';\nexport { default as ThemeProvider } from './components/theme-provider';\nexport { MenuListItem } from './components/menu-item';\n\n// hooks\nexport { useEditable } from './hooks/use-editable';\n","import * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport { Box, Tooltip } from '@elementor/ui';\n\ntype EllipsisWithTooltipProps< T extends React.ElementType > = {\n\tmaxWidth?: React.CSSProperties[ 'maxWidth' ];\n\ttitle: string;\n\tas?: T;\n} & React.ComponentProps< T >;\n\nexport const EllipsisWithTooltip = < T extends React.ElementType >( {\n\tmaxWidth,\n\ttitle,\n\tas,\n\t...props\n}: EllipsisWithTooltipProps< T > ) => {\n\tconst [ setRef, isOverflowing ] = useIsOverflowing();\n\n\tif ( isOverflowing ) {\n\t\treturn (\n\t\t\t<Tooltip title={ title } placement=\"top\">\n\t\t\t\t<Content maxWidth={ maxWidth } ref={ setRef } as={ as } { ...props }>\n\t\t\t\t\t{ title }\n\t\t\t\t</Content>\n\t\t\t</Tooltip>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Content maxWidth={ maxWidth } ref={ setRef } as={ as } { ...props }>\n\t\t\t{ title }\n\t\t</Content>\n\t);\n};\n\ntype ContentProps< T extends React.ElementType > = React.PropsWithChildren<\n\tOmit< EllipsisWithTooltipProps< T >, 'title' >\n>;\n\nconst Content = React.forwardRef(\n\t< T extends React.ElementType >(\n\t\t{ maxWidth, as: Component = Box, ...props }: ContentProps< T >,\n\t\t// forwardRef loses the typing when using generic components.\n\t\tref: unknown\n\t) => (\n\t\t<Component\n\t\t\tref={ ref }\n\t\t\tposition=\"relative\"\n\t\t\t{ ...props }\n\t\t\tstyle={ { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', maxWidth } }\n\t\t/>\n\t)\n);\n\nconst useIsOverflowing = () => {\n\tconst [ el, setEl ] = useState< HTMLElement | null >( null );\n\tconst [ isOverflowing, setIsOverflown ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst observer = new ResizeObserver( ( [ { target } ] ) => {\n\t\t\tsetIsOverflown( target.scrollWidth > target.clientWidth );\n\t\t} );\n\n\t\tif ( el ) {\n\t\t\tobserver.observe( el );\n\t\t}\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ el ] );\n\n\treturn [ setEl, isOverflowing ] as const;\n};\n","import * as React from 'react';\nimport { forwardRef } from 'react';\nimport { Box, styled, Tooltip } from '@elementor/ui';\n\ntype EditableFieldProps< T extends React.ElementType > = {\n\tvalue: string;\n\terror?: string;\n\tas?: T;\n} & React.ComponentPropsWithRef< T >;\n\nexport const EditableField = forwardRef(\n\t< T extends React.ElementType >(\n\t\t{ value, error, as = 'span', sx, ...props }: EditableFieldProps< T >,\n\t\tref: unknown\n\t) => {\n\t\treturn (\n\t\t\t<Tooltip title={ error } open={ !! error } placement=\"top\">\n\t\t\t\t<StyledField ref={ ref } component={ as } { ...props }>\n\t\t\t\t\t{ value }\n\t\t\t\t</StyledField>\n\t\t\t</Tooltip>\n\t\t);\n\t}\n);\n\nconst StyledField = styled( Box )`\n\twidth: 100%;\n\t&:focus {\n\t\toutline: none;\n\t}\n`;\n","import * as React from 'react';\nimport { useState } from 'react';\nimport {\n\tButton,\n\tCheckbox,\n\tDialog,\n\tDialogActions,\n\tDialogHeader,\n\tDialogTitle,\n\tFormControlLabel,\n\tImage,\n\tTypography,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\ntype IntroductionModalProps = {\n\topen: boolean;\n\thandleClose: ( shouldShowAgain: boolean ) => void;\n\ttitle?: string;\n\tcontent: React.ReactNode;\n\timage?: {\n\t\tsrc: string;\n\t\talt: string;\n\t};\n};\n\nconst OPEN_DELAY = 1000;\n\nexport const IntroductionModal = ( { open, handleClose, title, content, image }: IntroductionModalProps ) => {\n\tconst [ shouldShowAgain, setShouldShowAgain ] = useState( true );\n\n\treturn (\n\t\t<Dialog\n\t\t\topen={ open }\n\t\t\tonClose={ handleClose }\n\t\t\tmaxWidth={ 'sm' }\n\t\t\tTransitionProps={ {\n\t\t\t\ttimeout: 700,\n\t\t\t\tstyle: { transitionDelay: open ? `${ OPEN_DELAY }ms` : '0ms' },\n\t\t\t} }\n\t\t>\n\t\t\t{ title && (\n\t\t\t\t<DialogHeader logo={ false }>\n\t\t\t\t\t<DialogTitle>{ title }</DialogTitle>\n\t\t\t\t</DialogHeader>\n\t\t\t) }\n\t\t\t{ image && <Image sx={ { width: '100%' } } src={ image.src } alt={ image.alt } /> }\n\t\t\t{ content }\n\t\t\t<DialogActions>\n\t\t\t\t<FormControlLabel\n\t\t\t\t\tsx={ { marginRight: 'auto' } }\n\t\t\t\t\tcontrol={\n\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\tchecked={ ! shouldShowAgain }\n\t\t\t\t\t\t\tonChange={ () => setShouldShowAgain( ! shouldShowAgain ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\tlabel={\n\t\t\t\t\t\t<Typography variant={ 'body2' }>{ __( \"Don't show this again\", 'elementor' ) }</Typography>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Button size={ 'medium' } onClick={ () => handleClose( shouldShowAgain ) } variant=\"contained\">\n\t\t\t\t\t{ __( 'Got it', 'elementor' ) }\n\t\t\t\t</Button>\n\t\t\t</DialogActions>\n\t\t</Dialog>\n\t);\n};\n","import * as React from 'react';\nimport { ThemeProvider as ThemeProviderBase, type ThemeProviderProps } from '@elementor/ui';\n\nimport { useColorScheme } from '../hooks/use-color-scheme';\n\nconst EDITOR_PALLETTE: ThemeProviderProps[ 'palette' ] = 'unstable';\n\nexport default function ThemeProvider( { children }: { children: React.ReactNode } ) {\n\tconst colorScheme = useColorScheme();\n\n\treturn (\n\t\t<ThemeProviderBase colorScheme={ colorScheme } palette={ EDITOR_PALLETTE }>\n\t\t\t{ children }\n\t\t</ThemeProviderBase>\n\t);\n}\n","import { useEffect, useState } from 'react';\nimport {\n\t__privateListenTo as listenTo,\n\tcommandEndEvent,\n\ttype CommandEvent,\n\tv1ReadyEvent,\n} from '@elementor/editor-v1-adapters';\n\nexport type ColorScheme = 'auto' | 'dark' | 'light';\n\nexport type ExtendedWindow = Window & {\n\telementor: {\n\t\tgetPreferences: ( key: 'ui_theme' ) => ColorScheme;\n\t};\n};\n\nexport function useColorScheme() {\n\tconst [ colorScheme, setColorScheme ] = useState< ColorScheme >( () => getV1ColorScheme() );\n\n\tuseEffect( () => {\n\t\treturn listenTo( v1ReadyEvent(), () => setColorScheme( getV1ColorScheme() ) );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\treturn listenTo( commandEndEvent( 'document/elements/settings' ), ( e ) => {\n\t\t\tconst event = e as CommandEvent< {\n\t\t\t\tsettings: {\n\t\t\t\t\tui_theme?: ColorScheme;\n\t\t\t\t};\n\t\t\t} >;\n\n\t\t\t// The User-Preferences settings object has a key named `ui_theme` that controls the color scheme.\n\t\t\tconst isColorScheme = event.args?.settings && 'ui_theme' in event.args.settings;\n\n\t\t\tif ( isColorScheme ) {\n\t\t\t\tsetColorScheme( getV1ColorScheme() );\n\t\t\t}\n\t\t} );\n\t}, [] );\n\n\treturn colorScheme;\n}\n\nfunction getV1ColorScheme() {\n\treturn ( window as unknown as ExtendedWindow ).elementor?.getPreferences?.( 'ui_theme' ) || 'auto';\n}\n","import * as React from 'react';\nimport { MenuItem, type MenuItemProps, MenuItemText } from '@elementor/ui';\n\nexport const MenuListItem = ( { children, ...props }: MenuItemProps ) => {\n\treturn (\n\t\t<MenuItem\n\t\t\tdense\n\t\t\t{ ...props }\n\t\t\tsx={ {\n\t\t\t\t...( props.sx ?? {} ),\n\t\t\t} }\n\t\t>\n\t\t\t<MenuItemText\n\t\t\t\tprimary={ children }\n\t\t\t\tprimaryTypographyProps={ {\n\t\t\t\t\tvariant: 'caption',\n\t\t\t\t} }\n\t\t\t/>\n\t\t</MenuItem>\n\t);\n};\n","import { useEffect, useRef, useState } from 'react';\n\ntype UseEditableParams = {\n\tvalue: string;\n\tonSubmit: ( value: string ) => unknown;\n\tvalidation?: ( value: string ) => string | null;\n\tonClick?: ( event: React.MouseEvent< HTMLDivElement > ) => void;\n};\n\nexport const useEditable = ( { value, onSubmit, validation, onClick }: UseEditableParams ) => {\n\tconst [ isEditing, setIsEditing ] = useState( false );\n\tconst [ error, setError ] = useState< string | null >( null );\n\n\tconst ref = useSelection( isEditing );\n\n\tconst isDirty = ( newValue: string ) => newValue !== value;\n\n\tconst openEditMode = () => {\n\t\tsetIsEditing( true );\n\t};\n\n\tconst closeEditMode = () => {\n\t\tref.current?.blur();\n\n\t\tsetError( null );\n\t\tsetIsEditing( false );\n\t};\n\n\tconst submit = ( newValue: string ) => {\n\t\tif ( ! isDirty( newValue ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! error ) {\n\t\t\ttry {\n\t\t\t\tonSubmit( newValue );\n\t\t\t} finally {\n\t\t\t\tcloseEditMode();\n\t\t\t}\n\t\t}\n\t};\n\n\tconst onChange = ( event: React.ChangeEvent< HTMLSpanElement > ) => {\n\t\tconst { innerText: newValue } = event.target;\n\n\t\tif ( validation ) {\n\t\t\tsetError( isDirty( newValue ) ? validation( newValue ) : null );\n\t\t}\n\t};\n\n\tconst handleKeyDown = ( event: React.KeyboardEvent ) => {\n\t\tevent.stopPropagation();\n\n\t\tif ( [ 'Escape' ].includes( event.key ) ) {\n\t\t\treturn closeEditMode();\n\t\t}\n\n\t\tif ( [ 'Enter' ].includes( event.key ) ) {\n\t\t\tevent.preventDefault();\n\t\t\treturn submit( ( event.target as HTMLElement ).innerText );\n\t\t}\n\t};\n\n\tconst handleClick = ( event: React.MouseEvent< HTMLDivElement > ) => {\n\t\tif ( isEditing ) {\n\t\t\tevent.stopPropagation();\n\t\t}\n\n\t\tonClick?.( event );\n\t};\n\n\tconst listeners = {\n\t\tonClick: handleClick,\n\t\tonKeyDown: handleKeyDown,\n\t\tonInput: onChange,\n\t\tonBlur: closeEditMode,\n\t} as const;\n\n\tconst attributes = {\n\t\tvalue,\n\t\trole: 'textbox',\n\t\tcontentEditable: isEditing,\n\t\t...( isEditing && {\n\t\t\tsuppressContentEditableWarning: true,\n\t\t} ),\n\t} as const;\n\n\treturn {\n\t\tref,\n\t\tisEditing,\n\t\topenEditMode,\n\t\tcloseEditMode,\n\t\tvalue,\n\t\terror,\n\t\tgetProps: () => ( { ...listeners, ...attributes } ),\n\t} as const;\n};\n\nconst useSelection = ( isEditing: boolean ) => {\n\tconst ref = useRef< HTMLElement | null >( null );\n\n\tuseEffect( () => {\n\t\tif ( isEditing ) {\n\t\t\tselectAll( ref.current );\n\t\t}\n\t}, [ isEditing ] );\n\n\treturn ref;\n};\n\nconst selectAll = ( el: HTMLElement | null ) => {\n\tconst selection = getSelection();\n\n\tif ( ! selection || ! el ) {\n\t\treturn;\n\t}\n\n\tconst range = document.createRange();\n\trange.selectNodeContents( el );\n\n\tselection.removeAllRanges();\n\tselection.addRange( range );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,mBAAoC;AACpC,gBAA6B;AAQtB,IAAM,sBAAsB,CAAiC;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,MAAsC;AACrC,QAAM,CAAE,QAAQ,aAAc,IAAI,iBAAiB;AAEnD,MAAK,eAAgB;AACpB,WACC,oCAAC,qBAAQ,OAAgB,WAAU,SAClC,oCAAC,WAAQ,UAAsB,KAAM,QAAS,IAAY,GAAG,SAC1D,KACH,CACD;AAAA,EAEF;AAEA,SACC,oCAAC,WAAQ,UAAsB,KAAM,QAAS,IAAY,GAAG,SAC1D,KACH;AAEF;AAMA,IAAM,UAAgB;AAAA,EACrB,CACC,EAAE,UAAU,IAAI,YAAY,eAAK,GAAG,MAAM,GAE1C,QAEA;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,UAAS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;AAE/B,MAAK,CAAE,aAAa,CAAE,IAAK;AAC1B;AAAA,EACD;AAEA,QAAM,QAAQ,SAAS,YAAY;AACnC,QAAM,mBAAoB,EAAG;AAE7B,YAAU,gBAAgB;AAC1B,YAAU,SAAU,KAAM;AAC3B;","names":["React","import_react","import_ui","React","import_react","import_ui","React","import_ui","import_react","listenTo","ThemeProviderBase","React","import_ui","import_react"]}
package/dist/index.mjs CHANGED
@@ -61,10 +61,20 @@ var StyledField = styled(Box2)`
61
61
  // src/components/introduction-modal.tsx
62
62
  import * as React3 from "react";
63
63
  import { useState as useState2 } from "react";
64
- import { Button, Checkbox, Dialog, DialogActions, DialogHeader, DialogTitle, FormControlLabel } from "@elementor/ui";
64
+ import {
65
+ Button,
66
+ Checkbox,
67
+ Dialog,
68
+ DialogActions,
69
+ DialogHeader,
70
+ DialogTitle,
71
+ FormControlLabel,
72
+ Image,
73
+ Typography
74
+ } from "@elementor/ui";
65
75
  import { __ } from "@wordpress/i18n";
66
76
  var OPEN_DELAY = 1e3;
67
- var IntroductionModal = ({ open, handleClose, title, content }) => {
77
+ var IntroductionModal = ({ open, handleClose, title, content, image }) => {
68
78
  const [shouldShowAgain, setShouldShowAgain] = useState2(true);
69
79
  return /* @__PURE__ */ React3.createElement(
70
80
  Dialog,
@@ -77,7 +87,8 @@ var IntroductionModal = ({ open, handleClose, title, content }) => {
77
87
  style: { transitionDelay: open ? `${OPEN_DELAY}ms` : "0ms" }
78
88
  }
79
89
  },
80
- /* @__PURE__ */ React3.createElement(DialogHeader, { logo: false }, /* @__PURE__ */ React3.createElement(DialogTitle, null, title)),
90
+ title && /* @__PURE__ */ React3.createElement(DialogHeader, { logo: false }, /* @__PURE__ */ React3.createElement(DialogTitle, null, title)),
91
+ image && /* @__PURE__ */ React3.createElement(Image, { sx: { width: "100%" }, src: image.src, alt: image.alt }),
81
92
  content,
82
93
  /* @__PURE__ */ React3.createElement(DialogActions, null, /* @__PURE__ */ React3.createElement(
83
94
  FormControlLabel,
@@ -90,17 +101,80 @@ var IntroductionModal = ({ open, handleClose, title, content }) => {
90
101
  onChange: () => setShouldShowAgain(!shouldShowAgain)
91
102
  }
92
103
  ),
93
- label: __("Don't show this again", "elementor")
104
+ label: /* @__PURE__ */ React3.createElement(Typography, { variant: "body2" }, __("Don't show this again", "elementor"))
94
105
  }
95
106
  ), /* @__PURE__ */ React3.createElement(Button, { size: "medium", onClick: () => handleClose(shouldShowAgain), variant: "contained" }, __("Got it", "elementor")))
96
107
  );
97
108
  };
98
109
 
110
+ // src/components/theme-provider.tsx
111
+ import * as React4 from "react";
112
+ import { ThemeProvider as ThemeProviderBase } from "@elementor/ui";
113
+
114
+ // src/hooks/use-color-scheme.ts
115
+ import { useEffect as useEffect2, useState as useState3 } from "react";
116
+ import {
117
+ __privateListenTo as listenTo,
118
+ commandEndEvent,
119
+ v1ReadyEvent
120
+ } from "@elementor/editor-v1-adapters";
121
+ function useColorScheme() {
122
+ const [colorScheme, setColorScheme] = useState3(() => getV1ColorScheme());
123
+ useEffect2(() => {
124
+ return listenTo(v1ReadyEvent(), () => setColorScheme(getV1ColorScheme()));
125
+ }, []);
126
+ useEffect2(() => {
127
+ return listenTo(commandEndEvent("document/elements/settings"), (e) => {
128
+ const event = e;
129
+ const isColorScheme = event.args?.settings && "ui_theme" in event.args.settings;
130
+ if (isColorScheme) {
131
+ setColorScheme(getV1ColorScheme());
132
+ }
133
+ });
134
+ }, []);
135
+ return colorScheme;
136
+ }
137
+ function getV1ColorScheme() {
138
+ return window.elementor?.getPreferences?.("ui_theme") || "auto";
139
+ }
140
+
141
+ // src/components/theme-provider.tsx
142
+ var EDITOR_PALLETTE = "unstable";
143
+ function ThemeProvider({ children }) {
144
+ const colorScheme = useColorScheme();
145
+ return /* @__PURE__ */ React4.createElement(ThemeProviderBase, { colorScheme, palette: EDITOR_PALLETTE }, children);
146
+ }
147
+
148
+ // src/components/menu-item.tsx
149
+ import * as React5 from "react";
150
+ import { MenuItem, MenuItemText } from "@elementor/ui";
151
+ var MenuListItem = ({ children, ...props }) => {
152
+ return /* @__PURE__ */ React5.createElement(
153
+ MenuItem,
154
+ {
155
+ dense: true,
156
+ ...props,
157
+ sx: {
158
+ ...props.sx ?? {}
159
+ }
160
+ },
161
+ /* @__PURE__ */ React5.createElement(
162
+ MenuItemText,
163
+ {
164
+ primary: children,
165
+ primaryTypographyProps: {
166
+ variant: "caption"
167
+ }
168
+ }
169
+ )
170
+ );
171
+ };
172
+
99
173
  // src/hooks/use-editable.ts
100
- import { useEffect as useEffect2, useRef, useState as useState3 } from "react";
174
+ import { useEffect as useEffect3, useRef, useState as useState4 } from "react";
101
175
  var useEditable = ({ value, onSubmit, validation, onClick }) => {
102
- const [isEditing, setIsEditing] = useState3(false);
103
- const [error, setError] = useState3(null);
176
+ const [isEditing, setIsEditing] = useState4(false);
177
+ const [error, setError] = useState4(null);
104
178
  const ref = useSelection(isEditing);
105
179
  const isDirty = (newValue) => newValue !== value;
106
180
  const openEditMode = () => {
@@ -171,7 +245,7 @@ var useEditable = ({ value, onSubmit, validation, onClick }) => {
171
245
  };
172
246
  var useSelection = (isEditing) => {
173
247
  const ref = useRef(null);
174
- useEffect2(() => {
248
+ useEffect3(() => {
175
249
  if (isEditing) {
176
250
  selectAll(ref.current);
177
251
  }
@@ -192,6 +266,8 @@ export {
192
266
  EditableField,
193
267
  EllipsisWithTooltip,
194
268
  IntroductionModal,
269
+ MenuListItem,
270
+ ThemeProvider,
195
271
  useEditable
196
272
  };
197
273
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/ellipsis-with-tooltip.tsx","../src/components/editable-field.tsx","../src/components/introduction-modal.tsx","../src/hooks/use-editable.ts"],"sourcesContent":["import * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport { Box, Tooltip } from '@elementor/ui';\n\ntype EllipsisWithTooltipProps< T extends React.ElementType > = {\n\tmaxWidth?: React.CSSProperties[ 'maxWidth' ];\n\ttitle: string;\n\tas?: T;\n} & React.ComponentProps< T >;\n\nexport const EllipsisWithTooltip = < T extends React.ElementType >( {\n\tmaxWidth,\n\ttitle,\n\tas,\n\t...props\n}: EllipsisWithTooltipProps< T > ) => {\n\tconst [ setRef, isOverflowing ] = useIsOverflowing();\n\n\tif ( isOverflowing ) {\n\t\treturn (\n\t\t\t<Tooltip title={ title } placement=\"top\">\n\t\t\t\t<Content maxWidth={ maxWidth } ref={ setRef } as={ as } { ...props }>\n\t\t\t\t\t{ title }\n\t\t\t\t</Content>\n\t\t\t</Tooltip>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Content maxWidth={ maxWidth } ref={ setRef } as={ as } { ...props }>\n\t\t\t{ title }\n\t\t</Content>\n\t);\n};\n\ntype ContentProps< T extends React.ElementType > = React.PropsWithChildren<\n\tOmit< EllipsisWithTooltipProps< T >, 'title' >\n>;\n\nconst Content = React.forwardRef(\n\t< T extends React.ElementType >(\n\t\t{ maxWidth, as: Component = Box, ...props }: ContentProps< T >,\n\t\t// forwardRef loses the typing when using generic components.\n\t\tref: unknown\n\t) => (\n\t\t<Component\n\t\t\tref={ ref }\n\t\t\tposition=\"relative\"\n\t\t\t{ ...props }\n\t\t\tstyle={ { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', maxWidth } }\n\t\t/>\n\t)\n);\n\nconst useIsOverflowing = () => {\n\tconst [ el, setEl ] = useState< HTMLElement | null >( null );\n\tconst [ isOverflowing, setIsOverflown ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst observer = new ResizeObserver( ( [ { target } ] ) => {\n\t\t\tsetIsOverflown( target.scrollWidth > target.clientWidth );\n\t\t} );\n\n\t\tif ( el ) {\n\t\t\tobserver.observe( el );\n\t\t}\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ el ] );\n\n\treturn [ setEl, isOverflowing ] as const;\n};\n","import * as React from 'react';\nimport { forwardRef } from 'react';\nimport { Box, styled, Tooltip } from '@elementor/ui';\n\ntype EditableFieldProps< T extends React.ElementType > = {\n\tvalue: string;\n\terror?: string;\n\tas?: T;\n} & React.ComponentPropsWithRef< T >;\n\nexport const EditableField = forwardRef(\n\t< T extends React.ElementType >(\n\t\t{ value, error, as = 'span', sx, ...props }: EditableFieldProps< T >,\n\t\tref: unknown\n\t) => {\n\t\treturn (\n\t\t\t<Tooltip title={ error } open={ !! error } placement=\"top\">\n\t\t\t\t<StyledField ref={ ref } component={ as } { ...props }>\n\t\t\t\t\t{ value }\n\t\t\t\t</StyledField>\n\t\t\t</Tooltip>\n\t\t);\n\t}\n);\n\nconst StyledField = styled( Box )`\n\twidth: 100%;\n\t&:focus {\n\t\toutline: none;\n\t}\n`;\n","import * as React from 'react';\nimport { useState } from 'react';\nimport { Button, Checkbox, Dialog, DialogActions, DialogHeader, DialogTitle, FormControlLabel } from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\ntype IntroductionModalProps = {\n\topen: boolean;\n\thandleClose: ( shouldShowAgain: boolean ) => void;\n\ttitle: string;\n\tcontent: React.ReactNode;\n};\n\nconst OPEN_DELAY = 1000;\n\nexport const IntroductionModal = ( { open, handleClose, title, content }: IntroductionModalProps ) => {\n\tconst [ shouldShowAgain, setShouldShowAgain ] = useState( true );\n\n\treturn (\n\t\t<Dialog\n\t\t\topen={ open }\n\t\t\tonClose={ handleClose }\n\t\t\tmaxWidth={ 'sm' }\n\t\t\tTransitionProps={ {\n\t\t\t\ttimeout: 700,\n\t\t\t\tstyle: { transitionDelay: open ? `${ OPEN_DELAY }ms` : '0ms' },\n\t\t\t} }\n\t\t>\n\t\t\t<DialogHeader logo={ false }>\n\t\t\t\t<DialogTitle>{ title }</DialogTitle>\n\t\t\t</DialogHeader>\n\t\t\t{ content }\n\t\t\t<DialogActions>\n\t\t\t\t<FormControlLabel\n\t\t\t\t\tsx={ { marginRight: 'auto' } }\n\t\t\t\t\tcontrol={\n\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\tchecked={ ! shouldShowAgain }\n\t\t\t\t\t\t\tonChange={ () => setShouldShowAgain( ! shouldShowAgain ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\tlabel={ __( \"Don't show this again\", 'elementor' ) }\n\t\t\t\t/>\n\t\t\t\t<Button size={ 'medium' } onClick={ () => handleClose( shouldShowAgain ) } variant=\"contained\">\n\t\t\t\t\t{ __( 'Got it', 'elementor' ) }\n\t\t\t\t</Button>\n\t\t\t</DialogActions>\n\t\t</Dialog>\n\t);\n};\n","import { useEffect, useRef, useState } from 'react';\n\ntype UseEditableParams = {\n\tvalue: string;\n\tonSubmit: ( value: string ) => unknown;\n\tvalidation?: ( value: string ) => string | null;\n\tonClick?: ( event: React.MouseEvent< HTMLDivElement > ) => void;\n};\n\nexport const useEditable = ( { value, onSubmit, validation, onClick }: UseEditableParams ) => {\n\tconst [ isEditing, setIsEditing ] = useState( false );\n\tconst [ error, setError ] = useState< string | null >( null );\n\n\tconst ref = useSelection( isEditing );\n\n\tconst isDirty = ( newValue: string ) => newValue !== value;\n\n\tconst openEditMode = () => {\n\t\tsetIsEditing( true );\n\t};\n\n\tconst closeEditMode = () => {\n\t\tref.current?.blur();\n\n\t\tsetError( null );\n\t\tsetIsEditing( false );\n\t};\n\n\tconst submit = ( newValue: string ) => {\n\t\tif ( ! isDirty( newValue ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! error ) {\n\t\t\ttry {\n\t\t\t\tonSubmit( newValue );\n\t\t\t} finally {\n\t\t\t\tcloseEditMode();\n\t\t\t}\n\t\t}\n\t};\n\n\tconst onChange = ( event: React.ChangeEvent< HTMLSpanElement > ) => {\n\t\tconst { innerText: newValue } = event.target;\n\n\t\tif ( validation ) {\n\t\t\tsetError( isDirty( newValue ) ? validation( newValue ) : null );\n\t\t}\n\t};\n\n\tconst handleKeyDown = ( event: React.KeyboardEvent ) => {\n\t\tevent.stopPropagation();\n\n\t\tif ( [ 'Escape' ].includes( event.key ) ) {\n\t\t\treturn closeEditMode();\n\t\t}\n\n\t\tif ( [ 'Enter' ].includes( event.key ) ) {\n\t\t\tevent.preventDefault();\n\t\t\treturn submit( ( event.target as HTMLElement ).innerText );\n\t\t}\n\t};\n\n\tconst handleClick = ( event: React.MouseEvent< HTMLDivElement > ) => {\n\t\tif ( isEditing ) {\n\t\t\tevent.stopPropagation();\n\t\t}\n\n\t\tonClick?.( event );\n\t};\n\n\tconst listeners = {\n\t\tonClick: handleClick,\n\t\tonKeyDown: handleKeyDown,\n\t\tonInput: onChange,\n\t\tonBlur: closeEditMode,\n\t} as const;\n\n\tconst attributes = {\n\t\tvalue,\n\t\trole: 'textbox',\n\t\tcontentEditable: isEditing,\n\t\t...( isEditing && {\n\t\t\tsuppressContentEditableWarning: true,\n\t\t} ),\n\t} as const;\n\n\treturn {\n\t\tref,\n\t\tisEditing,\n\t\topenEditMode,\n\t\tcloseEditMode,\n\t\tvalue,\n\t\terror,\n\t\tgetProps: () => ( { ...listeners, ...attributes } ),\n\t} as const;\n};\n\nconst useSelection = ( isEditing: boolean ) => {\n\tconst ref = useRef< HTMLElement | null >( null );\n\n\tuseEffect( () => {\n\t\tif ( isEditing ) {\n\t\t\tselectAll( ref.current );\n\t\t}\n\t}, [ isEditing ] );\n\n\treturn ref;\n};\n\nconst selectAll = ( el: HTMLElement | null ) => {\n\tconst selection = getSelection();\n\n\tif ( ! selection || ! el ) {\n\t\treturn;\n\t}\n\n\tconst range = document.createRange();\n\trange.selectNodeContents( el );\n\n\tselection.removeAllRanges();\n\tselection.addRange( range );\n};\n"],"mappings":";AAAA,YAAY,WAAW;AACvB,SAAS,WAAW,gBAAgB;AACpC,SAAS,KAAK,eAAe;AAQtB,IAAM,sBAAsB,CAAiC;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,MAAsC;AACrC,QAAM,CAAE,QAAQ,aAAc,IAAI,iBAAiB;AAEnD,MAAK,eAAgB;AACpB,WACC,oCAAC,WAAQ,OAAgB,WAAU,SAClC,oCAAC,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AE,GAAG,WAAW,GAAG,WAAW;AAAA,EACjD;AACD;AAEA,IAAM,eAAe,CAAE,cAAwB;AAC9C,QAAM,MAAM,OAA8B,IAAK;AAE/C,EAAAD,WAAW,MAAM;AAChB,QAAK,WAAY;AAChB,gBAAW,IAAI,OAAQ;AAAA,IACxB;AAAA,EACD,GAAG,CAAE,SAAU,CAAE;AAEjB,SAAO;AACR;AAEA,IAAM,YAAY,CAAE,OAA4B;AAC/C,QAAM,YAAY,aAAa;AAE/B,MAAK,CAAE,aAAa,CAAE,IAAK;AAC1B;AAAA,EACD;AAEA,QAAM,QAAQ,SAAS,YAAY;AACnC,QAAM,mBAAoB,EAAG;AAE7B,YAAU,gBAAgB;AAC1B,YAAU,SAAU,KAAM;AAC3B;","names":["React","forwardRef","Box","Tooltip","React","useState","useEffect","useState"]}
1
+ {"version":3,"sources":["../src/components/ellipsis-with-tooltip.tsx","../src/components/editable-field.tsx","../src/components/introduction-modal.tsx","../src/components/theme-provider.tsx","../src/hooks/use-color-scheme.ts","../src/components/menu-item.tsx","../src/hooks/use-editable.ts"],"sourcesContent":["import * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport { Box, Tooltip } from '@elementor/ui';\n\ntype EllipsisWithTooltipProps< T extends React.ElementType > = {\n\tmaxWidth?: React.CSSProperties[ 'maxWidth' ];\n\ttitle: string;\n\tas?: T;\n} & React.ComponentProps< T >;\n\nexport const EllipsisWithTooltip = < T extends React.ElementType >( {\n\tmaxWidth,\n\ttitle,\n\tas,\n\t...props\n}: EllipsisWithTooltipProps< T > ) => {\n\tconst [ setRef, isOverflowing ] = useIsOverflowing();\n\n\tif ( isOverflowing ) {\n\t\treturn (\n\t\t\t<Tooltip title={ title } placement=\"top\">\n\t\t\t\t<Content maxWidth={ maxWidth } ref={ setRef } as={ as } { ...props }>\n\t\t\t\t\t{ title }\n\t\t\t\t</Content>\n\t\t\t</Tooltip>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Content maxWidth={ maxWidth } ref={ setRef } as={ as } { ...props }>\n\t\t\t{ title }\n\t\t</Content>\n\t);\n};\n\ntype ContentProps< T extends React.ElementType > = React.PropsWithChildren<\n\tOmit< EllipsisWithTooltipProps< T >, 'title' >\n>;\n\nconst Content = React.forwardRef(\n\t< T extends React.ElementType >(\n\t\t{ maxWidth, as: Component = Box, ...props }: ContentProps< T >,\n\t\t// forwardRef loses the typing when using generic components.\n\t\tref: unknown\n\t) => (\n\t\t<Component\n\t\t\tref={ ref }\n\t\t\tposition=\"relative\"\n\t\t\t{ ...props }\n\t\t\tstyle={ { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', maxWidth } }\n\t\t/>\n\t)\n);\n\nconst useIsOverflowing = () => {\n\tconst [ el, setEl ] = useState< HTMLElement | null >( null );\n\tconst [ isOverflowing, setIsOverflown ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst observer = new ResizeObserver( ( [ { target } ] ) => {\n\t\t\tsetIsOverflown( target.scrollWidth > target.clientWidth );\n\t\t} );\n\n\t\tif ( el ) {\n\t\t\tobserver.observe( el );\n\t\t}\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ el ] );\n\n\treturn [ setEl, isOverflowing ] as const;\n};\n","import * as React from 'react';\nimport { forwardRef } from 'react';\nimport { Box, styled, Tooltip } from '@elementor/ui';\n\ntype EditableFieldProps< T extends React.ElementType > = {\n\tvalue: string;\n\terror?: string;\n\tas?: T;\n} & React.ComponentPropsWithRef< T >;\n\nexport const EditableField = forwardRef(\n\t< T extends React.ElementType >(\n\t\t{ value, error, as = 'span', sx, ...props }: EditableFieldProps< T >,\n\t\tref: unknown\n\t) => {\n\t\treturn (\n\t\t\t<Tooltip title={ error } open={ !! error } placement=\"top\">\n\t\t\t\t<StyledField ref={ ref } component={ as } { ...props }>\n\t\t\t\t\t{ value }\n\t\t\t\t</StyledField>\n\t\t\t</Tooltip>\n\t\t);\n\t}\n);\n\nconst StyledField = styled( Box )`\n\twidth: 100%;\n\t&:focus {\n\t\toutline: none;\n\t}\n`;\n","import * as React from 'react';\nimport { useState } from 'react';\nimport {\n\tButton,\n\tCheckbox,\n\tDialog,\n\tDialogActions,\n\tDialogHeader,\n\tDialogTitle,\n\tFormControlLabel,\n\tImage,\n\tTypography,\n} from '@elementor/ui';\nimport { __ } from '@wordpress/i18n';\n\ntype IntroductionModalProps = {\n\topen: boolean;\n\thandleClose: ( shouldShowAgain: boolean ) => void;\n\ttitle?: string;\n\tcontent: React.ReactNode;\n\timage?: {\n\t\tsrc: string;\n\t\talt: string;\n\t};\n};\n\nconst OPEN_DELAY = 1000;\n\nexport const IntroductionModal = ( { open, handleClose, title, content, image }: IntroductionModalProps ) => {\n\tconst [ shouldShowAgain, setShouldShowAgain ] = useState( true );\n\n\treturn (\n\t\t<Dialog\n\t\t\topen={ open }\n\t\t\tonClose={ handleClose }\n\t\t\tmaxWidth={ 'sm' }\n\t\t\tTransitionProps={ {\n\t\t\t\ttimeout: 700,\n\t\t\t\tstyle: { transitionDelay: open ? `${ OPEN_DELAY }ms` : '0ms' },\n\t\t\t} }\n\t\t>\n\t\t\t{ title && (\n\t\t\t\t<DialogHeader logo={ false }>\n\t\t\t\t\t<DialogTitle>{ title }</DialogTitle>\n\t\t\t\t</DialogHeader>\n\t\t\t) }\n\t\t\t{ image && <Image sx={ { width: '100%' } } src={ image.src } alt={ image.alt } /> }\n\t\t\t{ content }\n\t\t\t<DialogActions>\n\t\t\t\t<FormControlLabel\n\t\t\t\t\tsx={ { marginRight: 'auto' } }\n\t\t\t\t\tcontrol={\n\t\t\t\t\t\t<Checkbox\n\t\t\t\t\t\t\tchecked={ ! shouldShowAgain }\n\t\t\t\t\t\t\tonChange={ () => setShouldShowAgain( ! shouldShowAgain ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\tlabel={\n\t\t\t\t\t\t<Typography variant={ 'body2' }>{ __( \"Don't show this again\", 'elementor' ) }</Typography>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Button size={ 'medium' } onClick={ () => handleClose( shouldShowAgain ) } variant=\"contained\">\n\t\t\t\t\t{ __( 'Got it', 'elementor' ) }\n\t\t\t\t</Button>\n\t\t\t</DialogActions>\n\t\t</Dialog>\n\t);\n};\n","import * as React from 'react';\nimport { ThemeProvider as ThemeProviderBase, type ThemeProviderProps } from '@elementor/ui';\n\nimport { useColorScheme } from '../hooks/use-color-scheme';\n\nconst EDITOR_PALLETTE: ThemeProviderProps[ 'palette' ] = 'unstable';\n\nexport default function ThemeProvider( { children }: { children: React.ReactNode } ) {\n\tconst colorScheme = useColorScheme();\n\n\treturn (\n\t\t<ThemeProviderBase colorScheme={ colorScheme } palette={ EDITOR_PALLETTE }>\n\t\t\t{ children }\n\t\t</ThemeProviderBase>\n\t);\n}\n","import { useEffect, useState } from 'react';\nimport {\n\t__privateListenTo as listenTo,\n\tcommandEndEvent,\n\ttype CommandEvent,\n\tv1ReadyEvent,\n} from '@elementor/editor-v1-adapters';\n\nexport type ColorScheme = 'auto' | 'dark' | 'light';\n\nexport type ExtendedWindow = Window & {\n\telementor: {\n\t\tgetPreferences: ( key: 'ui_theme' ) => ColorScheme;\n\t};\n};\n\nexport function useColorScheme() {\n\tconst [ colorScheme, setColorScheme ] = useState< ColorScheme >( () => getV1ColorScheme() );\n\n\tuseEffect( () => {\n\t\treturn listenTo( v1ReadyEvent(), () => setColorScheme( getV1ColorScheme() ) );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\treturn listenTo( commandEndEvent( 'document/elements/settings' ), ( e ) => {\n\t\t\tconst event = e as CommandEvent< {\n\t\t\t\tsettings: {\n\t\t\t\t\tui_theme?: ColorScheme;\n\t\t\t\t};\n\t\t\t} >;\n\n\t\t\t// The User-Preferences settings object has a key named `ui_theme` that controls the color scheme.\n\t\t\tconst isColorScheme = event.args?.settings && 'ui_theme' in event.args.settings;\n\n\t\t\tif ( isColorScheme ) {\n\t\t\t\tsetColorScheme( getV1ColorScheme() );\n\t\t\t}\n\t\t} );\n\t}, [] );\n\n\treturn colorScheme;\n}\n\nfunction getV1ColorScheme() {\n\treturn ( window as unknown as ExtendedWindow ).elementor?.getPreferences?.( 'ui_theme' ) || 'auto';\n}\n","import * as React from 'react';\nimport { MenuItem, type MenuItemProps, MenuItemText } from '@elementor/ui';\n\nexport const MenuListItem = ( { children, ...props }: MenuItemProps ) => {\n\treturn (\n\t\t<MenuItem\n\t\t\tdense\n\t\t\t{ ...props }\n\t\t\tsx={ {\n\t\t\t\t...( props.sx ?? {} ),\n\t\t\t} }\n\t\t>\n\t\t\t<MenuItemText\n\t\t\t\tprimary={ children }\n\t\t\t\tprimaryTypographyProps={ {\n\t\t\t\t\tvariant: 'caption',\n\t\t\t\t} }\n\t\t\t/>\n\t\t</MenuItem>\n\t);\n};\n","import { useEffect, useRef, useState } from 'react';\n\ntype UseEditableParams = {\n\tvalue: string;\n\tonSubmit: ( value: string ) => unknown;\n\tvalidation?: ( value: string ) => string | null;\n\tonClick?: ( event: React.MouseEvent< HTMLDivElement > ) => void;\n};\n\nexport const useEditable = ( { value, onSubmit, validation, onClick }: UseEditableParams ) => {\n\tconst [ isEditing, setIsEditing ] = useState( false );\n\tconst [ error, setError ] = useState< string | null >( null );\n\n\tconst ref = useSelection( isEditing );\n\n\tconst isDirty = ( newValue: string ) => newValue !== value;\n\n\tconst openEditMode = () => {\n\t\tsetIsEditing( true );\n\t};\n\n\tconst closeEditMode = () => {\n\t\tref.current?.blur();\n\n\t\tsetError( null );\n\t\tsetIsEditing( false );\n\t};\n\n\tconst submit = ( newValue: string ) => {\n\t\tif ( ! isDirty( newValue ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! error ) {\n\t\t\ttry {\n\t\t\t\tonSubmit( newValue );\n\t\t\t} finally {\n\t\t\t\tcloseEditMode();\n\t\t\t}\n\t\t}\n\t};\n\n\tconst onChange = ( event: React.ChangeEvent< HTMLSpanElement > ) => {\n\t\tconst { innerText: newValue } = event.target;\n\n\t\tif ( validation ) {\n\t\t\tsetError( isDirty( newValue ) ? validation( newValue ) : null );\n\t\t}\n\t};\n\n\tconst handleKeyDown = ( event: React.KeyboardEvent ) => {\n\t\tevent.stopPropagation();\n\n\t\tif ( [ 'Escape' ].includes( event.key ) ) {\n\t\t\treturn closeEditMode();\n\t\t}\n\n\t\tif ( [ 'Enter' ].includes( event.key ) ) {\n\t\t\tevent.preventDefault();\n\t\t\treturn submit( ( event.target as HTMLElement ).innerText );\n\t\t}\n\t};\n\n\tconst handleClick = ( event: React.MouseEvent< HTMLDivElement > ) => {\n\t\tif ( isEditing ) {\n\t\t\tevent.stopPropagation();\n\t\t}\n\n\t\tonClick?.( event );\n\t};\n\n\tconst listeners = {\n\t\tonClick: handleClick,\n\t\tonKeyDown: handleKeyDown,\n\t\tonInput: onChange,\n\t\tonBlur: closeEditMode,\n\t} as const;\n\n\tconst attributes = {\n\t\tvalue,\n\t\trole: 'textbox',\n\t\tcontentEditable: isEditing,\n\t\t...( isEditing && {\n\t\t\tsuppressContentEditableWarning: true,\n\t\t} ),\n\t} as const;\n\n\treturn {\n\t\tref,\n\t\tisEditing,\n\t\topenEditMode,\n\t\tcloseEditMode,\n\t\tvalue,\n\t\terror,\n\t\tgetProps: () => ( { ...listeners, ...attributes } ),\n\t} as const;\n};\n\nconst useSelection = ( isEditing: boolean ) => {\n\tconst ref = useRef< HTMLElement | null >( null );\n\n\tuseEffect( () => {\n\t\tif ( isEditing ) {\n\t\t\tselectAll( ref.current );\n\t\t}\n\t}, [ isEditing ] );\n\n\treturn ref;\n};\n\nconst selectAll = ( el: HTMLElement | null ) => {\n\tconst selection = getSelection();\n\n\tif ( ! selection || ! el ) {\n\t\treturn;\n\t}\n\n\tconst range = document.createRange();\n\trange.selectNodeContents( el );\n\n\tselection.removeAllRanges();\n\tselection.addRange( range );\n};\n"],"mappings":";AAAA,YAAY,WAAW;AACvB,SAAS,WAAW,gBAAgB;AACpC,SAAS,KAAK,eAAe;AAQtB,IAAM,sBAAsB,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BAAgB;AAAA,IACvB;AAEA,cAAW,KAAM;AAAA,EAClB;AAEA,QAAM,YAAY;AAAA,IACjB,SAAS;AAAA,IACT,WAAW;AAAA,IACX,SAAS;AAAA,IACT,QAAQ;AAAA,EACT;AAEA,QAAM,aAAa;AAAA,IAClB;AAAA,IACA,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,GAAK,aAAa;AAAA,MACjB,gCAAgC;AAAA,IACjC;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,OAAQ,EAAE,GAAG,WAAW,GAAG,WAAW;AAAA,EACjD;AACD;AAEA,IAAM,eAAe,CAAE,cAAwB;AAC9C,QAAM,MAAM,OAA8B,IAAK;AAE/C,EAAAD,WAAW,MAAM;AAChB,QAAK,WAAY;AAChB,gBAAW,IAAI,OAAQ;AAAA,IACxB;AAAA,EACD,GAAG,CAAE,SAAU,CAAE;AAEjB,SAAO;AACR;AAEA,IAAM,YAAY,CAAE,OAA4B;AAC/C,QAAM,YAAY,aAAa;AAE/B,MAAK,CAAE,aAAa,CAAE,IAAK;AAC1B;AAAA,EACD;AAEA,QAAM,QAAQ,SAAS,YAAY;AACnC,QAAM,mBAAoB,EAAG;AAE7B,YAAU,gBAAgB;AAC1B,YAAU,SAAU,KAAM;AAC3B;","names":["React","forwardRef","Box","Tooltip","React","useState","React","useEffect","useState","React","useEffect","useState"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-ui",
3
3
  "description": "Elementor Editor UI",
4
- "version": "0.4.3",
4
+ "version": "0.5.1",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -36,6 +36,7 @@
36
36
  "react": "^18.3.1"
37
37
  },
38
38
  "dependencies": {
39
+ "@elementor/editor-v1-adapters": "0.11.0",
39
40
  "@elementor/ui": "1.32.1",
40
41
  "@wordpress/i18n": "^5.13.0"
41
42
  },
@@ -1,18 +1,32 @@
1
1
  import * as React from 'react';
2
2
  import { useState } from 'react';
3
- import { Button, Checkbox, Dialog, DialogActions, DialogHeader, DialogTitle, FormControlLabel } from '@elementor/ui';
3
+ import {
4
+ Button,
5
+ Checkbox,
6
+ Dialog,
7
+ DialogActions,
8
+ DialogHeader,
9
+ DialogTitle,
10
+ FormControlLabel,
11
+ Image,
12
+ Typography,
13
+ } from '@elementor/ui';
4
14
  import { __ } from '@wordpress/i18n';
5
15
 
6
16
  type IntroductionModalProps = {
7
17
  open: boolean;
8
18
  handleClose: ( shouldShowAgain: boolean ) => void;
9
- title: string;
19
+ title?: string;
10
20
  content: React.ReactNode;
21
+ image?: {
22
+ src: string;
23
+ alt: string;
24
+ };
11
25
  };
12
26
 
13
27
  const OPEN_DELAY = 1000;
14
28
 
15
- export const IntroductionModal = ( { open, handleClose, title, content }: IntroductionModalProps ) => {
29
+ export const IntroductionModal = ( { open, handleClose, title, content, image }: IntroductionModalProps ) => {
16
30
  const [ shouldShowAgain, setShouldShowAgain ] = useState( true );
17
31
 
18
32
  return (
@@ -25,9 +39,12 @@ export const IntroductionModal = ( { open, handleClose, title, content }: Introd
25
39
  style: { transitionDelay: open ? `${ OPEN_DELAY }ms` : '0ms' },
26
40
  } }
27
41
  >
28
- <DialogHeader logo={ false }>
29
- <DialogTitle>{ title }</DialogTitle>
30
- </DialogHeader>
42
+ { title && (
43
+ <DialogHeader logo={ false }>
44
+ <DialogTitle>{ title }</DialogTitle>
45
+ </DialogHeader>
46
+ ) }
47
+ { image && <Image sx={ { width: '100%' } } src={ image.src } alt={ image.alt } /> }
31
48
  { content }
32
49
  <DialogActions>
33
50
  <FormControlLabel
@@ -38,7 +55,9 @@ export const IntroductionModal = ( { open, handleClose, title, content }: Introd
38
55
  onChange={ () => setShouldShowAgain( ! shouldShowAgain ) }
39
56
  />
40
57
  }
41
- label={ __( "Don't show this again", 'elementor' ) }
58
+ label={
59
+ <Typography variant={ 'body2' }>{ __( "Don't show this again", 'elementor' ) }</Typography>
60
+ }
42
61
  />
43
62
  <Button size={ 'medium' } onClick={ () => handleClose( shouldShowAgain ) } variant="contained">
44
63
  { __( 'Got it', 'elementor' ) }
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { MenuItem, type MenuItemProps, MenuItemText } from '@elementor/ui';
3
+
4
+ export const MenuListItem = ( { children, ...props }: MenuItemProps ) => {
5
+ return (
6
+ <MenuItem
7
+ dense
8
+ { ...props }
9
+ sx={ {
10
+ ...( props.sx ?? {} ),
11
+ } }
12
+ >
13
+ <MenuItemText
14
+ primary={ children }
15
+ primaryTypographyProps={ {
16
+ variant: 'caption',
17
+ } }
18
+ />
19
+ </MenuItem>
20
+ );
21
+ };
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { ThemeProvider as ThemeProviderBase, type ThemeProviderProps } from '@elementor/ui';
3
+
4
+ import { useColorScheme } from '../hooks/use-color-scheme';
5
+
6
+ const EDITOR_PALLETTE: ThemeProviderProps[ 'palette' ] = 'unstable';
7
+
8
+ export default function ThemeProvider( { children }: { children: React.ReactNode } ) {
9
+ const colorScheme = useColorScheme();
10
+
11
+ return (
12
+ <ThemeProviderBase colorScheme={ colorScheme } palette={ EDITOR_PALLETTE }>
13
+ { children }
14
+ </ThemeProviderBase>
15
+ );
16
+ }
@@ -0,0 +1,91 @@
1
+ import { act, renderHook } from '@testing-library/react';
2
+
3
+ import { type ColorScheme, type ExtendedWindow, useColorScheme } from '../use-color-scheme';
4
+
5
+ describe( '@elementor/editor - useColorScheme', () => {
6
+ it( 'should use the "auto" color scheme by default', () => {
7
+ // Act.
8
+ const { result } = renderHook( () => useColorScheme() );
9
+
10
+ // Assert.
11
+ expect( result.current ).toBe( 'auto' );
12
+ } );
13
+
14
+ it( 'should sync color scheme on V1 ready', () => {
15
+ // Arrange.
16
+ mockV1ColorScheme( 'dark' );
17
+
18
+ // Act.
19
+ const { result } = renderHook( () => useColorScheme() );
20
+
21
+ act( () => {
22
+ dispatchEvent( new CustomEvent( 'elementor/initialized' ) );
23
+ } );
24
+
25
+ // Assert.
26
+ expect( result.current ).toBe( 'dark' );
27
+ } );
28
+
29
+ it( 'should sync color scheme on V1 change', () => {
30
+ // Arrange.
31
+ mockV1ColorScheme( 'auto' );
32
+
33
+ const { result } = renderHook( () => useColorScheme() );
34
+
35
+ // Assert - Before change.
36
+ expect( result.current ).toBe( 'auto' );
37
+
38
+ // Act - Change.
39
+ act( () => {
40
+ mockV1ColorScheme( 'dark' );
41
+
42
+ dispatchEvent(
43
+ new CustomEvent( 'elementor/commands/run/after', {
44
+ detail: {
45
+ command: 'document/elements/settings',
46
+ args: {
47
+ container: {
48
+ id: 'editorPreferences_settings',
49
+ },
50
+ settings: {
51
+ ui_theme: 'dark',
52
+ },
53
+ },
54
+ },
55
+ } )
56
+ );
57
+ } );
58
+
59
+ // Assert.
60
+ expect( result.current ).toBe( 'dark' );
61
+ } );
62
+
63
+ it( 'should not sync color scheme on unrelated commands', () => {
64
+ // Act.
65
+ const { result } = renderHook( () => useColorScheme() );
66
+
67
+ act( () => {
68
+ dispatchEvent(
69
+ new CustomEvent( 'elementor/commands/run/after', {
70
+ detail: {
71
+ command: 'document/elements/settings',
72
+ args: {
73
+ container: {
74
+ id: 'some_other_container',
75
+ },
76
+ },
77
+ },
78
+ } )
79
+ );
80
+ } );
81
+
82
+ // Assert.
83
+ expect( result.current ).toBe( 'auto' );
84
+ } );
85
+ } );
86
+
87
+ function mockV1ColorScheme( colorScheme: ColorScheme ) {
88
+ ( window as unknown as ExtendedWindow ).elementor = {
89
+ getPreferences: () => colorScheme,
90
+ };
91
+ }
@@ -0,0 +1,46 @@
1
+ import { useEffect, useState } from 'react';
2
+ import {
3
+ __privateListenTo as listenTo,
4
+ commandEndEvent,
5
+ type CommandEvent,
6
+ v1ReadyEvent,
7
+ } from '@elementor/editor-v1-adapters';
8
+
9
+ export type ColorScheme = 'auto' | 'dark' | 'light';
10
+
11
+ export type ExtendedWindow = Window & {
12
+ elementor: {
13
+ getPreferences: ( key: 'ui_theme' ) => ColorScheme;
14
+ };
15
+ };
16
+
17
+ export function useColorScheme() {
18
+ const [ colorScheme, setColorScheme ] = useState< ColorScheme >( () => getV1ColorScheme() );
19
+
20
+ useEffect( () => {
21
+ return listenTo( v1ReadyEvent(), () => setColorScheme( getV1ColorScheme() ) );
22
+ }, [] );
23
+
24
+ useEffect( () => {
25
+ return listenTo( commandEndEvent( 'document/elements/settings' ), ( e ) => {
26
+ const event = e as CommandEvent< {
27
+ settings: {
28
+ ui_theme?: ColorScheme;
29
+ };
30
+ } >;
31
+
32
+ // The User-Preferences settings object has a key named `ui_theme` that controls the color scheme.
33
+ const isColorScheme = event.args?.settings && 'ui_theme' in event.args.settings;
34
+
35
+ if ( isColorScheme ) {
36
+ setColorScheme( getV1ColorScheme() );
37
+ }
38
+ } );
39
+ }, [] );
40
+
41
+ return colorScheme;
42
+ }
43
+
44
+ function getV1ColorScheme() {
45
+ return ( window as unknown as ExtendedWindow ).elementor?.getPreferences?.( 'ui_theme' ) || 'auto';
46
+ }
package/src/index.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  export { EllipsisWithTooltip } from './components/ellipsis-with-tooltip';
3
3
  export { EditableField } from './components/editable-field';
4
4
  export { IntroductionModal } from './components/introduction-modal';
5
+ export { default as ThemeProvider } from './components/theme-provider';
6
+ export { MenuListItem } from './components/menu-item';
5
7
 
6
8
  // hooks
7
9
  export { useEditable } from './hooks/use-editable';