linear-react-components-ui 2.0.0-beta.4 → 2.0.0-rc.0

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.
Files changed (122) hide show
  1. package/lib/assets/styles/radio.css +1 -1
  2. package/lib/assets/styles/selectfield.css +1 -1
  3. package/lib/assets/styles/split.css +1 -1
  4. package/lib/form2/useForm/index.js +74 -63
  5. package/lib/form2/useForm/index.js.map +1 -1
  6. package/lib/inputs/base/types.d.ts +2 -2
  7. package/lib/inputs/date/helpers.js +11 -22
  8. package/lib/inputs/date/helpers.js.map +1 -1
  9. package/lib/inputs/mask/BaseMask.js +55 -65
  10. package/lib/inputs/mask/BaseMask.js.map +1 -1
  11. package/lib/inputs/mask/types.d.ts +2 -1
  12. package/lib/inputs/number/Currency.js +35 -45
  13. package/lib/inputs/number/Currency.js.map +1 -1
  14. package/lib/inputs/number/Decimal.js +38 -48
  15. package/lib/inputs/number/Decimal.js.map +1 -1
  16. package/lib/inputs/number/index.js +38 -48
  17. package/lib/inputs/number/index.js.map +1 -1
  18. package/lib/inputs/period/helper.d.ts +1 -0
  19. package/lib/inputs/period/helper.js +27 -19
  20. package/lib/inputs/period/helper.js.map +1 -1
  21. package/lib/inputs/period/index.js +143 -139
  22. package/lib/inputs/period/index.js.map +1 -1
  23. package/lib/inputs2/date/datefield/base.js +60 -70
  24. package/lib/inputs2/date/datefield/base.js.map +1 -1
  25. package/lib/inputs2/date/dateperiodfield/base.js +79 -89
  26. package/lib/inputs2/date/dateperiodfield/base.js.map +1 -1
  27. package/lib/inputs2/mask/Cnpj.js +58 -68
  28. package/lib/inputs2/mask/Cnpj.js.map +1 -1
  29. package/lib/inputs2/mask/Cpf.js +38 -48
  30. package/lib/inputs2/mask/Cpf.js.map +1 -1
  31. package/lib/inputs2/mask/index.js +50 -60
  32. package/lib/inputs2/mask/index.js.map +1 -1
  33. package/lib/inputs2/numberfield/currency.js +51 -61
  34. package/lib/inputs2/numberfield/currency.js.map +1 -1
  35. package/lib/inputs2/numberfield/decimal.js +25 -35
  36. package/lib/inputs2/numberfield/decimal.js.map +1 -1
  37. package/lib/inputs2/numberfield/index.js +46 -56
  38. package/lib/inputs2/numberfield/index.js.map +1 -1
  39. package/lib/inputs2/selectfield/base.d.ts +1 -2
  40. package/lib/inputs2/selectfield/base.js +260 -382
  41. package/lib/inputs2/selectfield/base.js.map +1 -1
  42. package/lib/inputs2/selectfield/context.d.ts +1 -1
  43. package/lib/inputs2/selectfield/context.js.map +1 -1
  44. package/lib/inputs2/selectfield/helpers.d.ts +5 -0
  45. package/lib/inputs2/selectfield/helpers.js +22 -13
  46. package/lib/inputs2/selectfield/helpers.js.map +1 -1
  47. package/lib/inputs2/selectfield/index.js.map +1 -1
  48. package/lib/inputs2/selectfield/listbox.js +17 -18
  49. package/lib/inputs2/selectfield/listbox.js.map +1 -1
  50. package/lib/inputs2/selectfield/selections.d.ts +1 -1
  51. package/lib/inputs2/selectfield/selections.js +11 -11
  52. package/lib/inputs2/selectfield/selections.js.map +1 -1
  53. package/lib/inputs2/selectfield/triggers.js +15 -15
  54. package/lib/inputs2/selectfield/triggers.js.map +1 -1
  55. package/lib/radio/index.js +74 -84
  56. package/lib/radio/index.js.map +1 -1
  57. package/lib/table/Row.js +57 -46
  58. package/lib/table/Row.js.map +1 -1
  59. package/lib/table/types.d.ts +2 -1
  60. package/package.json +9 -6
  61. package/lib/node_modules/imask/esm/controls/html-contenteditable-mask-element.js +0 -35
  62. package/lib/node_modules/imask/esm/controls/html-contenteditable-mask-element.js.map +0 -1
  63. package/lib/node_modules/imask/esm/controls/html-input-mask-element.js +0 -32
  64. package/lib/node_modules/imask/esm/controls/html-input-mask-element.js.map +0 -1
  65. package/lib/node_modules/imask/esm/controls/html-mask-element.js +0 -49
  66. package/lib/node_modules/imask/esm/controls/html-mask-element.js.map +0 -1
  67. package/lib/node_modules/imask/esm/controls/input-history.js +0 -31
  68. package/lib/node_modules/imask/esm/controls/input-history.js.map +0 -1
  69. package/lib/node_modules/imask/esm/controls/input.js +0 -223
  70. package/lib/node_modules/imask/esm/controls/input.js.map +0 -1
  71. package/lib/node_modules/imask/esm/controls/mask-element.js +0 -44
  72. package/lib/node_modules/imask/esm/controls/mask-element.js.map +0 -1
  73. package/lib/node_modules/imask/esm/core/action-details.js +0 -52
  74. package/lib/node_modules/imask/esm/core/action-details.js.map +0 -1
  75. package/lib/node_modules/imask/esm/core/change-details.js +0 -37
  76. package/lib/node_modules/imask/esm/core/change-details.js.map +0 -1
  77. package/lib/node_modules/imask/esm/core/continuous-tail-details.js +0 -43
  78. package/lib/node_modules/imask/esm/core/continuous-tail-details.js.map +0 -1
  79. package/lib/node_modules/imask/esm/core/holder.js +0 -7
  80. package/lib/node_modules/imask/esm/core/holder.js.map +0 -1
  81. package/lib/node_modules/imask/esm/core/utils.js +0 -68
  82. package/lib/node_modules/imask/esm/core/utils.js.map +0 -1
  83. package/lib/node_modules/imask/esm/index.js +0 -51
  84. package/lib/node_modules/imask/esm/index.js.map +0 -1
  85. package/lib/node_modules/imask/esm/masked/base.js +0 -253
  86. package/lib/node_modules/imask/esm/masked/base.js.map +0 -1
  87. package/lib/node_modules/imask/esm/masked/date.js +0 -118
  88. package/lib/node_modules/imask/esm/masked/date.js.map +0 -1
  89. package/lib/node_modules/imask/esm/masked/dynamic.js +0 -223
  90. package/lib/node_modules/imask/esm/masked/dynamic.js.map +0 -1
  91. package/lib/node_modules/imask/esm/masked/enum.js +0 -70
  92. package/lib/node_modules/imask/esm/masked/enum.js.map +0 -1
  93. package/lib/node_modules/imask/esm/masked/factory.js +0 -47
  94. package/lib/node_modules/imask/esm/masked/factory.js.map +0 -1
  95. package/lib/node_modules/imask/esm/masked/function.js +0 -24
  96. package/lib/node_modules/imask/esm/masked/function.js.map +0 -1
  97. package/lib/node_modules/imask/esm/masked/number.js +0 -213
  98. package/lib/node_modules/imask/esm/masked/number.js.map +0 -1
  99. package/lib/node_modules/imask/esm/masked/pattern/chunk-tail-details.js +0 -104
  100. package/lib/node_modules/imask/esm/masked/pattern/chunk-tail-details.js.map +0 -1
  101. package/lib/node_modules/imask/esm/masked/pattern/cursor.js +0 -101
  102. package/lib/node_modules/imask/esm/masked/pattern/cursor.js.map +0 -1
  103. package/lib/node_modules/imask/esm/masked/pattern/fixed-definition.js +0 -103
  104. package/lib/node_modules/imask/esm/masked/pattern/fixed-definition.js.map +0 -1
  105. package/lib/node_modules/imask/esm/masked/pattern/input-definition.js +0 -134
  106. package/lib/node_modules/imask/esm/masked/pattern/input-definition.js.map +0 -1
  107. package/lib/node_modules/imask/esm/masked/pattern.js +0 -323
  108. package/lib/node_modules/imask/esm/masked/pattern.js.map +0 -1
  109. package/lib/node_modules/imask/esm/masked/pipe.js +0 -24
  110. package/lib/node_modules/imask/esm/masked/pipe.js.map +0 -1
  111. package/lib/node_modules/imask/esm/masked/range.js +0 -79
  112. package/lib/node_modules/imask/esm/masked/range.js.map +0 -1
  113. package/lib/node_modules/imask/esm/masked/regexp.js +0 -22
  114. package/lib/node_modules/imask/esm/masked/regexp.js.map +0 -1
  115. package/lib/node_modules/imask/esm/masked/repeat.js +0 -105
  116. package/lib/node_modules/imask/esm/masked/repeat.js.map +0 -1
  117. package/lib/node_modules/react-imask/esm/hook.js +0 -76
  118. package/lib/node_modules/react-imask/esm/hook.js.map +0 -1
  119. package/lib/node_modules/react-imask/esm/input.js +0 -24
  120. package/lib/node_modules/react-imask/esm/input.js.map +0 -1
  121. package/lib/node_modules/react-imask/esm/mixin.js +0 -132
  122. package/lib/node_modules/react-imask/esm/mixin.js.map +0 -1
