linear-react-components-ui 1.1.17-beta.5 → 1.1.17-beta.6

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.
@@ -5,6 +5,7 @@ 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"));
8
9
  var _base = _interopRequireDefault(require("../base"));
9
10
  var _Header = _interopRequireDefault(require("../base/Header"));
10
11
  var _index = require("../../buttons/index");
@@ -65,15 +66,18 @@ const ModalForm = props => {
65
66
  icon: props.icon
66
67
  })), /*#__PURE__*/_react.default.createElement(_Content.default, {
67
68
  styleForContent: _objectSpread(_objectSpread({}, props.styleForContent), overlayStyle)
68
- }, content || children), getSpinner(), showFooter && props.buttons && /*#__PURE__*/_react.default.createElement(_Footer.default, null, /*#__PURE__*/_react.default.createElement(_index.ButtonContainer, _extends({}, props, {
69
+ }, content || children), getSpinner(), showFooter && props.buttons && props.buttons.length > 0 && /*#__PURE__*/_react.default.createElement(_Footer.default, null, /*#__PURE__*/_react.default.createElement(_index.ButtonContainer, _extends({}, props, {
69
70
  style: _objectSpread({}, overlayStyle)
70
- }), _react.default.Children.toArray(props.buttons.map(button => {
71
+ }), props.buttons.map(button => {
71
72
  if (context && context.securityBeforeUnload && button && button.type && button.type.name === 'CancelButton') {
72
73
  return /*#__PURE__*/_react.default.cloneElement(button, {
74
+ key: "button-".concat(uuid.v1()),
73
75
  onClick: props.handlerClose
74
76
  });
75
77
  }
76
- return /*#__PURE__*/_react.default.cloneElement(button);
77
- }))))));
78
+ return /*#__PURE__*/_react.default.cloneElement(button, {
79
+ key: "button-".concat(uuid.v1())
80
+ });
81
+ })))));
78
82
  };
79
83
  var _default = exports.default = (0, _withFormSecurity.default)(ModalForm);
package/lib/form/Field.js CHANGED
@@ -44,6 +44,7 @@ const getEvents = _ref => {
44
44
  onChange: e => {
45
45
  if (validatorsArray && e.target && handlerFieldValidade) {
46
46
  handlerFieldValidade(name, e.target.value, validatorsArray);
47
+ handleShowValidateMessages(true);
47
48
  }
48
49
  if (handlerFieldChange) handlerFieldChange(e);
49
50
  if (onChange) onChange(e);
@@ -24,11 +24,9 @@ const getEventProps = _ref => {
24
24
  validators,
25
25
  onBlur,
26
26
  onKeyDown,
27
- onChange,
28
27
  handlerFieldValidade,
29
28
  handlerFieldChange,
30
- handleShowValidateMessages,
31
- component
29
+ handleShowValidateMessages
32
30
  } = _ref;
33
31
  return {
34
32
  onBlur: e => {
@@ -39,19 +37,11 @@ const getEventProps = _ref => {
39
37
  },
40
38
  onKeyDown: e => {
41
39
  if ([constants.keyCodes.ENTER].includes(e.keyCode)) {
40
+ handlerFieldChange === null || handlerFieldChange === void 0 ? void 0 : handlerFieldChange(e);
42
41
  if (validators) handlerFieldValidade === null || handlerFieldValidade === void 0 ? void 0 : handlerFieldValidade(name, e.target.value, validators);
43
42
  if (onKeyDown) onKeyDown(e);
44
43
  handleShowValidateMessages(true);
45
44
  }
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
- }
52
- if (handlerFieldChange) handlerFieldChange(e);
53
- if (onChange) onChange(e);
54
- }
55
45
  }
56
46
  };
57
47
  };
package/lib/form/index.js CHANGED
@@ -138,33 +138,13 @@ const Form = _ref => {
138
138
  if (event) event.preventDefault();
139
139
  if (checkIsValid(usedData)) onSubmit(usedData);
140
140
  }, [usedData]);
