@elementor/editor-controls 4.0.0-498 → 4.0.0-500
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 +28 -19
- package/dist/index.d.ts +28 -19
- package/dist/index.js +165 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +164 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/size/unit-select.tsx +69 -0
- package/src/components/size/unstable-size-field.tsx +63 -0
- package/src/components/size/unstable-size-input.tsx +46 -0
- package/src/hooks/use-size-value.ts +49 -0
- package/src/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -642,14 +642,14 @@ var TextFieldInnerSelection = forwardRef2(
|
|
|
642
642
|
id
|
|
643
643
|
}, ref) => {
|
|
644
644
|
const { placeholder: boundPropPlaceholder } = useBoundProp(sizePropTypeUtil);
|
|
645
|
-
const
|
|
645
|
+
const getCursorStyle2 = () => ({
|
|
646
646
|
input: { cursor: InputProps.readOnly ? "default !important" : void 0 }
|
|
647
647
|
});
|
|
648
648
|
return /* @__PURE__ */ React18.createElement(
|
|
649
649
|
NumberInput,
|
|
650
650
|
{
|
|
651
651
|
ref,
|
|
652
|
-
sx:
|
|
652
|
+
sx: getCursorStyle2(),
|
|
653
653
|
size: "tiny",
|
|
654
654
|
fullWidth: true,
|
|
655
655
|
type,
|
|
@@ -7000,6 +7000,167 @@ var usePopover = (openOnMount, onOpen) => {
|
|
|
7000
7000
|
popoverProps
|
|
7001
7001
|
};
|
|
7002
7002
|
};
|
|
7003
|
+
|
|
7004
|
+
// src/components/size/unstable-size-field.tsx
|
|
7005
|
+
import * as React107 from "react";
|
|
7006
|
+
import { InputAdornment as InputAdornment5 } from "@elementor/ui";
|
|
7007
|
+
|
|
7008
|
+
// src/hooks/use-size-value.ts
|
|
7009
|
+
var useSizeValue = (externalValue, onChange, defaultValue) => {
|
|
7010
|
+
const [sizeValue, setSizeValue] = useSyncExternalState({
|
|
7011
|
+
external: externalValue,
|
|
7012
|
+
setExternal: (newState) => {
|
|
7013
|
+
if (newState !== null) {
|
|
7014
|
+
onChange(newState);
|
|
7015
|
+
}
|
|
7016
|
+
},
|
|
7017
|
+
persistWhen: (newState) => differsFromExternal(newState, externalValue),
|
|
7018
|
+
fallback: () => defaultValue
|
|
7019
|
+
});
|
|
7020
|
+
const setSize = (value) => {
|
|
7021
|
+
const newState = {
|
|
7022
|
+
...sizeValue,
|
|
7023
|
+
size: value.trim() === "" ? null : Number(value)
|
|
7024
|
+
};
|
|
7025
|
+
setSizeValue(newState);
|
|
7026
|
+
};
|
|
7027
|
+
const setUnit = (unit) => {
|
|
7028
|
+
const newState = {
|
|
7029
|
+
...sizeValue,
|
|
7030
|
+
unit
|
|
7031
|
+
};
|
|
7032
|
+
setSizeValue(newState);
|
|
7033
|
+
};
|
|
7034
|
+
return {
|
|
7035
|
+
size: sizeValue.size,
|
|
7036
|
+
unit: sizeValue.unit,
|
|
7037
|
+
setSize,
|
|
7038
|
+
setUnit
|
|
7039
|
+
};
|
|
7040
|
+
};
|
|
7041
|
+
var differsFromExternal = (newState, externalState) => {
|
|
7042
|
+
return newState.size !== externalState.size || newState.unit !== externalState.unit;
|
|
7043
|
+
};
|
|
7044
|
+
|
|
7045
|
+
// src/components/size/unit-select.tsx
|
|
7046
|
+
import * as React105 from "react";
|
|
7047
|
+
import { useId as useId3 } from "react";
|
|
7048
|
+
import { MenuListItem as MenuListItem7 } from "@elementor/editor-ui";
|
|
7049
|
+
import { bindMenu as bindMenu2, bindTrigger as bindTrigger7, Button as Button5, Menu as Menu3, styled as styled11, usePopupState as usePopupState11 } from "@elementor/ui";
|
|
7050
|
+
var menuItemContentStyles = {
|
|
7051
|
+
display: "flex",
|
|
7052
|
+
flexDirection: "column",
|
|
7053
|
+
justifyContent: "center"
|
|
7054
|
+
};
|
|
7055
|
+
var UnitSelect = ({ value, showPrimaryColor, onClick, options }) => {
|
|
7056
|
+
const popupState = usePopupState11({
|
|
7057
|
+
variant: "popover",
|
|
7058
|
+
popupId: useId3()
|
|
7059
|
+
});
|
|
7060
|
+
const handleMenuItemClick = (index) => {
|
|
7061
|
+
onClick(options[index]);
|
|
7062
|
+
popupState.close();
|
|
7063
|
+
};
|
|
7064
|
+
return /* @__PURE__ */ React105.createElement(React105.Fragment, null, /* @__PURE__ */ React105.createElement(StyledButton2, { isPrimaryColor: showPrimaryColor, size: "small", ...bindTrigger7(popupState) }, value), /* @__PURE__ */ React105.createElement(Menu3, { MenuListProps: { dense: true }, ...bindMenu2(popupState) }, options.map((option, index) => /* @__PURE__ */ React105.createElement(
|
|
7065
|
+
MenuListItem7,
|
|
7066
|
+
{
|
|
7067
|
+
key: option,
|
|
7068
|
+
onClick: () => handleMenuItemClick(index),
|
|
7069
|
+
primaryTypographyProps: {
|
|
7070
|
+
variant: "caption",
|
|
7071
|
+
sx: {
|
|
7072
|
+
...menuItemContentStyles,
|
|
7073
|
+
lineHeight: "1"
|
|
7074
|
+
}
|
|
7075
|
+
},
|
|
7076
|
+
menuItemTextProps: {
|
|
7077
|
+
sx: menuItemContentStyles
|
|
7078
|
+
}
|
|
7079
|
+
},
|
|
7080
|
+
option.toUpperCase()
|
|
7081
|
+
))));
|
|
7082
|
+
};
|
|
7083
|
+
var StyledButton2 = styled11(Button5, {
|
|
7084
|
+
shouldForwardProp: (prop) => prop !== "isPrimaryColor"
|
|
7085
|
+
})(({ isPrimaryColor, theme }) => ({
|
|
7086
|
+
color: isPrimaryColor ? theme.palette.text.primary : theme.palette.text.tertiary,
|
|
7087
|
+
font: "inherit",
|
|
7088
|
+
minWidth: "initial",
|
|
7089
|
+
textTransform: "uppercase"
|
|
7090
|
+
}));
|
|
7091
|
+
|
|
7092
|
+
// src/components/size/unstable-size-input.tsx
|
|
7093
|
+
import * as React106 from "react";
|
|
7094
|
+
import { forwardRef as forwardRef11 } from "react";
|
|
7095
|
+
var UnstableSizeInput = forwardRef11(
|
|
7096
|
+
({ type, value, onChange, onKeyDown, onKeyUp, InputProps, onBlur, focused, disabled }, ref) => {
|
|
7097
|
+
return /* @__PURE__ */ React106.createElement(
|
|
7098
|
+
NumberInput,
|
|
7099
|
+
{
|
|
7100
|
+
ref,
|
|
7101
|
+
size: "tiny",
|
|
7102
|
+
fullWidth: true,
|
|
7103
|
+
type,
|
|
7104
|
+
value,
|
|
7105
|
+
onKeyUp,
|
|
7106
|
+
focused,
|
|
7107
|
+
disabled,
|
|
7108
|
+
onKeyDown,
|
|
7109
|
+
onInput: onChange,
|
|
7110
|
+
onBlur,
|
|
7111
|
+
InputProps,
|
|
7112
|
+
sx: getCursorStyle(InputProps?.readOnly ?? false)
|
|
7113
|
+
}
|
|
7114
|
+
);
|
|
7115
|
+
}
|
|
7116
|
+
);
|
|
7117
|
+
var getCursorStyle = (readOnly) => ({
|
|
7118
|
+
input: { cursor: readOnly ? "default !important" : void 0 }
|
|
7119
|
+
});
|
|
7120
|
+
|
|
7121
|
+
// src/components/size/unstable-size-field.tsx
|
|
7122
|
+
var DEFAULT_VALUE = {
|
|
7123
|
+
unit: "px",
|
|
7124
|
+
size: 0
|
|
7125
|
+
};
|
|
7126
|
+
var UnstableSizeField = ({
|
|
7127
|
+
value,
|
|
7128
|
+
defaultValue,
|
|
7129
|
+
onChange,
|
|
7130
|
+
onBlur,
|
|
7131
|
+
units: units2
|
|
7132
|
+
}) => {
|
|
7133
|
+
const { size, unit, setSize, setUnit } = useSizeValue(value, onChange, {
|
|
7134
|
+
...DEFAULT_VALUE,
|
|
7135
|
+
...defaultValue
|
|
7136
|
+
});
|
|
7137
|
+
const shouldHighlightUnit = () => {
|
|
7138
|
+
return hasValue(size);
|
|
7139
|
+
};
|
|
7140
|
+
return /* @__PURE__ */ React107.createElement(
|
|
7141
|
+
UnstableSizeInput,
|
|
7142
|
+
{
|
|
7143
|
+
type: "number",
|
|
7144
|
+
value: size ?? "",
|
|
7145
|
+
onBlur,
|
|
7146
|
+
onChange: (event) => setSize(event.target.value),
|
|
7147
|
+
InputProps: {
|
|
7148
|
+
endAdornment: /* @__PURE__ */ React107.createElement(InputAdornment5, { position: "end" }, /* @__PURE__ */ React107.createElement(
|
|
7149
|
+
UnitSelect,
|
|
7150
|
+
{
|
|
7151
|
+
options: units2,
|
|
7152
|
+
value: unit,
|
|
7153
|
+
onClick: setUnit,
|
|
7154
|
+
showPrimaryColor: shouldHighlightUnit()
|
|
7155
|
+
}
|
|
7156
|
+
))
|
|
7157
|
+
}
|
|
7158
|
+
}
|
|
7159
|
+
);
|
|
7160
|
+
};
|
|
7161
|
+
var hasValue = (value) => {
|
|
7162
|
+
return value !== null && value !== "";
|
|
7163
|
+
};
|
|
7003
7164
|
export {
|
|
7004
7165
|
AspectRatioControl,
|
|
7005
7166
|
BackgroundControl,
|
|
@@ -7049,6 +7210,7 @@ export {
|
|
|
7049
7210
|
TransformRepeaterControl,
|
|
7050
7211
|
TransformSettingsControl,
|
|
7051
7212
|
TransitionRepeaterControl,
|
|
7213
|
+
UnstableSizeField,
|
|
7052
7214
|
UrlControl,
|
|
7053
7215
|
createControl,
|
|
7054
7216
|
createControlReplacementsRegistry,
|