@@ -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 f 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 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 o from "../../../node_modules/moment/dist/moment.js";
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 pe } from "../../../form2/helpers.js";
20
- import { Keys as l } from "../types.js";
21
- import { Root as Re, Label as Be, Container as we, Input as Ie } from "../base/index.js";
22
- import { TOKEN_PTBR_FORMAT as S, TOKEN_ISO_FORMAT as r, TOKEN_MASK as xe, NAVIGATION_KEYS as ve } from "../helpers.js";
23
- import { Triggers as Ve } from "./triggers.js";
24
- import { CalendarBox as Fe } from "./calendarbox.js";
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: V,
30
- errors: F,
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: oe = !0,
48
- undigitable: p = !1,
49
- showClearDateButton: le = !0,
37
+ openCalendarOnFocus: le = !0,
38
+ undigitable: R = !1,
39
+ showClearDateButton: oe = !0,
50
40
  placeholder: se = S,
51
- readOnly: m,
41
+ readOnly: f,
52
42
  disabled: k,
53
43
  ...re
54
- } = t, [g, R] = a.useState(!1), [B, D] = a.useState(o().format(r)), [i, w] = a.useState(null), [ie, u] = a.useState(i ?? o()), N = a.useRef(null), P = a.useRef(null), h = a.useRef(null), T = a.useRef(null), {
55
- setValue: I,
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: xe,
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 = o(e, S);
67
- n.isValid() && v(n);
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 = !f.isEmpty(t?.label), z = !!t.hint?.length, x = !!F?.length, ce = !f.isEmpty(t?.value), v = a.useCallback((e) => {
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
- w(e.clone()), u(e.clone()), t.onChange?.({
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(() => R(!0), []), C = a.useCallback(() => R(!1), []), Y = a.useCallback(() => u((e) => e.clone().add(1, "month")), []), L = a.useCallback(() => u((e) => e.clone().subtract(1, "month")), []), ue = a.useCallback(() => {
78
- R((e) => (h.current !== document.activeElement && h?.current?.focus?.(), !e));
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
- }, []), me = a.useCallback(() => {
79
+ }, []), fe = a.useCallback(() => {
90
80
  t.onChange?.({
91
81
  target: {
92
82
  name: t.name,
93
83
  value: ""
94
84
  }
95
- }), w(null), I(""), C();
96
- }, [t.onChange]), fe = (e) => {
97
- if (t?.onBlur?.(e), C(), D((i ?? o()).format(r)), u(i ?? o()), f.size(E) !== 8) {
98
- const n = o(f.toString(t?.value), r);
99
- n.isValid() && I(n.format("DD/MM/YYYY"));
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 ?? o()).format(r)), u(i ?? o()), !m && oe && W();
92
+ t?.onFocus?.(e), D((i ?? l()).format(r)), u(i ?? l()), !f && le && W();
103
93
  }, be = (e) => {
104
- p ? e.preventDefault() : t.onPaste?.(e);
94
+ R ? e.preventDefault() : t.onPaste?.(e);
105
95
  }, Ce = (e) => {
106
- p ? e.preventDefault() : t.onBeforeInput?.(e);
96
+ R ? e.preventDefault() : t.onBeforeInput?.(e);
107
97
  }, ke = (e) => {
108
- if (t?.onKeyDown?.(e), g && e.key && !e.shiftKey && !e.altKey && ve.includes(e.key))
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 l.arrowLeft:
100
+ case o.arrowLeft:
111
101
  y(-1);
112
102
  break;
113
- case l.arrowRight:
103
+ case o.arrowRight:
114
104
  y(1);
115
105
  break;
116
- case l.arrowUp:
106
+ case o.arrowUp:
117
107
  y(-7);
118
108
  break;
119
- case l.arrowDown:
109
+ case o.arrowDown:
120
110
  y(7);
121
111
  break;
122
- case l.pageUp:
112
+ case o.pageUp:
123
113
  Y();
124
114
  break;
125
- case l.pageDown:
115
+ case o.pageDown:
126
116
  L();
127
117
  break;
128
- case l.home:
118
+ case o.home:
129
119
  U("start");
130
120
  break;
131
- case l.end:
121
+ case o.end:
132
122
  U("end");
133
123
  break;
134
- case l.escape:
124
+ case o.escape:
135
125
  C();
136
126
  break;
137
- case l.enter:
138
- v(o(f.toString(B), r));
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 = o(f.toString(e), r);
144
- w(n.isValid() ? n : null), I(n.format(S));
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: V,
137
+ label: F,
148
138
  inputFieldId: b,
149
- activeDescendant: B,
139
+ activeDescendant: w,
150
140
  calendarBoxOpen: g,
151
- isReadOnly: !!m,
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: v,
152
+ handleSelectDate: V,
163
153
  selectedDate: i,
164
154
  unmaskedValue: E,
165
155
  maskedValue: A,
166
- showClearDateButton: le,
156
+ showClearDateButton: oe,
167
157
  handleChangeCalendarBoxState: ue,
168
- handleOnClickClearSelectedDate: me,
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(Re, { ref: P, "data-testid": "test-date-field-root", customClassWrapper: X, hasValidationErrors: x, children: [
174
- de && /* @__PURE__ */ d(Be, { "data-testid": "test-date-field-label", label: V, inputId: b, hint: t?.hint, isDisabled: k, isReadOnly: m, skeletonize: c, required: t?.required, hintPosition: M, themePopover: te, popoverAlign: ae, labelUppercase: ee, hasHintMessages: z, customClassLabel: Q }),
175
- /* @__PURE__ */ O(we, { ref: T, skeletonize: c, customClassInputContainer: Z, children: [
176
- /* @__PURE__ */ d(Ie, { ...re, ref: pe(j, h), id: b, name: t?.name, value: A, readOnly: m, disabled: k, customClass: J, tabIndex: !m && !c ? 0 : -1, placeholder: se, "aria-activedescendant": B, "aria-expanded": g, "aria-controls": b, "aria-labelledby": b, "data-state-is-period-input": !1, "data-testid": "test-date-field-input", "data-state-error": x, "data-state-read-only": m, "data-state-text-align": _, "data-state-undigitable": p, "data-state-skeletonize": c, onBlur: fe, onFocus: he, onPaste: be, onKeyDown: ke, onBeforeInput: Ce }),
177
- /* @__PURE__ */ d(Ve, {})
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(Fe, { ref: N }), document.body),
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
- x && /* @__PURE__ */ d("span", { "data-testid": "test-date-field-list-errors", className: "error", "data-state-skeletonize": c, "aria-describedby": String(t.name).concat("-errors"), children: F?.map((e, n) => /* @__PURE__ */ O(a.Fragment, { children: [
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}`)) })
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sources":["../../../../src/lib/inputs2/date/datefield/base.tsx"],"sourcesContent":["import React from 'react';\nimport _ from 'lodash';\nimport { useIMask } from 'react-imask';\nimport { v1 as uuid } from 'uuid';\nimport { createPortal } from 'react-dom';\nimport moment, { type Moment } from 'moment';\nimport Hint from '../../../hint';\nimport { Tooltip } from '../../../tooltip';\nimport { mergeRefs } from '../../../form2/helpers';\nimport { Keys } from '../types';\nimport * as BaseDate from '../base';\nimport { NAVIGATION_KEYS, TOKEN_ISO_FORMAT, TOKEN_MASK, TOKEN_PTBR_FORMAT } from '../helpers';\nimport { Triggers } from './triggers';\nimport { CalendarBox } from './calendarbox';\nimport { DateFieldContext } from './context';\nimport type { DateFieldInputBaseProps } from './types';\n\nexport const InputBase = \n React.forwardRef<HTMLInputElement, DateFieldInputBaseProps>((props, ref) => {\n const {\n label, errors, tooltip, tooltipPosition, tooltipWidth, shouldCloseOnSelect = true, returnValueType = 'default',\n customClass = '', customClassLabel = '', customClassWrapper = '', customClassInputContainer = '', textAlign = 'left',\n labelUppercase = false, skeletonize = false, hintPosition = 'below', themePopover = 'light',\n popoverAlign = 'left', showCalendarButton = true, openCalendarOnFocus = true, undigitable = false, \n showClearDateButton = true, placeholder = TOKEN_PTBR_FORMAT, readOnly, disabled, ...rest\n } = props;\n const [calendarBoxOpen, setCalendarBoxOpen] = React.useState(false);\n const [activeDescendant, setActiveDescendant] = React.useState<string>(\n moment().format(TOKEN_ISO_FORMAT),\n );\n const [selectedDate, setSelectedDate] = React.useState<Moment | null>(null);\n const [calendarDisplayDate, setCalendarDisplayDate] = React.useState<Moment>(\n selectedDate ?? moment(),\n );\n const calendarRef = React.useRef<HTMLDivElement | null>(null);\n const inputRootRef = React.useRef<HTMLInputElement | null>(null);\n const dateInputRef = React.useRef<HTMLInputElement | null>(null);\n const dateContainerRef = React.useRef<HTMLDivElement | null>(null);\n\n const { setValue: setMaskValue, unmaskedValue, value: maskedValue } = useIMask(\n { mask: TOKEN_MASK, lazy: false, placeholderChar: '_' },\n {\n ref: dateInputRef,\n defaultValue: selectedDate?.format(TOKEN_PTBR_FORMAT),\n onComplete: (value) => {\n const date = moment(value, TOKEN_PTBR_FORMAT);\n if (date.isValid()) { handleUpdateDateState(date); }\n },\n },\n );\n\n const inputId = React.useMemo(() => props.id || props.name || uuid(), [props.id, props.name]);\n const hasLabel = !_.isEmpty(props?.label);\n const hasHintMessages = Boolean(props.hint?.length);\n const hasValidationErrors = Boolean(errors?.length);\n const hasValidDateSelected = !_.isEmpty(props?.value);\n\n const handleUpdateDateState = React.useCallback((date: Moment) => {\n const nonIsoDateFormat = date.format(TOKEN_ISO_FORMAT);\n const isoDateFormat = date.toISOString();\n setSelectedDate(date.clone());\n setCalendarDisplayDate(date.clone());\n props.onChange?.({\n target: {\n name: props.name,\n value: returnValueType === 'default' ? nonIsoDateFormat : isoDateFormat,\n },\n } as React.ChangeEvent<HTMLInputElement>);\n if (shouldCloseOnSelect) handleCloseCalendar();\n }, [selectedDate, props.name, props.onChange, shouldCloseOnSelect]);\n\n const handleOpenCalendar = React.useCallback(() => setCalendarBoxOpen(true), []);\n const handleCloseCalendar = React.useCallback(() => setCalendarBoxOpen(false), []);\n const handleNextMonth = React.useCallback(() => setCalendarDisplayDate(prevDisplayDate =>\n prevDisplayDate.clone().add(1, 'month')), []);\n const handlePreviousMonth = React.useCallback(() => setCalendarDisplayDate(prevDisplayDate =>\n prevDisplayDate.clone().subtract(1, 'month')), []);\n const handleChangeCalendarBoxState = React.useCallback(() => {\n setCalendarBoxOpen((prevState) => {\n if (dateInputRef.current !== document.activeElement) {\n dateInputRef?.current?.focus?.();\n }\n return !prevState;\n });\n }, []);\n const handleNavigateWithDays = React.useCallback((offset: number) => {\n setCalendarDisplayDate((prevDisplayDate) => {\n const daySelected = prevDisplayDate.clone().add(offset, 'day');\n setActiveDescendant(daySelected.format(TOKEN_ISO_FORMAT));\n return daySelected;\n });\n }, []);\n const handleNavigateWithWeeks = React.useCallback((when: 'start' | 'end') => {\n setCalendarDisplayDate((prevDisplayDate) => {\n let daySelected = prevDisplayDate;\n if (when === 'end') daySelected = prevDisplayDate.clone().endOf('week');\n if (when === 'start') daySelected = prevDisplayDate.clone().startOf('week');\n setActiveDescendant(daySelected.format(TOKEN_ISO_FORMAT));\n return daySelected;\n });\n }, []);\n\n const handleOnClickClearSelectedDate = React.useCallback(() => {\n props.onChange?.({\n target: { name: props.name, value: '' },\n } as React.ChangeEvent<HTMLInputElement>);\n setSelectedDate(null);\n setMaskValue('');\n handleCloseCalendar();\n }, [props.onChange]);\n\n const handleOnBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n props?.onBlur?.(event);\n handleCloseCalendar();\n setActiveDescendant((selectedDate ?? moment()).format(TOKEN_ISO_FORMAT));\n setCalendarDisplayDate(selectedDate ?? moment());\n if (_.size(unmaskedValue) !== 8) {\n const date = moment(_.toString(props?.value), TOKEN_ISO_FORMAT);\n if (date.isValid()) { setMaskValue(date.format('DD/MM/YYYY')); }\n }\n };\n\n const handleOnFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n props?.onFocus?.(event);\n setActiveDescendant((selectedDate ?? moment()).format(TOKEN_ISO_FORMAT));\n setCalendarDisplayDate(selectedDate ?? moment());\n if (!readOnly && openCalendarOnFocus) {\n handleOpenCalendar();\n }\n };\n\n const handleOnPaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n if (undigitable) {\n event.preventDefault();\n } else {\n props.onPaste?.(event);\n }\n };\n\n const handleOnBeforeInput = (event: React.InputEvent<HTMLInputElement>) => {\n if (undigitable) {\n event.preventDefault();\n } else {\n props.onBeforeInput?.(event);\n }\n };\n\n const handleOnKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n props?.onKeyDown?.(event);\n if (calendarBoxOpen && event.key && !event.shiftKey && \n !event.altKey && NAVIGATION_KEYS.includes(event.key)) {\n event.preventDefault();\n switch (event.key) {\n case Keys.arrowLeft: handleNavigateWithDays(-1);\n break;\n case Keys.arrowRight: handleNavigateWithDays(1);\n break;\n case Keys.arrowUp: handleNavigateWithDays(-7);\n break;\n case Keys.arrowDown: handleNavigateWithDays(7);\n break;\n case Keys.pageUp: handleNextMonth();\n break;\n case Keys.pageDown: handlePreviousMonth();\n break;\n case Keys.home: handleNavigateWithWeeks('start');\n break;\n case Keys.end: handleNavigateWithWeeks('end');\n break;\n case Keys.escape: handleCloseCalendar();\n break;\n case Keys.enter: handleUpdateDateState(\n moment(_.toString(activeDescendant), TOKEN_ISO_FORMAT),\n );\n break;\n default:\n break;\n }\n }\n };\n\n React.useEffect(() => {\n const currentValue = props?.value ?? null;\n const date = moment(_.toString(currentValue), TOKEN_ISO_FORMAT);\n setSelectedDate(date.isValid() ? date : null);\n setMaskValue(date.format(TOKEN_PTBR_FORMAT));\n }, [props?.value]);\n\n const contextValues = ({\n label, inputFieldId: inputId, activeDescendant, calendarBoxOpen, \n isReadOnly: Boolean(readOnly), isDisabled: Boolean(disabled), skeletonize, showCalendarButton,\n hasValidDateSelected, dateInputRef, dateContainerRef, handleOpenCalendar, \n handleCloseCalendar, handleNextMonth, handlePreviousMonth, \n handleSelectDate: handleUpdateDateState, selectedDate, unmaskedValue, maskedValue, \n showClearDateButton, handleChangeCalendarBoxState, handleOnClickClearSelectedDate,\n calendarDisplayDate, calendarRef,\n });\n\n return (\n <React.Fragment>\n <DateFieldContext.Provider value={contextValues}>\n <BaseDate.Root\n ref={inputRootRef}\n data-testid=\"test-date-field-root\"\n customClassWrapper={customClassWrapper}\n hasValidationErrors={hasValidationErrors}>\n {hasLabel && (\n <BaseDate.Label\n data-testid=\"test-date-field-label\"\n label={label}\n inputId={inputId}\n hint={props?.hint}\n isDisabled={disabled}\n isReadOnly={readOnly}\n skeletonize={skeletonize}\n required={props?.required}\n hintPosition={hintPosition}\n themePopover={themePopover}\n popoverAlign={popoverAlign}\n labelUppercase={labelUppercase}\n hasHintMessages={hasHintMessages}\n customClassLabel={customClassLabel} />\n )}\n <BaseDate.Container\n ref={dateContainerRef}\n skeletonize={skeletonize}\n customClassInputContainer={customClassInputContainer}>\n <BaseDate.Input\n {...rest}\n ref={mergeRefs(ref, dateInputRef)}\n id={inputId}\n name={props?.name}\n value={maskedValue}\n readOnly={readOnly}\n disabled={disabled}\n customClass={customClass}\n tabIndex={(!readOnly && !skeletonize) ? 0 : -1}\n placeholder={placeholder}\n aria-activedescendant={activeDescendant}\n aria-expanded={calendarBoxOpen}\n aria-controls={inputId}\n aria-labelledby={inputId}\n data-state-is-period-input={false}\n data-testid=\"test-date-field-input\"\n data-state-error={hasValidationErrors}\n data-state-read-only={readOnly}\n data-state-text-align={textAlign}\n data-state-undigitable={undigitable}\n data-state-skeletonize={skeletonize}\n onBlur={handleOnBlur}\n onFocus={handleOnFocus}\n onPaste={handleOnPaste}\n onKeyDown={handleOnKeyDown}\n onBeforeInput={handleOnBeforeInput} />\n <Triggers />\n </BaseDate.Container>\n {calendarBoxOpen &&\n createPortal(<CalendarBox ref={calendarRef} />, document.body)\n }\n {hintPosition === 'below' && (\n <Hint\n customClass=\"hint\"\n description={props.hint}\n disabled={disabled}\n skeletonize={skeletonize}\n visible={hasHintMessages} />\n )}\n {hasValidationErrors && (\n <span\n data-testid=\"test-date-field-list-errors\"\n className=\"error\"\n data-state-skeletonize={skeletonize}\n aria-describedby={String(props.name).concat('-errors')}>\n {errors?.map((error, index) => (\n <React.Fragment key={`${index + 1}-${error}`}>\n {error}\n {' '}\n </React.Fragment>\n ))}\n </span>\n )}\n </BaseDate.Root>\n </DateFieldContext.Provider>\n <Tooltip\n targetRef={inputRootRef}\n text={tooltip}\n width={tooltipWidth}\n position={tooltipPosition} />\n </React.Fragment>\n );\n });\n\nInputBase.displayName = 'DateFieldInputBase';\n"],"names":["InputBase","React","forwardRef","props","ref","label","errors","tooltip","tooltipPosition","tooltipWidth","shouldCloseOnSelect","returnValueType","customClass","customClassLabel","customClassWrapper","customClassInputContainer","textAlign","labelUppercase","skeletonize","hintPosition","themePopover","popoverAlign","showCalendarButton","openCalendarOnFocus","undigitable","showClearDateButton","placeholder","TOKEN_PTBR_FORMAT","readOnly","disabled","rest","calendarBoxOpen","setCalendarBoxOpen","useState","activeDescendant","setActiveDescendant","moment","format","TOKEN_ISO_FORMAT","selectedDate","setSelectedDate","calendarDisplayDate","setCalendarDisplayDate","calendarRef","useRef","inputRootRef","dateInputRef","dateContainerRef","setValue","setMaskValue","unmaskedValue","value","maskedValue","useIMask","mask","TOKEN_MASK","lazy","placeholderChar","defaultValue","onComplete","date","isValid","handleUpdateDateState","inputId","useMemo","id","name","uuid","hasLabel","_","isEmpty","hasHintMessages","Boolean","hint","length","hasValidationErrors","hasValidDateSelected","useCallback","nonIsoDateFormat","isoDateFormat","toISOString","clone","onChange","target","handleCloseCalendar","handleOpenCalendar","handleNextMonth","prevDisplayDate","add","handlePreviousMonth","subtract","handleChangeCalendarBoxState","prevState","current","document","activeElement","focus","handleNavigateWithDays","offset","daySelected","handleNavigateWithWeeks","when","endOf","startOf","handleOnClickClearSelectedDate","handleOnBlur","event","onBlur","size","toString","handleOnFocus","onFocus","handleOnPaste","preventDefault","onPaste","handleOnBeforeInput","onBeforeInput","handleOnKeyDown","onKeyDown","key","shiftKey","altKey","NAVIGATION_KEYS","includes","Keys","arrowLeft","arrowRight","arrowUp","arrowDown","pageUp","pageDown","home","end","escape","enter","useEffect","currentValue","contextValues","inputFieldId","isReadOnly","isDisabled","handleSelectDate","jsxs","jsx","DateFieldContext","BaseDate.Root","BaseDate.Label","required","BaseDate.Container","BaseDate.Input","mergeRefs","Triggers","createPortal","CalendarBox","body","Hint","String","concat","map","error","index","Tooltip","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,MAAMA,KACXC,EAAMC,WAAsD,CAACC,GAAOC,MAAQ;AAC1E,QAAM;AAAA,IACJC,OAAAA;AAAAA,IAAOC,QAAAA;AAAAA,IAAQC,SAAAA;AAAAA,IAASC,iBAAAA;AAAAA,IAAiBC,cAAAA;AAAAA,IAAcC,qBAAAA,IAAsB;AAAA,IAAMC,iBAAAA,IAAkB;AAAA,IACrGC,aAAAA,IAAc;AAAA,IAAIC,kBAAAA,IAAmB;AAAA,IA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,gBAAAoE,EAAC,QAAA,EACC,eAAY,+BACZ,WAAU,SACV,0BAAwB7H,GACxB,oBAAkB0I,OAAOzJ,EAAM+D,IAAI,EAAE2F,OAAO,SAAS,GACpDvJ,UAAAA,GAAQwJ,IAAI,CAACC,GAAOC,MACnB,gBAAAlB,EAAC7I,EAAM,UAAN,EACE8J,UAAAA;AAAAA,QAAAA;AAAAA,QACA;AAAA,MAAA,EAAA,GAFkB,GAAGC,IAAQ,CAAC,IAAID,CAAK,EAG1C,CACD,EAAA,CACH;AAAA,IAAA,EAAA,CAEF,EAAA,CACF;AAAA,IACA,gBAAAhB,EAACkB,MACC,WAAWpH,GACX,MAAMtC,GACN,OAAOE,GACP,UAAUD,EAAAA,CAAgB;AAAA,EAAA,GAC9B;AAEJ,CAAC;AAEHR,GAAUkK,cAAc;"}
1
+ {"version":3,"file":"base.js","sources":["../../../../src/lib/inputs2/date/datefield/base.tsx"],"sourcesContent":["import React from 'react';\nimport _ from 'lodash';\nimport { useIMask } from 'react-imask';\nimport { v1 as uuid } from 'uuid';\nimport { createPortal } from 'react-dom';\nimport moment, { type Moment } from 'moment';\nimport Hint from '../../../hint';\nimport { Tooltip } from '../../../tooltip';\nimport { mergeRefs } from '../../../form2/helpers';\nimport { Keys } from '../types';\nimport * as BaseDate from '../base';\nimport { NAVIGATION_KEYS, TOKEN_ISO_FORMAT, TOKEN_MASK, TOKEN_PTBR_FORMAT } from '../helpers';\nimport { Triggers } from './triggers';\nimport { CalendarBox } from './calendarbox';\nimport { DateFieldContext } from './context';\nimport type { DateFieldInputBaseProps } from './types';\n\nexport const InputBase = \n React.forwardRef<HTMLInputElement, DateFieldInputBaseProps>((props, ref) => {\n const {\n label, errors, tooltip, tooltipPosition, tooltipWidth, shouldCloseOnSelect = true, returnValueType = 'default',\n customClass = '', customClassLabel = '', customClassWrapper = '', customClassInputContainer = '', textAlign = 'left',\n labelUppercase = false, skeletonize = false, hintPosition = 'below', themePopover = 'light',\n popoverAlign = 'left', showCalendarButton = true, openCalendarOnFocus = true, undigitable = false, \n showClearDateButton = true, placeholder = TOKEN_PTBR_FORMAT, readOnly, disabled, ...rest\n } = props;\n const [calendarBoxOpen, setCalendarBoxOpen] = React.useState(false);\n const [activeDescendant, setActiveDescendant] = React.useState<string>(\n moment().format(TOKEN_ISO_FORMAT),\n );\n const [selectedDate, setSelectedDate] = React.useState<Moment | null>(null);\n const [calendarDisplayDate, setCalendarDisplayDate] = React.useState<Moment>(\n selectedDate ?? moment(),\n );\n const calendarRef = React.useRef<HTMLDivElement | null>(null);\n const inputRootRef = React.useRef<HTMLInputElement | null>(null);\n const dateInputRef = React.useRef<HTMLInputElement | null>(null);\n const dateContainerRef = React.useRef<HTMLDivElement | null>(null);\n\n const { setValue: setMaskValue, unmaskedValue, value: maskedValue } = useIMask(\n { mask: TOKEN_MASK, lazy: false, placeholderChar: '_' },\n {\n ref: dateInputRef,\n defaultValue: selectedDate?.format(TOKEN_PTBR_FORMAT),\n onComplete: (value) => {\n const date = moment(value, TOKEN_PTBR_FORMAT);\n if (date.isValid()) { handleUpdateDateState(date); }\n },\n },\n );\n\n const inputId = React.useMemo(() => props.id || props.name || uuid(), [props.id, props.name]);\n const hasLabel = !_.isEmpty(props?.label);\n const hasHintMessages = Boolean(props.hint?.length);\n const hasValidationErrors = Boolean(errors?.length);\n const hasValidDateSelected = !_.isEmpty(props?.value);\n\n const handleUpdateDateState = React.useCallback((date: Moment) => {\n const nonIsoDateFormat = date.format(TOKEN_ISO_FORMAT);\n const isoDateFormat = date.toISOString();\n setSelectedDate(date.clone());\n setCalendarDisplayDate(date.clone());\n props.onChange?.({\n target: {\n name: props.name,\n value: returnValueType === 'default' ? nonIsoDateFormat : isoDateFormat,\n },\n } as React.ChangeEvent<HTMLInputElement>);\n if (shouldCloseOnSelect) handleCloseCalendar();\n }, [selectedDate, props.name, props.onChange, shouldCloseOnSelect]);\n\n const handleOpenCalendar = React.useCallback(() => setCalendarBoxOpen(true), []);\n const handleCloseCalendar = React.useCallback(() => setCalendarBoxOpen(false), []);\n const handleNextMonth = React.useCallback(() => setCalendarDisplayDate(prevDisplayDate =>\n prevDisplayDate.clone().add(1, 'month')), []);\n const handlePreviousMonth = React.useCallback(() => setCalendarDisplayDate(prevDisplayDate =>\n prevDisplayDate.clone().subtract(1, 'month')), []);\n const handleChangeCalendarBoxState = React.useCallback(() => {\n setCalendarBoxOpen((prevState) => {\n if (dateInputRef.current !== document.activeElement) {\n dateInputRef?.current?.focus?.();\n }\n return !prevState;\n });\n }, []);\n const handleNavigateWithDays = React.useCallback((offset: number) => {\n setCalendarDisplayDate((prevDisplayDate) => {\n const daySelected = prevDisplayDate.clone().add(offset, 'day');\n setActiveDescendant(daySelected.format(TOKEN_ISO_FORMAT));\n return daySelected;\n });\n }, []);\n const handleNavigateWithWeeks = React.useCallback((when: 'start' | 'end') => {\n setCalendarDisplayDate((prevDisplayDate) => {\n let daySelected = prevDisplayDate;\n if (when === 'end') daySelected = prevDisplayDate.clone().endOf('week');\n if (when === 'start') daySelected = prevDisplayDate.clone().startOf('week');\n setActiveDescendant(daySelected.format(TOKEN_ISO_FORMAT));\n return daySelected;\n });\n }, []);\n\n const handleOnClickClearSelectedDate = React.useCallback(() => {\n props.onChange?.({\n target: { name: props.name, value: '' },\n } as React.ChangeEvent<HTMLInputElement>);\n setSelectedDate(null);\n setMaskValue('');\n handleCloseCalendar();\n }, [props.onChange]);\n\n const handleOnBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n props?.onBlur?.(event);\n handleCloseCalendar();\n setActiveDescendant((selectedDate ?? moment()).format(TOKEN_ISO_FORMAT));\n setCalendarDisplayDate(selectedDate ?? moment());\n if (_.size(unmaskedValue) !== 8) {\n const date = moment(_.toString(props?.value), TOKEN_ISO_FORMAT);\n if (date.isValid()) { setMaskValue(date.format('DD/MM/YYYY')); }\n }\n };\n\n const handleOnFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n props?.onFocus?.(event);\n setActiveDescendant((selectedDate ?? moment()).format(TOKEN_ISO_FORMAT));\n setCalendarDisplayDate(selectedDate ?? moment());\n if (!readOnly && openCalendarOnFocus) {\n handleOpenCalendar();\n }\n };\n\n const handleOnPaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n if (undigitable) {\n event.preventDefault();\n } else {\n props.onPaste?.(event);\n }\n };\n\n const handleOnBeforeInput = (event: React.InputEvent<HTMLInputElement>) => {\n if (undigitable) {\n event.preventDefault();\n } else {\n props.onBeforeInput?.(event);\n }\n };\n\n const handleOnKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n props?.onKeyDown?.(event);\n if (calendarBoxOpen && event.key && !event.shiftKey && \n !event.altKey && NAVIGATION_KEYS.includes(event.key)) {\n event.preventDefault();\n switch (event.key) {\n case Keys.arrowLeft: handleNavigateWithDays(-1);\n break;\n case Keys.arrowRight: handleNavigateWithDays(1);\n break;\n case Keys.arrowUp: handleNavigateWithDays(-7);\n break;\n case Keys.arrowDown: handleNavigateWithDays(7);\n break;\n case Keys.pageUp: handleNextMonth();\n break;\n case Keys.pageDown: handlePreviousMonth();\n break;\n case Keys.home: handleNavigateWithWeeks('start');\n break;\n case Keys.end: handleNavigateWithWeeks('end');\n break;\n case Keys.escape: handleCloseCalendar();\n break;\n case Keys.enter: handleUpdateDateState(\n moment(_.toString(activeDescendant), TOKEN_ISO_FORMAT),\n );\n break;\n default:\n break;\n }\n }\n };\n\n React.useEffect(() => {\n const currentValue = props?.value ?? null;\n const date = moment(_.toString(currentValue), TOKEN_ISO_FORMAT);\n setSelectedDate(date.isValid() ? date : null);\n setMaskValue(date.format(TOKEN_PTBR_FORMAT));\n }, [props?.value]);\n\n const contextValues = ({\n label, inputFieldId: inputId, activeDescendant, calendarBoxOpen, \n isReadOnly: Boolean(readOnly), isDisabled: Boolean(disabled), skeletonize, showCalendarButton,\n hasValidDateSelected, dateInputRef, dateContainerRef, handleOpenCalendar, \n handleCloseCalendar, handleNextMonth, handlePreviousMonth, \n handleSelectDate: handleUpdateDateState, selectedDate, unmaskedValue, maskedValue, \n showClearDateButton, handleChangeCalendarBoxState, handleOnClickClearSelectedDate,\n calendarDisplayDate, calendarRef,\n });\n\n return (\n <React.Fragment>\n <DateFieldContext.Provider value={contextValues}>\n <BaseDate.Root\n ref={inputRootRef}\n data-testid=\"test-date-field-root\"\n customClassWrapper={customClassWrapper}\n hasValidationErrors={hasValidationErrors}>\n {hasLabel && (\n <BaseDate.Label\n data-testid=\"test-date-field-label\"\n label={label}\n inputId={inputId}\n hint={props?.hint}\n isDisabled={disabled}\n isReadOnly={readOnly}\n skeletonize={skeletonize}\n required={props?.required}\n hintPosition={hintPosition}\n themePopover={themePopover}\n popoverAlign={popoverAlign}\n labelUppercase={labelUppercase}\n hasHintMessages={hasHintMessages}\n customClassLabel={customClassLabel} />\n )}\n <BaseDate.Container\n ref={dateContainerRef}\n skeletonize={skeletonize}\n customClassInputContainer={customClassInputContainer}>\n <BaseDate.Input\n {...rest}\n ref={mergeRefs(ref, dateInputRef)}\n id={inputId}\n name={props?.name}\n value={maskedValue}\n readOnly={readOnly}\n disabled={disabled}\n customClass={customClass}\n tabIndex={(!readOnly && !skeletonize) ? 0 : -1}\n placeholder={placeholder}\n aria-activedescendant={activeDescendant}\n aria-expanded={calendarBoxOpen}\n aria-controls={inputId}\n aria-labelledby={inputId}\n data-state-is-period-input={false}\n data-testid=\"test-date-field-input\"\n data-state-error={hasValidationErrors}\n data-state-read-only={readOnly}\n data-state-text-align={textAlign}\n data-state-undigitable={undigitable}\n data-state-skeletonize={skeletonize}\n onBlur={handleOnBlur}\n onFocus={handleOnFocus}\n onPaste={handleOnPaste}\n onKeyDown={handleOnKeyDown}\n onBeforeInput={handleOnBeforeInput} />\n <Triggers />\n </BaseDate.Container>\n {calendarBoxOpen &&\n createPortal(<CalendarBox ref={calendarRef} />, document.body)\n }\n {hintPosition === 'below' && (\n <Hint\n customClass=\"hint\"\n description={props.hint}\n disabled={disabled}\n skeletonize={skeletonize}\n visible={hasHintMessages} />\n )}\n {hasValidationErrors && (\n <span\n data-testid=\"test-date-field-list-errors\"\n className=\"error\"\n data-state-skeletonize={skeletonize}\n aria-describedby={String(props.name).concat('-errors')}>\n {errors?.map((error, index) => (\n <React.Fragment key={`${index + 1}-${error}`}>\n {error}\n {' '}\n </React.Fragment>\n ))}\n </span>\n )}\n </BaseDate.Root>\n </DateFieldContext.Provider>\n <Tooltip\n targetRef={inputRootRef}\n text={tooltip}\n width={tooltipWidth}\n position={tooltipPosition} />\n </React.Fragment>\n );\n });\n\nInputBase.displayName = 'DateFieldInputBase';\n"],"names":["InputBase","React","forwardRef","props","ref","label","errors","tooltip","tooltipPosition","tooltipWidth","shouldCloseOnSelect","returnValueType","customClass","customClassLabel","customClassWrapper","customClassInputContainer","textAlign","labelUppercase","skeletonize","hintPosition","themePopover","popoverAlign","showCalendarButton","openCalendarOnFocus","undigitable","showClearDateButton","placeholder","TOKEN_PTBR_FORMAT","readOnly","disabled","rest","calendarBoxOpen","setCalendarBoxOpen","useState","activeDescendant","setActiveDescendant","moment","format","TOKEN_ISO_FORMAT","selectedDate","setSelectedDate","calendarDisplayDate","setCalendarDisplayDate","calendarRef","useRef","inputRootRef","dateInputRef","dateContainerRef","setValue","setMaskValue","unmaskedValue","value","maskedValue","useIMask","mask","TOKEN_MASK","lazy","placeholderChar","defaultValue","onComplete","date","isValid","handleUpdateDateState","inputId","useMemo","id","name","uuid","hasLabel","_","isEmpty","hasHintMessages","Boolean","hint","length","hasValidationErrors","hasValidDateSelected","useCallback","nonIsoDateFormat","isoDateFormat","toISOString","clone","onChange","target","handleCloseCalendar","handleOpenCalendar","handleNextMonth","prevDisplayDate","add","handlePreviousMonth","subtract","handleChangeCalendarBoxState","prevState","current","document","activeElement","focus","handleNavigateWithDays","offset","daySelected","handleNavigateWithWeeks","when","endOf","startOf","handleOnClickClearSelectedDate","handleOnBlur","event","onBlur","size","toString","handleOnFocus","onFocus","handleOnPaste","preventDefault","onPaste","handleOnBeforeInput","onBeforeInput","handleOnKeyDown","onKeyDown","key","shiftKey","altKey","NAVIGATION_KEYS","includes","Keys","arrowLeft","arrowRight","arrowUp","arrowDown","pageUp","pageDown","home","end","escape","enter","useEffect","currentValue","contextValues","inputFieldId","isReadOnly","isDisabled","handleSelectDate","jsxs","jsx","DateFieldContext","BaseDate.Root","BaseDate.Label","required","BaseDate.Container","BaseDate.Input","mergeRefs","Triggers","createPortal","CalendarBox","body","Hint","String","concat","map","error","index","Tooltip","displayName"],"mappings":";;;;;;;;;;;;;;;;AAiBO,MAAMA,KACXC,EAAMC,WAAsD,CAACC,GAAOC,MAAQ;AAC1E,QAAM;AAAA,IACJC,OAAAA;AAAAA,IAAOC,QAAAA;AAAAA,IAAQC,SAAAA;AAAAA,IAASC,iBAAAA;AAAAA,IAAiBC,cAAAA;AAAAA,IAAcC,qBAAAA,IAAsB;AAAA,IAAMC,iBAAAA,IAAkB;AAAA,IACrGC,aAAAA,IAAc;AAAA,IAAIC,kBAAAA,IAAmB;AAAA,IAAIC,oBAAAA,IAAqB;AAAA,IAAIC,2BAAAA,IAA4B;AAAA,IAAIC,WAAAA,IAAY;AAAA,IAC9GC,gBAAAA,KAAiB;AAAA,IAAOC,aAAAA,IAAc;AAAA,IAAOC,cAAAA,IAAe;AAAA,IAASC,cAAAA,KAAe;AAAA,IACpFC,cAAAA,KAAe;AAAA,IAAQC,oBAAAA,KAAqB;AAAA,IAAMC,qBAAAA,KAAsB;AAAA,IAAMC,aAAAA,IAAc;AAAA,IAC5FC,qBAAAA,KAAsB;AAAA,IAAMC,aAAAA,KAAcC;AAAAA,IAAmBC,UAAAA;AAAAA,IAAUC,UAAAA;AAAAA,IAAU,GAAGC;AAAAA,EAAAA,IAClF3B,GACE,CAAC4B,GAAiBC,CAAkB,IAAI/B,EAAMgC,SAAS,EAAK,GAC5D,CAACC,GAAkBC,CAAmB,IAAIlC,EAAMgC,SACpDG,EAAAA,EAASC,OAAOC,CAAgB,CAClC,GACM,CAACC,GAAcC,CAAe,IAAIvC,EAAMgC,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