linear-react-components-ui 1.1.15-beta.1 → 1.1.15-beta.2
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/lib/dialog/form/index.js +4 -8
- package/lib/form/FieldNumber.js +13 -2
- package/lib/form/types.d.ts +3 -0
- package/lib/inputs/base/InputTextBase.js +5 -1
- package/lib/inputs/base/types.d.ts +3 -2
- package/lib/inputs/date/helpers.js +2 -2
- package/lib/inputs/date/index.js +8 -6
- package/lib/inputs/mask/BaseMask.d.ts +1 -1
- package/lib/inputs/mask/BaseMask.js +11 -11
- package/lib/inputs/mask/helpers.d.ts +10 -7
- package/lib/inputs/mask/helpers.js +17 -3
- package/lib/inputs/mask/types.d.ts +4 -1
- package/lib/inputs/number/index.js +30 -11
- package/lib/inputs/number/types.d.ts +10 -10
- package/lib/inputs/select/multiple/index.js +28 -17
- package/lib/inputs/select/simple/index.js +4 -1
- package/lib/inputs/select/types.d.ts +3 -0
- package/lib/inputs/types.d.ts +3 -5
- package/package.json +2 -1
package/lib/dialog/form/index.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.FormDialogContext = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var uuid = _interopRequireWildcard(require("uuid"));
|
|
9
8
|
var _base = _interopRequireDefault(require("../base"));
|
|
10
9
|
var _Header = _interopRequireDefault(require("../base/Header"));
|
|
11
10
|
var _index = require("../../buttons/index");
|
|
@@ -66,18 +65,15 @@ const ModalForm = props => {
|
|
|
66
65
|
icon: props.icon
|
|
67
66
|
})), /*#__PURE__*/_react.default.createElement(_Content.default, {
|
|
68
67
|
styleForContent: _objectSpread(_objectSpread({}, props.styleForContent), overlayStyle)
|
|
69
|
-
}, content || children), getSpinner(), showFooter && props.buttons &&
|
|
68
|
+
}, content || children), getSpinner(), showFooter && props.buttons && /*#__PURE__*/_react.default.createElement(_Footer.default, null, /*#__PURE__*/_react.default.createElement(_index.ButtonContainer, _extends({}, props, {
|
|
70
69
|
style: _objectSpread({}, overlayStyle)
|
|
71
|
-
}), props.buttons.map(button => {
|
|
70
|
+
}), _react.default.Children.toArray(props.buttons.map(button => {
|
|
72
71
|
if (context && context.securityBeforeUnload && button && button.type && button.type.name === 'CancelButton') {
|
|
73
72
|
return /*#__PURE__*/_react.default.cloneElement(button, {
|
|
74
|
-
key: "button-".concat(uuid.v1()),
|
|
75
73
|
onClick: props.handlerClose
|
|
76
74
|
});
|
|
77
75
|
}
|
|
78
|
-
return /*#__PURE__*/_react.default.cloneElement(button
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
})))));
|
|
76
|
+
return /*#__PURE__*/_react.default.cloneElement(button);
|
|
77
|
+
}))))));
|
|
82
78
|
};
|
|
83
79
|
var _default = exports.default = (0, _withFormSecurity.default)(ModalForm);
|
package/lib/form/FieldNumber.js
CHANGED
|
@@ -24,9 +24,11 @@ const getEventProps = _ref => {
|
|
|
24
24
|
validators,
|
|
25
25
|
onBlur,
|
|
26
26
|
onKeyDown,
|
|
27
|
+
onChange,
|
|
27
28
|
handlerFieldValidade,
|
|
28
29
|
handlerFieldChange,
|
|
29
|
-
handleShowValidateMessages
|
|
30
|
+
handleShowValidateMessages,
|
|
31
|
+
component
|
|
30
32
|
} = _ref;
|
|
31
33
|
return {
|
|
32
34
|
onBlur: e => {
|
|
@@ -37,11 +39,20 @@ const getEventProps = _ref => {
|
|
|
37
39
|
},
|
|
38
40
|
onKeyDown: e => {
|
|
39
41
|
if ([constants.keyCodes.ENTER].includes(e.keyCode)) {
|
|
40
|
-
handlerFieldChange === null || handlerFieldChange === void 0 ? void 0 : handlerFieldChange(e);
|
|
41
42
|
if (validators) handlerFieldValidade === null || handlerFieldValidade === void 0 ? void 0 : handlerFieldValidade(name, e.target.value, validators);
|
|
42
43
|
if (onKeyDown) onKeyDown(e);
|
|
43
44
|
handleShowValidateMessages(true);
|
|
44
45
|
}
|
|
46
|
+
},
|
|
47
|
+
onChange: e => {
|
|
48
|
+
if ((component === null || component === void 0 ? void 0 : component.name) === 'NumberField') {
|
|
49
|
+
if (validators && e.target && handlerFieldValidade) {
|
|
50
|
+
handlerFieldValidade(name, e.target.value, validators);
|
|
51
|
+
handleShowValidateMessages(true);
|
|
52
|
+
}
|
|
53
|
+
if (handlerFieldChange) handlerFieldChange(e);
|
|
54
|
+
if (onChange) onChange(e);
|
|
55
|
+
}
|
|
45
56
|
}
|
|
46
57
|
};
|
|
47
58
|
};
|
package/lib/form/types.d.ts
CHANGED
|
@@ -90,6 +90,7 @@ interface IFieldProps extends WithFieldProps {
|
|
|
90
90
|
themePopover?: 'light' | 'dark';
|
|
91
91
|
popoverAlign?: 'right' | 'left';
|
|
92
92
|
displayCurrencySymbol?: boolean;
|
|
93
|
+
removeZeroLeft?: boolean;
|
|
93
94
|
}
|
|
94
95
|
interface CustomEvent {
|
|
95
96
|
target: {
|
|
@@ -185,6 +186,7 @@ interface WithFieldProps {
|
|
|
185
186
|
handlerStoreValidators?: (name: string, validators: Validator | Validator[]) => void;
|
|
186
187
|
handlerRemoveValidators?: (name: string) => void;
|
|
187
188
|
validators?: Validator | Validator[] | PeriodValidator | PeriodValidator[];
|
|
189
|
+
customClass?: string;
|
|
188
190
|
}
|
|
189
191
|
interface IWithFieldContext {
|
|
190
192
|
validatorFromComponent: Validator | Validator[] | undefined;
|
|
@@ -215,6 +217,7 @@ interface IEventParams {
|
|
|
215
217
|
handlerFieldChange?: (event: ChangeEvent<HTMLInputElement> | CustomKeyboardEvent) => void;
|
|
216
218
|
validatorFromComponent?: Validator | Validator[];
|
|
217
219
|
handleShowValidateMessages: (value: boolean) => void;
|
|
220
|
+
component?: ComponentType<any>;
|
|
218
221
|
}
|
|
219
222
|
interface IGetErrorMessagesParams {
|
|
220
223
|
name: string;
|
|
@@ -68,6 +68,7 @@ const InputTextBase = props => {
|
|
|
68
68
|
onDragOver,
|
|
69
69
|
onDrop,
|
|
70
70
|
onDragLeave,
|
|
71
|
+
onClick,
|
|
71
72
|
readOnlyClass,
|
|
72
73
|
autoComplete = 'on',
|
|
73
74
|
themePopover = 'light',
|
|
@@ -120,7 +121,7 @@ const InputTextBase = props => {
|
|
|
120
121
|
};
|
|
121
122
|
if (!disableCallbacks) {
|
|
122
123
|
propsInput = _objectSpread(_objectSpread({}, propsInput), {}, {
|
|
123
|
-
onFocus
|
|
124
|
+
onFocus: e => {
|
|
124
125
|
var _props$onInputReceive;
|
|
125
126
|
(_props$onInputReceive = props.onInputReceiveFocus) === null || _props$onInputReceive === void 0 ? void 0 : _props$onInputReceive.call(props);
|
|
126
127
|
if (props.onFocus) props.onFocus(e);
|
|
@@ -147,6 +148,9 @@ const InputTextBase = props => {
|
|
|
147
148
|
},
|
|
148
149
|
onDragLeave: e => {
|
|
149
150
|
if (onDragLeave) onDragLeave(e);
|
|
151
|
+
},
|
|
152
|
+
onClick: e => {
|
|
153
|
+
if (onClick) onClick(e);
|
|
150
154
|
}
|
|
151
155
|
});
|
|
152
156
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MutableRefObject, KeyboardEvent, DragEvent, RefObject, CSSProperties } from 'react';
|
|
1
|
+
import { MutableRefObject, MouseEvent, KeyboardEvent, DragEvent, RefObject, CSSProperties } from 'react';
|
|
2
2
|
import { TextAlign } from '../../@types/Align.js';
|
|
3
3
|
import { Period } from '../../@types/Period.js';
|
|
4
4
|
import { PermissionAttr, OnDenied } from '../../@types/PermissionAttr.js';
|
|
@@ -27,7 +27,7 @@ interface InputLabelProps extends WithTooltipProps {
|
|
|
27
27
|
required?: boolean;
|
|
28
28
|
targetRef?: (ref: HTMLSpanElement | null) => void;
|
|
29
29
|
labelRef?: MutableRefObject<HTMLSpanElement | null>;
|
|
30
|
-
onHoverLabel?:
|
|
30
|
+
onHoverLabel?: React.MouseEventHandler<HTMLSpanElement>;
|
|
31
31
|
}
|
|
32
32
|
interface IBaseProps {
|
|
33
33
|
inputHasFocus?: boolean;
|
|
@@ -47,6 +47,7 @@ interface IBaseProps {
|
|
|
47
47
|
maxLength?: number;
|
|
48
48
|
name?: string;
|
|
49
49
|
required?: boolean;
|
|
50
|
+
onClick?: (event: MouseEvent) => void;
|
|
50
51
|
onBlur?: (e: CustomInputEvent) => void;
|
|
51
52
|
onFocus?: (e: CustomInputEvent) => void;
|
|
52
53
|
onReset?: (e: CustomInputEvent) => void;
|
|
@@ -20,8 +20,8 @@ const getCalendarDropdownStyle = _ref => {
|
|
|
20
20
|
exports.getCalendarDropdownStyle = getCalendarDropdownStyle;
|
|
21
21
|
const getMomentValue = value => {
|
|
22
22
|
let newValue = value;
|
|
23
|
-
if ((0, _moment.default)(newValue, PT_BR_FORMAT).isValid()) {
|
|
24
|
-
newValue = (0, _moment.default)(newValue, PT_BR_FORMAT).format(
|
|
23
|
+
if ((0, _moment.default)(newValue, PT_BR_FORMAT, true).isValid()) {
|
|
24
|
+
newValue = (0, _moment.default)(newValue, PT_BR_FORMAT).format(PT_BR_FORMAT);
|
|
25
25
|
}
|
|
26
26
|
return typeof newValue === 'string' ? (0, _moment.default)(newValue, EN_US_FORMAT) : newValue;
|
|
27
27
|
};
|
package/lib/inputs/date/index.js
CHANGED
|
@@ -135,8 +135,10 @@ const DatePicker = props => {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
|
-
const setValue = (
|
|
138
|
+
const setValue = function () {
|
|
139
139
|
var _inputRef$current2;
|
|
140
|
+
let valueParam = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
141
|
+
let e = arguments.length > 1 ? arguments[1] : undefined;
|
|
140
142
|
if (showCalendar && setFocusOnSelect) (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
|
|
141
143
|
if (props.onComplete) props.onComplete(e, valueParam);
|
|
142
144
|
if (props.onChange) onInputChange({
|
|
@@ -228,11 +230,11 @@ const DatePicker = props => {
|
|
|
228
230
|
if (onDenied && onDenied.unvisible) return null;
|
|
229
231
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_BaseMask.default, _extends({}, props, {
|
|
230
232
|
value: !valueState ? ' ' : valueState.format(_helpers.PT_BR_FORMAT),
|
|
231
|
-
isDateField: true,
|
|
232
233
|
mask: "00/00/0000",
|
|
233
|
-
onComplete:
|
|
234
|
-
if (
|
|
235
|
-
|
|
234
|
+
onComplete: e => {
|
|
235
|
+
if (e) {
|
|
236
|
+
var _e$target;
|
|
237
|
+
setValue((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.maskedValue, e);
|
|
236
238
|
}
|
|
237
239
|
},
|
|
238
240
|
onBlur: onInputBlur,
|
|
@@ -241,7 +243,7 @@ const DatePicker = props => {
|
|
|
241
243
|
},
|
|
242
244
|
onKeyDown: onInputKeyDown,
|
|
243
245
|
onChange: (e, __, date) => {
|
|
244
|
-
if (date) onInputChange(e,
|
|
246
|
+
if (date) onInputChange(e, e.target.value);
|
|
245
247
|
},
|
|
246
248
|
inputRef: el => {
|
|
247
249
|
inputRef.current = el;
|
|
@@ -7,6 +7,6 @@ import '../../@types/Period.js';
|
|
|
7
7
|
import '../../internals/types.js';
|
|
8
8
|
import '../../@types/Position.js';
|
|
9
9
|
|
|
10
|
-
declare const BaseMask: ({ value: valueProp, defaultValue, inputRef, onChange, onComplete, permissionAttr, ...rest }: IBaseMaskProps) => JSX.Element;
|
|
10
|
+
declare const BaseMask: ({ value: valueProp, defaultValue, inputRef, onChange, onComplete, permissionAttr, mask, ...rest }: IBaseMaskProps) => JSX.Element;
|
|
11
11
|
|
|
12
12
|
export { BaseMask as default };
|
|
@@ -10,7 +10,7 @@ var _format_number = require("../number/format_number");
|
|
|
10
10
|
var _reactImask = require("react-imask");
|
|
11
11
|
var _permissionValidations = require("../../permissionValidations");
|
|
12
12
|
var _helpers = require("./helpers");
|
|
13
|
-
const _excluded = ["value", "defaultValue", "inputRef", "onChange", "onComplete", "permissionAttr"];
|
|
13
|
+
const _excluded = ["value", "defaultValue", "inputRef", "onChange", "onComplete", "permissionAttr", "mask"];
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -68,9 +68,9 @@ const getEventProps = (props, setValue, maskRef) => {
|
|
|
68
68
|
} = e.target;
|
|
69
69
|
const formatedValue = (0, _format_number.formatOnlyNumbers)(value);
|
|
70
70
|
const eventWithFormatedValue = _objectSpread(_objectSpread({}, e), {}, {
|
|
71
|
-
target: {
|
|
71
|
+
target: _objectSpread(_objectSpread({}, e.target), {}, {
|
|
72
72
|
value: formatedValue
|
|
73
|
-
}
|
|
73
|
+
})
|
|
74
74
|
});
|
|
75
75
|
const formattedEvent = returnEventFormattedValue(props, eventWithFormatedValue);
|
|
76
76
|
props.onBlur(formattedEvent);
|
|
@@ -101,7 +101,8 @@ const BaseMask = _ref => {
|
|
|
101
101
|
inputRef,
|
|
102
102
|
onChange,
|
|
103
103
|
onComplete,
|
|
104
|
-
permissionAttr
|
|
104
|
+
permissionAttr,
|
|
105
|
+
mask
|
|
105
106
|
} = _ref,
|
|
106
107
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
107
108
|
const onDenied = (0, _permissionValidations.actionsOnPermissionDenied)(options, permissionAttr);
|
|
@@ -110,10 +111,13 @@ const BaseMask = _ref => {
|
|
|
110
111
|
readOnly
|
|
111
112
|
} = onDenied;
|
|
112
113
|
const disableCallbacks = disabled || readOnly;
|
|
113
|
-
const maskOptions = (0, _helpers.getMaskOptions)(
|
|
114
|
+
const maskOptions = (0, _helpers.getMaskOptions)(_objectSpread({
|
|
115
|
+
mask
|
|
116
|
+
}, rest));
|
|
114
117
|
const {
|
|
115
118
|
ref,
|
|
116
119
|
setValue,
|
|
120
|
+
setTypedValue,
|
|
117
121
|
maskRef
|
|
118
122
|
} = (0, _reactImask.useIMask)(maskOptions, {
|
|
119
123
|
defaultValue: defaultValue,
|
|
@@ -146,18 +150,14 @@ const BaseMask = _ref => {
|
|
|
146
150
|
});
|
|
147
151
|
(0, _react.useEffect)(() => {
|
|
148
152
|
if (valueProp) {
|
|
149
|
-
setValue(
|
|
153
|
+
if (typeof valueProp === 'string') setValue(valueProp);else setTypedValue(valueProp);
|
|
150
154
|
}
|
|
151
155
|
}, [valueProp]);
|
|
152
156
|
return /*#__PURE__*/_react.default.createElement(_InputTextBase.default, _extends({
|
|
153
157
|
inputRef: r => {
|
|
154
158
|
ref.current = r;
|
|
155
159
|
if (inputRef) {
|
|
156
|
-
if (typeof inputRef === '
|
|
157
|
-
inputRef(r);
|
|
158
|
-
} else {
|
|
159
|
-
inputRef.current = r;
|
|
160
|
-
}
|
|
160
|
+
if (typeof inputRef === 'object') inputRef.current = r;else inputRef(r);
|
|
161
161
|
}
|
|
162
162
|
},
|
|
163
163
|
permissionAttr: permissionAttr
|
|
@@ -7,20 +7,16 @@ import '../../@types/Period.js';
|
|
|
7
7
|
import '../../internals/types.js';
|
|
8
8
|
import '../../@types/Position.js';
|
|
9
9
|
|
|
10
|
-
declare const getMaskOptions: ({ isDateField, placeholderChar, min, max, lazy, rightElements, ...rest }: IBaseMaskProps) => {
|
|
11
|
-
value?: string | undefined;
|
|
10
|
+
declare const getMaskOptions: ({ isDateField, placeholderChar, min, max, lazy, pattern, radix, thousandsSeparator, mapToRadix, scale, normalizeZeros, padFractionalZeros, rightElements, ...rest }: IBaseMaskProps) => {
|
|
11
|
+
value?: string | number | undefined;
|
|
12
12
|
onBlur?: ((e: CustomInputEvent) => void) | undefined;
|
|
13
13
|
onKeyDown?: ((e: CustomInputEvent | React.KeyboardEvent<Element>) => void) | undefined;
|
|
14
14
|
defaultValue?: string | undefined;
|
|
15
15
|
isNumeric?: boolean | undefined;
|
|
16
|
-
scale?: number | undefined;
|
|
17
|
-
radix?: string | undefined;
|
|
18
16
|
blocks?: any;
|
|
19
|
-
thousandsSeparator?: string | undefined;
|
|
20
17
|
leftElements?: JSX.Element | JSX.Element[] | undefined;
|
|
21
18
|
handlerSetOnDenied?: ((onDeniedValue: OnDenied) => void) | undefined;
|
|
22
19
|
onChange?: ((e: CustomInputEvent, maskValue?: string | undefined, date?: string | undefined) => void) | undefined;
|
|
23
|
-
padFractionalZeros?: boolean | undefined;
|
|
24
20
|
onComplete?: ((e: CustomInputEvent, maskValue?: string | undefined, date?: string | undefined) => void) | undefined;
|
|
25
21
|
inputRef?: React.MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null> | ((ref: HTMLInputElement | HTMLTextAreaElement | null) => void) | undefined;
|
|
26
22
|
permissionAttr?: PermissionAttr | undefined;
|
|
@@ -52,7 +48,14 @@ declare const getMaskOptions: ({ isDateField, placeholderChar, min, max, lazy, r
|
|
|
52
48
|
placeholderChar: string;
|
|
53
49
|
min: any;
|
|
54
50
|
max: any;
|
|
55
|
-
lazy: boolean
|
|
51
|
+
lazy: boolean;
|
|
52
|
+
pattern: string;
|
|
53
|
+
radix: string;
|
|
54
|
+
thousandsSeparator: string;
|
|
55
|
+
mapToRadix: string[];
|
|
56
|
+
scale: number;
|
|
57
|
+
normalizeZeros: boolean;
|
|
58
|
+
padFractionalZeros: boolean;
|
|
56
59
|
};
|
|
57
60
|
declare function CPFValidation(cpf?: string, returnMessage?: (msg: string) => void): void | "CPF inválido";
|
|
58
61
|
declare function CNPJValidation(cnpj?: string, returnMessage?: (msg: string) => void): void | "CNPJ inválido";
|
|
@@ -7,7 +7,7 @@ exports.CNPJValidation = CNPJValidation;
|
|
|
7
7
|
exports.CPFValidation = CPFValidation;
|
|
8
8
|
exports.getMaskOptions = void 0;
|
|
9
9
|
var _lodash = require("lodash");
|
|
10
|
-
const _excluded = ["isDateField", "placeholderChar", "min", "max", "lazy", "rightElements"];
|
|
10
|
+
const _excluded = ["isDateField", "placeholderChar", "min", "max", "lazy", "pattern", "radix", "thousandsSeparator", "mapToRadix", "scale", "normalizeZeros", "padFractionalZeros", "rightElements"];
|
|
11
11
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
12
12
|
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; }
|
|
13
13
|
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; }
|
|
@@ -23,7 +23,14 @@ const getMaskOptions = _ref => {
|
|
|
23
23
|
placeholderChar = '_',
|
|
24
24
|
min,
|
|
25
25
|
max,
|
|
26
|
-
lazy,
|
|
26
|
+
lazy = false,
|
|
27
|
+
pattern = '',
|
|
28
|
+
radix = ' ',
|
|
29
|
+
thousandsSeparator = '',
|
|
30
|
+
mapToRadix = [],
|
|
31
|
+
scale = 2,
|
|
32
|
+
normalizeZeros = true,
|
|
33
|
+
padFractionalZeros = true,
|
|
27
34
|
rightElements
|
|
28
35
|
} = _ref,
|
|
29
36
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -63,7 +70,14 @@ const getMaskOptions = _ref => {
|
|
|
63
70
|
placeholderChar: placeholderChar === '' ? ' ' : placeholderChar,
|
|
64
71
|
min,
|
|
65
72
|
max,
|
|
66
|
-
lazy
|
|
73
|
+
lazy,
|
|
74
|
+
pattern,
|
|
75
|
+
radix,
|
|
76
|
+
thousandsSeparator,
|
|
77
|
+
mapToRadix,
|
|
78
|
+
scale,
|
|
79
|
+
normalizeZeros,
|
|
80
|
+
padFractionalZeros
|
|
67
81
|
}, rest);
|
|
68
82
|
};
|
|
69
83
|
exports.getMaskOptions = getMaskOptions;
|
|
@@ -7,7 +7,7 @@ import '../../internals/types.js';
|
|
|
7
7
|
import '../../@types/Position.js';
|
|
8
8
|
|
|
9
9
|
type IBaseMaskProps = {
|
|
10
|
-
value?: string;
|
|
10
|
+
value?: string | number;
|
|
11
11
|
onBlur?: (e: CustomInputEvent) => void;
|
|
12
12
|
onKeyDown?: (e: CustomInputEvent | KeyboardEvent<Element>) => void;
|
|
13
13
|
defaultValue?: string;
|
|
@@ -54,6 +54,9 @@ type IBaseMaskProps = {
|
|
|
54
54
|
hintPosition?: 'below' | 'onLabelRight';
|
|
55
55
|
themePopover?: 'light' | 'dark';
|
|
56
56
|
popoverAlign?: 'right' | 'left';
|
|
57
|
+
pattern?: string;
|
|
58
|
+
mapToRadix?: string[];
|
|
59
|
+
normalizeZeros?: boolean;
|
|
57
60
|
};
|
|
58
61
|
type ICnpjFieldProps = IBaseMaskProps & {
|
|
59
62
|
value?: string;
|
|
@@ -16,30 +16,49 @@ Object.defineProperty(exports, "DecimalField", {
|
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
exports.default = void 0;
|
|
19
|
-
var _react =
|
|
20
|
-
var _BaseMask = _interopRequireDefault(require("../mask/BaseMask"));
|
|
19
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
21
20
|
var _Currency = _interopRequireDefault(require("./Currency"));
|
|
22
21
|
var _Decimal = _interopRequireDefault(require("./Decimal"));
|
|
23
22
|
require("../../assets/styles/numbers.scss");
|
|
24
|
-
var
|
|
23
|
+
var _InputTextBase = _interopRequireDefault(require("../base/InputTextBase"));
|
|
25
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
26
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
27
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
27
28
|
const NumberField = props => {
|
|
28
29
|
const {
|
|
29
30
|
textAlign = 'left',
|
|
30
31
|
value = '',
|
|
31
32
|
themePopover = 'light',
|
|
32
|
-
popoverAlign = 'left'
|
|
33
|
+
popoverAlign = 'left',
|
|
34
|
+
removeZeroLeft = true,
|
|
35
|
+
min,
|
|
36
|
+
max
|
|
33
37
|
} = props;
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
const [numberValue, setNumberValue] = (0, _react.useState)();
|
|
39
|
+
const onChange = event => {
|
|
40
|
+
const inputValue = event.target.value;
|
|
41
|
+
const numericValue = inputValue.replace(/\D/g, '');
|
|
42
|
+
if (min && parseInt(numericValue, 10) < min || max && parseInt(numericValue, 10) > max) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (removeZeroLeft && numericValue.charAt(0) === '0' && numericValue.length > 1) {
|
|
46
|
+
setNumberValue(numericValue.substring(1));
|
|
47
|
+
} else {
|
|
48
|
+
setNumberValue(numericValue);
|
|
49
|
+
}
|
|
50
|
+
if (props.onChange) props.onChange(event);
|
|
51
|
+
};
|
|
52
|
+
(0, _react.useEffect)(() => {
|
|
53
|
+
if (value && !numberValue) setNumberValue(value.toString());
|
|
54
|
+
}, [value]);
|
|
55
|
+
return /*#__PURE__*/_react.default.createElement(_InputTextBase.default, _extends({}, props, {
|
|
56
|
+
value: numberValue,
|
|
36
57
|
textAlign: textAlign,
|
|
37
|
-
mask: Number,
|
|
38
58
|
themePopover: themePopover,
|
|
39
59
|
popoverAlign: popoverAlign,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, props));
|
|
60
|
+
onChange: onChange,
|
|
61
|
+
type: "number"
|
|
62
|
+
}));
|
|
44
63
|
};
|
|
45
64
|
var _default = exports.default = NumberField;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PermissionAttr } from '../../@types/PermissionAttr.js';
|
|
2
2
|
import { CustomInputEvent } from '../base/types.js';
|
|
3
3
|
import { IMaskHOCProps } from '../types.js';
|
|
4
|
+
import { TextAlign } from '../../@types/Align.js';
|
|
4
5
|
import 'react';
|
|
5
|
-
import '../../@types/Align.js';
|
|
6
6
|
import '../../@types/Period.js';
|
|
7
7
|
import '../../internals/types.js';
|
|
8
8
|
import '../../@types/Position.js';
|
|
@@ -15,25 +15,25 @@ interface INumberFieldProps extends IMaskHOCProps {
|
|
|
15
15
|
value?: string;
|
|
16
16
|
permissionAttr?: PermissionAttr;
|
|
17
17
|
disabled?: boolean;
|
|
18
|
-
onChange?: (e?: CustomInputEvent | InputEvent, maskValue?: string, date?: string | {
|
|
19
|
-
initial: string;
|
|
20
|
-
final: string;
|
|
21
|
-
}) => void;
|
|
22
18
|
hint?: string | string[];
|
|
23
19
|
hintPosition?: 'below' | 'onLabelRight';
|
|
24
20
|
themePopover?: 'light' | 'dark';
|
|
25
21
|
popoverAlign?: 'right' | 'left';
|
|
22
|
+
onChange?: (e?: CustomInputEvent) => void;
|
|
23
|
+
removeZeroLeft?: boolean;
|
|
24
|
+
textAlign?: TextAlign;
|
|
26
25
|
}
|
|
27
|
-
interface IBaseNumberProps extends
|
|
28
|
-
value?: string;
|
|
29
|
-
leftElements?: JSX.Element | JSX.Element[];
|
|
30
|
-
onBlur?: (e: CustomInputEvent) => void;
|
|
26
|
+
interface IBaseNumberProps extends IMaskHOCProps {
|
|
31
27
|
returnFormattedValueOnBlur?: boolean;
|
|
32
28
|
returnFormattedValueOnKeyDown?: boolean;
|
|
33
29
|
}
|
|
34
|
-
interface ICurrencyProps extends
|
|
30
|
+
interface ICurrencyProps extends IMaskHOCProps {
|
|
35
31
|
currencySymbol?: string;
|
|
36
32
|
displayCurrencySymbol?: boolean;
|
|
33
|
+
hint?: string | string[];
|
|
34
|
+
hintPosition?: 'below' | 'onLabelRight';
|
|
35
|
+
themePopover?: 'light' | 'dark';
|
|
36
|
+
popoverAlign?: 'right' | 'left';
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export { IBaseNumberProps, ICurrencyProps, INumberFieldProps };
|
|
@@ -46,6 +46,7 @@ const MultipleSelect = props => {
|
|
|
46
46
|
const gridElRef = (0, _react.useRef)();
|
|
47
47
|
const inputTextRef = (0, _react.useRef)(null);
|
|
48
48
|
const descriptionKeyIsString = typeof descriptionKey === 'string';
|
|
49
|
+
const insideComponents = ['item', 'menubutton', 'filterinput', 'filtercontainer', 'label', 'actionbutton'];
|
|
49
50
|
const onScreenResize = () => {
|
|
50
51
|
if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);
|
|
51
52
|
};
|
|
@@ -53,7 +54,7 @@ const MultipleSelect = props => {
|
|
|
53
54
|
const {
|
|
54
55
|
target
|
|
55
56
|
} = event;
|
|
56
|
-
if (target !== selectWrapper.current && selectWrapper.current && !selectWrapper.current.contains(target) && dropdownRef.current && !dropdownRef.current.contains(target)) {
|
|
57
|
+
if (!insideComponents.includes(target.className) && target !== selectWrapper.current && selectWrapper.current && !selectWrapper.current.contains(target) && dropdownRef.current && !dropdownRef.current.contains(target)) {
|
|
57
58
|
setOpened(false);
|
|
58
59
|
}
|
|
59
60
|
};
|
|
@@ -93,34 +94,37 @@ const MultipleSelect = props => {
|
|
|
93
94
|
setInputValue([filteredValue]);
|
|
94
95
|
}
|
|
95
96
|
};
|
|
97
|
+
const onFocus = () => {
|
|
98
|
+
const dropdownWidthFocus = selectWrapper.current ? selectWrapper.current.clientWidth : dropdownWidth;
|
|
99
|
+
setOpened(true);
|
|
100
|
+
setDropdownWidth(dropdownWidthFocus);
|
|
101
|
+
};
|
|
96
102
|
const onSelect = select => {
|
|
103
|
+
var _dropdownRef$current2;
|
|
97
104
|
if (select === null) return;
|
|
98
105
|
const currentsSelect = [...currents, select];
|
|
99
106
|
setCurrents(currentsSelect);
|
|
100
107
|
setDataCombo(dataSource);
|
|
101
108
|
setInputValue([]);
|
|
102
109
|
if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
|
|
103
|
-
setOpened(false);
|
|
104
110
|
if (props.onSelect) setSelected(props.onSelect(currentsSelect.map(i => i[idKey])));
|
|
111
|
+
(_dropdownRef$current2 = dropdownRef.current) === null || _dropdownRef$current2 === void 0 ? void 0 : _dropdownRef$current2.focus();
|
|
105
112
|
};
|
|
106
113
|
const onUnselect = id => {
|
|
107
114
|
if (currents) {
|
|
115
|
+
var _dropdownRef$current3;
|
|
108
116
|
const result = currents.filter(item => item[idKey] !== id);
|
|
109
117
|
setCurrents(result);
|
|
110
118
|
if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
|
|
111
119
|
setOpened(false);
|
|
112
120
|
if (props.onSelect) setSelected(props.onSelect(result.map(i => i[idKey])));
|
|
121
|
+
(_dropdownRef$current3 = dropdownRef.current) === null || _dropdownRef$current3 === void 0 ? void 0 : _dropdownRef$current3.focus();
|
|
113
122
|
}
|
|
114
123
|
};
|
|
115
124
|
const onOpenClose = () => {
|
|
116
125
|
setOpened(prevState => !prevState);
|
|
117
126
|
if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);
|
|
118
127
|
};
|
|
119
|
-
const onFocus = () => {
|
|
120
|
-
const dropdownWidthFocus = selectWrapper.current ? selectWrapper.current.clientWidth : dropdownWidth;
|
|
121
|
-
setOpened(true);
|
|
122
|
-
setDropdownWidth(dropdownWidthFocus);
|
|
123
|
-
};
|
|
124
128
|
const onBlur = e => {
|
|
125
129
|
if (props.onBlur) props.onBlur(e);
|
|
126
130
|
if (!insideComponent) {
|
|
@@ -130,30 +134,36 @@ const MultipleSelect = props => {
|
|
|
130
134
|
};
|
|
131
135
|
const onInputKeyDown = e => {
|
|
132
136
|
if (e.keyCode) {
|
|
133
|
-
if (e.keyCode === constants.keyCodes.ENTER && selected) {
|
|
137
|
+
if (e.keyCode === constants.keyCodes.ENTER && selected && opened) {
|
|
134
138
|
var _e$preventDefault;
|
|
135
139
|
(_e$preventDefault = e.preventDefault) === null || _e$preventDefault === void 0 ? void 0 : _e$preventDefault.call(e);
|
|
136
|
-
if (!currents.
|
|
140
|
+
if (!currents.some(current => current[idKey] === selected[idKey])) {
|
|
141
|
+
var _e$preventDefault2;
|
|
142
|
+
(_e$preventDefault2 = e.preventDefault) === null || _e$preventDefault2 === void 0 ? void 0 : _e$preventDefault2.call(e);
|
|
143
|
+
onSelect(selected);
|
|
144
|
+
}
|
|
137
145
|
} else if ([constants.keyCodes.ARROW_UP, constants.keyCodes.ARROW_DOWN].includes(e.keyCode)) {
|
|
138
146
|
if (!opened) setOpened(true);
|
|
139
|
-
let index =
|
|
147
|
+
let index = dataCombo ? dataCombo.findIndex(d => d === selected) : 0;
|
|
140
148
|
if (e.keyCode === constants.keyCodes.ARROW_DOWN) {
|
|
141
|
-
index =
|
|
149
|
+
index = dataCombo && index === dataCombo.length - 1 ? 0 : index + 1;
|
|
142
150
|
} else {
|
|
143
|
-
index =
|
|
151
|
+
index = dataCombo && index === 0 ? dataCombo.length - 1 : index - 1;
|
|
144
152
|
}
|
|
145
|
-
if (
|
|
146
|
-
if (descriptionKeyIsString &&
|
|
147
|
-
setInputValue(
|
|
148
|
-
} else if (!descriptionKeyIsString) setInputValue([descriptionKey(
|
|
153
|
+
if (dataCombo && dataCombo.length) {
|
|
154
|
+
if (descriptionKeyIsString && dataCombo[index][descriptionKey]) {
|
|
155
|
+
setInputValue(dataCombo[index][descriptionKey]);
|
|
156
|
+
} else if (!descriptionKeyIsString) setInputValue([descriptionKey(dataCombo[index])]);
|
|
149
157
|
}
|
|
150
|
-
if (
|
|
158
|
+
if (dataCombo) setSelected(dataCombo[index]);
|
|
151
159
|
} else if (e.keyCode === constants.keyCodes.BACKSPACE) {
|
|
152
160
|
if (inputValue.length === 0) {
|
|
153
161
|
const currentsKeyDown = _lodash.default.dropRight(currents);
|
|
154
162
|
setCurrents(currentsKeyDown);
|
|
155
163
|
if (props.onSelect) props.onSelect(currentsKeyDown.map(i => i[idKey]));
|
|
156
164
|
}
|
|
165
|
+
} else if (e.keyCode === constants.keyCodes.TAB) {
|
|
166
|
+
setOpened(false);
|
|
157
167
|
}
|
|
158
168
|
}
|
|
159
169
|
};
|
|
@@ -225,6 +235,7 @@ const MultipleSelect = props => {
|
|
|
225
235
|
onChange: e => {
|
|
226
236
|
if (e) onFilter(e.target.value);
|
|
227
237
|
},
|
|
238
|
+
onClick: onFocus,
|
|
228
239
|
onKeyDown: onInputKeyDown,
|
|
229
240
|
customClassForWrapper: "selectwrapper ".concat((props.readOnly || shouldDisable() || shouldBeReadOnly()) && ' -undigitable'),
|
|
230
241
|
customClassForInputContent: "multiselect",
|
|
@@ -112,6 +112,7 @@ const SimpleSelect = props => {
|
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
114
|
const onSelect = selectedDropdown => {
|
|
115
|
+
var _dropdownRef$current4;
|
|
115
116
|
if (!selectedDropdown) return;
|
|
116
117
|
setSelected(selectedDropdown);
|
|
117
118
|
if (descriptionKeyIsString) setInputText(selectedDropdown[descriptionKey]);else setInputText(descriptionKey(selectedDropdown));
|
|
@@ -121,6 +122,7 @@ const SimpleSelect = props => {
|
|
|
121
122
|
if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
|
|
122
123
|
setOpened(false);
|
|
123
124
|
});
|
|
125
|
+
(_dropdownRef$current4 = dropdownRef.current) === null || _dropdownRef$current4 === void 0 ? void 0 : _dropdownRef$current4.focus();
|
|
124
126
|
};
|
|
125
127
|
const onOpenClose = () => {
|
|
126
128
|
setOpened(prevState => !prevState);
|
|
@@ -155,7 +157,7 @@ const SimpleSelect = props => {
|
|
|
155
157
|
};
|
|
156
158
|
const onInputKeyDown = e => {
|
|
157
159
|
if (e.keyCode) {
|
|
158
|
-
if (e.keyCode === constants.keyCodes.ENTER && selected) {
|
|
160
|
+
if (e.keyCode === constants.keyCodes.ENTER && selected && opened) {
|
|
159
161
|
var _e$preventDefault;
|
|
160
162
|
(_e$preventDefault = e.preventDefault) === null || _e$preventDefault === void 0 ? void 0 : _e$preventDefault.call(e);
|
|
161
163
|
onSelect(selected);
|
|
@@ -264,6 +266,7 @@ const SimpleSelect = props => {
|
|
|
264
266
|
onChange: e => {
|
|
265
267
|
if (e) onFilter(e.target.value);
|
|
266
268
|
},
|
|
269
|
+
onClick: onFocus,
|
|
267
270
|
onKeyDown: onInputKeyDown,
|
|
268
271
|
customClassForWrapper: "selectwrapper ".concat((undigitable || searchOnDropdown || shouldBeReadOnly()) && ' -undigitable'),
|
|
269
272
|
customClassForInputContent: "multiselect",
|
|
@@ -93,6 +93,9 @@ interface IMultipleSelectProps extends Omit<ISimpleSelectProps, 'idKey' | 'value
|
|
|
93
93
|
handlerClear?: () => void;
|
|
94
94
|
disabled?: boolean;
|
|
95
95
|
gridLayout?: string;
|
|
96
|
+
hintPosition?: 'below' | 'onLabelRight';
|
|
97
|
+
themePopover?: 'light' | 'dark';
|
|
98
|
+
popoverAlign?: 'right' | 'left';
|
|
96
99
|
}
|
|
97
100
|
interface ISelectedsMultipleProps {
|
|
98
101
|
idKey: string;
|
package/lib/inputs/types.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ interface ISearchProps extends IBaseProps {
|
|
|
20
20
|
resetButton?: boolean;
|
|
21
21
|
onReset?: (event?: CustomInputEvent) => void;
|
|
22
22
|
onChange?: (event?: CustomInputEvent) => void;
|
|
23
|
-
onClick?: (event: MouseEvent<
|
|
23
|
+
onClick?: (event: MouseEvent<Element>) => void;
|
|
24
24
|
textAlign?: TextAlign;
|
|
25
25
|
disabled?: boolean;
|
|
26
26
|
readOnly?: boolean;
|
|
@@ -54,10 +54,7 @@ interface IMaskHOCProps {
|
|
|
54
54
|
unmask?: boolean;
|
|
55
55
|
name?: string;
|
|
56
56
|
commit?: () => void;
|
|
57
|
-
onChange?: (event: CustomInputEvent, maskValue?: string, date?: string
|
|
58
|
-
initial: string;
|
|
59
|
-
final: string;
|
|
60
|
-
}) => void;
|
|
57
|
+
onChange?: (event: CustomInputEvent, maskValue?: string, date?: string) => void;
|
|
61
58
|
onFocus?: (e: CustomInputEvent) => void;
|
|
62
59
|
onComplete?: (e: CustomInputEvent, maskValue?: string, date?: string) => void;
|
|
63
60
|
inputRef?: MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null> | ((ref: HTMLInputElement | HTMLTextAreaElement | null) => void);
|
|
@@ -112,6 +109,7 @@ interface IDropdownSelectProps {
|
|
|
112
109
|
handleOnKeydown: (e: CustomInputEvent | KeyboardEvent) => void;
|
|
113
110
|
handleOnBlur: (item: DataCombo) => void;
|
|
114
111
|
handleOnFocus: () => void;
|
|
112
|
+
handlerSelecionadoAgora?: (bool: boolean) => void;
|
|
115
113
|
opened: boolean;
|
|
116
114
|
dropdownRef: MutableRefObject<HTMLDivElement | null>;
|
|
117
115
|
dataCombo: DataCombo[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linear-react-components-ui",
|
|
3
|
-
"version": "1.1.15-beta.
|
|
3
|
+
"version": "1.1.15-beta.2",
|
|
4
4
|
"description": "Linear Sistemas ReactJs Components",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.cjs",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"@babel/preset-typescript": "7.23.3",
|
|
68
68
|
"@svgr/webpack": "8.1.0",
|
|
69
69
|
"@swc/core": "1.4.13",
|
|
70
|
+
"@testing-library/dom": "10.4.0",
|
|
70
71
|
"@testing-library/jest-dom": "5.16.5",
|
|
71
72
|
"@testing-library/react": "14.1.2",
|
|
72
73
|
"@testing-library/user-event": "14.4.3",
|