linear-react-components-ui 2.0.0-beta.3 → 2.0.0-beta.5
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/inputs/date/helpers.js +11 -22
- package/lib/inputs/date/helpers.js.map +1 -1
- package/lib/inputs/mask/BaseMask.js +55 -65
- package/lib/inputs/mask/BaseMask.js.map +1 -1
- package/lib/inputs/multiSelect/Dropdown.js +44 -42
- package/lib/inputs/multiSelect/Dropdown.js.map +1 -1
- package/lib/inputs/number/Currency.js +35 -45
- package/lib/inputs/number/Currency.js.map +1 -1
- package/lib/inputs/number/Decimal.js +38 -48
- package/lib/inputs/number/Decimal.js.map +1 -1
- package/lib/inputs/number/index.js +38 -48
- package/lib/inputs/number/index.js.map +1 -1
- package/lib/inputs2/date/datefield/base.js +60 -70
- package/lib/inputs2/date/datefield/base.js.map +1 -1
- package/lib/inputs2/date/dateperiodfield/base.js +79 -89
- package/lib/inputs2/date/dateperiodfield/base.js.map +1 -1
- package/lib/inputs2/mask/Cnpj.js +58 -68
- package/lib/inputs2/mask/Cnpj.js.map +1 -1
- package/lib/inputs2/mask/Cpf.js +38 -48
- package/lib/inputs2/mask/Cpf.js.map +1 -1
- package/lib/inputs2/mask/index.js +50 -60
- package/lib/inputs2/mask/index.js.map +1 -1
- package/lib/inputs2/numberfield/currency.js +51 -61
- package/lib/inputs2/numberfield/currency.js.map +1 -1
- package/lib/inputs2/numberfield/decimal.js +25 -35
- package/lib/inputs2/numberfield/decimal.js.map +1 -1
- package/lib/inputs2/numberfield/index.js +46 -56
- package/lib/inputs2/numberfield/index.js.map +1 -1
- package/package.json +9 -6
- package/lib/node_modules/imask/esm/controls/html-contenteditable-mask-element.js +0 -35
- package/lib/node_modules/imask/esm/controls/html-contenteditable-mask-element.js.map +0 -1
- package/lib/node_modules/imask/esm/controls/html-input-mask-element.js +0 -32
- package/lib/node_modules/imask/esm/controls/html-input-mask-element.js.map +0 -1
- package/lib/node_modules/imask/esm/controls/html-mask-element.js +0 -49
- package/lib/node_modules/imask/esm/controls/html-mask-element.js.map +0 -1
- package/lib/node_modules/imask/esm/controls/input-history.js +0 -31
- package/lib/node_modules/imask/esm/controls/input-history.js.map +0 -1
- package/lib/node_modules/imask/esm/controls/input.js +0 -223
- package/lib/node_modules/imask/esm/controls/input.js.map +0 -1
- package/lib/node_modules/imask/esm/controls/mask-element.js +0 -44
- package/lib/node_modules/imask/esm/controls/mask-element.js.map +0 -1
- package/lib/node_modules/imask/esm/core/action-details.js +0 -52
- package/lib/node_modules/imask/esm/core/action-details.js.map +0 -1
- package/lib/node_modules/imask/esm/core/change-details.js +0 -37
- package/lib/node_modules/imask/esm/core/change-details.js.map +0 -1
- package/lib/node_modules/imask/esm/core/continuous-tail-details.js +0 -43
- package/lib/node_modules/imask/esm/core/continuous-tail-details.js.map +0 -1
- package/lib/node_modules/imask/esm/core/holder.js +0 -7
- package/lib/node_modules/imask/esm/core/holder.js.map +0 -1
- package/lib/node_modules/imask/esm/core/utils.js +0 -68
- package/lib/node_modules/imask/esm/core/utils.js.map +0 -1
- package/lib/node_modules/imask/esm/index.js +0 -51
- package/lib/node_modules/imask/esm/index.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/base.js +0 -253
- package/lib/node_modules/imask/esm/masked/base.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/date.js +0 -118
- package/lib/node_modules/imask/esm/masked/date.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/dynamic.js +0 -223
- package/lib/node_modules/imask/esm/masked/dynamic.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/enum.js +0 -70
- package/lib/node_modules/imask/esm/masked/enum.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/factory.js +0 -47
- package/lib/node_modules/imask/esm/masked/factory.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/function.js +0 -24
- package/lib/node_modules/imask/esm/masked/function.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/number.js +0 -213
- package/lib/node_modules/imask/esm/masked/number.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/pattern/chunk-tail-details.js +0 -104
- package/lib/node_modules/imask/esm/masked/pattern/chunk-tail-details.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/pattern/cursor.js +0 -101
- package/lib/node_modules/imask/esm/masked/pattern/cursor.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/pattern/fixed-definition.js +0 -103
- package/lib/node_modules/imask/esm/masked/pattern/fixed-definition.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/pattern/input-definition.js +0 -134
- package/lib/node_modules/imask/esm/masked/pattern/input-definition.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/pattern.js +0 -323
- package/lib/node_modules/imask/esm/masked/pattern.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/pipe.js +0 -24
- package/lib/node_modules/imask/esm/masked/pipe.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/range.js +0 -79
- package/lib/node_modules/imask/esm/masked/range.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/regexp.js +0 -22
- package/lib/node_modules/imask/esm/masked/regexp.js.map +0 -1
- package/lib/node_modules/imask/esm/masked/repeat.js +0 -105
- package/lib/node_modules/imask/esm/masked/repeat.js.map +0 -1
- package/lib/node_modules/react-imask/esm/hook.js +0 -76
- package/lib/node_modules/react-imask/esm/hook.js.map +0 -1
- package/lib/node_modules/react-imask/esm/input.js +0 -24
- package/lib/node_modules/react-imask/esm/input.js.map +0 -1
- package/lib/node_modules/react-imask/esm/mixin.js +0 -132
- package/lib/node_modules/react-imask/esm/mixin.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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,gBAAAA,IAAiB;AAAA,IACrFC,oBAAAA,IAAqB;AAAA,IAAOC,QAAAA,IAAS;AAAA,IAAMC,gBAAAA,IAAiB;AAAA,IAAMC,uBAAAA,IAAwB;AAAA,EAAA,IACxFd,GACEe,IAAyBC,EAAgC,IAAI,GAC7DC,IAAeH,IACnB,gBAAAI,EAAC,QAAA,EAAK,WAAU,mBAAmBL,UAAAA,EAAAA,CAAe,IAChD,CAAA,GAEE;AAAA,IAAEM,OAAOC;AAAAA,IAAaC,UAAUC;AAAAA,IAAgBC,eAAAA;AAAAA,EAAAA,IAAkBC,EAAS;AAAA,IAC/EC,MAAMC;AAAAA,IACNd,QAAAA;AAAAA,IACAH,OAAAA;AAAAA,IACAC,gBAAAA;AAAAA,IACAC,oBAAAA;AAAAA,IACAJ,KAAAA;AAAAA,IACAD,KAAMqB,EAAEC,MAAMtB,CAAG,IAAWE,IAAgBN,SAAY,IAAnCI;AAAAA,IACrBuB,OAAO;AAAA,IACPC,YAAY,CAAC,GAAG;AAAA,IAChBC,oBAAoB;AAAA,EAAA,GACnB;AAAA,IACDC,KAAKjB;AAAAA,IACLkB,UAAUA,CAACC,GAAIC,GAASC,MAAU;AAChC,YAAMC,IAAcC,EAAaH,EAAQZ,aAAa;AACtDvB,MAAAA,GAAOuC,WAAW;AAAA,QAChB,GAAGH;AAAAA,QACHI,QAAQ;AAAA,UACN,GAAGJ,GAAOI;AAAAA,UACVC,MAAMzC,GAAOyC;AAAAA,UACbtB,OAAOkB;AAAAA,QAAAA;AAAAA,MACT,CACsC;AAAA,IAC1C;AAAA,EAAA,CACD,GAMKK,IAAaA,CAACN,MAA4B;AAC9C,QAAI,CAACT,EAAEC,MAAMtB,CAAG,GAAG;AACjB,YAAMqC,IAAeC,WAAWrB,CAAa;AAC7C,OAAII,EAAEkB,MAAMF,CAAY,KAAKA,IAAerC,OAC1CgB,EAAeK,EAAEmB,SAASxC,CAAG,CAAC,GAC9BN,GAAOuC,WAAW;AAAA,QAChB,GAAGH;AAAAA,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,82 +1,72 @@
|
|
|
1
1
|
import { jsx as R } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import t from "../../_virtual/lodash.js";
|
|
3
3
|
import { useRef as F, useEffect as S } from "react";
|
|
4
|
-
import "
|
|
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";
|
|
4
|
+
import { useIMask as B } from "react-imask";
|
|
15
5
|
import { numberToEnUS as T } from "./format_number.js";
|
|
16
6
|
import b from "../base/InputTextBase.js";
|
|
17
7
|
import { mergeRefs as A } from "../../form2/helpers.js";
|
|
18
|
-
const
|
|
8
|
+
const w = (e) => {
|
|
19
9
|
const {
|
|
20
|
-
textAlign:
|
|
10
|
+
textAlign: m = "left",
|
|
21
11
|
themePopover: s = "light",
|
|
22
12
|
popoverAlign: f = "left",
|
|
23
|
-
min:
|
|
13
|
+
min: l = void 0,
|
|
24
14
|
max: d = void 0,
|
|
25
15
|
allowNegative: c = !1,
|
|
26
|
-
scale:
|
|
27
|
-
normalizeZeros:
|
|
28
|
-
padFractionalZeros:
|
|
29
|
-
unmask:
|
|
30
|
-
inputRef:
|
|
31
|
-
} = e,
|
|
32
|
-
value:
|
|
33
|
-
setValue:
|
|
34
|
-
unmaskedValue:
|
|
16
|
+
scale: g = 2,
|
|
17
|
+
normalizeZeros: v = !0,
|
|
18
|
+
padFractionalZeros: x = !0,
|
|
19
|
+
unmask: N = !0,
|
|
20
|
+
inputRef: h = void 0
|
|
21
|
+
} = e, n = F(null), {
|
|
22
|
+
value: k,
|
|
23
|
+
setValue: r,
|
|
24
|
+
unmaskedValue: i
|
|
35
25
|
} = B({
|
|
36
26
|
mask: Number,
|
|
37
|
-
unmask:
|
|
38
|
-
scale:
|
|
39
|
-
normalizeZeros:
|
|
40
|
-
padFractionalZeros:
|
|
27
|
+
unmask: N,
|
|
28
|
+
scale: g,
|
|
29
|
+
normalizeZeros: v,
|
|
30
|
+
padFractionalZeros: x,
|
|
41
31
|
max: d,
|
|
42
|
-
min:
|
|
32
|
+
min: t.isNil(l) ? c ? void 0 : 0 : l,
|
|
43
33
|
radix: ",",
|
|
44
34
|
mapToRadix: ["."],
|
|
45
35
|
thousandsSeparator: "."
|
|
46
36
|
}, {
|
|
47
|
-
ref:
|
|
48
|
-
onAccept: (
|
|
49
|
-
const
|
|
37
|
+
ref: n,
|
|
38
|
+
onAccept: (a, o, u) => {
|
|
39
|
+
const p = T(o.unmaskedValue);
|
|
50
40
|
e?.onChange?.({
|
|
51
|
-
...
|
|
41
|
+
...u,
|
|
52
42
|
target: {
|
|
53
|
-
...
|
|
43
|
+
...u?.target,
|
|
54
44
|
name: e?.name,
|
|
55
|
-
value:
|
|
45
|
+
value: p
|
|
56
46
|
}
|
|
57
47
|
});
|
|
58
48
|
}
|
|
59
|
-
}),
|
|
60
|
-
if (!
|
|
61
|
-
const
|
|
62
|
-
(
|
|
63
|
-
...
|
|
49
|
+
}), V = (a) => {
|
|
50
|
+
if (!t.isNil(l)) {
|
|
51
|
+
const o = parseFloat(i);
|
|
52
|
+
(t.isNaN(o) || o < l) && (r(t.toString(l)), e?.onChange?.({
|
|
53
|
+
...a,
|
|
64
54
|
target: {
|
|
65
|
-
...
|
|
55
|
+
...a?.target,
|
|
66
56
|
name: e?.name,
|
|
67
|
-
value:
|
|
57
|
+
value: l
|
|
68
58
|
}
|
|
69
59
|
}));
|
|
70
60
|
}
|
|
71
|
-
e?.onBlur?.(
|
|
61
|
+
e?.onBlur?.(a);
|
|
72
62
|
};
|
|
73
63
|
return S(() => {
|
|
74
|
-
const
|
|
75
|
-
!
|
|
76
|
-
}, [e?.value]), /* @__PURE__ */ R(b, { ...e, inputRef: A(
|
|
77
|
-
}, onBlur:
|
|
64
|
+
const a = t.toString(e?.value);
|
|
65
|
+
!t.isNil(e?.value) && !t.isEqual(parseFloat(a), parseFloat(i)) && r(a);
|
|
66
|
+
}, [e?.value]), /* @__PURE__ */ R(b, { ...e, inputRef: A(n, h), type: "text", onChange: () => {
|
|
67
|
+
}, onBlur: V, value: k, textAlign: m, themePopover: s, popoverAlign: f });
|
|
78
68
|
};
|
|
79
69
|
export {
|
|
80
|
-
|
|
70
|
+
w as default
|
|
81
71
|
};
|
|
82
72
|
//# sourceMappingURL=Decimal.js.map
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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,GAAOI;AAAAA,UACVC,MAAMrC,GAAOqC;AAAAA,UACbtB,OAAOkB;AAAAA,QAAAA;AAAAA,MACT,CACsC;AAAA,IAC1C;AAAA,EAAA,CACD,GAMKK,IAAaA,CAACN,MAA4B;AAC9C,QAAI,CAACT,EAAEC,MAAMpB,CAAG,GAAG;AACjB,YAAMmC,IAAeC,WAAWrB,CAAa;AAC7C,OAAII,EAAEkB,MAAMF,CAAY,KAAKA,IAAenC,OAC1Cc,EAAeK,EAAEmB,SAAStC,CAAG,CAAC,GAC9BJ,GAAOmC,WAAW;AAAA,QAChB,GAAGH;AAAAA,QACHI,QAAQ;AAAA,UACN,GAAGJ,GAAOI;AAAAA,UACVC,MAAMrC,GAAOqC;AAAAA,UACbtB,OAAOX;AAAAA,QAAAA;AAAAA,MACT,CACmB;AAAA,IAEzB;AACAJ,IAAAA,GAAO2C,SAASX,CAAK;AAAA,EACvB;AAEAY,SAAAA,EAAU,MAAM;AACd,UAAMC,IAAgBtB,EAAEmB,SAAS1C,GAAOe,KAAK;AAC7C,IAAI,CAACQ,EAAEC,MAAMxB,GAAOe,KAAK,KAAK,CAACQ,EAAEuB,QAC/BN,WAAWK,CAAa,GAAGL,WAAWrB,CAAa,CACrD,KACED,EAAe2B,CAAa;AAAA,EAEhC,GAAG,CAAC7C,GAAOe,KAAK,CAAC,GAGf,gBAAAgC,EAACC,GAAA,EACC,GAAIhD,GACJ,UAAUiD,EAAUpC,GAAuBD,CAAQ,GACnD,MAAK,QACL,UAAU,MAAM;AAAA,EAAE,GAClB,QAAQ0B,GACR,OAAOtB,GACP,WAAAf,GACA,cAAAC,GACA,cAAAC,GAA2B;AAEjC;"}
|
|
@@ -1,38 +1,28 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as N } from "react/jsx-runtime";
|
|
2
2
|
import '../../assets/styles/numbers.css';/* empty css */
|
|
3
|
-
import { useRef as
|
|
4
|
-
import
|
|
5
|
-
import "
|
|
6
|
-
import "
|
|
7
|
-
import "
|
|
8
|
-
import "
|
|
9
|
-
import "../../
|
|
10
|
-
|
|
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) => {
|
|
3
|
+
import { useRef as V, useEffect as h } from "react";
|
|
4
|
+
import t from "../../_virtual/lodash.js";
|
|
5
|
+
import { useIMask as k } from "react-imask";
|
|
6
|
+
import { default as Z } from "./Decimal.js";
|
|
7
|
+
import { default as p } from "./Currency.js";
|
|
8
|
+
import b from "../base/InputTextBase.js";
|
|
9
|
+
import { mergeRefs as I } from "../../form2/helpers.js";
|
|
10
|
+
const y = (e) => {
|
|
21
11
|
const {
|
|
22
|
-
textAlign:
|
|
12
|
+
textAlign: m = "left",
|
|
23
13
|
themePopover: f = "light",
|
|
24
14
|
popoverAlign: s = "left",
|
|
25
|
-
min:
|
|
15
|
+
min: l = void 0,
|
|
26
16
|
max: d = void 0,
|
|
27
17
|
inputRef: c = void 0
|
|
28
|
-
} = e,
|
|
18
|
+
} = e, n = V(null), {
|
|
29
19
|
value: v,
|
|
30
|
-
setValue:
|
|
31
|
-
unmaskedValue:
|
|
32
|
-
} =
|
|
20
|
+
setValue: o,
|
|
21
|
+
unmaskedValue: r
|
|
22
|
+
} = k({
|
|
33
23
|
mask: Number,
|
|
34
24
|
max: d,
|
|
35
|
-
min:
|
|
25
|
+
min: l,
|
|
36
26
|
scale: 0,
|
|
37
27
|
enum: void 0,
|
|
38
28
|
to: void 0,
|
|
@@ -40,41 +30,41 @@ const U = (e) => {
|
|
|
40
30
|
normalizeZeros: !0,
|
|
41
31
|
padFractionalZeros: !1
|
|
42
32
|
}, {
|
|
43
|
-
ref:
|
|
44
|
-
onAccept: (
|
|
45
|
-
const
|
|
33
|
+
ref: n,
|
|
34
|
+
onAccept: (a, u, i) => {
|
|
35
|
+
const x = parseInt(a, 10);
|
|
46
36
|
e?.onChange?.({
|
|
47
|
-
...
|
|
37
|
+
...i,
|
|
48
38
|
target: {
|
|
49
|
-
...
|
|
39
|
+
...i?.target,
|
|
50
40
|
name: e?.name,
|
|
51
|
-
value:
|
|
41
|
+
value: x
|
|
52
42
|
}
|
|
53
43
|
});
|
|
54
44
|
}
|
|
55
|
-
}), g = (
|
|
56
|
-
if (!
|
|
57
|
-
const
|
|
58
|
-
(
|
|
59
|
-
...
|
|
45
|
+
}), g = (a) => {
|
|
46
|
+
if (!t.isNil(l)) {
|
|
47
|
+
const u = parseInt(r, 10);
|
|
48
|
+
(t.isNaN(u) || u < l) && (o(t.toString(l)), e?.onChange?.({
|
|
49
|
+
...a,
|
|
60
50
|
target: {
|
|
61
|
-
...
|
|
51
|
+
...a?.target,
|
|
62
52
|
name: e?.name,
|
|
63
|
-
value:
|
|
53
|
+
value: l
|
|
64
54
|
}
|
|
65
55
|
}));
|
|
66
56
|
}
|
|
67
|
-
e?.onBlur?.(
|
|
57
|
+
e?.onBlur?.(a);
|
|
68
58
|
};
|
|
69
|
-
return
|
|
70
|
-
const
|
|
71
|
-
!
|
|
72
|
-
}, [e?.value]), /* @__PURE__ */
|
|
73
|
-
}, onBlur: g, value: v, textAlign:
|
|
59
|
+
return h(() => {
|
|
60
|
+
const a = Number(r || "0");
|
|
61
|
+
!t.isNil(e?.value) && (!t.isEqual(e?.value, a) || t.isEqual(e?.value, 0)) && o(t.toString(e?.value));
|
|
62
|
+
}, [e?.value]), /* @__PURE__ */ N(b, { ...e, inputRef: I(n, c), type: "number", onChange: () => {
|
|
63
|
+
}, onBlur: g, value: v, textAlign: m, themePopover: f, popoverAlign: s });
|
|
74
64
|
};
|
|
75
65
|
export {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
p as CurrencyField,
|
|
67
|
+
Z as DecimalField,
|
|
68
|
+
y as default
|
|
79
69
|
};
|
|
80
70
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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;"}
|
|
@@ -1,33 +1,23 @@
|
|
|
1
1
|
import { jsxs as O, jsx as d } from "react/jsx-runtime";
|
|
2
2
|
import a from "react";
|
|
3
|
-
import
|
|
4
|
-
import "
|
|
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 De from "../../../node_modules/react-imask/esm/hook.js";
|
|
14
|
-
import "../../../node_modules/react-imask/esm/mixin.js";
|
|
3
|
+
import m from "../../../_virtual/lodash.js";
|
|
4
|
+
import { useIMask as De } from "react-imask";
|
|
15
5
|
import { createPortal as ye } from "react-dom";
|
|
16
|
-
import
|
|
6
|
+
import l from "../../../node_modules/moment/dist/moment.js";
|
|
17
7
|
import Oe from "../../../hint/index.js";
|
|
18
8
|
import { Tooltip as Se } from "../../../tooltip/index.js";
|
|
19
|
-
import { mergeRefs as
|
|
20
|
-
import { Keys as
|
|
21
|
-
import { Root as
|
|
22
|
-
import { TOKEN_PTBR_FORMAT as S, TOKEN_ISO_FORMAT as r, TOKEN_MASK as
|
|
23
|
-
import { Triggers as
|
|
24
|
-
import { CalendarBox as
|
|
9
|
+
import { mergeRefs as Re } from "../../../form2/helpers.js";
|
|
10
|
+
import { Keys as o } from "../types.js";
|
|
11
|
+
import { Root as Be, Label as we, Container as Ie, Input as xe } from "../base/index.js";
|
|
12
|
+
import { TOKEN_PTBR_FORMAT as S, TOKEN_ISO_FORMAT as r, TOKEN_MASK as ve, NAVIGATION_KEYS as Ve } from "../helpers.js";
|
|
13
|
+
import { Triggers as Fe } from "./triggers.js";
|
|
14
|
+
import { CalendarBox as pe } from "./calendarbox.js";
|
|
25
15
|
import { DateFieldContext as Ke } from "./context.js";
|
|
26
16
|
import Me from "../../../node_modules/uuid/dist/v1.js";
|
|
27
17
|
const Ne = a.forwardRef((t, j) => {
|
|
28
18
|
const {
|
|
29
|
-
label:
|
|
30
|
-
errors:
|
|
19
|
+
label: F,
|
|
20
|
+
errors: p,
|
|
31
21
|
tooltip: q,
|
|
32
22
|
tooltipPosition: H,
|
|
33
23
|
tooltipWidth: $,
|
|
@@ -44,38 +34,38 @@ const Ne = a.forwardRef((t, j) => {
|
|
|
44
34
|
themePopover: te = "light",
|
|
45
35
|
popoverAlign: ae = "left",
|
|
46
36
|
showCalendarButton: ne = !0,
|
|
47
|
-
openCalendarOnFocus:
|
|
48
|
-
undigitable:
|
|
49
|
-
showClearDateButton:
|
|
37
|
+
openCalendarOnFocus: le = !0,
|
|
38
|
+
undigitable: R = !1,
|
|
39
|
+
showClearDateButton: oe = !0,
|
|
50
40
|
placeholder: se = S,
|
|
51
|
-
readOnly:
|
|
41
|
+
readOnly: f,
|
|
52
42
|
disabled: k,
|
|
53
43
|
...re
|
|
54
|
-
} = t, [g,
|
|
55
|
-
setValue:
|
|
44
|
+
} = t, [g, B] = a.useState(!1), [w, D] = a.useState(l().format(r)), [i, I] = a.useState(null), [ie, u] = a.useState(i ?? l()), N = a.useRef(null), P = a.useRef(null), h = a.useRef(null), T = a.useRef(null), {
|
|
45
|
+
setValue: x,
|
|
56
46
|
unmaskedValue: E,
|
|
57
47
|
value: A
|
|
58
48
|
} = De({
|
|
59
|
-
mask:
|
|
49
|
+
mask: ve,
|
|
60
50
|
lazy: !1,
|
|
61
51
|
placeholderChar: "_"
|
|
62
52
|
}, {
|
|
63
53
|
ref: h,
|
|
64
54
|
defaultValue: i?.format(S),
|
|
65
55
|
onComplete: (e) => {
|
|
66
|
-
const n =
|
|
67
|
-
n.isValid() &&
|
|
56
|
+
const n = l(e, S);
|
|
57
|
+
n.isValid() && V(n);
|
|
68
58
|
}
|
|
69
|
-
}), b = a.useMemo(() => t.id || t.name || Me(), [t.id, t.name]), de = !
|
|
59
|
+
}), b = a.useMemo(() => t.id || t.name || Me(), [t.id, t.name]), de = !m.isEmpty(t?.label), z = !!t.hint?.length, v = !!p?.length, ce = !m.isEmpty(t?.value), V = a.useCallback((e) => {
|
|
70
60
|
const n = e.format(r), s = e.toISOString();
|
|
71
|
-
|
|
61
|
+
I(e.clone()), u(e.clone()), t.onChange?.({
|
|
72
62
|
target: {
|
|
73
63
|
name: t.name,
|
|
74
64
|
value: G === "default" ? n : s
|
|
75
65
|
}
|
|
76
66
|
}), K && C();
|
|
77
|
-
}, [i, t.name, t.onChange, K]), W = a.useCallback(() =>
|
|
78
|
-
|
|
67
|
+
}, [i, t.name, t.onChange, K]), W = a.useCallback(() => B(!0), []), C = a.useCallback(() => B(!1), []), Y = a.useCallback(() => u((e) => e.clone().add(1, "month")), []), L = a.useCallback(() => u((e) => e.clone().subtract(1, "month")), []), ue = a.useCallback(() => {
|
|
68
|
+
B((e) => (h.current !== document.activeElement && h?.current?.focus?.(), !e));
|
|
79
69
|
}, []), y = a.useCallback((e) => {
|
|
80
70
|
u((n) => {
|
|
81
71
|
const s = n.clone().add(e, "day");
|
|
@@ -86,69 +76,69 @@ const Ne = a.forwardRef((t, j) => {
|
|
|
86
76
|
let s = n;
|
|
87
77
|
return e === "end" && (s = n.clone().endOf("week")), e === "start" && (s = n.clone().startOf("week")), D(s.format(r)), s;
|
|
88
78
|
});
|
|
89
|
-
}, []),
|
|
79
|
+
}, []), fe = a.useCallback(() => {
|
|
90
80
|
t.onChange?.({
|
|
91
81
|
target: {
|
|
92
82
|
name: t.name,
|
|
93
83
|
value: ""
|
|
94
84
|
}
|
|
95
|
-
}),
|
|
96
|
-
}, [t.onChange]),
|
|
97
|
-
if (t?.onBlur?.(e), C(), D((i ??
|
|
98
|
-
const n =
|
|
99
|
-
n.isValid() &&
|
|
85
|
+
}), I(null), x(""), C();
|
|
86
|
+
}, [t.onChange]), me = (e) => {
|
|
87
|
+
if (t?.onBlur?.(e), C(), D((i ?? l()).format(r)), u(i ?? l()), m.size(E) !== 8) {
|
|
88
|
+
const n = l(m.toString(t?.value), r);
|
|
89
|
+
n.isValid() && x(n.format("DD/MM/YYYY"));
|
|
100
90
|
}
|
|
101
91
|
}, he = (e) => {
|
|
102
|
-
t?.onFocus?.(e), D((i ??
|
|
92
|
+
t?.onFocus?.(e), D((i ?? l()).format(r)), u(i ?? l()), !f && le && W();
|
|
103
93
|
}, be = (e) => {
|
|
104
|
-
|
|
94
|
+
R ? e.preventDefault() : t.onPaste?.(e);
|
|
105
95
|
}, Ce = (e) => {
|
|
106
|
-
|
|
96
|
+
R ? e.preventDefault() : t.onBeforeInput?.(e);
|
|
107
97
|
}, ke = (e) => {
|
|
108
|
-
if (t?.onKeyDown?.(e), g && e.key && !e.shiftKey && !e.altKey &&
|
|
98
|
+
if (t?.onKeyDown?.(e), g && e.key && !e.shiftKey && !e.altKey && Ve.includes(e.key))
|
|
109
99
|
switch (e.preventDefault(), e.key) {
|
|
110
|
-
case
|
|
100
|
+
case o.arrowLeft:
|
|
111
101
|
y(-1);
|
|
112
102
|
break;
|
|
113
|
-
case
|
|
103
|
+
case o.arrowRight:
|
|
114
104
|
y(1);
|
|
115
105
|
break;
|
|
116
|
-
case
|
|
106
|
+
case o.arrowUp:
|
|
117
107
|
y(-7);
|
|
118
108
|
break;
|
|
119
|
-
case
|
|
109
|
+
case o.arrowDown:
|
|
120
110
|
y(7);
|
|
121
111
|
break;
|
|
122
|
-
case
|
|
112
|
+
case o.pageUp:
|
|
123
113
|
Y();
|
|
124
114
|
break;
|
|
125
|
-
case
|
|
115
|
+
case o.pageDown:
|
|
126
116
|
L();
|
|
127
117
|
break;
|
|
128
|
-
case
|
|
118
|
+
case o.home:
|
|
129
119
|
U("start");
|
|
130
120
|
break;
|
|
131
|
-
case
|
|
121
|
+
case o.end:
|
|
132
122
|
U("end");
|
|
133
123
|
break;
|
|
134
|
-
case
|
|
124
|
+
case o.escape:
|
|
135
125
|
C();
|
|
136
126
|
break;
|
|
137
|
-
case
|
|
138
|
-
|
|
127
|
+
case o.enter:
|
|
128
|
+
V(l(m.toString(w), r));
|
|
139
129
|
break;
|
|
140
130
|
}
|
|
141
131
|
};
|
|
142
132
|
a.useEffect(() => {
|
|
143
|
-
const e = t?.value ?? null, n =
|
|
144
|
-
|
|
133
|
+
const e = t?.value ?? null, n = l(m.toString(e), r);
|
|
134
|
+
I(n.isValid() ? n : null), x(n.format(S));
|
|
145
135
|
}, [t?.value]);
|
|
146
136
|
const ge = {
|
|
147
|
-
label:
|
|
137
|
+
label: F,
|
|
148
138
|
inputFieldId: b,
|
|
149
|
-
activeDescendant:
|
|
139
|
+
activeDescendant: w,
|
|
150
140
|
calendarBoxOpen: g,
|
|
151
|
-
isReadOnly: !!
|
|
141
|
+
isReadOnly: !!f,
|
|
152
142
|
isDisabled: !!k,
|
|
153
143
|
skeletonize: c,
|
|
154
144
|
showCalendarButton: ne,
|
|
@@ -159,26 +149,26 @@ const Ne = a.forwardRef((t, j) => {
|
|
|
159
149
|
handleCloseCalendar: C,
|
|
160
150
|
handleNextMonth: Y,
|
|
161
151
|
handlePreviousMonth: L,
|
|
162
|
-
handleSelectDate:
|
|
152
|
+
handleSelectDate: V,
|
|
163
153
|
selectedDate: i,
|
|
164
154
|
unmaskedValue: E,
|
|
165
155
|
maskedValue: A,
|
|
166
|
-
showClearDateButton:
|
|
156
|
+
showClearDateButton: oe,
|
|
167
157
|
handleChangeCalendarBoxState: ue,
|
|
168
|
-
handleOnClickClearSelectedDate:
|
|
158
|
+
handleOnClickClearSelectedDate: fe,
|
|
169
159
|
calendarDisplayDate: ie,
|
|
170
160
|
calendarRef: N
|
|
171
161
|
};
|
|
172
162
|
return /* @__PURE__ */ O(a.Fragment, { children: [
|
|
173
|
-
/* @__PURE__ */ d(Ke.Provider, { value: ge, children: /* @__PURE__ */ O(
|
|
174
|
-
de && /* @__PURE__ */ d(
|
|
175
|
-
/* @__PURE__ */ O(
|
|
176
|
-
/* @__PURE__ */ d(
|
|
177
|
-
/* @__PURE__ */ d(
|
|
163
|
+
/* @__PURE__ */ d(Ke.Provider, { value: ge, children: /* @__PURE__ */ O(Be, { ref: P, "data-testid": "test-date-field-root", customClassWrapper: X, hasValidationErrors: v, children: [
|
|
164
|
+
de && /* @__PURE__ */ d(we, { "data-testid": "test-date-field-label", label: F, inputId: b, hint: t?.hint, isDisabled: k, isReadOnly: f, skeletonize: c, required: t?.required, hintPosition: M, themePopover: te, popoverAlign: ae, labelUppercase: ee, hasHintMessages: z, customClassLabel: Q }),
|
|
165
|
+
/* @__PURE__ */ O(Ie, { ref: T, skeletonize: c, customClassInputContainer: Z, children: [
|
|
166
|
+
/* @__PURE__ */ d(xe, { ...re, ref: Re(j, h), id: b, name: t?.name, value: A, readOnly: f, disabled: k, customClass: J, tabIndex: !f && !c ? 0 : -1, placeholder: se, "aria-activedescendant": w, "aria-expanded": g, "aria-controls": b, "aria-labelledby": b, "data-state-is-period-input": !1, "data-testid": "test-date-field-input", "data-state-error": v, "data-state-read-only": f, "data-state-text-align": _, "data-state-undigitable": R, "data-state-skeletonize": c, onBlur: me, onFocus: he, onPaste: be, onKeyDown: ke, onBeforeInput: Ce }),
|
|
167
|
+
/* @__PURE__ */ d(Fe, {})
|
|
178
168
|
] }),
|
|
179
|
-
g && ye(/* @__PURE__ */ d(
|
|
169
|
+
g && ye(/* @__PURE__ */ d(pe, { ref: N }), document.body),
|
|
180
170
|
M === "below" && /* @__PURE__ */ d(Oe, { customClass: "hint", description: t.hint, disabled: k, skeletonize: c, visible: z }),
|
|
181
|
-
|
|
171
|
+
v && /* @__PURE__ */ d("span", { "data-testid": "test-date-field-list-errors", className: "error", "data-state-skeletonize": c, "aria-describedby": String(t.name).concat("-errors"), children: p?.map((e, n) => /* @__PURE__ */ O(a.Fragment, { children: [
|
|
182
172
|
e,
|
|
183
173
|
" "
|
|
184
174
|
] }, `${n + 1}-${e}`)) })
|