linear-react-components-ui 1.1.26-beta.22 → 1.1.26-beta.24
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/assets/styles/datepicker2.css +1 -1
- package/lib/assets/styles/radiofield.css +1 -1
- package/lib/assets/styles/selectfield.css +1 -1
- package/lib/assets/styles/textfield.css +1 -1
- package/lib/buttons/DefaultButton.js +1 -1
- package/lib/calendar/base/index.js +2 -2
- package/lib/dialog/base/Content.d.ts +1 -1
- package/lib/dialog/base/Content.js +8 -7
- package/lib/dialog/base/Content.js.map +1 -1
- package/lib/dialog/form/index.js +23 -23
- package/lib/dialog/form/index.js.map +1 -1
- package/lib/dialog/types.d.ts +2 -1
- package/lib/dialog/wizard/index.js +4 -4
- package/lib/form/Field.js.map +1 -1
- package/lib/form/FieldArray.js +18 -18
- package/lib/form/FieldArray.js.map +1 -1
- package/lib/form/FieldNumber.js +42 -39
- package/lib/form/FieldNumber.js.map +1 -1
- package/lib/form/FieldPeriod.js +27 -27
- package/lib/form/FieldPeriod.js.map +1 -1
- package/lib/form/helpers.d.ts +5 -1
- package/lib/form/helpers.js.map +1 -1
- package/lib/form/withFormSecurity.js +3 -3
- package/lib/form2/useForm/index.js +95 -87
- package/lib/form2/useForm/index.js.map +1 -1
- package/lib/icons/index.js +1 -1
- package/lib/inputs/base/InputTextBase.js +1 -1
- package/lib/inputs/date/index.js +1 -1
- package/lib/inputs/number/Currency.d.ts +1 -1
- package/lib/inputs/number/Currency.js +79 -18
- package/lib/inputs/number/Currency.js.map +1 -1
- package/lib/inputs/number/Decimal.d.ts +2 -2
- package/lib/inputs/number/Decimal.js +78 -8
- package/lib/inputs/number/Decimal.js.map +1 -1
- package/lib/inputs/number/format_number.js +11 -5
- package/lib/inputs/number/format_number.js.map +1 -1
- package/lib/inputs/number/index.d.ts +1 -1
- package/lib/inputs/number/index.js +75 -31
- package/lib/inputs/number/index.js.map +1 -1
- package/lib/inputs/number/types.d.ts +9 -0
- package/lib/inputs/period/PeriodList.js +3 -3
- package/lib/inputs2/checkboxfield/base.js +1 -1
- package/lib/inputs2/date/datefield/base.js +1 -1
- package/lib/inputs2/date/datefield/types.d.ts +2 -2
- package/lib/inputs2/date/dateperiodfield/base.js +1 -1
- package/lib/inputs2/date/dateperiodfield/types.d.ts +2 -2
- package/lib/inputs2/filefield/index.js.map +1 -1
- package/lib/inputs2/index.d.ts +3 -2
- package/lib/inputs2/index.js +11 -8
- package/lib/inputs2/index.js.map +1 -1
- package/lib/inputs2/mask/Cnpj.d.ts +6 -3
- package/lib/inputs2/mask/Cnpj.js +107 -43
- package/lib/inputs2/mask/Cnpj.js.map +1 -1
- package/lib/inputs2/mask/Cpf.d.ts +6 -3
- package/lib/inputs2/mask/Cpf.js +87 -37
- package/lib/inputs2/mask/Cpf.js.map +1 -1
- package/lib/inputs2/mask/Phone.d.ts +5 -3
- package/lib/inputs2/mask/Phone.js +19 -18
- package/lib/inputs2/mask/Phone.js.map +1 -1
- package/lib/inputs2/mask/ZipCode.d.ts +6 -2
- package/lib/inputs2/mask/ZipCode.js +18 -16
- package/lib/inputs2/mask/ZipCode.js.map +1 -1
- package/lib/inputs2/mask/index.d.ts +6 -0
- package/lib/inputs2/mask/index.js +113 -0
- package/lib/inputs2/mask/index.js.map +1 -0
- package/lib/inputs2/mask/types.d.ts +16 -0
- package/lib/inputs2/numberfield/currency.d.ts +2 -1
- package/lib/inputs2/numberfield/currency.js +93 -75
- package/lib/inputs2/numberfield/currency.js.map +1 -1
- package/lib/inputs2/numberfield/decimal.d.ts +2 -1
- package/lib/inputs2/numberfield/decimal.js +87 -68
- package/lib/inputs2/numberfield/decimal.js.map +1 -1
- package/lib/inputs2/numberfield/helpers.js +10 -10
- package/lib/inputs2/numberfield/helpers.js.map +1 -1
- package/lib/inputs2/numberfield/index.d.ts +3 -2
- package/lib/inputs2/numberfield/index.js +26 -25
- package/lib/inputs2/numberfield/index.js.map +1 -1
- package/lib/inputs2/radiofield/base.js +76 -80
- package/lib/inputs2/radiofield/base.js.map +1 -1
- package/lib/inputs2/radiofield/index.js.map +1 -1
- package/lib/inputs2/selectfield/base.d.ts +1 -2
- package/lib/inputs2/selectfield/base.js +300 -300
- package/lib/inputs2/selectfield/base.js.map +1 -1
- package/lib/inputs2/selectfield/context.d.ts +1 -1
- package/lib/inputs2/selectfield/context.js.map +1 -1
- package/lib/inputs2/selectfield/index.d.ts +2 -1
- package/lib/inputs2/selectfield/index.js +20 -18
- package/lib/inputs2/selectfield/index.js.map +1 -1
- package/lib/inputs2/selectfield/listbox.d.ts +1 -0
- package/lib/inputs2/selectfield/listbox.js +34 -33
- package/lib/inputs2/selectfield/listbox.js.map +1 -1
- package/lib/inputs2/selectfield/selections.d.ts +1 -1
- package/lib/inputs2/selectfield/selections.js +11 -11
- package/lib/inputs2/selectfield/selections.js.map +1 -1
- package/lib/inputs2/selectfield/simple.d.ts +9 -0
- package/lib/inputs2/selectfield/simple.js +24 -0
- package/lib/inputs2/selectfield/simple.js.map +1 -0
- package/lib/inputs2/selectfield/triggers.js +15 -15
- package/lib/inputs2/selectfield/triggers.js.map +1 -1
- package/lib/inputs2/selectfield/types.d.ts +1 -0
- package/lib/inputs2/selectfield/types.js.map +1 -1
- package/lib/inputs2/textareafield/base.js +1 -1
- package/lib/inputs2/textfield/base.js +1 -1
- package/lib/labels/DefaultLabel.js +1 -1
- package/lib/list/Item.js +1 -1
- package/lib/menus/sidenav/MenuLink.js +1 -1
- package/lib/menus/sidenav/NavMenuItem.js +1 -1
- package/lib/permissionValidations.js +1 -2
- package/lib/textContent/index.js +1 -1
- package/package.json +6 -1
- package/lib/inputs/number/BaseNumber.d.ts +0 -3
- package/lib/inputs/number/BaseNumber.js +0 -60
- package/lib/inputs/number/BaseNumber.js.map +0 -1
- package/lib/inputs2/mask/BaseMask.d.ts +0 -13
- package/lib/inputs2/mask/BaseMask.js +0 -79
- package/lib/inputs2/mask/BaseMask.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { c as
|
|
3
|
-
import
|
|
1
|
+
import { jsx as W } from "react/jsx-runtime";
|
|
2
|
+
import { c as X } from "../../_virtual/compiler-runtime.js";
|
|
3
|
+
import { forwardRef as Y, useRef as tt, useEffect as et } from "react";
|
|
4
|
+
import i from "../../_virtual/lodash.js";
|
|
4
5
|
import "../../node_modules/imask/esm/index.js";
|
|
5
6
|
import "../../node_modules/imask/esm/controls/input.js";
|
|
6
7
|
import "../../node_modules/imask/esm/masked/factory.js";
|
|
@@ -10,94 +11,112 @@ import "../../node_modules/imask/esm/controls/html-mask-element.js";
|
|
|
10
11
|
import "../../node_modules/imask/esm/controls/html-contenteditable-mask-element.js";
|
|
11
12
|
import "../../node_modules/imask/esm/controls/input-history.js";
|
|
12
13
|
import "../../node_modules/react-imask/esm/input.js";
|
|
13
|
-
import
|
|
14
|
+
import ot from "../../node_modules/react-imask/esm/hook.js";
|
|
14
15
|
import "../../node_modules/react-imask/esm/mixin.js";
|
|
15
|
-
import {
|
|
16
|
-
import { Input as Y } from "../textfield/index.js";
|
|
16
|
+
import { Input as it } from "../textfield/index.js";
|
|
17
17
|
import "../textareafield/index.js";
|
|
18
18
|
import "./index.js";
|
|
19
19
|
import "../date/datefield/index.js";
|
|
20
20
|
import "../radiofield/index.js";
|
|
21
21
|
import "../selectfield/index.js";
|
|
22
22
|
import "../colorfield/index.js";
|
|
23
|
+
import "../mask/index.js";
|
|
23
24
|
import "../checkboxfield/index.js";
|
|
24
25
|
import "../date/dateperiodfield/index.js";
|
|
25
26
|
import "../filefield/index.js";
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
import "../slot/index.js";
|
|
28
|
+
import { mergeRefs as lt } from "../../form2/helpers.js";
|
|
29
|
+
const at = Y((e, b) => {
|
|
30
|
+
const t = X.c(50);
|
|
31
|
+
let a, u, c, d, f, v, p, g, N, x, F, h, R, k;
|
|
30
32
|
t[0] !== e ? ({
|
|
31
|
-
min:
|
|
32
|
-
max:
|
|
33
|
-
to:
|
|
34
|
-
from:
|
|
35
|
-
enum:
|
|
36
|
-
onChange:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
min: u,
|
|
34
|
+
max: c,
|
|
35
|
+
to: p,
|
|
36
|
+
from: g,
|
|
37
|
+
enum: N,
|
|
38
|
+
onChange: x,
|
|
39
|
+
onBlur: F,
|
|
40
|
+
allowNegative: h,
|
|
41
|
+
textAlign: R,
|
|
42
|
+
children: k,
|
|
43
|
+
scale: d,
|
|
44
|
+
normalizeZeros: f,
|
|
45
|
+
padFractionalZeros: v,
|
|
46
|
+
...a
|
|
47
|
+
} = e, t[0] = e, t[1] = a, t[2] = u, t[3] = c, t[4] = d, t[5] = f, t[6] = v, t[7] = p, t[8] = g, t[9] = N, t[10] = x, t[11] = F, t[12] = h, t[13] = R, t[14] = k) : (a = t[1], u = t[2], c = t[3], d = t[4], f = t[5], v = t[6], p = t[7], g = t[8], N = t[9], x = t[10], F = t[11], h = t[12], R = t[13], k = t[14]);
|
|
48
|
+
const o = u === void 0 ? void 0 : u, w = c === void 0 ? void 0 : c, y = p === void 0 ? void 0 : p, A = g === void 0 ? void 0 : g, E = N === void 0 ? void 0 : N, n = x === void 0 ? null : x, M = F === void 0 ? null : F, Q = h === void 0 ? !0 : h, z = R === void 0 ? "right" : R, D = k === void 0 ? null : k, j = d === void 0 ? 2 : d, q = f === void 0 ? !1 : f, L = v === void 0 ? !0 : v, K = tt(null), $ = i.isNil(o) ? Q ? void 0 : 0 : o;
|
|
49
|
+
let V;
|
|
50
|
+
t[15] === Symbol.for("react.memo_cache_sentinel") ? (V = ["."], t[15] = V) : V = t[15];
|
|
51
|
+
let S;
|
|
52
|
+
t[16] !== A || t[17] !== E || t[18] !== w || t[19] !== q || t[20] !== L || t[21] !== j || t[22] !== $ || t[23] !== y ? (S = {
|
|
50
53
|
mask: Number,
|
|
51
54
|
unmask: !0,
|
|
52
|
-
min:
|
|
53
|
-
enum:
|
|
55
|
+
min: $,
|
|
56
|
+
enum: E,
|
|
54
57
|
radix: ",",
|
|
55
|
-
mapToRadix:
|
|
58
|
+
mapToRadix: V,
|
|
56
59
|
thousandsSeparator: ".",
|
|
57
|
-
max:
|
|
58
|
-
to:
|
|
59
|
-
from:
|
|
60
|
-
scale:
|
|
61
|
-
normalizeZeros:
|
|
62
|
-
padFractionalZeros:
|
|
63
|
-
}, t[
|
|
64
|
-
let
|
|
65
|
-
t[
|
|
66
|
-
ref:
|
|
67
|
-
onAccept: (
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
max: w,
|
|
61
|
+
to: y,
|
|
62
|
+
from: A,
|
|
63
|
+
scale: j,
|
|
64
|
+
normalizeZeros: q,
|
|
65
|
+
padFractionalZeros: L
|
|
66
|
+
}, t[16] = A, t[17] = E, t[18] = w, t[19] = q, t[20] = L, t[21] = j, t[22] = $, t[23] = y, t[24] = S) : S = t[24];
|
|
67
|
+
let B;
|
|
68
|
+
t[25] !== n || t[26] !== e.name ? (B = {
|
|
69
|
+
ref: K,
|
|
70
|
+
onAccept: (l, _, O) => {
|
|
71
|
+
const P = parseFloat(_.unmaskedValue), U = i.isNaN(P) ? 0 : P;
|
|
72
|
+
n?.({
|
|
73
|
+
...O,
|
|
71
74
|
target: {
|
|
72
|
-
|
|
75
|
+
...O?.target,
|
|
73
76
|
name: e?.name,
|
|
74
|
-
value:
|
|
77
|
+
value: U
|
|
75
78
|
}
|
|
76
79
|
});
|
|
77
80
|
}
|
|
78
|
-
}, t[
|
|
81
|
+
}, t[25] = n, t[26] = e.name, t[27] = B) : B = t[27];
|
|
79
82
|
const {
|
|
80
|
-
value:
|
|
81
|
-
setValue:
|
|
82
|
-
unmaskedValue:
|
|
83
|
-
} =
|
|
84
|
-
let
|
|
85
|
-
t[
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
value: G,
|
|
84
|
+
setValue: r,
|
|
85
|
+
unmaskedValue: m
|
|
86
|
+
} = ot(S, B);
|
|
87
|
+
let T;
|
|
88
|
+
t[28] !== o || t[29] !== M || t[30] !== n || t[31] !== e.name || t[32] !== r || t[33] !== m ? (T = (l) => {
|
|
89
|
+
if (!i.isNil(o)) {
|
|
90
|
+
const _ = parseFloat(m);
|
|
91
|
+
(i.isNaN(_) || _ < o) && (r(i.toString(o)), n?.({
|
|
92
|
+
...l,
|
|
93
|
+
target: {
|
|
94
|
+
...l?.target,
|
|
95
|
+
name: e?.name,
|
|
96
|
+
value: o
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
M?.(l);
|
|
101
|
+
}, t[28] = o, t[29] = M, t[30] = n, t[31] = e.name, t[32] = r, t[33] = m, t[34] = T) : T = t[34];
|
|
102
|
+
const H = T;
|
|
103
|
+
let C;
|
|
104
|
+
t[35] !== e.value || t[36] !== r || t[37] !== m ? (C = () => {
|
|
105
|
+
const l = i.toString(e?.value);
|
|
106
|
+
!i.isNil(e?.value) && !i.isEqual(parseFloat(l), parseFloat(m)) && r(parseFloat(l).toLocaleString("pt-BR"));
|
|
107
|
+
}, t[35] = e.value, t[36] = r, t[37] = m, t[38] = C) : C = t[38];
|
|
108
|
+
const J = e?.value;
|
|
109
|
+
let I;
|
|
110
|
+
t[39] !== J ? (I = [J], t[39] = J, t[40] = I) : I = t[40], et(C, I);
|
|
111
|
+
let s;
|
|
112
|
+
t[41] !== b ? (s = lt(b, K), t[41] = b, t[42] = s) : s = t[42];
|
|
113
|
+
let Z;
|
|
114
|
+
return t[43] !== D || t[44] !== H || t[45] !== G || t[46] !== a || t[47] !== s || t[48] !== z ? (Z = /* @__PURE__ */ W(it, { ...a, ref: s, type: "text", inputMode: "decimal", value: G, textAlign: z, onBlur: H, onChange: nt, children: D }), t[43] = D, t[44] = H, t[45] = G, t[46] = a, t[47] = s, t[48] = z, t[49] = Z) : Z = t[49], Z;
|
|
96
115
|
});
|
|
97
|
-
|
|
98
|
-
function
|
|
116
|
+
at.displayName = "DecimalFieldInput";
|
|
117
|
+
function nt() {
|
|
99
118
|
}
|
|
100
119
|
export {
|
|
101
|
-
|
|
120
|
+
at as Decimal
|
|
102
121
|
};
|
|
103
122
|
//# sourceMappingURL=decimal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal.js","sources":["../../../src/lib/inputs2/numberfield/decimal.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"decimal.js","sources":["../../../src/lib/inputs2/numberfield/decimal.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useRef, ChangeEvent} from 'react';\nimport _ from 'lodash';\nimport { useIMask } from 'react-imask';\nimport { TextField } from '..';\nimport { mergeRefs } from '../../form2/helpers';\nimport type { DecimalFieldInputProps } from './types';\n\nconst Decimal = forwardRef<HTMLInputElement, DecimalFieldInputProps>((props, ref) => {\n const {\n min = undefined, max = undefined, to = undefined, from = undefined, enum: interval = undefined,\n onChange = null, onBlur = null, allowNegative = true, textAlign = 'right', children = null, \n scale = 2, normalizeZeros = false, padFractionalZeros = true, ...rest\n } = props;\n const numberInputRef = useRef<HTMLInputElement | null>(null);\n\n const { value: maskedValue, setValue: setMaskedValue, unmaskedValue } = useIMask({\n mask: Number,\n unmask: true,\n min: !_.isNil(min) ? min : (allowNegative ? undefined : 0),\n enum: interval,\n radix: ',',\n mapToRadix: ['.'],\n thousandsSeparator: '.',\n max,\n to,\n from,\n scale,\n normalizeZeros,\n padFractionalZeros,\n }, {\n ref: numberInputRef,\n onAccept: (__, options, event) => {\n const parsedValueToFloat = parseFloat(options.unmaskedValue);\n const valueToReturn = !_.isNaN(parsedValueToFloat) ? parsedValueToFloat : 0;\n onChange?.({\n ...event,\n target: {\n ...event?.target,\n name: props?.name,\n value: valueToReturn as unknown,\n },\n } as ChangeEvent<HTMLInputElement>);\n },\n });\n\n /**\n * Função sobrescrevendo o evento onBlur para tratar o valor mínimo ao sair do campo, \n * garantindo que o valor não seja menor que o mínimo definido.\n */\n const handleBlur = useCallback((event: React.FocusEvent<HTMLInputElement>) => {\n if (!_.isNil(min)) {\n const parsedCurrentValueToFloat = parseFloat(unmaskedValue) as number;\n if (_.isNaN(parsedCurrentValueToFloat) || parsedCurrentValueToFloat < min) {\n setMaskedValue(_.toString(min));\n onChange?.({\n ...event,\n target: {\n ...event?.target,\n name: props?.name,\n value: min as any,\n },\n } as React.ChangeEvent<HTMLInputElement>);\n }\n }\n onBlur?.(event);\n }, [min, unmaskedValue, onChange, onBlur, setMaskedValue, props.name]);\n\n useEffect(() => {\n const valueToString = _.toString(props?.value);\n if (!_.isNil(props?.value) && \n !_.isEqual(parseFloat(valueToString), parseFloat(unmaskedValue))) {\n setMaskedValue(parseFloat(valueToString).toLocaleString('pt-BR'));\n }\n }, [props?.value]);\n\n return (\n <TextField.Input\n {...rest}\n ref={mergeRefs(ref, numberInputRef)}\n type=\"text\"\n inputMode=\"decimal\"\n value={maskedValue}\n textAlign={textAlign}\n onBlur={handleBlur}\n onChange={() => { }}>\n {children}\n </TextField.Input>\n );\n});\n\nDecimal.displayName = 'DecimalFieldInput';\n\nexport { Decimal };\n"],"names":["Decimal","forwardRef","props","ref","$","_c","rest","t0","t1","t10","t11","t12","t2","t3","t4","t5","t6","t7","t8","t9","min","max","to","from","enum","onChange","onBlur","allowNegative","textAlign","children","scale","normalizeZeros","padFractionalZeros","undefined","interval","numberInputRef","useRef","t13","_","isNil","t14","Symbol","for","t15","mask","Number","unmask","radix","mapToRadix","thousandsSeparator","t16","name","onAccept","__","options","event","parsedValueToFloat","parseFloat","unmaskedValue","valueToReturn","isNaN","target","value","maskedValue","setValue","setMaskedValue","useIMask","t17","event_0","parsedCurrentValueToFloat","toString","handleBlur","t18","valueToString","isEqual","toLocaleString","t19","t20","useEffect","t21","mergeRefs","t22","_temp","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAMA,KAAUC,EAAqD,CAAAC,GAAAC,MAAA;AAAA,QAAAC,IAAAC,EAAAA,EAAA,EAAA;AAAA,MAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC;AAAA,EAAAf,SAAAF,KACnE;AAAA,IAAAkB,KAAAb;AAAAA,IAAAc,KAAAb;AAAAA,IAAAc,IAAAV;AAAAA,IAAAW,MAAAV;AAAAA,IAAAW,MAAAV;AAAAA,IAAAW,UAAAV;AAAAA,IAAAW,QAAAV;AAAAA,IAAAW,eAAAV;AAAAA,IAAAW,WAAAV;AAAAA,IAAAW,UAAAV;AAAAA,IAAAW,OAAArB;AAAAA,IAAAsB,gBAAArB;AAAAA,IAAAsB,oBAAArB;AAAAA,IAAA,GAAAL;AAAAA,EAAAA,IAIIJ,GAAME,OAAAF,GAAAE,OAAAE,GAAAF,OAAAG,GAAAH,OAAAI,GAAAJ,OAAAK,GAAAL,OAAAM,GAAAN,OAAAO,GAAAP,OAAAQ,GAAAR,OAAAS,GAAAT,OAAAU,GAAAV,QAAAW,GAAAX,QAAAY,GAAAZ,QAAAa,GAAAb,QAAAc,GAAAd,QAAAe,MAAAb,IAAAF,EAAA,CAAA,GAAAG,IAAAH,EAAA,CAAA,GAAAI,IAAAJ,EAAA,CAAA,GAAAK,IAAAL,EAAA,CAAA,GAAAM,IAAAN,EAAA,CAAA,GAAAO,IAAAP,EAAA,CAAA,GAAAQ,IAAAR,EAAA,CAAA,GAAAS,IAAAT,EAAA,CAAA,GAAAU,IAAAV,EAAA,CAAA,GAAAW,IAAAX,EAAA,EAAA,GAAAY,IAAAZ,EAAA,EAAA,GAAAa,IAAAb,EAA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AAC,GAAU7E,GAAKgC,CAAc,GAAC/B,QAAAD,GAAAC,QAAA2E,KAAAA,IAAA3E,EAAA,EAAA;AAAA,MAAA6E;AAAA,SAAA7E,UAAAyB,KAAAzB,EAAA,EAAA,MAAAmE,KAAAnE,EAAA,EAAA,MAAA2D,KAAA3D,EAAA,EAAA,MAAAE,KAAAF,UAAA2E,KAAA3E,EAAA,EAAA,MAAAwB,KAFrCqD,+BACM3E,GACC,KAAAyE,GACA,MAAA,QACK,WAAA,WACHhB,OAAAA,GACInC,WAAAA,GACH2C,QAAAA,GACE,UAAAW,IACTrD,UAAAA,GACH,GAAkBzB,QAAAyB,GAAAzB,QAAAmE,GAAAnE,QAAA2D,GAAA3D,QAAAE,GAAAF,QAAA2E,GAAA3E,QAAAwB,GAAAxB,QAAA6E,KAAAA,IAAA7E,EAAA,EAAA,GAVlB6E;AAUkB,CAErB;AAEDjF,GAAQmF,cAAc;AAnF+C,SAAAD,KAAA;AAAA;"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
const
|
|
2
|
-
if (!
|
|
3
|
-
const
|
|
4
|
-
if (
|
|
5
|
-
return
|
|
1
|
+
const u = (r, t) => {
|
|
2
|
+
if (!r || r === "") return t ? "" : 0;
|
|
3
|
+
const e = r.replace(/[^\d-]/g, "");
|
|
4
|
+
if (t)
|
|
5
|
+
return e;
|
|
6
6
|
const {
|
|
7
|
-
MAX_SAFE_INTEGER:
|
|
7
|
+
MAX_SAFE_INTEGER: n
|
|
8
8
|
} = Number;
|
|
9
9
|
try {
|
|
10
|
-
const
|
|
11
|
-
return
|
|
10
|
+
const c = BigInt(e);
|
|
11
|
+
return c > BigInt(n) || c < BigInt(-n) ? e : Number(e);
|
|
12
12
|
} catch {
|
|
13
|
-
return
|
|
13
|
+
return e;
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
u as convertToSafeNumber
|
|
18
18
|
};
|
|
19
19
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../src/lib/inputs2/numberfield/helpers.ts"],"sourcesContent":["/**\n * Converte um valor string para um número seguro ou retorna como string limpa.\n * \n * Esta função sanitiza a entrada removendo todos os caracteres não-dígitos exceto hífens,\n * e então converte para número se estiver dentro do intervalo seguro de inteiros do JavaScript.\n * Se o valor exceder o intervalo seguro ou a conversão falhar, retorna a string limpa.\n * \n * @param stringValue - A string de entrada a ser convertida. Pode conter qualquer caractere.\n * @param returnAsString - Se true, retorna a string limpa sem tentar conversão para número. Se false, \n * tenta converter para número dentro dos limites seguros de inteiros.\n * \n * @returns {number | string} Retorna:\n * - String vazia ('') ou 0 se a entrada estiver vazia/nula (baseado na prop \"returnAsString\")\n * - String limpa se \"returnAsString\" for true\n * - Número se a conversão for bem-sucedida e dentro do intervalo seguro de inteiros\n * - String limpa se o número exceder o intervalo seguro ou a conversão falhar\n * \n * @example\n * ```typescript\n * convertToSafeNumber(\"123abc\", false); // Retorna: 123\n * convertToSafeNumber(\"123abc\", true); // Retorna: \"123\"\n * convertToSafeNumber(\"-456def\", false); // Retorna: -456\n * convertToSafeNumber(\"999999999999999999999\", false); // Retorna: \"999999999999999999999\" (excede intervalo seguro)\n * convertToSafeNumber(\"\", false); // Retorna: 0\n * convertToSafeNumber(\"\", true); // Retorna: \"\"\n * ```\n */\nexport const convertToSafeNumber = (\n stringValue: string, returnAsString: boolean,\n): number | string => {\n if (!stringValue || stringValue === '') return returnAsString ? '' : 0;\n const cleanValue = stringValue.replace(/[^\\d-]/g, '');\n\n if (returnAsString) {\n return cleanValue;\n }\n const { MAX_SAFE_INTEGER } = Number;\n try {\n const numValue = BigInt(cleanValue);\n \n if (numValue > BigInt(MAX_SAFE_INTEGER) || numValue < BigInt(-MAX_SAFE_INTEGER)) {\n return cleanValue;\n }\n return Number(cleanValue);\n } catch
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../src/lib/inputs2/numberfield/helpers.ts"],"sourcesContent":["/**\n * Converte um valor string para um número seguro ou retorna como string limpa.\n * \n * Esta função sanitiza a entrada removendo todos os caracteres não-dígitos exceto hífens,\n * e então converte para número se estiver dentro do intervalo seguro de inteiros do JavaScript.\n * Se o valor exceder o intervalo seguro ou a conversão falhar, retorna a string limpa.\n * \n * @param stringValue - A string de entrada a ser convertida. Pode conter qualquer caractere.\n * @param returnAsString - Se true, retorna a string limpa sem tentar conversão para número. Se false, \n * tenta converter para número dentro dos limites seguros de inteiros.\n * \n * @returns {number | string} Retorna:\n * - String vazia ('') ou 0 se a entrada estiver vazia/nula (baseado na prop \"returnAsString\")\n * - String limpa se \"returnAsString\" for true\n * - Número se a conversão for bem-sucedida e dentro do intervalo seguro de inteiros\n * - String limpa se o número exceder o intervalo seguro ou a conversão falhar\n * \n * @example\n * ```typescript\n * convertToSafeNumber(\"123abc\", false); // Retorna: 123\n * convertToSafeNumber(\"123abc\", true); // Retorna: \"123\"\n * convertToSafeNumber(\"-456def\", false); // Retorna: -456\n * convertToSafeNumber(\"999999999999999999999\", false); // Retorna: \"999999999999999999999\" (excede intervalo seguro)\n * convertToSafeNumber(\"\", false); // Retorna: 0\n * convertToSafeNumber(\"\", true); // Retorna: \"\"\n * ```\n */\nexport const convertToSafeNumber = (\n stringValue: string, returnAsString: boolean,\n): number | string => {\n if (!stringValue || stringValue === '') return returnAsString ? '' : 0;\n const cleanValue = stringValue.replace(/[^\\d-]/g, '');\n\n if (returnAsString) {\n return cleanValue;\n }\n const { MAX_SAFE_INTEGER } = Number;\n try {\n const numValue = BigInt(cleanValue);\n \n if (numValue > BigInt(MAX_SAFE_INTEGER) || numValue < BigInt(-MAX_SAFE_INTEGER)) {\n return cleanValue;\n }\n return Number(cleanValue);\n } catch {\n return cleanValue;\n }\n};\n"],"names":["convertToSafeNumber","stringValue","returnAsString","cleanValue","replace","MAX_SAFE_INTEGER","Number","numValue","BigInt"],"mappings":"AA2BO,MAAMA,IAAsBA,CACjCC,GAAqBC,MACD;AACpB,MAAI,CAACD,KAAeA,MAAgB,GAAI,QAAOC,IAAiB,KAAK;AACrE,QAAMC,IAAaF,EAAYG,QAAQ,WAAW,EAAE;AAEpD,MAAIF;AACF,WAAOC;AAET,QAAM;AAAA,IAAEE,kBAAAA;AAAAA,EAAAA,IAAqBC;AAC7B,MAAI;AACF,UAAMC,IAAWC,OAAOL,CAAU;AAElC,WAAII,IAAWC,OAAOH,CAAgB,KAAKE,IAAWC,OAAO,CAACH,CAAgB,IACrEF,IAEFG,OAAOH,CAAU;AAAA,EAC1B,QAAQ;AACN,WAAOA;AAAAA,EACT;AACF;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
2
|
import { Decimal } from './decimal';
|
|
3
3
|
import { Currency } from './currency';
|
|
4
|
+
import { LeftSlot, RightSlot } from '../slot';
|
|
4
5
|
import { NumberFieldInputProps, DecimalFieldInputProps, CurrencyFieldInputProps } from './types';
|
|
5
|
-
declare const Input:
|
|
6
|
+
declare const Input: React.ForwardRefExoticComponent<NumberFieldInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
6
7
|
export { Input, Decimal, Currency, LeftSlot, RightSlot };
|
|
7
8
|
export type { NumberFieldInputProps, DecimalFieldInputProps, CurrencyFieldInputProps, };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as K } from "react/jsx-runtime";
|
|
2
2
|
import { c as O } from "../../_virtual/compiler-runtime.js";
|
|
3
|
-
import
|
|
3
|
+
import { forwardRef as P, useRef as Q, useEffect as W } from "react";
|
|
4
|
+
import i from "../../_virtual/lodash.js";
|
|
4
5
|
import "../../node_modules/imask/esm/index.js";
|
|
5
6
|
import "../../node_modules/imask/esm/controls/input.js";
|
|
6
7
|
import "../../node_modules/imask/esm/masked/factory.js";
|
|
@@ -10,41 +11,41 @@ import "../../node_modules/imask/esm/controls/html-mask-element.js";
|
|
|
10
11
|
import "../../node_modules/imask/esm/controls/html-contenteditable-mask-element.js";
|
|
11
12
|
import "../../node_modules/imask/esm/controls/input-history.js";
|
|
12
13
|
import "../../node_modules/react-imask/esm/input.js";
|
|
13
|
-
import
|
|
14
|
+
import X from "../../node_modules/react-imask/esm/hook.js";
|
|
14
15
|
import "../../node_modules/react-imask/esm/mixin.js";
|
|
15
|
-
import {
|
|
16
|
+
import { Decimal as yt } from "./decimal.js";
|
|
17
|
+
import { Currency as qt } from "./currency.js";
|
|
18
|
+
import { convertToSafeNumber as G } from "./helpers.js";
|
|
16
19
|
import { Input as Y } from "../textfield/index.js";
|
|
17
20
|
import "../textareafield/index.js";
|
|
18
21
|
import "../date/datefield/index.js";
|
|
19
22
|
import "../radiofield/index.js";
|
|
20
23
|
import "../selectfield/index.js";
|
|
21
24
|
import "../colorfield/index.js";
|
|
25
|
+
import "../mask/index.js";
|
|
22
26
|
import "../checkboxfield/index.js";
|
|
23
27
|
import "../date/dateperiodfield/index.js";
|
|
24
28
|
import "../filefield/index.js";
|
|
29
|
+
import { LeftSlot as $t, RightSlot as jt } from "../slot/index.js";
|
|
25
30
|
import { mergeRefs as Z } from "../../form2/helpers.js";
|
|
26
|
-
|
|
27
|
-
import { Decimal as qt } from "./decimal.js";
|
|
28
|
-
import { Currency as $t } from "./currency.js";
|
|
29
|
-
import { convertToSafeNumber as G } from "./helpers.js";
|
|
30
|
-
const tt = Q((e, C) => {
|
|
31
|
+
const tt = P((e, C) => {
|
|
31
32
|
const t = O.c(46);
|
|
32
|
-
let n, f, c, d, v, g, p,
|
|
33
|
+
let n, f, c, d, v, g, p, N, x, h, S, V;
|
|
33
34
|
t[0] !== e ? ({
|
|
34
35
|
min: f,
|
|
35
36
|
max: c,
|
|
36
37
|
to: v,
|
|
37
38
|
from: g,
|
|
38
39
|
enum: p,
|
|
39
|
-
onChange:
|
|
40
|
-
onBlur:
|
|
40
|
+
onChange: N,
|
|
41
|
+
onBlur: x,
|
|
41
42
|
allowNegative: h,
|
|
42
43
|
returnAsString: S,
|
|
43
44
|
textAlign: V,
|
|
44
45
|
children: d,
|
|
45
46
|
...n
|
|
46
|
-
} = e, t[0] = e, t[1] = n, t[2] = f, t[3] = c, t[4] = d, t[5] = v, t[6] = g, t[7] = p, t[8] =
|
|
47
|
-
const
|
|
47
|
+
} = e, t[0] = e, t[1] = n, t[2] = f, t[3] = c, t[4] = d, t[5] = v, t[6] = g, t[7] = p, t[8] = N, t[9] = x, t[10] = h, t[11] = S, t[12] = V) : (n = t[1], f = t[2], c = t[3], d = t[4], v = t[5], g = t[6], p = t[7], N = t[8], x = t[9], h = t[10], S = t[11], V = t[12]);
|
|
48
|
+
const o = f === void 0 ? void 0 : f, E = c === void 0 ? void 0 : c, w = v === void 0 ? void 0 : v, y = g === void 0 ? void 0 : g, M = p === void 0 ? void 0 : p, m = N === void 0 ? null : N, q = x === void 0 ? null : x, H = h === void 0 ? !0 : h, r = S === void 0 ? !1 : S, _ = V === void 0 ? "right" : V, $ = d === void 0 ? null : d, U = Q(null), j = i.isNil(o) ? H ? void 0 : 0 : o;
|
|
48
49
|
let k;
|
|
49
50
|
t[13] !== y || t[14] !== M || t[15] !== E || t[16] !== j || t[17] !== w ? (k = {
|
|
50
51
|
mask: Number,
|
|
@@ -74,31 +75,31 @@ const tt = Q((e, C) => {
|
|
|
74
75
|
value: D,
|
|
75
76
|
setValue: a,
|
|
76
77
|
unmaskedValue: u
|
|
77
|
-
} =
|
|
78
|
+
} = X(k, I);
|
|
78
79
|
let R;
|
|
79
|
-
t[23] !==
|
|
80
|
-
if (!
|
|
80
|
+
t[23] !== o || t[24] !== q || t[25] !== m || t[26] !== e.name || t[27] !== r || t[28] !== a || t[29] !== u ? (R = (l) => {
|
|
81
|
+
if (!i.isNil(o)) {
|
|
81
82
|
const T = G(u, !1);
|
|
82
|
-
(
|
|
83
|
+
(i.isNaN(T) || T < o) && (a(i.toString(o)), m?.({
|
|
83
84
|
...l,
|
|
84
85
|
target: {
|
|
85
86
|
...l?.target,
|
|
86
87
|
name: e?.name,
|
|
87
|
-
value: r ?
|
|
88
|
+
value: r ? i.toString(o) : o
|
|
88
89
|
}
|
|
89
90
|
}));
|
|
90
91
|
}
|
|
91
92
|
q?.(l);
|
|
92
|
-
}, t[23] =
|
|
93
|
+
}, t[23] = o, t[24] = q, t[25] = m, t[26] = e.name, t[27] = r, t[28] = a, t[29] = u, t[30] = R) : R = t[30];
|
|
93
94
|
const F = R;
|
|
94
95
|
let b;
|
|
95
96
|
t[31] !== e.value || t[32] !== a || t[33] !== u ? (b = () => {
|
|
96
97
|
const l = Number(u || "0");
|
|
97
|
-
!
|
|
98
|
+
!i.isNil(e?.value) && (!i.isEqual(e?.value, l) || i.isEqual(e?.value, 0)) && a(i.toString(e?.value));
|
|
98
99
|
}, t[31] = e.value, t[32] = a, t[33] = u, t[34] = b) : b = t[34];
|
|
99
100
|
const L = e?.value;
|
|
100
101
|
let A;
|
|
101
|
-
t[35] !== L ? (A = [L], t[35] = L, t[36] = A) : A = t[36],
|
|
102
|
+
t[35] !== L ? (A = [L], t[35] = L, t[36] = A) : A = t[36], W(b, A);
|
|
102
103
|
let s;
|
|
103
104
|
t[37] !== C ? (s = Z(C, U), t[37] = C, t[38] = s) : s = t[38];
|
|
104
105
|
let B;
|
|
@@ -108,10 +109,10 @@ tt.displayName = "NumberFieldInput";
|
|
|
108
109
|
function et() {
|
|
109
110
|
}
|
|
110
111
|
export {
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
qt as Currency,
|
|
113
|
+
yt as Decimal,
|
|
113
114
|
tt as Input,
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
$t as LeftSlot,
|
|
116
|
+
jt as RightSlot
|
|
116
117
|
};
|
|
117
118
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/lib/inputs2/numberfield/index.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/lib/inputs2/numberfield/index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useRef, type ChangeEvent } from 'react';\nimport _ from 'lodash';\nimport { useIMask } from 'react-imask';\nimport { Decimal } from './decimal';\nimport { Currency } from './currency';\nimport { convertToSafeNumber } from './helpers';\nimport { TextField } from '..';\nimport { LeftSlot, RightSlot } from '../slot';\nimport { mergeRefs } from '../../form2/helpers';\nimport type { NumberFieldInputProps, DecimalFieldInputProps, CurrencyFieldInputProps } from './types';\n\nconst Input = forwardRef<HTMLInputElement, NumberFieldInputProps>((props, ref) => {\n const {\n min = undefined, max = undefined, to = undefined, from = undefined, enum: interval = undefined,\n onChange = null, onBlur = null, allowNegative = true, returnAsString = false, textAlign = 'right', \n children = null, ...rest\n } = props;\n const numberInputRef = useRef<HTMLInputElement | null>(null);\n\n const { value: maskedValue, setValue: setMaskedValue, unmaskedValue } = useIMask({\n mask: Number,\n scale: 0,\n enum: interval,\n min: !_.isNil(min) ? min : (allowNegative ? undefined : 0),\n max,\n to,\n from,\n }, {\n ref: numberInputRef,\n onAccept: (value, __, event) => {\n const parsedValue = convertToSafeNumber(value, returnAsString);\n onChange?.({\n ...event,\n target: {\n ...event?.target,\n name: props?.name,\n value: parsedValue as any,\n },\n } as ChangeEvent<HTMLInputElement>);\n },\n });\n\n /**\n * Função sobrescrevendo o evento onBlur para tratar o valor mínimo ao sair do campo, \n * garantindo que o valor não seja menor que o mínimo definido.\n */\n const handleBlur = useCallback((event: React.FocusEvent<HTMLInputElement>) => {\n if (!_.isNil(min)) {\n const currentValue = convertToSafeNumber(unmaskedValue, false) as number;\n if (_.isNaN(currentValue) || currentValue < min) {\n setMaskedValue(_.toString(min));\n onChange?.({\n ...event,\n target: {\n ...event?.target,\n name: props?.name,\n value: (returnAsString ? _.toString(min) : min) as any,\n },\n } as React.ChangeEvent<HTMLInputElement>);\n }\n }\n onBlur?.(event);\n }, [min, unmaskedValue, onChange, onBlur, setMaskedValue, props.name, returnAsString]);\n\n useEffect(() => {\n const floatUnmaskedValue = Number(unmaskedValue || '0');\n if (!_.isNil(props?.value) && (!_.isEqual(props?.value,\n floatUnmaskedValue) || _.isEqual(props?.value, 0))) {\n setMaskedValue(_.toString(props?.value));\n }\n }, [props?.value]);\n\n return (\n <TextField.Input\n {...rest}\n ref={mergeRefs(ref, numberInputRef)}\n type=\"text\"\n inputMode=\"numeric\"\n value={maskedValue}\n textAlign={textAlign}\n onBlur={handleBlur}\n onChange={() => { }}>\n {children}\n </TextField.Input>\n );\n});\n\nInput.displayName = 'NumberFieldInput';\n\nexport { Input, Decimal, Currency, LeftSlot, RightSlot };\nexport type { \n NumberFieldInputProps, \n DecimalFieldInputProps, \n CurrencyFieldInputProps, \n};\n"],"names":["Input","forwardRef","props","ref","$","_c","rest","t0","t1","t10","t2","t3","t4","t5","t6","t7","t8","t9","min","max","to","from","enum","onChange","onBlur","allowNegative","returnAsString","textAlign","children","undefined","interval","numberInputRef","useRef","t11","_","isNil","t12","mask","Number","scale","t13","name","onAccept","value","__","event","parsedValue","convertToSafeNumber","target","maskedValue","setValue","setMaskedValue","unmaskedValue","useIMask","t14","event_0","currentValue","isNaN","toString","handleBlur","t15","floatUnmaskedValue","isEqual","t16","t17","useEffect","t18","mergeRefs","t19","_temp","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,MAAMA,KAAQC,EAAoD,CAAAC,GAAAC,MAAA;AAAA,QAAAC,IAAAC,EAAAA,EAAA,EAAA;AAAA,MAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC;AAAA,EAAAb,SAAAF,KAChE;AAAA,IAAAgB,KAAAX;AAAAA,IAAAY,KAAAX;AAAAA,IAAAY,IAAAV;AAAAA,IAAAW,MAAAV;AAAAA,IAAAW,MAAAV;AAAAA,IAAAW,UAAAV;AAAAA,IAAAW,QAAAV;AAAAA,IAAAW,eAAAV;AAAAA,IAAAW,gBAAAV;AAAAA,IAAAW,WAAAV;AAAAA,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