linear-react-components-ui 1.1.26-beta.23 → 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 +1 -1
- package/lib/inputs2/index.js +8 -8
- 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 +86 -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 +1 -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,23 +1,84 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as C, useEffect as F } from "react";
|
|
3
|
+
import a from "../../_virtual/lodash.js";
|
|
4
|
+
import "../../node_modules/imask/esm/index.js";
|
|
5
|
+
import "../../node_modules/imask/esm/controls/input.js";
|
|
6
|
+
import "../../node_modules/imask/esm/masked/factory.js";
|
|
7
|
+
import "../../node_modules/imask/esm/controls/mask-element.js";
|
|
8
|
+
import "../../node_modules/imask/esm/controls/html-input-mask-element.js";
|
|
9
|
+
import "../../node_modules/imask/esm/controls/html-mask-element.js";
|
|
10
|
+
import "../../node_modules/imask/esm/controls/html-contenteditable-mask-element.js";
|
|
11
|
+
import "../../node_modules/imask/esm/controls/input-history.js";
|
|
12
|
+
import "../../node_modules/react-imask/esm/input.js";
|
|
13
|
+
import B from "../../node_modules/react-imask/esm/hook.js";
|
|
14
|
+
import "../../node_modules/react-imask/esm/mixin.js";
|
|
15
|
+
import { numberToEnUS as E } from "./format_number.js";
|
|
16
|
+
import T from "../base/InputTextBase.js";
|
|
17
|
+
import { mergeRefs as A } from "../../form2/helpers.js";
|
|
18
|
+
const O = (e) => {
|
|
11
19
|
const {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
inputRef: s = void 0,
|
|
21
|
+
textAlign: c = "left",
|
|
22
|
+
themePopover: f = "light",
|
|
23
|
+
popoverAlign: d = "left",
|
|
24
|
+
min: r = void 0,
|
|
25
|
+
max: p = void 0,
|
|
26
|
+
allowNegative: g = !1,
|
|
27
|
+
scale: v = 2,
|
|
28
|
+
normalizeZeros: y = !0,
|
|
29
|
+
padFractionalZeros: N = !1,
|
|
30
|
+
unmask: h = !0,
|
|
31
|
+
currencySymbol: x = "R$",
|
|
32
|
+
displayCurrencySymbol: k = !0
|
|
33
|
+
} = e, i = C(null), R = k ? /* @__PURE__ */ u("span", { className: "currency-symbol", children: x }) : [], {
|
|
34
|
+
value: S,
|
|
35
|
+
setValue: l,
|
|
36
|
+
unmaskedValue: n
|
|
37
|
+
} = B({
|
|
38
|
+
mask: Number,
|
|
39
|
+
unmask: h,
|
|
40
|
+
scale: v,
|
|
41
|
+
normalizeZeros: y,
|
|
42
|
+
padFractionalZeros: N,
|
|
43
|
+
max: p,
|
|
44
|
+
min: a.isNil(r) ? g ? void 0 : 0 : r,
|
|
45
|
+
radix: ",",
|
|
46
|
+
mapToRadix: ["."],
|
|
47
|
+
thousandsSeparator: "."
|
|
48
|
+
}, {
|
|
49
|
+
ref: i,
|
|
50
|
+
onAccept: (t, o, m) => {
|
|
51
|
+
const b = E(o.unmaskedValue);
|
|
52
|
+
e?.onChange?.({
|
|
53
|
+
...m,
|
|
54
|
+
target: {
|
|
55
|
+
...m?.target,
|
|
56
|
+
name: e?.name,
|
|
57
|
+
value: b
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}), V = (t) => {
|
|
62
|
+
if (!a.isNil(r)) {
|
|
63
|
+
const o = parseFloat(n);
|
|
64
|
+
(a.isNaN(o) || o < r) && (l(a.toString(r)), e?.onChange?.({
|
|
65
|
+
...t,
|
|
66
|
+
target: {
|
|
67
|
+
...t?.target,
|
|
68
|
+
name: e?.name,
|
|
69
|
+
value: r
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
e?.onBlur?.(t);
|
|
74
|
+
};
|
|
75
|
+
return F(() => {
|
|
76
|
+
const t = a.toString(e?.value);
|
|
77
|
+
!a.isNil(e?.value) && !a.isEqual(parseFloat(t), parseFloat(n)) && l(t);
|
|
78
|
+
}, [e?.value]), /* @__PURE__ */ u(T, { ...e, inputRef: A(i, s), type: "text", onChange: () => {
|
|
79
|
+
}, leftElements: R, onBlur: V, value: S, textAlign: c, themePopover: f, popoverAlign: d });
|
|
19
80
|
};
|
|
20
81
|
export {
|
|
21
|
-
|
|
82
|
+
O as default
|
|
22
83
|
};
|
|
23
84
|
//# sourceMappingURL=Currency.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Currency.js","sources":["../../../src/lib/inputs/number/Currency.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Currency.js","sources":["../../../src/lib/inputs/number/Currency.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport _ from 'lodash';\nimport { useIMask } from 'react-imask';\nimport { ICurrencyProps } from './types';\nimport { numberToEnUS } from './format_number';\nimport InputTextBase from '../base/InputTextBase';\nimport { mergeRefs } from '../../form2/helpers';\nimport type { CustomInputEvent } from '../base/types';\n\nconst CurrencyField = (props: ICurrencyProps) => {\n const {\n inputRef = undefined, textAlign = 'left', themePopover = 'light', popoverAlign = 'left',\n min = undefined, max = undefined, allowNegative = false, scale = 2, normalizeZeros = true,\n padFractionalZeros = false, unmask = true, currencySymbol = 'R$', displayCurrencySymbol = true,\n } = props;\n const currencyNumberInputRef = useRef<HTMLInputElement | null>(null);\n const leftElements = displayCurrencySymbol ?\n <span className=\"currency-symbol\">{currencySymbol}</span>\n : [];\n\n const { value: maskedValue, setValue: setMaskedValue, unmaskedValue } = useIMask({\n mask: Number,\n unmask,\n scale,\n normalizeZeros,\n padFractionalZeros,\n max,\n min: !_.isNil(min) ? min : (allowNegative ? undefined : 0),\n radix: ',',\n mapToRadix: ['.'],\n thousandsSeparator: '.',\n }, {\n ref: currencyNumberInputRef,\n onAccept: (__, options, event) => {\n const parsedValue = numberToEnUS(options.unmaskedValue);\n props?.onChange?.({\n ...event,\n target: {\n ...event?.target,\n name: props?.name,\n value: parsedValue as any,\n },\n } as React.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 = (event: CustomInputEvent) => {\n if (!_.isNil(min)) {\n const currentValue = parseFloat(unmaskedValue) as number;\n if (_.isNaN(currentValue) || currentValue < min) {\n setMaskedValue(_.toString(min));\n props?.onChange?.({\n ...event,\n target: {\n ...event?.target,\n name: props?.name,\n value: min as any,\n },\n } as CustomInputEvent);\n }\n }\n props?.onBlur?.(event);\n };\n\n useEffect(() => {\n const valueToString = _.toString(props?.value);\n if (!_.isNil(props?.value) && !_.isEqual(\n parseFloat(valueToString), parseFloat(unmaskedValue),\n )) {\n setMaskedValue(valueToString);\n }\n }, [props?.value]);\n\n return (\n <InputTextBase\n {...props}\n inputRef={mergeRefs(currencyNumberInputRef, inputRef) as any}\n type=\"text\"\n onChange={() => { }}\n leftElements={leftElements}\n onBlur={handleBlur}\n value={maskedValue}\n textAlign={textAlign}\n themePopover={themePopover}\n popoverAlign={popoverAlign} />\n );\n};\n\nexport default CurrencyField;\n"],"names":["CurrencyField","props","inputRef","undefined","textAlign","themePopover","popoverAlign","min","max","allowNegative","scale","normalizeZeros","padFractionalZeros","unmask","currencySymbol","displayCurrencySymbol","currencyNumberInputRef","useRef","leftElements","jsx","value","maskedValue","setValue","setMaskedValue","unmaskedValue","useIMask","mask","Number","_","isNil","radix","mapToRadix","thousandsSeparator","ref","onAccept","__","options","event","parsedValue","numberToEnUS","onChange","target","name","handleBlur","currentValue","parseFloat","isNaN","toString","onBlur","useEffect","valueToString","isEqual","InputTextBase","mergeRefs"],"mappings":";;;;;;;;;;;;;;;;;AASA,MAAMA,IAAgBA,CAACC,MAA0B;AAC/C,QAAM;AAAA,IACJC,UAAAA,IAAWC;AAAAA,IAAWC,WAAAA,IAAY;AAAA,IAAQC,cAAAA,IAAe;AAAA,IAASC,cAAAA,IAAe;AAAA,IACjFC,KAAAA,IAAMJ;AAAAA,IAAWK,KAAAA,IAAML;AAAAA,IAAWM,eAAAA,IAAgB;AAAA,IAAOC,OAAAA,IAAQ;AAAA,IAAGC,gBAAA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,QACHI,QAAQ;AAAA,UACN,GAAGJ,GAAOI;AAAAA,UACVC,MAAMzC,GAAOyC;AAAAA,UACbtB,OAAOb;AAAAA,QAAAA;AAAAA,MACT,CACmB;AAAA,IAEzB;AACAN,IAAAA,GAAO+C,SAASX,CAAK;AAAA,EACvB;AAEAY,SAAAA,EAAU,MAAM;AACd,UAAMC,IAAgBtB,EAAEmB,SAAS9C,GAAOmB,KAAK;AAC7C,IAAI,CAACQ,EAAEC,MAAM5B,GAAOmB,KAAK,KAAK,CAACQ,EAAEuB,QAC/BN,WAAWK,CAAa,GAAGL,WAAWrB,CAAa,CACrD,KACED,EAAe2B,CAAa;AAAA,EAEhC,GAAG,CAACjD,GAAOmB,KAAK,CAAC,GAGf,gBAAAD,EAACiC,GAAA,EACC,GAAInD,GACJ,UAAUoD,EAAUrC,GAAwBd,CAAQ,GACpD,MAAK,QACL,UAAU,MAAM;AAAA,EAAE,GAClB,cAAAgB,GACA,QAAQyB,GACR,OAAOtB,GACP,WAAAjB,GACA,cAAAC,GACA,cAAAC,GAA2B;AAEjC;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const DecimalField: (props:
|
|
1
|
+
import { IDecimalProps } from './types';
|
|
2
|
+
declare const DecimalField: (props: IDecimalProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default DecimalField;
|
|
@@ -1,12 +1,82 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as R } from "react/jsx-runtime";
|
|
2
|
+
import a from "../../_virtual/lodash.js";
|
|
3
|
+
import { useRef as F, useEffect as S } from "react";
|
|
4
|
+
import "../../node_modules/imask/esm/index.js";
|
|
5
|
+
import "../../node_modules/imask/esm/controls/input.js";
|
|
6
|
+
import "../../node_modules/imask/esm/masked/factory.js";
|
|
7
|
+
import "../../node_modules/imask/esm/controls/mask-element.js";
|
|
8
|
+
import "../../node_modules/imask/esm/controls/html-input-mask-element.js";
|
|
9
|
+
import "../../node_modules/imask/esm/controls/html-mask-element.js";
|
|
10
|
+
import "../../node_modules/imask/esm/controls/html-contenteditable-mask-element.js";
|
|
11
|
+
import "../../node_modules/imask/esm/controls/input-history.js";
|
|
12
|
+
import "../../node_modules/react-imask/esm/input.js";
|
|
13
|
+
import B from "../../node_modules/react-imask/esm/hook.js";
|
|
14
|
+
import "../../node_modules/react-imask/esm/mixin.js";
|
|
15
|
+
import { numberToEnUS as T } from "./format_number.js";
|
|
16
|
+
import b from "../base/InputTextBase.js";
|
|
17
|
+
import { mergeRefs as A } from "../../form2/helpers.js";
|
|
18
|
+
const K = (e) => {
|
|
19
|
+
const {
|
|
20
|
+
textAlign: u = "left",
|
|
21
|
+
themePopover: s = "light",
|
|
22
|
+
popoverAlign: f = "left",
|
|
23
|
+
min: o = void 0,
|
|
24
|
+
max: d = void 0,
|
|
25
|
+
allowNegative: c = !1,
|
|
26
|
+
scale: p = 2,
|
|
27
|
+
normalizeZeros: g = !0,
|
|
28
|
+
padFractionalZeros: v = !0,
|
|
29
|
+
unmask: x = !0,
|
|
30
|
+
inputRef: N = void 0
|
|
31
|
+
} = e, i = F(null), {
|
|
32
|
+
value: h,
|
|
33
|
+
setValue: m,
|
|
34
|
+
unmaskedValue: l
|
|
35
|
+
} = B({
|
|
36
|
+
mask: Number,
|
|
37
|
+
unmask: x,
|
|
38
|
+
scale: p,
|
|
39
|
+
normalizeZeros: g,
|
|
40
|
+
padFractionalZeros: v,
|
|
41
|
+
max: d,
|
|
42
|
+
min: a.isNil(o) ? c ? void 0 : 0 : o,
|
|
43
|
+
radix: ",",
|
|
44
|
+
mapToRadix: ["."],
|
|
45
|
+
thousandsSeparator: "."
|
|
46
|
+
}, {
|
|
47
|
+
ref: i,
|
|
48
|
+
onAccept: (t, r, n) => {
|
|
49
|
+
const V = T(r.unmaskedValue);
|
|
50
|
+
e?.onChange?.({
|
|
51
|
+
...n,
|
|
52
|
+
target: {
|
|
53
|
+
...n?.target,
|
|
54
|
+
name: e?.name,
|
|
55
|
+
value: V
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}), k = (t) => {
|
|
60
|
+
if (!a.isNil(o)) {
|
|
61
|
+
const r = parseFloat(l);
|
|
62
|
+
(a.isNaN(r) || r < o) && (m(a.toString(o)), e?.onChange?.({
|
|
63
|
+
...t,
|
|
64
|
+
target: {
|
|
65
|
+
...t?.target,
|
|
66
|
+
name: e?.name,
|
|
67
|
+
value: o
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
e?.onBlur?.(t);
|
|
72
|
+
};
|
|
73
|
+
return S(() => {
|
|
74
|
+
const t = a.toString(e?.value);
|
|
75
|
+
!a.isNil(e?.value) && !a.isEqual(parseFloat(t), parseFloat(l)) && m(t);
|
|
76
|
+
}, [e?.value]), /* @__PURE__ */ R(b, { ...e, inputRef: A(i, N), type: "text", onChange: () => {
|
|
77
|
+
}, onBlur: k, value: h, textAlign: u, themePopover: s, popoverAlign: f });
|
|
8
78
|
};
|
|
9
79
|
export {
|
|
10
|
-
|
|
80
|
+
K as default
|
|
11
81
|
};
|
|
12
82
|
//# sourceMappingURL=Decimal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Decimal.js","sources":["../../../src/lib/inputs/number/Decimal.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Decimal.js","sources":["../../../src/lib/inputs/number/Decimal.tsx"],"sourcesContent":["import _ from 'lodash';\nimport React, { useEffect, useRef } from 'react';\nimport { useIMask } from 'react-imask';\nimport { IDecimalProps } from './types';\nimport { numberToEnUS } from './format_number';\nimport InputTextBase from '../base/InputTextBase';\nimport type { CustomInputEvent } from '../base/types';\nimport { mergeRefs } from '../../form2/helpers';\n\nconst DecimalField = (props: IDecimalProps) => {\n const {\n textAlign = 'left', themePopover = 'light', popoverAlign = 'left', min = undefined,\n max = undefined, allowNegative = false, scale = 2, normalizeZeros = true,\n padFractionalZeros = true, unmask = true, inputRef = undefined,\n } = props;\n const decimalNumberInputRef = useRef<HTMLInputElement | null>(null);\n\n const { value: maskedValue, setValue: setMaskedValue, unmaskedValue } = useIMask({\n mask: Number,\n unmask,\n scale,\n normalizeZeros,\n padFractionalZeros,\n max,\n min: !_.isNil(min) ? min : (allowNegative ? undefined : 0),\n radix: ',',\n mapToRadix: ['.'],\n thousandsSeparator: '.',\n }, {\n ref: decimalNumberInputRef,\n onAccept: (__, options, event) => {\n const parsedValue = numberToEnUS(options.unmaskedValue);\n props?.onChange?.({\n ...event,\n target: {\n ...event?.target,\n name: props?.name,\n value: parsedValue as any,\n },\n } as React.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 = (event: CustomInputEvent) => {\n if (!_.isNil(min)) {\n const currentValue = parseFloat(unmaskedValue) as number;\n if (_.isNaN(currentValue) || currentValue < min) {\n setMaskedValue(_.toString(min));\n props?.onChange?.({\n ...event,\n target: {\n ...event?.target,\n name: props?.name,\n value: min as any,\n },\n } as CustomInputEvent);\n }\n }\n props?.onBlur?.(event);\n };\n\n useEffect(() => {\n const valueToString = _.toString(props?.value);\n if (!_.isNil(props?.value) && !_.isEqual(\n parseFloat(valueToString), parseFloat(unmaskedValue),\n )) {\n setMaskedValue(valueToString);\n }\n }, [props?.value]);\n\n return (\n <InputTextBase\n {...props}\n inputRef={mergeRefs(decimalNumberInputRef, inputRef) as any}\n type=\"text\"\n onChange={() => { }}\n onBlur={handleBlur}\n value={maskedValue}\n textAlign={textAlign}\n themePopover={themePopover}\n popoverAlign={popoverAlign} />\n );\n};\n\nexport default DecimalField;\n"],"names":["DecimalField","props","textAlign","themePopover","popoverAlign","min","undefined","max","allowNegative","scale","normalizeZeros","padFractionalZeros","unmask","inputRef","decimalNumberInputRef","useRef","value","maskedValue","setValue","setMaskedValue","unmaskedValue","useIMask","mask","Number","_","isNil","radix","mapToRadix","thousandsSeparator","ref","onAccept","__","options","event","parsedValue","numberToEnUS","onChange","target","name","handleBlur","currentValue","parseFloat","isNaN","toString","onBlur","useEffect","valueToString","isEqual","jsx","InputTextBase","mergeRefs"],"mappings":";;;;;;;;;;;;;;;;;AASA,MAAMA,IAAeA,CAACC,MAAyB;AAC7C,QAAM;AAAA,IACJC,WAAAA,IAAY;AAAA,IAAQC,cAAAA,IAAe;AAAA,IAASC,cAAAA,IAAe;AAAA,IAAQC,KAAAA,IAAMC;AAAAA,IACzEC,KAAAA,IAAMD;AAAAA,IAAWE,eAAAA,IAAgB;AAAA,IAAOC,OAAAA,IAAQ;AAAA,IAAGC,gBAAAA,IAAiB;AAAA,IACpEC,oBAAAA,IAAqB;AAAA,IAAMC,QAAAA,IAAS;AAAA,IAAMC,UAAAA,IAAWP;AAAAA,EAAAA,IACnDL,GACEa,IAAwBC,EAAgC,IAAI,GAE5D;AAAA,IAAEC,OAAOC;AAAAA,IAAaC,UAAUC;AAAAA,IAAgBC,eAAAA;AAAAA,EAAAA,IAAkBC,EAAS;AAAA,IAC/EC,MAAMC;AAAAA,IACNX,QAAAA;AAAAA,IACAH,OAAAA;AAAAA,IACAC,gBAAAA;AAAAA,IACAC,oBAAAA;AAAAA,IACAJ,KAAAA;AAAAA,IACAF,KAAMmB,EAAEC,MAAMpB,CAAG,IAAWG,IAAgBF,SAAY,IAAnCD;AAAAA,IACrBqB,OAAO;AAAA,IACPC,YAAY,CAAC,GAAG;AAAA,IAChBC,oBAAoB;AAAA,EAAA,GACnB;AAAA,IACDC,KAAKf;AAAAA,IACLgB,UAAUA,CAACC,GAAIC,GAASC,MAAU;AAChC,YAAMC,IAAcC,EAAaH,EAAQZ,aAAa;AACtDnB,MAAAA,GAAOmC,WAAW;AAAA,QAChB,GAAGH;AAAAA,QACHI,QAAQ;AAAA,UACN,GAAGJ,G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replaceAll(",", "."), t = Number(s);
|
|
6
|
+
return isNaN(t) ? 0 : t;
|
|
7
|
+
}
|
|
8
|
+
const e = Number(r);
|
|
9
|
+
return isNaN(e) ? 0 : e;
|
|
10
|
+
}, c = (r) => r.replace(/[._\-/()\s+]/g, "");
|
|
5
11
|
export {
|
|
6
|
-
|
|
12
|
+
c as formatOnlyNumbers,
|
|
7
13
|
n as numberToEnUS
|
|
8
14
|
};
|
|
9
15
|
//# sourceMappingURL=format_number.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format_number.js","sources":["../../../src/lib/inputs/number/format_number.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"format_number.js","sources":["../../../src/lib/inputs/number/format_number.tsx"],"sourcesContent":["export const numberToPtBR = (value?: string | number): string | undefined => {\n if (value !== undefined && typeof value === 'number') {\n return value.toLocaleString('pt-BR');\n }\n return value;\n};\n\nexport const numberToEnUS = (value: string) => {\n // Se o valor estiver vazio ou já for um número válido sem formatação BR\n if (!value || value.trim() === '') {\n return 0;\n }\n // Verifica se contém vírgula(indicador de formato BR)\n // Formatos BR: \"12,89\", \"1.234,56\", \"1234,56\"\n if (value.includes(',')) {\n // Remove separadores de milhar(.) e substitui vírgula decimal por ponto\n const formattedNumber = value.replaceAll('.', '').replaceAll(',', '.');\n const parsed = Number(formattedNumber);\n return isNaN(parsed) ? 0 : parsed;\n }\n // Tenta converter diretamente(formato já é en-US ou Number)\n const parsed = Number(value);\n return isNaN(parsed) ? 0 : parsed;\n};\n\nexport const formatOnlyNumbers = (value: string): string => {\n const teste = value.replace(/[._\\-/()\\s+]/g, '');\n return teste;\n};\n"],"names":["numberToEnUS","value","trim","includes","formattedNumber","replaceAll","parsed","Number","isNaN","formatOnlyNumbers","replace"],"mappings":"AAOO,MAAMA,IAAeA,CAACC,MAAkB;AAE7C,MAAI,CAACA,KAASA,EAAMC,KAAAA,MAAW;AAC7B,WAAO;AAIT,MAAID,EAAME,SAAS,GAAG,GAAG;AAEvB,UAAMC,IAAkBH,EAAMI,WAAW,KAAK,EAAE,EAAEA,WAAW,KAAK,GAAG,GAC/DC,IAASC,OAAOH,CAAe;AACrC,WAAOI,MAAMF,CAAM,IAAI,IAAIA;AAAAA,EAC7B;AAEA,QAAMA,IAASC,OAAON,CAAK;AAC3B,SAAOO,MAAMF,CAAM,IAAI,IAAIA;AAC7B,GAEaG,IAAoBA,CAACR,MAClBA,EAAMS,QAAQ,iBAAiB,EAAE;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { default as CurrencyField } from './Currency';
|
|
2
1
|
import { default as DecimalField } from './Decimal';
|
|
2
|
+
import { default as CurrencyField } from './Currency';
|
|
3
3
|
import { INumberFieldProps } from './types';
|
|
4
4
|
declare const NumberField: (props: INumberFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export default NumberField;
|
|
@@ -1,36 +1,80 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { c as I } from "../../_virtual/compiler-runtime.js";
|
|
3
|
-
import { useState as y, useEffect as D } from "react";
|
|
4
|
-
import { default as $ } from "./Currency.js";
|
|
5
|
-
import { default as q } from "./Decimal.js";
|
|
1
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
6
2
|
import '../../assets/styles/numbers.css';/* empty css */
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
3
|
+
import { useRef as N, useEffect as V } from "react";
|
|
4
|
+
import a from "../../_virtual/lodash.js";
|
|
5
|
+
import "../../node_modules/imask/esm/index.js";
|
|
6
|
+
import "../../node_modules/imask/esm/controls/input.js";
|
|
7
|
+
import "../../node_modules/imask/esm/masked/factory.js";
|
|
8
|
+
import "../../node_modules/imask/esm/controls/mask-element.js";
|
|
9
|
+
import "../../node_modules/imask/esm/controls/html-input-mask-element.js";
|
|
10
|
+
import "../../node_modules/imask/esm/controls/html-mask-element.js";
|
|
11
|
+
import "../../node_modules/imask/esm/controls/html-contenteditable-mask-element.js";
|
|
12
|
+
import "../../node_modules/imask/esm/controls/input-history.js";
|
|
13
|
+
import "../../node_modules/react-imask/esm/input.js";
|
|
14
|
+
import h from "../../node_modules/react-imask/esm/hook.js";
|
|
15
|
+
import "../../node_modules/react-imask/esm/mixin.js";
|
|
16
|
+
import { default as G } from "./Decimal.js";
|
|
17
|
+
import { default as J } from "./Currency.js";
|
|
18
|
+
import k from "../base/InputTextBase.js";
|
|
19
|
+
import { mergeRefs as b } from "../../form2/helpers.js";
|
|
20
|
+
const U = (e) => {
|
|
21
|
+
const {
|
|
22
|
+
textAlign: n = "left",
|
|
23
|
+
themePopover: f = "light",
|
|
24
|
+
popoverAlign: s = "left",
|
|
25
|
+
min: o = void 0,
|
|
26
|
+
max: d = void 0,
|
|
27
|
+
inputRef: c = void 0
|
|
28
|
+
} = e, i = N(null), {
|
|
29
|
+
value: v,
|
|
30
|
+
setValue: m,
|
|
31
|
+
unmaskedValue: l
|
|
32
|
+
} = h({
|
|
33
|
+
mask: Number,
|
|
34
|
+
max: d,
|
|
35
|
+
min: o,
|
|
36
|
+
scale: 0,
|
|
37
|
+
enum: void 0,
|
|
38
|
+
to: void 0,
|
|
39
|
+
from: void 0,
|
|
40
|
+
normalizeZeros: !0,
|
|
41
|
+
padFractionalZeros: !1
|
|
42
|
+
}, {
|
|
43
|
+
ref: i,
|
|
44
|
+
onAccept: (t, r, u) => {
|
|
45
|
+
const p = parseInt(t, 10);
|
|
46
|
+
e?.onChange?.({
|
|
47
|
+
...u,
|
|
48
|
+
target: {
|
|
49
|
+
...u?.target,
|
|
50
|
+
name: e?.name,
|
|
51
|
+
value: p
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}), g = (t) => {
|
|
56
|
+
if (!a.isNil(o)) {
|
|
57
|
+
const r = parseInt(l, 10);
|
|
58
|
+
(a.isNaN(r) || r < o) && (m(a.toString(o)), e?.onChange?.({
|
|
59
|
+
...t,
|
|
60
|
+
target: {
|
|
61
|
+
...t?.target,
|
|
62
|
+
name: e?.name,
|
|
63
|
+
value: o
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
e?.onBlur?.(t);
|
|
68
|
+
};
|
|
69
|
+
return V(() => {
|
|
70
|
+
const t = Number(l || "0");
|
|
71
|
+
!a.isNil(e?.value) && (!a.isEqual(e?.value, t) || a.isEqual(e?.value, 0)) && m(a.toString(e?.value));
|
|
72
|
+
}, [e?.value]), /* @__PURE__ */ x(k, { ...e, inputRef: b(i, c), type: "number", onChange: () => {
|
|
73
|
+
}, onBlur: g, value: v, textAlign: n, themePopover: f, popoverAlign: s });
|
|
30
74
|
};
|
|
31
75
|
export {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
76
|
+
J as CurrencyField,
|
|
77
|
+
G as DecimalField,
|
|
78
|
+
U as default
|
|
35
79
|
};
|
|
36
80
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/lib/inputs/number/index.tsx"],"sourcesContent":["import { useEffect,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/lib/inputs/number/index.tsx"],"sourcesContent":["import '../../assets/styles/numbers.scss';\n\nimport React, { useEffect, useRef } from 'react';\nimport _ from 'lodash';\nimport { useIMask } from 'react-imask';\nimport DecimalField from './Decimal';\nimport CurrencyField from './Currency';\nimport { INumberFieldProps } from './types';\nimport InputTextBase from '../base/InputTextBase';\nimport { CustomInputEvent } from '../base/types';\nimport { mergeRefs } from '../../form2/helpers';\n\nconst NumberField = (props: INumberFieldProps) => {\n const {\n textAlign = 'left', themePopover = 'light', popoverAlign = 'left', min = undefined, \n max = undefined, inputRef = undefined,\n } = props;\n const numberInputRef = useRef<HTMLInputElement | null>(null);\n\n const { value: maskedValue, setValue: setMaskedValue, unmaskedValue } = useIMask({\n mask: Number,\n max,\n min,\n scale: 0,\n enum: undefined,\n to: undefined,\n from: undefined,\n normalizeZeros: true,\n padFractionalZeros: false,\n }, {\n ref: numberInputRef,\n onAccept: (value, __, event) => {\n const parsedValue = parseInt(value, 10);\n props?.onChange?.({\n ...event,\n target: {\n ...event?.target,\n name: props?.name,\n value: parsedValue as any,\n },\n } as CustomInputEvent);\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 = (event: CustomInputEvent) => {\n if (!_.isNil(min)) {\n const currentValue = parseInt(unmaskedValue, 10) as number;\n if (_.isNaN(currentValue) || currentValue < min) {\n setMaskedValue(_.toString(min));\n props?.onChange?.({\n ...event,\n target: {\n ...event?.target,\n name: props?.name,\n value: min as any,\n },\n } as CustomInputEvent);\n }\n }\n props?.onBlur?.(event);\n };\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 <InputTextBase\n {...props}\n inputRef={mergeRefs(numberInputRef, inputRef) as any}\n type=\"number\"\n onChange={() => {}}\n onBlur={handleBlur}\n value={maskedValue}\n textAlign={textAlign}\n themePopover={themePopover}\n popoverAlign={popoverAlign} />\n );\n};\n\nexport default NumberField;\nexport {\n CurrencyField,\n DecimalField,\n};\n"],"names":["NumberField","props","textAlign","themePopover","popoverAlign","min","undefined","max","inputRef","numberInputRef","useRef","value","maskedValue","setValue","setMaskedValue","unmaskedValue","useIMask","mask","Number","scale","enum","to","from","normalizeZeros","padFractionalZeros","ref","onAccept","__","event","parsedValue","parseInt","onChange","target","name","handleBlur","_","isNil","currentValue","isNaN","toString","onBlur","useEffect","floatUnmaskedValue","isEqual","jsx","InputTextBase","mergeRefs"],"mappings":";;;;;;;;;;;;;;;;;;;AAYA,MAAMA,IAAcA,CAACC,MAA6B;AAChD,QAAM;AAAA,IACJC,WAAAA,IAAY;AAAA,IAAQC,cAAAA,IAAe;AAAA,IAASC,cAAAA,IAAe;AAAA,IAAQC,KAAAA,IAAMC;AAAAA,IACzEC,KAAAA,IAAMD;AAAAA,IAAWE,UAAAA,IAAWF;AAAAA,EAAAA,IAC1BL,GACEQ,IAAiBC,EAAgC,IAAI,GAErD;AAAA,IAAEC,OAAOC;AAAAA,IAAaC,UAAUC;AAAAA,IAAgBC,eAAAA;AAAAA,EAAAA,IAAkBC,EAAS;AAAA,IAC/EC,MAAMC;AAAAA,IACNX,KAAAA;AAAAA,IACAF,KAAAA;AAAAA,IACAc,OAAO;AAAA,IACPC,MAAMd;AAAAA,IACNe,IAAIf;AAAAA,IACJgB,MAAMhB;AAAAA,IACNiB,gBAAgB;AAAA,IAChBC,oBAAoB;AAAA,EAAA,GACnB;AAAA,IACDC,KAAKhB;AAAAA,IACLiB,UAAUA,CAACf,GAAOgB,GAAIC,MAAU;AAC9B,YAAMC,IAAcC,SAASnB,GAAO,EAAE;AACtCV,MAAAA,GAAO8B,WAAW;AAAA,QAChB,GAAGH;AAAAA,QACHI,QAAQ;AAAA,UACN,GAAGJ,GAAOI;AAAAA,UACVC,MAAMhC,GAAOgC;AAAAA,UACbtB,OAAOkB;AAAAA,QAAAA;AAAAA,MACT,CACmB;AAAA,IACvB;AAAA,EAAA,CACD,GAMKK,IAAaA,CAACN,MAA4B;AAC9C,QAAI,CAACO,EAAEC,MAAM/B,CAAG,GAAG;AACjB,YAAMgC,IAAeP,SAASf,GAAe,EAAE;AAC/C,OAAIoB,EAAEG,MAAMD,CAAY,KAAKA,IAAehC,OAC1CS,EAAeqB,EAAEI,SAASlC,CAAG,CAAC,GAC9BJ,GAAO8B,WAAW;AAAA,QAChB,GAAGH;AAAAA,QACHI,QAAQ;AAAA,UACN,GAAGJ,GAAOI;AAAAA,UACVC,MAAMhC,GAAOgC;AAAAA,UACbtB,OAAON;AAAAA,QAAAA;AAAAA,MACT,CACmB;AAAA,IAEzB;AACAJ,IAAAA,GAAOuC,SAASZ,CAAK;AAAA,EACvB;AAEAa,SAAAA,EAAU,MAAM;AACd,UAAMC,IAAqBxB,OAAOH,KAAiB,GAAG;AACtD,IAAI,CAACoB,EAAEC,MAAMnC,GAAOU,KAAK,MAAM,CAACwB,EAAEQ,QAAQ1C,GAAOU,OAC/C+B,CAAkB,KAAKP,EAAEQ,QAAQ1C,GAAOU,OAAO,CAAC,MAChDG,EAAeqB,EAAEI,SAAStC,GAAOU,KAAK,CAAC;AAAA,EAE3C,GAAG,CAACV,GAAOU,KAAK,CAAC,GAGf,gBAAAiC,EAACC,GAAA,EACC,GAAI5C,GACJ,UAAU6C,EAAUrC,GAAgBD,CAAQ,GAC5C,MAAK,UACL,UAAU,MAAM;AAAA,EAAC,GACjB,QAAQ0B,GACR,OAAOtB,GACP,WAAAV,GACA,cAAAC,GACA,cAAAC,GAA2B;AAEjC;"}
|
|
@@ -21,8 +21,17 @@ export interface IBaseNumberProps extends IMaskHOCProps {
|
|
|
21
21
|
export interface ICurrencyProps extends IMaskHOCProps {
|
|
22
22
|
currencySymbol?: string;
|
|
23
23
|
displayCurrencySymbol?: boolean;
|
|
24
|
+
allowNegative?: boolean;
|
|
24
25
|
hint?: string;
|
|
25
26
|
hintPosition?: 'below' | 'onLabelRight';
|
|
26
27
|
themePopover?: 'light' | 'dark';
|
|
27
28
|
popoverAlign?: 'right' | 'left';
|
|
28
29
|
}
|
|
30
|
+
export interface IDecimalProps extends IMaskHOCProps {
|
|
31
|
+
allowNegative?: boolean;
|
|
32
|
+
hint?: string;
|
|
33
|
+
textAlign?: TextAlign;
|
|
34
|
+
hintPosition?: 'below' | 'onLabelRight';
|
|
35
|
+
themePopover?: 'light' | 'dark';
|
|
36
|
+
popoverAlign?: 'right' | 'left';
|
|
37
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "../../_virtual/compiler-runtime.js";
|
|
3
|
-
import {
|
|
3
|
+
import { CalcDatesByPeriod as m, getDropdownItemCssClass as p } from "./helper.js";
|
|
4
4
|
const u = [{
|
|
5
5
|
id: "today",
|
|
6
6
|
label: "Hoje"
|
|
@@ -30,8 +30,8 @@ const u = [{
|
|
|
30
30
|
let t;
|
|
31
31
|
e[0] !== s || e[1] !== o ? (t = u.map((l) => {
|
|
32
32
|
const n = o === l.id;
|
|
33
|
-
return /* @__PURE__ */ i("button", { tabIndex: -1, className:
|
|
34
|
-
const r = l.id !== "custom" ?
|
|
33
|
+
return /* @__PURE__ */ i("button", { tabIndex: -1, className: p(n), onClick: () => {
|
|
34
|
+
const r = l.id !== "custom" ? m(l.id) : null;
|
|
35
35
|
s(l.id, r);
|
|
36
36
|
}, children: l.label }, "item-".concat(l.id));
|
|
37
37
|
}), e[0] = s, e[1] = o, e[2] = t) : t = e[2];
|
|
@@ -6,7 +6,7 @@ import fe from "../../_virtual/lodash.js";
|
|
|
6
6
|
import be from "../../hint/index.js";
|
|
7
7
|
import ve from "../../icons/index.js";
|
|
8
8
|
import pe from "../../popover/index.js";
|
|
9
|
-
import ke from "../../tooltip/index.js";
|
|
9
|
+
import { Tooltip as ke } from "../../tooltip/index.js";
|
|
10
10
|
import Ce from "../../popover/PopoverText.js";
|
|
11
11
|
const ge = G.forwardRef((t, N) => {
|
|
12
12
|
const e = ue.c(97);
|
|
@@ -15,7 +15,7 @@ import "../../../node_modules/react-imask/esm/mixin.js";
|
|
|
15
15
|
import { createPortal as ye } from "react-dom";
|
|
16
16
|
import o from "../../../node_modules/moment/dist/moment.js";
|
|
17
17
|
import Oe from "../../../hint/index.js";
|
|
18
|
-
import Se from "../../../tooltip/index.js";
|
|
18
|
+
import { Tooltip as Se } from "../../../tooltip/index.js";
|
|
19
19
|
import { mergeRefs as pe } from "../../../form2/helpers.js";
|
|
20
20
|
import { Keys as l } from "../types.js";
|
|
21
21
|
import { Root as Re, Label as Be, Container as we, Input as Ie } from "../base/index.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Moment } from 'moment';
|
|
2
|
-
import { RefObject } from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, RefObject } from 'react';
|
|
3
3
|
import { TextAlign } from '../../../@types/Align';
|
|
4
4
|
import { ColorTheme } from '../../../@types/ColorStyles';
|
|
5
5
|
import { ITooltipCommonProps } from '../../../tooltip/types';
|
|
6
6
|
import { Position, HintPosition } from '../../../@types/Position';
|
|
7
7
|
import { OnDenied, PermissionAttr } from '../../../@types/PermissionAttr';
|
|
8
8
|
import { DateValueReturnType } from '../types';
|
|
9
|
-
type InputHTMLProps = Omit<
|
|
9
|
+
type InputHTMLProps = Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'multiple'>;
|
|
10
10
|
export interface DateFieldInputBaseProps extends InputHTMLProps, ITooltipCommonProps {
|
|
11
11
|
hint?: string;
|
|
12
12
|
label?: string;
|
|
@@ -17,7 +17,7 @@ import { createPortal as ma } from "react-dom";
|
|
|
17
17
|
import o from "../../../node_modules/moment/dist/moment.js";
|
|
18
18
|
import ha from "../../../hint/index.js";
|
|
19
19
|
import ba from "../../../icons/index.js";
|
|
20
|
-
import ya from "../../../tooltip/index.js";
|
|
20
|
+
import { Tooltip as ya } from "../../../tooltip/index.js";
|
|
21
21
|
import { mergeRefs as ea } from "../../../form2/helpers.js";
|
|
22
22
|
import { Keys as V } from "../types.js";
|
|
23
23
|
import * as ga from "../base/index.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Moment } from 'moment';
|
|
2
|
-
import { RefObject } from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef, RefObject } from 'react';
|
|
3
3
|
import { TextAlign } from '../../../@types/Align';
|
|
4
4
|
import { ColorTheme } from '../../../@types/ColorStyles';
|
|
5
5
|
import { ITooltipCommonProps } from '../../../tooltip/types';
|
|
@@ -21,7 +21,7 @@ export type UpdateDateStateParams = {
|
|
|
21
21
|
inputType: InputType;
|
|
22
22
|
typing?: boolean;
|
|
23
23
|
};
|
|
24
|
-
type InputHTMLProps = Omit<
|
|
24
|
+
type InputHTMLProps = Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'multiple' | 'value'>;
|
|
25
25
|
export interface DatePeriodFieldBaseProps extends InputHTMLProps, ITooltipCommonProps {
|
|
26
26
|
value?: any;
|
|
27
27
|
initialName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/lib/inputs2/filefield/index.tsx"],"sourcesContent":["import '../../assets/styles/filefield.scss';\n\nimport _ from 'lodash';\nimport { ChangeEvent, ClipboardEvent, FormEvent, forwardRef, Fragment, InputEventHandler, useRef, useState } from 'react';\nimport Button from '../../buttons';\nimport * as TextField from '../textfield';\nimport List, { ListItem } from '../../list';\n\ninterface FileFieldInputProps extends Omit<TextField.TextFieldInputProps, 'type'> {\n multiple?: boolean;\n accept?: string;\n maxSize?: number;\n gridLayout?: string;\n showClearButton?: boolean;\n}\n\nconst Input = forwardRef<HTMLInputElement, FileFieldInputProps>((props, ref) => {\n const { ...rest } = props;\n\n const inputFileRef = useRef<HTMLInputElement>(null);\n const [internalFiles, setInternalFiles] = useState<File[]>([]);\n\n const files = props?.value ?? internalFiles;\n const inputLabel = _.isArray(files) && files.length > 0 ? \n `${files.length} arquivo(s) selecionado(s)`\n : 'Nenhum arquivo selecionado';\n\n const handleSelect = (event: ChangeEvent<HTMLInputElement>) => {\n const fileList = event.target.files;\n if (!fileList) return;\n\n let selectedFiles = Array.from(fileList);\n\n if (props?.maxSize) {\n selectedFiles = selectedFiles.filter(file => \n file.size <= _.toNumber(props.maxSize));\n }\n\n if (!props?.multiple && selectedFiles.length > 1) {\n selectedFiles = [selectedFiles[0]];\n }\n\n if (_.isNil(props?.value)) {\n setInternalFiles(selectedFiles);\n }\n props.onChange?.({\n target: {\n name: props.name,\n value: selectedFiles as any,\n },\n } as ChangeEvent<HTMLInputElement>);\n inputFileRef.current!.value = '';\n };\n\n const handleClear = () => {\n if (_.isNil(props?.value)) {\n setInternalFiles([]);\n }\n props.onChange?.({\n target: {\n name: props.name,\n value: '',\n },\n } as ChangeEvent<HTMLInputElement>);\n inputFileRef.current!.value = '';\n };\n\n const openDialog = () => {\n inputFileRef.current?.click();\n };\n\n const handleLockOnPaste = (event: ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault();\n };\n\n const handleLockOnBeforeInput: InputEventHandler<HTMLInputElement> = (event) => {\n props.onBeforeInput?.(event);\n };\n\n return (\n <Fragment>\n <TextField.Input\n {...rest}\n ref={ref}\n type=\"text\"\n readOnly={false}\n value={inputLabel}\n customClass=\"file-input\"\n onPaste={handleLockOnPaste}\n onBeforeInput={handleLockOnBeforeInput}\n customClassInputContainer=\"file-container\">\n <TextField.LeftSlot>\n <input\n ref={inputFileRef}\n type=\"file\"\n name={props?.name}\n accept={props?.accept}\n multiple={props?.multiple}\n onChange={handleSelect}\n style={{ all: 'unset', display: 'none' }} />\n </TextField.LeftSlot>\n <TextField.RightSlot className=\"file-right-slot\">\n <Button\n className=\"show-files-selected-list\"\n visible\n dropdown\n transparent\n boxShadow={false}\n showIconDropdown={false}\n type=\"button\"\n title=\"Arquivos Selecionados\"\n tabIndex={-1}\n disabled={props?.disabled}\n aria-label=\"Arquivos Selecionados\"\n aria-readonly={props?.readOnly}\n data-state-read-only={props?.readOnly}\n iconName=\"information\"\n dropdownAlign=\"right\"\n onMouseDown={(event) => { event.preventDefault(); }}>\n {!_.isArray(files) && (\n <List condensed>\n <ListItem\n key=\"nenhum-selecionado\"\n itemId=\"nenhum-selecionado\"\n text=\"Nenhum arquivo selecionado\"\n onMouseDown={(event) => { event?.preventDefault?.(); }} />\n </List>\n )}\n {_.isArray(files) && _.size(files) > 0 && (\n <List condensed>\n {files.map((file: File, index) => {\n const id = `${file.name}-${index + 1}`;\n return (\n <ListItem\n key={id}\n itemId={id}\n text={file.name}\n onMouseDown={(event) => { event?.preventDefault?.(); }} />\n );\n })}\n </List>\n )}\n </Button>\n <Button\n data-testid=\"test-file-field-trigger-clear-files-selected\"\n className=\"clear-files-selected\"\n visible\n transparent\n boxShadow={false}\n showIconDropdown={false}\n type=\"button\"\n title=\"Limpar\"\n tabIndex={-1}\n disabled={props?.disabled}\n aria-label=\"Limpar\"\n aria-readonly={props?.readOnly}\n data-state-read-only={props?.readOnly}\n iconName=\"close\"\n onClick={handleClear}\n onMouseDown={(event) => { event.preventDefault(); }} />\n <Button\n data-testid=\"test-file-field-trigger-select-files\"\n className=\"select-files\"\n visible\n boxShadow={false}\n showIconDropdown={false}\n type=\"button\"\n title=\"Selecionar\"\n label=\"Selecionar\"\n tabIndex={-1}\n disabled={props?.disabled}\n aria-label=\"Selecionar\"\n aria-readonly={props?.readOnly}\n data-state-read-only={props?.readOnly}\n iconName=\"upload4\"\n onClick={openDialog}\n onMouseDown={(event) => { event.preventDefault(); }} />\n </TextField.RightSlot>\n </TextField.Input>\n </Fragment>\n );\n});\n\nInput.displayName = 'FileFieldInput';\n\nexport { Input };\nexport type { FileFieldInputProps };\n"],"names":["Input","forwardRef","props","ref","$","_c","rest","inputFileRef","useRef","t0","Symbol","for","internalFiles","setInternalFiles","useState","files","value","t1","_","isArray","length","inputLabel","t2","event","fileList","target","selectedFiles","Array","from","maxSize","filter","file","size","toNumber","multiple","isNil","onChange","name","current","handleSelect","t3","handleClear","t4","click","openDialog","handleLockOnPaste","_temp","t5","event_1","onBeforeInput","handleLockOnBeforeInput","t6","t7","accept","t8","t9","all","display","t10","t11","disabled","t12","readOnly","t13","t14","jsx","List","ListItem","_temp3","t15","map","_temp5","t16","Button","_temp2","t17","t18","t19","t20","_temp6","t21","t22","t23","t24","_temp7","t25","jsxs","TextField.RightSlot","t26","Fragment","TextField.Input","displayName","event_0","preventDefault","event_2","event_3","_temp4","event_4","file_0","index","id","event_5","event_6"],"mappings":";;;;;;;;;;;AAgBA,MAAMA,KAAQC,EAAkD,CAAAC,GAAAC,MAAA;AAAA,QAAAC,IAAAC,EAAAA,EAAA,EAAA;AAAA,MAAAC;AAAA,EAAAF,SAAAF,KAC9D;AAAA,IAAA,GAAAI;AAAAA,EAAAA,IAAoBJ,GAAME,OAAAF,GAAAE,OAAAE,KAAAA,IAAAF,EAAA,CAAA;AAE1B,QAAAG,IAAqBC,EAAyB,IAAI;AAAE,MAAAC;AAAA,EAAAL,EAAA,CAAA,MAAAM,OAAAC,IAAA,2BAAA,KACOF,IAAA,CAAA,GAAEL,OAAAK,KAAAA,IAAAL,EAAA,CAAA;AAA7D,QAAA,CAAAQ,GAAAC,CAAA,IAA0CC,GAAiBL,CAAE,GAE7DM,IAAcb,GAAKc,SAALJ;AAA8B,MAAAK;AAAA,EAAAb,SAAAW,KACzBE,IAAAC,EAACC,QAASJ,CAAyB,KAAfA,EAAKK,SAAU,IAAnC,GACdL,EAAKK,MAAO,+BADE,8BAEahB,OAAAW,GAAAX,OAAAa,KAAAA,IAAAb,EAAA,CAAA;AAFhC,QAAAiB,IAAmBJ;AAEc,MAAAK;AAAA,EAAAlB,SAAAF,KAEZoB,IAAAC,CAAAA,MAAA;AACnB,UAAAC,IAAiBD,EAAKE,OAAOV;AAC7B,QAAI,CAACS;AAAQ;AAEb,QAAAE,IAAoBC,MAAKC,KAAMJ,CAAQ;AAEvC,IAAItB,GAAK2B,YACPH,IAAgBA,EAAaI,OAAQC,CAAAA,MACnCA,EAAIC,QAASd,EAACe,SAAU/B,EAAK2B,OAAQ,CAAC,IAGtC,CAAC3B,GAAKgC,YAAcR,EAAaN,SAAU,MAC7CM,IAAgBA,CAACA,IAAgB,IAG/BR,EAACiB,MAAOjC,GAAKc,KAAO,KACtBH,EAAiBa,CAAa,GAEhCxB,EAAKkC,WAAY;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GAAAC,GAAA;AAyHhB1E,EAAAA,GAAKsE,iBAAAA;AAAoB;AAzHT,SAAAtB,GAAA2B,GAAAC,GAAA;AAmH9C,QAAAC,IAAW,GAAGrE,EAAIM,IAAK,IAAI8D,IAAQ,CAAC;AAAG,SAErC,gBAAAlC,EAACE,KAESiC,QAAAA,GACF,MAAArE,EAAIM,MACG,aAAA2D,GAAAA,GAHRI,CAGiD;AAAI;AAzHhB,SAAArB,GAAAsB,GAAA;AA+I1B9E,EAAAA,EAAKsE,eAAAA;AAAiB;AA/II,SAAAT,GAAAkB,GAAA;AAgK1B/E,EAAAA,EAAKsE,eAAAA;AAAiB;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/lib/inputs2/filefield/index.tsx"],"sourcesContent":["import '../../assets/styles/filefield.scss';\n\nimport _ from 'lodash';\nimport { ChangeEvent, ClipboardEvent, forwardRef, Fragment, InputEventHandler, useRef, useState } from 'react';\nimport Button from '../../buttons';\nimport * as TextField from '../textfield';\nimport List, { ListItem } from '../../list';\n\ninterface FileFieldInputProps extends Omit<TextField.TextFieldInputProps, 'type'> {\n multiple?: boolean;\n accept?: string;\n maxSize?: number;\n gridLayout?: string;\n showClearButton?: boolean;\n}\n\nconst Input = forwardRef<HTMLInputElement, FileFieldInputProps>((props, ref) => {\n const { ...rest } = props;\n\n const inputFileRef = useRef<HTMLInputElement>(null);\n const [internalFiles, setInternalFiles] = useState<File[]>([]);\n\n const files = props?.value ?? internalFiles;\n const inputLabel = _.isArray(files) && files.length > 0 ? \n `${files.length} arquivo(s) selecionado(s)`\n : 'Nenhum arquivo selecionado';\n\n const handleSelect = (event: ChangeEvent<HTMLInputElement>) => {\n const fileList = event.target.files;\n if (!fileList) return;\n\n let selectedFiles = Array.from(fileList);\n\n if (props?.maxSize) {\n selectedFiles = selectedFiles.filter(file => \n file.size <= _.toNumber(props.maxSize));\n }\n\n if (!props?.multiple && selectedFiles.length > 1) {\n selectedFiles = [selectedFiles[0]];\n }\n\n if (_.isNil(props?.value)) {\n setInternalFiles(selectedFiles);\n }\n props.onChange?.({\n target: {\n name: props.name,\n value: selectedFiles as any,\n },\n } as ChangeEvent<HTMLInputElement>);\n inputFileRef.current!.value = '';\n };\n\n const handleClear = () => {\n if (_.isNil(props?.value)) {\n setInternalFiles([]);\n }\n props.onChange?.({\n target: {\n name: props.name,\n value: '',\n },\n } as ChangeEvent<HTMLInputElement>);\n inputFileRef.current!.value = '';\n };\n\n const openDialog = () => {\n inputFileRef.current?.click();\n };\n\n const handleLockOnPaste = (event: ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault();\n };\n\n const handleLockOnBeforeInput: InputEventHandler<HTMLInputElement> = (event) => {\n props.onBeforeInput?.(event);\n };\n\n return (\n <Fragment>\n <TextField.Input\n {...rest}\n ref={ref}\n type=\"text\"\n readOnly={false}\n value={inputLabel}\n customClass=\"file-input\"\n onPaste={handleLockOnPaste}\n onBeforeInput={handleLockOnBeforeInput}\n customClassInputContainer=\"file-container\">\n <TextField.LeftSlot>\n <input\n ref={inputFileRef}\n type=\"file\"\n name={props?.name}\n accept={props?.accept}\n multiple={props?.multiple}\n onChange={handleSelect}\n style={{ all: 'unset', display: 'none' }} />\n </TextField.LeftSlot>\n <TextField.RightSlot className=\"file-right-slot\">\n <Button\n className=\"show-files-selected-list\"\n visible\n dropdown\n transparent\n boxShadow={false}\n showIconDropdown={false}\n type=\"button\"\n title=\"Arquivos Selecionados\"\n tabIndex={-1}\n disabled={props?.disabled}\n aria-label=\"Arquivos Selecionados\"\n aria-readonly={props?.readOnly}\n data-state-read-only={props?.readOnly}\n iconName=\"information\"\n dropdownAlign=\"right\"\n onMouseDown={(event) => { event.preventDefault(); }}>\n {!_.isArray(files) && (\n <List condensed>\n <ListItem\n key=\"nenhum-selecionado\"\n itemId=\"nenhum-selecionado\"\n text=\"Nenhum arquivo selecionado\"\n onMouseDown={(event) => { event?.preventDefault?.(); }} />\n </List>\n )}\n {_.isArray(files) && _.size(files) > 0 && (\n <List condensed>\n {files.map((file: File, index) => {\n const id = `${file.name}-${index + 1}`;\n return (\n <ListItem\n key={id}\n itemId={id}\n text={file.name}\n onMouseDown={(event) => { event?.preventDefault?.(); }} />\n );\n })}\n </List>\n )}\n </Button>\n <Button\n data-testid=\"test-file-field-trigger-clear-files-selected\"\n className=\"clear-files-selected\"\n visible\n transparent\n boxShadow={false}\n showIconDropdown={false}\n type=\"button\"\n title=\"Limpar\"\n tabIndex={-1}\n disabled={props?.disabled}\n aria-label=\"Limpar\"\n aria-readonly={props?.readOnly}\n data-state-read-only={props?.readOnly}\n iconName=\"close\"\n onClick={handleClear}\n onMouseDown={(event) => { event.preventDefault(); }} />\n <Button\n data-testid=\"test-file-field-trigger-select-files\"\n className=\"select-files\"\n visible\n boxShadow={false}\n showIconDropdown={false}\n type=\"button\"\n title=\"Selecionar\"\n label=\"Selecionar\"\n tabIndex={-1}\n disabled={props?.disabled}\n aria-label=\"Selecionar\"\n aria-readonly={props?.readOnly}\n data-state-read-only={props?.readOnly}\n iconName=\"upload4\"\n onClick={openDialog}\n onMouseDown={(event) => { event.preventDefault(); }} />\n </TextField.RightSlot>\n </TextField.Input>\n </Fragment>\n );\n});\n\nInput.displayName = 'FileFieldInput';\n\nexport { Input };\nexport type { FileFieldInputProps };\n"],"names":["Input","forwardRef","props","ref","$","_c","rest","inputFileRef","useRef","t0","Symbol","for","internalFiles","setInternalFiles","useState","files","value","t1","_","isArray","length","inputLabel","t2","event","fileList","target","selectedFiles","Array","from","maxSize","filter","file","size","toNumber","multiple","isNil","onChange","name","current","handleSelect","t3","handleClear","t4","click","openDialog","handleLockOnPaste","_temp","t5","event_1","onBeforeInput","handleLockOnBeforeInput","t6","t7","accept","t8","t9","all","display","t10","t11","disabled","t12","readOnly","t13","t14","jsx","List","ListItem","_temp3","t15","map","_temp5","t16","Button","_temp2","t17","t18","t19","t20","_temp6","t21","t22","t23","t24","_temp7","t25","jsxs","TextField.RightSlot","t26","Fragment","TextField.Input","displayName","event_0","preventDefault","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