linear-react-components-ui 1.1.25-beta.7 → 1.1.25-beta.9
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/{BaseMask-0c14ef51.d.ts → BaseMask-78847f45.d.ts} +1 -1
- package/lib/{Cnpj-53bfd6ab.d.ts → Cnpj-8366781f.d.ts} +1 -2
- package/lib/{Cpf-019b21e0.d.ts → Cpf-3dfd54eb.d.ts} +1 -2
- package/lib/{Phone-2bb0b397.d.ts → Phone-1962c0f2.d.ts} +1 -1
- package/lib/{ZipCode-09460e18.d.ts → ZipCode-be9c5b3b.d.ts} +1 -1
- package/lib/assets/styles/radio.scss +44 -32
- package/lib/assets/styles/split.scss +1 -1
- package/lib/form2/index.d.ts +1 -1
- package/lib/{index-3b70931d.d.ts → index-02a27c19.d.ts} +2 -20
- package/lib/index-053f615b.d.ts +26 -0
- package/lib/{index-7dfa8924.d.ts → index-25b80f32.d.ts} +1 -1
- package/lib/{index-9e576346.d.ts → index-6f5c772d.d.ts} +1 -1
- package/lib/{index-208e7f62.d.ts → index-6fcf446c.d.ts} +2 -20
- package/lib/index-7159df18.d.ts +21 -0
- package/lib/index-c41f4a15.d.ts +15 -0
- package/lib/inputs2/checkboxfield/base.d.ts +29 -0
- package/lib/inputs2/checkboxfield/base.js +134 -0
- package/lib/inputs2/checkboxfield/index.d.ts +3 -2
- package/lib/inputs2/checkboxfield/index.js +32 -125
- package/lib/inputs2/colorfield/index.d.ts +6 -5
- package/lib/inputs2/date/datefield/base.d.ts +13 -0
- package/lib/inputs2/date/datefield/base.js +330 -0
- package/lib/inputs2/date/datefield/calendarbox.d.ts +1 -1
- package/lib/inputs2/date/datefield/index.js +34 -322
- package/lib/inputs2/date/datefield/types.d.ts +5 -3
- package/lib/inputs2/date/dateperiodfield/base.d.ts +13 -0
- package/lib/inputs2/date/dateperiodfield/base.js +595 -0
- package/lib/inputs2/date/dateperiodfield/calendarbox.d.ts +1 -1
- package/lib/inputs2/date/dateperiodfield/index.js +34 -587
- package/lib/inputs2/date/dateperiodfield/types.d.ts +5 -3
- package/lib/inputs2/filefield/index.d.ts +6 -5
- package/lib/inputs2/index.d.ts +18 -15
- package/lib/inputs2/mask/BaseMask.d.ts +6 -5
- package/lib/inputs2/mask/Cnpj.d.ts +7 -6
- package/lib/inputs2/mask/Cnpj.js +18 -21
- package/lib/inputs2/mask/Cpf.d.ts +7 -6
- package/lib/inputs2/mask/Cpf.js +12 -19
- package/lib/inputs2/mask/Phone.d.ts +7 -6
- package/lib/inputs2/mask/ZipCode.d.ts +7 -6
- package/lib/inputs2/numberfield/currency.d.ts +5 -4
- package/lib/inputs2/numberfield/decimal.d.ts +5 -4
- package/lib/inputs2/numberfield/index.d.ts +5 -4
- package/lib/inputs2/numberfield/types.d.ts +5 -4
- package/lib/inputs2/radiofield/base.d.ts +12 -0
- package/lib/inputs2/radiofield/base.js +156 -0
- package/lib/inputs2/radiofield/index.d.ts +1 -1
- package/lib/inputs2/radiofield/index.js +25 -126
- package/lib/inputs2/radiofield/types.d.ts +6 -4
- package/lib/inputs2/selectfield/base.d.ts +11 -0
- package/lib/inputs2/selectfield/base.js +513 -0
- package/lib/inputs2/selectfield/index.d.ts +1 -1
- package/lib/inputs2/selectfield/index.js +35 -502
- package/lib/inputs2/selectfield/item.d.ts +1 -1
- package/lib/inputs2/selectfield/listbox.d.ts +1 -1
- package/lib/inputs2/selectfield/options.d.ts +1 -1
- package/lib/inputs2/selectfield/search.d.ts +1 -1
- package/lib/inputs2/selectfield/selections.d.ts +1 -1
- package/lib/inputs2/selectfield/types.d.ts +8 -6
- package/lib/inputs2/slot/index.d.ts +2 -2
- package/lib/inputs2/textareafield/base.d.ts +26 -0
- package/lib/inputs2/textareafield/base.js +166 -0
- package/lib/inputs2/textareafield/index.d.ts +4 -3
- package/lib/inputs2/textareafield/index.js +30 -154
- package/lib/inputs2/textfield/base.d.ts +26 -0
- package/lib/inputs2/textfield/base.js +131 -0
- package/lib/inputs2/textfield/index.d.ts +5 -4
- package/lib/inputs2/textfield/index.js +30 -120
- package/lib/radio/index.js +3 -4
- package/lib/tooltip/useTooltip.d.ts +1 -1
- package/package.json +1 -1
- package/lib/index-19761a50.d.ts +0 -26
- package/lib/index-4bda404f.d.ts +0 -42
- package/lib/index-afb7b5a9.d.ts +0 -15
|
@@ -5,341 +5,53 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Input = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
-
var _reactImask = require("react-imask");
|
|
10
|
-
var _uuid = require("uuid");
|
|
11
|
-
var _reactDom = require("react-dom");
|
|
12
|
-
var _moment = _interopRequireDefault(require("moment"));
|
|
13
|
-
var _hint = _interopRequireDefault(require("../../../hint"));
|
|
14
8
|
var _gridlayout = _interopRequireDefault(require("../../../gridlayout"));
|
|
15
|
-
var _tooltip = require("../../../tooltip");
|
|
16
|
-
var _helpers = require("../../../form2/helpers");
|
|
17
9
|
var _permissionValidations = require("../../../permissionValidations");
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
var _triggers = require("./triggers");
|
|
22
|
-
var _calendarbox = require("./calendarbox");
|
|
23
|
-
var _context = require("./context");
|
|
24
|
-
const _excluded = ["label", "errors", "tooltip", "tooltipPosition", "tooltipWidth", "onDeniedActions", "permissionAttr", "customClass", "customClassLabel", "customClassWrapper", "customClassInputContainer", "textAlign", "labelUppercase", "skeletonize", "hintPosition", "gridLayout", "themePopover", "popoverAlign", "showCalendarButton", "openCalendarOnFocus", "undigitable", "shouldCloseOnSelect", "showClearDateButton", "placeholder", "returnValueType"];
|
|
10
|
+
var _helpers = require("../helpers");
|
|
11
|
+
var _base = require("./base");
|
|
12
|
+
const _excluded = ["onDeniedActions", "permissionAttr", "disabled", "readOnly", "gridLayout"];
|
|
25
13
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
26
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
27
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
28
15
|
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); }
|
|
16
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
20
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
29
21
|
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; }
|
|
30
22
|
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; }
|
|
31
|
-
const Input = exports.Input = /*#__PURE__*/_react.default.forwardRef((
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
permissionAttr = undefined,
|
|
41
|
-
customClass = '',
|
|
42
|
-
customClassLabel = '',
|
|
43
|
-
customClassWrapper = '',
|
|
44
|
-
customClassInputContainer = '',
|
|
45
|
-
textAlign = 'left',
|
|
46
|
-
labelUppercase = false,
|
|
47
|
-
skeletonize = false,
|
|
48
|
-
hintPosition = 'below',
|
|
49
|
-
gridLayout = undefined,
|
|
50
|
-
themePopover = 'light',
|
|
51
|
-
popoverAlign = 'left',
|
|
52
|
-
showCalendarButton = true,
|
|
53
|
-
openCalendarOnFocus = true,
|
|
54
|
-
undigitable = false,
|
|
55
|
-
shouldCloseOnSelect = true,
|
|
56
|
-
showClearDateButton = true,
|
|
57
|
-
placeholder = _helpers2.TOKEN_PTBR_FORMAT,
|
|
58
|
-
returnValueType = 'default'
|
|
59
|
-
} = props,
|
|
60
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
23
|
+
const Input = exports.Input = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
24
|
+
let {
|
|
25
|
+
onDeniedActions,
|
|
26
|
+
permissionAttr,
|
|
27
|
+
disabled,
|
|
28
|
+
readOnly,
|
|
29
|
+
gridLayout
|
|
30
|
+
} = _ref,
|
|
31
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
61
32
|
const onDenied = _react.default.useMemo(() => {
|
|
62
|
-
return onDeniedActions || (0, _permissionValidations.actionsOnPermissionDenied)(
|
|
33
|
+
return onDeniedActions || (0, _permissionValidations.actionsOnPermissionDenied)(_helpers.options, permissionAttr);
|
|
63
34
|
}, [onDeniedActions, permissionAttr]);
|
|
64
35
|
const {
|
|
65
36
|
hideContent,
|
|
66
37
|
unvisible
|
|
67
38
|
} = onDenied;
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const [calendarDisplayDate, setCalendarDisplayDate] = _react.default.useState(selectedDate !== null && selectedDate !== void 0 ? selectedDate : (0, _moment.default)());
|
|
72
|
-
const calendarRef = _react.default.useRef(null);
|
|
73
|
-
const inputRootRef = _react.default.useRef(null);
|
|
74
|
-
const dateInputRef = _react.default.useRef(null);
|
|
75
|
-
const dateContainerRef = _react.default.useRef(null);
|
|
76
|
-
const {
|
|
77
|
-
setValue: setMaskValue,
|
|
78
|
-
unmaskedValue,
|
|
79
|
-
value: maskedValue
|
|
80
|
-
} = (0, _reactImask.useIMask)({
|
|
81
|
-
mask: _helpers2.TOKEN_MASK,
|
|
82
|
-
lazy: false,
|
|
83
|
-
placeholderChar: '_'
|
|
84
|
-
}, {
|
|
85
|
-
ref: dateInputRef,
|
|
86
|
-
defaultValue: selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.format(_helpers2.TOKEN_PTBR_FORMAT),
|
|
87
|
-
onComplete: value => {
|
|
88
|
-
const date = (0, _moment.default)(value, _helpers2.TOKEN_PTBR_FORMAT);
|
|
89
|
-
if (date.isValid()) {
|
|
90
|
-
handleUpdateDateState(date);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
const inputId = _react.default.useMemo(() => props.id || props.name || (0, _uuid.v1)(), [props.id, props.name]);
|
|
95
|
-
const hasLabel = !_lodash.default.isEmpty(props === null || props === void 0 ? void 0 : props.label);
|
|
96
|
-
const isReadOnly = Boolean(props.readOnly || onDenied.readOnly);
|
|
97
|
-
const isDisabled = Boolean(props.disabled || onDenied.disabled);
|
|
98
|
-
const hasHintMessages = Boolean((_props$hint = props.hint) === null || _props$hint === void 0 ? void 0 : _props$hint.length);
|
|
99
|
-
const hasValidationErrors = Boolean(errors === null || errors === void 0 ? void 0 : errors.length);
|
|
100
|
-
const hasValidDateSelected = !_lodash.default.isEmpty(props === null || props === void 0 ? void 0 : props.value);
|
|
101
|
-
const handleUpdateDateState = _react.default.useCallback(date => {
|
|
102
|
-
var _props$onChange;
|
|
103
|
-
const nonIsoDateFormat = date.format(_helpers2.TOKEN_ISO_FORMAT);
|
|
104
|
-
const isoDateFormat = date.toISOString();
|
|
105
|
-
setSelectedDate(date.clone());
|
|
106
|
-
setCalendarDisplayDate(date.clone());
|
|
107
|
-
(_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, {
|
|
108
|
-
target: {
|
|
109
|
-
name: props.name,
|
|
110
|
-
value: returnValueType === 'default' ? nonIsoDateFormat : isoDateFormat
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
if (shouldCloseOnSelect) handleCloseCalendar();
|
|
114
|
-
}, [selectedDate, props.name, props.onChange, shouldCloseOnSelect]);
|
|
115
|
-
const handleOpenCalendar = _react.default.useCallback(() => setCalendarBoxOpen(true), []);
|
|
116
|
-
const handleCloseCalendar = _react.default.useCallback(() => setCalendarBoxOpen(false), []);
|
|
117
|
-
const handleNextMonth = _react.default.useCallback(() => setCalendarDisplayDate(prevDisplayDate => prevDisplayDate.clone().add(1, 'month')), []);
|
|
118
|
-
const handlePreviousMonth = _react.default.useCallback(() => setCalendarDisplayDate(prevDisplayDate => prevDisplayDate.clone().subtract(1, 'month')), []);
|
|
119
|
-
const handleChangeCalendarBoxState = _react.default.useCallback(() => {
|
|
120
|
-
setCalendarBoxOpen(prevState => {
|
|
121
|
-
if (dateInputRef.current !== document.activeElement) {
|
|
122
|
-
var _dateInputRef$current, _dateInputRef$current2;
|
|
123
|
-
dateInputRef === null || dateInputRef === void 0 ? void 0 : (_dateInputRef$current = dateInputRef.current) === null || _dateInputRef$current === void 0 ? void 0 : (_dateInputRef$current2 = _dateInputRef$current.focus) === null || _dateInputRef$current2 === void 0 ? void 0 : _dateInputRef$current2.call(_dateInputRef$current);
|
|
124
|
-
}
|
|
125
|
-
return !prevState;
|
|
126
|
-
});
|
|
127
|
-
}, []);
|
|
128
|
-
const handleNavigateWithDays = _react.default.useCallback(offset => {
|
|
129
|
-
setCalendarDisplayDate(prevDisplayDate => {
|
|
130
|
-
const daySelected = prevDisplayDate.clone().add(offset, 'day');
|
|
131
|
-
setActiveDescendant(daySelected.format(_helpers2.TOKEN_ISO_FORMAT));
|
|
132
|
-
return daySelected;
|
|
133
|
-
});
|
|
134
|
-
}, []);
|
|
135
|
-
const handleNavigateWithWeeks = _react.default.useCallback(when => {
|
|
136
|
-
setCalendarDisplayDate(prevDisplayDate => {
|
|
137
|
-
let daySelected = prevDisplayDate;
|
|
138
|
-
if (when === 'end') daySelected = prevDisplayDate.clone().endOf('week');
|
|
139
|
-
if (when === 'start') daySelected = prevDisplayDate.clone().startOf('week');
|
|
140
|
-
setActiveDescendant(daySelected.format(_helpers2.TOKEN_ISO_FORMAT));
|
|
141
|
-
return daySelected;
|
|
142
|
-
});
|
|
143
|
-
}, []);
|
|
144
|
-
const handleOnClickClearSelectedDate = _react.default.useCallback(() => {
|
|
145
|
-
var _props$onChange2;
|
|
146
|
-
(_props$onChange2 = props.onChange) === null || _props$onChange2 === void 0 ? void 0 : _props$onChange2.call(props, {
|
|
147
|
-
target: {
|
|
148
|
-
name: props.name,
|
|
149
|
-
value: ''
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
setSelectedDate(null);
|
|
153
|
-
setMaskValue('');
|
|
154
|
-
handleCloseCalendar();
|
|
155
|
-
}, [props.onChange]);
|
|
156
|
-
const handleOnBlur = event => {
|
|
157
|
-
var _props$onBlur;
|
|
158
|
-
props === null || props === void 0 ? void 0 : (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 ? void 0 : _props$onBlur.call(props, event);
|
|
159
|
-
handleCloseCalendar();
|
|
160
|
-
setActiveDescendant((selectedDate !== null && selectedDate !== void 0 ? selectedDate : (0, _moment.default)()).format(_helpers2.TOKEN_ISO_FORMAT));
|
|
161
|
-
setCalendarDisplayDate(selectedDate !== null && selectedDate !== void 0 ? selectedDate : (0, _moment.default)());
|
|
162
|
-
if (_lodash.default.size(unmaskedValue) !== 8) {
|
|
163
|
-
const date = (0, _moment.default)(_lodash.default.toString(props === null || props === void 0 ? void 0 : props.value), _helpers2.TOKEN_ISO_FORMAT);
|
|
164
|
-
if (date.isValid()) {
|
|
165
|
-
setMaskValue(date.format('DD/MM/YYYY'));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
const handleOnFocus = event => {
|
|
170
|
-
var _props$onFocus;
|
|
171
|
-
props === null || props === void 0 ? void 0 : (_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 ? void 0 : _props$onFocus.call(props, event);
|
|
172
|
-
setActiveDescendant((selectedDate !== null && selectedDate !== void 0 ? selectedDate : (0, _moment.default)()).format(_helpers2.TOKEN_ISO_FORMAT));
|
|
173
|
-
setCalendarDisplayDate(selectedDate !== null && selectedDate !== void 0 ? selectedDate : (0, _moment.default)());
|
|
174
|
-
if (!isReadOnly && openCalendarOnFocus) {
|
|
175
|
-
handleOpenCalendar();
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
const handleOnPaste = event => {
|
|
179
|
-
if (undigitable) {
|
|
180
|
-
event.preventDefault();
|
|
181
|
-
} else {
|
|
182
|
-
var _props$onPaste;
|
|
183
|
-
(_props$onPaste = props.onPaste) === null || _props$onPaste === void 0 ? void 0 : _props$onPaste.call(props, event);
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
const handleOnBeforeInput = event => {
|
|
187
|
-
if (undigitable) {
|
|
188
|
-
event.preventDefault();
|
|
189
|
-
} else {
|
|
190
|
-
var _props$onBeforeInput;
|
|
191
|
-
(_props$onBeforeInput = props.onBeforeInput) === null || _props$onBeforeInput === void 0 ? void 0 : _props$onBeforeInput.call(props, event);
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
const handleOnKeyDown = event => {
|
|
195
|
-
var _props$onKeyDown;
|
|
196
|
-
props === null || props === void 0 ? void 0 : (_props$onKeyDown = props.onKeyDown) === null || _props$onKeyDown === void 0 ? void 0 : _props$onKeyDown.call(props, event);
|
|
197
|
-
if (calendarBoxOpen && event.key && !event.shiftKey && !event.altKey && _helpers2.NAVIGATION_KEYS.includes(event.key)) {
|
|
198
|
-
event.preventDefault();
|
|
199
|
-
switch (event.key) {
|
|
200
|
-
case _types.Keys.arrowLeft:
|
|
201
|
-
handleNavigateWithDays(-1);
|
|
202
|
-
break;
|
|
203
|
-
case _types.Keys.arrowRight:
|
|
204
|
-
handleNavigateWithDays(1);
|
|
205
|
-
break;
|
|
206
|
-
case _types.Keys.arrowUp:
|
|
207
|
-
handleNavigateWithDays(-7);
|
|
208
|
-
break;
|
|
209
|
-
case _types.Keys.arrowDown:
|
|
210
|
-
handleNavigateWithDays(7);
|
|
211
|
-
break;
|
|
212
|
-
case _types.Keys.pageUp:
|
|
213
|
-
handleNextMonth();
|
|
214
|
-
break;
|
|
215
|
-
case _types.Keys.pageDown:
|
|
216
|
-
handlePreviousMonth();
|
|
217
|
-
break;
|
|
218
|
-
case _types.Keys.home:
|
|
219
|
-
handleNavigateWithWeeks('start');
|
|
220
|
-
break;
|
|
221
|
-
case _types.Keys.end:
|
|
222
|
-
handleNavigateWithWeeks('end');
|
|
223
|
-
break;
|
|
224
|
-
case _types.Keys.escape:
|
|
225
|
-
handleCloseCalendar();
|
|
226
|
-
break;
|
|
227
|
-
case _types.Keys.enter:
|
|
228
|
-
handleUpdateDateState((0, _moment.default)(_lodash.default.toString(activeDescendant), _helpers2.TOKEN_ISO_FORMAT));
|
|
229
|
-
break;
|
|
230
|
-
default:
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
_react.default.useEffect(() => {
|
|
236
|
-
var _props$value;
|
|
237
|
-
const currentValue = (_props$value = props === null || props === void 0 ? void 0 : props.value) !== null && _props$value !== void 0 ? _props$value : null;
|
|
238
|
-
const date = (0, _moment.default)(_lodash.default.toString(currentValue), _helpers2.TOKEN_ISO_FORMAT);
|
|
239
|
-
setSelectedDate(date.isValid() ? date : null);
|
|
240
|
-
setMaskValue(date.format(_helpers2.TOKEN_PTBR_FORMAT));
|
|
241
|
-
}, [props === null || props === void 0 ? void 0 : props.value]);
|
|
242
|
-
const contextValues = _react.default.useMemo(() => ({
|
|
243
|
-
label,
|
|
244
|
-
inputFieldId: inputId,
|
|
245
|
-
activeDescendant,
|
|
246
|
-
calendarBoxOpen,
|
|
247
|
-
isReadOnly,
|
|
248
|
-
isDisabled,
|
|
249
|
-
skeletonize,
|
|
250
|
-
showCalendarButton,
|
|
251
|
-
hasValidDateSelected,
|
|
252
|
-
dateInputRef,
|
|
253
|
-
dateContainerRef,
|
|
254
|
-
handleOpenCalendar,
|
|
255
|
-
handleCloseCalendar,
|
|
256
|
-
handleNextMonth,
|
|
257
|
-
handlePreviousMonth,
|
|
258
|
-
handleSelectDate: handleUpdateDateState,
|
|
259
|
-
selectedDate,
|
|
260
|
-
calendarDisplayDate,
|
|
261
|
-
calendarRef,
|
|
262
|
-
unmaskedValue,
|
|
263
|
-
maskedValue,
|
|
264
|
-
showClearDateButton,
|
|
265
|
-
handleChangeCalendarBoxState,
|
|
266
|
-
handleOnClickClearSelectedDate
|
|
267
|
-
}), [label, activeDescendant, calendarBoxOpen, isReadOnly, isDisabled, skeletonize, showCalendarButton, selectedDate, calendarDisplayDate, hasValidDateSelected, unmaskedValue, maskedValue]);
|
|
268
|
-
if (unvisible || hideContent) return null;
|
|
269
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
|
|
270
|
-
cols: gridLayout
|
|
271
|
-
}, /*#__PURE__*/_react.default.createElement(_context.DateFieldContext.Provider, {
|
|
272
|
-
value: contextValues
|
|
273
|
-
}, /*#__PURE__*/_react.default.createElement(BaseDate.Root, {
|
|
274
|
-
ref: inputRootRef,
|
|
275
|
-
"data-testid": "test-date-field-root",
|
|
276
|
-
customClassWrapper: customClassWrapper,
|
|
277
|
-
hasValidationErrors: hasValidationErrors
|
|
278
|
-
}, hasLabel && /*#__PURE__*/_react.default.createElement(BaseDate.Label, {
|
|
279
|
-
"data-testid": "test-date-field-label",
|
|
280
|
-
label: label,
|
|
281
|
-
inputId: inputId,
|
|
282
|
-
hint: props === null || props === void 0 ? void 0 : props.hint,
|
|
283
|
-
isDisabled: isDisabled,
|
|
284
|
-
isReadOnly: isReadOnly,
|
|
285
|
-
skeletonize: skeletonize,
|
|
286
|
-
required: props === null || props === void 0 ? void 0 : props.required,
|
|
287
|
-
hintPosition: hintPosition,
|
|
288
|
-
themePopover: themePopover,
|
|
289
|
-
popoverAlign: popoverAlign,
|
|
290
|
-
labelUppercase: labelUppercase,
|
|
291
|
-
hasHintMessages: hasHintMessages,
|
|
292
|
-
customClassLabel: customClassLabel
|
|
293
|
-
}), /*#__PURE__*/_react.default.createElement(BaseDate.Container, {
|
|
294
|
-
ref: dateContainerRef,
|
|
295
|
-
skeletonize: skeletonize,
|
|
296
|
-
customClassInputContainer: customClassInputContainer
|
|
297
|
-
}, /*#__PURE__*/_react.default.createElement(BaseDate.Input, _extends({}, rest, {
|
|
298
|
-
ref: (0, _helpers.mergeRefs)(ref, dateInputRef),
|
|
299
|
-
id: inputId,
|
|
300
|
-
name: props === null || props === void 0 ? void 0 : props.name,
|
|
301
|
-
value: maskedValue,
|
|
39
|
+
const isReadOnly = Boolean(readOnly || onDenied.readOnly);
|
|
40
|
+
const isDisabled = Boolean(disabled || onDenied.disabled);
|
|
41
|
+
const inputProps = _objectSpread({
|
|
302
42
|
readOnly: isReadOnly,
|
|
303
|
-
disabled: isDisabled
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
"data-state-undigitable": undigitable,
|
|
317
|
-
"data-state-skeletonize": skeletonize,
|
|
318
|
-
onBlur: handleOnBlur,
|
|
319
|
-
onFocus: handleOnFocus,
|
|
320
|
-
onPaste: handleOnPaste,
|
|
321
|
-
onKeyDown: handleOnKeyDown,
|
|
322
|
-
onBeforeInput: handleOnBeforeInput
|
|
323
|
-
})), /*#__PURE__*/_react.default.createElement(_triggers.Triggers, null)), calendarBoxOpen && !hideContent && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement(_calendarbox.CalendarBox, {
|
|
324
|
-
ref: calendarRef
|
|
325
|
-
}), document.body), hintPosition === 'below' && /*#__PURE__*/_react.default.createElement(_hint.default, {
|
|
326
|
-
customClass: "hint",
|
|
327
|
-
description: props.hint,
|
|
328
|
-
disabled: isDisabled,
|
|
329
|
-
skeletonize: skeletonize,
|
|
330
|
-
visible: hasHintMessages
|
|
331
|
-
}), hasValidationErrors && /*#__PURE__*/_react.default.createElement("span", {
|
|
332
|
-
"data-testid": "test-date-field-list-errors",
|
|
333
|
-
className: "error",
|
|
334
|
-
"data-state-skeletonize": skeletonize,
|
|
335
|
-
"aria-describedby": String(props.name).concat('-errors')
|
|
336
|
-
}, errors === null || errors === void 0 ? void 0 : errors.map((error, index) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
337
|
-
key: "".concat(index + 1, "-").concat(error)
|
|
338
|
-
}, error, "\xA0")))))), /*#__PURE__*/_react.default.createElement(_tooltip.Tooltip, {
|
|
339
|
-
targetRef: inputRootRef,
|
|
340
|
-
text: tooltip,
|
|
341
|
-
width: tooltipWidth,
|
|
342
|
-
position: tooltipPosition
|
|
343
|
-
}));
|
|
43
|
+
disabled: isDisabled
|
|
44
|
+
}, props);
|
|
45
|
+
if (unvisible || hideContent) return null;
|
|
46
|
+
if (gridLayout) {
|
|
47
|
+
return /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
|
|
48
|
+
cols: gridLayout
|
|
49
|
+
}, /*#__PURE__*/_react.default.createElement(_base.InputBase, _extends({
|
|
50
|
+
ref: ref
|
|
51
|
+
}, inputProps)));
|
|
52
|
+
}
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(_base.InputBase, _extends({
|
|
54
|
+
ref: ref
|
|
55
|
+
}, inputProps));
|
|
344
56
|
});
|
|
345
57
|
Input.displayName = 'DateFieldInput';
|
|
@@ -8,11 +8,10 @@ import { DateValueReturnType } from '../types.js';
|
|
|
8
8
|
import 'react';
|
|
9
9
|
|
|
10
10
|
type InputHTMLProps = Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'multiple'>;
|
|
11
|
-
interface
|
|
11
|
+
interface DateFieldInputBaseProps extends InputHTMLProps, ITooltipCommonProps {
|
|
12
12
|
hint?: string;
|
|
13
13
|
label?: string;
|
|
14
14
|
errors?: string[];
|
|
15
|
-
gridLayout?: string;
|
|
16
15
|
customClass?: string;
|
|
17
16
|
customClassLabel?: string;
|
|
18
17
|
customClassWrapper?: string;
|
|
@@ -30,6 +29,9 @@ interface DateFieldInputProps extends InputHTMLProps, ITooltipCommonProps {
|
|
|
30
29
|
hintPosition?: HintPosition;
|
|
31
30
|
themePopover?: ColorTheme;
|
|
32
31
|
popoverAlign?: Extract<Position, 'left' | 'right'>;
|
|
32
|
+
}
|
|
33
|
+
interface DateFieldInputProps extends DateFieldInputBaseProps {
|
|
34
|
+
gridLayout?: string;
|
|
33
35
|
permissionAttr?: PermissionAttr;
|
|
34
36
|
onDeniedActions?: OnDenied;
|
|
35
37
|
}
|
|
@@ -60,4 +62,4 @@ interface DateFieldContextProps {
|
|
|
60
62
|
handleOnClickClearSelectedDate: () => void;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
export { DateFieldContextProps, DateFieldInputProps };
|
|
65
|
+
export { DateFieldContextProps, DateFieldInputBaseProps, DateFieldInputProps };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { DatePeriodFieldBaseProps } from './types.js';
|
|
3
|
+
import 'moment';
|
|
4
|
+
import '../../../@types/Align.js';
|
|
5
|
+
import '../../../@types/ColorStyles.js';
|
|
6
|
+
import '../../../tooltip/types.js';
|
|
7
|
+
import '../../../@types/Position.js';
|
|
8
|
+
import '../../../@types/PermissionAttr.js';
|
|
9
|
+
import '../types.js';
|
|
10
|
+
|
|
11
|
+
declare const InputBase: React__default.ForwardRefExoticComponent<DatePeriodFieldBaseProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
12
|
+
|
|
13
|
+
export { InputBase };
|