141
- const onResetField = (cb, fields) => {
142
- const fieldsArray = !fields ? [] : fields instanceof Array ? fields : [fields];
143
- if (fieldsArray.length > 0) {
144
- cb(state => {
145
- const newState = JSON.parse(JSON.stringify(state));
146
- fieldsArray.forEach(field => {
147
- if (field) _lodash.default.set(newState, field, _lodash.default.get(originalData, field));
148
- });
149
- return newState;
150
- });
151
- setFieldErrors(state => {
152
- fieldsArray.forEach(field => {
153
- delete state[field];
154
- });
155
- return state;
156
- });
157
- } else {
158
- cb(JSON.parse(JSON.stringify(originalData)));
159
- setFieldErrors({});
160
- }
161
- };
162
- const onReset = fields => {
141
+ const onReset = () => {
163
142
  if (!useInternalState && onDataChange) {
164
- onResetField(onDataChange, fields);
143
+ onDataChange(JSON.parse(JSON.stringify(originalData)));
165
144
  } else {
166
- onResetField(setData, fields);
145
+ setData(JSON.parse(JSON.stringify(originalData)));
167
146
  }
147
+ setFieldErrors({});
168
148
  };
169
149
  const onRemoveFieldValidators = fieldName => {
170
150
  const newFieldsValidators = _lodash.default.omit(fieldsValidators, fieldName);
@@ -235,9 +215,9 @@ const Form = _ref => {
235
215
  }
236
216
  }, [submitOnPressEnterKey]);
237
217
  (0, _react.useEffect)(() => {
238
- const validatorsQuantity = Object.values(fieldsValidators.current).reduce((acc, currentValue) => acc + ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.length) || 0), 0);
239
- if (fieldsValidators.current && onValidateForm && oldFieldsValidatorsQuantity !== validatorsQuantity) {
240
- setOldFieldsValidatorsQuantity(validatorsQuantity);
218
+ const newValidatorsQuantity = Object.values(fieldsValidators.current).reduce((acc, currentValue) => acc + ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.length) || 0), 0);
219
+ if (fieldsValidators.current && onValidateForm && oldFieldsValidatorsQuantity !== newValidatorsQuantity) {
220
+ setOldFieldsValidatorsQuantity(newValidatorsQuantity);
241
221
  onValidateForm(checkIsValid(usedData, true, fieldsValidators.current));
242
222
  }
243
223
  }, [fieldsValidators.current, oldFieldsValidatorsQuantity, onValidateForm, JSON.stringify(usedData)]);
@@ -38,7 +38,7 @@ type BaseFormProps = {
38
38
  skeletonize?: boolean;
39
39
  disabled?: boolean;
40
40
  };
