@rolster/react-components 18.15.1 → 18.15.2
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/dist/cjs/assets/{index-xOmRdBnF.css → index-Dbh6DUCn.css} +15 -10
- package/dist/cjs/index.js +1759 -1574
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/assets/{index-xOmRdBnF.css → index-Dbh6DUCn.css} +15 -10
- package/dist/es/index.js +1641 -1456
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/atoms/CheckBox/CheckBox.js +2 -2
- package/dist/esm/components/atoms/CheckBox/CheckBox.js.map +1 -1
- package/dist/esm/components/atoms/Input/Input.js +4 -4
- package/dist/esm/components/atoms/InputMoney/InputMoney.js +2 -2
- package/dist/esm/components/atoms/InputMoney/InputMoney.js.map +1 -1
- package/dist/esm/components/atoms/InputNumber/InputNumber.js +2 -2
- package/dist/esm/components/atoms/InputPassword/InputPassword.js +1 -1
- package/dist/esm/components/atoms/InputText/InputText.js +2 -2
- package/dist/esm/components/atoms/InputText/InputText.js.map +1 -1
- package/dist/esm/components/atoms/Switch/Switch.js +2 -2
- package/dist/esm/components/molecules/LabelCheckBox/LabelCheckBox.js +4 -4
- package/dist/esm/components/molecules/LabelRadioButton/LabelRadioButton.js +4 -4
- package/dist/esm/components/molecules/LabelSwitch/LabelSwitch.js +4 -4
- package/dist/esm/components/molecules/Pagination/Pagination.d.ts +7 -19
- package/dist/esm/components/molecules/Pagination/Pagination.js +42 -198
- package/dist/esm/components/molecules/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/molecules/PickerDay/PickerDay.css +5 -3
- package/dist/esm/components/molecules/PickerDay/PickerDay.js +6 -6
- package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js +4 -4
- package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js.map +1 -1
- package/dist/esm/components/molecules/PickerMonth/PickerMonth.js +6 -6
- package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.css +1 -1
- package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.js +16 -16
- package/dist/esm/components/molecules/PickerYear/PickerYear.css +8 -3
- package/dist/esm/components/molecules/PickerYear/PickerYear.js +6 -6
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.d.ts +5 -5
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +14 -14
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js +6 -6
- package/dist/esm/components/organisms/FieldDate/FieldDate.d.ts +3 -2
- package/dist/esm/components/organisms/FieldDate/FieldDate.js +15 -14
- package/dist/esm/components/organisms/FieldDate/FieldDate.js.map +1 -1
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js +2 -2
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.d.ts +4 -4
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +9 -9
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js +4 -4
- package/dist/esm/components/organisms/PickerDate/PickerDate.css +1 -3
- package/dist/esm/components/organisms/PickerDate/PickerDate.js +23 -23
- package/dist/esm/components/organisms/PickerDate/PickerDate.js.map +1 -1
- package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js +13 -13
- package/dist/esm/hooks/ListControlHook.d.ts +1 -1
- package/dist/esm/hooks/ListControlHook.js +23 -23
- package/dist/esm/hooks/ListControlHook.js.map +1 -1
- package/package.json +13 -15
package/dist/es/index.js
CHANGED
|
@@ -1,55 +1,1359 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import require$$0, { useState, useRef, useEffect, createContext } from 'react';
|
|
2
|
+
import { currencyFormat, itIsDefined, PartialSealed } from '@rolster/commons';
|
|
3
|
+
import { PaginationController, checkDayPicker, createDayPicker, createDayRangePicker, checkMonthPicker, createMonthPicker, monthLimitTemplate, createYearPicker, checkYearPicker, ListCollection, locationListCanTop, navigationListFromInput, navigationListFromElement, createAutocompleteStore, checkDateRange, dateOutRange, PickerListenerType } from '@rolster/components';
|
|
4
|
+
import { DAY_LABELS, DateRange, normalizeMinTime, dateFormatTemplate, assignDayInDate, dateIsBefore, MONTH_NAMES, Month, assignYearInDate, assignMonthInDate } from '@rolster/dates';
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
|
-
import '
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
6
|
+
import { i18n } from '@rolster/i18n';
|
|
7
|
+
import { useReactControl } from '@rolster/react-forms';
|
|
8
|
+
|
|
9
|
+
var jsxRuntime = {exports: {}};
|
|
10
|
+
|
|
11
|
+
var reactJsxRuntime_production_min = {};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @license React
|
|
15
|
+
* react-jsx-runtime.production.min.js
|
|
16
|
+
*
|
|
17
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the MIT license found in the
|
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
var hasRequiredReactJsxRuntime_production_min;
|
|
24
|
+
|
|
25
|
+
function requireReactJsxRuntime_production_min () {
|
|
26
|
+
if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
|
|
27
|
+
hasRequiredReactJsxRuntime_production_min = 1;
|
|
28
|
+
var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};
|
|
29
|
+
function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return {$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}reactJsxRuntime_production_min.Fragment=l;reactJsxRuntime_production_min.jsx=q;reactJsxRuntime_production_min.jsxs=q;
|
|
30
|
+
return reactJsxRuntime_production_min;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var reactJsxRuntime_development = {};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @license React
|
|
37
|
+
* react-jsx-runtime.development.js
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
var hasRequiredReactJsxRuntime_development;
|
|
46
|
+
|
|
47
|
+
function requireReactJsxRuntime_development () {
|
|
48
|
+
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
49
|
+
hasRequiredReactJsxRuntime_development = 1;
|
|
50
|
+
|
|
51
|
+
if (process.env.NODE_ENV !== "production") {
|
|
52
|
+
(function() {
|
|
53
|
+
|
|
54
|
+
var React = require$$0;
|
|
55
|
+
|
|
56
|
+
// ATTENTION
|
|
57
|
+
// When adding new symbols to this file,
|
|
58
|
+
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
59
|
+
// The Symbol used to tag the ReactElement-like types.
|
|
60
|
+
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
|
61
|
+
var REACT_PORTAL_TYPE = Symbol.for('react.portal');
|
|
62
|
+
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
|
63
|
+
var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
|
|
64
|
+
var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
|
|
65
|
+
var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
|
66
|
+
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
|
67
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
|
68
|
+
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
|
69
|
+
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
|
70
|
+
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
|
71
|
+
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
|
72
|
+
var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
|
|
73
|
+
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
|
74
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
75
|
+
function getIteratorFn(maybeIterable) {
|
|
76
|
+
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
81
|
+
|
|
82
|
+
if (typeof maybeIterator === 'function') {
|
|
83
|
+
return maybeIterator;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
90
|
+
|
|
91
|
+
function error(format) {
|
|
92
|
+
{
|
|
93
|
+
{
|
|
94
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
95
|
+
args[_key2 - 1] = arguments[_key2];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
printWarning('error', format, args);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function printWarning(level, format, args) {
|
|
104
|
+
// When changing this logic, you might want to also
|
|
105
|
+
// update consoleWithStackDev.www.js as well.
|
|
106
|
+
{
|
|
107
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
108
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
109
|
+
|
|
110
|
+
if (stack !== '') {
|
|
111
|
+
format += '%s';
|
|
112
|
+
args = args.concat([stack]);
|
|
113
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
var argsWithFormat = args.map(function (item) {
|
|
117
|
+
return String(item);
|
|
118
|
+
}); // Careful: RN currently depends on this prefix
|
|
119
|
+
|
|
120
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
121
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
122
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
|
123
|
+
|
|
124
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// -----------------------------------------------------------------------------
|
|
129
|
+
|
|
130
|
+
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
|
131
|
+
var enableCacheElement = false;
|
|
132
|
+
var enableTransitionTracing = false; // No known bugs, but needs performance testing
|
|
133
|
+
|
|
134
|
+
var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
|
|
135
|
+
// stuff. Intended to enable React core members to more easily debug scheduling
|
|
136
|
+
// issues in DEV builds.
|
|
137
|
+
|
|
138
|
+
var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
|
|
139
|
+
|
|
140
|
+
var REACT_MODULE_REFERENCE;
|
|
141
|
+
|
|
142
|
+
{
|
|
143
|
+
REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function isValidElementType(type) {
|
|
147
|
+
if (typeof type === 'string' || typeof type === 'function') {
|
|
148
|
+
return true;
|
|
149
|
+
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (typeof type === 'object' && type !== null) {
|
|
157
|
+
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
|
|
158
|
+
// types supported by any Flight configuration anywhere since
|
|
159
|
+
// we don't know which Flight build this will end up being used
|
|
160
|
+
// with.
|
|
161
|
+
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function getWrappedName(outerType, innerType, wrapperName) {
|
|
170
|
+
var displayName = outerType.displayName;
|
|
171
|
+
|
|
172
|
+
if (displayName) {
|
|
173
|
+
return displayName;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
var functionName = innerType.displayName || innerType.name || '';
|
|
177
|
+
return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
|
|
178
|
+
} // Keep in sync with react-reconciler/getComponentNameFromFiber
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
function getContextName(type) {
|
|
182
|
+
return type.displayName || 'Context';
|
|
183
|
+
} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
function getComponentNameFromType(type) {
|
|
187
|
+
if (type == null) {
|
|
188
|
+
// Host root, text node or just invalid type.
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
{
|
|
193
|
+
if (typeof type.tag === 'number') {
|
|
194
|
+
error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (typeof type === 'function') {
|
|
199
|
+
return type.displayName || type.name || null;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (typeof type === 'string') {
|
|
203
|
+
return type;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
switch (type) {
|
|
207
|
+
case REACT_FRAGMENT_TYPE:
|
|
208
|
+
return 'Fragment';
|
|
209
|
+
|
|
210
|
+
case REACT_PORTAL_TYPE:
|
|
211
|
+
return 'Portal';
|
|
212
|
+
|
|
213
|
+
case REACT_PROFILER_TYPE:
|
|
214
|
+
return 'Profiler';
|
|
215
|
+
|
|
216
|
+
case REACT_STRICT_MODE_TYPE:
|
|
217
|
+
return 'StrictMode';
|
|
218
|
+
|
|
219
|
+
case REACT_SUSPENSE_TYPE:
|
|
220
|
+
return 'Suspense';
|
|
221
|
+
|
|
222
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
223
|
+
return 'SuspenseList';
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (typeof type === 'object') {
|
|
228
|
+
switch (type.$$typeof) {
|
|
229
|
+
case REACT_CONTEXT_TYPE:
|
|
230
|
+
var context = type;
|
|
231
|
+
return getContextName(context) + '.Consumer';
|
|
232
|
+
|
|
233
|
+
case REACT_PROVIDER_TYPE:
|
|
234
|
+
var provider = type;
|
|
235
|
+
return getContextName(provider._context) + '.Provider';
|
|
236
|
+
|
|
237
|
+
case REACT_FORWARD_REF_TYPE:
|
|
238
|
+
return getWrappedName(type, type.render, 'ForwardRef');
|
|
239
|
+
|
|
240
|
+
case REACT_MEMO_TYPE:
|
|
241
|
+
var outerName = type.displayName || null;
|
|
242
|
+
|
|
243
|
+
if (outerName !== null) {
|
|
244
|
+
return outerName;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return getComponentNameFromType(type.type) || 'Memo';
|
|
248
|
+
|
|
249
|
+
case REACT_LAZY_TYPE:
|
|
250
|
+
{
|
|
251
|
+
var lazyComponent = type;
|
|
252
|
+
var payload = lazyComponent._payload;
|
|
253
|
+
var init = lazyComponent._init;
|
|
254
|
+
|
|
255
|
+
try {
|
|
256
|
+
return getComponentNameFromType(init(payload));
|
|
257
|
+
} catch (x) {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// eslint-disable-next-line no-fallthrough
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
var assign = Object.assign;
|
|
270
|
+
|
|
271
|
+
// Helpers to patch console.logs to avoid logging during side-effect free
|
|
272
|
+
// replaying on render function. This currently only patches the object
|
|
273
|
+
// lazily which won't cover if the log function was extracted eagerly.
|
|
274
|
+
// We could also eagerly patch the method.
|
|
275
|
+
var disabledDepth = 0;
|
|
276
|
+
var prevLog;
|
|
277
|
+
var prevInfo;
|
|
278
|
+
var prevWarn;
|
|
279
|
+
var prevError;
|
|
280
|
+
var prevGroup;
|
|
281
|
+
var prevGroupCollapsed;
|
|
282
|
+
var prevGroupEnd;
|
|
283
|
+
|
|
284
|
+
function disabledLog() {}
|
|
285
|
+
|
|
286
|
+
disabledLog.__reactDisabledLog = true;
|
|
287
|
+
function disableLogs() {
|
|
288
|
+
{
|
|
289
|
+
if (disabledDepth === 0) {
|
|
290
|
+
/* eslint-disable react-internal/no-production-logging */
|
|
291
|
+
prevLog = console.log;
|
|
292
|
+
prevInfo = console.info;
|
|
293
|
+
prevWarn = console.warn;
|
|
294
|
+
prevError = console.error;
|
|
295
|
+
prevGroup = console.group;
|
|
296
|
+
prevGroupCollapsed = console.groupCollapsed;
|
|
297
|
+
prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
|
|
298
|
+
|
|
299
|
+
var props = {
|
|
300
|
+
configurable: true,
|
|
301
|
+
enumerable: true,
|
|
302
|
+
value: disabledLog,
|
|
303
|
+
writable: true
|
|
304
|
+
}; // $FlowFixMe Flow thinks console is immutable.
|
|
305
|
+
|
|
306
|
+
Object.defineProperties(console, {
|
|
307
|
+
info: props,
|
|
308
|
+
log: props,
|
|
309
|
+
warn: props,
|
|
310
|
+
error: props,
|
|
311
|
+
group: props,
|
|
312
|
+
groupCollapsed: props,
|
|
313
|
+
groupEnd: props
|
|
314
|
+
});
|
|
315
|
+
/* eslint-enable react-internal/no-production-logging */
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
disabledDepth++;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function reenableLogs() {
|
|
322
|
+
{
|
|
323
|
+
disabledDepth--;
|
|
324
|
+
|
|
325
|
+
if (disabledDepth === 0) {
|
|
326
|
+
/* eslint-disable react-internal/no-production-logging */
|
|
327
|
+
var props = {
|
|
328
|
+
configurable: true,
|
|
329
|
+
enumerable: true,
|
|
330
|
+
writable: true
|
|
331
|
+
}; // $FlowFixMe Flow thinks console is immutable.
|
|
332
|
+
|
|
333
|
+
Object.defineProperties(console, {
|
|
334
|
+
log: assign({}, props, {
|
|
335
|
+
value: prevLog
|
|
336
|
+
}),
|
|
337
|
+
info: assign({}, props, {
|
|
338
|
+
value: prevInfo
|
|
339
|
+
}),
|
|
340
|
+
warn: assign({}, props, {
|
|
341
|
+
value: prevWarn
|
|
342
|
+
}),
|
|
343
|
+
error: assign({}, props, {
|
|
344
|
+
value: prevError
|
|
345
|
+
}),
|
|
346
|
+
group: assign({}, props, {
|
|
347
|
+
value: prevGroup
|
|
348
|
+
}),
|
|
349
|
+
groupCollapsed: assign({}, props, {
|
|
350
|
+
value: prevGroupCollapsed
|
|
351
|
+
}),
|
|
352
|
+
groupEnd: assign({}, props, {
|
|
353
|
+
value: prevGroupEnd
|
|
354
|
+
})
|
|
355
|
+
});
|
|
356
|
+
/* eslint-enable react-internal/no-production-logging */
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (disabledDepth < 0) {
|
|
360
|
+
error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
366
|
+
var prefix;
|
|
367
|
+
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
|
368
|
+
{
|
|
369
|
+
if (prefix === undefined) {
|
|
370
|
+
// Extract the VM specific prefix used by each line.
|
|
371
|
+
try {
|
|
372
|
+
throw Error();
|
|
373
|
+
} catch (x) {
|
|
374
|
+
var match = x.stack.trim().match(/\n( *(at )?)/);
|
|
375
|
+
prefix = match && match[1] || '';
|
|
376
|
+
}
|
|
377
|
+
} // We use the prefix to ensure our stacks line up with native stack frames.
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
return '\n' + prefix + name;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
var reentry = false;
|
|
384
|
+
var componentFrameCache;
|
|
385
|
+
|
|
386
|
+
{
|
|
387
|
+
var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
|
|
388
|
+
componentFrameCache = new PossiblyWeakMap();
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function describeNativeComponentFrame(fn, construct) {
|
|
392
|
+
// If something asked for a stack inside a fake render, it should get ignored.
|
|
393
|
+
if ( !fn || reentry) {
|
|
394
|
+
return '';
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
{
|
|
398
|
+
var frame = componentFrameCache.get(fn);
|
|
399
|
+
|
|
400
|
+
if (frame !== undefined) {
|
|
401
|
+
return frame;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
var control;
|
|
406
|
+
reentry = true;
|
|
407
|
+
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
|
|
408
|
+
|
|
409
|
+
Error.prepareStackTrace = undefined;
|
|
410
|
+
var previousDispatcher;
|
|
411
|
+
|
|
412
|
+
{
|
|
413
|
+
previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
|
|
414
|
+
// for warnings.
|
|
415
|
+
|
|
416
|
+
ReactCurrentDispatcher.current = null;
|
|
417
|
+
disableLogs();
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
try {
|
|
421
|
+
// This should throw.
|
|
422
|
+
if (construct) {
|
|
423
|
+
// Something should be setting the props in the constructor.
|
|
424
|
+
var Fake = function () {
|
|
425
|
+
throw Error();
|
|
426
|
+
}; // $FlowFixMe
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
Object.defineProperty(Fake.prototype, 'props', {
|
|
430
|
+
set: function () {
|
|
431
|
+
// We use a throwing setter instead of frozen or non-writable props
|
|
432
|
+
// because that won't throw in a non-strict mode function.
|
|
433
|
+
throw Error();
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
if (typeof Reflect === 'object' && Reflect.construct) {
|
|
438
|
+
// We construct a different control for this case to include any extra
|
|
439
|
+
// frames added by the construct call.
|
|
440
|
+
try {
|
|
441
|
+
Reflect.construct(Fake, []);
|
|
442
|
+
} catch (x) {
|
|
443
|
+
control = x;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
Reflect.construct(fn, [], Fake);
|
|
447
|
+
} else {
|
|
448
|
+
try {
|
|
449
|
+
Fake.call();
|
|
450
|
+
} catch (x) {
|
|
451
|
+
control = x;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
fn.call(Fake.prototype);
|
|
455
|
+
}
|
|
456
|
+
} else {
|
|
457
|
+
try {
|
|
458
|
+
throw Error();
|
|
459
|
+
} catch (x) {
|
|
460
|
+
control = x;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
fn();
|
|
464
|
+
}
|
|
465
|
+
} catch (sample) {
|
|
466
|
+
// This is inlined manually because closure doesn't do it for us.
|
|
467
|
+
if (sample && control && typeof sample.stack === 'string') {
|
|
468
|
+
// This extracts the first frame from the sample that isn't also in the control.
|
|
469
|
+
// Skipping one frame that we assume is the frame that calls the two.
|
|
470
|
+
var sampleLines = sample.stack.split('\n');
|
|
471
|
+
var controlLines = control.stack.split('\n');
|
|
472
|
+
var s = sampleLines.length - 1;
|
|
473
|
+
var c = controlLines.length - 1;
|
|
474
|
+
|
|
475
|
+
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
|
476
|
+
// We expect at least one stack frame to be shared.
|
|
477
|
+
// Typically this will be the root most one. However, stack frames may be
|
|
478
|
+
// cut off due to maximum stack limits. In this case, one maybe cut off
|
|
479
|
+
// earlier than the other. We assume that the sample is longer or the same
|
|
480
|
+
// and there for cut off earlier. So we should find the root most frame in
|
|
481
|
+
// the sample somewhere in the control.
|
|
482
|
+
c--;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
for (; s >= 1 && c >= 0; s--, c--) {
|
|
486
|
+
// Next we find the first one that isn't the same which should be the
|
|
487
|
+
// frame that called our sample function and the control.
|
|
488
|
+
if (sampleLines[s] !== controlLines[c]) {
|
|
489
|
+
// In V8, the first line is describing the message but other VMs don't.
|
|
490
|
+
// If we're about to return the first line, and the control is also on the same
|
|
491
|
+
// line, that's a pretty good indicator that our sample threw at same line as
|
|
492
|
+
// the control. I.e. before we entered the sample frame. So we ignore this result.
|
|
493
|
+
// This can happen if you passed a class to function component, or non-function.
|
|
494
|
+
if (s !== 1 || c !== 1) {
|
|
495
|
+
do {
|
|
496
|
+
s--;
|
|
497
|
+
c--; // We may still have similar intermediate frames from the construct call.
|
|
498
|
+
// The next one that isn't the same should be our match though.
|
|
499
|
+
|
|
500
|
+
if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
|
501
|
+
// V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
|
|
502
|
+
var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
|
|
503
|
+
// but we have a user-provided "displayName"
|
|
504
|
+
// splice it in to make the stack more readable.
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
if (fn.displayName && _frame.includes('<anonymous>')) {
|
|
508
|
+
_frame = _frame.replace('<anonymous>', fn.displayName);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
{
|
|
512
|
+
if (typeof fn === 'function') {
|
|
513
|
+
componentFrameCache.set(fn, _frame);
|
|
514
|
+
}
|
|
515
|
+
} // Return the line we found.
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
return _frame;
|
|
519
|
+
}
|
|
520
|
+
} while (s >= 1 && c >= 0);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
} finally {
|
|
528
|
+
reentry = false;
|
|
529
|
+
|
|
530
|
+
{
|
|
531
|
+
ReactCurrentDispatcher.current = previousDispatcher;
|
|
532
|
+
reenableLogs();
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
Error.prepareStackTrace = previousPrepareStackTrace;
|
|
536
|
+
} // Fallback to just using the name if we couldn't make it throw.
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
var name = fn ? fn.displayName || fn.name : '';
|
|
540
|
+
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
|
|
541
|
+
|
|
542
|
+
{
|
|
543
|
+
if (typeof fn === 'function') {
|
|
544
|
+
componentFrameCache.set(fn, syntheticFrame);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
return syntheticFrame;
|
|
549
|
+
}
|
|
550
|
+
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
|
551
|
+
{
|
|
552
|
+
return describeNativeComponentFrame(fn, false);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function shouldConstruct(Component) {
|
|
557
|
+
var prototype = Component.prototype;
|
|
558
|
+
return !!(prototype && prototype.isReactComponent);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
|
562
|
+
|
|
563
|
+
if (type == null) {
|
|
564
|
+
return '';
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (typeof type === 'function') {
|
|
568
|
+
{
|
|
569
|
+
return describeNativeComponentFrame(type, shouldConstruct(type));
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
if (typeof type === 'string') {
|
|
574
|
+
return describeBuiltInComponentFrame(type);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
switch (type) {
|
|
578
|
+
case REACT_SUSPENSE_TYPE:
|
|
579
|
+
return describeBuiltInComponentFrame('Suspense');
|
|
580
|
+
|
|
581
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
582
|
+
return describeBuiltInComponentFrame('SuspenseList');
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
if (typeof type === 'object') {
|
|
586
|
+
switch (type.$$typeof) {
|
|
587
|
+
case REACT_FORWARD_REF_TYPE:
|
|
588
|
+
return describeFunctionComponentFrame(type.render);
|
|
589
|
+
|
|
590
|
+
case REACT_MEMO_TYPE:
|
|
591
|
+
// Memo may contain any component type so we recursively resolve it.
|
|
592
|
+
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
|
593
|
+
|
|
594
|
+
case REACT_LAZY_TYPE:
|
|
595
|
+
{
|
|
596
|
+
var lazyComponent = type;
|
|
597
|
+
var payload = lazyComponent._payload;
|
|
598
|
+
var init = lazyComponent._init;
|
|
599
|
+
|
|
600
|
+
try {
|
|
601
|
+
// Lazy may contain any component type so we recursively resolve it.
|
|
602
|
+
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
|
603
|
+
} catch (x) {}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
return '';
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
612
|
+
|
|
613
|
+
var loggedTypeFailures = {};
|
|
614
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
615
|
+
|
|
616
|
+
function setCurrentlyValidatingElement(element) {
|
|
617
|
+
{
|
|
618
|
+
if (element) {
|
|
619
|
+
var owner = element._owner;
|
|
620
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
621
|
+
ReactDebugCurrentFrame.setExtraStackFrame(stack);
|
|
622
|
+
} else {
|
|
623
|
+
ReactDebugCurrentFrame.setExtraStackFrame(null);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
629
|
+
{
|
|
630
|
+
// $FlowFixMe This is okay but Flow doesn't know it.
|
|
631
|
+
var has = Function.call.bind(hasOwnProperty);
|
|
632
|
+
|
|
633
|
+
for (var typeSpecName in typeSpecs) {
|
|
634
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
635
|
+
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
|
|
636
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
637
|
+
// After these have been cleaned up, we'll let them throw.
|
|
638
|
+
|
|
639
|
+
try {
|
|
640
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
641
|
+
// behavior as without this statement except with a better message.
|
|
642
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
643
|
+
// eslint-disable-next-line react-internal/prod-error-codes
|
|
644
|
+
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
|
|
645
|
+
err.name = 'Invariant Violation';
|
|
646
|
+
throw err;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
|
|
650
|
+
} catch (ex) {
|
|
651
|
+
error$1 = ex;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
if (error$1 && !(error$1 instanceof Error)) {
|
|
655
|
+
setCurrentlyValidatingElement(element);
|
|
656
|
+
|
|
657
|
+
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
|
|
658
|
+
|
|
659
|
+
setCurrentlyValidatingElement(null);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
663
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
664
|
+
// same error.
|
|
665
|
+
loggedTypeFailures[error$1.message] = true;
|
|
666
|
+
setCurrentlyValidatingElement(element);
|
|
667
|
+
|
|
668
|
+
error('Failed %s type: %s', location, error$1.message);
|
|
669
|
+
|
|
670
|
+
setCurrentlyValidatingElement(null);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
|
678
|
+
|
|
679
|
+
function isArray(a) {
|
|
680
|
+
return isArrayImpl(a);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/*
|
|
684
|
+
* The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
|
|
685
|
+
* and Temporal.* types. See https://github.com/facebook/react/pull/22064.
|
|
686
|
+
*
|
|
687
|
+
* The functions in this module will throw an easier-to-understand,
|
|
688
|
+
* easier-to-debug exception with a clear errors message message explaining the
|
|
689
|
+
* problem. (Instead of a confusing exception thrown inside the implementation
|
|
690
|
+
* of the `value` object).
|
|
691
|
+
*/
|
|
692
|
+
// $FlowFixMe only called in DEV, so void return is not possible.
|
|
693
|
+
function typeName(value) {
|
|
694
|
+
{
|
|
695
|
+
// toStringTag is needed for namespaced types like Temporal.Instant
|
|
696
|
+
var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
|
|
697
|
+
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
|
|
698
|
+
return type;
|
|
699
|
+
}
|
|
700
|
+
} // $FlowFixMe only called in DEV, so void return is not possible.
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
function willCoercionThrow(value) {
|
|
704
|
+
{
|
|
705
|
+
try {
|
|
706
|
+
testStringCoercion(value);
|
|
707
|
+
return false;
|
|
708
|
+
} catch (e) {
|
|
709
|
+
return true;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
function testStringCoercion(value) {
|
|
715
|
+
// If you ended up here by following an exception call stack, here's what's
|
|
716
|
+
// happened: you supplied an object or symbol value to React (as a prop, key,
|
|
717
|
+
// DOM attribute, CSS property, string ref, etc.) and when React tried to
|
|
718
|
+
// coerce it to a string using `'' + value`, an exception was thrown.
|
|
719
|
+
//
|
|
720
|
+
// The most common types that will cause this exception are `Symbol` instances
|
|
721
|
+
// and Temporal objects like `Temporal.Instant`. But any object that has a
|
|
722
|
+
// `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
|
|
723
|
+
// exception. (Library authors do this to prevent users from using built-in
|
|
724
|
+
// numeric operators like `+` or comparison operators like `>=` because custom
|
|
725
|
+
// methods are needed to perform accurate arithmetic or comparison.)
|
|
726
|
+
//
|
|
727
|
+
// To fix the problem, coerce this object or symbol value to a string before
|
|
728
|
+
// passing it to React. The most reliable way is usually `String(value)`.
|
|
729
|
+
//
|
|
730
|
+
// To find which value is throwing, check the browser or debugger console.
|
|
731
|
+
// Before this exception was thrown, there should be `console.error` output
|
|
732
|
+
// that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
|
|
733
|
+
// problem and how that type was used: key, atrribute, input value prop, etc.
|
|
734
|
+
// In most cases, this console output also shows the component and its
|
|
735
|
+
// ancestor components where the exception happened.
|
|
736
|
+
//
|
|
737
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
|
738
|
+
return '' + value;
|
|
739
|
+
}
|
|
740
|
+
function checkKeyStringCoercion(value) {
|
|
741
|
+
{
|
|
742
|
+
if (willCoercionThrow(value)) {
|
|
743
|
+
error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
|
|
744
|
+
|
|
745
|
+
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
751
|
+
var RESERVED_PROPS = {
|
|
752
|
+
key: true,
|
|
753
|
+
ref: true,
|
|
754
|
+
__self: true,
|
|
755
|
+
__source: true
|
|
756
|
+
};
|
|
757
|
+
var specialPropKeyWarningShown;
|
|
758
|
+
var specialPropRefWarningShown;
|
|
759
|
+
var didWarnAboutStringRefs;
|
|
760
|
+
|
|
761
|
+
{
|
|
762
|
+
didWarnAboutStringRefs = {};
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
function hasValidRef(config) {
|
|
766
|
+
{
|
|
767
|
+
if (hasOwnProperty.call(config, 'ref')) {
|
|
768
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
769
|
+
|
|
770
|
+
if (getter && getter.isReactWarning) {
|
|
771
|
+
return false;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
return config.ref !== undefined;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
function hasValidKey(config) {
|
|
780
|
+
{
|
|
781
|
+
if (hasOwnProperty.call(config, 'key')) {
|
|
782
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
|
783
|
+
|
|
784
|
+
if (getter && getter.isReactWarning) {
|
|
785
|
+
return false;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
return config.key !== undefined;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function warnIfStringRefCannotBeAutoConverted(config, self) {
|
|
794
|
+
{
|
|
795
|
+
if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
|
|
796
|
+
var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
|
|
797
|
+
|
|
798
|
+
if (!didWarnAboutStringRefs[componentName]) {
|
|
799
|
+
error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
|
|
800
|
+
|
|
801
|
+
didWarnAboutStringRefs[componentName] = true;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
808
|
+
{
|
|
809
|
+
var warnAboutAccessingKey = function () {
|
|
810
|
+
if (!specialPropKeyWarningShown) {
|
|
811
|
+
specialPropKeyWarningShown = true;
|
|
812
|
+
|
|
813
|
+
error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
818
|
+
Object.defineProperty(props, 'key', {
|
|
819
|
+
get: warnAboutAccessingKey,
|
|
820
|
+
configurable: true
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
function defineRefPropWarningGetter(props, displayName) {
|
|
826
|
+
{
|
|
827
|
+
var warnAboutAccessingRef = function () {
|
|
828
|
+
if (!specialPropRefWarningShown) {
|
|
829
|
+
specialPropRefWarningShown = true;
|
|
830
|
+
|
|
831
|
+
error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
warnAboutAccessingRef.isReactWarning = true;
|
|
836
|
+
Object.defineProperty(props, 'ref', {
|
|
837
|
+
get: warnAboutAccessingRef,
|
|
838
|
+
configurable: true
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Factory method to create a new React element. This no longer adheres to
|
|
844
|
+
* the class pattern, so do not use new to call it. Also, instanceof check
|
|
845
|
+
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
846
|
+
* if something is a React Element.
|
|
847
|
+
*
|
|
848
|
+
* @param {*} type
|
|
849
|
+
* @param {*} props
|
|
850
|
+
* @param {*} key
|
|
851
|
+
* @param {string|object} ref
|
|
852
|
+
* @param {*} owner
|
|
853
|
+
* @param {*} self A *temporary* helper to detect places where `this` is
|
|
854
|
+
* different from the `owner` when React.createElement is called, so that we
|
|
855
|
+
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
|
856
|
+
* functions, and as long as `this` and owner are the same, there will be no
|
|
857
|
+
* change in behavior.
|
|
858
|
+
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
|
859
|
+
* indicating filename, line number, and/or other information.
|
|
860
|
+
* @internal
|
|
861
|
+
*/
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
865
|
+
var element = {
|
|
866
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
867
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
868
|
+
// Built-in properties that belong on the element
|
|
869
|
+
type: type,
|
|
870
|
+
key: key,
|
|
871
|
+
ref: ref,
|
|
872
|
+
props: props,
|
|
873
|
+
// Record the component responsible for creating this element.
|
|
874
|
+
_owner: owner
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
{
|
|
878
|
+
// The validation flag is currently mutative. We put it on
|
|
879
|
+
// an external backing store so that we can freeze the whole object.
|
|
880
|
+
// This can be replaced with a WeakMap once they are implemented in
|
|
881
|
+
// commonly used development environments.
|
|
882
|
+
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
|
883
|
+
// the validation flag non-enumerable (where possible, which should
|
|
884
|
+
// include every environment we run tests in), so the test framework
|
|
885
|
+
// ignores it.
|
|
886
|
+
|
|
887
|
+
Object.defineProperty(element._store, 'validated', {
|
|
888
|
+
configurable: false,
|
|
889
|
+
enumerable: false,
|
|
890
|
+
writable: true,
|
|
891
|
+
value: false
|
|
892
|
+
}); // self and source are DEV only properties.
|
|
893
|
+
|
|
894
|
+
Object.defineProperty(element, '_self', {
|
|
895
|
+
configurable: false,
|
|
896
|
+
enumerable: false,
|
|
897
|
+
writable: false,
|
|
898
|
+
value: self
|
|
899
|
+
}); // Two elements created in two different places should be considered
|
|
900
|
+
// equal for testing purposes and therefore we hide it from enumeration.
|
|
901
|
+
|
|
902
|
+
Object.defineProperty(element, '_source', {
|
|
903
|
+
configurable: false,
|
|
904
|
+
enumerable: false,
|
|
905
|
+
writable: false,
|
|
906
|
+
value: source
|
|
907
|
+
});
|
|
908
|
+
|
|
909
|
+
if (Object.freeze) {
|
|
910
|
+
Object.freeze(element.props);
|
|
911
|
+
Object.freeze(element);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
return element;
|
|
916
|
+
};
|
|
917
|
+
/**
|
|
918
|
+
* https://github.com/reactjs/rfcs/pull/107
|
|
919
|
+
* @param {*} type
|
|
920
|
+
* @param {object} props
|
|
921
|
+
* @param {string} key
|
|
922
|
+
*/
|
|
923
|
+
|
|
924
|
+
function jsxDEV(type, config, maybeKey, source, self) {
|
|
925
|
+
{
|
|
926
|
+
var propName; // Reserved names are extracted
|
|
927
|
+
|
|
928
|
+
var props = {};
|
|
929
|
+
var key = null;
|
|
930
|
+
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
|
931
|
+
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
|
932
|
+
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
|
933
|
+
// but as an intermediary step, we will use jsxDEV for everything except
|
|
934
|
+
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
|
935
|
+
// key is explicitly declared to be undefined or not.
|
|
936
|
+
|
|
937
|
+
if (maybeKey !== undefined) {
|
|
938
|
+
{
|
|
939
|
+
checkKeyStringCoercion(maybeKey);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
key = '' + maybeKey;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
if (hasValidKey(config)) {
|
|
946
|
+
{
|
|
947
|
+
checkKeyStringCoercion(config.key);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
key = '' + config.key;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
if (hasValidRef(config)) {
|
|
954
|
+
ref = config.ref;
|
|
955
|
+
warnIfStringRefCannotBeAutoConverted(config, self);
|
|
956
|
+
} // Remaining properties are added to a new props object
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
for (propName in config) {
|
|
960
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
961
|
+
props[propName] = config[propName];
|
|
962
|
+
}
|
|
963
|
+
} // Resolve default props
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
if (type && type.defaultProps) {
|
|
967
|
+
var defaultProps = type.defaultProps;
|
|
968
|
+
|
|
969
|
+
for (propName in defaultProps) {
|
|
970
|
+
if (props[propName] === undefined) {
|
|
971
|
+
props[propName] = defaultProps[propName];
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
if (key || ref) {
|
|
977
|
+
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
978
|
+
|
|
979
|
+
if (key) {
|
|
980
|
+
defineKeyPropWarningGetter(props, displayName);
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
if (ref) {
|
|
984
|
+
defineRefPropWarningGetter(props, displayName);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
|
993
|
+
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
994
|
+
|
|
995
|
+
function setCurrentlyValidatingElement$1(element) {
|
|
996
|
+
{
|
|
997
|
+
if (element) {
|
|
998
|
+
var owner = element._owner;
|
|
999
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
1000
|
+
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
|
1001
|
+
} else {
|
|
1002
|
+
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
var propTypesMisspellWarningShown;
|
|
1008
|
+
|
|
1009
|
+
{
|
|
1010
|
+
propTypesMisspellWarningShown = false;
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Verifies the object is a ReactElement.
|
|
1014
|
+
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
1015
|
+
* @param {?object} object
|
|
1016
|
+
* @return {boolean} True if `object` is a ReactElement.
|
|
1017
|
+
* @final
|
|
1018
|
+
*/
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
function isValidElement(object) {
|
|
1022
|
+
{
|
|
1023
|
+
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
function getDeclarationErrorAddendum() {
|
|
1028
|
+
{
|
|
1029
|
+
if (ReactCurrentOwner$1.current) {
|
|
1030
|
+
var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
|
|
1031
|
+
|
|
1032
|
+
if (name) {
|
|
1033
|
+
return '\n\nCheck the render method of `' + name + '`.';
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
return '';
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
function getSourceInfoErrorAddendum(source) {
|
|
1042
|
+
{
|
|
1043
|
+
|
|
1044
|
+
return '';
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
1049
|
+
* object keys are not valid. This allows us to keep track of children between
|
|
1050
|
+
* updates.
|
|
1051
|
+
*/
|
|
1052
|
+
|
|
1053
|
+
|
|
1054
|
+
var ownerHasKeyUseWarning = {};
|
|
1055
|
+
|
|
1056
|
+
function getCurrentComponentErrorInfo(parentType) {
|
|
1057
|
+
{
|
|
1058
|
+
var info = getDeclarationErrorAddendum();
|
|
1059
|
+
|
|
1060
|
+
if (!info) {
|
|
1061
|
+
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
1062
|
+
|
|
1063
|
+
if (parentName) {
|
|
1064
|
+
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
return info;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Warn if the element doesn't have an explicit key assigned to it.
|
|
1073
|
+
* This element is in an array. The array could grow and shrink or be
|
|
1074
|
+
* reordered. All children that haven't already been validated are required to
|
|
1075
|
+
* have a "key" property assigned to it. Error statuses are cached so a warning
|
|
1076
|
+
* will only be shown once.
|
|
1077
|
+
*
|
|
1078
|
+
* @internal
|
|
1079
|
+
* @param {ReactElement} element Element that requires a key.
|
|
1080
|
+
* @param {*} parentType element's parent's type.
|
|
1081
|
+
*/
|
|
1082
|
+
|
|
1083
|
+
|
|
1084
|
+
function validateExplicitKey(element, parentType) {
|
|
1085
|
+
{
|
|
1086
|
+
if (!element._store || element._store.validated || element.key != null) {
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
element._store.validated = true;
|
|
1091
|
+
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
1092
|
+
|
|
1093
|
+
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
|
1098
|
+
// property, it may be the creator of the child that's responsible for
|
|
1099
|
+
// assigning it a key.
|
|
1100
|
+
|
|
1101
|
+
var childOwner = '';
|
|
1102
|
+
|
|
1103
|
+
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
|
1104
|
+
// Give the component that originally created this child.
|
|
1105
|
+
childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
setCurrentlyValidatingElement$1(element);
|
|
1109
|
+
|
|
1110
|
+
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
1111
|
+
|
|
1112
|
+
setCurrentlyValidatingElement$1(null);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Ensure that every element either is passed in a static location, in an
|
|
1117
|
+
* array with an explicit keys property defined, or in an object literal
|
|
1118
|
+
* with valid key property.
|
|
1119
|
+
*
|
|
1120
|
+
* @internal
|
|
1121
|
+
* @param {ReactNode} node Statically passed child of any type.
|
|
1122
|
+
* @param {*} parentType node's parent's type.
|
|
1123
|
+
*/
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
function validateChildKeys(node, parentType) {
|
|
1127
|
+
{
|
|
1128
|
+
if (typeof node !== 'object') {
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
if (isArray(node)) {
|
|
1133
|
+
for (var i = 0; i < node.length; i++) {
|
|
1134
|
+
var child = node[i];
|
|
1135
|
+
|
|
1136
|
+
if (isValidElement(child)) {
|
|
1137
|
+
validateExplicitKey(child, parentType);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
} else if (isValidElement(node)) {
|
|
1141
|
+
// This element was passed in a valid location.
|
|
1142
|
+
if (node._store) {
|
|
1143
|
+
node._store.validated = true;
|
|
1144
|
+
}
|
|
1145
|
+
} else if (node) {
|
|
1146
|
+
var iteratorFn = getIteratorFn(node);
|
|
1147
|
+
|
|
1148
|
+
if (typeof iteratorFn === 'function') {
|
|
1149
|
+
// Entry iterators used to provide implicit keys,
|
|
1150
|
+
// but now we print a separate warning for them later.
|
|
1151
|
+
if (iteratorFn !== node.entries) {
|
|
1152
|
+
var iterator = iteratorFn.call(node);
|
|
1153
|
+
var step;
|
|
1154
|
+
|
|
1155
|
+
while (!(step = iterator.next()).done) {
|
|
1156
|
+
if (isValidElement(step.value)) {
|
|
1157
|
+
validateExplicitKey(step.value, parentType);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* Given an element, validate that its props follow the propTypes definition,
|
|
1167
|
+
* provided by the type.
|
|
1168
|
+
*
|
|
1169
|
+
* @param {ReactElement} element
|
|
1170
|
+
*/
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
function validatePropTypes(element) {
|
|
1174
|
+
{
|
|
1175
|
+
var type = element.type;
|
|
1176
|
+
|
|
1177
|
+
if (type === null || type === undefined || typeof type === 'string') {
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
var propTypes;
|
|
1182
|
+
|
|
1183
|
+
if (typeof type === 'function') {
|
|
1184
|
+
propTypes = type.propTypes;
|
|
1185
|
+
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
|
1186
|
+
// Inner props are checked in the reconciler.
|
|
1187
|
+
type.$$typeof === REACT_MEMO_TYPE)) {
|
|
1188
|
+
propTypes = type.propTypes;
|
|
1189
|
+
} else {
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
if (propTypes) {
|
|
1194
|
+
// Intentionally inside to avoid triggering lazy initializers:
|
|
1195
|
+
var name = getComponentNameFromType(type);
|
|
1196
|
+
checkPropTypes(propTypes, element.props, 'prop', name, element);
|
|
1197
|
+
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
1198
|
+
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
|
|
1199
|
+
|
|
1200
|
+
var _name = getComponentNameFromType(type);
|
|
1201
|
+
|
|
1202
|
+
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
|
|
1206
|
+
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Given a fragment, validate that it can only be provided with fragment props
|
|
1212
|
+
* @param {ReactElement} fragment
|
|
1213
|
+
*/
|
|
1214
|
+
|
|
1215
|
+
|
|
1216
|
+
function validateFragmentProps(fragment) {
|
|
1217
|
+
{
|
|
1218
|
+
var keys = Object.keys(fragment.props);
|
|
1219
|
+
|
|
1220
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1221
|
+
var key = keys[i];
|
|
1222
|
+
|
|
1223
|
+
if (key !== 'children' && key !== 'key') {
|
|
1224
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
1225
|
+
|
|
1226
|
+
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
1227
|
+
|
|
1228
|
+
setCurrentlyValidatingElement$1(null);
|
|
1229
|
+
break;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
if (fragment.ref !== null) {
|
|
1234
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
1235
|
+
|
|
1236
|
+
error('Invalid attribute `ref` supplied to `React.Fragment`.');
|
|
1237
|
+
|
|
1238
|
+
setCurrentlyValidatingElement$1(null);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
1244
|
+
{
|
|
1245
|
+
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
|
1246
|
+
// succeed and there will likely be errors in render.
|
|
1247
|
+
|
|
1248
|
+
if (!validType) {
|
|
1249
|
+
var info = '';
|
|
1250
|
+
|
|
1251
|
+
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
1252
|
+
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
var sourceInfo = getSourceInfoErrorAddendum();
|
|
1256
|
+
|
|
1257
|
+
if (sourceInfo) {
|
|
1258
|
+
info += sourceInfo;
|
|
1259
|
+
} else {
|
|
1260
|
+
info += getDeclarationErrorAddendum();
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
var typeString;
|
|
1264
|
+
|
|
1265
|
+
if (type === null) {
|
|
1266
|
+
typeString = 'null';
|
|
1267
|
+
} else if (isArray(type)) {
|
|
1268
|
+
typeString = 'array';
|
|
1269
|
+
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
1270
|
+
typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
|
|
1271
|
+
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
1272
|
+
} else {
|
|
1273
|
+
typeString = typeof type;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
|
1280
|
+
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
1281
|
+
|
|
1282
|
+
if (element == null) {
|
|
1283
|
+
return element;
|
|
1284
|
+
} // Skip key warning if the type isn't valid since our key validation logic
|
|
1285
|
+
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
1286
|
+
// We don't want exception behavior to differ between dev and prod.
|
|
1287
|
+
// (Rendering will throw with a helpful message and as soon as the type is
|
|
1288
|
+
// fixed, the key warnings will appear.)
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
if (validType) {
|
|
1292
|
+
var children = props.children;
|
|
1293
|
+
|
|
1294
|
+
if (children !== undefined) {
|
|
1295
|
+
if (isStaticChildren) {
|
|
1296
|
+
if (isArray(children)) {
|
|
1297
|
+
for (var i = 0; i < children.length; i++) {
|
|
1298
|
+
validateChildKeys(children[i], type);
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
if (Object.freeze) {
|
|
1302
|
+
Object.freeze(children);
|
|
1303
|
+
}
|
|
1304
|
+
} else {
|
|
1305
|
+
error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
|
1306
|
+
}
|
|
1307
|
+
} else {
|
|
1308
|
+
validateChildKeys(children, type);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
|
1314
|
+
validateFragmentProps(element);
|
|
1315
|
+
} else {
|
|
1316
|
+
validatePropTypes(element);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
return element;
|
|
1320
|
+
}
|
|
1321
|
+
} // These two functions exist to still get child warnings in dev
|
|
1322
|
+
// even with the prod transform. This means that jsxDEV is purely
|
|
1323
|
+
// opt-in behavior for better messages but that we won't stop
|
|
1324
|
+
// giving you warnings if you use production apis.
|
|
1325
|
+
|
|
1326
|
+
function jsxWithValidationStatic(type, props, key) {
|
|
1327
|
+
{
|
|
1328
|
+
return jsxWithValidation(type, props, key, true);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
function jsxWithValidationDynamic(type, props, key) {
|
|
1332
|
+
{
|
|
1333
|
+
return jsxWithValidation(type, props, key, false);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
|
|
1338
|
+
// for now we can ship identical prod functions
|
|
1339
|
+
|
|
1340
|
+
var jsxs = jsxWithValidationStatic ;
|
|
1341
|
+
|
|
1342
|
+
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
1343
|
+
reactJsxRuntime_development.jsx = jsx;
|
|
1344
|
+
reactJsxRuntime_development.jsxs = jsxs;
|
|
1345
|
+
})();
|
|
1346
|
+
}
|
|
1347
|
+
return reactJsxRuntime_development;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1351
|
+
jsxRuntime.exports = requireReactJsxRuntime_production_min();
|
|
1352
|
+
} else {
|
|
1353
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
53
1357
|
|
|
54
1358
|
const baseCls = 'rls-tabular-text';
|
|
55
1359
|
const pointers = ['.', ','];
|
|
@@ -57,11 +1361,11 @@ function charClass(char) {
|
|
|
57
1361
|
return pointers.includes(char) ? `${baseCls}__pointer` : `${baseCls}__char`;
|
|
58
1362
|
}
|
|
59
1363
|
function RlsTabularText({ value }) {
|
|
60
|
-
return (jsx("div", { className: "rls-tabular-text", children: value?.split('').map((char, index) => (jsx("span", { className: charClass(char), children: char }, index))) }));
|
|
1364
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-tabular-text", children: value?.split('').map((char, index) => (jsxRuntimeExports.jsx("span", { className: charClass(char), children: char }, index))) }));
|
|
61
1365
|
}
|
|
62
1366
|
|
|
63
1367
|
function RlsAmount({ value, decimals, rlsTheme, symbol }) {
|
|
64
|
-
return (jsxs("div", { className: "rls-amount", "rls-theme": rlsTheme, children: [symbol && jsx("span", { children: symbol }), jsx(RlsTabularText, { value: currencyFormat({ value, decimals }) })] }));
|
|
1368
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-amount", "rls-theme": rlsTheme, children: [symbol && jsxRuntimeExports.jsx("span", { children: symbol }), jsxRuntimeExports.jsx(RlsTabularText, { value: currencyFormat({ value, decimals }) })] }));
|
|
65
1369
|
}
|
|
66
1370
|
|
|
67
1371
|
function renderClassStatus(base, status = {}, aditionals) {
|
|
@@ -80,45 +1384,45 @@ function renderClassStatus(base, status = {}, aditionals) {
|
|
|
80
1384
|
}
|
|
81
1385
|
|
|
82
1386
|
function RlsAvatar({ children, rounded, skeleton, rlsTheme }) {
|
|
83
|
-
return (jsx("div", { className: renderClassStatus('rls-avatar', { rounded, skeleton }), "rls-theme": rlsTheme, children: children }));
|
|
1387
|
+
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-avatar', { rounded, skeleton }), "rls-theme": rlsTheme, children: children }));
|
|
84
1388
|
}
|
|
85
1389
|
|
|
86
1390
|
function RlsBadge({ children, rlsTheme }) {
|
|
87
|
-
return (jsx("div", { className: "rls-badge", "rls-theme": rlsTheme, children: children }));
|
|
1391
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-badge", "rls-theme": rlsTheme, children: children }));
|
|
88
1392
|
}
|
|
89
1393
|
|
|
90
1394
|
function RlsBreadcrumb({ labels }) {
|
|
91
|
-
return (jsx("div", { className: "rls-breadcrumb", children: labels.map(({ label, onClick }, index) => (jsx("label", { className: "rls-breadcrumb__label", onClick: onClick, children: jsx("a", { className: "rls-breadcrumb__label__a", children: label }) }, index))) }));
|
|
1395
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-breadcrumb", children: labels.map(({ label, onClick }, index) => (jsxRuntimeExports.jsx("label", { className: "rls-breadcrumb__label", onClick: onClick, children: jsxRuntimeExports.jsx("a", { className: "rls-breadcrumb__label__a", children: label }) }, index))) }));
|
|
92
1396
|
}
|
|
93
1397
|
|
|
94
1398
|
function RlsIcon({ value, skeleton }) {
|
|
95
|
-
return (jsx("div", { className: renderClassStatus('rls-icon', { skeleton }), children: jsx("i", { className: `rls-icon-${value}` }) }));
|
|
1399
|
+
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-icon', { skeleton }), children: jsxRuntimeExports.jsx("i", { className: `rls-icon-${value}` }) }));
|
|
96
1400
|
}
|
|
97
1401
|
|
|
98
1402
|
function RlsButton({ type, children, disabled, prefixIcon, suffixIcon, rlsTheme, onClick }) {
|
|
99
|
-
return (jsx("button", { className: "rls-button", onClick: onClick, "rls-theme": rlsTheme, disabled: disabled, children: jsxs("div", { className: renderClassStatus('rls-button__content', { type }), children: [prefixIcon && jsx(RlsIcon, { value: prefixIcon }), children && jsx("div", { className: "rls-button__label", children: children }), suffixIcon && jsx(RlsIcon, { value: suffixIcon })] }) }));
|
|
1403
|
+
return (jsxRuntimeExports.jsx("button", { className: "rls-button", onClick: onClick, "rls-theme": rlsTheme, disabled: disabled, children: jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-button__content', { type }), children: [prefixIcon && jsxRuntimeExports.jsx(RlsIcon, { value: prefixIcon }), children && jsxRuntimeExports.jsx("div", { className: "rls-button__label", children: children }), suffixIcon && jsxRuntimeExports.jsx(RlsIcon, { value: suffixIcon })] }) }));
|
|
100
1404
|
}
|
|
101
1405
|
|
|
102
1406
|
function RlsButtonAction({ icon, disabled, tooltip, onClick }) {
|
|
103
|
-
return (jsxs("button", { className: "rls-button-action", onClick: onClick, disabled: disabled, children: [jsx("div", { className: "rls-button-action__content", children: jsx(RlsIcon, { value: icon }) }), tooltip && (jsx("div", { className: "rls-button-action__tooltip caption-semibold", children: jsx("span", { children: tooltip }) }))] }));
|
|
1407
|
+
return (jsxRuntimeExports.jsxs("button", { className: "rls-button-action", onClick: onClick, disabled: disabled, children: [jsxRuntimeExports.jsx("div", { className: "rls-button-action__content", children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) }), tooltip && (jsxRuntimeExports.jsx("div", { className: "rls-button-action__tooltip caption-semibold", children: jsxRuntimeExports.jsx("span", { children: tooltip }) }))] }));
|
|
104
1408
|
}
|
|
105
1409
|
|
|
106
1410
|
function RlsCheckBox({ checked, disabled, onClick, rlsTheme }) {
|
|
107
|
-
return (jsx("div", { className: renderClassStatus('rls-checkbox', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsx("div", { className: "rls-checkbox__component" }) }));
|
|
1411
|
+
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-checkbox', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-checkbox__component" }) }));
|
|
108
1412
|
}
|
|
109
1413
|
function RlsCheckBoxControl({ formControl, disabled, rlsTheme }) {
|
|
110
|
-
return (jsx(RlsCheckBox, { checked: formControl.
|
|
111
|
-
formControl.
|
|
1414
|
+
return (jsxRuntimeExports.jsx(RlsCheckBox, { checked: !!formControl.value, disabled: disabled, onClick: () => {
|
|
1415
|
+
formControl.setValue(!formControl.value);
|
|
112
1416
|
}, rlsTheme: rlsTheme }));
|
|
113
1417
|
}
|
|
114
1418
|
|
|
115
1419
|
function RlsInput({ children, disabled, formControl, placeholder, type, value, onValue }) {
|
|
116
1420
|
const [focused, setFocused] = useState(false);
|
|
117
1421
|
function onChange(event) {
|
|
118
|
-
|
|
1422
|
+
setValue(type === 'number' ? +event.target.value : event.target.value);
|
|
119
1423
|
}
|
|
120
|
-
function
|
|
121
|
-
formControl?.
|
|
1424
|
+
function setValue(value) {
|
|
1425
|
+
formControl?.setValue(value);
|
|
122
1426
|
if (onValue) {
|
|
123
1427
|
onValue(value);
|
|
124
1428
|
}
|
|
@@ -131,15 +1435,15 @@ function RlsInput({ children, disabled, formControl, placeholder, type, value, o
|
|
|
131
1435
|
formControl?.blur();
|
|
132
1436
|
setFocused(false);
|
|
133
1437
|
}
|
|
134
|
-
return (jsxs("div", { className: renderClassStatus('rls-input', {
|
|
1438
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-input', {
|
|
135
1439
|
focused: formControl?.focused || focused,
|
|
136
1440
|
disabled: formControl?.disabled || disabled
|
|
137
|
-
}), children: [jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type || 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange, value: formControl?.
|
|
1441
|
+
}), children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type || 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange, value: formControl?.value || value || '' }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
|
|
138
1442
|
}
|
|
139
1443
|
|
|
140
1444
|
function RlsInputMoney({ decimals, disabled, formControl, placeholder, symbol, value, onValue }) {
|
|
141
1445
|
const [valueInput, setValueInput] = useState(value || 0);
|
|
142
|
-
function
|
|
1446
|
+
function onChange(value) {
|
|
143
1447
|
if (!formControl) {
|
|
144
1448
|
setValueInput(value);
|
|
145
1449
|
}
|
|
@@ -147,12 +1451,12 @@ function RlsInputMoney({ decimals, disabled, formControl, placeholder, symbol, v
|
|
|
147
1451
|
onValue(value);
|
|
148
1452
|
}
|
|
149
1453
|
}
|
|
150
|
-
return (jsx("div", { className: "rls-input-money", children: jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue:
|
|
1454
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-input-money", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: jsxRuntimeExports.jsx(RlsAmount, { value: formControl?.value || value || valueInput, symbol: symbol, decimals: decimals }) }) }));
|
|
151
1455
|
}
|
|
152
1456
|
|
|
153
1457
|
function RlsInputNumber({ disabled, formControl, placeholder, value, onValue }) {
|
|
154
1458
|
const [valueInput, setValueInput] = useState(value || 0);
|
|
155
|
-
function
|
|
1459
|
+
function onChange(value) {
|
|
156
1460
|
if (!formControl) {
|
|
157
1461
|
setValueInput(value);
|
|
158
1462
|
}
|
|
@@ -160,13 +1464,13 @@ function RlsInputNumber({ disabled, formControl, placeholder, value, onValue })
|
|
|
160
1464
|
onValue(value);
|
|
161
1465
|
}
|
|
162
1466
|
}
|
|
163
|
-
return (jsx("div", { className: "rls-input-number", children: jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue:
|
|
1467
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-input-number", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value || value || valueInput }) }));
|
|
164
1468
|
}
|
|
165
1469
|
|
|
166
1470
|
function RlsInputPassword({ disabled, formControl, placeholder, type, onValue }) {
|
|
167
1471
|
const [focused, setFocused] = useState(false);
|
|
168
1472
|
function onChange(event) {
|
|
169
|
-
formControl?.
|
|
1473
|
+
formControl?.setValue(event.target.value);
|
|
170
1474
|
if (onValue) {
|
|
171
1475
|
onValue(event.target.value);
|
|
172
1476
|
}
|
|
@@ -179,19 +1483,19 @@ function RlsInputPassword({ disabled, formControl, placeholder, type, onValue })
|
|
|
179
1483
|
formControl?.blur();
|
|
180
1484
|
setFocused(false);
|
|
181
1485
|
}
|
|
182
|
-
return (jsx("div", { className: renderClassStatus('rls-input-password', {
|
|
1486
|
+
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-input-password', {
|
|
183
1487
|
focused: formControl?.focused || focused,
|
|
184
1488
|
disabled
|
|
185
|
-
}), children: jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type || 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
|
|
1489
|
+
}), children: jsxRuntimeExports.jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type || 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
|
|
186
1490
|
}
|
|
187
1491
|
|
|
188
1492
|
function RlsInputSearch({ formControl, placeholder, onSearch }) {
|
|
189
|
-
return (jsxs("div", { className: "rls-input-search", children: [jsx(RlsInput, { formControl: formControl, placeholder: placeholder }), onSearch && jsx(RlsButtonAction, { icon: "search", onClick: onSearch })] }));
|
|
1493
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-input-search", children: [jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, placeholder: placeholder }), onSearch && jsxRuntimeExports.jsx(RlsButtonAction, { icon: "search", onClick: onSearch })] }));
|
|
190
1494
|
}
|
|
191
1495
|
|
|
192
1496
|
function RlsInputText({ disabled, formControl, placeholder, value, onValue }) {
|
|
193
1497
|
const [valueInput, setValueInput] = useState(value || '');
|
|
194
|
-
function
|
|
1498
|
+
function onChange(value) {
|
|
195
1499
|
if (!formControl) {
|
|
196
1500
|
setValueInput(value);
|
|
197
1501
|
}
|
|
@@ -199,56 +1503,56 @@ function RlsInputText({ disabled, formControl, placeholder, value, onValue }) {
|
|
|
199
1503
|
onValue(value);
|
|
200
1504
|
}
|
|
201
1505
|
}
|
|
202
|
-
return (jsx("div", { className: "rls-input-text", children: jsx(RlsInput, { formControl: formControl, type: "text", value: value, disabled: disabled, placeholder: placeholder, onValue:
|
|
1506
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-input-text", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "text", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value || value || valueInput }) }));
|
|
203
1507
|
}
|
|
204
1508
|
|
|
205
1509
|
function RlsLabel({ children, rlsTheme }) {
|
|
206
|
-
return (jsx("label", { className: "rls-label", "rls-theme": rlsTheme, children: children }));
|
|
1510
|
+
return (jsxRuntimeExports.jsx("label", { className: "rls-label", "rls-theme": rlsTheme, children: children }));
|
|
207
1511
|
}
|
|
208
1512
|
|
|
209
1513
|
function RlsMessageIcon({ icon, children, rlsTheme }) {
|
|
210
|
-
return (jsxs("div", { className: "rls-message-icon", "rls-theme": rlsTheme, children: [icon && jsx(RlsIcon, { value: icon }), jsx("span", { className: "truncate", children: children })] }));
|
|
1514
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-message-icon", "rls-theme": rlsTheme, children: [icon && jsxRuntimeExports.jsx(RlsIcon, { value: icon }), jsxRuntimeExports.jsx("span", { className: "truncate", children: children })] }));
|
|
211
1515
|
}
|
|
212
1516
|
|
|
213
1517
|
function RlsPoster({ children, rlsTheme }) {
|
|
214
|
-
return (jsx("div", { className: "rls-poster", "rls-theme": rlsTheme, children: children }));
|
|
1518
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-poster", "rls-theme": rlsTheme, children: children }));
|
|
215
1519
|
}
|
|
216
1520
|
|
|
217
1521
|
function RlsProgressBar({ indeterminate, percentage, rlsTheme }) {
|
|
218
|
-
return (jsx("div", { className: renderClassStatus('rls-progress-bar', { indeterminate }), "rls-theme": rlsTheme, children: jsx("div", { className: "rls-progress-bar__component", style: { width: `${percentage || 0}%` } }) }));
|
|
1522
|
+
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-progress-bar', { indeterminate }), "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-progress-bar__component", style: { width: `${percentage || 0}%` } }) }));
|
|
219
1523
|
}
|
|
220
1524
|
|
|
221
1525
|
function RlsProgressCircular({ rlsTheme }) {
|
|
222
|
-
return (jsx("div", { className: "rls-progress-circular", "rls-theme": rlsTheme, children: jsx("svg", { className: "rls-progress-circular__svg", viewBox: "0 0 36 36", children: jsx("circle", { className: "rls-progress-circular__circle", cx: "18", cy: "18", r: "12" }) }) }));
|
|
1526
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-progress-circular", "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("svg", { className: "rls-progress-circular__svg", viewBox: "0 0 36 36", children: jsxRuntimeExports.jsx("circle", { className: "rls-progress-circular__circle", cx: "18", cy: "18", r: "12" }) }) }));
|
|
223
1527
|
}
|
|
224
1528
|
|
|
225
1529
|
function RlsRadioButton({ checked, disabled, rlsTheme, onClick }) {
|
|
226
|
-
return (jsx("div", { className: renderClassStatus('rls-radiobutton', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsx("div", { className: "rls-radiobutton__component" }) }));
|
|
1530
|
+
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-radiobutton', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-radiobutton__component" }) }));
|
|
227
1531
|
}
|
|
228
1532
|
|
|
229
1533
|
function RlsSkeleton({ rlsTheme }) {
|
|
230
|
-
return jsx("div", { className: "rls-skeleton", "rls-theme": rlsTheme });
|
|
1534
|
+
return jsxRuntimeExports.jsx("div", { className: "rls-skeleton", "rls-theme": rlsTheme });
|
|
231
1535
|
}
|
|
232
1536
|
|
|
233
1537
|
function RlsSkeletonText({ active, children, rlsTheme }) {
|
|
234
|
-
return (jsx("div", { className: "rls-skeleton-text", "rls-theme": rlsTheme, children: active ? (jsx(RlsSkeleton, {})) : (jsx("span", { className: "rls-skeleton-text__value", children: children })) }));
|
|
1538
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-skeleton-text", "rls-theme": rlsTheme, children: active ? (jsxRuntimeExports.jsx(RlsSkeleton, {})) : (jsxRuntimeExports.jsx("span", { className: "rls-skeleton-text__value", children: children })) }));
|
|
235
1539
|
}
|
|
236
1540
|
|
|
237
1541
|
function RlsSwitch({ checked, disabled, rlsTheme, onClick }) {
|
|
238
|
-
return (jsx("div", { className: renderClassStatus('rls-switch', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxs("div", { className: "rls-switch__component", children: [jsx("div", { className: "rls-switch__component__element" }), jsx("div", { className: "rls-switch__component__bar" })] }) }));
|
|
1542
|
+
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-switch', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsxs("div", { className: "rls-switch__component", children: [jsxRuntimeExports.jsx("div", { className: "rls-switch__component__element" }), jsxRuntimeExports.jsx("div", { className: "rls-switch__component__bar" })] }) }));
|
|
239
1543
|
}
|
|
240
1544
|
function RlsSwitchControl({ formControl, disabled, rlsTheme }) {
|
|
241
|
-
return (jsx(RlsSwitch, { checked: formControl.
|
|
242
|
-
formControl.
|
|
1545
|
+
return (jsxRuntimeExports.jsx(RlsSwitch, { checked: formControl.value || false, disabled: disabled, onClick: () => {
|
|
1546
|
+
formControl.setValue(!formControl.value);
|
|
243
1547
|
}, rlsTheme: rlsTheme }));
|
|
244
1548
|
}
|
|
245
1549
|
|
|
246
1550
|
function RlsBallot({ bordered, children, img, initials, skeleton, subtitle, rlsTheme }) {
|
|
247
|
-
return (jsxs("div", { className: renderClassStatus('rls-ballot', { bordered, skeleton }), "rls-theme": rlsTheme, children: [(img || initials) && (jsxs(RlsAvatar, { skeleton: skeleton, children: [img && jsx("img", { src: img }), initials && jsx("span", { children: initials })] })), jsxs("div", { className: "rls-ballot__component", children: [jsx("label", { className: "rls-ballot__title", children: jsx(RlsSkeletonText, { active: skeleton, children: children }) }), subtitle && (jsx("label", { className: "rls-ballot__subtitle", children: jsx(RlsSkeletonText, { active: skeleton, children: subtitle }) }))] })] }));
|
|
1551
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-ballot', { bordered, skeleton }), "rls-theme": rlsTheme, children: [(img || initials) && (jsxRuntimeExports.jsxs(RlsAvatar, { skeleton: skeleton, children: [img && jsxRuntimeExports.jsx("img", { src: img }), initials && jsxRuntimeExports.jsx("span", { children: initials })] })), jsxRuntimeExports.jsxs("div", { className: "rls-ballot__component", children: [jsxRuntimeExports.jsx("label", { className: "rls-ballot__title", children: jsxRuntimeExports.jsx(RlsSkeletonText, { active: skeleton, children: children }) }), subtitle && (jsxRuntimeExports.jsx("label", { className: "rls-ballot__subtitle", children: jsxRuntimeExports.jsx(RlsSkeletonText, { active: skeleton, children: subtitle }) }))] })] }));
|
|
248
1552
|
}
|
|
249
1553
|
|
|
250
1554
|
function RlsButtonProgress({ icon, disabled, onClick, progressing, rlsTheme }) {
|
|
251
|
-
return (jsxs("div", { className: renderClassStatus('rls-button-progress', { progressing }), "rls-theme": rlsTheme, children: [!progressing && (jsx(RlsButtonAction, { icon: icon, onClick: onClick, disabled: disabled })), progressing && jsx(RlsProgressCircular, {})] }));
|
|
1555
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-button-progress', { progressing }), "rls-theme": rlsTheme, children: [!progressing && (jsxRuntimeExports.jsx(RlsButtonAction, { icon: icon, onClick: onClick, disabled: disabled })), progressing && jsxRuntimeExports.jsx(RlsProgressCircular, {})] }));
|
|
252
1556
|
}
|
|
253
1557
|
|
|
254
1558
|
function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsTheme }) {
|
|
@@ -277,30 +1581,30 @@ function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsThem
|
|
|
277
1581
|
onAction(action.value);
|
|
278
1582
|
}
|
|
279
1583
|
}
|
|
280
|
-
return (jsxs("div", { className: "rls-button-toggle", ref: componentRef, "rls-theme": rlsTheme, children: [jsxs("div", { className: "rls-button-toggle__content", children: [action && (jsx("div", { className: "rls-button-toggle__action", children: jsx(RlsButton, { disabled: disabled, type: type, onClick: () => onAction(action.value), children: action.label }) })), jsx("div", { className: "rls-button-toggle__icon", children: jsx(RlsButton, { type: type, prefixIcon: "arrow-ios-down", disabled: disabled, onClick: onClickMenu }) })] }), jsx("div", { className: renderClassStatus('rls-button-toggle__list', {
|
|
1584
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-button-toggle", ref: componentRef, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-button-toggle__content", children: [action && (jsxRuntimeExports.jsx("div", { className: "rls-button-toggle__action", children: jsxRuntimeExports.jsx(RlsButton, { disabled: disabled, type: type, onClick: () => onAction(action.value), children: action.label }) })), jsxRuntimeExports.jsx("div", { className: "rls-button-toggle__icon", children: jsxRuntimeExports.jsx(RlsButton, { type: type, prefixIcon: "arrow-ios-down", disabled: disabled, onClick: onClickMenu }) })] }), jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-button-toggle__list', {
|
|
281
1585
|
visible,
|
|
282
1586
|
hide: !visible
|
|
283
|
-
}), children: jsx("ul", { children: options.map((action, index) => (jsx("li", { className: "truncate", onClick: () => onSelectAction(action), children: action.label }, index))) }) })] }));
|
|
1587
|
+
}), children: jsxRuntimeExports.jsx("ul", { children: options.map((action, index) => (jsxRuntimeExports.jsx("li", { className: "truncate", onClick: () => onSelectAction(action), children: action.label }, index))) }) })] }));
|
|
284
1588
|
}
|
|
285
1589
|
|
|
286
1590
|
function RlsMessageFormError({ className, formControl }) {
|
|
287
|
-
return (jsx(Fragment, { children: formControl?.wrong && (jsx("div", { className: className, children: jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl?.error?.message }) })) }));
|
|
1591
|
+
return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: formControl?.wrong && (jsxRuntimeExports.jsx("div", { className: className, children: jsxRuntimeExports.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl?.error?.message }) })) }));
|
|
288
1592
|
}
|
|
289
1593
|
|
|
290
1594
|
function RlsFieldMoney({ children, decimals, disabled, formControl, placeholder, symbol, rlsTheme, value, onValue }) {
|
|
291
|
-
return (jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
1595
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
292
1596
|
focused: formControl?.focused,
|
|
293
1597
|
error: formControl?.wrong,
|
|
294
1598
|
disabled: formControl?.disabled || disabled
|
|
295
|
-
}, 'rls-field-money'), "rls-theme": rlsTheme, children: [children && jsx("label", { className: "rls-field-box__label", children: children }), jsx("div", { className: "rls-field-box__component", children: jsx("div", { className: "rls-field-box__body", children: jsx(RlsInputMoney, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, symbol: symbol, decimals: decimals, onValue: onValue }) }) }), jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
1599
|
+
}, 'rls-field-money'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputMoney, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, symbol: symbol, decimals: decimals, onValue: onValue }) }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
296
1600
|
}
|
|
297
1601
|
|
|
298
1602
|
function RlsFieldNumber({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
|
|
299
|
-
return (jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
1603
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
300
1604
|
focused: formControl?.focused,
|
|
301
1605
|
error: formControl?.wrong,
|
|
302
1606
|
disabled: formControl?.disabled || disabled
|
|
303
|
-
}, 'rls-field-number'), "rls-theme": rlsTheme, children: [children && jsx("label", { className: "rls-field-box__label", children: children }), jsx("div", { className: "rls-field-box__component", children: jsx("div", { className: "rls-field-box__body", children: jsx(RlsInputNumber, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
1607
|
+
}, 'rls-field-number'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputNumber, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
304
1608
|
}
|
|
305
1609
|
|
|
306
1610
|
function RlsFieldPassword({ children, disabled, formControl, placeholder, rlsTheme }) {
|
|
@@ -308,1155 +1612,133 @@ function RlsFieldPassword({ children, disabled, formControl, placeholder, rlsThe
|
|
|
308
1612
|
function onToggleInput() {
|
|
309
1613
|
setPassword(!password);
|
|
310
1614
|
}
|
|
311
|
-
return (jsxs("div", { className: renderClassStatus(' rls-field-box', {
|
|
1615
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus(' rls-field-box', {
|
|
312
1616
|
focused: formControl?.focused,
|
|
313
1617
|
error: formControl?.wrong,
|
|
314
1618
|
disabled: formControl?.disabled || disabled
|
|
315
|
-
}, 'rls-field-password'), "rls-theme": rlsTheme, children: [children && jsx("label", { className: "rls-field-box__label", children: children }), jsx("div", { className: "rls-field-box__component", children: jsxs("div", { className: "rls-field-box__body", children: [jsx(RlsInputPassword, { formControl: formControl, disabled: disabled, placeholder: placeholder, type: password ? 'password' : 'text' }), jsx(RlsButtonAction, { icon: password ? 'eye' : 'eye-off', onClick: onToggleInput })] }) }), jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
1619
|
+
}, 'rls-field-password'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx(RlsInputPassword, { formControl: formControl, disabled: disabled, placeholder: placeholder, type: password ? 'password' : 'text' }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: password ? 'eye' : 'eye-off', onClick: onToggleInput })] }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
316
1620
|
}
|
|
317
1621
|
|
|
318
1622
|
function RlsFieldText({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
|
|
319
|
-
return (jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
1623
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
320
1624
|
focused: formControl?.focused,
|
|
321
1625
|
error: formControl?.wrong,
|
|
322
1626
|
disabled: formControl?.disabled || disabled
|
|
323
|
-
}, 'rls-field-text'), "rls-theme": rlsTheme, children: [children && jsx("label", { className: "rls-field-box__label", children: children }), jsx("div", { className: "rls-field-box__component", children: jsx("div", { className: "rls-field-box__body", children: jsx(RlsInputText, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
1627
|
+
}, 'rls-field-text'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputText, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
324
1628
|
}
|
|
325
1629
|
|
|
326
1630
|
function RlsLabelCheckBox({ children, disabled, extended, formControl, rlsTheme }) {
|
|
327
|
-
const [checked, setChecked] = useState(!!formControl?.
|
|
1631
|
+
const [checked, setChecked] = useState(!!formControl?.value);
|
|
328
1632
|
useEffect(() => {
|
|
329
|
-
setChecked(!!formControl?.
|
|
330
|
-
}, [formControl?.
|
|
1633
|
+
setChecked(!!formControl?.value);
|
|
1634
|
+
}, [formControl?.value]);
|
|
331
1635
|
function onToggle() {
|
|
332
1636
|
if (formControl) {
|
|
333
|
-
formControl?.
|
|
1637
|
+
formControl?.setValue(!formControl.value);
|
|
334
1638
|
}
|
|
335
1639
|
else {
|
|
336
1640
|
setChecked(!checked);
|
|
337
1641
|
}
|
|
338
1642
|
}
|
|
339
|
-
return (jsxs("div", { className: renderClassStatus('rls-label-checkbox', {
|
|
1643
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-label-checkbox', {
|
|
340
1644
|
disabled,
|
|
341
1645
|
extended
|
|
342
|
-
}), "rls-theme": rlsTheme, children: [jsx("div", { className: "rls-label-checkbox__component", onClick: onToggle, children: jsx(RlsCheckBox, { checked: checked, disabled: disabled }) }), jsx("label", { className: "rls-label-checkbox__text", children: children })] }));
|
|
1646
|
+
}), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-label-checkbox__component", onClick: onToggle, children: jsxRuntimeExports.jsx(RlsCheckBox, { checked: checked, disabled: disabled }) }), jsxRuntimeExports.jsx("label", { className: "rls-label-checkbox__text", children: children })] }));
|
|
343
1647
|
}
|
|
344
1648
|
|
|
345
1649
|
function RlsLabelRadioButton({ children, disabled, extended, formControl, rlsTheme, value }) {
|
|
346
|
-
const [checked, setChecked] = useState(formControl?.
|
|
1650
|
+
const [checked, setChecked] = useState(formControl?.value === value);
|
|
347
1651
|
useEffect(() => {
|
|
348
|
-
setChecked(formControl?.
|
|
349
|
-
}, [formControl?.
|
|
1652
|
+
setChecked(formControl?.value === value);
|
|
1653
|
+
}, [formControl?.value]);
|
|
350
1654
|
function onSelect() {
|
|
351
1655
|
if (formControl) {
|
|
352
|
-
formControl?.
|
|
1656
|
+
formControl?.setValue(value);
|
|
353
1657
|
}
|
|
354
1658
|
}
|
|
355
|
-
return (jsxs("div", { className: renderClassStatus('rls-label-radiobutton', {
|
|
1659
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-label-radiobutton', {
|
|
356
1660
|
disabled,
|
|
357
1661
|
extended
|
|
358
|
-
}), "rls-theme": rlsTheme, children: [jsx("div", { className: "rls-label-radiobutton__component", onClick: onSelect, children: jsx(RlsRadioButton, { checked: checked, disabled: disabled }) }), jsx("label", { className: "rls-label-radiobutton__text", children: children })] }));
|
|
1662
|
+
}), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-label-radiobutton__component", onClick: onSelect, children: jsxRuntimeExports.jsx(RlsRadioButton, { checked: checked, disabled: disabled }) }), jsxRuntimeExports.jsx("label", { className: "rls-label-radiobutton__text", children: children })] }));
|
|
359
1663
|
}
|
|
360
1664
|
|
|
361
1665
|
function RlsLabelSwitch({ children, disabled, extended, formControl, rlsTheme }) {
|
|
362
|
-
const [checked, setChecked] = useState(!!formControl?.
|
|
1666
|
+
const [checked, setChecked] = useState(!!formControl?.value);
|
|
363
1667
|
useEffect(() => {
|
|
364
|
-
setChecked(!!formControl?.
|
|
365
|
-
}, [formControl?.
|
|
1668
|
+
setChecked(!!formControl?.value);
|
|
1669
|
+
}, [formControl?.value]);
|
|
366
1670
|
function onToggle() {
|
|
367
1671
|
if (formControl) {
|
|
368
|
-
formControl?.
|
|
1672
|
+
formControl?.setValue(!formControl.value);
|
|
369
1673
|
}
|
|
370
1674
|
else {
|
|
371
1675
|
setChecked(!checked);
|
|
372
1676
|
}
|
|
373
1677
|
}
|
|
374
|
-
return (jsxs("div", { className: renderClassStatus('rls-label-switch', { disabled, extended }), "rls-theme": rlsTheme, children: [jsx("div", { className: "rls-label-switch__component", onClick: onToggle, children: jsx(RlsSwitch, { checked: checked, disabled: disabled }) }), jsx("label", { className: "rls-label-switch__text", children: children })] }));
|
|
1678
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-label-switch', { disabled, extended }), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-label-switch__component", onClick: onToggle, children: jsxRuntimeExports.jsx(RlsSwitch, { checked: checked, disabled: disabled }) }), jsxRuntimeExports.jsx("label", { className: "rls-label-switch__text", children: children })] }));
|
|
375
1679
|
}
|
|
376
1680
|
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
const
|
|
380
|
-
const DEFAULT_MAX_VISIBLE = 4;
|
|
381
|
-
function RlsPagination({ elements, count: defaultCount, filter, onElements, onPagination }) {
|
|
382
|
-
const count = defaultCount || DEFAULT_COUNT_ELEMENT;
|
|
383
|
-
const [collection, setCollection] = useState([]);
|
|
384
|
-
const [index, setIndex] = useState(0);
|
|
385
|
-
const [maxPage, setMaxPage] = useState(calculateMaxPage(elements, count));
|
|
386
|
-
const [paginations, setPaginations] = useState([]);
|
|
387
|
-
const [currentPagination, setCurrentPagination] = useState();
|
|
388
|
-
const [description, setDescription] = useState('');
|
|
389
|
-
const [firstPage, setFirstPage] = useState(true);
|
|
390
|
-
const [lastPage, setLastPage] = useState(false);
|
|
1681
|
+
function RlsPagination({ suggestions, count, filter, onPagination }) {
|
|
1682
|
+
const controller = useRef(new PaginationController({ suggestions, count }));
|
|
1683
|
+
const [template, setTemplate] = useState(controller.current.template);
|
|
391
1684
|
useEffect(() => {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
1685
|
+
controller.current = new PaginationController({
|
|
1686
|
+
suggestions,
|
|
1687
|
+
count,
|
|
1688
|
+
position: template.currentPage.value
|
|
1689
|
+
});
|
|
1690
|
+
onPagination &&
|
|
1691
|
+
onPagination({
|
|
1692
|
+
firstPage: controller.current.template.firstPage,
|
|
1693
|
+
lastPage: controller.current.template.lastPage,
|
|
1694
|
+
suggestions: controller.current.page.collection
|
|
1695
|
+
});
|
|
1696
|
+
setTemplate(controller.current.template);
|
|
1697
|
+
}, [suggestions, count]);
|
|
403
1698
|
useEffect(() => {
|
|
404
|
-
|
|
1699
|
+
refreshPagination(controller.current.filtrable(filter));
|
|
405
1700
|
}, [filter]);
|
|
406
|
-
function
|
|
407
|
-
if (
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
1701
|
+
function refreshPagination(pagination) {
|
|
1702
|
+
if (pagination) {
|
|
1703
|
+
const { page, template } = pagination;
|
|
1704
|
+
const { firstPage, lastPage } = template;
|
|
1705
|
+
onPagination &&
|
|
1706
|
+
onPagination({
|
|
1707
|
+
firstPage,
|
|
1708
|
+
lastPage,
|
|
1709
|
+
suggestions: page.collection
|
|
1710
|
+
});
|
|
1711
|
+
setTemplate(template);
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
function goToPagination(page) {
|
|
1715
|
+
refreshPagination(controller.current.goToPage(page));
|
|
413
1716
|
}
|
|
414
|
-
function
|
|
415
|
-
|
|
416
|
-
pagination.active = true;
|
|
417
|
-
setIndex(value);
|
|
418
|
-
setCurrentPagination(pagination);
|
|
419
|
-
refreshFromChanged(clonePage({ index: value }));
|
|
420
|
-
}
|
|
421
|
-
function goPagination(pagination) {
|
|
422
|
-
if (currentPagination) {
|
|
423
|
-
currentPagination.active = false;
|
|
424
|
-
}
|
|
425
|
-
onSelectPagination(pagination);
|
|
1717
|
+
function goFirstPagination() {
|
|
1718
|
+
refreshPagination(controller.current.goFirstPage());
|
|
426
1719
|
}
|
|
427
1720
|
function goPreviousPagination() {
|
|
428
|
-
|
|
429
|
-
const { prev, value } = currentPagination;
|
|
430
|
-
if (prev) {
|
|
431
|
-
onSelectPagination(prev);
|
|
432
|
-
currentPagination.active = false;
|
|
433
|
-
}
|
|
434
|
-
else {
|
|
435
|
-
const prevIndex = value - MIN_NUMBER_PAGE;
|
|
436
|
-
if (prevIndex >= FIRST_PAGE) {
|
|
437
|
-
refreshFromChanged(clonePageFromIndex(prevIndex));
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
function goFirstPagination() {
|
|
443
|
-
if (collection.length) {
|
|
444
|
-
refreshFromChanged(clonePageFromIndex(FIRST_PAGE));
|
|
445
|
-
}
|
|
1721
|
+
refreshPagination(controller.current.goPreviousPage());
|
|
446
1722
|
}
|
|
447
1723
|
function goNextPagination() {
|
|
448
|
-
|
|
449
|
-
const { next, value } = currentPagination;
|
|
450
|
-
if (next) {
|
|
451
|
-
onSelectPagination(next);
|
|
452
|
-
currentPagination.active = false;
|
|
453
|
-
}
|
|
454
|
-
else {
|
|
455
|
-
const nextIndex = value + 1;
|
|
456
|
-
if (nextIndex <= maxPage) {
|
|
457
|
-
refreshFromChanged(clonePageFromIndex(nextIndex));
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
1724
|
+
refreshPagination(controller.current.goNextPage());
|
|
461
1725
|
}
|
|
462
1726
|
function goLastPagination() {
|
|
463
|
-
|
|
464
|
-
refreshFromChanged(clonePageFromIndex(maxPage - MIN_NUMBER_PAGE));
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
function createPageCollection(props) {
|
|
468
|
-
const { collection, count, index } = props;
|
|
469
|
-
if (collection.length) {
|
|
470
|
-
const finish = (index + MIN_NUMBER_PAGE) * count;
|
|
471
|
-
const start = index * count;
|
|
472
|
-
return collection.slice(start, finish);
|
|
473
|
-
}
|
|
474
|
-
return [];
|
|
475
|
-
}
|
|
476
|
-
function refreshFromElements(elements) {
|
|
477
|
-
elements.length
|
|
478
|
-
? refreshFromChanged(refreshPage(elements, filter))
|
|
479
|
-
: rebootPagination();
|
|
480
|
-
}
|
|
481
|
-
function refreshFromFilter(filter) {
|
|
482
|
-
refreshFromChanged(refreshPage(elements, filter));
|
|
483
|
-
}
|
|
484
|
-
function refreshFromChanged(page) {
|
|
485
|
-
refreshPaginations(page);
|
|
486
|
-
refreshDescription(page);
|
|
487
|
-
onChangeElements(createPageCollection(page));
|
|
488
|
-
}
|
|
489
|
-
function refreshCollection(elements, filter) {
|
|
490
|
-
const collection = filter
|
|
491
|
-
? elements.filter((element) => hasPattern$1(JSON.stringify(element), filter))
|
|
492
|
-
: elements;
|
|
493
|
-
setCollection(collection);
|
|
494
|
-
return collection;
|
|
495
|
-
}
|
|
496
|
-
function refreshMaxPage(collection, count) {
|
|
497
|
-
const maxPage = calculateMaxPage(collection, count);
|
|
498
|
-
setMaxPage(maxPage);
|
|
499
|
-
return maxPage;
|
|
500
|
-
}
|
|
501
|
-
function refreshIndex(collection, currentMaxPage) {
|
|
502
|
-
const maxPage = currentMaxPage || refreshMaxPage(collection, count);
|
|
503
|
-
if (index < maxPage || index === FIRST_PAGE) {
|
|
504
|
-
return index;
|
|
505
|
-
}
|
|
506
|
-
const newIndex = maxPage - 1;
|
|
507
|
-
setIndex(newIndex);
|
|
508
|
-
return newIndex;
|
|
509
|
-
}
|
|
510
|
-
function refreshDescription(page) {
|
|
511
|
-
const { collection, count, index } = page;
|
|
512
|
-
const totalCount = elements.length;
|
|
513
|
-
const start = index * count + MIN_NUMBER_PAGE;
|
|
514
|
-
let end = (index + MIN_NUMBER_PAGE) * count;
|
|
515
|
-
if (end > collection.length) {
|
|
516
|
-
end = collection.length;
|
|
517
|
-
}
|
|
518
|
-
setDescription(`${start} - ${end} de ${totalCount}`);
|
|
519
|
-
}
|
|
520
|
-
function refreshPaginations({ index, maxPage }) {
|
|
521
|
-
let maxPageVisible = index + DEFAULT_MAX_VISIBLE;
|
|
522
|
-
if (maxPageVisible > maxPage) {
|
|
523
|
-
maxPageVisible = maxPage;
|
|
524
|
-
}
|
|
525
|
-
let minIndexPage = maxPageVisible - DEFAULT_MAX_VISIBLE;
|
|
526
|
-
if (minIndexPage < 0) {
|
|
527
|
-
minIndexPage = 0;
|
|
528
|
-
}
|
|
529
|
-
if (minIndexPage > index) {
|
|
530
|
-
minIndexPage = index;
|
|
531
|
-
}
|
|
532
|
-
let prevPagination = undefined;
|
|
533
|
-
const paginations = [];
|
|
534
|
-
for (let i = minIndexPage; i < maxPageVisible; i++) {
|
|
535
|
-
const pagination = createPagination(i, index);
|
|
536
|
-
paginations.push(pagination);
|
|
537
|
-
pagination.prev = prevPagination;
|
|
538
|
-
if (prevPagination) {
|
|
539
|
-
prevPagination.next = pagination;
|
|
540
|
-
}
|
|
541
|
-
prevPagination = pagination;
|
|
542
|
-
}
|
|
543
|
-
setPaginations(paginations);
|
|
544
|
-
}
|
|
545
|
-
function clonePage(pagePartial) {
|
|
546
|
-
return {
|
|
547
|
-
collection: pagePartial.collection || collection,
|
|
548
|
-
index: typeof pagePartial.index === 'number' ? pagePartial.index : index,
|
|
549
|
-
count: pagePartial.count || count,
|
|
550
|
-
maxPage: typeof pagePartial.maxPage === 'number' ? pagePartial.maxPage : maxPage
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
function clonePageFromIndex(index) {
|
|
554
|
-
return clonePage({ index });
|
|
555
|
-
}
|
|
556
|
-
function refreshPage(elements, filter) {
|
|
557
|
-
const collection = refreshCollection(elements, filter);
|
|
558
|
-
const maxPage = refreshMaxPage(collection, count);
|
|
559
|
-
const index = refreshIndex(collection, maxPage);
|
|
560
|
-
return clonePage({ collection, index, maxPage });
|
|
561
|
-
}
|
|
562
|
-
function createPagination(value, index) {
|
|
563
|
-
const active = value === index;
|
|
564
|
-
const pagination = {
|
|
565
|
-
label: (value + 1).toString(),
|
|
566
|
-
value,
|
|
567
|
-
active
|
|
568
|
-
};
|
|
569
|
-
if (active) {
|
|
570
|
-
setCurrentPagination(pagination);
|
|
571
|
-
}
|
|
572
|
-
return pagination;
|
|
1727
|
+
refreshPagination(controller.current.goLastPage());
|
|
573
1728
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
setMaxPage(0);
|
|
577
|
-
setIndex(0);
|
|
578
|
-
setPaginations([]);
|
|
579
|
-
onChangeElements([]);
|
|
580
|
-
}
|
|
581
|
-
return (jsxs("div", { className: "rls-pagination", children: [jsxs("div", { className: "rls-pagination__actions", children: [jsx("button", { className: "rls-pagination__action", onClick: goFirstPagination, disabled: firstPage, children: jsx(RlsIcon, { value: "arrowhead-left" }) }), jsx("button", { className: "rls-pagination__action", onClick: goPreviousPagination, disabled: firstPage, children: jsx(RlsIcon, { value: "arrow-ios-left" }) })] }), jsx("div", { className: "rls-pagination__pages", children: paginations.map((page, index) => {
|
|
582
|
-
return (jsx("div", { className: renderClassStatus('rls-pagination__page', {
|
|
1729
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-pagination", children: [jsxRuntimeExports.jsxs("div", { className: "rls-pagination__actions", children: [jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goFirstPagination, disabled: template.firstPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrowhead-left" }) }), jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goPreviousPagination, disabled: template.firstPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-left" }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-pagination__pages", children: template.pages.map((page, index) => {
|
|
1730
|
+
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-pagination__page', {
|
|
583
1731
|
active: page.active
|
|
584
1732
|
}), onClick: () => {
|
|
585
|
-
|
|
1733
|
+
goToPagination(page);
|
|
586
1734
|
}, children: page.label }, index));
|
|
587
|
-
}) }), jsx("div", { className: "rls-pagination__description", children: description }), jsxs("div", { className: "rls-pagination__actions", children: [jsx("button", { className: "rls-pagination__action", onClick: goNextPagination, disabled: lastPage, children: jsx(RlsIcon, { value: "arrow-ios-right" }) }), jsx("button", { className: "rls-pagination__action", onClick: goLastPagination, disabled: lastPage, children: jsx(RlsIcon, { value: "arrowhead-right" }) })] })] }));
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
const dateI18n = i18n({
|
|
591
|
-
es: {
|
|
592
|
-
// Months
|
|
593
|
-
january: 'Enero',
|
|
594
|
-
february: 'Febrero',
|
|
595
|
-
march: 'Marzo',
|
|
596
|
-
april: 'Abril',
|
|
597
|
-
may: 'Mayo',
|
|
598
|
-
june: 'Junio',
|
|
599
|
-
july: 'Julio',
|
|
600
|
-
august: 'Agosto',
|
|
601
|
-
september: 'Septiembre',
|
|
602
|
-
october: 'Octubre',
|
|
603
|
-
november: 'Noviembre',
|
|
604
|
-
december: 'Diciembre',
|
|
605
|
-
// Days
|
|
606
|
-
monday: 'Lunes',
|
|
607
|
-
tuesday: 'Martes',
|
|
608
|
-
wednesday: 'Miércoles',
|
|
609
|
-
thursday: 'Jueves',
|
|
610
|
-
friday: 'Viernes',
|
|
611
|
-
saturday: 'Sábado',
|
|
612
|
-
sunday: 'Domingo',
|
|
613
|
-
// Timestamps
|
|
614
|
-
year: 'año',
|
|
615
|
-
month: 'mes',
|
|
616
|
-
week: 'semana',
|
|
617
|
-
day: 'día',
|
|
618
|
-
hour: 'hora',
|
|
619
|
-
minute: 'minuto',
|
|
620
|
-
second: 'segundo'
|
|
621
|
-
},
|
|
622
|
-
en: {
|
|
623
|
-
// Months
|
|
624
|
-
january: 'January',
|
|
625
|
-
february: 'February',
|
|
626
|
-
march: 'March',
|
|
627
|
-
april: 'April',
|
|
628
|
-
may: 'May',
|
|
629
|
-
june: 'June',
|
|
630
|
-
july: 'July',
|
|
631
|
-
august: 'August',
|
|
632
|
-
september: 'September',
|
|
633
|
-
october: 'October',
|
|
634
|
-
november: 'November',
|
|
635
|
-
december: 'December',
|
|
636
|
-
// Days
|
|
637
|
-
monday: 'Monday',
|
|
638
|
-
tuesday: 'Tuesday',
|
|
639
|
-
wednesday: 'Wednesday',
|
|
640
|
-
thursday: 'Thursday',
|
|
641
|
-
friday: 'Friday',
|
|
642
|
-
saturday: 'Saturday',
|
|
643
|
-
sunday: 'Sunday',
|
|
644
|
-
// Timestamps
|
|
645
|
-
year: 'year',
|
|
646
|
-
month: 'month',
|
|
647
|
-
week: 'week',
|
|
648
|
-
day: 'day',
|
|
649
|
-
hour: 'hour',
|
|
650
|
-
minute: 'minute',
|
|
651
|
-
second: 'second'
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
|
|
655
|
-
var Miliseconds;
|
|
656
|
-
(function (Miliseconds) {
|
|
657
|
-
Miliseconds[Miliseconds["Year"] = 31536000000] = "Year";
|
|
658
|
-
Miliseconds[Miliseconds["Month"] = 2592000000] = "Month";
|
|
659
|
-
Miliseconds[Miliseconds["Week"] = 604800000] = "Week";
|
|
660
|
-
Miliseconds[Miliseconds["Day"] = 86400000] = "Day";
|
|
661
|
-
Miliseconds[Miliseconds["Hour"] = 3600000] = "Hour";
|
|
662
|
-
Miliseconds[Miliseconds["Minute"] = 60000] = "Minute";
|
|
663
|
-
Miliseconds[Miliseconds["Second"] = 1000] = "Second";
|
|
664
|
-
})(Miliseconds || (Miliseconds = {}));
|
|
665
|
-
var Day;
|
|
666
|
-
(function (Day) {
|
|
667
|
-
Day[Day["Sunday"] = 0] = "Sunday";
|
|
668
|
-
Day[Day["Monday"] = 1] = "Monday";
|
|
669
|
-
Day[Day["Tuesday"] = 2] = "Tuesday";
|
|
670
|
-
Day[Day["Wednesday"] = 3] = "Wednesday";
|
|
671
|
-
Day[Day["Thursday"] = 4] = "Thursday";
|
|
672
|
-
Day[Day["Friday"] = 5] = "Friday";
|
|
673
|
-
Day[Day["Saturday"] = 6] = "Saturday";
|
|
674
|
-
})(Day || (Day = {}));
|
|
675
|
-
var Month;
|
|
676
|
-
(function (Month) {
|
|
677
|
-
Month[Month["January"] = 0] = "January";
|
|
678
|
-
Month[Month["February"] = 1] = "February";
|
|
679
|
-
Month[Month["March"] = 2] = "March";
|
|
680
|
-
Month[Month["April"] = 3] = "April";
|
|
681
|
-
Month[Month["May"] = 4] = "May";
|
|
682
|
-
Month[Month["June"] = 5] = "June";
|
|
683
|
-
Month[Month["July"] = 6] = "July";
|
|
684
|
-
Month[Month["August"] = 7] = "August";
|
|
685
|
-
Month[Month["September"] = 8] = "September";
|
|
686
|
-
Month[Month["October"] = 9] = "October";
|
|
687
|
-
Month[Month["November"] = 10] = "November";
|
|
688
|
-
Month[Month["December"] = 11] = "December";
|
|
689
|
-
})(Month || (Month = {}));
|
|
690
|
-
var MonthDay;
|
|
691
|
-
(function (MonthDay) {
|
|
692
|
-
MonthDay[MonthDay["January"] = 31] = "January";
|
|
693
|
-
MonthDay[MonthDay["February"] = 28] = "February";
|
|
694
|
-
MonthDay[MonthDay["March"] = 31] = "March";
|
|
695
|
-
MonthDay[MonthDay["April"] = 30] = "April";
|
|
696
|
-
MonthDay[MonthDay["May"] = 31] = "May";
|
|
697
|
-
MonthDay[MonthDay["June"] = 30] = "June";
|
|
698
|
-
MonthDay[MonthDay["July"] = 31] = "July";
|
|
699
|
-
MonthDay[MonthDay["August"] = 31] = "August";
|
|
700
|
-
MonthDay[MonthDay["September"] = 30] = "September";
|
|
701
|
-
MonthDay[MonthDay["October"] = 31] = "October";
|
|
702
|
-
MonthDay[MonthDay["November"] = 30] = "November";
|
|
703
|
-
MonthDay[MonthDay["December"] = 31] = "December";
|
|
704
|
-
})(MonthDay || (MonthDay = {}));
|
|
705
|
-
|
|
706
|
-
let MONTH_NAMES_I18N = [];
|
|
707
|
-
let MONTH_LABELS_I18N = [];
|
|
708
|
-
let DAY_NAMES_I18N = [];
|
|
709
|
-
let DAY_LABELS_I18N = [];
|
|
710
|
-
function loadI18n(language = 'es') {
|
|
711
|
-
MONTH_NAMES_I18N = [
|
|
712
|
-
dateI18n('january', { language }),
|
|
713
|
-
dateI18n('february', { language }),
|
|
714
|
-
dateI18n('march', { language }),
|
|
715
|
-
dateI18n('april', { language }),
|
|
716
|
-
dateI18n('may', { language }),
|
|
717
|
-
dateI18n('june', { language }),
|
|
718
|
-
dateI18n('july', { language }),
|
|
719
|
-
dateI18n('august', { language }),
|
|
720
|
-
dateI18n('september', { language }),
|
|
721
|
-
dateI18n('october', { language }),
|
|
722
|
-
dateI18n('november', { language }),
|
|
723
|
-
dateI18n('december', { language })
|
|
724
|
-
];
|
|
725
|
-
MONTH_LABELS_I18N = MONTH_NAMES_I18N.map((name) => name.substring(0, 3));
|
|
726
|
-
DAY_NAMES_I18N = [
|
|
727
|
-
dateI18n('sunday', { language }),
|
|
728
|
-
dateI18n('monday', { language }),
|
|
729
|
-
dateI18n('tuesday', { language }),
|
|
730
|
-
dateI18n('wednesday', { language }),
|
|
731
|
-
dateI18n('thursday', { language }),
|
|
732
|
-
dateI18n('friday', { language }),
|
|
733
|
-
dateI18n('saturday', { language })
|
|
734
|
-
];
|
|
735
|
-
DAY_LABELS_I18N = DAY_NAMES_I18N.map((name) => name.substring(0, 3));
|
|
736
|
-
}
|
|
737
|
-
function isNumber(value) {
|
|
738
|
-
return value !== undefined && value !== null;
|
|
739
|
-
}
|
|
740
|
-
loadI18n();
|
|
741
|
-
i18nSubscribe((language) => loadI18n(language));
|
|
742
|
-
const MONTH_DAYS = [
|
|
743
|
-
MonthDay.January,
|
|
744
|
-
MonthDay.February,
|
|
745
|
-
MonthDay.March,
|
|
746
|
-
MonthDay.April,
|
|
747
|
-
MonthDay.May,
|
|
748
|
-
MonthDay.June,
|
|
749
|
-
MonthDay.July,
|
|
750
|
-
MonthDay.August,
|
|
751
|
-
MonthDay.September,
|
|
752
|
-
MonthDay.October,
|
|
753
|
-
MonthDay.November,
|
|
754
|
-
MonthDay.December
|
|
755
|
-
];
|
|
756
|
-
function MONTH_NAMES(index) {
|
|
757
|
-
return isNumber(index) ? MONTH_NAMES_I18N[index] || '' : MONTH_NAMES_I18N;
|
|
758
|
-
}
|
|
759
|
-
function MONTH_LABELS(index) {
|
|
760
|
-
return isNumber(index) ? MONTH_LABELS_I18N[index] || '' : MONTH_LABELS_I18N;
|
|
761
|
-
}
|
|
762
|
-
function DAY_NAMES(index) {
|
|
763
|
-
return isNumber(index) ? DAY_NAMES_I18N[index] || '' : DAY_NAMES_I18N;
|
|
764
|
-
}
|
|
765
|
-
function DAY_LABELS(index) {
|
|
766
|
-
return isNumber(index) ? DAY_LABELS_I18N[index] || '' : DAY_LABELS_I18N;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
function completFormat(value, size) {
|
|
770
|
-
return value.toString().padStart(size, '0');
|
|
771
|
-
}
|
|
772
|
-
function hourFormat(date) {
|
|
773
|
-
const hour = date.getHours();
|
|
774
|
-
return hour > 12 ? hour - 12 : hour === 0 ? 12 : hour;
|
|
775
|
-
}
|
|
776
|
-
function verifyDayInYear(date, year) {
|
|
777
|
-
const days = getDaysOfMonth(year, date.getMonth());
|
|
778
|
-
if (days < date.getDate()) {
|
|
779
|
-
date.setDate(days);
|
|
780
|
-
}
|
|
781
|
-
date.setFullYear(year); // Establecer el año
|
|
782
|
-
}
|
|
783
|
-
function verifyDayInMonth(date, month) {
|
|
784
|
-
const days = getDaysOfMonth(date.getFullYear(), month);
|
|
785
|
-
if (days < date.getDate()) {
|
|
786
|
-
date.setDate(days);
|
|
787
|
-
}
|
|
788
|
-
date.setMonth(month); // Establecer el mes
|
|
789
|
-
}
|
|
790
|
-
const formatters = {
|
|
791
|
-
dd: (date) => {
|
|
792
|
-
return completFormat(date.getDate(), 2);
|
|
793
|
-
},
|
|
794
|
-
dw: (date) => {
|
|
795
|
-
return DAY_NAMES()[date.getDay()];
|
|
796
|
-
},
|
|
797
|
-
dx: (date) => {
|
|
798
|
-
return DAY_NAMES()[date.getDay()];
|
|
799
|
-
},
|
|
800
|
-
mm: (date) => {
|
|
801
|
-
return completFormat(date.getMonth() + 1, 2);
|
|
802
|
-
},
|
|
803
|
-
mn: (date) => {
|
|
804
|
-
return MONTH_NAMES(date.getMonth());
|
|
805
|
-
},
|
|
806
|
-
mx: (date) => {
|
|
807
|
-
return MONTH_LABELS(date.getMonth());
|
|
808
|
-
},
|
|
809
|
-
aa: (date) => {
|
|
810
|
-
return completFormat(date.getFullYear(), 4);
|
|
811
|
-
},
|
|
812
|
-
hh: (date) => {
|
|
813
|
-
return completFormat(date.getHours(), 2);
|
|
814
|
-
},
|
|
815
|
-
ii: (date) => {
|
|
816
|
-
return completFormat(date.getMinutes(), 2);
|
|
817
|
-
},
|
|
818
|
-
ss: (date) => {
|
|
819
|
-
return completFormat(date.getSeconds(), 2);
|
|
820
|
-
},
|
|
821
|
-
hz: (date) => {
|
|
822
|
-
return completFormat(hourFormat(date), 2);
|
|
823
|
-
},
|
|
824
|
-
zz: (date) => {
|
|
825
|
-
return date.getHours() > 11 ? 'PM' : 'AM';
|
|
826
|
-
}
|
|
827
|
-
};
|
|
828
|
-
const createElapsedTime = (value, single, charPlural = 's', plural) => {
|
|
829
|
-
plural = plural || `${single}${charPlural}`;
|
|
830
|
-
const label = `${single}(${charPlural})`;
|
|
831
|
-
return {
|
|
832
|
-
value,
|
|
833
|
-
label,
|
|
834
|
-
single,
|
|
835
|
-
plural
|
|
836
|
-
};
|
|
837
|
-
};
|
|
838
|
-
[
|
|
839
|
-
createElapsedTime(Miliseconds.Year, 'año'),
|
|
840
|
-
createElapsedTime(Miliseconds.Month, 'mes', 'es'),
|
|
841
|
-
createElapsedTime(Miliseconds.Week, 'semana'),
|
|
842
|
-
createElapsedTime(Miliseconds.Day, 'día', 's', 'dias'),
|
|
843
|
-
createElapsedTime(Miliseconds.Hour, 'hora'),
|
|
844
|
-
createElapsedTime(Miliseconds.Minute, 'minuto'),
|
|
845
|
-
createElapsedTime(Miliseconds.Second, 'segundo')
|
|
846
|
-
];
|
|
847
|
-
function getDateWeight(date) {
|
|
848
|
-
return date.getFullYear() * 365 + (date.getMonth() + 1) * 30 + date.getDate();
|
|
849
|
-
}
|
|
850
|
-
function dateIsEquals(date, compare = new Date()) {
|
|
851
|
-
return date.getTime() === compare.getTime();
|
|
852
|
-
}
|
|
853
|
-
function dateIsEqualsWeight(date, compare = new Date()) {
|
|
854
|
-
return getDateWeight(date) === getDateWeight(compare);
|
|
855
|
-
}
|
|
856
|
-
function dateIsBefore(date, compare = new Date()) {
|
|
857
|
-
return date.getTime() > compare.getTime();
|
|
858
|
-
}
|
|
859
|
-
function dateIsAfter(date, compare = new Date()) {
|
|
860
|
-
return date.getTime() < compare.getTime();
|
|
861
|
-
}
|
|
862
|
-
function dateIsBetween(minDate, maxDate, compare = new Date()) {
|
|
863
|
-
return dateIsAfter(minDate, compare) && dateIsBefore(maxDate, compare);
|
|
864
|
-
}
|
|
865
|
-
function getTimeDifference(date, compare = new Date()) {
|
|
866
|
-
return date.getTime() - compare.getTime();
|
|
867
|
-
}
|
|
868
|
-
function normalizeMinTime(date) {
|
|
869
|
-
const normalize = new Date(date.getTime());
|
|
870
|
-
normalize.setHours(0);
|
|
871
|
-
normalize.setMinutes(0);
|
|
872
|
-
normalize.setSeconds(0);
|
|
873
|
-
normalize.setMilliseconds(0);
|
|
874
|
-
return normalize;
|
|
875
|
-
}
|
|
876
|
-
function normalizeMaxTime(date) {
|
|
877
|
-
const normalize = new Date(date.getTime());
|
|
878
|
-
normalize.setHours(23);
|
|
879
|
-
normalize.setMinutes(59);
|
|
880
|
-
normalize.setSeconds(59);
|
|
881
|
-
normalize.setMilliseconds(0);
|
|
882
|
-
return normalize;
|
|
883
|
-
}
|
|
884
|
-
function getDaysOfMonth(year, month) {
|
|
885
|
-
return month === 1 && isLeapYear(year) ? 29 : MONTH_DAYS[month];
|
|
886
|
-
}
|
|
887
|
-
function isLeapYear(value) {
|
|
888
|
-
const year = value instanceof Date ? value.getFullYear() : value;
|
|
889
|
-
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
890
|
-
}
|
|
891
|
-
const regInterpolation = /{([^{}]*)}/g;
|
|
892
|
-
function dateFormatTemplate(date, template) {
|
|
893
|
-
return template.replace(regInterpolation, (value, key) => formatters[key] ? formatters[key](date) : value);
|
|
894
|
-
}
|
|
895
|
-
function assignYearInDate(date, year) {
|
|
896
|
-
const newDate = new Date(date.getTime());
|
|
897
|
-
verifyDayInYear(newDate, year);
|
|
898
|
-
newDate.setFullYear(year);
|
|
899
|
-
return newDate;
|
|
900
|
-
}
|
|
901
|
-
function assignMonthInDate(date, month) {
|
|
902
|
-
const newDate = new Date(date.getTime());
|
|
903
|
-
verifyDayInMonth(newDate, month);
|
|
904
|
-
newDate.setMonth(month);
|
|
905
|
-
return newDate;
|
|
906
|
-
}
|
|
907
|
-
function assignDayInDate(date, day) {
|
|
908
|
-
const newDate = new Date(date.getTime());
|
|
909
|
-
newDate.setDate(day);
|
|
910
|
-
return newDate;
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
class DateRange {
|
|
914
|
-
constructor(minDate, maxDate) {
|
|
915
|
-
this.minDate = normalizeMinTime(minDate);
|
|
916
|
-
this.maxDate =
|
|
917
|
-
maxDate && dateIsBefore(maxDate, minDate)
|
|
918
|
-
? normalizeMinTime(maxDate)
|
|
919
|
-
: normalizeMinTime(minDate);
|
|
920
|
-
}
|
|
921
|
-
get minISOFormat() {
|
|
922
|
-
return this.minDate.toISOString();
|
|
923
|
-
}
|
|
924
|
-
get maxISOFormat() {
|
|
925
|
-
return this.maxDate.toISOString();
|
|
926
|
-
}
|
|
927
|
-
between(date) {
|
|
928
|
-
return dateIsBetween(this.minDate, this.maxDate, date);
|
|
929
|
-
}
|
|
930
|
-
equals({ maxDate, minDate }) {
|
|
931
|
-
return dateIsEquals(this.minDate, minDate) && dateIsEquals(this.maxDate, maxDate);
|
|
932
|
-
}
|
|
933
|
-
recalculate(date) {
|
|
934
|
-
if (dateIsBefore(this.minDate, date)) {
|
|
935
|
-
return new DateRange(date, this.maxDate);
|
|
936
|
-
}
|
|
937
|
-
if (dateIsAfter(this.maxDate, date)) {
|
|
938
|
-
return new DateRange(this.minDate, date);
|
|
939
|
-
}
|
|
940
|
-
const minDifference = getTimeDifference(date, this.minDate);
|
|
941
|
-
const maxDifference = getTimeDifference(this.maxDate, date);
|
|
942
|
-
return minDifference > maxDifference
|
|
943
|
-
? new DateRange(this.minDate, date)
|
|
944
|
-
: new DateRange(date, this.maxDate);
|
|
945
|
-
}
|
|
946
|
-
static now() {
|
|
947
|
-
return new DateRange(new Date());
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
function dateIsOutRangeMin(props) {
|
|
952
|
-
const { date, minDate } = props;
|
|
953
|
-
return !!minDate && dateIsBefore(normalizeMinTime(minDate), date);
|
|
954
|
-
}
|
|
955
|
-
function dateIsOutRangeMax(props) {
|
|
956
|
-
const { date, maxDate } = props;
|
|
957
|
-
return !!maxDate && dateIsAfter(normalizeMaxTime(maxDate), date);
|
|
958
|
-
}
|
|
959
|
-
function dateOutRange(props) {
|
|
960
|
-
return dateIsOutRangeMin(props) || dateIsOutRangeMax(props);
|
|
961
|
-
}
|
|
962
|
-
function checkDateRange(props) {
|
|
963
|
-
const { date, maxDate, minDate } = props;
|
|
964
|
-
return minDate && dateIsOutRangeMax(props)
|
|
965
|
-
? minDate
|
|
966
|
-
: maxDate && dateIsOutRangeMax(props)
|
|
967
|
-
? maxDate
|
|
968
|
-
: date;
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
const DAYS_WEEK = 7;
|
|
972
|
-
const COUNT_YEAR_RANGE = 4;
|
|
973
|
-
|
|
974
|
-
function createDayState(props, today, value) {
|
|
975
|
-
const { date, day, month, year } = props;
|
|
976
|
-
const dateValue = value && new Date(year, month, value);
|
|
977
|
-
return {
|
|
978
|
-
disabled: dayIsOutside(props, value || 0),
|
|
979
|
-
focused: !!value && day === value,
|
|
980
|
-
forbidden: !value,
|
|
981
|
-
selected: !!dateValue && dateIsEqualsWeight(date, dateValue),
|
|
982
|
-
today: !!dateValue && dateIsEqualsWeight(today, dateValue),
|
|
983
|
-
value
|
|
984
|
-
};
|
|
985
|
-
}
|
|
986
|
-
function createFirstWeek$1(props, date, today) {
|
|
987
|
-
const days = [];
|
|
988
|
-
let day = 1;
|
|
989
|
-
for (let start = 0; start < date.getDay(); start++) {
|
|
990
|
-
days.push(createDayState(props, today));
|
|
991
|
-
}
|
|
992
|
-
for (let end = date.getDay(); end < 7; end++) {
|
|
993
|
-
days.push(createDayState(props, today, day));
|
|
994
|
-
day++;
|
|
995
|
-
}
|
|
996
|
-
return { days };
|
|
997
|
-
}
|
|
998
|
-
function createDaysPending$1(props, today, days) {
|
|
999
|
-
const daysPending = [];
|
|
1000
|
-
const length = 7 - days;
|
|
1001
|
-
for (let index = 0; index < length; index++) {
|
|
1002
|
-
daysPending.push(createDayState(props, today));
|
|
1003
|
-
}
|
|
1004
|
-
return daysPending;
|
|
1005
|
-
}
|
|
1006
|
-
function createNextWeeks$1(props, date, today) {
|
|
1007
|
-
const daysMonth = getDaysOfMonth(date.getFullYear(), date.getMonth());
|
|
1008
|
-
const weeks = [];
|
|
1009
|
-
let days = [];
|
|
1010
|
-
let countDays = 1;
|
|
1011
|
-
let day = DAYS_WEEK - date.getDay() + 1;
|
|
1012
|
-
do {
|
|
1013
|
-
days.push(createDayState(props, today, day));
|
|
1014
|
-
day++;
|
|
1015
|
-
countDays++;
|
|
1016
|
-
if (countDays > DAYS_WEEK) {
|
|
1017
|
-
weeks.push({ days });
|
|
1018
|
-
days = [];
|
|
1019
|
-
countDays = 1;
|
|
1020
|
-
}
|
|
1021
|
-
} while (day <= daysMonth);
|
|
1022
|
-
if (days.length && days.length < DAYS_WEEK) {
|
|
1023
|
-
weeks.push({
|
|
1024
|
-
days: [...days, ...createDaysPending$1(props, today, days.length)]
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
|
-
return weeks;
|
|
1028
|
-
}
|
|
1029
|
-
function dayIsOutsideMin(props, day) {
|
|
1030
|
-
const { month, year, minDate } = props;
|
|
1031
|
-
return minDate
|
|
1032
|
-
? getDateWeight(new Date(year, month, day)) < getDateWeight(minDate)
|
|
1033
|
-
: false;
|
|
1034
|
-
}
|
|
1035
|
-
function dayIsOutsideMax(props, day) {
|
|
1036
|
-
const { month, year, maxDate } = props;
|
|
1037
|
-
return maxDate
|
|
1038
|
-
? getDateWeight(new Date(year, month, day)) > getDateWeight(maxDate)
|
|
1039
|
-
: false;
|
|
1040
|
-
}
|
|
1041
|
-
function dayIsOutside(props, day) {
|
|
1042
|
-
return dayIsOutsideMin(props, day) || dayIsOutsideMax(props, day);
|
|
1043
|
-
}
|
|
1044
|
-
function checkDayPicker(props) {
|
|
1045
|
-
const { day, maxDate, minDate } = props;
|
|
1046
|
-
return minDate && dayIsOutsideMin(props, day)
|
|
1047
|
-
? minDate.getDate()
|
|
1048
|
-
: maxDate && dayIsOutsideMax(props, day)
|
|
1049
|
-
? maxDate.getDate()
|
|
1050
|
-
: undefined;
|
|
1051
|
-
}
|
|
1052
|
-
function createDayPicker(props) {
|
|
1053
|
-
const date = new Date(props.year, props.month, 1);
|
|
1054
|
-
const today = new Date();
|
|
1055
|
-
const firstWeek = createFirstWeek$1(props, date, today);
|
|
1056
|
-
const nextWeeks = createNextWeeks$1(props, date, today);
|
|
1057
|
-
return [firstWeek, ...nextWeeks];
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
function dateIsSelected(base, date, day) {
|
|
1061
|
-
return (date.getFullYear() === base.getFullYear() &&
|
|
1062
|
-
date.getMonth() === base.getMonth() &&
|
|
1063
|
-
day === date.getDate());
|
|
1064
|
-
}
|
|
1065
|
-
function sourceIsSelected({ sourceDate }, base, day) {
|
|
1066
|
-
return dateIsSelected(base, sourceDate, day);
|
|
1067
|
-
}
|
|
1068
|
-
function rangeIsSelected({ range }, base, day) {
|
|
1069
|
-
return (dateIsSelected(base, range.minDate, day) ||
|
|
1070
|
-
dateIsSelected(base, range.maxDate, day));
|
|
1071
|
-
}
|
|
1072
|
-
function dayIsRange({ range }, base, day) {
|
|
1073
|
-
return dateIsBetween(range.minDate, range.maxDate, assignDayInDate(base, day));
|
|
1074
|
-
}
|
|
1075
|
-
function createDayRangeState(props, base, day) {
|
|
1076
|
-
return {
|
|
1077
|
-
disabled: dayRangeIsOutside(props, day || 0),
|
|
1078
|
-
end: day ? rangeIsSelected(props, base, day) : false,
|
|
1079
|
-
forbidden: !day,
|
|
1080
|
-
ranged: day ? dayIsRange(props, base, day) : false,
|
|
1081
|
-
source: day ? sourceIsSelected(props, base, day) : false,
|
|
1082
|
-
value: day
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1085
|
-
function createFirstWeek(props, base) {
|
|
1086
|
-
const days = [];
|
|
1087
|
-
let day = 1;
|
|
1088
|
-
for (let start = 0; start < base.getDay(); start++) {
|
|
1089
|
-
days.push(createDayRangeState(props, base));
|
|
1090
|
-
}
|
|
1091
|
-
for (let end = base.getDay(); end < 7; end++) {
|
|
1092
|
-
days.push(createDayRangeState(props, base, day));
|
|
1093
|
-
day++;
|
|
1094
|
-
}
|
|
1095
|
-
return { days };
|
|
1096
|
-
}
|
|
1097
|
-
function createDaysPending(props, base, days) {
|
|
1098
|
-
const daysPending = [];
|
|
1099
|
-
const length = 7 - days;
|
|
1100
|
-
for (let index = 0; index < length; index++) {
|
|
1101
|
-
daysPending.push(createDayRangeState(props, base));
|
|
1102
|
-
}
|
|
1103
|
-
return daysPending;
|
|
1104
|
-
}
|
|
1105
|
-
function createNextWeeks(props, base) {
|
|
1106
|
-
const weeks = [];
|
|
1107
|
-
const { date } = props;
|
|
1108
|
-
const dayCount = getDaysOfMonth(date.getFullYear(), date.getMonth());
|
|
1109
|
-
let days = [];
|
|
1110
|
-
let countDays = 1;
|
|
1111
|
-
let day = DAYS_WEEK - base.getDay() + 1;
|
|
1112
|
-
do {
|
|
1113
|
-
days.push(createDayRangeState(props, date, day));
|
|
1114
|
-
day++;
|
|
1115
|
-
countDays++;
|
|
1116
|
-
if (countDays > 7) {
|
|
1117
|
-
weeks.push({ days });
|
|
1118
|
-
days = [];
|
|
1119
|
-
countDays = 1;
|
|
1120
|
-
}
|
|
1121
|
-
} while (day <= dayCount);
|
|
1122
|
-
if (days.length && days.length < DAYS_WEEK) {
|
|
1123
|
-
weeks.push({
|
|
1124
|
-
days: [...days, ...createDaysPending(props, base, days.length)]
|
|
1125
|
-
});
|
|
1126
|
-
}
|
|
1127
|
-
return weeks;
|
|
1128
|
-
}
|
|
1129
|
-
function dayRangeIsOutsideMin(props, day) {
|
|
1130
|
-
const { date, minDate } = props;
|
|
1131
|
-
return minDate
|
|
1132
|
-
? getDateWeight(assignDayInDate(date, day)) < getDateWeight(minDate)
|
|
1133
|
-
: false;
|
|
1134
|
-
}
|
|
1135
|
-
function dayRangeIsOutsideMax(props, day) {
|
|
1136
|
-
const { date, maxDate } = props;
|
|
1137
|
-
return maxDate
|
|
1138
|
-
? getDateWeight(assignDayInDate(date, day)) > getDateWeight(maxDate)
|
|
1139
|
-
: false;
|
|
1140
|
-
}
|
|
1141
|
-
function dayRangeIsOutside(props, day) {
|
|
1142
|
-
return dayRangeIsOutsideMin(props, day) || dayRangeIsOutsideMax(props, day);
|
|
1143
|
-
}
|
|
1144
|
-
function createDayRangePicker(props) {
|
|
1145
|
-
const date = new Date(props.date.getFullYear(), props.date.getMonth(), 1);
|
|
1146
|
-
const firstWeek = createFirstWeek(props, date);
|
|
1147
|
-
const nextWeeks = createNextWeeks(props, date);
|
|
1148
|
-
return [firstWeek, ...nextWeeks];
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
function createMonthState(props, value) {
|
|
1152
|
-
const { date, month, year } = props;
|
|
1153
|
-
return {
|
|
1154
|
-
disabled: monthIsOutside(props, value),
|
|
1155
|
-
focused: value === month,
|
|
1156
|
-
label: MONTH_NAMES()[value],
|
|
1157
|
-
selected: date.getFullYear() === year && value === date.getMonth(),
|
|
1158
|
-
value
|
|
1159
|
-
};
|
|
1160
|
-
}
|
|
1161
|
-
function monthIsOutsideMin(props, month) {
|
|
1162
|
-
const { year, minDate } = props;
|
|
1163
|
-
return minDate
|
|
1164
|
-
? minDate.getFullYear() === year && month < minDate.getMonth()
|
|
1165
|
-
: false;
|
|
1166
|
-
}
|
|
1167
|
-
function monthIsOutsideMax(props, month) {
|
|
1168
|
-
const { year, maxDate } = props;
|
|
1169
|
-
return maxDate
|
|
1170
|
-
? maxDate.getFullYear() === year && month > maxDate.getMonth()
|
|
1171
|
-
: false;
|
|
1172
|
-
}
|
|
1173
|
-
function monthIsOutside(props, month) {
|
|
1174
|
-
return monthIsOutsideMin(props, month) || monthIsOutsideMax(props, month);
|
|
1175
|
-
}
|
|
1176
|
-
function checkMonthPicker(props) {
|
|
1177
|
-
const { maxDate, minDate, month } = props;
|
|
1178
|
-
return minDate && monthIsOutsideMin(props, month)
|
|
1179
|
-
? minDate.getMonth()
|
|
1180
|
-
: maxDate && monthIsOutsideMax(props, month)
|
|
1181
|
-
? maxDate.getMonth()
|
|
1182
|
-
: undefined;
|
|
1183
|
-
}
|
|
1184
|
-
function createMonthPicker(props) {
|
|
1185
|
-
return [
|
|
1186
|
-
createMonthState(props, Month.January),
|
|
1187
|
-
createMonthState(props, Month.February),
|
|
1188
|
-
createMonthState(props, Month.March),
|
|
1189
|
-
createMonthState(props, Month.April),
|
|
1190
|
-
createMonthState(props, Month.May),
|
|
1191
|
-
createMonthState(props, Month.June),
|
|
1192
|
-
createMonthState(props, Month.July),
|
|
1193
|
-
createMonthState(props, Month.August),
|
|
1194
|
-
createMonthState(props, Month.September),
|
|
1195
|
-
createMonthState(props, Month.October),
|
|
1196
|
-
createMonthState(props, Month.November),
|
|
1197
|
-
createMonthState(props, Month.December)
|
|
1198
|
-
];
|
|
1199
|
-
}
|
|
1200
|
-
function monthIsLimitMin(props) {
|
|
1201
|
-
const { month, date, minDate } = props;
|
|
1202
|
-
if (itIsDefined(month) && date) {
|
|
1203
|
-
const minYear = minDate ? minDate.getFullYear() : 0;
|
|
1204
|
-
const minMonth = minDate ? minDate.getMonth() : 0;
|
|
1205
|
-
return date.getFullYear() === minYear && month <= minMonth;
|
|
1206
|
-
}
|
|
1207
|
-
return false;
|
|
1208
|
-
}
|
|
1209
|
-
function monthIsLimitMax(props) {
|
|
1210
|
-
const { month, date, maxDate } = props;
|
|
1211
|
-
if (itIsDefined(month) && date) {
|
|
1212
|
-
const maxYear = maxDate ? maxDate.getFullYear() : 10000;
|
|
1213
|
-
const maxMonth = maxDate ? maxDate.getMonth() : 11;
|
|
1214
|
-
return date.getFullYear() === maxYear && month >= maxMonth;
|
|
1215
|
-
}
|
|
1216
|
-
return false;
|
|
1217
|
-
}
|
|
1218
|
-
function monthLimitTemplate(props) {
|
|
1219
|
-
return {
|
|
1220
|
-
limitNext: monthIsLimitMax(props),
|
|
1221
|
-
limitPrevious: monthIsLimitMin(props)
|
|
1222
|
-
};
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
var PickerListenerType;
|
|
1226
|
-
(function (PickerListenerType) {
|
|
1227
|
-
PickerListenerType["Select"] = "PickerSelect";
|
|
1228
|
-
PickerListenerType["Now"] = "PickerNow";
|
|
1229
|
-
PickerListenerType["Cancel"] = "PickerCancel";
|
|
1230
|
-
})(PickerListenerType || (PickerListenerType = {}));
|
|
1231
|
-
|
|
1232
|
-
function createYear(props, value) {
|
|
1233
|
-
const { date, year } = props;
|
|
1234
|
-
return {
|
|
1235
|
-
disabled: !value,
|
|
1236
|
-
focused: value === year,
|
|
1237
|
-
selected: value === date.getFullYear(),
|
|
1238
|
-
value
|
|
1239
|
-
};
|
|
1240
|
-
}
|
|
1241
|
-
function yearIsOutlineMin(props) {
|
|
1242
|
-
const { year, minDate } = props;
|
|
1243
|
-
return minDate ? year < minDate.getFullYear() : false;
|
|
1244
|
-
}
|
|
1245
|
-
function yearIsOutlineMax(props) {
|
|
1246
|
-
const { year, maxDate } = props;
|
|
1247
|
-
return maxDate ? year > maxDate.getFullYear() : false;
|
|
1248
|
-
}
|
|
1249
|
-
function checkYearPicker(props) {
|
|
1250
|
-
const { maxDate, minDate } = props;
|
|
1251
|
-
return minDate && yearIsOutlineMin(props)
|
|
1252
|
-
? minDate.getFullYear()
|
|
1253
|
-
: maxDate && yearIsOutlineMax(props)
|
|
1254
|
-
? maxDate.getFullYear()
|
|
1255
|
-
: undefined;
|
|
1256
|
-
}
|
|
1257
|
-
function createYearPicker(props) {
|
|
1258
|
-
const { year, maxDate, minDate } = props;
|
|
1259
|
-
const prevYears = [];
|
|
1260
|
-
const nextYears = [];
|
|
1261
|
-
let minRange = year;
|
|
1262
|
-
let maxRange = year;
|
|
1263
|
-
const minYear = minDate?.getFullYear() || 0;
|
|
1264
|
-
const maxYear = maxDate?.getFullYear() || 10000;
|
|
1265
|
-
for (let index = 0; index < COUNT_YEAR_RANGE; index++) {
|
|
1266
|
-
const prevValue = year - COUNT_YEAR_RANGE + index;
|
|
1267
|
-
const nextValue = year + index + 1;
|
|
1268
|
-
const prevYear = prevValue >= minYear ? prevValue : undefined;
|
|
1269
|
-
const nextYear = nextValue <= maxYear ? nextValue : undefined;
|
|
1270
|
-
const prevState = createYear(props, prevYear);
|
|
1271
|
-
const nextState = createYear(props, nextYear);
|
|
1272
|
-
prevYears.push(prevState);
|
|
1273
|
-
nextYears.push(nextState);
|
|
1274
|
-
if (!!prevState.value && minRange > prevState.value) {
|
|
1275
|
-
minRange = prevState.value;
|
|
1276
|
-
}
|
|
1277
|
-
if (!!nextState.value && maxRange < nextState.value) {
|
|
1278
|
-
maxRange = nextState.value;
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
const yearCenter = createYear(props, year);
|
|
1282
|
-
return {
|
|
1283
|
-
canPrevious: minYear < minRange,
|
|
1284
|
-
canNext: maxYear > maxRange,
|
|
1285
|
-
maxRange,
|
|
1286
|
-
minRange,
|
|
1287
|
-
years: [...prevYears, yearCenter, ...nextYears]
|
|
1288
|
-
};
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
const normalize = (word) => {
|
|
1292
|
-
return word
|
|
1293
|
-
.slice()
|
|
1294
|
-
.replace(/á/g, 'a')
|
|
1295
|
-
.replace(/Á/g, 'A')
|
|
1296
|
-
.replace(/é/g, 'e')
|
|
1297
|
-
.replace(/É/g, 'E')
|
|
1298
|
-
.replace(/í/g, 'i')
|
|
1299
|
-
.replace(/Í/g, 'I')
|
|
1300
|
-
.replace(/ó/g, 'o')
|
|
1301
|
-
.replace(/Ó/g, 'O')
|
|
1302
|
-
.replace(/ú/g, 'u')
|
|
1303
|
-
.replace(/Ú/g, 'U');
|
|
1304
|
-
};
|
|
1305
|
-
const hasPattern = (word, pattern, force = false) => {
|
|
1306
|
-
let filter = pattern.toLowerCase();
|
|
1307
|
-
let test = word.toLowerCase();
|
|
1308
|
-
if (force) {
|
|
1309
|
-
test = normalize(test);
|
|
1310
|
-
filter = normalize(filter);
|
|
1311
|
-
}
|
|
1312
|
-
return !!test.match(`^.*${filter}.*$`);
|
|
1313
|
-
};
|
|
1314
|
-
|
|
1315
|
-
function createEmptyStore() {
|
|
1316
|
-
return {
|
|
1317
|
-
coincidences: undefined,
|
|
1318
|
-
pattern: '',
|
|
1319
|
-
previous: null
|
|
1320
|
-
};
|
|
1321
|
-
}
|
|
1322
|
-
function searchForPattern(props) {
|
|
1323
|
-
const { pattern, store } = props;
|
|
1324
|
-
if (!store?.pattern) {
|
|
1325
|
-
return null;
|
|
1326
|
-
}
|
|
1327
|
-
let newStore = store;
|
|
1328
|
-
let search = false;
|
|
1329
|
-
while (!search && newStore) {
|
|
1330
|
-
search = hasPattern(pattern || '', newStore.pattern, true);
|
|
1331
|
-
if (!search) {
|
|
1332
|
-
newStore = newStore.previous;
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
return newStore || createEmptyStore();
|
|
1336
|
-
}
|
|
1337
|
-
function createStoreAutocomplete(props) {
|
|
1338
|
-
const { pattern, suggestions, reboot } = props;
|
|
1339
|
-
if (!pattern) {
|
|
1340
|
-
return { collection: suggestions, store: createEmptyStore() };
|
|
1341
|
-
}
|
|
1342
|
-
const store = reboot ? createEmptyStore() : searchForPattern(props);
|
|
1343
|
-
const elements = store?.coincidences || suggestions;
|
|
1344
|
-
const coincidences = elements.filter((element) => element.hasCoincidence(pattern));
|
|
1345
|
-
return {
|
|
1346
|
-
collection: coincidences,
|
|
1347
|
-
store: {
|
|
1348
|
-
coincidences,
|
|
1349
|
-
pattern,
|
|
1350
|
-
previous: store
|
|
1351
|
-
}
|
|
1352
|
-
};
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
const classElement = '.rls-list-field__element';
|
|
1356
|
-
const POSITION_INITIAL = 0;
|
|
1357
|
-
function locationListIsBottom(contentElement, listElement) {
|
|
1358
|
-
if (contentElement && listElement) {
|
|
1359
|
-
const { top, height } = contentElement.getBoundingClientRect();
|
|
1360
|
-
const { clientHeight } = listElement;
|
|
1361
|
-
return top + height + clientHeight < window.innerHeight;
|
|
1362
|
-
}
|
|
1363
|
-
return true;
|
|
1364
|
-
}
|
|
1365
|
-
function navigationInputDown(props) {
|
|
1366
|
-
const { contentElement, listElement } = props;
|
|
1367
|
-
if (!locationListIsBottom(contentElement, listElement)) {
|
|
1368
|
-
return undefined;
|
|
1369
|
-
}
|
|
1370
|
-
const elements = listElement?.querySelectorAll(classElement);
|
|
1371
|
-
if (elements?.length) {
|
|
1372
|
-
elements.item(0).focus();
|
|
1373
|
-
setTimeout(() => {
|
|
1374
|
-
listElement?.scroll({ top: 0, behavior: 'smooth' });
|
|
1375
|
-
}, 100);
|
|
1376
|
-
}
|
|
1377
|
-
return POSITION_INITIAL;
|
|
1378
|
-
}
|
|
1379
|
-
function navigationInputUp(props) {
|
|
1380
|
-
const { contentElement, listElement } = props;
|
|
1381
|
-
if (locationListIsBottom(contentElement, listElement)) {
|
|
1382
|
-
return undefined;
|
|
1383
|
-
}
|
|
1384
|
-
const elements = listElement?.querySelectorAll(classElement);
|
|
1385
|
-
if (!elements?.length) {
|
|
1386
|
-
return POSITION_INITIAL;
|
|
1387
|
-
}
|
|
1388
|
-
const position = elements.length - 1;
|
|
1389
|
-
const element = elements.item(position);
|
|
1390
|
-
element?.focus();
|
|
1391
|
-
setTimeout(() => {
|
|
1392
|
-
listElement?.scroll({
|
|
1393
|
-
top: element?.offsetTop + element?.offsetLeft,
|
|
1394
|
-
behavior: 'smooth'
|
|
1395
|
-
});
|
|
1396
|
-
}, 100);
|
|
1397
|
-
return position;
|
|
1398
|
-
}
|
|
1399
|
-
function navigationElementDown(props) {
|
|
1400
|
-
const { contentElement, inputElement, listElement, position } = props;
|
|
1401
|
-
const elements = listElement?.querySelectorAll(classElement);
|
|
1402
|
-
const newPosition = position + 1;
|
|
1403
|
-
if (newPosition < (elements?.length || 0)) {
|
|
1404
|
-
elements?.item(newPosition)?.focus();
|
|
1405
|
-
return newPosition;
|
|
1406
|
-
}
|
|
1407
|
-
if (!locationListIsBottom(contentElement, listElement)) {
|
|
1408
|
-
inputElement?.focus();
|
|
1409
|
-
}
|
|
1410
|
-
return position;
|
|
1411
|
-
}
|
|
1412
|
-
function navigationElementUp(props) {
|
|
1413
|
-
const { contentElement, inputElement, listElement, position } = props;
|
|
1414
|
-
if (position > 0) {
|
|
1415
|
-
const elements = listElement?.querySelectorAll(classElement);
|
|
1416
|
-
const newPosition = position - 1;
|
|
1417
|
-
elements?.item(newPosition)?.focus();
|
|
1418
|
-
return newPosition;
|
|
1419
|
-
}
|
|
1420
|
-
if (locationListIsBottom(contentElement, listElement)) {
|
|
1421
|
-
inputElement?.focus();
|
|
1422
|
-
}
|
|
1423
|
-
return POSITION_INITIAL;
|
|
1424
|
-
}
|
|
1425
|
-
function listNavigationInput(props) {
|
|
1426
|
-
switch (props.event.code) {
|
|
1427
|
-
case 'ArrowDown':
|
|
1428
|
-
return navigationInputDown(props);
|
|
1429
|
-
case 'ArrowUp':
|
|
1430
|
-
return navigationInputUp(props);
|
|
1431
|
-
default:
|
|
1432
|
-
return undefined;
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
function listNavigationElement(props) {
|
|
1436
|
-
const { event } = props;
|
|
1437
|
-
switch (event.code) {
|
|
1438
|
-
case 'ArrowDown':
|
|
1439
|
-
return navigationElementDown(props);
|
|
1440
|
-
case 'ArrowUp':
|
|
1441
|
-
return navigationElementUp(props);
|
|
1442
|
-
default:
|
|
1443
|
-
return POSITION_INITIAL;
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
class ListCollection {
|
|
1448
|
-
constructor(value) {
|
|
1449
|
-
this.value = value;
|
|
1450
|
-
}
|
|
1451
|
-
find(element) {
|
|
1452
|
-
return this.value.find((current) => current.compareTo(element));
|
|
1453
|
-
}
|
|
1735
|
+
}) }), jsxRuntimeExports.jsx("div", { className: "rls-pagination__description", children: template.description }), jsxRuntimeExports.jsxs("div", { className: "rls-pagination__actions", children: [jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goNextPagination, disabled: template.lastPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-right" }) }), jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goLastPagination, disabled: template.lastPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrowhead-right" }) })] })] }));
|
|
1454
1736
|
}
|
|
1455
1737
|
|
|
1456
1738
|
function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, month, minDate, onValue, rlsTheme, year }) {
|
|
1457
1739
|
const currentDate = date || new Date(); // Initial date
|
|
1458
1740
|
const [weeks, setWeeks] = useState([]);
|
|
1459
|
-
const [value, setValue] = useState(formControl?.
|
|
1741
|
+
const [value, setValue] = useState(formControl?.value || currentDate.getDate());
|
|
1460
1742
|
useEffect(() => {
|
|
1461
1743
|
const props = createPickerProps();
|
|
1462
1744
|
const day = checkDayPicker(props);
|
|
@@ -1465,13 +1747,13 @@ function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, mo
|
|
|
1465
1747
|
useEffect(() => {
|
|
1466
1748
|
const day = checkDayPicker(createPickerProps());
|
|
1467
1749
|
day
|
|
1468
|
-
? formControl?.
|
|
1469
|
-
: setValue(formControl?.
|
|
1470
|
-
}, [formControl?.
|
|
1750
|
+
? formControl?.setValue(day)
|
|
1751
|
+
: setValue(formControl?.value || currentDate.getDate());
|
|
1752
|
+
}, [formControl?.value]);
|
|
1471
1753
|
function createPickerProps() {
|
|
1472
1754
|
return {
|
|
1473
1755
|
date: currentDate,
|
|
1474
|
-
day: formControl?.
|
|
1756
|
+
day: formControl?.value || value,
|
|
1475
1757
|
month: itIsDefined(month) ? month : currentDate.getMonth(),
|
|
1476
1758
|
year: year || currentDate.getFullYear(),
|
|
1477
1759
|
minDate,
|
|
@@ -1479,7 +1761,7 @@ function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, mo
|
|
|
1479
1761
|
};
|
|
1480
1762
|
}
|
|
1481
1763
|
function setDayValue(value) {
|
|
1482
|
-
formControl ? formControl.
|
|
1764
|
+
formControl ? formControl.setValue(value) : setValue(value);
|
|
1483
1765
|
}
|
|
1484
1766
|
function onChange(value) {
|
|
1485
1767
|
setDayValue(value);
|
|
@@ -1487,19 +1769,18 @@ function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, mo
|
|
|
1487
1769
|
onValue(value);
|
|
1488
1770
|
}
|
|
1489
1771
|
}
|
|
1490
|
-
return (jsxs("div", { className: "rls-picker-day", "rls-theme": rlsTheme, children: [jsx("div", { className: "rls-picker-day__header", children: DAY_LABELS().map((title, index) => (jsx("label", { className: "rls-picker-day__label", children: title }, index))) }), jsx("div", { className: "rls-picker-day__component", children: weeks.map(({ days }, index) => (jsx("div", { className: "rls-picker-day__week", children: days.map(({ value, disabled, focused, forbidden, selected, today }, index) => (jsx("div", { className: renderClassStatus('rls-picker-day__element', {
|
|
1772
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-day", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-day__header", children: DAY_LABELS().map((title, index) => (jsxRuntimeExports.jsx("label", { className: "rls-picker-day__label", children: title }, index))) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-day__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-picker-day__week", children: days.map(({ value, disabled, focused, forbidden, selected, today }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-picker-day__element', {
|
|
1491
1773
|
disabled: disabled || disabledPicker,
|
|
1492
1774
|
focused,
|
|
1493
1775
|
forbidden,
|
|
1494
1776
|
selected,
|
|
1495
1777
|
today
|
|
1496
|
-
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsx("span", { className: "rls-picker-day__element__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
1778
|
+
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day__element__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
1497
1779
|
}
|
|
1498
1780
|
|
|
1499
|
-
const
|
|
1500
|
-
|
|
1781
|
+
const FORMAT_RANGE = '{dd}/{mx}/{aa}';
|
|
1501
1782
|
function RlsPickerDayRange({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
|
|
1502
|
-
const currentRange = formControl?.
|
|
1783
|
+
const currentRange = formControl?.value || DateRange.now();
|
|
1503
1784
|
const currentDate = normalizeMinTime(date || currentRange.minDate);
|
|
1504
1785
|
const sourceDate = useRef(currentRange.minDate);
|
|
1505
1786
|
const [weeks, setWeeks] = useState([]);
|
|
@@ -1520,21 +1801,21 @@ function RlsPickerDayRange({ date, disabled: disabledPicker, formControl, maxDat
|
|
|
1520
1801
|
: new DateRange(date, sourceDate.current);
|
|
1521
1802
|
sourceDate.current = date;
|
|
1522
1803
|
setRange(range);
|
|
1523
|
-
formControl?.
|
|
1804
|
+
formControl?.setValue(range);
|
|
1524
1805
|
}
|
|
1525
|
-
return (jsxs("div", { className: "rls-picker-day-range", "rls-theme": rlsTheme, children: [jsx("div", { className: "rls-picker-day-range__title", children: dateFormatTemplate(sourceDate.current,
|
|
1806
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-day-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__title", children: dateFormatTemplate(sourceDate.current, FORMAT_RANGE) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__header", children: DAY_LABELS().map((title, index) => (jsxRuntimeExports.jsx("label", { className: "rls-picker-day-range__label", children: title }, index))) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__week", children: days.map(({ disabled, end, forbidden, source, ranged, value }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-picker-day-range__element', {
|
|
1526
1807
|
disabled: disabled || disabledPicker,
|
|
1527
1808
|
end,
|
|
1528
1809
|
forbidden,
|
|
1529
1810
|
ranged,
|
|
1530
1811
|
source
|
|
1531
|
-
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsx("span", { className: "rls-picker-day-range__element__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
1812
|
+
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day-range__element__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
1532
1813
|
}
|
|
1533
1814
|
|
|
1534
1815
|
function RlsPickerMonth({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme, year }) {
|
|
1535
1816
|
const currentDate = date || new Date();
|
|
1536
1817
|
const [months, setMonths] = useState([]);
|
|
1537
|
-
const [value, setValue] = useState(formControl?.
|
|
1818
|
+
const [value, setValue] = useState(formControl?.value || currentDate.getMonth());
|
|
1538
1819
|
useEffect(() => {
|
|
1539
1820
|
const props = createPickerProps(); // MonthPickerProps
|
|
1540
1821
|
const month = checkMonthPicker(props);
|
|
@@ -1543,20 +1824,20 @@ function RlsPickerMonth({ date, disabled: disabledPicker, formControl, maxDate,
|
|
|
1543
1824
|
useEffect(() => {
|
|
1544
1825
|
const month = checkMonthPicker(createPickerProps());
|
|
1545
1826
|
itIsDefined(month)
|
|
1546
|
-
? formControl?.
|
|
1547
|
-
: setValue(formControl?.
|
|
1548
|
-
}, [formControl?.
|
|
1827
|
+
? formControl?.setValue(month)
|
|
1828
|
+
: setValue(formControl?.value || currentDate.getMonth());
|
|
1829
|
+
}, [formControl?.value]);
|
|
1549
1830
|
function createPickerProps() {
|
|
1550
1831
|
return {
|
|
1551
1832
|
date: currentDate,
|
|
1552
|
-
month: itIsDefined(formControl?.
|
|
1833
|
+
month: itIsDefined(formControl?.value) ? formControl?.value : value,
|
|
1553
1834
|
year: year || currentDate.getFullYear(),
|
|
1554
1835
|
minDate,
|
|
1555
1836
|
maxDate
|
|
1556
1837
|
};
|
|
1557
1838
|
}
|
|
1558
1839
|
function setMonthValue(value) {
|
|
1559
|
-
formControl ? formControl.
|
|
1840
|
+
formControl ? formControl.setValue(value) : setValue(value);
|
|
1560
1841
|
}
|
|
1561
1842
|
function onChange(value) {
|
|
1562
1843
|
setMonthValue(value);
|
|
@@ -1564,11 +1845,11 @@ function RlsPickerMonth({ date, disabled: disabledPicker, formControl, maxDate,
|
|
|
1564
1845
|
onValue(value);
|
|
1565
1846
|
}
|
|
1566
1847
|
}
|
|
1567
|
-
return (jsx("div", { className: "rls-picker-month", "rls-theme": rlsTheme, children: months.map(({ label, value, disabled, focused, selected }, index) => (jsx("div", { className: renderClassStatus('rls-picker-month__component', {
|
|
1848
|
+
return (jsxRuntimeExports.jsx("div", { className: "rls-picker-month", "rls-theme": rlsTheme, children: months.map(({ label, value, disabled, focused, selected }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-picker-month__component', {
|
|
1568
1849
|
disabled: disabled || disabledPicker,
|
|
1569
1850
|
focused,
|
|
1570
1851
|
selected
|
|
1571
|
-
}), onClick: !(disabled || disabledPicker) ? () => onChange(value) : undefined, children: jsx("span", { className: "rls-picker-month__span", children: label }) }, index))) }));
|
|
1852
|
+
}), onClick: !(disabled || disabledPicker) ? () => onChange(value) : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-month__span", children: label }) }, index))) }));
|
|
1572
1853
|
}
|
|
1573
1854
|
|
|
1574
1855
|
function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled, maxDate, minDate, onClick }) {
|
|
@@ -1576,54 +1857,54 @@ function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled,
|
|
|
1576
1857
|
date,
|
|
1577
1858
|
maxDate,
|
|
1578
1859
|
minDate,
|
|
1579
|
-
month: monthControl.
|
|
1860
|
+
month: monthControl.value
|
|
1580
1861
|
});
|
|
1581
|
-
const monthName = MONTH_NAMES()[monthControl.
|
|
1862
|
+
const monthName = MONTH_NAMES()[monthControl.value || 0];
|
|
1582
1863
|
function onPreviousMonth() {
|
|
1583
|
-
if (itIsDefined(monthControl.
|
|
1584
|
-
if (monthControl.
|
|
1585
|
-
monthControl.
|
|
1864
|
+
if (itIsDefined(monthControl.value) && itIsDefined(yearControl.value)) {
|
|
1865
|
+
if (monthControl.value > Month.January) {
|
|
1866
|
+
monthControl.setValue(monthControl.value - 1);
|
|
1586
1867
|
}
|
|
1587
1868
|
else {
|
|
1588
|
-
monthControl.
|
|
1589
|
-
yearControl.
|
|
1869
|
+
monthControl.setValue(Month.December);
|
|
1870
|
+
yearControl.setValue(yearControl.value - 1);
|
|
1590
1871
|
}
|
|
1591
1872
|
}
|
|
1592
1873
|
}
|
|
1593
1874
|
function onPreviousYear() {
|
|
1594
|
-
if (itIsDefined(yearControl.
|
|
1595
|
-
yearControl.
|
|
1875
|
+
if (itIsDefined(yearControl.value)) {
|
|
1876
|
+
yearControl.setValue(yearControl.value - 1);
|
|
1596
1877
|
}
|
|
1597
1878
|
}
|
|
1598
1879
|
function onPrevious() {
|
|
1599
1880
|
type === 'month' ? onPreviousMonth() : onPreviousYear();
|
|
1600
1881
|
}
|
|
1601
1882
|
function onNextMonth() {
|
|
1602
|
-
if (itIsDefined(monthControl.
|
|
1603
|
-
if (monthControl.
|
|
1604
|
-
monthControl.
|
|
1883
|
+
if (itIsDefined(monthControl.value) && itIsDefined(yearControl.value)) {
|
|
1884
|
+
if (monthControl.value < Month.December) {
|
|
1885
|
+
monthControl.setValue(monthControl.value + 1);
|
|
1605
1886
|
}
|
|
1606
1887
|
else {
|
|
1607
|
-
monthControl.
|
|
1608
|
-
yearControl.
|
|
1888
|
+
monthControl.setValue(Month.January);
|
|
1889
|
+
yearControl.setValue(yearControl.value + 1);
|
|
1609
1890
|
}
|
|
1610
1891
|
}
|
|
1611
1892
|
}
|
|
1612
1893
|
function onNextYear() {
|
|
1613
|
-
if (itIsDefined(yearControl.
|
|
1614
|
-
yearControl.
|
|
1894
|
+
if (itIsDefined(yearControl.value)) {
|
|
1895
|
+
yearControl.setValue(yearControl.value + 1);
|
|
1615
1896
|
}
|
|
1616
1897
|
}
|
|
1617
1898
|
function onNext() {
|
|
1618
1899
|
type === 'month' ? onNextMonth() : onNextYear();
|
|
1619
1900
|
}
|
|
1620
|
-
return (jsxs("div", { className: "rls-picker-month-title", children: [jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPrevious, disabled: limitPrevious || disabled }), jsx("span", { onClick: onClick, children: monthName }), jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onNext, disabled: limitNext || disabled })] }));
|
|
1901
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-month-title", children: [jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPrevious, disabled: limitPrevious || disabled }), jsxRuntimeExports.jsx("span", { onClick: onClick, children: monthName }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onNext, disabled: limitNext || disabled })] }));
|
|
1621
1902
|
}
|
|
1622
1903
|
|
|
1623
1904
|
function RlsPickerYear({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme }) {
|
|
1624
1905
|
const currentDate = date || new Date();
|
|
1625
|
-
const [value, setValue] = useState(formControl?.
|
|
1626
|
-
const [year, setYear] = useState(formControl?.
|
|
1906
|
+
const [value, setValue] = useState(formControl?.value || currentDate.getFullYear());
|
|
1907
|
+
const [year, setYear] = useState(formControl?.value || currentDate.getFullYear());
|
|
1627
1908
|
const [template, setTemplate] = useState(createYearPicker(createPickerProps()));
|
|
1628
1909
|
useEffect(() => {
|
|
1629
1910
|
const props = createPickerProps(); // YearPickerProps
|
|
@@ -1635,9 +1916,9 @@ function RlsPickerYear({ date, disabled: disabledPicker, formControl, maxDate, m
|
|
|
1635
1916
|
useEffect(() => {
|
|
1636
1917
|
const year = checkYearPicker(createPickerProps());
|
|
1637
1918
|
itIsDefined(year)
|
|
1638
|
-
? formControl?.
|
|
1639
|
-
: setValue(formControl?.
|
|
1640
|
-
}, [formControl?.
|
|
1919
|
+
? formControl?.setValue(year)
|
|
1920
|
+
: setValue(formControl?.value || currentDate.getFullYear());
|
|
1921
|
+
}, [formControl?.value]);
|
|
1641
1922
|
function createPickerProps() {
|
|
1642
1923
|
return {
|
|
1643
1924
|
date: currentDate,
|
|
@@ -1647,7 +1928,7 @@ function RlsPickerYear({ date, disabled: disabledPicker, formControl, maxDate, m
|
|
|
1647
1928
|
};
|
|
1648
1929
|
}
|
|
1649
1930
|
function setYearValue(value) {
|
|
1650
|
-
formControl ? formControl.
|
|
1931
|
+
formControl ? formControl.setValue(value) : setValue(value);
|
|
1651
1932
|
setYear(value);
|
|
1652
1933
|
}
|
|
1653
1934
|
function onClickPrev() {
|
|
@@ -1662,19 +1943,19 @@ function RlsPickerYear({ date, disabled: disabledPicker, formControl, maxDate, m
|
|
|
1662
1943
|
onValue(value);
|
|
1663
1944
|
}
|
|
1664
1945
|
}
|
|
1665
|
-
return (jsxs("div", { className: "rls-picker-year", "rls-theme": rlsTheme, children: [jsxs("div", { className: "rls-picker-year__header", children: [jsx("div", { className: "rls-picker-year__action rls-picker-year__action--prev", children: jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onClickPrev, disabled: !template.canPrevious || disabledPicker }) }), jsxs("label", { className: "rls-title-bold", children: [template.minRange, " - ", template.maxRange] }), jsx("div", { className: "rls-picker-year__action rls-picker-year__action--next", children: jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onClickNext, disabled: !template.canNext || disabledPicker }) })] }), jsx("div", { className: "rls-picker-year__component", children: template.years.map(({ value, disabled, focused, selected }, index) => (jsx("div", { className: renderClassStatus('rls-picker-year__year', {
|
|
1946
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-year", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-year__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-year__action rls-picker-year__action--prev", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onClickPrev, disabled: !template.canPrevious || disabledPicker }) }), jsxRuntimeExports.jsxs("label", { className: "rls-title-bold", children: [template.minRange, " - ", template.maxRange] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-year__action rls-picker-year__action--next", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onClickNext, disabled: !template.canNext || disabledPicker }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-year__component", children: template.years.map(({ value, disabled, focused, selected }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-picker-year__year', {
|
|
1666
1947
|
disabled: disabled || disabledPicker,
|
|
1667
1948
|
focused,
|
|
1668
1949
|
selected
|
|
1669
|
-
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsx("span", { className: "rls-picker-year__year__span rls-body1-medium", children: value || '????' }) }, index))) })] }));
|
|
1950
|
+
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-year__year__span rls-body1-medium", children: value || '????' }) }, index))) })] }));
|
|
1670
1951
|
}
|
|
1671
1952
|
|
|
1672
1953
|
function RlsToolbar({ actions, children, subtitle }) {
|
|
1673
|
-
return (jsxs("div", { className: "rls-toolbar", children: [jsxs("div", { className: "rls-toolbar__description", children: [children && jsx("label", { className: "rls-toolbar__title", children: children }), subtitle && (jsx("label", { className: "rls-toolbar__subtitle smalltext-semibold", children: subtitle }))] }), actions && (jsx("div", { className: "rls-toolbar__actions", children: actions.map((action, index) => (jsx("div", { children: action }, index))) }))] }));
|
|
1954
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-toolbar", children: [jsxRuntimeExports.jsxs("div", { className: "rls-toolbar__description", children: [children && jsxRuntimeExports.jsx("label", { className: "rls-toolbar__title", children: children }), subtitle && (jsxRuntimeExports.jsx("label", { className: "rls-toolbar__subtitle smalltext-semibold", children: subtitle }))] }), actions && (jsxRuntimeExports.jsx("div", { className: "rls-toolbar__actions", children: actions.map((action, index) => (jsxRuntimeExports.jsx("div", { children: action }, index))) }))] }));
|
|
1674
1955
|
}
|
|
1675
1956
|
|
|
1676
1957
|
function RlsCard({ children, outline, rlsTheme }) {
|
|
1677
|
-
return (jsx("div", { className: renderClassStatus('rls-card', { outline }), "rls-theme": rlsTheme, children: jsx("div", { className: "rls-card__content", children: children }) }));
|
|
1958
|
+
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-card', { outline }), "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-card__content", children: children }) }));
|
|
1678
1959
|
}
|
|
1679
1960
|
|
|
1680
1961
|
const reactI18n = i18n({
|
|
@@ -1707,12 +1988,12 @@ class ConfirmationResult extends PartialSealed {
|
|
|
1707
1988
|
}
|
|
1708
1989
|
}
|
|
1709
1990
|
function RlsConfirmation({ approved, content, reject, rlsTheme, subtitle, title, visible }) {
|
|
1710
|
-
return (jsxs("div", { className: renderClassStatus('rls-confirmation', { visible }), "rls-theme": rlsTheme, children: [jsxs("div", { className: "rls-confirmation__component", children: [jsxs("div", { className: "rls-confirmation__header", children: [title && jsx("div", { className: "rls-confirmation__title", children: title }), subtitle && (jsx("div", { className: "rls-confirmation__subtitle", children: subtitle }))] }), jsx("div", { className: "rls-confirmation__body", children: content && (jsx("div", { className: "rls-confirmation__message", children: content })) }), (approved || reject) && (jsx("div", { className: "rls-confirmation__footer", children: jsxs("div", { className: "rls-confirmation__actions", children: [approved && (jsx(RlsButton, { type: "raised", onClick: approved.onClick, children: approved.label })), reject && (jsx(RlsButton, { type: "outline", onClick: reject.onClick, children: reject.label }))] }) }))] }), jsx("div", { className: "rls-confirmation__backdrop" })] }));
|
|
1991
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-confirmation', { visible }), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__component", children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__header", children: [title && jsxRuntimeExports.jsx("div", { className: "rls-confirmation__title", children: title }), subtitle && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__subtitle", children: subtitle }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__body", children: content && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__message", children: content })) }), (approved || reject) && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__actions", children: [approved && (jsxRuntimeExports.jsx(RlsButton, { type: "raised", onClick: approved.onClick, children: approved.label })), reject && (jsxRuntimeExports.jsx(RlsButton, { type: "outline", onClick: reject.onClick, children: reject.label }))] }) }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__backdrop" })] }));
|
|
1711
1992
|
}
|
|
1712
1993
|
function useConfirmationService() {
|
|
1713
1994
|
const [config, setConfig] = useState({});
|
|
1714
1995
|
const [visible, setVisible] = useState(false);
|
|
1715
|
-
const rlsConfirmation = ReactDOM.createPortal(jsx(RlsConfirmation, { ...config, visible: visible }), document.body);
|
|
1996
|
+
const rlsConfirmation = ReactDOM.createPortal(jsxRuntimeExports.jsx(RlsConfirmation, { ...config, visible: visible }), document.body);
|
|
1716
1997
|
function confirmation(config) {
|
|
1717
1998
|
return new Promise((resolve) => {
|
|
1718
1999
|
const { content, rlsTheme, subtitle, title, approved, reject } = config;
|
|
@@ -1748,27 +2029,27 @@ function useConfirmationService() {
|
|
|
1748
2029
|
}
|
|
1749
2030
|
|
|
1750
2031
|
function RlsDatatableHeader({ children }) {
|
|
1751
|
-
return jsx("tr", { className: "rls-datatable__header", children: children });
|
|
2032
|
+
return jsxRuntimeExports.jsx("tr", { className: "rls-datatable__header", children: children });
|
|
1752
2033
|
}
|
|
1753
2034
|
function RlsDatatableTitle({ children, className, control }) {
|
|
1754
|
-
return (jsx("th", { className: renderClassStatus('rls-datatable__title', { control }, className).trim(), children: children }));
|
|
2035
|
+
return (jsxRuntimeExports.jsx("th", { className: renderClassStatus('rls-datatable__title', { control }, className).trim(), children: children }));
|
|
1755
2036
|
}
|
|
1756
2037
|
function RlsDatatableData({ children, className, error }) {
|
|
1757
|
-
return (jsx("tr", { className: renderClassStatus('rls-datatable__data', { error }, className).trim(), children: children }));
|
|
2038
|
+
return (jsxRuntimeExports.jsx("tr", { className: renderClassStatus('rls-datatable__data', { error }, className).trim(), children: children }));
|
|
1758
2039
|
}
|
|
1759
2040
|
function RlsDatatableCell({ children, className, control, overflow }) {
|
|
1760
|
-
return (jsx("th", { className: renderClassStatus('rls-datatable__cell', { control, overflow }, className).trim(), children: children }));
|
|
2041
|
+
return (jsxRuntimeExports.jsx("th", { className: renderClassStatus('rls-datatable__cell', { control, overflow }, className).trim(), children: children }));
|
|
1761
2042
|
}
|
|
1762
2043
|
function RlsDatatableTotals({ children, className, error }) {
|
|
1763
|
-
return (jsx("div", { className: renderClassStatus('rls-datatable__totals', { error }, className).trim(), children: children }));
|
|
2044
|
+
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-datatable__totals', { error }, className).trim(), children: children }));
|
|
1764
2045
|
}
|
|
1765
2046
|
function RlsDatatableInfo({ children, className, control, overflow }) {
|
|
1766
|
-
return (jsx("div", { className: renderClassStatus('rls-datatable__info', { control, overflow }, className).trim(), children: children }));
|
|
2047
|
+
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-datatable__info', { control, overflow }, className).trim(), children: children }));
|
|
1767
2048
|
}
|
|
1768
2049
|
function RlsDatatable({ children, datatable, footer, header, rlsTheme, summary }) {
|
|
1769
|
-
return (jsxs("div", { className: renderClassStatus('rls-datatable', {
|
|
2050
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-datatable', {
|
|
1770
2051
|
scrolleable: datatable?.scrolleable
|
|
1771
|
-
}), "rls-theme": rlsTheme, children: [jsxs("table", { children: [header && jsx("thead", { className: "rls-datatable__thead", children: header }), jsx("tbody", { ref: datatable?.bodyRef, className: "rls-datatable__tbody", children: children })] }), summary && jsx("div", { className: "rls-datatable__tsummary", children: summary }), footer && jsx("div", { className: "rls-datatable__tfooter", children: footer })] }));
|
|
2052
|
+
}), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("table", { children: [header && jsxRuntimeExports.jsx("thead", { className: "rls-datatable__thead", children: header }), jsxRuntimeExports.jsx("tbody", { ref: datatable?.bodyRef, className: "rls-datatable__tbody", children: children })] }), summary && jsxRuntimeExports.jsx("div", { className: "rls-datatable__tsummary", children: summary }), footer && jsxRuntimeExports.jsx("div", { className: "rls-datatable__tfooter", children: footer })] }));
|
|
1772
2053
|
}
|
|
1773
2054
|
|
|
1774
2055
|
function useDatatable() {
|
|
@@ -1793,10 +2074,10 @@ function useDatatable() {
|
|
|
1793
2074
|
}
|
|
1794
2075
|
|
|
1795
2076
|
function useListControl({ suggestions, formControl }) {
|
|
1796
|
-
const
|
|
2077
|
+
const contentRef = useRef(null);
|
|
1797
2078
|
const listRef = useRef(null);
|
|
1798
2079
|
const inputRef = useRef(null);
|
|
1799
|
-
const [
|
|
2080
|
+
const [state, setState] = useState({
|
|
1800
2081
|
collection: new ListCollection([]),
|
|
1801
2082
|
focused: false,
|
|
1802
2083
|
higher: false,
|
|
@@ -1806,8 +2087,8 @@ function useListControl({ suggestions, formControl }) {
|
|
|
1806
2087
|
const position = useRef(0);
|
|
1807
2088
|
useEffect(() => {
|
|
1808
2089
|
function onCloseSuggestions({ target }) {
|
|
1809
|
-
if (!
|
|
1810
|
-
|
|
2090
|
+
if (!contentRef?.current?.contains(target)) {
|
|
2091
|
+
setState((state) => ({ ...state, visible: false }));
|
|
1811
2092
|
}
|
|
1812
2093
|
}
|
|
1813
2094
|
document.addEventListener('click', onCloseSuggestions);
|
|
@@ -1816,51 +2097,51 @@ function useListControl({ suggestions, formControl }) {
|
|
|
1816
2097
|
};
|
|
1817
2098
|
}, []);
|
|
1818
2099
|
useEffect(() => {
|
|
1819
|
-
const
|
|
2100
|
+
const content = contentRef.current;
|
|
1820
2101
|
const list = listRef.current;
|
|
1821
2102
|
formControl?.touch();
|
|
1822
|
-
|
|
2103
|
+
setState((state) => ({
|
|
1823
2104
|
...state,
|
|
1824
|
-
higher:
|
|
2105
|
+
higher: locationListCanTop(content, list)
|
|
1825
2106
|
}));
|
|
1826
|
-
}, [
|
|
2107
|
+
}, [state.visible]);
|
|
1827
2108
|
useEffect(() => {
|
|
1828
|
-
|
|
2109
|
+
setState((state) => ({
|
|
1829
2110
|
...state,
|
|
1830
2111
|
collection: new ListCollection(suggestions)
|
|
1831
2112
|
}));
|
|
1832
2113
|
}, [suggestions]);
|
|
1833
2114
|
function setFocused(focused) {
|
|
1834
|
-
|
|
2115
|
+
setState((state) => ({ ...state, focused }));
|
|
1835
2116
|
}
|
|
1836
2117
|
function setValue(value) {
|
|
1837
|
-
|
|
2118
|
+
setState((state) => ({ ...state, value }));
|
|
1838
2119
|
}
|
|
1839
2120
|
function setVisible(visible) {
|
|
1840
|
-
|
|
2121
|
+
setState((state) => ({ ...state, visible }));
|
|
1841
2122
|
}
|
|
1842
2123
|
function navigationInput(event) {
|
|
1843
|
-
if (
|
|
1844
|
-
const newPosition =
|
|
1845
|
-
|
|
2124
|
+
if (state.visible) {
|
|
2125
|
+
const newPosition = navigationListFromInput({
|
|
2126
|
+
content: contentRef.current,
|
|
1846
2127
|
event: event,
|
|
1847
|
-
|
|
2128
|
+
list: listRef.current
|
|
1848
2129
|
});
|
|
1849
2130
|
position.current = newPosition || 0;
|
|
1850
2131
|
}
|
|
1851
2132
|
}
|
|
1852
2133
|
function navigationElement(event) {
|
|
1853
|
-
position.current =
|
|
1854
|
-
|
|
2134
|
+
position.current = navigationListFromElement({
|
|
2135
|
+
content: contentRef.current,
|
|
1855
2136
|
event: event,
|
|
1856
|
-
|
|
1857
|
-
|
|
2137
|
+
input: inputRef.current,
|
|
2138
|
+
list: listRef.current,
|
|
1858
2139
|
position: position.current
|
|
1859
2140
|
});
|
|
1860
2141
|
}
|
|
1861
2142
|
return {
|
|
1862
|
-
...
|
|
1863
|
-
|
|
2143
|
+
...state,
|
|
2144
|
+
contentRef,
|
|
1864
2145
|
inputRef,
|
|
1865
2146
|
listRef,
|
|
1866
2147
|
navigationElement,
|
|
@@ -1901,14 +2182,14 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
1901
2182
|
changeInternal.current = false;
|
|
1902
2183
|
return;
|
|
1903
2184
|
}
|
|
1904
|
-
refresh(collection, formControl?.
|
|
1905
|
-
}, [formControl?.
|
|
2185
|
+
refresh(collection, formControl?.value);
|
|
2186
|
+
}, [formControl?.value]);
|
|
1906
2187
|
useEffect(() => {
|
|
1907
2188
|
if (!initializedCollection.current || !initializedState.current) {
|
|
1908
2189
|
initializedCollection.current = true;
|
|
1909
2190
|
return;
|
|
1910
2191
|
}
|
|
1911
|
-
refresh(collection, formControl?.
|
|
2192
|
+
refresh(collection, formControl?.value);
|
|
1912
2193
|
}, [collection]);
|
|
1913
2194
|
function refresh(collection, state) {
|
|
1914
2195
|
if (!state) {
|
|
@@ -1924,7 +2205,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
1924
2205
|
function setFormState(value) {
|
|
1925
2206
|
if (formControl) {
|
|
1926
2207
|
changeInternal.current = true;
|
|
1927
|
-
formControl.
|
|
2208
|
+
formControl.setValue(value);
|
|
1928
2209
|
}
|
|
1929
2210
|
}
|
|
1930
2211
|
function onClickControl() {
|
|
@@ -1987,7 +2268,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
1987
2268
|
}
|
|
1988
2269
|
}
|
|
1989
2270
|
function refreshCoincidences(pattern, reboot = false) {
|
|
1990
|
-
const { collection, store } =
|
|
2271
|
+
const { collection, store } = createAutocompleteStore({
|
|
1991
2272
|
pattern,
|
|
1992
2273
|
suggestions,
|
|
1993
2274
|
reboot,
|
|
@@ -2012,32 +2293,34 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
|
|
|
2012
2293
|
};
|
|
2013
2294
|
}
|
|
2014
2295
|
|
|
2015
|
-
function RlsFieldAutocompleteTemplate({ suggestions, children, disabled, formControl, hiddenIcon,
|
|
2016
|
-
const
|
|
2296
|
+
function RlsFieldAutocompleteTemplate({ render, suggestions, children, disabled, formControl, hiddenIcon, onSearch, onSelect, onValue, placeholder, rlsTheme, searching }) {
|
|
2297
|
+
const fieldAutocomplete = useFieldAutocomplete({
|
|
2017
2298
|
suggestions,
|
|
2018
2299
|
disabled,
|
|
2019
2300
|
formControl,
|
|
2020
2301
|
onSelect,
|
|
2021
2302
|
onValue
|
|
2022
2303
|
});
|
|
2023
|
-
return (jsxs("div", { ref: listControl.
|
|
2304
|
+
return (jsxRuntimeExports.jsxs("div", { ref: fieldAutocomplete.listControl.contentRef, className: renderClassStatus('rls-field-box', {
|
|
2024
2305
|
disabled,
|
|
2025
|
-
focused: listControl.focused,
|
|
2026
|
-
selected: !!listControl.value
|
|
2027
|
-
}, 'rls-field-list rls-field-autocomplete'), "rls-theme": rlsTheme, children: [children && jsx("label", { className: "rls-field-box__label", children: children }), jsx("div", { className: "rls-field-box__component", children: jsxs("div", { className: "rls-field-box__body", children: [jsx("label", { className: "rls-field-list__control", onClick: onClickControl, children: listControl.value ? (jsx("span", { className: "rls-field-list__control__description", children: listControl.value })) : (jsx("span", { className: "rls-field-list__control__placeholder", children: placeholder })) }), !hiddenIcon && listControl.value && (jsx("button", { className: "rls-field-list__action", disabled: disabled, onClick: onClickAction, children: jsx(RlsIcon, { value: "trash-2" }) }))] }) }), jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }), jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
|
|
2028
|
-
visible: listControl.visible,
|
|
2029
|
-
hide: !listControl.visible,
|
|
2030
|
-
higher: listControl.higher
|
|
2031
|
-
}), children: [jsx("div", { className: "rls-field-list__suggestions__body", children: jsxs("ul", { ref: listControl.listRef, className: "rls-field-list__ul", children: [jsxs("div", { className: "rls-field-list__ul__search", children: [jsx("input", { ref: listControl.inputRef, className: "rls-field-list__ul__control", type: "text", placeholder: reactI18n('listInputPlaceholder'), value: pattern, onChange: ({ target: { value } }) => {
|
|
2032
|
-
setPattern(value);
|
|
2033
|
-
}, disabled: disabled || searching, onFocus: onFocusInput, onBlur: onBlurInput, onKeyDown: onKeydownInput }), onSearch && (jsx("button", { disabled: disabled || searching, onClick: () => {
|
|
2034
|
-
onSearch(pattern);
|
|
2035
|
-
}, children: jsx(RlsIcon, { value: "search" }) }))] }), searching && jsx(RlsProgressBar, { indeterminate: true }), coincidences.map((element, index) => (jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: onClickElement(element), onKeyDown: onKeydownElement(element), children: render(element) }, index))), !coincidences.length && (jsx("li", { className: "rls-field-list__empty", children: jsxs("div", { className: "rls-field-list__empty__description", children: [jsx("label", { className: "rls-label-bold truncate", children: reactI18n('listEmptyTitle') }), jsx("p", { className: "rls-caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsx("div", { className: "rls-field-list__backdrop", onClick: onClickBackdrop })] })] }));
|
|
2306
|
+
focused: fieldAutocomplete.listControl.focused,
|
|
2307
|
+
selected: !!fieldAutocomplete.listControl.value
|
|
2308
|
+
}, 'rls-field-list rls-field-autocomplete'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("label", { className: "rls-field-list__control", onClick: fieldAutocomplete.onClickControl, children: fieldAutocomplete.listControl.value ? (jsxRuntimeExports.jsx("span", { className: "rls-field-list__control__description", children: fieldAutocomplete.listControl.value })) : (jsxRuntimeExports.jsx("span", { className: "rls-field-list__control__placeholder", children: placeholder })) }), !hiddenIcon && fieldAutocomplete.listControl.value && (jsxRuntimeExports.jsx("button", { className: "rls-field-list__action", disabled: disabled, onClick: fieldAutocomplete.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: "trash-2" }) }))] }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
|
|
2309
|
+
visible: fieldAutocomplete.listControl.visible,
|
|
2310
|
+
hide: !fieldAutocomplete.listControl.visible,
|
|
2311
|
+
higher: fieldAutocomplete.listControl.higher
|
|
2312
|
+
}), children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: fieldAutocomplete.listControl.listRef, className: "rls-field-list__ul", children: [jsxRuntimeExports.jsxs("div", { className: "rls-field-list__ul__search", children: [jsxRuntimeExports.jsx("input", { ref: fieldAutocomplete.listControl.inputRef, className: "rls-field-list__ul__control", type: "text", placeholder: reactI18n('listInputPlaceholder'), value: fieldAutocomplete.pattern, onChange: ({ target: { value } }) => {
|
|
2313
|
+
fieldAutocomplete.setPattern(value);
|
|
2314
|
+
}, disabled: disabled || searching, onFocus: fieldAutocomplete.onFocusInput, onBlur: fieldAutocomplete.onBlurInput, onKeyDown: fieldAutocomplete.onKeydownInput }), onSearch && (jsxRuntimeExports.jsx("button", { disabled: disabled || searching, onClick: () => {
|
|
2315
|
+
onSearch(fieldAutocomplete.pattern);
|
|
2316
|
+
}, children: jsxRuntimeExports.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntimeExports.jsx(RlsProgressBar, { indeterminate: true }), fieldAutocomplete.coincidences.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: fieldAutocomplete.onClickElement(element), onKeyDown: fieldAutocomplete.onKeydownElement(element), children: render(element) }, index))), !fieldAutocomplete.coincidences.length && (jsxRuntimeExports.jsx("li", { className: "rls-field-list__empty", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-list__empty__description", children: [jsxRuntimeExports.jsx("label", { className: "rls-label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntimeExports.jsx("p", { className: "rls-caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: fieldAutocomplete.onClickBackdrop })] })] }));
|
|
2036
2317
|
}
|
|
2037
2318
|
function RlsFieldAutocomplete(props) {
|
|
2038
|
-
return (jsx(RlsFieldAutocompleteTemplate, { ...props, render: (element) => (jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
2319
|
+
return (jsxRuntimeExports.jsx(RlsFieldAutocompleteTemplate, { ...props, render: (element) => (jsxRuntimeExports.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
2039
2320
|
}
|
|
2040
2321
|
|
|
2322
|
+
const DATE_RANGE_FORMAT = '{dd}/{mx}/{aa}';
|
|
2323
|
+
|
|
2041
2324
|
function rangeFormatTemplate({ maxDate, minDate }) {
|
|
2042
2325
|
const minFormat = dateFormatTemplate(minDate, DATE_RANGE_FORMAT);
|
|
2043
2326
|
const maxFormat = dateFormatTemplate(maxDate, DATE_RANGE_FORMAT);
|
|
@@ -2045,113 +2328,13 @@ function rangeFormatTemplate({ maxDate, minDate }) {
|
|
|
2045
2328
|
}
|
|
2046
2329
|
|
|
2047
2330
|
function RlsModal({ children, visible, rlsTheme }) {
|
|
2048
|
-
return ReactDOM.createPortal(jsxs("div", { className: renderClassStatus('rls-modal', { visible }), "rls-theme": rlsTheme, children: [jsx("div", { className: "rls-modal__component", children: children }), jsx("div", { className: "rls-modal__backdrop" })] }), document.body);
|
|
2049
|
-
}
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
return (typeof props === 'object' && ('state' in props || 'validators' in props));
|
|
2053
|
-
}
|
|
2054
|
-
function createFormControlOptions(...argsProps) {
|
|
2055
|
-
const [props, validators] = argsProps;
|
|
2056
|
-
if (!props) {
|
|
2057
|
-
return { state: props, validators };
|
|
2058
|
-
}
|
|
2059
|
-
if (!validators && itIsFormControlOptions(props)) {
|
|
2060
|
-
return props;
|
|
2061
|
-
}
|
|
2062
|
-
return {
|
|
2063
|
-
state: props,
|
|
2064
|
-
validators
|
|
2065
|
-
};
|
|
2066
|
-
}
|
|
2067
|
-
|
|
2068
|
-
const controlIsValid = ({ state, validators }) => {
|
|
2069
|
-
return validators.reduce((errors, validator) => {
|
|
2070
|
-
const error = validator(state);
|
|
2071
|
-
if (error) {
|
|
2072
|
-
errors.push(error);
|
|
2073
|
-
}
|
|
2074
|
-
return errors;
|
|
2075
|
-
}, []);
|
|
2076
|
-
};
|
|
2077
|
-
|
|
2078
|
-
function useControl(controlOptions, controlValidators) {
|
|
2079
|
-
const { state, touched, validators } = createFormControlOptions(controlOptions, controlValidators);
|
|
2080
|
-
const [controlState, setControlState] = useState({
|
|
2081
|
-
dirty: false,
|
|
2082
|
-
disabled: false,
|
|
2083
|
-
focused: false,
|
|
2084
|
-
state: state,
|
|
2085
|
-
touched: !!touched,
|
|
2086
|
-
validators: validators
|
|
2087
|
-
});
|
|
2088
|
-
const initialState = useRef(state);
|
|
2089
|
-
const elementRef = useRef(null);
|
|
2090
|
-
const errors = validators ? controlIsValid({ state, validators }) : [];
|
|
2091
|
-
const valid = errors.length === 0;
|
|
2092
|
-
function focus() {
|
|
2093
|
-
setControlState((state) => ({ ...state, focused: true }));
|
|
2094
|
-
}
|
|
2095
|
-
function blur() {
|
|
2096
|
-
setControlState((state) => ({ ...state, focused: false, touched: true }));
|
|
2097
|
-
}
|
|
2098
|
-
function disable() {
|
|
2099
|
-
setControlState((state) => ({ ...state, disabled: true }));
|
|
2100
|
-
}
|
|
2101
|
-
function enable() {
|
|
2102
|
-
setControlState((state) => ({ ...state, disabled: false }));
|
|
2103
|
-
}
|
|
2104
|
-
function touch() {
|
|
2105
|
-
setControlState((state) => ({ ...state, touched: true }));
|
|
2106
|
-
}
|
|
2107
|
-
function setState(state) {
|
|
2108
|
-
setControlState((currentState) => ({
|
|
2109
|
-
...currentState,
|
|
2110
|
-
dirty: true,
|
|
2111
|
-
state
|
|
2112
|
-
}));
|
|
2113
|
-
}
|
|
2114
|
-
function setValidators(validators) {
|
|
2115
|
-
setControlState((state) => ({ ...state, validators }));
|
|
2116
|
-
}
|
|
2117
|
-
function reset() {
|
|
2118
|
-
setControlState((currentState) => ({
|
|
2119
|
-
...currentState,
|
|
2120
|
-
dirty: false,
|
|
2121
|
-
state: initialState.current,
|
|
2122
|
-
touched: false
|
|
2123
|
-
}));
|
|
2124
|
-
}
|
|
2125
|
-
return {
|
|
2126
|
-
...controlState,
|
|
2127
|
-
blur,
|
|
2128
|
-
disable,
|
|
2129
|
-
elementRef,
|
|
2130
|
-
enable,
|
|
2131
|
-
enabled: !controlState.disabled,
|
|
2132
|
-
error: errors[0],
|
|
2133
|
-
errors,
|
|
2134
|
-
focus,
|
|
2135
|
-
invalid: !valid,
|
|
2136
|
-
pristine: !controlState.dirty,
|
|
2137
|
-
reset,
|
|
2138
|
-
setState,
|
|
2139
|
-
setValidators,
|
|
2140
|
-
touch,
|
|
2141
|
-
unfocused: !controlState.focused,
|
|
2142
|
-
untouched: !controlState.touched,
|
|
2143
|
-
valid,
|
|
2144
|
-
wrong: controlState.touched && !valid
|
|
2145
|
-
};
|
|
2146
|
-
}
|
|
2147
|
-
function useReactControl(options, validators) {
|
|
2148
|
-
return useControl(options, validators);
|
|
2149
|
-
}
|
|
2150
|
-
|
|
2151
|
-
const FORMAT_DESCRIPTION = '{dw}, {mx} {dd} de {aa}';
|
|
2331
|
+
return ReactDOM.createPortal(jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-modal', { visible }), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-modal__component", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-modal__backdrop" })] }), document.body);
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
const FORMAT_TITLE = '{dw}, {mx} {dd} de {aa}';
|
|
2152
2335
|
function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
|
|
2153
2336
|
const today = new Date(); // Initial current date in component
|
|
2154
|
-
const dateInitial = formControl?.
|
|
2337
|
+
const dateInitial = formControl?.value || date || today;
|
|
2155
2338
|
const yearControl = useReactControl(dateInitial.getFullYear());
|
|
2156
2339
|
const dayControl = useReactControl(dateInitial.getDate());
|
|
2157
2340
|
const monthControl = useReactControl(dateInitial.getMonth());
|
|
@@ -2159,28 +2342,28 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
2159
2342
|
const [visibility, setVisibility] = useState('DAY');
|
|
2160
2343
|
useEffect(() => {
|
|
2161
2344
|
const dateCheck = checkDateRange({
|
|
2162
|
-
date: formControl?.
|
|
2345
|
+
date: formControl?.value || date || today,
|
|
2163
2346
|
minDate,
|
|
2164
2347
|
maxDate
|
|
2165
2348
|
});
|
|
2166
2349
|
setValue(dateCheck);
|
|
2167
|
-
formControl?.
|
|
2350
|
+
formControl?.setValue(dateCheck);
|
|
2168
2351
|
}, []);
|
|
2169
2352
|
useEffect(() => {
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
}, [yearControl.
|
|
2353
|
+
if (itIsDefined(yearControl.value)) {
|
|
2354
|
+
setValue(assignYearInDate(value, yearControl.value));
|
|
2355
|
+
}
|
|
2356
|
+
}, [yearControl.value]);
|
|
2174
2357
|
useEffect(() => {
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
}, [monthControl.
|
|
2358
|
+
if (itIsDefined(monthControl.value)) {
|
|
2359
|
+
setValue(assignMonthInDate(value, monthControl.value));
|
|
2360
|
+
}
|
|
2361
|
+
}, [monthControl.value]);
|
|
2179
2362
|
useEffect(() => {
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
}, [dayControl.
|
|
2363
|
+
if (itIsDefined(dayControl.value)) {
|
|
2364
|
+
setValue(assignDayInDate(value, dayControl.value));
|
|
2365
|
+
}
|
|
2366
|
+
}, [dayControl.value]);
|
|
2184
2367
|
function onVisibilityDay() {
|
|
2185
2368
|
setVisibility('DAY');
|
|
2186
2369
|
}
|
|
@@ -2196,54 +2379,53 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
2196
2379
|
}
|
|
2197
2380
|
}
|
|
2198
2381
|
function onToday() {
|
|
2199
|
-
yearControl.
|
|
2200
|
-
dayControl.
|
|
2201
|
-
monthControl.
|
|
2202
|
-
formControl?.
|
|
2382
|
+
yearControl.setValue(today.getFullYear());
|
|
2383
|
+
dayControl.setValue(today.getDate());
|
|
2384
|
+
monthControl.setValue(today.getMonth());
|
|
2385
|
+
formControl?.setValue(today);
|
|
2203
2386
|
if (onListener) {
|
|
2204
2387
|
onListener({ type: PickerListenerType.Now, value: today });
|
|
2205
2388
|
}
|
|
2206
2389
|
}
|
|
2207
2390
|
function onSelect() {
|
|
2208
|
-
formControl?.
|
|
2391
|
+
formControl?.setValue(value);
|
|
2209
2392
|
if (onListener) {
|
|
2210
2393
|
onListener({ type: PickerListenerType.Select, value });
|
|
2211
2394
|
}
|
|
2212
2395
|
}
|
|
2213
|
-
return (jsxs("div", { className: "rls-picker-date", "rls-theme": rlsTheme, children: [jsxs("div", { className: "rls-picker-date__header", children: [jsx("div", { className: "rls-picker-date__title rls-picker-date__title--description", children: jsx("span", { onClick: onVisibilityDay, children: dateFormatTemplate(dateInitial,
|
|
2396
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date__title rls-picker-date__title--description", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: dateFormatTemplate(dateInitial, FORMAT_TITLE) }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__title rls-picker-date__title--year", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityYear, children: yearControl.value }) }), jsxRuntimeExports.jsx(RlsPickerMonthTitle, { monthControl: monthControl, yearControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: 'month', onClick: onVisibilityMonth })] }), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-picker-date__component', {
|
|
2214
2397
|
day: visibility === 'DAY',
|
|
2215
2398
|
month: visibility === 'MONTH',
|
|
2216
2399
|
year: visibility === 'YEAR'
|
|
2217
|
-
}), children: [jsx(RlsPickerDay, { formControl: dayControl, date: dateInitial, month: monthControl.
|
|
2400
|
+
}), children: [jsxRuntimeExports.jsx(RlsPickerDay, { formControl: dayControl, date: dateInitial, month: monthControl.value, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsPickerMonth, { formControl: monthControl, date: dateInitial, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntimeExports.jsx(RlsPickerYear, { formControl: yearControl, date: dateInitial, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), !automatic && (jsxRuntimeExports.jsx("div", { className: "rls-picker-date__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--today", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onToday, disabled: dateOutRange({ date: today, maxDate, minDate }), children: reactI18n('dateActionToday') }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) }))] }));
|
|
2218
2401
|
}
|
|
2219
2402
|
|
|
2220
|
-
|
|
2403
|
+
const FORMAT_DATE = '{dd}/{mx}/{aa}';
|
|
2404
|
+
function RlsFieldDate({ children, date, disabled, formControl, format, maxDate, minDate, onValue, placeholder, rlsTheme }) {
|
|
2221
2405
|
const today = new Date(); // Initial current date in component
|
|
2222
2406
|
const [value, setValue] = useState();
|
|
2223
2407
|
const [modalIsVisible, setModalIsVisible] = useState(false);
|
|
2224
2408
|
useEffect(() => {
|
|
2225
2409
|
const dateCheck = checkDateRange({
|
|
2226
|
-
date: formControl?.
|
|
2410
|
+
date: formControl?.value || date || today,
|
|
2227
2411
|
minDate,
|
|
2228
2412
|
maxDate
|
|
2229
2413
|
});
|
|
2230
2414
|
setValue(dateCheck);
|
|
2231
|
-
formControl?.
|
|
2415
|
+
formControl?.setValue(dateCheck);
|
|
2232
2416
|
}, []);
|
|
2233
|
-
function
|
|
2234
|
-
setModalIsVisible(true);
|
|
2235
|
-
}
|
|
2236
|
-
function onChange(value, ignoreControl = false) {
|
|
2237
|
-
if (!ignoreControl) {
|
|
2238
|
-
formControl?.setState(value);
|
|
2239
|
-
}
|
|
2417
|
+
function onChange(value) {
|
|
2240
2418
|
setValue(value);
|
|
2241
2419
|
if (onValue) {
|
|
2242
2420
|
onValue(value);
|
|
2243
2421
|
}
|
|
2244
2422
|
}
|
|
2245
|
-
function
|
|
2423
|
+
function onClickInput() {
|
|
2424
|
+
setModalIsVisible(true);
|
|
2425
|
+
}
|
|
2426
|
+
function onClickAction() {
|
|
2246
2427
|
if (value) {
|
|
2428
|
+
formControl?.setValue(undefined);
|
|
2247
2429
|
formControl?.touch();
|
|
2248
2430
|
onChange(undefined);
|
|
2249
2431
|
}
|
|
@@ -2251,9 +2433,12 @@ function RlsFieldDate({ children, date, disabled, formControl, maxDate, minDate,
|
|
|
2251
2433
|
setModalIsVisible(true);
|
|
2252
2434
|
}
|
|
2253
2435
|
}
|
|
2254
|
-
|
|
2436
|
+
const valueInput = value
|
|
2437
|
+
? dateFormatTemplate(value, format || FORMAT_DATE)
|
|
2438
|
+
: '';
|
|
2439
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', { disabled }), children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-date__control", type: "text", value: valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntimeExports.jsx("button", { className: "rls-field-date__action", onClick: onClickAction, disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }), jsxRuntimeExports.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDate, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value, type }) => {
|
|
2255
2440
|
if (type !== PickerListenerType.Cancel) {
|
|
2256
|
-
onChange(value
|
|
2441
|
+
onChange(value);
|
|
2257
2442
|
}
|
|
2258
2443
|
formControl?.touch();
|
|
2259
2444
|
setModalIsVisible(false);
|
|
@@ -2262,7 +2447,7 @@ function RlsFieldDate({ children, date, disabled, formControl, maxDate, minDate,
|
|
|
2262
2447
|
|
|
2263
2448
|
function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
|
|
2264
2449
|
const dateInitial = normalizeMinTime(datePicker || new Date());
|
|
2265
|
-
const rangeInitial = formControl?.
|
|
2450
|
+
const rangeInitial = formControl?.value || DateRange.now();
|
|
2266
2451
|
const yearControl = useReactControl(dateInitial.getFullYear());
|
|
2267
2452
|
const monthControl = useReactControl(dateInitial.getMonth());
|
|
2268
2453
|
const dayControl = useReactControl(rangeInitial);
|
|
@@ -2271,24 +2456,24 @@ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl
|
|
|
2271
2456
|
const [visibility, setVisibility] = useState('DAY');
|
|
2272
2457
|
useEffect(() => {
|
|
2273
2458
|
setDate((prevValue) => {
|
|
2274
|
-
return typeof yearControl.
|
|
2275
|
-
? assignYearInDate(prevValue, yearControl.
|
|
2459
|
+
return typeof yearControl.value === 'number'
|
|
2460
|
+
? assignYearInDate(prevValue, yearControl.value)
|
|
2276
2461
|
: prevValue;
|
|
2277
2462
|
});
|
|
2278
|
-
}, [yearControl.
|
|
2463
|
+
}, [yearControl.value]);
|
|
2279
2464
|
useEffect(() => {
|
|
2280
2465
|
setDate((prevValue) => {
|
|
2281
|
-
return typeof monthControl.
|
|
2282
|
-
? assignMonthInDate(prevValue, monthControl.
|
|
2466
|
+
return typeof monthControl.value === 'number'
|
|
2467
|
+
? assignMonthInDate(prevValue, monthControl.value)
|
|
2283
2468
|
: prevValue;
|
|
2284
2469
|
});
|
|
2285
|
-
}, [monthControl.
|
|
2470
|
+
}, [monthControl.value]);
|
|
2286
2471
|
useEffect(() => {
|
|
2287
|
-
if (dayControl.
|
|
2288
|
-
setValue(dayControl.
|
|
2472
|
+
if (dayControl.value) {
|
|
2473
|
+
setValue(dayControl.value);
|
|
2289
2474
|
}
|
|
2290
2475
|
setVisibility('DAY');
|
|
2291
|
-
}, [dayControl.
|
|
2476
|
+
}, [dayControl.value]);
|
|
2292
2477
|
function onVisibilityDay() {
|
|
2293
2478
|
setVisibility('DAY');
|
|
2294
2479
|
}
|
|
@@ -2304,22 +2489,22 @@ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl
|
|
|
2304
2489
|
}
|
|
2305
2490
|
}
|
|
2306
2491
|
function onSelect() {
|
|
2307
|
-
formControl?.
|
|
2492
|
+
formControl?.setValue(value);
|
|
2308
2493
|
if (onListener) {
|
|
2309
2494
|
onListener({ type: PickerListenerType.Select, value });
|
|
2310
2495
|
}
|
|
2311
2496
|
}
|
|
2312
|
-
return (jsxs("div", { className: "rls-picker-date-range", "rls-theme": rlsTheme, children: [jsxs("div", { className: "rls-picker-date-range__header", children: [jsx("div", { className: "rls-picker-date-range__title rls-picker-date-range__title--description", children: jsx("span", { onClick: onVisibilityDay, children: rangeFormatTemplate(value) }) }), jsx("div", { className: "rls-picker-date-range__title rls-picker-date-range__title--year", children: jsx("span", { onClick: onVisibilityYear, children: yearControl.
|
|
2497
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__title rls-picker-date-range__title--description", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: rangeFormatTemplate(value) }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__title rls-picker-date-range__title--year", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityYear, children: yearControl.value }) }), jsxRuntimeExports.jsx(RlsPickerMonthTitle, { monthControl: monthControl, yearControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: visibility === 'MONTH' ? 'year' : 'month', onClick: onVisibilityMonth })] }), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-picker-date-range__component', {
|
|
2313
2498
|
day: visibility === 'DAY',
|
|
2314
2499
|
month: visibility === 'MONTH',
|
|
2315
2500
|
year: visibility === 'YEAR'
|
|
2316
|
-
}), children: [jsx(RlsPickerDayRange, { formControl: dayControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsx(RlsPickerMonth, { formControl: monthControl, year: yearControl.
|
|
2501
|
+
}), children: [jsxRuntimeExports.jsx(RlsPickerDayRange, { formControl: dayControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsPickerMonth, { formControl: monthControl, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntimeExports.jsx(RlsPickerYear, { formControl: yearControl, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-picker-date-range__footer', {
|
|
2317
2502
|
automatic
|
|
2318
|
-
}), children: jsxs("div", { className: "rls-picker-date-range__actions", children: [jsx("div", { className: "rls-picker-date-range__actions--cancel", children: jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsx("div", { className: "rls-picker-date-range__actions--ok", children: jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
|
|
2503
|
+
}), children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
|
|
2319
2504
|
}
|
|
2320
2505
|
|
|
2321
2506
|
function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
|
|
2322
|
-
const currentRange = formControl?.
|
|
2507
|
+
const currentRange = formControl?.value || DateRange.now();
|
|
2323
2508
|
const currentDate = datePicker || new Date();
|
|
2324
2509
|
const [value, setValue] = useState(currentRange);
|
|
2325
2510
|
const [modalIsVisible, setModalIsVisible] = useState(false);
|
|
@@ -2328,14 +2513,14 @@ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl,
|
|
|
2328
2513
|
}
|
|
2329
2514
|
function onClickAction() {
|
|
2330
2515
|
if (value) {
|
|
2331
|
-
formControl?.
|
|
2516
|
+
formControl?.setValue(undefined);
|
|
2332
2517
|
setValue(undefined);
|
|
2333
2518
|
}
|
|
2334
2519
|
else {
|
|
2335
2520
|
setModalIsVisible(true);
|
|
2336
2521
|
}
|
|
2337
2522
|
}
|
|
2338
|
-
return (jsxs("div", { className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxs("div", { className: renderClassStatus('rls-field-box', { disabled }), children: [children && jsx("label", { className: "rls-field-box__label", children: children }), jsx("div", { className: "rls-field-box__component", children: jsxs("div", { className: "rls-field-box__body", children: [jsx("input", { className: "rls-field-date-range__control", type: "text", value: value ? rangeFormatTemplate(value) : '', readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsx("button", { className: "rls-field-date-range__action", onClick: onClickAction, disabled: disabled, children: jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }), jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsx(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
|
|
2523
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', { disabled }), children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-date-range__control", type: "text", value: value ? rangeFormatTemplate(value) : '', readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntimeExports.jsx("button", { className: "rls-field-date-range__action", onClick: onClickAction, disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }), jsxRuntimeExports.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
|
|
2339
2524
|
if (value) {
|
|
2340
2525
|
setValue(value);
|
|
2341
2526
|
}
|
|
@@ -2358,14 +2543,14 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2358
2543
|
changeInternal.current = false;
|
|
2359
2544
|
return;
|
|
2360
2545
|
}
|
|
2361
|
-
refresh(collection, formControl?.
|
|
2362
|
-
}, [formControl?.
|
|
2546
|
+
refresh(collection, formControl?.value);
|
|
2547
|
+
}, [formControl?.value]);
|
|
2363
2548
|
useEffect(() => {
|
|
2364
2549
|
if (!initializedCollection.current || !initializedState.current) {
|
|
2365
2550
|
initializedCollection.current = true;
|
|
2366
2551
|
return;
|
|
2367
2552
|
}
|
|
2368
|
-
refresh(collection, formControl?.
|
|
2553
|
+
refresh(collection, formControl?.value);
|
|
2369
2554
|
}, [collection]);
|
|
2370
2555
|
function refresh(collection, state) {
|
|
2371
2556
|
if (!state) {
|
|
@@ -2381,7 +2566,7 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2381
2566
|
function setFormState(value) {
|
|
2382
2567
|
if (formControl) {
|
|
2383
2568
|
changeInternal.current = true;
|
|
2384
|
-
formControl.
|
|
2569
|
+
formControl.setValue(value);
|
|
2385
2570
|
}
|
|
2386
2571
|
}
|
|
2387
2572
|
function onFocusInput() {
|
|
@@ -2454,28 +2639,28 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2454
2639
|
};
|
|
2455
2640
|
}
|
|
2456
2641
|
|
|
2457
|
-
function RlsFieldSelectTemplate({ suggestions, children, disabled, formControl,
|
|
2458
|
-
const
|
|
2642
|
+
function RlsFieldSelectTemplate({ render, suggestions, children, disabled, formControl, onSelect, onValue, placeholder, rlsTheme }) {
|
|
2643
|
+
const fieldSelect = useFieldSelect({
|
|
2459
2644
|
suggestions,
|
|
2460
2645
|
disabled,
|
|
2461
2646
|
formControl,
|
|
2462
2647
|
onSelect,
|
|
2463
2648
|
onValue
|
|
2464
2649
|
});
|
|
2465
|
-
return (jsxs("div", { ref: listControl.
|
|
2466
|
-
visible: listControl.visible
|
|
2467
|
-
}), disabled: disabled, onClick: onClickAction, children: jsx(RlsIcon, { value: "arrow-ios-down" }) })] }) }), jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }), jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
|
|
2468
|
-
visible: listControl.visible,
|
|
2469
|
-
hide: !listControl.visible,
|
|
2470
|
-
higher: listControl.higher
|
|
2471
|
-
}), children: [jsx("div", { className: "rls-field-list__suggestions__body", children: jsxs("ul", { ref: listControl.listRef, className: "rls-field-list__ul", children: [suggestions.map((element, index) => (jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: onClickElement(element), onKeyDown: onKeydownElement(element), children: render(element) }, index))), !suggestions.length && (jsx("li", { className: "rls-field-list__empty", children: jsxs("div", { className: "rls-field-list__empty__description", children: [jsx("label", { className: "rls-label-bold truncate", children: reactI18n('listEmptyTitle') }), jsx("p", { className: "rls-caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsx("div", { className: "rls-field-list__backdrop", onClick: onClickBackdrop })] })] }));
|
|
2650
|
+
return (jsxRuntimeExports.jsxs("div", { ref: fieldSelect.listControl.contentRef, className: renderClassStatus('rls-field-box', { focused: fieldSelect.listControl.focused, disabled }, 'rls-field-list rls-field-select'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { ref: fieldSelect.listControl.inputRef, className: "rls-field-list__control", readOnly: true, disabled: disabled, placeholder: placeholder, value: fieldSelect.listControl.value, onFocus: fieldSelect.onFocusInput, onBlur: fieldSelect.onBlurInput, onClick: fieldSelect.onClickInput, onKeyDown: fieldSelect.onKeydownInput }), jsxRuntimeExports.jsx("button", { className: renderClassStatus('rls-field-list__action', {
|
|
2651
|
+
visible: fieldSelect.listControl.visible
|
|
2652
|
+
}), disabled: disabled, onClick: fieldSelect.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-down" }) })] }) }), jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
|
|
2653
|
+
visible: fieldSelect.listControl.visible,
|
|
2654
|
+
hide: !fieldSelect.listControl.visible,
|
|
2655
|
+
higher: fieldSelect.listControl.higher
|
|
2656
|
+
}), children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: fieldSelect.listControl.listRef, className: "rls-field-list__ul", children: [suggestions.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: fieldSelect.onClickElement(element), onKeyDown: fieldSelect.onKeydownElement(element), children: render(element) }, index))), !suggestions.length && (jsxRuntimeExports.jsx("li", { className: "rls-field-list__empty", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-list__empty__description", children: [jsxRuntimeExports.jsx("label", { className: "rls-label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntimeExports.jsx("p", { className: "rls-caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: fieldSelect.onClickBackdrop })] })] }));
|
|
2472
2657
|
}
|
|
2473
2658
|
function RlsFieldSelect(props) {
|
|
2474
|
-
return (jsx(RlsFieldSelectTemplate, { ...props, render: (element) => (jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
2659
|
+
return (jsxRuntimeExports.jsx(RlsFieldSelectTemplate, { ...props, render: (element) => (jsxRuntimeExports.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
2475
2660
|
}
|
|
2476
2661
|
|
|
2477
2662
|
function RlsFormNavigation({ children, visible, rlsTheme }) {
|
|
2478
|
-
return (jsx("div", { className: renderClassStatus('rls-form-navigation', { visible }), "rls-theme": rlsTheme, children: jsx("div", { className: "rls-form-navigation__body", children: children }) }));
|
|
2663
|
+
return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-form-navigation', { visible }), "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-form-navigation__body", children: children }) }));
|
|
2479
2664
|
}
|
|
2480
2665
|
|
|
2481
2666
|
const DURATION_ANIMATION = 240;
|
|
@@ -2494,14 +2679,14 @@ function calculateDuration({ length }) {
|
|
|
2494
2679
|
return duration + DURATION_RESET;
|
|
2495
2680
|
}
|
|
2496
2681
|
function RlsSnackbar({ content, icon, title, visible, rlsTheme }) {
|
|
2497
|
-
return (jsxs("div", { className: renderClassStatus('rls-snackbar', { visible }), "rls-theme": rlsTheme, children: [icon && (jsx("div", { className: "rls-snackbar__avatar", children: jsx(RlsIcon, { value: icon }) })), jsxs("div", { className: "rls-snackbar__component", children: [title && jsx("div", { className: "rls-snackbar__title", children: title }), jsx("div", { className: "rls-snackbar__content", children: content })] })] }));
|
|
2682
|
+
return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-snackbar', { visible }), "rls-theme": rlsTheme, children: [icon && (jsxRuntimeExports.jsx("div", { className: "rls-snackbar__avatar", children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) })), jsxRuntimeExports.jsxs("div", { className: "rls-snackbar__component", children: [title && jsxRuntimeExports.jsx("div", { className: "rls-snackbar__title", children: title }), jsxRuntimeExports.jsx("div", { className: "rls-snackbar__content", children: content })] })] }));
|
|
2498
2683
|
}
|
|
2499
2684
|
function useSnackbarService() {
|
|
2500
2685
|
const [config, setConfig] = useState({});
|
|
2501
2686
|
const [duration, setDuration] = useState(4000);
|
|
2502
2687
|
const [timeoutId, setTimeoutId] = useState();
|
|
2503
2688
|
const [visible, setVisible] = useState(false);
|
|
2504
|
-
const rlsSnackbar = jsx(RlsSnackbar, { ...config, visible: visible });
|
|
2689
|
+
const rlsSnackbar = jsxRuntimeExports.jsx(RlsSnackbar, { ...config, visible: visible });
|
|
2505
2690
|
useEffect(() => {
|
|
2506
2691
|
if (visible) {
|
|
2507
2692
|
const timeoutId = setTimeout(() => {
|
|
@@ -2536,7 +2721,7 @@ const RlsContext = createContext({
|
|
|
2536
2721
|
function RlsApplication({ children }) {
|
|
2537
2722
|
const { RlsConfirmation, confirmation } = useConfirmationService();
|
|
2538
2723
|
const { RlsSnackbar, snackbar } = useSnackbarService();
|
|
2539
|
-
return (jsxs(RlsContext.Provider, { value: { confirmation, snackbar }, children: [jsx("div", { className: "rls-app__body", children: children }), RlsSnackbar, RlsConfirmation] }));
|
|
2724
|
+
return (jsxRuntimeExports.jsxs(RlsContext.Provider, { value: { confirmation, snackbar }, children: [jsxRuntimeExports.jsx("div", { className: "rls-app__body", children: children }), RlsSnackbar, RlsConfirmation] }));
|
|
2540
2725
|
}
|
|
2541
2726
|
|
|
2542
2727
|
export { ConfirmationResult, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableHeader, RlsDatatableInfo, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldDate, RlsFieldDateRange, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsPagination, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerMonthTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsTabularText, RlsToolbar, rangeFormatTemplate, renderClassStatus, useConfirmationService, useDatatable, useListControl, useSnackbarService };
|