@elementor/editor-controls 3.35.0-492 → 3.35.0
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 +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.js +494 -477
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +510 -496
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/inline-editor-toolbar.tsx +78 -74
- package/src/components/inline-editor.tsx +157 -231
- package/src/components/promotions/display-conditions-control.tsx +61 -0
- package/src/controls/inline-editing-control.tsx +1 -1
- package/src/index.ts +2 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { PromotionChip, PromotionInfotip } from '@elementor/editor-ui';
|
|
4
|
+
import { SitemapIcon } from '@elementor/icons';
|
|
5
|
+
import { Box, IconButton, Stack, Tooltip } from '@elementor/ui';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
|
|
8
|
+
import { createControl } from '../../create-control';
|
|
9
|
+
|
|
10
|
+
const ARIA_LABEL = __( 'Display Conditions', 'elementor' );
|
|
11
|
+
|
|
12
|
+
function getDisplayConditionPromotion() {
|
|
13
|
+
return window.elementor?.config?.v4Promotions?.displayConditions;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const DisplayConditionsControl = createControl( () => {
|
|
17
|
+
const [ isInfotipOpen, setIsInfotipOpen ] = useState( false );
|
|
18
|
+
const promotion = getDisplayConditionPromotion();
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Stack
|
|
22
|
+
direction="row"
|
|
23
|
+
spacing={ 2 }
|
|
24
|
+
sx={ {
|
|
25
|
+
justifyContent: 'flex-end',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
} }
|
|
28
|
+
>
|
|
29
|
+
<PromotionInfotip
|
|
30
|
+
title={ promotion?.title ?? '' }
|
|
31
|
+
content={ promotion?.content ?? '' }
|
|
32
|
+
assetUrl={ promotion?.image ?? '' }
|
|
33
|
+
ctaUrl={ promotion?.ctaUrl ?? '' }
|
|
34
|
+
open={ isInfotipOpen }
|
|
35
|
+
onClose={ () => setIsInfotipOpen( false ) }
|
|
36
|
+
>
|
|
37
|
+
<Box
|
|
38
|
+
onClick={ () => setIsInfotipOpen( ( prev ) => ! prev ) }
|
|
39
|
+
sx={ { cursor: 'pointer', display: 'inline-flex' } }
|
|
40
|
+
>
|
|
41
|
+
<PromotionChip />
|
|
42
|
+
</Box>
|
|
43
|
+
</PromotionInfotip>
|
|
44
|
+
<Tooltip title={ ARIA_LABEL } placement="top">
|
|
45
|
+
<IconButton
|
|
46
|
+
size="tiny"
|
|
47
|
+
aria-label={ ARIA_LABEL }
|
|
48
|
+
data-behavior="display-conditions"
|
|
49
|
+
onClick={ () => setIsInfotipOpen( ( prev ) => ! prev ) }
|
|
50
|
+
sx={ {
|
|
51
|
+
border: '1px solid',
|
|
52
|
+
borderColor: 'divider',
|
|
53
|
+
borderRadius: 1,
|
|
54
|
+
} }
|
|
55
|
+
>
|
|
56
|
+
<SitemapIcon fontSize="tiny" color="disabled" />
|
|
57
|
+
</IconButton>
|
|
58
|
+
</Tooltip>
|
|
59
|
+
</Stack>
|
|
60
|
+
);
|
|
61
|
+
} );
|
|
@@ -19,7 +19,7 @@ export const InlineEditingControl = createControl(
|
|
|
19
19
|
props?: ComponentProps< 'div' >;
|
|
20
20
|
} ) => {
|
|
21
21
|
const { value, setValue } = useBoundProp( htmlPropTypeUtil );
|
|
22
|
-
const handleChange = ( newValue: unknown ) => setValue( newValue as string );
|
|
22
|
+
const handleChange = ( newValue: unknown ) => setValue( ( newValue ?? '' ) as string );
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<ControlActions>
|
package/src/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ export { enqueueFont } from './controls/font-family-control/enqueue-font';
|
|
|
35
35
|
export { transitionProperties, transitionsItemsList } from './controls/transition-control/data';
|
|
36
36
|
export { DateTimeControl } from './controls/date-time-control';
|
|
37
37
|
export { InlineEditingControl } from './controls/inline-editing-control';
|
|
38
|
+
export { DisplayConditionsControl } from './components/promotions/display-conditions-control';
|
|
38
39
|
|
|
39
40
|
// components
|
|
40
41
|
export { ControlFormLabel } from './components/control-form-label';
|
|
@@ -63,6 +64,7 @@ export type { SetValue, SetValueMeta } from './bound-prop-context/prop-context';
|
|
|
63
64
|
export type { ExtendedOption, Unit, LengthUnit, AngleUnit, TimeUnit } from './utils/size-control';
|
|
64
65
|
export type { ToggleControlProps } from './controls/toggle-control';
|
|
65
66
|
export type { FontCategory } from './controls/font-family-control/font-family-control';
|
|
67
|
+
export type { InlineEditorToolbarProps } from './components/inline-editor-toolbar';
|
|
66
68
|
|
|
67
69
|
// providers
|
|
68
70
|
export {
|