@onesy/ui-react 1.0.99 → 1.0.101
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/ColorTextField/ColorTextField.d.ts +1 -0
- package/ColorTextField/ColorTextField.js +5 -7
- package/SmartTextField/SmartTextField.js +11 -9
- package/esm/ColorTextField/ColorTextField.js +9 -7
- package/esm/SmartTextField/SmartTextField.js +10 -7
- package/esm/index.js +1 -1
- package/package.json +1 -1
@@ -7,6 +7,7 @@ export declare type IColorTextField = ITextField & {
|
|
7
7
|
onChangeColor?: (valueNew: string) => any;
|
8
8
|
onChangeOpacity?: (valueNew: string | number) => any;
|
9
9
|
opacity?: boolean;
|
10
|
+
WrapperProps?: any;
|
10
11
|
};
|
11
12
|
declare const ColorTextField: React.FC<IColorTextField>;
|
12
13
|
export default ColorTextField;
|
@@ -52,7 +52,7 @@ const useStyle = (0, style_react_1.style)(theme => ({
|
|
52
52
|
fontSize: '100%',
|
53
53
|
background: 'transparent',
|
54
54
|
boxSizing: 'border-box',
|
55
|
-
touchAction: 'manipulation'
|
55
|
+
touchAction: 'manipulation'
|
56
56
|
},
|
57
57
|
inputColor: {
|
58
58
|
// Reset
|
@@ -82,7 +82,7 @@ const ColorTextField = react_1.default.forwardRef((props_, ref) => {
|
|
82
82
|
const props = react_1.default.useMemo(() => { var _a, _b, _c, _d, _e, _f, _g, _h; return (Object.assign(Object.assign(Object.assign({}, (_d = (_c = (_b = (_a = theme === null || theme === void 0 ? void 0 : theme.ui) === null || _a === void 0 ? void 0 : _a.elements) === null || _b === void 0 ? void 0 : _b.all) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.default), (_h = (_g = (_f = (_e = theme === null || theme === void 0 ? void 0 : theme.ui) === null || _e === void 0 ? void 0 : _e.elements) === null || _f === void 0 ? void 0 : _f.onesyColorTextField) === null || _g === void 0 ? void 0 : _g.props) === null || _h === void 0 ? void 0 : _h.default), props_)); }, [props_]);
|
83
83
|
const Line = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.Line) || Line_1.default; }, [theme]);
|
84
84
|
const TextField = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.TextField) || TextField_1.default; }, [theme]);
|
85
|
-
const { name, version = 'outlined', size = 'regular', valueDefault, value: value_, valueColor: valueColor_, valueOpacity: valueOpacity_, onChange: onChange_, onChangeColor: onChangeColor_, onChangeOpacity: onChangeOpacity_, opacity, className } = props, other = __rest(props, ["name", "version", "size", "valueDefault", "value", "valueColor", "valueOpacity", "onChange", "onChangeColor", "onChangeOpacity", "opacity", "className"]);
|
85
|
+
const { name, version = 'outlined', size = 'regular', valueDefault, value: value_, valueColor: valueColor_, valueOpacity: valueOpacity_, onChange: onChange_, onChangeColor: onChangeColor_, onChangeOpacity: onChangeOpacity_, WrapperProps, opacity, className, style } = props, other = __rest(props, ["name", "version", "size", "valueDefault", "value", "valueColor", "valueOpacity", "onChange", "onChangeColor", "onChangeOpacity", "WrapperProps", "opacity", "className", "style"]);
|
86
86
|
const { classes } = useStyle();
|
87
87
|
const [value, setValue] = react_1.default.useState((valueDefault !== undefined ? valueDefault : value_) || '');
|
88
88
|
const [valueColor, setValueColor] = react_1.default.useState(valueColor_ !== undefined ? valueColor_ : '');
|
@@ -167,13 +167,11 @@ const ColorTextField = react_1.default.forwardRef((props_, ref) => {
|
|
167
167
|
`onesy-ColorTextField-version-${version}`,
|
168
168
|
`onesy-ColorTextField-size-${size}`
|
169
169
|
],
|
170
|
+
className,
|
170
171
|
classes.root
|
171
|
-
]), fullWidth: opacity }, (!opacity && other))));
|
172
|
+
]), fullWidth: opacity, style: style }, (!opacity && other))));
|
172
173
|
if (opacity) {
|
173
|
-
return ((0, jsx_runtime_1.jsxs)(Line, Object.assign({ ref: ref, gap: 1, fullWidth: true,
|
174
|
-
className,
|
175
|
-
classes.root
|
176
|
-
]) }, other, { children: [root, (0, jsx_runtime_1.jsx)(SliderInput, { name: l('Opacity'), value: valueOpacity, onChange: onChangeOpacity, min: 0, max: 100 })] })));
|
174
|
+
return ((0, jsx_runtime_1.jsxs)(Line, Object.assign({ ref: ref, gap: 1, fullWidth: true }, WrapperProps, { children: [root, (0, jsx_runtime_1.jsx)(SliderInput, { name: l('Opacity'), value: valueOpacity, onChange: onChangeOpacity, min: 0, max: 100 })] })));
|
177
175
|
}
|
178
176
|
return root;
|
179
177
|
});
|
@@ -600,14 +600,9 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
|
|
600
600
|
}, 140);
|
601
601
|
}, []);
|
602
602
|
const onMouseDown = react_1.default.useCallback(() => {
|
603
|
-
var _a, _b;
|
604
603
|
if (!refs.edit.current)
|
605
604
|
return;
|
606
605
|
textQueryUpdate();
|
607
|
-
const selection_ = refs.rootWindow.current.getSelection();
|
608
|
-
if (selection_.anchorNode &&
|
609
|
-
!((_b = (_a = selection_.anchorNode) === null || _a === void 0 ? void 0 : _a.className) === null || _b === void 0 ? void 0 : _b.includes('TextField')))
|
610
|
-
refs.range.current = selection_.getRangeAt(0);
|
611
606
|
}, []);
|
612
607
|
const onKeyUp = react_1.default.useCallback(() => {
|
613
608
|
if (!refs.edit.current)
|
@@ -807,9 +802,9 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
|
|
807
802
|
'onesy-RichTextEditor-palette'
|
808
803
|
],
|
809
804
|
classes.palette
|
810
|
-
]) }, other_, { children: [(0, jsx_runtime_1.jsxs)(Line, Object.assign({ gap: 0.5,
|
805
|
+
]) }, other_, { children: [(0, jsx_runtime_1.jsxs)(Line, Object.assign({ gap: 0.5, style: {
|
811
806
|
maxHeight: 136,
|
812
|
-
padding:
|
807
|
+
padding: '10px 10px 0',
|
813
808
|
overflow: 'hidden auto'
|
814
809
|
} }, { children: [(0, jsx_runtime_1.jsxs)(Line, Object.assign({ gap: 0.5, direction: 'row', style: {
|
815
810
|
width: '100%'
|
@@ -830,7 +825,7 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
|
|
830
825
|
onUpdate_(style_react_1.colors[item][item_]);
|
831
826
|
onClose();
|
832
827
|
} }, index_))) }), index)))] })), (0, jsx_runtime_1.jsx)(Divider, {}), (0, jsx_runtime_1.jsxs)(Line, Object.assign({ gap: 0.5, direction: 'row', align: 'center', fullWidth: true, style: {
|
833
|
-
padding:
|
828
|
+
padding: '0px 10px 10px'
|
834
829
|
} }, { children: [(0, jsx_runtime_1.jsx)(ColorTextField, Object.assign({ tonal: tonal, color: color, name: l('Custom color'), version: 'outlined', size: 'small', value: refs.inputValues.current[version_], onChange: valueNew => updateInputValues(version_, valueNew) }, ColorTextFieldProps, { className: (0, style_react_1.classNames)([
|
835
830
|
(0, utils_2.staticClassName)('RichTextEditor', theme) && [
|
836
831
|
'onesy-RichTextEditor-text-field-color'
|
@@ -911,7 +906,14 @@ const SmartTextField = react_1.default.forwardRef((props_, ref) => {
|
|
911
906
|
updateInputValues('link', '');
|
912
907
|
}, className: classes.input }) }))) }, { children: (0, jsx_runtime_1.jsx)(WrapperToggleButton, Object.assign({ name: l('Insert Link'), open: refs.open.current.linkMiniMenu ? false : undefined }, { children: (0, jsx_runtime_1.jsx)(ToggleButton, Object.assign({ ref: refs.miniMenuElements.linkAdd }, ToggleButtonProps, { selected: refs.open.current.linkMiniMenu, onClick: () => updateOpen('linkMiniMenu', !refs.open.current.linkMiniMenu) }, { children: (0, jsx_runtime_1.jsx)(IconMaterialAddLinkW100_1.default, Object.assign({}, IconProps)) })) })) }))),
|
913
908
|
'link-remove': ((0, jsx_runtime_1.jsx)(WrapperToggleButton, Object.assign({ name: l('Remove Link') }, { children: (0, jsx_runtime_1.jsx)(ToggleButton, Object.assign({}, ToggleButtonProps, { onClick: textMethod('link-remove') }, { children: (0, jsx_runtime_1.jsx)(IconMaterialLinkOffW100_1.default, Object.assign({}, IconProps)) })) }))),
|
914
|
-
'font-color': ((0, jsx_runtime_1.jsx)(WrapperAppend, Object.assign({ open: refs.open.current.color, anchorElement: refs.elements.color.current, element: ((0, jsx_runtime_1.jsx)(ClickListener, Object.assign({ onClickOutside: () => updateOpen('color', false), include: [refs.elements.color.current] }, { children: (0, jsx_runtime_1.jsx)(Palette, { version: 'font-color', onClose: () => updateOpen('color', false), onUpdate:
|
909
|
+
'font-color': ((0, jsx_runtime_1.jsx)(WrapperAppend, Object.assign({ open: refs.open.current.color, anchorElement: refs.elements.color.current, element: ((0, jsx_runtime_1.jsx)(ClickListener, Object.assign({ onClickOutside: () => updateOpen('color', false), include: [refs.elements.color.current] }, { children: (0, jsx_runtime_1.jsx)(Palette, { version: 'font-color', onClose: () => updateOpen('color', false), onUpdate: () => {
|
910
|
+
if (refs.range.current) {
|
911
|
+
const selection_ = refs.rootWindow.current.getSelection();
|
912
|
+
selection_.removeAllRanges();
|
913
|
+
selection_.addRange(refs.range.current);
|
914
|
+
}
|
915
|
+
textMethod('font-color');
|
916
|
+
} }) }))) }, { children: (0, jsx_runtime_1.jsx)(WrapperToggleButton, Object.assign({ name: l('Text Color'), open: refs.open.current.color ? false : undefined }, { children: (0, jsx_runtime_1.jsx)(ToggleButton, Object.assign({ ref: refs.elements.color }, ToggleButtonProps, { selected: refs.open.current.color, onClick: () => updateOpen('color', !refs.open.current.color) }, { children: (0, jsx_runtime_1.jsx)(IconMaterialFormatColorTextW100_1.default, Object.assign({}, IconProps)) })) })) }))),
|
915
917
|
'font-color-mini-menu': ((0, jsx_runtime_1.jsx)(WrapperAppend, Object.assign({ open: refs.open.current.colorMiniMenu, anchorElement: refs.miniMenuElements.color, element: ((0, jsx_runtime_1.jsx)(ClickListener, Object.assign({ onClickOutside: () => updateOpen('colorMiniMenu', false), include: [refs.miniMenuElements.color] }, { children: (0, jsx_runtime_1.jsx)(Palette, { ref: refs.miniMenuElements.colorPalette, version: 'font-color', onClose: () => updateOpen('colorMiniMenu', false), onUpdate: textMethod('font-color') }) }))) }, { children: (0, jsx_runtime_1.jsx)(WrapperToggleButton, Object.assign({ name: l('Text Color'), open: refs.open.current.colorMiniMenu ? false : undefined }, { children: (0, jsx_runtime_1.jsx)(ToggleButton, Object.assign({ ref: refs.miniMenuElements.color }, ToggleButtonProps, { selected: refs.open.current.colorMiniMenu, onClick: () => updateOpen('colorMiniMenu', !refs.open.current.colorMiniMenu) }, { children: (0, jsx_runtime_1.jsx)(IconMaterialFormatColorTextW100_1.default, Object.assign({}, IconProps)) })) })) }))),
|
916
918
|
'font-background': ((0, jsx_runtime_1.jsx)(WrapperAppend, Object.assign({ open: refs.open.current.background, anchorElement: refs.elements.background.current, element: ((0, jsx_runtime_1.jsx)(ClickListener, Object.assign({ onClickOutside: () => updateOpen('background', false), include: [refs.elements.background.current] }, { children: (0, jsx_runtime_1.jsx)(Palette, { version: 'font-background', onClose: () => updateOpen('background', false), onUpdate: textMethod('font-background') }) }))) }, { children: (0, jsx_runtime_1.jsx)(WrapperToggleButton, Object.assign({ name: l('Background Color'), open: refs.open.current.background ? false : undefined }, { children: (0, jsx_runtime_1.jsx)(ToggleButton, Object.assign({ ref: refs.elements.background }, ToggleButtonProps, { selected: refs.open.current.background, onClick: () => updateOpen('background', !refs.open.current.background) }, { children: (0, jsx_runtime_1.jsx)(IconMaterialFormatColorFillW100_1.default, Object.assign({}, IconProps)) })) })) }))),
|
917
919
|
'font-background-mini-menu': ((0, jsx_runtime_1.jsx)(WrapperAppend, Object.assign({ open: refs.open.current.backgroundMiniMenu, anchorElement: refs.miniMenuElements.background, element: ((0, jsx_runtime_1.jsx)(ClickListener, Object.assign({ onClickOutside: () => updateOpen('backgroundMiniMenu', false), include: [refs.miniMenuElements.background] }, { children: (0, jsx_runtime_1.jsx)(Palette, { ref: refs.miniMenuElements.backgroundPalette, version: 'font-background', onClose: () => updateOpen('backgroundMiniMenu', false), onUpdate: textMethod('font-background') }) }))) }, { children: (0, jsx_runtime_1.jsx)(WrapperToggleButton, Object.assign({ name: l('Text Color'), open: refs.open.current.backgroundMiniMenu ? false : undefined }, { children: (0, jsx_runtime_1.jsx)(ToggleButton, Object.assign({ ref: refs.miniMenuElements.background }, ToggleButtonProps, { selected: refs.open.current.backgroundMiniMenu, onClick: () => updateOpen('backgroundMiniMenu', !refs.open.current.backgroundMiniMenu) }, { children: (0, jsx_runtime_1.jsx)(IconMaterialFormatColorFillW100_1.default, Object.assign({}, IconProps)) })) })) }))),
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
4
|
const _excluded = ["name", "value", "onChange", "min", "max", "children", "className"],
|
5
|
-
_excluded2 = ["name", "version", "size", "valueDefault", "value", "valueColor", "valueOpacity", "onChange", "onChangeColor", "onChangeOpacity", "opacity", "className"];
|
5
|
+
_excluded2 = ["name", "version", "size", "valueDefault", "value", "valueColor", "valueOpacity", "onChange", "onChangeColor", "onChangeOpacity", "WrapperProps", "opacity", "className", "style"];
|
6
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
8
8
|
import React from 'react';
|
@@ -114,8 +114,10 @@ const ColorTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
114
114
|
onChange: onChange_,
|
115
115
|
onChangeColor: onChangeColor_,
|
116
116
|
onChangeOpacity: onChangeOpacity_,
|
117
|
+
WrapperProps,
|
117
118
|
opacity,
|
118
|
-
className
|
119
|
+
className,
|
120
|
+
style
|
119
121
|
} = props,
|
120
122
|
other = _objectWithoutProperties(props, _excluded2);
|
121
123
|
const {
|
@@ -192,16 +194,16 @@ const ColorTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
192
194
|
onChange: event => opacity ? onChangeColor(event.target.value) : onChange(event.target.value),
|
193
195
|
className: classNames([staticClassName('ColorTextField', theme) && ['onesy-ColorTextField-input-color'], classes.inputColor])
|
194
196
|
}),
|
195
|
-
className: classNames([staticClassName('ColorTextField', theme) && ['onesy-ColorTextField-root', `onesy-ColorTextField-version-${version}`, `onesy-ColorTextField-size-${size}`], classes.root]),
|
196
|
-
fullWidth: opacity
|
197
|
+
className: classNames([staticClassName('ColorTextField', theme) && ['onesy-ColorTextField-root', `onesy-ColorTextField-version-${version}`, `onesy-ColorTextField-size-${size}`], className, classes.root]),
|
198
|
+
fullWidth: opacity,
|
199
|
+
style: style
|
197
200
|
}, !opacity && other));
|
198
201
|
if (opacity) {
|
199
202
|
return /*#__PURE__*/React.createElement(Line, _extends({
|
200
203
|
ref: ref,
|
201
204
|
gap: 1,
|
202
|
-
fullWidth: true
|
203
|
-
|
204
|
-
}, other), root, /*#__PURE__*/React.createElement(SliderInput, {
|
205
|
+
fullWidth: true
|
206
|
+
}, WrapperProps), root, /*#__PURE__*/React.createElement(SliderInput, {
|
205
207
|
name: l('Opacity'),
|
206
208
|
value: valueOpacity,
|
207
209
|
onChange: onChangeOpacity,
|
@@ -646,8 +646,6 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
646
646
|
const onMouseDown = React.useCallback(() => {
|
647
647
|
if (!refs.edit.current) return;
|
648
648
|
textQueryUpdate();
|
649
|
-
const selection_ = refs.rootWindow.current.getSelection();
|
650
|
-
if (selection_.anchorNode && !selection_.anchorNode?.className?.includes('TextField')) refs.range.current = selection_.getRangeAt(0);
|
651
649
|
}, []);
|
652
650
|
const onKeyUp = React.useCallback(() => {
|
653
651
|
if (!refs.edit.current) return;
|
@@ -817,11 +815,9 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
817
815
|
className: classNames([staticClassName('RichTextEditor', theme) && ['onesy-RichTextEditor-palette'], classes.palette])
|
818
816
|
}, other_), /*#__PURE__*/React.createElement(Line, {
|
819
817
|
gap: 0.5,
|
820
|
-
onMouseUp: onMouseUp,
|
821
|
-
onMouseDown: onMouseDown,
|
822
818
|
style: {
|
823
819
|
maxHeight: 136,
|
824
|
-
padding:
|
820
|
+
padding: '10px 10px 0',
|
825
821
|
overflow: 'hidden auto'
|
826
822
|
}
|
827
823
|
}, /*#__PURE__*/React.createElement(Line, {
|
@@ -867,7 +863,7 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
867
863
|
align: "center",
|
868
864
|
fullWidth: true,
|
869
865
|
style: {
|
870
|
-
padding:
|
866
|
+
padding: '0px 10px 10px'
|
871
867
|
}
|
872
868
|
}, /*#__PURE__*/React.createElement(ColorTextField, _extends({
|
873
869
|
tonal: tonal,
|
@@ -1082,7 +1078,14 @@ const SmartTextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
1082
1078
|
}, /*#__PURE__*/React.createElement(Palette, {
|
1083
1079
|
version: "font-color",
|
1084
1080
|
onClose: () => updateOpen('color', false),
|
1085
|
-
onUpdate:
|
1081
|
+
onUpdate: () => {
|
1082
|
+
if (refs.range.current) {
|
1083
|
+
const selection_ = refs.rootWindow.current.getSelection();
|
1084
|
+
selection_.removeAllRanges();
|
1085
|
+
selection_.addRange(refs.range.current);
|
1086
|
+
}
|
1087
|
+
textMethod('font-color');
|
1088
|
+
}
|
1086
1089
|
}))
|
1087
1090
|
}, /*#__PURE__*/React.createElement(WrapperToggleButton, {
|
1088
1091
|
name: l('Text Color'),
|
package/esm/index.js
CHANGED