@onesy/ui-react 1.0.125 → 1.0.127
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/TextField/TextField.js +21 -21
- package/esm/TextField/TextField.js +29 -29
- package/esm/index.js +1 -1
- package/package.json +1 -1
package/TextField/TextField.js
CHANGED
|
@@ -401,7 +401,7 @@ const TextField = react_1.default.forwardRef((props_, ref) => {
|
|
|
401
401
|
const Type = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.Type) || Type_1.default; }, [theme]);
|
|
402
402
|
const Tooltip = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.Tooltip) || Tooltip_1.default; }, [theme]);
|
|
403
403
|
const IconButton = react_1.default.useMemo(() => { var _a; return ((_a = theme === null || theme === void 0 ? void 0 : theme.elements) === null || _a === void 0 ? void 0 : _a.IconButton) || IconButton_1.default; }, [theme]);
|
|
404
|
-
const { tonal = true, color = 'primary', version = 'filled', size = 'regular', rootRef, valueDefault, value: value_, onChange, name, label: label_, align, start, startVerticalAlign = 'start', end: end_, endVerticalAlign: endVerticalAlign_ = 'start', placeholder, fullWidth: fullWidth_, helperText, counter, prefix, sufix, noPrefixMargin, noSufixMargin, enabled, autoFocus, autoComplete, type: type_ = 'text', required, optional, optionalText = 'optional', error, multiline, rows: rows_, minRows = 1, maxRows, clear, focus: focus_, footer: footer_, subscription, controlled, minimal, restoreSelection = false, minWidth, readOnly, disabled, onInput: onInput_, onFocus: onFocus_, onBlur: onBlur_, onMouseEnter: onMouseEnter_, onMouseLeave: onMouseLeave_, inputProps = {}, InputWrapperProps = {}, HelperTextProps, IconProps, IconClear = IconMaterialCloseW100_1.default, InputComponent: InputComponent_, WrapperComponent = 'div', Component = 'div', className, style, children,
|
|
404
|
+
const { tonal = true, color = 'primary', version = 'filled', size = 'regular', rootRef, valueDefault, value: value_, onChange, name, label: label_, align, start, startVerticalAlign: startVerticalAlign_ = 'start', end: end_, endVerticalAlign: endVerticalAlign_ = 'start', placeholder, fullWidth: fullWidth_, helperText, counter, prefix, sufix, noPrefixMargin, noSufixMargin, enabled, autoFocus, autoComplete, type: type_ = 'text', required, optional, optionalText = 'optional', error, multiline, rows: rows_, minRows = 1, maxRows, clear, focus: focus_, footer: footer_, subscription, controlled, minimal, restoreSelection = false, minWidth, readOnly, disabled, onInput: onInput_, onFocus: onFocus_, onBlur: onBlur_, onMouseEnter: onMouseEnter_, onMouseLeave: onMouseLeave_, inputProps = {}, InputWrapperProps = {}, HelperTextProps, IconProps, IconClear = IconMaterialCloseW100_1.default, InputComponent: InputComponent_, WrapperComponent = 'div', Component = 'div', className, style, children,
|
|
405
405
|
// Other
|
|
406
406
|
colorUnchecked } = props, other = __rest(props, ["tonal", "color", "version", "size", "rootRef", "valueDefault", "value", "onChange", "name", "label", "align", "start", "startVerticalAlign", "end", "endVerticalAlign", "placeholder", "fullWidth", "helperText", "counter", "prefix", "sufix", "noPrefixMargin", "noSufixMargin", "enabled", "autoFocus", "autoComplete", "type", "required", "optional", "optionalText", "error", "multiline", "rows", "minRows", "maxRows", "clear", "focus", "footer", "subscription", "controlled", "minimal", "restoreSelection", "minWidth", "readOnly", "disabled", "onInput", "onFocus", "onBlur", "onMouseEnter", "onMouseLeave", "inputProps", "InputWrapperProps", "HelperTextProps", "IconProps", "IconClear", "InputComponent", "WrapperComponent", "Component", "className", "style", "children", "colorUnchecked"]);
|
|
407
407
|
const { classes } = useStyle();
|
|
@@ -431,6 +431,7 @@ const TextField = react_1.default.forwardRef((props_, ref) => {
|
|
|
431
431
|
breakpoints[key] = (0, useMediaQuery_1.default)(theme.breakpoints.media[key], { element: refs.root.current });
|
|
432
432
|
});
|
|
433
433
|
const label = name !== undefined ? name : label_;
|
|
434
|
+
let startVerticalAlign = startVerticalAlign_;
|
|
434
435
|
let endVerticalAlign = endVerticalAlign_;
|
|
435
436
|
const fullWidth = (0, utils_2.valueBreakpoints)(fullWidth_, undefined, breakpoints, theme);
|
|
436
437
|
const rowValue = () => {
|
|
@@ -685,27 +686,26 @@ const TextField = react_1.default.forwardRef((props_, ref) => {
|
|
|
685
686
|
const iconProps = {
|
|
686
687
|
size
|
|
687
688
|
};
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
IconProps === null || IconProps === void 0 ? void 0 : IconProps.className,
|
|
698
|
-
classes.clear
|
|
699
|
-
]) }), refs.ids.clear));
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
if (value && password) {
|
|
703
|
-
if (!multiline && props.endVerticalAlign === undefined)
|
|
704
|
-
endVerticalAlign = version === 'text' ? 'end' : 'center';
|
|
705
|
-
endItems.unshift((0, jsx_runtime_1.jsx)(Tooltip, Object.assign({ name: visible ? l('Hide password') : l('View password'), color: 'inverted' }, { children: (0, jsx_runtime_1.jsx)(IconButton, Object.assign({ onClick: onToggleVisible, color: 'default', size: size === 'large' ? 'regular' : 'small' }, { children: visible ? (0, jsx_runtime_1.jsx)(IconMaterialPassword2OffW100_1.default, Object.assign({}, iconProps)) : (0, jsx_runtime_1.jsx)(IconMaterialPassword2W100_1.default, Object.assign({}, iconProps)) })) })));
|
|
689
|
+
const isTypePassword = type === 'password';
|
|
690
|
+
const end = (Array.isArray(end_) ? end_ : [end_]).filter(Boolean);
|
|
691
|
+
if (value && clear) {
|
|
692
|
+
const exists = end === null || end === void 0 ? void 0 : end.find(item => item.key === refs.ids.clear);
|
|
693
|
+
if (!exists) {
|
|
694
|
+
end.push((0, jsx_runtime_1.jsx)(IconClear, Object.assign({ color: 'inherit', onClick: onClear }, IconProps, { className: (0, style_react_1.classNames)([
|
|
695
|
+
IconProps === null || IconProps === void 0 ? void 0 : IconProps.className,
|
|
696
|
+
classes.clear
|
|
697
|
+
]) }), refs.ids.clear));
|
|
706
698
|
}
|
|
707
|
-
|
|
708
|
-
|
|
699
|
+
}
|
|
700
|
+
if (value && isTypePassword) {
|
|
701
|
+
end.unshift((0, jsx_runtime_1.jsx)(Tooltip, Object.assign({ name: visible ? l('Hide password') : l('View password'), color: 'inverted' }, { children: (0, jsx_runtime_1.jsx)(IconButton, Object.assign({ onClick: onToggleVisible, color: 'default', size: size === 'large' ? 'regular' : 'small' }, { children: visible ? (0, jsx_runtime_1.jsx)(IconMaterialPassword2OffW100_1.default, Object.assign({}, iconProps)) : (0, jsx_runtime_1.jsx)(IconMaterialPassword2W100_1.default, Object.assign({}, iconProps)) })) })));
|
|
702
|
+
}
|
|
703
|
+
if (!multiline) {
|
|
704
|
+
if (props.startVerticalAlign === undefined)
|
|
705
|
+
startVerticalAlign = version === 'text' ? 'end' : 'center';
|
|
706
|
+
if (props.endVerticalAlign === undefined)
|
|
707
|
+
endVerticalAlign = version === 'text' ? 'end' : 'center';
|
|
708
|
+
}
|
|
709
709
|
const valueWithData = value !== undefined && String(value);
|
|
710
710
|
return ((0, jsx_runtime_1.jsxs)(Wrapper, Object.assign({}, WrapperProps, { children: [(0, jsx_runtime_1.jsxs)(Component, Object.assign({ onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onTouchStart: onMouseEnter, onTouchEnd: onMouseLeave, role: 'textbox', "aria-multiline": multiline, "aria-labelledby": refs.ids.label }, ComponentProps, { className: (0, style_react_1.classNames)([
|
|
711
711
|
(0, utils_2.staticClassName)('TextField', theme) && [
|
|
@@ -496,7 +496,7 @@ const TextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
|
496
496
|
label: label_,
|
|
497
497
|
align,
|
|
498
498
|
start,
|
|
499
|
-
startVerticalAlign = 'start',
|
|
499
|
+
startVerticalAlign: startVerticalAlign_ = 'start',
|
|
500
500
|
end: end_,
|
|
501
501
|
endVerticalAlign: endVerticalAlign_ = 'start',
|
|
502
502
|
placeholder,
|
|
@@ -579,6 +579,7 @@ const TextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
|
579
579
|
});
|
|
580
580
|
});
|
|
581
581
|
const label = name !== undefined ? name : label_;
|
|
582
|
+
let startVerticalAlign = startVerticalAlign_;
|
|
582
583
|
let endVerticalAlign = endVerticalAlign_;
|
|
583
584
|
const fullWidth = valueBreakpoints(fullWidth_, undefined, breakpoints, theme);
|
|
584
585
|
const rowValue = () => {
|
|
@@ -803,35 +804,34 @@ const TextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
|
803
804
|
const iconProps = {
|
|
804
805
|
size
|
|
805
806
|
};
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
className: classNames([IconProps?.className, classes.clear])
|
|
819
|
-
})));
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
if (value && password) {
|
|
823
|
-
if (!multiline && props.endVerticalAlign === undefined) endVerticalAlign = version === 'text' ? 'end' : 'center';
|
|
824
|
-
endItems.unshift(/*#__PURE__*/React.createElement(Tooltip, {
|
|
825
|
-
name: visible ? l('Hide password') : l('View password'),
|
|
826
|
-
color: "inverted"
|
|
827
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
828
|
-
onClick: onToggleVisible,
|
|
829
|
-
color: "default",
|
|
830
|
-
size: size === 'large' ? 'regular' : 'small'
|
|
831
|
-
}, visible ? /*#__PURE__*/React.createElement(IconMaterialPassword2Off, iconProps) : /*#__PURE__*/React.createElement(IconMaterialPassword2, iconProps))));
|
|
807
|
+
const isTypePassword = type === 'password';
|
|
808
|
+
const end = (Array.isArray(end_) ? end_ : [end_]).filter(Boolean);
|
|
809
|
+
if (value && clear) {
|
|
810
|
+
const exists = end?.find(item => item.key === refs.ids.clear);
|
|
811
|
+
if (!exists) {
|
|
812
|
+
end.push(/*#__PURE__*/React.createElement(IconClear, _extends({
|
|
813
|
+
key: refs.ids.clear,
|
|
814
|
+
color: "inherit",
|
|
815
|
+
onClick: onClear
|
|
816
|
+
}, IconProps, {
|
|
817
|
+
className: classNames([IconProps?.className, classes.clear])
|
|
818
|
+
})));
|
|
832
819
|
}
|
|
833
|
-
|
|
834
|
-
|
|
820
|
+
}
|
|
821
|
+
if (value && isTypePassword) {
|
|
822
|
+
end.unshift(/*#__PURE__*/React.createElement(Tooltip, {
|
|
823
|
+
name: visible ? l('Hide password') : l('View password'),
|
|
824
|
+
color: "inverted"
|
|
825
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
826
|
+
onClick: onToggleVisible,
|
|
827
|
+
color: "default",
|
|
828
|
+
size: size === 'large' ? 'regular' : 'small'
|
|
829
|
+
}, visible ? /*#__PURE__*/React.createElement(IconMaterialPassword2Off, iconProps) : /*#__PURE__*/React.createElement(IconMaterialPassword2, iconProps))));
|
|
830
|
+
}
|
|
831
|
+
if (!multiline) {
|
|
832
|
+
if (props.startVerticalAlign === undefined) startVerticalAlign = version === 'text' ? 'end' : 'center';
|
|
833
|
+
if (props.endVerticalAlign === undefined) endVerticalAlign = version === 'text' ? 'end' : 'center';
|
|
834
|
+
}
|
|
835
835
|
const valueWithData = value !== undefined && String(value);
|
|
836
836
|
return /*#__PURE__*/React.createElement(Wrapper, WrapperProps, /*#__PURE__*/React.createElement(Component, _extends({
|
|
837
837
|
onMouseEnter: onMouseEnter,
|
package/esm/index.js
CHANGED