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
|
@@ -7,11 +7,11 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
9
|
var _icons = _interopRequireDefault(require("../../lib/icons"));
|
|
10
|
-
var _withTooltip = _interopRequireWildcard(require("../internals/withTooltip"));
|
|
11
10
|
var _spinner = _interopRequireDefault(require("../spinner"));
|
|
12
11
|
var _withDropdown = _interopRequireDefault(require("../dropdown/withDropdown"));
|
|
13
12
|
var _permissionValidations = require("../permissionValidations");
|
|
14
|
-
|
|
13
|
+
var _tooltip = require("../tooltip");
|
|
14
|
+
const _excluded = ["dropdown", "onClick", "disabled", "iconName", "icon", "targetRef", "tabIndex", "isLoading", "label", "showDropdown", "getDropdownPopup", "isDropdownOpened", "showIconDropdown", "content", "style", "toggleable", "activeIconColor", "iconStyle", "visible", "customClass", "className", "size", "iconAlign", "boxShadow", "transparent", "round", "permissionAttr", "skeletonize", "tooltip", "tooltipWidth", "tooltipPosition", "buttonRef", "errorMessage", "onDeniedText"];
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
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); }
|
|
17
17
|
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; }
|
|
@@ -53,7 +53,11 @@ const DefaultButton = _ref => {
|
|
|
53
53
|
round,
|
|
54
54
|
permissionAttr,
|
|
55
55
|
skeletonize,
|
|
56
|
+
tooltip,
|
|
57
|
+
tooltipWidth,
|
|
58
|
+
tooltipPosition,
|
|
56
59
|
buttonRef,
|
|
60
|
+
errorMessage,
|
|
57
61
|
onDeniedText = 'Permissão Negada! Consulte o Administrador do sistema.'
|
|
58
62
|
} = _ref,
|
|
59
63
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -64,9 +68,6 @@ const DefaultButton = _ref => {
|
|
|
64
68
|
const disabledIconColor = 'rgb(193, 193, 193)';
|
|
65
69
|
const disabledByPermission = onDenied.disabled;
|
|
66
70
|
const isDisabled = !!onDenied.disabled || disabled;
|
|
67
|
-
const {
|
|
68
|
-
handlerSetOnDeniedText
|
|
69
|
-
} = (0, _react.useContext)(_withTooltip.TooltipContext);
|
|
70
71
|
const getClass = () => `button-component ${className}
|
|
71
72
|
${customClass}
|
|
72
73
|
${transparent && '-transparent'}
|
|
@@ -124,11 +125,8 @@ const DefaultButton = _ref => {
|
|
|
124
125
|
}
|
|
125
126
|
return null;
|
|
126
127
|
};
|
|
127
|
-
(0, _react.useEffect)(() => {
|
|
128
|
-
if (disabledByPermission) handlerSetOnDeniedText(onDeniedText);
|
|
129
|
-
}, [disabledByPermission]);
|
|
130
128
|
if (!visible || onDenied.unvisible) return null;
|
|
131
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("button", _extends({}, rest, {
|
|
129
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("button", _extends({}, _lodash.default.omit(rest, 'dropdownAlign'), {
|
|
132
130
|
style: style,
|
|
133
131
|
onKeyDown: e => {
|
|
134
132
|
if (e && (e.key === 'Enter' || e.key === ' ')) {
|
|
@@ -162,7 +160,10 @@ const DefaultButton = _ref => {
|
|
|
162
160
|
},
|
|
163
161
|
tabIndex: isDisabled ? -1 : tabIndex
|
|
164
162
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
165
|
-
className: "button-container"
|
|
163
|
+
className: "button-container",
|
|
164
|
+
style: {
|
|
165
|
+
pointerEvents: 'none'
|
|
166
|
+
}
|
|
166
167
|
}, !dropdown && getIcon(), content || label && /*#__PURE__*/_react.default.createElement("div", {
|
|
167
168
|
className: "button-content"
|
|
168
169
|
}, content, label || ''), dropdown && getIcon()), isLoading && /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -170,6 +171,13 @@ const DefaultButton = _ref => {
|
|
|
170
171
|
}, /*#__PURE__*/_react.default.createElement(_spinner.default, {
|
|
171
172
|
align: "none",
|
|
172
173
|
delayTime: 0
|
|
173
|
-
}))),
|
|
174
|
+
}))), /*#__PURE__*/_react.default.createElement(_tooltip.Tooltip, {
|
|
175
|
+
targetRef: refButton,
|
|
176
|
+
text: tooltip,
|
|
177
|
+
width: tooltipWidth,
|
|
178
|
+
position: tooltipPosition,
|
|
179
|
+
onDeniedText: disabledByPermission ? onDeniedText : undefined,
|
|
180
|
+
textError: errorMessage
|
|
181
|
+
}), dropdown && refButton.current && getDropdownPopup && getDropdownPopup(refButton.current));
|
|
174
182
|
};
|
|
175
|
-
var _default = exports.default = (0, _withDropdown.default)(
|
|
183
|
+
var _default = exports.default = (0, _withDropdown.default)(DefaultButton);
|
package/lib/buttons/index.d.ts
CHANGED
package/lib/buttons/types.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ import { PermissionAttr } from '../@types/PermissionAttr.js';
|
|
|
3
3
|
import { Position } from '../@types/Position.js';
|
|
4
4
|
import { Size } from '../@types/Size.js';
|
|
5
5
|
import { IconNames } from '../@types/Icon.js';
|
|
6
|
+
import { ITooltipCommonProps } from '../tooltip/types.js';
|
|
6
7
|
import '../icons/helper.js';
|
|
7
8
|
|
|
8
|
-
interface IButtonProps extends ButtonHTMLAttributes<HTMLButtonElement
|
|
9
|
+
interface IButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, ITooltipCommonProps {
|
|
9
10
|
label?: string;
|
|
10
11
|
activeIconColor?: string;
|
|
11
12
|
toggleable?: boolean;
|
|
@@ -32,10 +33,6 @@ interface IButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
32
33
|
permissionAttr?: PermissionAttr | PermissionAttr[];
|
|
33
34
|
transparent?: boolean;
|
|
34
35
|
skeletonize?: boolean;
|
|
35
|
-
tooltipPosition?: Exclude<Position, 'center'>;
|
|
36
|
-
tooltipWidth?: string | number;
|
|
37
|
-
space?: number;
|
|
38
|
-
tooltip?: string;
|
|
39
36
|
split?: boolean;
|
|
40
37
|
isFloatMenu?: boolean;
|
|
41
38
|
customClassForDropdown?: string;
|
package/lib/drawer/Drawer.js
CHANGED
|
@@ -79,9 +79,10 @@ const BaseDrawer = _ref => {
|
|
|
79
79
|
componentEl.appendChild(drawerContainerEl.current);
|
|
80
80
|
drawerComponentEl.current = componentEl;
|
|
81
81
|
};
|
|
82
|
-
const setDrawerOverlay = body => {
|
|
82
|
+
const setDrawerOverlay = (body, id) => {
|
|
83
83
|
const drawerOverlay = document.createElement('div');
|
|
84
84
|
drawerOverlay.className = 'drawer-overlay';
|
|
85
|
+
drawerOverlay.id = id;
|
|
85
86
|
drawerOverlay.dataset.testid = 'drawer-overlay';
|
|
86
87
|
body.appendChild(drawerOverlay);
|
|
87
88
|
};
|
|
@@ -93,16 +94,19 @@ const BaseDrawer = _ref => {
|
|
|
93
94
|
};
|
|
94
95
|
(0, _react.useEffect)(() => {
|
|
95
96
|
let body;
|
|
96
|
-
const
|
|
97
|
+
const randomId = Math.round(+new Date() / 1000);
|
|
98
|
+
const overlayId = `overlay-${randomId}`;
|
|
97
99
|
if (targetId === undefined) {
|
|
98
100
|
body = document.getElementsByTagName('body')[0];
|
|
99
101
|
} else {
|
|
100
102
|
body = document.getElementById(targetId);
|
|
101
103
|
}
|
|
102
|
-
if (body) setDrawerComponent(body,
|
|
103
|
-
if (overlay &&
|
|
104
|
+
if (body) setDrawerComponent(body, randomId);
|
|
105
|
+
if (overlay && body) {
|
|
106
|
+
setDrawerOverlay(body, overlayId);
|
|
107
|
+
}
|
|
104
108
|
return () => {
|
|
105
|
-
const drawerOverlay = document.
|
|
109
|
+
const drawerOverlay = document.getElementById(overlayId);
|
|
106
110
|
if (closeOnEsc) document.body.removeEventListener('keydown', closeDrawerOnEsc);
|
|
107
111
|
if (targetId) {
|
|
108
112
|
const drawerComponentTarget = document.getElementById(targetId);
|
|
@@ -110,7 +114,7 @@ const BaseDrawer = _ref => {
|
|
|
110
114
|
drawerComponentTarget.removeChild(drawerComponentEl.current);
|
|
111
115
|
}
|
|
112
116
|
} else if (drawerComponentEl.current) document.body.removeChild(drawerComponentEl.current);
|
|
113
|
-
if (drawerOverlay &&
|
|
117
|
+
if (drawerOverlay && body) body.removeChild(drawerOverlay);
|
|
114
118
|
};
|
|
115
119
|
}, []);
|
|
116
120
|
(0, _react.useEffect)(() => {
|
package/lib/form/Field.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import '../@types/DataCombo.js';
|
|
|
6
6
|
import '../@types/PermissionAttr.js';
|
|
7
7
|
import '../inputs/base/types.js';
|
|
8
8
|
import '../@types/Period.js';
|
|
9
|
-
import '../
|
|
9
|
+
import '../tooltip/types.js';
|
|
10
10
|
import '../@types/Position.js';
|
|
11
11
|
|
|
12
12
|
declare const _default: React__default.ForwardRefExoticComponent<Pick<IFieldProps & React__default.RefAttributes<unknown>, "key" | keyof IFieldProps> & React__default.RefAttributes<HTMLElement>>;
|
package/lib/form/FieldArray.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import '../@types/DataCombo.js';
|
|
|
6
6
|
import '../@types/PermissionAttr.js';
|
|
7
7
|
import '../inputs/base/types.js';
|
|
8
8
|
import '../@types/Period.js';
|
|
9
|
-
import '../
|
|
9
|
+
import '../tooltip/types.js';
|
|
10
10
|
import '../@types/Position.js';
|
|
11
11
|
|
|
12
12
|
declare const _default: React__default.ForwardRefExoticComponent<IFieldArrayProps & React__default.RefAttributes<HTMLElement>>;
|
|
@@ -6,7 +6,7 @@ import '../@types/DataCombo.js';
|
|
|
6
6
|
import '../@types/PermissionAttr.js';
|
|
7
7
|
import '../inputs/base/types.js';
|
|
8
8
|
import '../@types/Period.js';
|
|
9
|
-
import '../
|
|
9
|
+
import '../tooltip/types.js';
|
|
10
10
|
import '../@types/Position.js';
|
|
11
11
|
|
|
12
12
|
declare const _default: React__default.ForwardRefExoticComponent<IFieldProps & React__default.RefAttributes<HTMLElement>>;
|
|
@@ -6,7 +6,7 @@ import '../@types/DataCombo.js';
|
|
|
6
6
|
import '../@types/PermissionAttr.js';
|
|
7
7
|
import '../inputs/base/types.js';
|
|
8
8
|
import '../@types/Period.js';
|
|
9
|
-
import '../
|
|
9
|
+
import '../tooltip/types.js';
|
|
10
10
|
import '../@types/Position.js';
|
|
11
11
|
|
|
12
12
|
declare const _default: React__default.ForwardRefExoticComponent<IFieldPeriodProps & React__default.RefAttributes<HTMLElement>>;
|
package/lib/form/helpers.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import '../@types/DataCombo.js';
|
|
|
6
6
|
import '../@types/PermissionAttr.js';
|
|
7
7
|
import '../inputs/base/types.js';
|
|
8
8
|
import '../@types/Period.js';
|
|
9
|
-
import '../
|
|
9
|
+
import '../tooltip/types.js';
|
|
10
10
|
import '../@types/Position.js';
|
|
11
11
|
|
|
12
12
|
declare const securityBeforeUnload = "securityBeforeUnload";
|
package/lib/form/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import '../@types/DataCombo.js';
|
|
|
10
10
|
import '../@types/PermissionAttr.js';
|
|
11
11
|
import '../inputs/base/types.js';
|
|
12
12
|
import '../@types/Period.js';
|
|
13
|
-
import '../
|
|
13
|
+
import '../tooltip/types.js';
|
|
14
14
|
import '../@types/Position.js';
|
|
15
15
|
|
|
16
16
|
declare const Form: ({ submitOnPressEnterKey, dataSource, securityBeforeUnload, handlerReset, handlerSubmit, handlerValidates, style, customClass, securityTitle, securityText, securityData, onDataChange, onValidateForm, externalFieldErrors, onSubmit, skeletonize, disabled, children, useInternalState, onValidateErrorsOnTab, }: FormProps) => JSX.Element;
|
package/lib/form/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import '../@types/DataCombo.js';
|
|
|
5
5
|
import '../@types/PermissionAttr.js';
|
|
6
6
|
import '../inputs/base/types.js';
|
|
7
7
|
import '../@types/Period.js';
|
|
8
|
-
import '../
|
|
8
|
+
import '../tooltip/types.js';
|
|
9
9
|
import '../@types/Position.js';
|
|
10
10
|
|
|
11
11
|
type Validator = (value: string) => string | undefined;
|
|
@@ -6,7 +6,7 @@ import '../@types/DataCombo.js';
|
|
|
6
6
|
import '../@types/PermissionAttr.js';
|
|
7
7
|
import '../inputs/base/types.js';
|
|
8
8
|
import '../@types/Period.js';
|
|
9
|
-
import '../
|
|
9
|
+
import '../tooltip/types.js';
|
|
10
10
|
import '../@types/Position.js';
|
|
11
11
|
|
|
12
12
|
declare const withFieldHOC: <ComponentProps extends WithFieldProps>(WrappedComponent: React__default.ComponentType<ComponentProps>) => React__default.ForwardRefExoticComponent<React__default.PropsWithoutRef<ComponentProps> & React__default.RefAttributes<HTMLElement>>;
|
|
@@ -6,7 +6,7 @@ import '../@types/DataCombo.js';
|
|
|
6
6
|
import '../@types/PermissionAttr.js';
|
|
7
7
|
import '../inputs/base/types.js';
|
|
8
8
|
import '../@types/Period.js';
|
|
9
|
-
import '../
|
|
9
|
+
import '../tooltip/types.js';
|
|
10
10
|
import '../@types/Position.js';
|
|
11
11
|
|
|
12
12
|
declare const FormSecurityContext: React__default.Context<IFormSecurityContext>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { DeepPartial } from './types.js';
|
|
3
|
+
|
|
4
|
+
declare const mergeRefs: <T>(...refs: (React__default.Ref<T> | undefined)[]) => (fieldElement: T) => void;
|
|
5
|
+
declare const deepMergeValues: <T>(current: T, incoming: DeepPartial<T>) => T;
|
|
6
|
+
declare const flattenValidators: (validators: Record<string, any>, prefix?: string) => Record<string, any>;
|
|
7
|
+
|
|
8
|
+
export { deepMergeValues, flattenValidators, mergeRefs };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mergeRefs = exports.flattenValidators = exports.deepMergeValues = void 0;
|
|
7
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const mergeRefs = function () {
|
|
10
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
11
|
+
refs[_key] = arguments[_key];
|
|
12
|
+
}
|
|
13
|
+
return fieldElement => {
|
|
14
|
+
refs.forEach(ref => {
|
|
15
|
+
if (_lodash.default.isFunction(ref)) ref(fieldElement);else if (ref && _lodash.default.isObject(ref)) ref.current = fieldElement;
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.mergeRefs = mergeRefs;
|
|
20
|
+
const deepMergeValues = (current, incoming) => {
|
|
21
|
+
return _lodash.default.mergeWith(_lodash.default.cloneDeep(current), incoming, (objValue, srcValue) => _lodash.default.isPlainObject(objValue) && _lodash.default.isPlainObject(srcValue) ? undefined : srcValue);
|
|
22
|
+
};
|
|
23
|
+
exports.deepMergeValues = deepMergeValues;
|
|
24
|
+
const flattenValidators = function (validators) {
|
|
25
|
+
let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
26
|
+
const flattened = {};
|
|
27
|
+
Object.entries(validators).forEach(_ref => {
|
|
28
|
+
let [key, value] = _ref;
|
|
29
|
+
const fullPath = prefix ? `${prefix}.${key}` : key;
|
|
30
|
+
if (Array.isArray(value)) {
|
|
31
|
+
flattened[fullPath] = value;
|
|
32
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
33
|
+
const nestedFlattened = flattenValidators(value, fullPath);
|
|
34
|
+
Object.assign(flattened, nestedFlattened);
|
|
35
|
+
} else {
|
|
36
|
+
flattened[fullPath] = [value];
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return flattened;
|
|
40
|
+
};
|
|
41
|
+
exports.flattenValidators = flattenValidators;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
export { default as useForm } from './useForm/index.js';
|
|
3
|
+
import './types.js';
|
|
4
|
+
|
|
5
|
+
interface FormElementProps extends React__default.ComponentProps<'form'> {
|
|
6
|
+
}
|
|
7
|
+
declare const Form: React__default.ForwardRefExoticComponent<Pick<FormElementProps, "className" | "onClick" | "color" | "children" | "style" | "id" | "key" | "slot" | "title" | "name" | "hidden" | "onKeyPress" | "role" | "tabIndex" | "align" | "target" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "nonce" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "rel" | "autoComplete" | "acceptCharset" | "action" | "encType" | "method" | "noValidate"> & React__default.RefAttributes<HTMLFormElement>>;
|
|
8
|
+
|
|
9
|
+
export { Form as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
Object.defineProperty(exports, "useForm", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _useForm.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _react = _interopRequireDefault(require("react"));
|
|
14
|
+
var _useForm = _interopRequireDefault(require("./useForm"));
|
|
15
|
+
const _excluded = ["noValidate", "autoComplete", "translate"];
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
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); }
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
20
|
+
const Form = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
21
|
+
const {
|
|
22
|
+
noValidate = true,
|
|
23
|
+
autoComplete = 'off',
|
|
24
|
+
translate = 'no'
|
|
25
|
+
} = props,
|
|
26
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement("form", _extends({
|
|
28
|
+
ref: ref,
|
|
29
|
+
className: "form-container",
|
|
30
|
+
translate: translate,
|
|
31
|
+
noValidate: noValidate,
|
|
32
|
+
autoComplete: autoComplete
|
|
33
|
+
}, rest));
|
|
34
|
+
});
|
|
35
|
+
Form.displayName = 'Form';
|
|
36
|
+
var _default = exports.default = Form;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
type DeepPartial<T> = {
|
|
2
|
+
[K in keyof T]?: T[K] extends Array<infer U> ? Array<DeepPartial<U>> : T[K] extends object ? DeepPartial<T[K]> : T[K];
|
|
3
|
+
};
|
|
4
|
+
type NestedState<T, R = any> = {
|
|
5
|
+
[K in keyof T]?: [T[K]] extends [readonly any[]] ? R : T[K] extends object ? NestedState<T[K], R> : R;
|
|
6
|
+
};
|
|
7
|
+
type FieldChanged<T> = NestedState<T, boolean>;
|
|
8
|
+
type FieldTouched<T> = NestedState<T, boolean>;
|
|
9
|
+
type FieldErrors<T> = NestedState<T, string[]>;
|
|
10
|
+
type FieldFocusOptions = Partial<{
|
|
11
|
+
shouldSelect: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
type ValidatorFunction<T> = (value: T, data?: Record<string, any>) => string | null;
|
|
14
|
+
type ValidatorsSchema = Record<string, ValidatorFunction<any>[]>;
|
|
15
|
+
type ValidationMode = 'default' | 'onSubmit';
|
|
16
|
+
type UseFormOptionsProps = Partial<{
|
|
17
|
+
validationMode: ValidationMode;
|
|
18
|
+
}>;
|
|
19
|
+
type RegisterFunction = (name: string, externalRef?: React.Ref<HTMLInputElement>) => {
|
|
20
|
+
name: string;
|
|
21
|
+
value: any;
|
|
22
|
+
ref: (fieldElement: HTMLInputElement) => void;
|
|
23
|
+
onBlur: () => void;
|
|
24
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
25
|
+
};
|
|
26
|
+
interface UseFormProps<T> {
|
|
27
|
+
initialValues: T;
|
|
28
|
+
validators?: ValidatorsSchema;
|
|
29
|
+
options?: UseFormOptionsProps;
|
|
30
|
+
}
|
|
31
|
+
interface UseFormReturn<T> {
|
|
32
|
+
/**
|
|
33
|
+
* Reseta os campos especificados ou todo o formulário para seus valores iniciais.
|
|
34
|
+
* Também limpa estados de `errors`, `touched` e `changed`.
|
|
35
|
+
* @param fields - Lista de nomes de campos a serem resetados. Se não informado, todos os campos são resetados.
|
|
36
|
+
*/
|
|
37
|
+
reset: (fields?: string[]) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Objeto que indica quais campos foram modificados em relação ao `initialValues`.
|
|
40
|
+
*/
|
|
41
|
+
changed: FieldChanged<T>;
|
|
42
|
+
/**
|
|
43
|
+
* Objeto com os valores atuais dos campos do formulário.
|
|
44
|
+
*/
|
|
45
|
+
values: Record<string, any>;
|
|
46
|
+
/**
|
|
47
|
+
* Objeto contendo arrays de mensagens de erro por campo.
|
|
48
|
+
*/
|
|
49
|
+
errors: FieldErrors<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Objeto que indica se os campos foram tocados (interagidos via blur).
|
|
52
|
+
*/
|
|
53
|
+
touched: FieldTouched<T>;
|
|
54
|
+
/**
|
|
55
|
+
* Indica se o formulário está válido com base nos validadores definidos.
|
|
56
|
+
*/
|
|
57
|
+
isValid: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Registra um campo no formulário, integrando com `ref`, `value`, `onChange` e `onBlur`.
|
|
60
|
+
* @param name - Nome do campo.
|
|
61
|
+
* @param externalRef - Referência externa para o input.
|
|
62
|
+
*/
|
|
63
|
+
register: (name: string, externalRef?: React.Ref<HTMLInputElement>) => {
|
|
64
|
+
name: string;
|
|
65
|
+
ref: React.RefCallback<HTMLInputElement>;
|
|
66
|
+
value: any;
|
|
67
|
+
onBlur: () => void;
|
|
68
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Limpa mensagens de erro de campos especificados, ou de todos os campos se nenhum for informado.
|
|
72
|
+
* @param fields - Lista de campos a limpar.
|
|
73
|
+
*/
|
|
74
|
+
cleanErrors: (fields?: string[]) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Altera os valores dos campos do formulário com base em dados externos (ex: dados assíncronos).
|
|
77
|
+
* Preserva os dados atuais para campos não especificados.
|
|
78
|
+
* @param values - Novo objeto de dados com valores para atualizar no estado do formulário.
|
|
79
|
+
*/
|
|
80
|
+
changeValues: (values: DeepPartial<T>) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Compara o valor atual de um campo com um valor fornecido, retornando true se forem iguais.
|
|
83
|
+
* @param name - Nome do campo.
|
|
84
|
+
* @param value - Valor a ser comparado.
|
|
85
|
+
*/
|
|
86
|
+
compareField: (name: string, value: any) => boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Gera uma função de submit que é executada ao chamar a callback fornecida.
|
|
89
|
+
* @param callback - Função de submit executada em caso de formulário válido e retornando objeto de valores do formulário.
|
|
90
|
+
*/
|
|
91
|
+
handleSubmit: (callback: (data: T) => void) => (event: React.FormEvent) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Retorna o valor atual de um campo específico.
|
|
94
|
+
* @param name - Nome do campo.
|
|
95
|
+
*/
|
|
96
|
+
getFieldValue: (name: string) => any;
|
|
97
|
+
/**
|
|
98
|
+
* Retorna as mensagens de erro associadas a um campo específico.
|
|
99
|
+
* @param name - Nome do campo.
|
|
100
|
+
*/
|
|
101
|
+
getFieldError: (name: string) => string[];
|
|
102
|
+
/**
|
|
103
|
+
* Define o foco programaticamente em um campo registrado.
|
|
104
|
+
* @param name - Nome do campo.
|
|
105
|
+
* @param options - Opções adicionais como selecionar o texto ao focar.
|
|
106
|
+
*/
|
|
107
|
+
setFieldFocus: (name: string, options?: FieldFocusOptions) => void;
|
|
108
|
+
/**
|
|
109
|
+
* Atualiza o valor de um campo específico e dispara validações quando apropriado.
|
|
110
|
+
* @param name - Nome do campo.
|
|
111
|
+
* @param value - Novo valor.
|
|
112
|
+
*/
|
|
113
|
+
setFieldValue: (name: string, value: any) => void;
|
|
114
|
+
/**
|
|
115
|
+
* Objeto original passado como `initialValues`. Utilizado para reset e comparações.
|
|
116
|
+
*/
|
|
117
|
+
initialValues: Record<string, any>;
|
|
118
|
+
/**
|
|
119
|
+
* Define erros manualmente em campos do formulário, útil para erros externos (ex: backend).
|
|
120
|
+
* @param errors - Objeto contendo mensagens de erro para campos.
|
|
121
|
+
*/
|
|
122
|
+
setExternalErrors: (errors: Record<string, string[]>) => void;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { DeepPartial, FieldChanged, FieldErrors, FieldFocusOptions, FieldTouched, NestedState, RegisterFunction, UseFormOptionsProps, UseFormProps, UseFormReturn, ValidationMode, ValidatorFunction, ValidatorsSchema };
|