41
- type OnDataChange = React.Dispatch<React.SetStateAction<object>>;
41
+ type OnDataChange = React.Dispatch<React.SetStateAction<any>>;
42
42
  type FormProps = BaseFormProps & ({
43
43
  useInternalState?: false;
44
44
  onDataChange: OnDataChange;
@@ -89,8 +89,6 @@ interface IFieldProps extends WithFieldProps {
89
89
  hintPosition?: 'below' | 'onLabelRight';
90
90
  themePopover?: 'light' | 'dark';
91
91
  popoverAlign?: 'right' | 'left';
92
- displayCurrencySymbol?: boolean;
93
- removeZeroLeft?: boolean;
94
92
  checked?: boolean;
95
93
  }
96
94
  interface CustomEvent {
@@ -187,7 +185,6 @@ interface WithFieldProps {
187
185
  handlerStoreValidators?: (name: string, validators: Validator | Validator[]) => void;
188
186
  handlerRemoveValidators?: (name: string) => void;
189
187
  validators?: Validator | Validator[] | PeriodValidator | PeriodValidator[];
190
- customClass?: string;
191
188
  }
192
189
  interface IWithFieldContext {
193
190
  validatorFromComponent: Validator | Validator[] | undefined;
@@ -218,7 +215,6 @@ interface IEventParams {
218
215
  handlerFieldChange?: (event: ChangeEvent<HTMLInputElement> | CustomKeyboardEvent) => void;
219
216
  validatorFromComponent?: Validator | Validator[];
220
217
  handleShowValidateMessages: (value: boolean) => void;
221
- component?: ComponentType<any>;
222
218
  }
223
219
  interface IGetErrorMessagesParams {
224
220
  name: string;
@@ -68,7 +68,6 @@ const InputTextBase = props => {
68
68
  onDragOver,
69
69
  onDrop,
70
70
  onDragLeave,
71
- onClick,
72
71
  readOnlyClass,
73
72
  autoComplete = 'on',
74
73
  themePopover = 'light',
@@ -121,7 +120,7 @@ const InputTextBase = props => {
121
120
  };
122
121
  if (!disableCallbacks) {
123
122
  propsInput = _objectSpread(_objectSpread({}, propsInput), {}, {
124
- onFocus: e => {
123
+ onFocus(e) {
125
124
  var _props$onInputReceive;
126
125
  (_props$onInputReceive = props.onInputReceiveFocus) === null || _props$onInputReceive === void 0 ? void 0 : _props$onInputReceive.call(props);
127
126
  if (props.onFocus) props.onFocus(e);
@@ -148,9 +147,6 @@ const InputTextBase = props => {
148
147
  },
149
148
  onDragLeave: e => {
150
149
  if (onDragLeave) onDragLeave(e);
151
- },
152
- onClick: e => {
153
- if (onClick) onClick(e);
154
150
  }
155
151
  });
156
152
  }
@@ -202,11 +198,10 @@ const InputTextBase = props => {
202
198
  }, /*#__PURE__*/_react.default.createElement(_textContent.default, {
203
199
  labelRef: labelRef,
204
200
  required: required,
205
- label: label,
206
201
  onHoverLabel: onHoverLabel,
207
202
  customClassForLabel: customClassForLabel,
208
203
  labelUppercase: labelUppercase,
209
- tooltip: label.toString(),
204
+ tooltip: showTooltip ? label.toString() : undefined,
210
205
  tooltipPosition: "top"
211
206
  }), /*#__PURE__*/_react.default.createElement("div", {
212
207
  className: "text-content",
@@ -1,4 +1,4 @@
1
- import { MutableRefObject, MouseEvent, KeyboardEvent, DragEvent, RefObject, CSSProperties } from 'react';
1
+ import { MutableRefObject, 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?: React.MouseEventHandler<HTMLSpanElement>;
30
+ onHoverLabel?: (e: React.MouseEvent<HTMLSpanElement, MouseEvent>) => void;
31
31
  }
32
32
  interface IBaseProps {
33
33
  inputHasFocus?: boolean;
@@ -47,7 +47,6 @@ interface IBaseProps {
47
47
  maxLength?: number;
48
48
  name?: string;
49
49
  required?: boolean;
50
- onClick?: (event: MouseEvent) => void;
51
50
  onBlur?: (e: CustomInputEvent) => void;
52
51
  onFocus?: (e: CustomInputEvent) => void;
53
52
  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, true).isValid()) {
24
- newValue = (0, _moment.default)(newValue, PT_BR_FORMAT).format(PT_BR_FORMAT);
23
+ if ((0, _moment.default)(newValue, PT_BR_FORMAT).isValid()) {
24
+ newValue = (0, _moment.default)(newValue, PT_BR_FORMAT).format(EN_US_FORMAT);
25
25
  }
26
26
  return typeof newValue === 'string' ? (0, _moment.default)(newValue, EN_US_FORMAT) : newValue;
27
27
  };
@@ -135,10 +135,8 @@ const DatePicker = props => {
135
135
  }
136
136
  }
137
137
  };
138
- const setValue = function () {
138
+ const setValue = (valueParam, e) => {
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;
142
140
  if (showCalendar && setFocusOnSelect) (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
143
141
  if (props.onComplete) props.onComplete(e, valueParam);
144
142
  if (props.onChange) onInputChange({
@@ -230,11 +228,11 @@ const DatePicker = props => {
230
228
  if (onDenied && onDenied.unvisible) return null;
231
229
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_BaseMask.default, _extends({}, props, {
232
230
  value: !valueState ? ' ' : valueState.format(_helpers.PT_BR_FORMAT),
231
+ isDateField: true,
233
232
  mask: "00/00/0000",
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);
233
+ onComplete: (e, __, date) => {
234
+ if (date) {
235
+ setValue(date, e);
238
236
  }
239
237
  },
240
238
  onBlur: onInputBlur,
@@ -243,7 +241,7 @@ const DatePicker = props => {
243
241
  },
244
242
  onKeyDown: onInputKeyDown,
245
243
  onChange: (e, __, date) => {
246
- if (date) onInputChange(e, e.target.value);
244
+ if (date) onInputChange(e, date);
247
245
  },
248
246
  inputRef: el => {
249
247
  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, mask, ...rest }: IBaseMaskProps) => JSX.Element;
10
+ declare const BaseMask: ({ value: valueProp, defaultValue, inputRef, onChange, onComplete, permissionAttr, ...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", "mask"];
13
+ const _excluded = ["value", "defaultValue", "inputRef", "onChange", "onComplete", "permissionAttr"];
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: _objectSpread(_objectSpread({}, e.target), {}, {
71
+ target: {
72
72
  value: formatedValue
73
- })
73
+ }
74
74
  });
75
75
  const formattedEvent = returnEventFormattedValue(props, eventWithFormatedValue);
76
76
  props.onBlur(formattedEvent);
@@ -101,8 +101,7 @@ const BaseMask = _ref => {
101
101
  inputRef,
102
102
  onChange,
103
103
  onComplete,
104
- permissionAttr,
105
- mask
104
+ permissionAttr
106
105
  } = _ref,
107
106
  rest = _objectWithoutProperties(_ref, _excluded);
108
107
  const onDenied = (0, _permissionValidations.actionsOnPermissionDenied)(options, permissionAttr);
@@ -111,13 +110,10 @@ const BaseMask = _ref => {
111
110
  readOnly
112
111
  } = onDenied;
113
112
  const disableCallbacks = disabled || readOnly;
114
- const maskOptions = (0, _helpers.getMaskOptions)(_objectSpread({
115
- mask
116
- }, rest));
113
+ const maskOptions = (0, _helpers.getMaskOptions)(rest);
117
114
  const {
118
115
  ref,
119
116
  setValue,
120
- setTypedValue,
121
117
  maskRef
122
118
  } = (0, _reactImask.useIMask)(maskOptions, {
123
119
  defaultValue: defaultValue,
@@ -149,13 +145,19 @@ const BaseMask = _ref => {
149
145
  }
150
146
  });
151
147
  (0, _react.useEffect)(() => {
152
- if (typeof valueProp === 'number') setTypedValue(valueProp);else setValue(valueProp !== null && valueProp !== void 0 ? valueProp : '');
148
+ if (valueProp) {
149
+ setValue(String(valueProp));
150
+ }
153
151
  }, [valueProp]);
154
152
  return /*#__PURE__*/_react.default.createElement(_InputTextBase.default, _extends({
155
153
  inputRef: r => {
156
154
  ref.current = r;
157
155
  if (inputRef) {
158
- if (typeof inputRef === 'object') inputRef.current = r;else inputRef(r);
156
+ if (typeof inputRef === 'function') {
157
+ inputRef(r);
158
+ } else {
159
+ inputRef.current = r;
160
+ }
159
161
  }
160
162
  },
161
163
  permissionAttr: permissionAttr
@@ -7,15 +7,20 @@ 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, pattern, radix, thousandsSeparator, mapToRadix, scale, normalizeZeros, padFractionalZeros, rightElements, leftElements, ...rest }: IBaseMaskProps) => {
11
- value?: string | number | undefined;
10
+ declare const getMaskOptions: ({ isDateField, placeholderChar, min, max, lazy, rightElements, ...rest }: IBaseMaskProps) => {
11
+ value?: string | 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;
16
18
  blocks?: any;
19
+ thousandsSeparator?: string | undefined;
20
+ leftElements?: JSX.Element | JSX.Element[] | undefined;
17
21
  handlerSetOnDenied?: ((onDeniedValue: OnDenied) => void) | undefined;
18
22
  onChange?: ((e: CustomInputEvent, maskValue?: string | undefined, date?: string | undefined) => void) | undefined;
23
+ padFractionalZeros?: boolean | undefined;
19
24
  onComplete?: ((e: CustomInputEvent, maskValue?: string | undefined, date?: string | undefined) => void) | undefined;
20
25
  inputRef?: React.MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null> | ((ref: HTMLInputElement | HTMLTextAreaElement | null) => void) | undefined;
21
26
  permissionAttr?: PermissionAttr | undefined;
@@ -42,19 +47,12 @@ declare const getMaskOptions: ({ isDateField, placeholderChar, min, max, lazy, p
42
47
  mask?: any;
43
48
  hint?: string | string[] | undefined;
44
49
  hintPosition?: "below" | "onLabelRight" | undefined;
45
- themePopover?: "light" | "dark" | undefined;
50
+ themePopover?: "dark" | "light" | undefined;
46
51
  popoverAlign?: "left" | "right" | undefined;
47
52
  placeholderChar: string;
48
53
  min: any;
49
54
  max: any;
50
- lazy: boolean;
51
- pattern: string;
52
- radix: string;
53
- thousandsSeparator: string;
54
- mapToRadix: string[];
55
- scale: number;
56
- normalizeZeros: boolean;
57
- padFractionalZeros: boolean;
55
+ lazy: boolean | undefined;
58
56
  };
59
57
  declare function CPFValidation(cpf?: string, returnMessage?: (msg: string) => void): void | "CPF inválido";
60
58
  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", "pattern", "radix", "thousandsSeparator", "mapToRadix", "scale", "normalizeZeros", "padFractionalZeros", "rightElements", "leftElements"];
10
+ const _excluded = ["isDateField", "placeholderChar", "min", "max", "lazy", "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,16 +23,8 @@ const getMaskOptions = _ref => {
23
23
  placeholderChar = '_',
24
24
  min,
25
25
  max,
26
- lazy = false,
27
- pattern = '',
28
- radix = ' ',
29
- thousandsSeparator = '',
30
- mapToRadix = [],
31
- scale = 2,
32
- normalizeZeros = true,
33
- padFractionalZeros = true,
34
- rightElements,
35
- leftElements
26
+ lazy,
27
+ rightElements
36
28
  } = _ref,
37
29
  rest = _objectWithoutProperties(_ref, _excluded);
38
30
  // TODO: essa etapa deverá ser feita junto com o refactory dos componentes Date e Period.
@@ -71,14 +63,7 @@ const getMaskOptions = _ref => {
71
63
  placeholderChar: placeholderChar === '' ? ' ' : placeholderChar,
72
64
  min,
73
65
  max,
74
- lazy,
75
- pattern,
76
- radix,
77
- thousandsSeparator,
78
- mapToRadix,
79
- scale,
80
- normalizeZeros,
81
- padFractionalZeros
66
+ lazy
82
67
  }, rest);
83
68
  };
84
69
  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 | number;
10
+ value?: string;
11
11
  onBlur?: (e: CustomInputEvent) => void;
12
12
  onKeyDown?: (e: CustomInputEvent | KeyboardEvent<Element>) => void;
13
13
  defaultValue?: string;
@@ -54,9 +54,6 @@ 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;
60
57
  };
61
58
  type ICnpjFieldProps = IBaseMaskProps & {
62
59
  value?: string;
@@ -16,49 +16,30 @@ Object.defineProperty(exports, "DecimalField", {
16
16
  }
17
17
  });
18
18
  exports.default = void 0;
19
- var _react = _interopRequireWildcard(require("react"));
19
+ var _react = _interopRequireDefault(require("react"));
20
+ var _BaseMask = _interopRequireDefault(require("../mask/BaseMask"));
20
21
  var _Currency = _interopRequireDefault(require("./Currency"));
21
22
  var _Decimal = _interopRequireDefault(require("./Decimal"));
22
23
  require("../../assets/styles/numbers.scss");
23
- var _InputTextBase = _interopRequireDefault(require("../base/InputTextBase"));
24
+ var _format_number = require("./format_number");
24
25
  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; }
27
26
  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); }
28
27
  const NumberField = props => {
29
28
  const {
30
29
  textAlign = 'left',
31
30
  value = '',
32
31
  themePopover = 'light',
33
- popoverAlign = 'left',
34
- removeZeroLeft = true,
35
- min,
36
- max
32
+ popoverAlign = 'left'
37
33
  } = props;
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
- setNumberValue(value.toString());
54
- }, [value]);
55
- return /*#__PURE__*/_react.default.createElement(_InputTextBase.default, _extends({}, props, {
56
- value: numberValue,
34
+ return /*#__PURE__*/_react.default.createElement(_BaseMask.default, _extends({
35
+ value: typeof value === 'number' ? (0, _format_number.numberToPtBR)(value) : value,
57
36
  textAlign: textAlign,
37
+ mask: Number,
58
38
  themePopover: themePopover,
59
39
  popoverAlign: popoverAlign,
60
- onChange: onChange,
61
- type: "number"
62
- }));
40
+ isNumeric: true,
41
+ scale: 0,
42
+ padFractionalZeros: false
43
+ }, props));
63
44
  };
64
45
  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';
5
4
  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;
18
22
  hint?: string | string[];
19
23
  hintPosition?: 'below' | 'onLabelRight';
20
24
  themePopover?: 'light' | 'dark';
21
25
  popoverAlign?: 'right' | 'left';
22
- onChange?: (e?: CustomInputEvent) => void;
23
- removeZeroLeft?: boolean;
24
- textAlign?: TextAlign;
25
26
  }
26
- interface IBaseNumberProps extends IMaskHOCProps {
27
+ interface IBaseNumberProps extends INumberFieldProps {
28
+ value?: string;
29
+ leftElements?: JSX.Element | JSX.Element[];
30
+ onBlur?: (e: CustomInputEvent) => void;
27
31
  returnFormattedValueOnBlur?: boolean;
28
32
  returnFormattedValueOnKeyDown?: boolean;
29
33
  }
30
- interface ICurrencyProps extends IMaskHOCProps {
34
+ interface ICurrencyProps extends INumberFieldProps {
31
35
  currencySymbol?: string;
32
36
  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,7 +46,6 @@ 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'];
50
49
  const onScreenResize = () => {
51
50
  if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);
52
51
  };
@@ -54,7 +53,7 @@ const MultipleSelect = props => {
54
53
  const {
55
54
  target
56
55
  } = event;
57
- if (!insideComponents.includes(target.className) && target !== selectWrapper.current && selectWrapper.current && !selectWrapper.current.contains(target) && dropdownRef.current && !dropdownRef.current.contains(target)) {
56
+ if (target !== selectWrapper.current && selectWrapper.current && !selectWrapper.current.contains(target) && dropdownRef.current && !dropdownRef.current.contains(target)) {
58
57
  setOpened(false);
59
58
  }
60
59
  };
@@ -94,37 +93,34 @@ const MultipleSelect = props => {
94
93
  setInputValue([filteredValue]);
95
94
  }
96
95
  };
97
- const onFocus = () => {
98
- const dropdownWidthFocus = selectWrapper.current ? selectWrapper.current.clientWidth : dropdownWidth;
99
- setOpened(true);
100
- setDropdownWidth(dropdownWidthFocus);
101
- };
102
96
  const onSelect = select => {
103
- var _dropdownRef$current2;
104
97
  if (select === null) return;
105
98
  const currentsSelect = [...currents, select];
106
99
  setCurrents(currentsSelect);
107
100
  setDataCombo(dataSource);
108
101
  setInputValue([]);
109
102
  if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
103
+ setOpened(false);
110
104
  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();
112
105
  };
113
106
  const onUnselect = id => {
114
107
  if (currents) {
115
- var _dropdownRef$current3;
116
108
  const result = currents.filter(item => item[idKey] !== id);
117
109
  setCurrents(result);
118
110
  if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
119
111
  setOpened(false);
120
112
  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();
122
113
  }
123
114
  };
124
115
  const onOpenClose = () => {
125
116
  setOpened(prevState => !prevState);
126
117
  if (selectWrapper.current) setDropdownWidth(selectWrapper.current.clientWidth);
127
118
  };
119
+ const onFocus = () => {
120
+ const dropdownWidthFocus = selectWrapper.current ? selectWrapper.current.clientWidth : dropdownWidth;
121
+ setOpened(true);
122
+ setDropdownWidth(dropdownWidthFocus);
123
+ };
128
124
  const onBlur = e => {
129
125
  if (props.onBlur) props.onBlur(e);
130
126
  if (!insideComponent) {
@@ -134,36 +130,30 @@ const MultipleSelect = props => {
134
130
  };
135
131
  const onInputKeyDown = e => {
136
132
  if (e.keyCode) {
137
- if (e.keyCode === constants.keyCodes.ENTER && selected && opened) {
133
+ if (e.keyCode === constants.keyCodes.ENTER && selected) {
138
134
  var _e$preventDefault;
139
135
  (_e$preventDefault = e.preventDefault) === null || _e$preventDefault === void 0 ? void 0 : _e$preventDefault.call(e);
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
- }
136
+ if (!currents.includes(selected)) onSelect(selected);
145
137
  } else if ([constants.keyCodes.ARROW_UP, constants.keyCodes.ARROW_DOWN].includes(e.keyCode)) {
146
138
  if (!opened) setOpened(true);
147
- let index = dataCombo ? dataCombo.findIndex(d => d === selected) : 0;
139
+ let index = dataSource ? dataSource.findIndex(d => d === selected) : 0;
148
140
  if (e.keyCode === constants.keyCodes.ARROW_DOWN) {
149
- index = dataCombo && index === dataCombo.length - 1 ? 0 : index + 1;
141
+ index = dataSource && index === dataSource.length - 1 ? 0 : index + 1;
150
142
  } else {
151
- index = dataCombo && index === 0 ? dataCombo.length - 1 : index - 1;
143
+ index = dataSource && index === 0 ? dataSource.length - 1 : index - 1;
152
144
  }
153
- if (dataCombo && dataCombo.length) {
154
- if (descriptionKeyIsString && dataCombo[index][descriptionKey]) {
155
- setInputValue(dataCombo[index][descriptionKey]);
156
- } else if (!descriptionKeyIsString) setInputValue([descriptionKey(dataCombo[index])]);
145
+ if (dataSource && dataSource.length) {
146
+ if (descriptionKeyIsString && dataSource[index][descriptionKey]) {
147
+ setInputValue(dataSource[index][descriptionKey]);
148
+ } else if (!descriptionKeyIsString) setInputValue([descriptionKey(dataSource[index])]);
157
149
  }
158
- if (dataCombo) setSelected(dataCombo[index]);
150
+ if (dataSource) setSelected(dataSource[index]);
159
151
  } else if (e.keyCode === constants.keyCodes.BACKSPACE) {
160
152
  if (inputValue.length === 0) {
161
153
  const currentsKeyDown = _lodash.default.dropRight(currents);
162
154
  setCurrents(currentsKeyDown);
163
155
  if (props.onSelect) props.onSelect(currentsKeyDown.map(i => i[idKey]));
164
156
  }
165
- } else if (e.keyCode === constants.keyCodes.TAB) {
166
- setOpened(false);
167
157
  }
168
158
  }
169
159
  };
@@ -235,7 +225,6 @@ const MultipleSelect = props => {
235
225
  onChange: e => {
236
226
  if (e) onFilter(e.target.value);
237
227
  },
238
- onClick: onFocus,
239
228
  onKeyDown: onInputKeyDown,
240
229
  customClassForWrapper: "selectwrapper ".concat((props.readOnly || shouldDisable() || shouldBeReadOnly()) && ' -undigitable'),
241
230
  customClassForInputContent: "multiselect",
@@ -112,7 +112,6 @@ const SimpleSelect = props => {
112
112
  }
113
113
  };
114
114
  const onSelect = selectedDropdown => {
115
- var _dropdownRef$current4;
116
115
  if (!selectedDropdown) return;
117
116
  setSelected(selectedDropdown);
118
117
  if (descriptionKeyIsString) setInputText(selectedDropdown[descriptionKey]);else setInputText(descriptionKey(selectedDropdown));
@@ -122,7 +121,6 @@ const SimpleSelect = props => {
122
121
  if (inputTextRef && inputTextRef.current) inputTextRef.current.focus();
123
122
  setOpened(false);
124
123
  });
125
- (_dropdownRef$current4 = dropdownRef.current) === null || _dropdownRef$current4 === void 0 ? void 0 : _dropdownRef$current4.focus();
126
124
  };
127
125
  const onOpenClose = () => {
128
126
  setOpened(prevState => !prevState);
@@ -157,7 +155,7 @@ const SimpleSelect = props => {
157
155
  };
158
156
  const onInputKeyDown = e => {
159
157
  if (e.keyCode) {
160
- if (e.keyCode === constants.keyCodes.ENTER && selected && opened) {
158
+ if (e.keyCode === constants.keyCodes.ENTER && selected) {
161
159
  var _e$preventDefault;
162
160
  (_e$preventDefault = e.preventDefault) === null || _e$preventDefault === void 0 ? void 0 : _e$preventDefault.call(e);
163
161
  onSelect(selected);
@@ -266,7 +264,6 @@ const SimpleSelect = props => {
266
264
  onChange: e => {
267
265
  if (e) onFilter(e.target.value);
268
266
  },
269
- onClick: onFocus,
270
267
  onKeyDown: onInputKeyDown,
271
268
  customClassForWrapper: "selectwrapper ".concat((undigitable || searchOnDropdown || shouldBeReadOnly()) && ' -undigitable'),
272
269
  customClassForInputContent: "multiselect",
@@ -93,9 +93,6 @@ 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';
99
96
  }
100
97
  interface ISelectedsMultipleProps {
101
98
  idKey: string;
@@ -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<Element>) => void;
23
+ onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
24
24
  textAlign?: TextAlign;
25
25
  disabled?: boolean;
26
26
  readOnly?: boolean;
@@ -54,7 +54,10 @@ interface IMaskHOCProps {
54
54
  unmask?: boolean;
55
55
  name?: string;
56
56
  commit?: () => void;
57
- onChange?: (event: CustomInputEvent, maskValue?: string, date?: string) => void;
57
+ onChange?: (event: CustomInputEvent, maskValue?: string, date?: string | {
58
+ initial: string;
59
+ final: string;
60
+ }) => void;
58
61
  onFocus?: (e: CustomInputEvent) => void;
59
62
  onComplete?: (e: CustomInputEvent, maskValue?: string, date?: string) => void;
60
63
  inputRef?: MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null> | ((ref: HTMLInputElement | HTMLTextAreaElement | null) => void);
@@ -109,7 +112,6 @@ interface IDropdownSelectProps {
109
112
  handleOnKeydown: (e: CustomInputEvent | KeyboardEvent) => void;
110
113
  handleOnBlur: (item: DataCombo) => void;
111
114
  handleOnFocus: () => void;
112
- handlerSelecionadoAgora?: (bool: boolean) => void;
113
115
  opened: boolean;
114
116
  dropdownRef: MutableRefObject<HTMLDivElement | null>;
115
117
  dataCombo: DataCombo[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "1.1.17-beta.5",
3
+ "version": "1.1.17-beta.6",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.cjs",
@@ -67,7 +67,6 @@
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",
71
70
  "@testing-library/jest-dom": "5.16.5",
72
71
  "@testing-library/react": "14.1.2",
73
72
  "@testing-library/user-event": "14.4.3",