linear-react-components-ui 1.1.22 → 1.1.24-beta.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.
- package/lib/@types/ColorStyles.d.ts +2 -1
- package/lib/@types/Position.d.ts +2 -1
- package/lib/BaseMask-3d5d581d.d.ts +24 -0
- package/lib/BaseNumber-797088d7.d.ts +23 -0
- package/lib/Cnpj-1602be21.d.ts +18 -0
- package/lib/Cpf-4d6b9079.d.ts +18 -0
- package/lib/Currency-b33d3a22.d.ts +18 -0
- package/lib/Decimal-55e836d5.d.ts +13 -0
- package/lib/Number-9c6aceff.d.ts +20 -0
- package/lib/Phone-79e5e3b4.d.ts +18 -0
- package/lib/ZipCode-8c2e9d8b.d.ts +13 -0
- package/lib/assets/styles/checkbox2.scss +199 -0
- package/lib/assets/styles/colorpicker.scss +1 -6
- package/lib/assets/styles/colors.scss +48 -12
- package/lib/assets/styles/datepicker2.scss +338 -0
- package/lib/assets/styles/label.scss +4 -2
- package/lib/assets/styles/select.scss +19 -15
- package/lib/assets/styles/selectfield.scss +409 -0
- package/lib/assets/styles/slot.scss +34 -0
- package/lib/assets/styles/textfield.scss +148 -0
- package/lib/buttons/ActivateButton.d.ts +1 -0
- package/lib/buttons/AddButton.d.ts +1 -0
- package/lib/buttons/Button.d.ts +1 -0
- package/lib/buttons/CancelButton.d.ts +1 -0
- package/lib/buttons/DangerButton.d.ts +1 -0
- package/lib/buttons/DefaultButton.d.ts +1 -0
- package/lib/buttons/DefaultButton.js +20 -12
- package/lib/buttons/DestroyButton.d.ts +1 -0
- package/lib/buttons/EditButton.d.ts +1 -0
- package/lib/buttons/InactivateButton.d.ts +1 -0
- package/lib/buttons/InfoButton.d.ts +1 -0
- package/lib/buttons/PrimaryButton.d.ts +1 -0
- package/lib/buttons/RestoreButton.d.ts +1 -0
- package/lib/buttons/SaveButton.d.ts +1 -0
- package/lib/buttons/SuccessButton.d.ts +1 -0
- package/lib/buttons/WarningButton.d.ts +1 -0
- package/lib/buttons/index.d.ts +1 -0
- package/lib/buttons/split_button/index.d.ts +1 -0
- package/lib/buttons/types.d.ts +2 -5
- package/lib/drawer/Drawer.js +10 -6
- package/lib/form/Field.d.ts +1 -1
- package/lib/form/FieldArray.d.ts +1 -1
- package/lib/form/FieldNumber.d.ts +1 -1
- package/lib/form/FieldPeriod.d.ts +1 -1
- package/lib/form/helpers.d.ts +1 -1
- package/lib/form/index.d.ts +1 -1
- package/lib/form/types.d.ts +1 -1
- package/lib/form/withFieldHOC.d.ts +1 -1
- package/lib/form/withFormSecurity.d.ts +1 -1
- package/lib/form2/helpers.d.ts +8 -0
- package/lib/form2/helpers.js +41 -0
- package/lib/form2/index.d.ts +9 -0
- package/lib/form2/index.js +36 -0
- package/lib/form2/types.d.ts +125 -0
- package/lib/form2/types.js +5 -0
- package/lib/form2/useForm/index.d.ts +5 -0
- package/lib/form2/useForm/index.js +203 -0
- package/lib/icons/helper.d.ts +4 -0
- package/lib/icons/helper.js +4 -0
- package/lib/icons/index.d.ts +4 -6
- package/lib/icons/index.js +14 -9
- package/lib/icons/types.d.ts +3 -6
- package/lib/index-18a64236.d.ts +23 -0
- package/lib/index-368f781f.d.ts +15 -0
- package/lib/index-43ad8140.d.ts +41 -0
- package/lib/index-772f9f1a.d.ts +44 -0
- package/lib/index-8a59cf4b.d.ts +23 -0
- package/lib/index-c9247c1f.d.ts +15 -0
- package/lib/index.d.ts +1 -0
- package/lib/inputs/base/InputTextBase.d.ts +1 -1
- package/lib/inputs/base/InputTextBase.js +18 -8
- package/lib/inputs/base/helpers.d.ts +1 -1
- package/lib/inputs/base/types.d.ts +5 -16
- package/lib/inputs/color/index.js +1 -1
- package/lib/inputs/color/types.d.ts +1 -1
- package/lib/inputs/date/Dialog.d.ts +1 -1
- package/lib/inputs/date/Dropdown.d.ts +1 -1
- package/lib/inputs/date/index.d.ts +1 -1
- package/lib/inputs/date/types.d.ts +2 -2
- package/lib/inputs/errorMessage/index.d.ts +1 -1
- package/lib/inputs/file/DefaultFile.d.ts +1 -1
- package/lib/inputs/file/DefaultFile.js +1 -1
- package/lib/inputs/file/DragDropFile.d.ts +1 -1
- package/lib/inputs/file/File.d.ts +1 -1
- package/lib/inputs/file/FileButtonSettings.d.ts +1 -1
- package/lib/inputs/file/helpers.d.ts +1 -1
- package/lib/inputs/file/index.d.ts +1 -1
- package/lib/inputs/file/types.d.ts +1 -1
- package/lib/inputs/inputHOC.d.ts +1 -1
- package/lib/inputs/mask/BaseMask.d.ts +1 -1
- package/lib/inputs/mask/BaseMask.js +9 -6
- package/lib/inputs/mask/Cnpj.d.ts +1 -1
- package/lib/inputs/mask/Cpf.d.ts +1 -1
- package/lib/inputs/mask/Phone.d.ts +1 -1
- package/lib/inputs/mask/ZipCode.d.ts +1 -1
- package/lib/inputs/mask/helpers.d.ts +1 -1
- package/lib/inputs/mask/helpers.js +1 -1
- package/lib/inputs/mask/index.d.ts +1 -1
- package/lib/inputs/mask/types.d.ts +2 -2
- package/lib/inputs/multiSelect/ActionButtons.d.ts +1 -1
- package/lib/inputs/multiSelect/Dropdown.d.ts +1 -1
- package/lib/inputs/multiSelect/helper.d.ts +1 -1
- package/lib/inputs/multiSelect/index.d.ts +1 -1
- package/lib/inputs/multiSelect/types.d.ts +2 -2
- package/lib/inputs/number/BaseNumber.d.ts +1 -1
- package/lib/inputs/number/BaseNumber.js +3 -2
- package/lib/inputs/number/Currency.d.ts +1 -1
- package/lib/inputs/number/Decimal.d.ts +1 -1
- package/lib/inputs/number/format_number.d.ts +1 -1
- package/lib/inputs/number/format_number.js +4 -2
- package/lib/inputs/number/index.d.ts +1 -1
- package/lib/inputs/number/types.d.ts +4 -4
- package/lib/inputs/period/Dialog.d.ts +1 -1
- package/lib/inputs/period/Dropdown.d.ts +1 -1
- package/lib/inputs/period/PeriodList.d.ts +1 -1
- package/lib/inputs/period/helper.d.ts +1 -1
- package/lib/inputs/period/index.d.ts +1 -1
- package/lib/inputs/period/index.js +8 -10
- package/lib/inputs/period/types.d.ts +2 -5
- package/lib/inputs/search/index.d.ts +1 -1
- package/lib/inputs/select/ActionButtons.d.ts +1 -1
- package/lib/inputs/select/Dropdown.d.ts +1 -1
- package/lib/inputs/select/helper.d.ts +1 -1
- package/lib/inputs/select/index.d.ts +1 -1
- package/lib/inputs/select/multiple/Selecteds.d.ts +2 -2
- package/lib/inputs/select/multiple/Selecteds.js +3 -1
- package/lib/inputs/select/multiple/index.d.ts +1 -1
- package/lib/inputs/select/multiple/index.js +3 -2
- package/lib/inputs/select/simple/index.d.ts +1 -1
- package/lib/inputs/select/simple/index.js +3 -3
- package/lib/inputs/select/types.d.ts +2 -1
- package/lib/inputs/text/index.d.ts +1 -1
- package/lib/inputs/text/types.d.ts +2 -3
- package/lib/inputs/textarea/index.d.ts +1 -1
- package/lib/inputs/textarea/types.d.ts +1 -1
- package/lib/inputs/types.d.ts +2 -2
- package/lib/inputs2/checkboxfield/index.d.ts +7 -0
- package/lib/inputs2/checkboxfield/index.js +146 -0
- package/lib/inputs2/colorfield/index.d.ts +9 -0
- package/lib/inputs2/colorfield/index.js +119 -0
- package/lib/inputs2/date/base/constants.d.ts +7 -0
- package/lib/inputs2/date/base/constants.js +43 -0
- package/lib/inputs2/date/base/index.d.ts +12 -0
- package/lib/inputs2/date/base/index.js +179 -0
- package/lib/inputs2/date/datefield/calendarbox.d.ts +7 -0
- package/lib/inputs2/date/datefield/calendarbox.js +115 -0
- package/lib/inputs2/date/datefield/context.d.ts +13 -0
- package/lib/inputs2/date/datefield/context.js +15 -0
- package/lib/inputs2/date/datefield/index.d.ts +9 -0
- package/lib/inputs2/date/datefield/index.js +334 -0
- package/lib/inputs2/date/datefield/triggers.d.ts +8 -0
- package/lib/inputs2/date/datefield/triggers.js +47 -0
- package/lib/inputs2/date/datefield/types.d.ts +61 -0
- package/lib/inputs2/date/datefield/types.js +5 -0
- package/lib/inputs2/date/dateperiodfield/calendarbox.d.ts +7 -0
- package/lib/inputs2/date/dateperiodfield/calendarbox.js +136 -0
- package/lib/inputs2/date/dateperiodfield/context.d.ts +13 -0
- package/lib/inputs2/date/dateperiodfield/context.js +17 -0
- package/lib/inputs2/date/dateperiodfield/index.d.ts +9 -0
- package/lib/inputs2/date/dateperiodfield/index.js +592 -0
- package/lib/inputs2/date/dateperiodfield/triggers.d.ts +6 -0
- package/lib/inputs2/date/dateperiodfield/triggers.js +120 -0
- package/lib/inputs2/date/dateperiodfield/types.d.ts +99 -0
- package/lib/inputs2/date/dateperiodfield/types.js +19 -0
- package/lib/inputs2/date/helpers.d.ts +20 -0
- package/lib/inputs2/date/helpers.js +62 -0
- package/lib/inputs2/date/types.d.ts +59 -0
- package/lib/inputs2/date/types.js +19 -0
- package/lib/inputs2/index.d.ts +29 -0
- package/lib/inputs2/index.js +38 -0
- package/lib/inputs2/mask/BaseMask.d.ts +10 -0
- package/lib/inputs2/mask/BaseMask.js +95 -0
- package/lib/inputs2/mask/Cnpj.d.ts +11 -0
- package/lib/inputs2/mask/Cnpj.js +57 -0
- package/lib/inputs2/mask/Cpf.d.ts +11 -0
- package/lib/inputs2/mask/Cpf.js +53 -0
- package/lib/inputs2/mask/Phone.d.ts +11 -0
- package/lib/inputs2/mask/Phone.js +26 -0
- package/lib/inputs2/mask/ZipCode.d.ts +11 -0
- package/lib/inputs2/mask/ZipCode.js +23 -0
- package/lib/inputs2/mask/helpers.d.ts +4 -0
- package/lib/inputs2/mask/helpers.js +57 -0
- package/lib/inputs2/number/BaseNumber.d.ts +10 -0
- package/lib/inputs2/number/BaseNumber.js +86 -0
- package/lib/inputs2/number/Currency.d.ts +11 -0
- package/lib/inputs2/number/Currency.js +47 -0
- package/lib/inputs2/number/Decimal.d.ts +11 -0
- package/lib/inputs2/number/Decimal.js +36 -0
- package/lib/inputs2/number/Number.d.ts +9 -0
- package/lib/inputs2/number/Number.js +49 -0
- package/lib/inputs2/number/format_number.d.ts +5 -0
- package/lib/inputs2/number/format_number.js +29 -0
- package/lib/inputs2/selectfield/context.d.ts +38 -0
- package/lib/inputs2/selectfield/context.js +15 -0
- package/lib/inputs2/selectfield/helpers.d.ts +6 -0
- package/lib/inputs2/selectfield/helpers.js +25 -0
- package/lib/inputs2/selectfield/index.d.ts +10 -0
- package/lib/inputs2/selectfield/index.js +491 -0
- package/lib/inputs2/selectfield/item.d.ts +11 -0
- package/lib/inputs2/selectfield/item.js +85 -0
- package/lib/inputs2/selectfield/listbox.d.ts +7 -0
- package/lib/inputs2/selectfield/listbox.js +103 -0
- package/lib/inputs2/selectfield/search.d.ts +7 -0
- package/lib/inputs2/selectfield/search.js +71 -0
- package/lib/inputs2/selectfield/selections.d.ts +10 -0
- package/lib/inputs2/selectfield/selections.js +86 -0
- package/lib/inputs2/selectfield/triggers.d.ts +8 -0
- package/lib/inputs2/selectfield/triggers.js +100 -0
- package/lib/inputs2/selectfield/types.d.ts +55 -0
- package/lib/inputs2/selectfield/types.js +21 -0
- package/lib/inputs2/slot/index.d.ts +14 -0
- package/lib/inputs2/slot/index.js +47 -0
- package/lib/inputs2/textfield/index.d.ts +8 -0
- package/lib/inputs2/textfield/index.js +159 -0
- package/lib/internals/types.d.ts +1 -17
- package/lib/labels/DangerLabel.d.ts +1 -0
- package/lib/labels/DefaultLabel.d.ts +3 -5
- package/lib/labels/DefaultLabel.js +15 -7
- package/lib/labels/InfoLabel.d.ts +1 -0
- package/lib/labels/PrimaryLabel.d.ts +1 -0
- package/lib/labels/SuccessLabel.d.ts +1 -0
- package/lib/labels/WarningLabel.d.ts +1 -0
- package/lib/labels/index.d.ts +3 -2
- package/lib/labels/types.d.ts +2 -5
- package/lib/list/Header.d.ts +1 -0
- package/lib/list/Item.d.ts +3 -5
- package/lib/list/Item.js +17 -12
- package/lib/list/helpers.d.ts +1 -0
- package/lib/list/index.d.ts +1 -0
- package/lib/list/types.d.ts +4 -6
- package/lib/menus/sidenav/ExpandMenu.d.ts +2 -2
- package/lib/menus/sidenav/MenuLink.d.ts +4 -7
- package/lib/menus/sidenav/MenuLink.js +20 -11
- package/lib/menus/sidenav/NavMenuGroup.d.ts +2 -2
- package/lib/menus/sidenav/NavMenuItem.d.ts +4 -7
- package/lib/menus/sidenav/NavMenuItem.js +16 -12
- package/lib/menus/sidenav/NavSubMenuItem.d.ts +2 -2
- package/lib/menus/sidenav/helpers.d.ts +2 -2
- package/lib/menus/sidenav/index.d.ts +2 -2
- package/lib/menus/sidenav/popup_menu_search/EmptyList.d.ts +2 -2
- package/lib/menus/sidenav/popup_menu_search/index.d.ts +2 -2
- package/lib/menus/sidenav/types.d.ts +6 -6
- package/lib/popover/PopoverText.js +11 -2
- package/lib/popover/types.d.ts +1 -0
- package/lib/textContent/index.d.ts +6 -11
- package/lib/textContent/index.js +20 -11
- package/lib/tooltip/TooltipContent.d.ts +7 -0
- package/lib/tooltip/TooltipContent.js +65 -0
- package/lib/tooltip/index.d.ts +4 -3
- package/lib/tooltip/index.js +36 -53
- package/lib/tooltip/types.d.ts +25 -3
- package/lib/tooltip/useTooltip.d.ts +30 -0
- package/lib/tooltip/useTooltip.js +128 -0
- package/package.json +4 -3
- package/lib/inputs/base/Label.d.ts +0 -14
- package/lib/inputs/base/Label.js +0 -35
- package/lib/internals/withTooltip.d.ts +0 -12
- package/lib/internals/withTooltip.js +0 -172
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Triggers = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
9
|
+
var _buttons = _interopRequireDefault(require("../../../buttons"));
|
|
10
|
+
var BaseDate = _interopRequireWildcard(require("../base"));
|
|
11
|
+
var _list = _interopRequireWildcard(require("../../../list"));
|
|
12
|
+
var _context = require("./context");
|
|
13
|
+
var _helpers = require("../helpers");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
const Triggers = () => {
|
|
18
|
+
const {
|
|
19
|
+
initialInputId,
|
|
20
|
+
initialInputRef,
|
|
21
|
+
finalInputRef,
|
|
22
|
+
isReadOnly,
|
|
23
|
+
isDisabled,
|
|
24
|
+
selectedDate,
|
|
25
|
+
calendarBoxOpen,
|
|
26
|
+
showCalendarButton,
|
|
27
|
+
skeletonize,
|
|
28
|
+
showPredefinedPeriodsButton,
|
|
29
|
+
showClearDateButton,
|
|
30
|
+
hasValidPeriodSelected,
|
|
31
|
+
handleChangeCalendarBoxState,
|
|
32
|
+
handleChangeActiveDescendant,
|
|
33
|
+
handleChangeCalendarDisplayDate,
|
|
34
|
+
handleOnClickClearSelectedPeriod,
|
|
35
|
+
handleChangeUpdateDateStateWithPredefinedPeriod
|
|
36
|
+
} = (0, _context.useDatePeriodFieldContext)();
|
|
37
|
+
const shouldHavePermitClickOnTrigger = !isReadOnly && !isDisabled;
|
|
38
|
+
const handleOnClickTriggerSelectPredefinedPeriods = (event, periodSelected) => {
|
|
39
|
+
if (!shouldHavePermitClickOnTrigger) event?.preventDefault?.();else {
|
|
40
|
+
if (periodSelected) handleChangeUpdateDateStateWithPredefinedPeriod(periodSelected);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const handleOnClickTriggerCalendar = event => {
|
|
44
|
+
if (!shouldHavePermitClickOnTrigger) event.preventDefault();else {
|
|
45
|
+
handleChangeCalendarBoxState(!calendarBoxOpen);
|
|
46
|
+
if (!calendarBoxOpen) {
|
|
47
|
+
switch (document.activeElement?.id) {
|
|
48
|
+
case initialInputRef.current?.id:
|
|
49
|
+
{
|
|
50
|
+
handleChangeActiveDescendant((selectedDate.inicial ?? (0, _moment.default)()).format(_helpers.TOKEN_ISO_FORMAT));
|
|
51
|
+
handleChangeCalendarDisplayDate(selectedDate.inicial ?? (0, _moment.default)());
|
|
52
|
+
initialInputRef.current?.focus();
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case finalInputRef.current?.id:
|
|
56
|
+
{
|
|
57
|
+
handleChangeActiveDescendant((selectedDate.final ?? (0, _moment.default)()).format(_helpers.TOKEN_ISO_FORMAT));
|
|
58
|
+
handleChangeCalendarDisplayDate(selectedDate.final ?? (0, _moment.default)());
|
|
59
|
+
finalInputRef.current?.focus();
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
default:
|
|
63
|
+
initialInputRef.current?.focus();
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return /*#__PURE__*/_react.default.createElement(BaseDate.Triggers, {
|
|
70
|
+
clearButtonTestId: "test-date-period-field-trigger-clean-selected-period",
|
|
71
|
+
calendarButtonTestId: "test-date-period-field-trigger-open-calendar",
|
|
72
|
+
isDisabled: isDisabled,
|
|
73
|
+
isReadOnly: isReadOnly,
|
|
74
|
+
skeletonize: skeletonize,
|
|
75
|
+
inputFieldId: initialInputId,
|
|
76
|
+
calendarBoxOpen: calendarBoxOpen,
|
|
77
|
+
showClearButton: showClearDateButton,
|
|
78
|
+
showCalendarButton: showCalendarButton,
|
|
79
|
+
hasValidDateSelection: false,
|
|
80
|
+
hasValidPeriodSelected: hasValidPeriodSelected,
|
|
81
|
+
onClearSelectedDate: handleOnClickClearSelectedPeriod,
|
|
82
|
+
onClickTriggerCalendar: handleOnClickTriggerCalendar
|
|
83
|
+
}, /*#__PURE__*/_react.default.createElement(_buttons.default, {
|
|
84
|
+
"data-testid": "test-date-period-field-trigger-select-predefined-periods",
|
|
85
|
+
className: "select-predefined-periods",
|
|
86
|
+
dropdown: true,
|
|
87
|
+
transparent: true,
|
|
88
|
+
boxShadow: false,
|
|
89
|
+
showIconDropdown: false,
|
|
90
|
+
visible: showPredefinedPeriodsButton,
|
|
91
|
+
type: "button",
|
|
92
|
+
title: "Selecionar Periodos Pr\xE9 Definidos",
|
|
93
|
+
tabIndex: -1,
|
|
94
|
+
disabled: isDisabled,
|
|
95
|
+
"aria-label": "Selecionar Periodos Pr\xE9 Definidos",
|
|
96
|
+
"aria-controls": initialInputId,
|
|
97
|
+
"aria-readonly": isReadOnly,
|
|
98
|
+
"data-state-read-only": isReadOnly,
|
|
99
|
+
"data-state-visible": showPredefinedPeriodsButton,
|
|
100
|
+
iconName: "more1",
|
|
101
|
+
dropdownAlign: "right",
|
|
102
|
+
onMouseDown: event => {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
}
|
|
105
|
+
}, /*#__PURE__*/_react.default.createElement(_list.default, {
|
|
106
|
+
condensed: true
|
|
107
|
+
}, _helpers.PERIOD_OPTIONS_LIST.map(period => /*#__PURE__*/_react.default.createElement(_list.ListItem, {
|
|
108
|
+
key: period.id,
|
|
109
|
+
itemId: period.id,
|
|
110
|
+
text: period.label,
|
|
111
|
+
onMouseDown: event => {
|
|
112
|
+
event?.preventDefault?.();
|
|
113
|
+
},
|
|
114
|
+
onClick: event => {
|
|
115
|
+
handleOnClickTriggerSelectPredefinedPeriods(event, period.id);
|
|
116
|
+
}
|
|
117
|
+
})))));
|
|
118
|
+
};
|
|
119
|
+
exports.Triggers = Triggers;
|
|
120
|
+
Triggers.displayName = 'DatePeriodFieldTriggers';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { Moment } from 'moment';
|
|
3
|
+
import { TextAlign } from '../../../@types/Align.js';
|
|
4
|
+
import { ColorTheme } from '../../../@types/ColorStyles.js';
|
|
5
|
+
import { ITooltipCommonProps } from '../../../tooltip/types.js';
|
|
6
|
+
import { HintPosition, Position } from '../../../@types/Position.js';
|
|
7
|
+
import { PermissionAttr, OnDenied } from '../../../@types/PermissionAttr.js';
|
|
8
|
+
|
|
9
|
+
type DatePeriodTypes = 'today' | 'week' | 'lastweek' | 'last15' | 'month' | 'lastmonth';
|
|
10
|
+
type PeriodOptions = {
|
|
11
|
+
id: DatePeriodTypes;
|
|
12
|
+
label?: string;
|
|
13
|
+
};
|
|
14
|
+
type InputType = 'initial' | 'final';
|
|
15
|
+
type SelectedDateType = {
|
|
16
|
+
inicial: Moment | null;
|
|
17
|
+
final: Moment | null;
|
|
18
|
+
};
|
|
19
|
+
type UpdateDateStateParams = {
|
|
20
|
+
date: Moment;
|
|
21
|
+
inputType: InputType;
|
|
22
|
+
typing?: boolean;
|
|
23
|
+
};
|
|
24
|
+
type InputHTMLProps = Omit<React__default.ComponentPropsWithoutRef<'input'>, 'type' | 'multiple' | 'value'>;
|
|
25
|
+
interface DatePeriodFieldProps extends InputHTMLProps, ITooltipCommonProps {
|
|
26
|
+
value?: any;
|
|
27
|
+
initialName?: string;
|
|
28
|
+
initialRef?: React__default.MutableRefObject<HTMLInputElement | null>;
|
|
29
|
+
finalName?: string;
|
|
30
|
+
finalRef?: React__default.MutableRefObject<HTMLInputElement | null>;
|
|
31
|
+
hint?: string;
|
|
32
|
+
label?: string;
|
|
33
|
+
errors?: string[];
|
|
34
|
+
gridLayout?: string;
|
|
35
|
+
customClass?: string;
|
|
36
|
+
customClassLabel?: string;
|
|
37
|
+
customClassWrapper?: string;
|
|
38
|
+
customClassInputContainer?: string;
|
|
39
|
+
required?: boolean;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
readOnly?: boolean;
|
|
42
|
+
undigitable?: boolean;
|
|
43
|
+
skeletonize?: boolean;
|
|
44
|
+
labelUppercase?: boolean;
|
|
45
|
+
showCalendarButton?: boolean;
|
|
46
|
+
openCalendarOnFocus?: boolean;
|
|
47
|
+
shouldCloseOnSelect?: boolean;
|
|
48
|
+
showClearDateButton?: boolean;
|
|
49
|
+
showPredefinedPeriodsButton?: boolean;
|
|
50
|
+
textAlign?: TextAlign;
|
|
51
|
+
hintPosition?: HintPosition;
|
|
52
|
+
themePopover?: ColorTheme;
|
|
53
|
+
popoverAlign?: Extract<Position, 'left' | 'right'>;
|
|
54
|
+
permissionAttr?: PermissionAttr;
|
|
55
|
+
onDeniedActions?: OnDenied;
|
|
56
|
+
}
|
|
57
|
+
interface DatePeriodContextProps {
|
|
58
|
+
initialInputId: string;
|
|
59
|
+
finalInputId: string;
|
|
60
|
+
activeDescendant: string;
|
|
61
|
+
isReadOnly: boolean;
|
|
62
|
+
isDisabled: boolean;
|
|
63
|
+
undigitable: boolean;
|
|
64
|
+
skeletonize: boolean;
|
|
65
|
+
calendarBoxOpen: boolean;
|
|
66
|
+
showCalendarButton: boolean;
|
|
67
|
+
openCalendarOnFocus: boolean;
|
|
68
|
+
hasValidationErrors: boolean;
|
|
69
|
+
showClearDateButton: boolean;
|
|
70
|
+
hasValidPeriodSelected: boolean;
|
|
71
|
+
showPredefinedPeriodsButton: boolean;
|
|
72
|
+
selectedDate: SelectedDateType;
|
|
73
|
+
calendarDisplayDate: Moment;
|
|
74
|
+
initialInputRef: React__default.RefObject<HTMLInputElement | null>;
|
|
75
|
+
finalInputRef: React__default.RefObject<HTMLInputElement | null>;
|
|
76
|
+
dateContainerRef: React__default.RefObject<HTMLDivElement | null>;
|
|
77
|
+
handleChangeUpdateDateState: (params: UpdateDateStateParams) => void;
|
|
78
|
+
handleChangeNextMonth: () => void;
|
|
79
|
+
handleChangePreviousMonth: () => void;
|
|
80
|
+
handleChangeCalendarBoxState: (value: boolean) => void;
|
|
81
|
+
handleChangeActiveDescendant: (value: string) => void;
|
|
82
|
+
handleChangeCalendarDisplayDate: (value: Moment) => void;
|
|
83
|
+
handleOnClickClearSelectedPeriod: () => void;
|
|
84
|
+
handleChangeUpdateDateStateWithPredefinedPeriod: (period: DatePeriodTypes) => void;
|
|
85
|
+
}
|
|
86
|
+
declare enum Keys {
|
|
87
|
+
arrowLeft = "ArrowLeft",
|
|
88
|
+
arrowRight = "ArrowRight",
|
|
89
|
+
arrowUp = "ArrowUp",
|
|
90
|
+
arrowDown = "ArrowDown",
|
|
91
|
+
pageUp = "PageUp",
|
|
92
|
+
pageDown = "PageDown",
|
|
93
|
+
home = "Home",
|
|
94
|
+
end = "End",
|
|
95
|
+
escape = "Escape",
|
|
96
|
+
enter = "Enter"
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { DatePeriodContextProps, DatePeriodFieldProps, DatePeriodTypes, InputType, Keys, PeriodOptions, SelectedDateType, UpdateDateStateParams };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Keys = void 0;
|
|
7
|
+
let Keys = exports.Keys = /*#__PURE__*/function (Keys) {
|
|
8
|
+
Keys["arrowLeft"] = "ArrowLeft";
|
|
9
|
+
Keys["arrowRight"] = "ArrowRight";
|
|
10
|
+
Keys["arrowUp"] = "ArrowUp";
|
|
11
|
+
Keys["arrowDown"] = "ArrowDown";
|
|
12
|
+
Keys["pageUp"] = "PageUp";
|
|
13
|
+
Keys["pageDown"] = "PageDown";
|
|
14
|
+
Keys["home"] = "Home";
|
|
15
|
+
Keys["end"] = "End";
|
|
16
|
+
Keys["escape"] = "Escape";
|
|
17
|
+
Keys["enter"] = "Enter";
|
|
18
|
+
return Keys;
|
|
19
|
+
}({});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as lodash from 'lodash';
|
|
2
|
+
import { Moment } from 'moment';
|
|
3
|
+
import { PeriodOptions } from './dateperiodfield/types.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '../../@types/Align.js';
|
|
6
|
+
import '../../@types/ColorStyles.js';
|
|
7
|
+
import '../../tooltip/types.js';
|
|
8
|
+
import '../../@types/Position.js';
|
|
9
|
+
import '../../@types/PermissionAttr.js';
|
|
10
|
+
|
|
11
|
+
declare const TOKEN_MASK = "00/00/0000";
|
|
12
|
+
declare const TOKEN_ISO_FORMAT = "YYYY-MM-DD";
|
|
13
|
+
declare const TOKEN_PTBR_FORMAT = "DD/MM/YYYY";
|
|
14
|
+
declare const options: string[];
|
|
15
|
+
declare const NAVIGATION_KEYS: string[];
|
|
16
|
+
declare const PERIOD_OPTIONS_LIST: PeriodOptions[];
|
|
17
|
+
declare const isWithinBounds: (date: Moment, minDate?: string, maxDate?: string) => boolean;
|
|
18
|
+
declare const generateCalendarWeeks: ((monthSelected: Moment) => Moment[][]) & lodash.MemoizedFunction;
|
|
19
|
+
|
|
20
|
+
export { NAVIGATION_KEYS, PERIOD_OPTIONS_LIST, TOKEN_ISO_FORMAT, TOKEN_MASK, TOKEN_PTBR_FORMAT, generateCalendarWeeks, isWithinBounds, options };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.options = exports.isWithinBounds = exports.generateCalendarWeeks = exports.TOKEN_PTBR_FORMAT = exports.TOKEN_MASK = exports.TOKEN_ISO_FORMAT = exports.PERIOD_OPTIONS_LIST = exports.NAVIGATION_KEYS = void 0;
|
|
7
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
8
|
+
var _memoize = _interopRequireDefault(require("lodash/memoize"));
|
|
9
|
+
var _permissionValidations = require("../../permissionValidations");
|
|
10
|
+
var _types = require("./types");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const TOKEN_MASK = exports.TOKEN_MASK = '00/00/0000';
|
|
13
|
+
const TOKEN_ISO_FORMAT = exports.TOKEN_ISO_FORMAT = 'YYYY-MM-DD';
|
|
14
|
+
const TOKEN_PTBR_FORMAT = exports.TOKEN_PTBR_FORMAT = 'DD/MM/YYYY';
|
|
15
|
+
const options = exports.options = [_permissionValidations.OPTIONS_ON_DENIED.disabled, _permissionValidations.OPTIONS_ON_DENIED.unvisible, _permissionValidations.OPTIONS_ON_DENIED.readOnly, _permissionValidations.OPTIONS_ON_DENIED.hideContent];
|
|
16
|
+
const NAVIGATION_KEYS = exports.NAVIGATION_KEYS = [_types.Keys.arrowLeft, _types.Keys.arrowRight, _types.Keys.arrowUp, _types.Keys.arrowDown, _types.Keys.pageUp, _types.Keys.pageDown, _types.Keys.home, _types.Keys.end, _types.Keys.escape, _types.Keys.enter];
|
|
17
|
+
const PERIOD_OPTIONS_LIST = exports.PERIOD_OPTIONS_LIST = [{
|
|
18
|
+
id: 'today',
|
|
19
|
+
label: 'Hoje'
|
|
20
|
+
}, {
|
|
21
|
+
id: 'week',
|
|
22
|
+
label: 'Semana Atual'
|
|
23
|
+
}, {
|
|
24
|
+
id: 'lastweek',
|
|
25
|
+
label: 'Última Semana'
|
|
26
|
+
}, {
|
|
27
|
+
id: 'last15',
|
|
28
|
+
label: 'Últimos 15 dias'
|
|
29
|
+
}, {
|
|
30
|
+
id: 'month',
|
|
31
|
+
label: 'Mês atual'
|
|
32
|
+
}, {
|
|
33
|
+
id: 'lastmonth',
|
|
34
|
+
label: 'Último Mês'
|
|
35
|
+
}];
|
|
36
|
+
const isWithinBounds = (date, minDate, maxDate) => {
|
|
37
|
+
if (minDate) {
|
|
38
|
+
const min = (0, _moment.default)(minDate, TOKEN_ISO_FORMAT);
|
|
39
|
+
if (date.isBefore(min, 'day')) return false;
|
|
40
|
+
}
|
|
41
|
+
if (maxDate) {
|
|
42
|
+
const max = (0, _moment.default)(maxDate, TOKEN_ISO_FORMAT);
|
|
43
|
+
if (date.isAfter(max, 'day')) return false;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
exports.isWithinBounds = isWithinBounds;
|
|
48
|
+
const generateCalendarWeeks = exports.generateCalendarWeeks = (0, _memoize.default)(monthSelected => {
|
|
49
|
+
const startOfCalendar = monthSelected.clone().startOf('month').startOf('week');
|
|
50
|
+
const endOfCalendar = monthSelected.clone().endOf('month').endOf('week');
|
|
51
|
+
const weeks = [];
|
|
52
|
+
let currentWeek = startOfCalendar.clone();
|
|
53
|
+
while (currentWeek.isSameOrBefore(endOfCalendar, 'day')) {
|
|
54
|
+
const week = [];
|
|
55
|
+
for (let days = 0; days < 7; days++) {
|
|
56
|
+
week.push(currentWeek.clone());
|
|
57
|
+
currentWeek.add(1, 'day');
|
|
58
|
+
}
|
|
59
|
+
weeks.push(week);
|
|
60
|
+
}
|
|
61
|
+
return weeks;
|
|
62
|
+
}, monthSelected => monthSelected.format('YYYY-MM'));
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ColorTheme } from '../../@types/ColorStyles.js';
|
|
2
|
+
import { HintPosition, Position } from '../../@types/Position.js';
|
|
3
|
+
|
|
4
|
+
declare enum Keys {
|
|
5
|
+
arrowLeft = "ArrowLeft",
|
|
6
|
+
arrowRight = "ArrowRight",
|
|
7
|
+
arrowUp = "ArrowUp",
|
|
8
|
+
arrowDown = "ArrowDown",
|
|
9
|
+
pageUp = "PageUp",
|
|
10
|
+
pageDown = "PageDown",
|
|
11
|
+
home = "Home",
|
|
12
|
+
end = "End",
|
|
13
|
+
escape = "Escape",
|
|
14
|
+
enter = "Enter"
|
|
15
|
+
}
|
|
16
|
+
interface BaseDateInputRootProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
17
|
+
customClassWrapper?: string;
|
|
18
|
+
hasValidationErrors?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface BaseDateInputLabelProps extends React.ComponentPropsWithoutRef<'span'> {
|
|
21
|
+
hint?: string;
|
|
22
|
+
customClassLabel?: string;
|
|
23
|
+
skeletonize?: boolean;
|
|
24
|
+
label?: string;
|
|
25
|
+
inputId?: string;
|
|
26
|
+
isDisabled?: boolean;
|
|
27
|
+
isReadOnly?: boolean;
|
|
28
|
+
required?: boolean;
|
|
29
|
+
labelUppercase?: boolean;
|
|
30
|
+
hasHintMessages?: boolean;
|
|
31
|
+
hintPosition?: HintPosition;
|
|
32
|
+
themePopover?: ColorTheme;
|
|
33
|
+
popoverAlign?: Extract<Position, 'left' | 'right'>;
|
|
34
|
+
}
|
|
35
|
+
interface BaseDateInputContainerProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
36
|
+
skeletonize?: boolean;
|
|
37
|
+
customClassInputContainer?: string;
|
|
38
|
+
}
|
|
39
|
+
type InputHTMLProps = Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'multiple'>;
|
|
40
|
+
interface BaseDateInputProps extends InputHTMLProps {
|
|
41
|
+
customClass?: string;
|
|
42
|
+
}
|
|
43
|
+
interface BaseDateInputTriggersProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
44
|
+
isDisabled?: boolean;
|
|
45
|
+
isReadOnly?: boolean;
|
|
46
|
+
skeletonize?: boolean;
|
|
47
|
+
inputFieldId?: string;
|
|
48
|
+
calendarBoxOpen?: boolean;
|
|
49
|
+
showClearButton?: boolean;
|
|
50
|
+
showCalendarButton?: boolean;
|
|
51
|
+
hasValidDateSelection?: boolean;
|
|
52
|
+
hasValidPeriodSelected?: boolean;
|
|
53
|
+
clearButtonTestId?: string;
|
|
54
|
+
calendarButtonTestId?: string;
|
|
55
|
+
onClearSelectedDate: () => void;
|
|
56
|
+
onClickTriggerCalendar: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { BaseDateInputContainerProps, BaseDateInputLabelProps, BaseDateInputProps, BaseDateInputRootProps, BaseDateInputTriggersProps, Keys };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Keys = void 0;
|
|
7
|
+
let Keys = exports.Keys = /*#__PURE__*/function (Keys) {
|
|
8
|
+
Keys["arrowLeft"] = "ArrowLeft";
|
|
9
|
+
Keys["arrowRight"] = "ArrowRight";
|
|
10
|
+
Keys["arrowUp"] = "ArrowUp";
|
|
11
|
+
Keys["arrowDown"] = "ArrowDown";
|
|
12
|
+
Keys["pageUp"] = "PageUp";
|
|
13
|
+
Keys["pageDown"] = "PageDown";
|
|
14
|
+
Keys["home"] = "Home";
|
|
15
|
+
Keys["end"] = "End";
|
|
16
|
+
Keys["escape"] = "Escape";
|
|
17
|
+
Keys["enter"] = "Enter";
|
|
18
|
+
return Keys;
|
|
19
|
+
}({});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { i as TextField } from '../index-772f9f1a.js';
|
|
2
|
+
export { i as DateField } from '../index-368f781f.js';
|
|
3
|
+
export { i as SelectField } from '../index-18a64236.js';
|
|
4
|
+
export { i as ColorField } from '../index-8a59cf4b.js';
|
|
5
|
+
export { B as BaseMaskNumber } from '../BaseNumber-797088d7.js';
|
|
6
|
+
export { N as NumberField } from '../Number-9c6aceff.js';
|
|
7
|
+
export { D as DecimalField } from '../Decimal-55e836d5.js';
|
|
8
|
+
export { C as CurrencyField } from '../Currency-b33d3a22.js';
|
|
9
|
+
export { B as MaskField } from '../BaseMask-3d5d581d.js';
|
|
10
|
+
export { C as CpfField } from '../Cpf-4d6b9079.js';
|
|
11
|
+
export { C as CnpjField } from '../Cnpj-1602be21.js';
|
|
12
|
+
export { P as PhoneField } from '../Phone-79e5e3b4.js';
|
|
13
|
+
export { Z as ZipCodeField } from '../ZipCode-8c2e9d8b.js';
|
|
14
|
+
export { i as CheckboxField } from '../index-43ad8140.js';
|
|
15
|
+
export { i as DatePeriodField } from '../index-c9247c1f.js';
|
|
16
|
+
import 'react';
|
|
17
|
+
import '../@types/Align.js';
|
|
18
|
+
import '../@types/ColorStyles.js';
|
|
19
|
+
import '../@types/Position.js';
|
|
20
|
+
import '../@types/PermissionAttr.js';
|
|
21
|
+
import './slot/index.js';
|
|
22
|
+
import '../tooltip/types.js';
|
|
23
|
+
import './date/datefield/types.js';
|
|
24
|
+
import 'moment';
|
|
25
|
+
import './selectfield/item.js';
|
|
26
|
+
import './selectfield/types.js';
|
|
27
|
+
import 'imask';
|
|
28
|
+
import '../@types/Size.js';
|
|
29
|
+
import './date/dateperiodfield/types.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ZipCodeField = exports.TextField = exports.SelectField = exports.PhoneField = exports.NumberField = exports.MaskField = exports.DecimalField = exports.DatePeriodField = exports.DateField = exports.CurrencyField = exports.CpfField = exports.ColorField = exports.CnpjField = exports.CheckboxField = exports.BaseMaskNumber = void 0;
|
|
7
|
+
var TextField = _interopRequireWildcard(require("./textfield"));
|
|
8
|
+
exports.TextField = TextField;
|
|
9
|
+
var DateField = _interopRequireWildcard(require("./date/datefield"));
|
|
10
|
+
exports.DateField = DateField;
|
|
11
|
+
var SelectField = _interopRequireWildcard(require("./selectfield"));
|
|
12
|
+
exports.SelectField = SelectField;
|
|
13
|
+
var ColorField = _interopRequireWildcard(require("./colorfield"));
|
|
14
|
+
exports.ColorField = ColorField;
|
|
15
|
+
var BaseMaskNumber = _interopRequireWildcard(require("./number/BaseNumber"));
|
|
16
|
+
exports.BaseMaskNumber = BaseMaskNumber;
|
|
17
|
+
var NumberField = _interopRequireWildcard(require("./number/Number"));
|
|
18
|
+
exports.NumberField = NumberField;
|
|
19
|
+
var DecimalField = _interopRequireWildcard(require("./number/Decimal"));
|
|
20
|
+
exports.DecimalField = DecimalField;
|
|
21
|
+
var CurrencyField = _interopRequireWildcard(require("./number/Currency"));
|
|
22
|
+
exports.CurrencyField = CurrencyField;
|
|
23
|
+
var MaskField = _interopRequireWildcard(require("./mask/BaseMask"));
|
|
24
|
+
exports.MaskField = MaskField;
|
|
25
|
+
var CpfField = _interopRequireWildcard(require("./mask/Cpf"));
|
|
26
|
+
exports.CpfField = CpfField;
|
|
27
|
+
var CnpjField = _interopRequireWildcard(require("./mask/Cnpj"));
|
|
28
|
+
exports.CnpjField = CnpjField;
|
|
29
|
+
var PhoneField = _interopRequireWildcard(require("./mask/Phone"));
|
|
30
|
+
exports.PhoneField = PhoneField;
|
|
31
|
+
var ZipCodeField = _interopRequireWildcard(require("./mask/ZipCode"));
|
|
32
|
+
exports.ZipCodeField = ZipCodeField;
|
|
33
|
+
var CheckboxField = _interopRequireWildcard(require("./checkboxfield"));
|
|
34
|
+
exports.CheckboxField = CheckboxField;
|
|
35
|
+
var DatePeriodField = _interopRequireWildcard(require("./date/dateperiodfield"));
|
|
36
|
+
exports.DatePeriodField = DatePeriodField;
|
|
37
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
38
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import 'react';
|
|
2
|
+
import '../../index-772f9f1a.js';
|
|
3
|
+
import 'imask';
|
|
4
|
+
export { I as Input, M as MaskFieldProps } from '../../BaseMask-3d5d581d.js';
|
|
5
|
+
import '../../@types/Align.js';
|
|
6
|
+
import '../../@types/ColorStyles.js';
|
|
7
|
+
import '../../@types/Position.js';
|
|
8
|
+
import '../../@types/PermissionAttr.js';
|
|
9
|
+
import '../slot/index.js';
|
|
10
|
+
import '../../tooltip/types.js';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Input = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactImask = require("react-imask");
|
|
9
|
+
var _textfield = require("../textfield");
|
|
10
|
+
var _helpers = require("../../form2/helpers");
|
|
11
|
+
const _excluded = ["maskOptions", "autoCompleteMask", "name", "value", "onComplete", "onChange", "onBlur", "onAccept"];
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
15
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
16
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
17
|
+
const Input = exports.Input = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
18
|
+
const {
|
|
19
|
+
maskOptions = {
|
|
20
|
+
mask: '',
|
|
21
|
+
lazy: false,
|
|
22
|
+
placeholderChar: '_'
|
|
23
|
+
},
|
|
24
|
+
autoCompleteMask = '',
|
|
25
|
+
name,
|
|
26
|
+
value: valueFromProps,
|
|
27
|
+
onComplete,
|
|
28
|
+
onChange,
|
|
29
|
+
onBlur,
|
|
30
|
+
onAccept
|
|
31
|
+
} = props,
|
|
32
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
33
|
+
const inputRef = (0, _react.useRef)(null);
|
|
34
|
+
const {
|
|
35
|
+
value,
|
|
36
|
+
unmaskedValue,
|
|
37
|
+
setValue: setMaskValue,
|
|
38
|
+
maskRef: refMask
|
|
39
|
+
} = (0, _reactImask.useIMask)(maskOptions, {
|
|
40
|
+
ref: inputRef,
|
|
41
|
+
onComplete: (__, maskRef) => {
|
|
42
|
+
onComplete?.(maskRef.value, maskRef);
|
|
43
|
+
},
|
|
44
|
+
onAccept: (__, maskRef) => {
|
|
45
|
+
const syntheticEvent = {
|
|
46
|
+
target: {
|
|
47
|
+
name,
|
|
48
|
+
value: maskRef.unmaskedValue
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
onChange?.(syntheticEvent);
|
|
52
|
+
onAccept?.(maskRef.value);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
_react.default.useEffect(() => {
|
|
56
|
+
const currentValue = valueFromProps ?? '';
|
|
57
|
+
if (currentValue === '') {
|
|
58
|
+
if (refMask.current) {
|
|
59
|
+
refMask.current.value = '';
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
setMaskValue(currentValue);
|
|
63
|
+
}
|
|
64
|
+
}, [valueFromProps]);
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement(_textfield.Input, _extends({}, rest, {
|
|
66
|
+
type: "text",
|
|
67
|
+
name: name,
|
|
68
|
+
value: value,
|
|
69
|
+
onBlur: e => {
|
|
70
|
+
if (unmaskedValue.trim().length && autoCompleteMask) {
|
|
71
|
+
const currentValue = unmaskedValue;
|
|
72
|
+
const sizeMask = maskOptions?.mask?.toString().replace(/\D+/g, '').length;
|
|
73
|
+
if (sizeMask && sizeMask > currentValue.length) {
|
|
74
|
+
switch (autoCompleteMask) {
|
|
75
|
+
case 'left':
|
|
76
|
+
setMaskValue(currentValue.padStart(sizeMask, '0'));
|
|
77
|
+
break;
|
|
78
|
+
case 'right':
|
|
79
|
+
setMaskValue(currentValue.padEnd(sizeMask, '0'));
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
setMaskValue(currentValue);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (onBlur) onBlur(e);
|
|
88
|
+
},
|
|
89
|
+
onChange: e => {
|
|
90
|
+
if (onChange) onChange(e);
|
|
91
|
+
},
|
|
92
|
+
ref: (0, _helpers.mergeRefs)(ref, inputRef)
|
|
93
|
+
}));
|
|
94
|
+
});
|
|
95
|
+
Input.displayName = 'MaskInputField';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import 'react';
|
|
2
|
+
import '../../BaseMask-3d5d581d.js';
|
|
3
|
+
export { a as CnpjFieldProps, I as Input } from '../../Cnpj-1602be21.js';
|
|
4
|
+
import '../../index-772f9f1a.js';
|
|
5
|
+
import '../../@types/Align.js';
|
|
6
|
+
import '../../@types/ColorStyles.js';
|
|
7
|
+
import '../../@types/Position.js';
|
|
8
|
+
import '../../@types/PermissionAttr.js';
|
|
9
|
+
import '../slot/index.js';
|
|
10
|
+
import '../../tooltip/types.js';
|
|
11
|
+
import 'imask';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Input = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _helpers = require("../../../lib/form2/helpers");
|
|
9
|
+
var _helpers2 = require("./helpers");
|
|
10
|
+
var _BaseMask = require("./BaseMask");
|
|
11
|
+
const _excluded = ["name", "onValidate", "onChange", "onBlur", "errors"];
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
15
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
16
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
17
|
+
const CNPJ_INVALID_MESSAGE = 'CNPJ inválido';
|
|
18
|
+
const Input = exports.Input = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
19
|
+
const {
|
|
20
|
+
name,
|
|
21
|
+
onValidate,
|
|
22
|
+
onChange,
|
|
23
|
+
onBlur,
|
|
24
|
+
errors: externalErrors = []
|
|
25
|
+
} = props,
|
|
26
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
27
|
+
const inputRef = (0, _react.useRef)(null);
|
|
28
|
+
const validateCnpj = raw => {
|
|
29
|
+
const hasCnpjError = externalErrors.includes(CNPJ_INVALID_MESSAGE);
|
|
30
|
+
const isValid = (0, _helpers2.CNPJValidation)(raw);
|
|
31
|
+
if (!isValid && hasCnpjError) {
|
|
32
|
+
onValidate?.([CNPJ_INVALID_MESSAGE]);
|
|
33
|
+
}
|
|
34
|
+
if (isValid && !hasCnpjError) {
|
|
35
|
+
onValidate?.([]);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const handleChange = e => {
|
|
39
|
+
const rawValue = e.target.value.replace(/\D/g, '');
|
|
40
|
+
validateCnpj(rawValue);
|
|
41
|
+
onChange?.(e);
|
|
42
|
+
};
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement(_BaseMask.Input, _extends({}, rest, {
|
|
44
|
+
type: "text",
|
|
45
|
+
name: name,
|
|
46
|
+
errors: externalErrors,
|
|
47
|
+
maskOptions: {
|
|
48
|
+
mask: '00.000.000/0000-00',
|
|
49
|
+
placeholderChar: '_',
|
|
50
|
+
lazy: false
|
|
51
|
+
},
|
|
52
|
+
onBlur: onBlur,
|
|
53
|
+
onChange: handleChange,
|
|
54
|
+
ref: (0, _helpers.mergeRefs)(ref, inputRef)
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
57
|
+
Input.displayName = 'CnpjInputField';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import 'react';
|
|
2
|
+
import '../../BaseMask-3d5d581d.js';
|
|
3
|
+
export { a as CpfFieldProps, I as Input } from '../../Cpf-4d6b9079.js';
|
|
4
|
+
import '../../index-772f9f1a.js';
|
|
5
|
+
import '../../@types/Align.js';
|
|
6
|
+
import '../../@types/ColorStyles.js';
|
|
7
|
+
import '../../@types/Position.js';
|
|
8
|
+
import '../../@types/PermissionAttr.js';
|
|
9
|
+
import '../slot/index.js';
|
|
10
|
+
import '../../tooltip/types.js';
|
|
11
|
+
import 'imask';
|