@onesy/ui-react 1.0.114 → 1.0.116
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 +2 -1
- package/esm/TextField/TextField.js +2 -1
- package/esm/index.js +1 -1
- package/esm/useForm/useForm.js +2 -2
- package/esm/useForm/validate.js +1 -1
- package/package.json +1 -1
- package/useForm/useForm.js +2 -2
- package/useForm/validate.js +1 -1
package/TextField/TextField.js
CHANGED
|
@@ -364,6 +364,7 @@ const useStyle = (0, style_react_1.style)(theme => {
|
|
|
364
364
|
const TextField = react_1.default.forwardRef((props_, ref) => {
|
|
365
365
|
var _a, _b, _c, _d, _e, _f;
|
|
366
366
|
const theme = (0, style_react_1.useOnesyTheme)();
|
|
367
|
+
const l = theme.l;
|
|
367
368
|
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.onesyTextField) === null || _g === void 0 ? void 0 : _g.props) === null || _h === void 0 ? void 0 : _h.default), props_)); }, [props_]);
|
|
368
369
|
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]);
|
|
369
370
|
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]);
|
|
@@ -838,7 +839,7 @@ const TextField = react_1.default.forwardRef((props_, ref) => {
|
|
|
838
839
|
HelperTextProps === null || HelperTextProps === void 0 ? void 0 : HelperTextProps.className,
|
|
839
840
|
classes.helperText,
|
|
840
841
|
error && classes.error_color
|
|
841
|
-
]) }, { children: helperText !== undefined ? helperText : required ? '
|
|
842
|
+
]) }, { children: helperText !== undefined ? helperText : required ? `*${l('required')}` : '' }))), counter && ((0, jsx_runtime_1.jsxs)(Type, Object.assign({ version: 'b3', className: (0, style_react_1.classNames)([
|
|
842
843
|
(0, utils_2.staticClassName)('TextField', theme) && [
|
|
843
844
|
'onesy-TextField-counter'
|
|
844
845
|
],
|
|
@@ -443,6 +443,7 @@ const useStyle = styleMethod(theme => {
|
|
|
443
443
|
});
|
|
444
444
|
const TextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
445
445
|
const theme = useOnesyTheme();
|
|
446
|
+
const l = theme.l;
|
|
446
447
|
const props = React.useMemo(() => _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.onesyTextField?.props?.default), props_), [props_]);
|
|
447
448
|
const Line = React.useMemo(() => theme?.elements?.Line || LineElement, [theme]);
|
|
448
449
|
const Type = React.useMemo(() => theme?.elements?.Type || TypeElement, [theme]);
|
|
@@ -861,7 +862,7 @@ const TextField = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
|
861
862
|
version: "b3"
|
|
862
863
|
}, HelperTextProps, {
|
|
863
864
|
className: classNames([staticClassName('TextField', theme) && ['onesy-TextField-helper-text', error && 'onesy-TextField-error'], HelperTextProps?.className, classes.helperText, error && classes.error_color])
|
|
864
|
-
}), helperText !== undefined ? helperText : required ? '
|
|
865
|
+
}), helperText !== undefined ? helperText : required ? `*${l('required')}` : ''), counter && /*#__PURE__*/React.createElement(Type, {
|
|
865
866
|
version: "b3",
|
|
866
867
|
className: classNames([staticClassName('TextField', theme) && ['onesy-TextField-counter'], classes.counterText, error && classes.error_color])
|
|
867
868
|
}, String(value)?.length || 0, "/", counter)), footer_));
|
package/esm/index.js
CHANGED
package/esm/useForm/useForm.js
CHANGED
|
@@ -80,7 +80,7 @@ const useForm = props => {
|
|
|
80
80
|
// Validate the property
|
|
81
81
|
if (property.required && property.value === undefined) {
|
|
82
82
|
const name = is('function', property.propertyNameUpdate) ? property.propertyNameUpdate(property.name) : property.capitalize !== false ? capitalize(property.name) : property.name;
|
|
83
|
-
property.error = `${name} ${l('is required')}`;
|
|
83
|
+
property.error = `${l(name)} ${l('is required')}`;
|
|
84
84
|
} else {
|
|
85
85
|
property.error = undefined;
|
|
86
86
|
|
|
@@ -133,7 +133,7 @@ const useForm = props => {
|
|
|
133
133
|
// Validate the property
|
|
134
134
|
if (property.required && property.value === undefined) {
|
|
135
135
|
const name = is('function', property.propertyNameUpdate) ? property.propertyNameUpdate(property.name) : property.capitalize !== false ? capitalize(property.name) : property.name;
|
|
136
|
-
property.error = `${name} ${l('is required')}`;
|
|
136
|
+
property.error = `${l(name)} ${l('is required')}`;
|
|
137
137
|
} else {
|
|
138
138
|
property.error = undefined;
|
|
139
139
|
|
package/esm/useForm/validate.js
CHANGED
|
@@ -19,7 +19,7 @@ const validate = async (model, property, form, options_) => {
|
|
|
19
19
|
parse: true
|
|
20
20
|
});
|
|
21
21
|
const l = options?.l || (item => item);
|
|
22
|
-
const name = is('function', model.propertyNameUpdate) ? model.propertyNameUpdate(model.name) : model.capitalize !== false ? capitalize(model.name) : model.name;
|
|
22
|
+
const name = l(is('function', model.propertyNameUpdate) ? model.propertyNameUpdate(model.name) : model.capitalize !== false ? capitalize(model.name) : model.name);
|
|
23
23
|
const value = model.value;
|
|
24
24
|
|
|
25
25
|
// value validate
|
package/package.json
CHANGED
package/useForm/useForm.js
CHANGED
|
@@ -71,7 +71,7 @@ const useForm = (props) => {
|
|
|
71
71
|
// Validate the property
|
|
72
72
|
if (property.required && property.value === undefined) {
|
|
73
73
|
const name = (0, utils_1.is)('function', property.propertyNameUpdate) ? property.propertyNameUpdate(property.name) : property.capitalize !== false ? (0, utils_1.capitalize)(property.name) : property.name;
|
|
74
|
-
property.error = `${name} ${l('is required')}`;
|
|
74
|
+
property.error = `${l(name)} ${l('is required')}`;
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
77
|
property.error = undefined;
|
|
@@ -122,7 +122,7 @@ const useForm = (props) => {
|
|
|
122
122
|
// Validate the property
|
|
123
123
|
if (property.required && property.value === undefined) {
|
|
124
124
|
const name = (0, utils_1.is)('function', property.propertyNameUpdate) ? property.propertyNameUpdate(property.name) : property.capitalize !== false ? (0, utils_1.capitalize)(property.name) : property.name;
|
|
125
|
-
property.error = `${name} ${l('is required')}`;
|
|
125
|
+
property.error = `${l(name)} ${l('is required')}`;
|
|
126
126
|
}
|
|
127
127
|
else {
|
|
128
128
|
property.error = undefined;
|
package/useForm/validate.js
CHANGED
|
@@ -24,7 +24,7 @@ const validate = async (model, property, form, options_) => {
|
|
|
24
24
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
25
25
|
const options = (0, utils_1.merge)((options_ && (0, is_1.default)('object', options_)) ? options_ : {}, { uriDecode: true, parse: true });
|
|
26
26
|
const l = (options === null || options === void 0 ? void 0 : options.l) || (item => item);
|
|
27
|
-
const name = (0, is_1.default)('function', model.propertyNameUpdate) ? model.propertyNameUpdate(model.name) : model.capitalize !== false ? (0, utils_1.capitalize)(model.name) : model.name;
|
|
27
|
+
const name = l((0, is_1.default)('function', model.propertyNameUpdate) ? model.propertyNameUpdate(model.name) : model.capitalize !== false ? (0, utils_1.capitalize)(model.name) : model.name);
|
|
28
28
|
const value = model.value;
|
|
29
29
|
// value validate
|
|
30
30
|
// with options above
|