@rolster/react-components 1.5.7 → 18.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/dist/cjs/assets/{lib.cjs-c052832f.css → index-Fy0sGm5F.css} +159 -106
  2. package/dist/cjs/index.js +2036 -0
  3. package/dist/cjs/index.js.map +1 -0
  4. package/dist/es/assets/{lib-c052832f.css → index-Fy0sGm5F.css} +159 -106
  5. package/dist/es/index.js +1970 -0
  6. package/dist/es/index.js.map +1 -0
  7. package/dist/esm/components/atoms/Amount/Amount.css +3 -2
  8. package/dist/esm/components/atoms/Amount/Amount.d.ts +3 -1
  9. package/dist/esm/components/atoms/Amount/Amount.js +2 -2
  10. package/dist/esm/components/atoms/Amount/Amount.js.map +1 -1
  11. package/dist/esm/components/atoms/Button/Button.css +1 -1
  12. package/dist/esm/components/atoms/CheckBox/CheckBox.d.ts +8 -1
  13. package/dist/esm/components/atoms/CheckBox/CheckBox.js +7 -2
  14. package/dist/esm/components/atoms/CheckBox/CheckBox.js.map +1 -1
  15. package/dist/esm/components/atoms/Icon/Icon.css +1 -1
  16. package/dist/esm/components/atoms/Input/Input.css +1 -1
  17. package/dist/esm/components/atoms/Input/Input.d.ts +3 -3
  18. package/dist/esm/components/atoms/Input/Input.js +12 -10
  19. package/dist/esm/components/atoms/Input/Input.js.map +1 -1
  20. package/dist/esm/components/atoms/InputMoney/InputMoney.d.ts +3 -3
  21. package/dist/esm/components/atoms/InputMoney/InputMoney.js +5 -10
  22. package/dist/esm/components/atoms/InputMoney/InputMoney.js.map +1 -1
  23. package/dist/esm/components/atoms/InputNumber/InputNumber.d.ts +3 -3
  24. package/dist/esm/components/atoms/InputNumber/InputNumber.js +5 -10
  25. package/dist/esm/components/atoms/InputNumber/InputNumber.js.map +1 -1
  26. package/dist/esm/components/atoms/InputPassword/InputPassword.d.ts +1 -1
  27. package/dist/esm/components/atoms/InputPassword/InputPassword.js +9 -7
  28. package/dist/esm/components/atoms/InputPassword/InputPassword.js.map +1 -1
  29. package/dist/esm/components/atoms/InputText/InputText.d.ts +3 -3
  30. package/dist/esm/components/atoms/InputText/InputText.js +5 -10
  31. package/dist/esm/components/atoms/InputText/InputText.js.map +1 -1
  32. package/dist/esm/components/atoms/Label/Label.css +3 -0
  33. package/dist/esm/components/atoms/Label/Label.d.ts +2 -0
  34. package/dist/esm/components/atoms/Label/Label.js +5 -0
  35. package/dist/esm/components/atoms/Label/Label.js.map +1 -0
  36. package/dist/esm/components/atoms/MessageIcon/MessageIcon.css +12 -0
  37. package/dist/esm/components/atoms/MessageIcon/MessageIcon.d.ts +7 -0
  38. package/dist/esm/components/atoms/MessageIcon/MessageIcon.js +7 -0
  39. package/dist/esm/components/atoms/MessageIcon/MessageIcon.js.map +1 -0
  40. package/dist/esm/components/atoms/RadioButton/RadioButton.d.ts +2 -1
  41. package/dist/esm/components/atoms/RadioButton/RadioButton.js +2 -2
  42. package/dist/esm/components/atoms/RadioButton/RadioButton.js.map +1 -1
  43. package/dist/esm/components/atoms/SearchInput/SearchInput.d.ts +2 -2
  44. package/dist/esm/components/atoms/Switch/Switch.css +40 -21
  45. package/dist/esm/components/atoms/Switch/Switch.d.ts +7 -1
  46. package/dist/esm/components/atoms/Switch/Switch.js +8 -3
  47. package/dist/esm/components/atoms/Switch/Switch.js.map +1 -1
  48. package/dist/esm/components/atoms/index.d.ts +2 -0
  49. package/dist/esm/components/atoms/index.js +2 -0
  50. package/dist/esm/components/atoms/index.js.map +1 -1
  51. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js.map +1 -1
  52. package/dist/esm/components/molecules/CheckBoxLabel/CheckBoxLabel.css +1 -5
  53. package/dist/esm/components/molecules/CheckBoxLabel/CheckBoxLabel.d.ts +1 -1
  54. package/dist/esm/components/molecules/CheckBoxLabel/CheckBoxLabel.js.map +1 -1
  55. package/dist/esm/components/molecules/DayPicker/DayPicker.d.ts +1 -1
  56. package/dist/esm/components/molecules/DayPicker/DayPicker.js +1 -1
  57. package/dist/esm/components/molecules/DayPicker/DayPicker.js.map +1 -1
  58. package/dist/esm/components/molecules/DayRangePicker/DayRangePicker.d.ts +1 -1
  59. package/dist/esm/components/molecules/DayRangePicker/DayRangePicker.js +1 -1
  60. package/dist/esm/components/molecules/DayRangePicker/DayRangePicker.js.map +1 -1
  61. package/dist/esm/components/molecules/MoneyField/MoneyField.d.ts +4 -2
  62. package/dist/esm/components/molecules/MoneyField/MoneyField.js +7 -8
  63. package/dist/esm/components/molecules/MoneyField/MoneyField.js.map +1 -1
  64. package/dist/esm/components/molecules/MonthPicker/MonthPicker.d.ts +1 -1
  65. package/dist/esm/components/molecules/MonthPicker/MonthPicker.js.map +1 -1
  66. package/dist/esm/components/molecules/MonthTitlePicker/MonthTitlePicker.d.ts +1 -1
  67. package/dist/esm/components/molecules/MonthTitlePicker/MonthTitlePicker.js +1 -1
  68. package/dist/esm/components/molecules/MonthTitlePicker/MonthTitlePicker.js.map +1 -1
  69. package/dist/esm/components/molecules/NumberField/NumberField.d.ts +4 -2
  70. package/dist/esm/components/molecules/NumberField/NumberField.js +7 -8
  71. package/dist/esm/components/molecules/NumberField/NumberField.js.map +1 -1
  72. package/dist/esm/components/molecules/Pagination/Pagination.js.map +1 -1
  73. package/dist/esm/components/molecules/PasswordField/PasswordField.d.ts +1 -1
  74. package/dist/esm/components/molecules/PasswordField/PasswordField.js +6 -7
  75. package/dist/esm/components/molecules/PasswordField/PasswordField.js.map +1 -1
  76. package/dist/esm/components/molecules/RadioButtonLabel/RadioButtonLabel.d.ts +1 -1
  77. package/dist/esm/components/molecules/RadioButtonLabel/RadioButtonLabel.js.map +1 -1
  78. package/dist/esm/components/molecules/SwitchLabel/SwitchLabel.css +2 -5
  79. package/dist/esm/components/molecules/SwitchLabel/SwitchLabel.d.ts +1 -1
  80. package/dist/esm/components/molecules/SwitchLabel/SwitchLabel.js.map +1 -1
  81. package/dist/esm/components/molecules/TextField/TextField.d.ts +4 -2
  82. package/dist/esm/components/molecules/TextField/TextField.js +7 -8
  83. package/dist/esm/components/molecules/TextField/TextField.js.map +1 -1
  84. package/dist/esm/components/molecules/YearPicker/YearPicker.d.ts +2 -2
  85. package/dist/esm/components/molecules/YearPicker/YearPicker.js +2 -2
  86. package/dist/esm/components/molecules/YearPicker/YearPicker.js.map +1 -1
  87. package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.css +21 -19
  88. package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.d.ts +5 -3
  89. package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.js +32 -29
  90. package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.js.map +1 -1
  91. package/dist/esm/components/organisms/Card/Card.css +1 -1
  92. package/dist/esm/components/organisms/Confirmation/Confirmation.css +58 -34
  93. package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
  94. package/dist/esm/components/organisms/Datatable/Datatable.d.ts +2 -1
  95. package/dist/esm/components/organisms/Datatable/Datatable.js +3 -2
  96. package/dist/esm/components/organisms/Datatable/Datatable.js.map +1 -1
  97. package/dist/esm/components/organisms/DateField/DateField.css +3 -0
  98. package/dist/esm/components/organisms/DateField/DateField.d.ts +1 -1
  99. package/dist/esm/components/organisms/DateField/DateField.js +10 -3
  100. package/dist/esm/components/organisms/DateField/DateField.js.map +1 -1
  101. package/dist/esm/components/organisms/DatePicker/DatePicker.d.ts +1 -1
  102. package/dist/esm/components/organisms/DatePicker/DatePicker.js +2 -2
  103. package/dist/esm/components/organisms/DatePicker/DatePicker.js.map +1 -1
  104. package/dist/esm/components/organisms/DateRangeField/DateRangeField.d.ts +1 -1
  105. package/dist/esm/components/organisms/DateRangeField/DateRangeField.js.map +1 -1
  106. package/dist/esm/components/organisms/DateRangePicker/DateRangePicker.d.ts +1 -1
  107. package/dist/esm/components/organisms/DateRangePicker/DateRangePicker.js +1 -1
  108. package/dist/esm/components/organisms/DateRangePicker/DateRangePicker.js.map +1 -1
  109. package/dist/esm/components/organisms/SelectField/SelectField.d.ts +4 -3
  110. package/dist/esm/components/organisms/SelectField/SelectField.js +16 -9
  111. package/dist/esm/components/organisms/SelectField/SelectField.js.map +1 -1
  112. package/dist/esm/components/organisms/Snackbar/Snackbar.css +14 -16
  113. package/dist/esm/components/organisms/Snackbar/Snackbar.d.ts +1 -1
  114. package/dist/esm/components/organisms/Snackbar/Snackbar.js +1 -1
  115. package/dist/esm/components/organisms/Snackbar/Snackbar.js.map +1 -1
  116. package/dist/esm/hooks/index.d.ts +0 -2
  117. package/dist/esm/hooks/index.js +0 -2
  118. package/dist/esm/hooks/index.js.map +1 -1
  119. package/dist/esm/hooks/list-control.hook.d.ts +13 -7
  120. package/dist/esm/hooks/list-control.hook.js +16 -9
  121. package/dist/esm/hooks/list-control.hook.js.map +1 -1
  122. package/dist/esm/models.d.ts +4 -4
  123. package/dist/esm/models.js +6 -7
  124. package/dist/esm/models.js.map +1 -1
  125. package/dist/esm/utils/css.d.ts +1 -1
  126. package/dist/esm/utils/css.js +4 -1
  127. package/dist/esm/utils/css.js.map +1 -1
  128. package/dist/esm/utils/date-range-picker.js.map +1 -1
  129. package/dist/esm/utils/day-picker.js.map +1 -1
  130. package/dist/esm/utils/month-picker.js +1 -1
  131. package/dist/esm/utils/month-picker.js.map +1 -1
  132. package/dist/esm/utils/year-picker.js.map +1 -1
  133. package/package.json +25 -11
  134. package/dist/cjs/lib.cjs.js +0 -3366
  135. package/dist/cjs/lib.cjs.js.map +0 -1
  136. package/dist/es/lib.js +0 -3300
  137. package/dist/es/lib.js.map +0 -1
  138. package/dist/esm/hooks/form-control.hook.d.ts +0 -15
  139. package/dist/esm/hooks/form-control.hook.js +0 -77
  140. package/dist/esm/hooks/form-control.hook.js.map +0 -1
  141. package/dist/esm/hooks/form-group.hook.d.ts +0 -2
  142. package/dist/esm/hooks/form-group.hook.js +0 -22
  143. package/dist/esm/hooks/form-group.hook.js.map +0 -1
package/dist/es/lib.js DELETED
@@ -1,3300 +0,0 @@
1
- import require$$0, { useState, useEffect, useRef, createContext } from 'react';
2
- import { currencyFormat, PartialSealed } from '@rolster/helpers-advanced';
3
- import { daysFromMonth, weight, refactorDay, DAY_LABELS, normalizeMinTime, isBefore, formatDate, isAfter, timeDifference, isBetween, Month, MONTH_NAMES, refactorYear, refactorMonth } from '@rolster/helpers-date';
4
- import { hasPattern } from '@rolster/helpers-string';
5
- import ReactDOM from 'react-dom';
6
-
7
- var jsxRuntime = {exports: {}};
8
-
9
- var reactJsxRuntime_production_min = {};
10
-
11
- /**
12
- * @license React
13
- * react-jsx-runtime.production.min.js
14
- *
15
- * Copyright (c) Facebook, Inc. and its affiliates.
16
- *
17
- * This source code is licensed under the MIT license found in the
18
- * LICENSE file in the root directory of this source tree.
19
- */
20
-
21
- var hasRequiredReactJsxRuntime_production_min;
22
-
23
- function requireReactJsxRuntime_production_min () {
24
- if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
25
- hasRequiredReactJsxRuntime_production_min = 1;
26
- 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};
27
- 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;
28
- return reactJsxRuntime_production_min;
29
- }
30
-
31
- var reactJsxRuntime_development = {};
32
-
33
- /**
34
- * @license React
35
- * react-jsx-runtime.development.js
36
- *
37
- * Copyright (c) Facebook, Inc. and its affiliates.
38
- *
39
- * This source code is licensed under the MIT license found in the
40
- * LICENSE file in the root directory of this source tree.
41
- */
42
-
43
- var hasRequiredReactJsxRuntime_development;
44
-
45
- function requireReactJsxRuntime_development () {
46
- if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
47
- hasRequiredReactJsxRuntime_development = 1;
48
-
49
- if (process.env.NODE_ENV !== "production") {
50
- (function() {
51
-
52
- var React = require$$0;
53
-
54
- // ATTENTION
55
- // When adding new symbols to this file,
56
- // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
57
- // The Symbol used to tag the ReactElement-like types.
58
- var REACT_ELEMENT_TYPE = Symbol.for('react.element');
59
- var REACT_PORTAL_TYPE = Symbol.for('react.portal');
60
- var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
61
- var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
62
- var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
63
- var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
64
- var REACT_CONTEXT_TYPE = Symbol.for('react.context');
65
- var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
66
- var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
67
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
68
- var REACT_MEMO_TYPE = Symbol.for('react.memo');
69
- var REACT_LAZY_TYPE = Symbol.for('react.lazy');
70
- var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
71
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
72
- var FAUX_ITERATOR_SYMBOL = '@@iterator';
73
- function getIteratorFn(maybeIterable) {
74
- if (maybeIterable === null || typeof maybeIterable !== 'object') {
75
- return null;
76
- }
77
-
78
- var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
79
-
80
- if (typeof maybeIterator === 'function') {
81
- return maybeIterator;
82
- }
83
-
84
- return null;
85
- }
86
-
87
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
88
-
89
- function error(format) {
90
- {
91
- {
92
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
93
- args[_key2 - 1] = arguments[_key2];
94
- }
95
-
96
- printWarning('error', format, args);
97
- }
98
- }
99
- }
100
-
101
- function printWarning(level, format, args) {
102
- // When changing this logic, you might want to also
103
- // update consoleWithStackDev.www.js as well.
104
- {
105
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
106
- var stack = ReactDebugCurrentFrame.getStackAddendum();
107
-
108
- if (stack !== '') {
109
- format += '%s';
110
- args = args.concat([stack]);
111
- } // eslint-disable-next-line react-internal/safe-string-coercion
112
-
113
-
114
- var argsWithFormat = args.map(function (item) {
115
- return String(item);
116
- }); // Careful: RN currently depends on this prefix
117
-
118
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
119
- // breaks IE9: https://github.com/facebook/react/issues/13610
120
- // eslint-disable-next-line react-internal/no-production-logging
121
-
122
- Function.prototype.apply.call(console[level], console, argsWithFormat);
123
- }
124
- }
125
-
126
- // -----------------------------------------------------------------------------
127
-
128
- var enableScopeAPI = false; // Experimental Create Event Handle API.
129
- var enableCacheElement = false;
130
- var enableTransitionTracing = false; // No known bugs, but needs performance testing
131
-
132
- var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
133
- // stuff. Intended to enable React core members to more easily debug scheduling
134
- // issues in DEV builds.
135
-
136
- var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
137
-
138
- var REACT_MODULE_REFERENCE;
139
-
140
- {
141
- REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
142
- }
143
-
144
- function isValidElementType(type) {
145
- if (typeof type === 'string' || typeof type === 'function') {
146
- return true;
147
- } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
148
-
149
-
150
- 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 ) {
151
- return true;
152
- }
153
-
154
- if (typeof type === 'object' && type !== null) {
155
- 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
156
- // types supported by any Flight configuration anywhere since
157
- // we don't know which Flight build this will end up being used
158
- // with.
159
- type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
160
- return true;
161
- }
162
- }
163
-
164
- return false;
165
- }
166
-
167
- function getWrappedName(outerType, innerType, wrapperName) {
168
- var displayName = outerType.displayName;
169
-
170
- if (displayName) {
171
- return displayName;
172
- }
173
-
174
- var functionName = innerType.displayName || innerType.name || '';
175
- return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
176
- } // Keep in sync with react-reconciler/getComponentNameFromFiber
177
-
178
-
179
- function getContextName(type) {
180
- return type.displayName || 'Context';
181
- } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
182
-
183
-
184
- function getComponentNameFromType(type) {
185
- if (type == null) {
186
- // Host root, text node or just invalid type.
187
- return null;
188
- }
189
-
190
- {
191
- if (typeof type.tag === 'number') {
192
- error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
193
- }
194
- }
195
-
196
- if (typeof type === 'function') {
197
- return type.displayName || type.name || null;
198
- }
199
-
200
- if (typeof type === 'string') {
201
- return type;
202
- }
203
-
204
- switch (type) {
205
- case REACT_FRAGMENT_TYPE:
206
- return 'Fragment';
207
-
208
- case REACT_PORTAL_TYPE:
209
- return 'Portal';
210
-
211
- case REACT_PROFILER_TYPE:
212
- return 'Profiler';
213
-
214
- case REACT_STRICT_MODE_TYPE:
215
- return 'StrictMode';
216
-
217
- case REACT_SUSPENSE_TYPE:
218
- return 'Suspense';
219
-
220
- case REACT_SUSPENSE_LIST_TYPE:
221
- return 'SuspenseList';
222
-
223
- }
224
-
225
- if (typeof type === 'object') {
226
- switch (type.$$typeof) {
227
- case REACT_CONTEXT_TYPE:
228
- var context = type;
229
- return getContextName(context) + '.Consumer';
230
-
231
- case REACT_PROVIDER_TYPE:
232
- var provider = type;
233
- return getContextName(provider._context) + '.Provider';
234
-
235
- case REACT_FORWARD_REF_TYPE:
236
- return getWrappedName(type, type.render, 'ForwardRef');
237
-
238
- case REACT_MEMO_TYPE:
239
- var outerName = type.displayName || null;
240
-
241
- if (outerName !== null) {
242
- return outerName;
243
- }
244
-
245
- return getComponentNameFromType(type.type) || 'Memo';
246
-
247
- case REACT_LAZY_TYPE:
248
- {
249
- var lazyComponent = type;
250
- var payload = lazyComponent._payload;
251
- var init = lazyComponent._init;
252
-
253
- try {
254
- return getComponentNameFromType(init(payload));
255
- } catch (x) {
256
- return null;
257
- }
258
- }
259
-
260
- // eslint-disable-next-line no-fallthrough
261
- }
262
- }
263
-
264
- return null;
265
- }
266
-
267
- var assign = Object.assign;
268
-
269
- // Helpers to patch console.logs to avoid logging during side-effect free
270
- // replaying on render function. This currently only patches the object
271
- // lazily which won't cover if the log function was extracted eagerly.
272
- // We could also eagerly patch the method.
273
- var disabledDepth = 0;
274
- var prevLog;
275
- var prevInfo;
276
- var prevWarn;
277
- var prevError;
278
- var prevGroup;
279
- var prevGroupCollapsed;
280
- var prevGroupEnd;
281
-
282
- function disabledLog() {}
283
-
284
- disabledLog.__reactDisabledLog = true;
285
- function disableLogs() {
286
- {
287
- if (disabledDepth === 0) {
288
- /* eslint-disable react-internal/no-production-logging */
289
- prevLog = console.log;
290
- prevInfo = console.info;
291
- prevWarn = console.warn;
292
- prevError = console.error;
293
- prevGroup = console.group;
294
- prevGroupCollapsed = console.groupCollapsed;
295
- prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
296
-
297
- var props = {
298
- configurable: true,
299
- enumerable: true,
300
- value: disabledLog,
301
- writable: true
302
- }; // $FlowFixMe Flow thinks console is immutable.
303
-
304
- Object.defineProperties(console, {
305
- info: props,
306
- log: props,
307
- warn: props,
308
- error: props,
309
- group: props,
310
- groupCollapsed: props,
311
- groupEnd: props
312
- });
313
- /* eslint-enable react-internal/no-production-logging */
314
- }
315
-
316
- disabledDepth++;
317
- }
318
- }
319
- function reenableLogs() {
320
- {
321
- disabledDepth--;
322
-
323
- if (disabledDepth === 0) {
324
- /* eslint-disable react-internal/no-production-logging */
325
- var props = {
326
- configurable: true,
327
- enumerable: true,
328
- writable: true
329
- }; // $FlowFixMe Flow thinks console is immutable.
330
-
331
- Object.defineProperties(console, {
332
- log: assign({}, props, {
333
- value: prevLog
334
- }),
335
- info: assign({}, props, {
336
- value: prevInfo
337
- }),
338
- warn: assign({}, props, {
339
- value: prevWarn
340
- }),
341
- error: assign({}, props, {
342
- value: prevError
343
- }),
344
- group: assign({}, props, {
345
- value: prevGroup
346
- }),
347
- groupCollapsed: assign({}, props, {
348
- value: prevGroupCollapsed
349
- }),
350
- groupEnd: assign({}, props, {
351
- value: prevGroupEnd
352
- })
353
- });
354
- /* eslint-enable react-internal/no-production-logging */
355
- }
356
-
357
- if (disabledDepth < 0) {
358
- error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
359
- }
360
- }
361
- }
362
-
363
- var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
364
- var prefix;
365
- function describeBuiltInComponentFrame(name, source, ownerFn) {
366
- {
367
- if (prefix === undefined) {
368
- // Extract the VM specific prefix used by each line.
369
- try {
370
- throw Error();
371
- } catch (x) {
372
- var match = x.stack.trim().match(/\n( *(at )?)/);
373
- prefix = match && match[1] || '';
374
- }
375
- } // We use the prefix to ensure our stacks line up with native stack frames.
376
-
377
-
378
- return '\n' + prefix + name;
379
- }
380
- }
381
- var reentry = false;
382
- var componentFrameCache;
383
-
384
- {
385
- var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
386
- componentFrameCache = new PossiblyWeakMap();
387
- }
388
-
389
- function describeNativeComponentFrame(fn, construct) {
390
- // If something asked for a stack inside a fake render, it should get ignored.
391
- if ( !fn || reentry) {
392
- return '';
393
- }
394
-
395
- {
396
- var frame = componentFrameCache.get(fn);
397
-
398
- if (frame !== undefined) {
399
- return frame;
400
- }
401
- }
402
-
403
- var control;
404
- reentry = true;
405
- var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
406
-
407
- Error.prepareStackTrace = undefined;
408
- var previousDispatcher;
409
-
410
- {
411
- previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
412
- // for warnings.
413
-
414
- ReactCurrentDispatcher.current = null;
415
- disableLogs();
416
- }
417
-
418
- try {
419
- // This should throw.
420
- if (construct) {
421
- // Something should be setting the props in the constructor.
422
- var Fake = function () {
423
- throw Error();
424
- }; // $FlowFixMe
425
-
426
-
427
- Object.defineProperty(Fake.prototype, 'props', {
428
- set: function () {
429
- // We use a throwing setter instead of frozen or non-writable props
430
- // because that won't throw in a non-strict mode function.
431
- throw Error();
432
- }
433
- });
434
-
435
- if (typeof Reflect === 'object' && Reflect.construct) {
436
- // We construct a different control for this case to include any extra
437
- // frames added by the construct call.
438
- try {
439
- Reflect.construct(Fake, []);
440
- } catch (x) {
441
- control = x;
442
- }
443
-
444
- Reflect.construct(fn, [], Fake);
445
- } else {
446
- try {
447
- Fake.call();
448
- } catch (x) {
449
- control = x;
450
- }
451
-
452
- fn.call(Fake.prototype);
453
- }
454
- } else {
455
- try {
456
- throw Error();
457
- } catch (x) {
458
- control = x;
459
- }
460
-
461
- fn();
462
- }
463
- } catch (sample) {
464
- // This is inlined manually because closure doesn't do it for us.
465
- if (sample && control && typeof sample.stack === 'string') {
466
- // This extracts the first frame from the sample that isn't also in the control.
467
- // Skipping one frame that we assume is the frame that calls the two.
468
- var sampleLines = sample.stack.split('\n');
469
- var controlLines = control.stack.split('\n');
470
- var s = sampleLines.length - 1;
471
- var c = controlLines.length - 1;
472
-
473
- while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
474
- // We expect at least one stack frame to be shared.
475
- // Typically this will be the root most one. However, stack frames may be
476
- // cut off due to maximum stack limits. In this case, one maybe cut off
477
- // earlier than the other. We assume that the sample is longer or the same
478
- // and there for cut off earlier. So we should find the root most frame in
479
- // the sample somewhere in the control.
480
- c--;
481
- }
482
-
483
- for (; s >= 1 && c >= 0; s--, c--) {
484
- // Next we find the first one that isn't the same which should be the
485
- // frame that called our sample function and the control.
486
- if (sampleLines[s] !== controlLines[c]) {
487
- // In V8, the first line is describing the message but other VMs don't.
488
- // If we're about to return the first line, and the control is also on the same
489
- // line, that's a pretty good indicator that our sample threw at same line as
490
- // the control. I.e. before we entered the sample frame. So we ignore this result.
491
- // This can happen if you passed a class to function component, or non-function.
492
- if (s !== 1 || c !== 1) {
493
- do {
494
- s--;
495
- c--; // We may still have similar intermediate frames from the construct call.
496
- // The next one that isn't the same should be our match though.
497
-
498
- if (c < 0 || sampleLines[s] !== controlLines[c]) {
499
- // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
500
- var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
501
- // but we have a user-provided "displayName"
502
- // splice it in to make the stack more readable.
503
-
504
-
505
- if (fn.displayName && _frame.includes('<anonymous>')) {
506
- _frame = _frame.replace('<anonymous>', fn.displayName);
507
- }
508
-
509
- {
510
- if (typeof fn === 'function') {
511
- componentFrameCache.set(fn, _frame);
512
- }
513
- } // Return the line we found.
514
-
515
-
516
- return _frame;
517
- }
518
- } while (s >= 1 && c >= 0);
519
- }
520
-
521
- break;
522
- }
523
- }
524
- }
525
- } finally {
526
- reentry = false;
527
-
528
- {
529
- ReactCurrentDispatcher.current = previousDispatcher;
530
- reenableLogs();
531
- }
532
-
533
- Error.prepareStackTrace = previousPrepareStackTrace;
534
- } // Fallback to just using the name if we couldn't make it throw.
535
-
536
-
537
- var name = fn ? fn.displayName || fn.name : '';
538
- var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
539
-
540
- {
541
- if (typeof fn === 'function') {
542
- componentFrameCache.set(fn, syntheticFrame);
543
- }
544
- }
545
-
546
- return syntheticFrame;
547
- }
548
- function describeFunctionComponentFrame(fn, source, ownerFn) {
549
- {
550
- return describeNativeComponentFrame(fn, false);
551
- }
552
- }
553
-
554
- function shouldConstruct(Component) {
555
- var prototype = Component.prototype;
556
- return !!(prototype && prototype.isReactComponent);
557
- }
558
-
559
- function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
560
-
561
- if (type == null) {
562
- return '';
563
- }
564
-
565
- if (typeof type === 'function') {
566
- {
567
- return describeNativeComponentFrame(type, shouldConstruct(type));
568
- }
569
- }
570
-
571
- if (typeof type === 'string') {
572
- return describeBuiltInComponentFrame(type);
573
- }
574
-
575
- switch (type) {
576
- case REACT_SUSPENSE_TYPE:
577
- return describeBuiltInComponentFrame('Suspense');
578
-
579
- case REACT_SUSPENSE_LIST_TYPE:
580
- return describeBuiltInComponentFrame('SuspenseList');
581
- }
582
-
583
- if (typeof type === 'object') {
584
- switch (type.$$typeof) {
585
- case REACT_FORWARD_REF_TYPE:
586
- return describeFunctionComponentFrame(type.render);
587
-
588
- case REACT_MEMO_TYPE:
589
- // Memo may contain any component type so we recursively resolve it.
590
- return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
591
-
592
- case REACT_LAZY_TYPE:
593
- {
594
- var lazyComponent = type;
595
- var payload = lazyComponent._payload;
596
- var init = lazyComponent._init;
597
-
598
- try {
599
- // Lazy may contain any component type so we recursively resolve it.
600
- return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
601
- } catch (x) {}
602
- }
603
- }
604
- }
605
-
606
- return '';
607
- }
608
-
609
- var hasOwnProperty = Object.prototype.hasOwnProperty;
610
-
611
- var loggedTypeFailures = {};
612
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
613
-
614
- function setCurrentlyValidatingElement(element) {
615
- {
616
- if (element) {
617
- var owner = element._owner;
618
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
619
- ReactDebugCurrentFrame.setExtraStackFrame(stack);
620
- } else {
621
- ReactDebugCurrentFrame.setExtraStackFrame(null);
622
- }
623
- }
624
- }
625
-
626
- function checkPropTypes(typeSpecs, values, location, componentName, element) {
627
- {
628
- // $FlowFixMe This is okay but Flow doesn't know it.
629
- var has = Function.call.bind(hasOwnProperty);
630
-
631
- for (var typeSpecName in typeSpecs) {
632
- if (has(typeSpecs, typeSpecName)) {
633
- var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
634
- // fail the render phase where it didn't fail before. So we log it.
635
- // After these have been cleaned up, we'll let them throw.
636
-
637
- try {
638
- // This is intentionally an invariant that gets caught. It's the same
639
- // behavior as without this statement except with a better message.
640
- if (typeof typeSpecs[typeSpecName] !== 'function') {
641
- // eslint-disable-next-line react-internal/prod-error-codes
642
- 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`.');
643
- err.name = 'Invariant Violation';
644
- throw err;
645
- }
646
-
647
- error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
648
- } catch (ex) {
649
- error$1 = ex;
650
- }
651
-
652
- if (error$1 && !(error$1 instanceof Error)) {
653
- setCurrentlyValidatingElement(element);
654
-
655
- 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);
656
-
657
- setCurrentlyValidatingElement(null);
658
- }
659
-
660
- if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
661
- // Only monitor this failure once because there tends to be a lot of the
662
- // same error.
663
- loggedTypeFailures[error$1.message] = true;
664
- setCurrentlyValidatingElement(element);
665
-
666
- error('Failed %s type: %s', location, error$1.message);
667
-
668
- setCurrentlyValidatingElement(null);
669
- }
670
- }
671
- }
672
- }
673
- }
674
-
675
- var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
676
-
677
- function isArray(a) {
678
- return isArrayImpl(a);
679
- }
680
-
681
- /*
682
- * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
683
- * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
684
- *
685
- * The functions in this module will throw an easier-to-understand,
686
- * easier-to-debug exception with a clear errors message message explaining the
687
- * problem. (Instead of a confusing exception thrown inside the implementation
688
- * of the `value` object).
689
- */
690
- // $FlowFixMe only called in DEV, so void return is not possible.
691
- function typeName(value) {
692
- {
693
- // toStringTag is needed for namespaced types like Temporal.Instant
694
- var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
695
- var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
696
- return type;
697
- }
698
- } // $FlowFixMe only called in DEV, so void return is not possible.
699
-
700
-
701
- function willCoercionThrow(value) {
702
- {
703
- try {
704
- testStringCoercion(value);
705
- return false;
706
- } catch (e) {
707
- return true;
708
- }
709
- }
710
- }
711
-
712
- function testStringCoercion(value) {
713
- // If you ended up here by following an exception call stack, here's what's
714
- // happened: you supplied an object or symbol value to React (as a prop, key,
715
- // DOM attribute, CSS property, string ref, etc.) and when React tried to
716
- // coerce it to a string using `'' + value`, an exception was thrown.
717
- //
718
- // The most common types that will cause this exception are `Symbol` instances
719
- // and Temporal objects like `Temporal.Instant`. But any object that has a
720
- // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
721
- // exception. (Library authors do this to prevent users from using built-in
722
- // numeric operators like `+` or comparison operators like `>=` because custom
723
- // methods are needed to perform accurate arithmetic or comparison.)
724
- //
725
- // To fix the problem, coerce this object or symbol value to a string before
726
- // passing it to React. The most reliable way is usually `String(value)`.
727
- //
728
- // To find which value is throwing, check the browser or debugger console.
729
- // Before this exception was thrown, there should be `console.error` output
730
- // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
731
- // problem and how that type was used: key, atrribute, input value prop, etc.
732
- // In most cases, this console output also shows the component and its
733
- // ancestor components where the exception happened.
734
- //
735
- // eslint-disable-next-line react-internal/safe-string-coercion
736
- return '' + value;
737
- }
738
- function checkKeyStringCoercion(value) {
739
- {
740
- if (willCoercionThrow(value)) {
741
- error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
742
-
743
- return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
744
- }
745
- }
746
- }
747
-
748
- var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
749
- var RESERVED_PROPS = {
750
- key: true,
751
- ref: true,
752
- __self: true,
753
- __source: true
754
- };
755
- var specialPropKeyWarningShown;
756
- var specialPropRefWarningShown;
757
- var didWarnAboutStringRefs;
758
-
759
- {
760
- didWarnAboutStringRefs = {};
761
- }
762
-
763
- function hasValidRef(config) {
764
- {
765
- if (hasOwnProperty.call(config, 'ref')) {
766
- var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
767
-
768
- if (getter && getter.isReactWarning) {
769
- return false;
770
- }
771
- }
772
- }
773
-
774
- return config.ref !== undefined;
775
- }
776
-
777
- function hasValidKey(config) {
778
- {
779
- if (hasOwnProperty.call(config, 'key')) {
780
- var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
781
-
782
- if (getter && getter.isReactWarning) {
783
- return false;
784
- }
785
- }
786
- }
787
-
788
- return config.key !== undefined;
789
- }
790
-
791
- function warnIfStringRefCannotBeAutoConverted(config, self) {
792
- {
793
- if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
794
- var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
795
-
796
- if (!didWarnAboutStringRefs[componentName]) {
797
- 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);
798
-
799
- didWarnAboutStringRefs[componentName] = true;
800
- }
801
- }
802
- }
803
- }
804
-
805
- function defineKeyPropWarningGetter(props, displayName) {
806
- {
807
- var warnAboutAccessingKey = function () {
808
- if (!specialPropKeyWarningShown) {
809
- specialPropKeyWarningShown = true;
810
-
811
- 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);
812
- }
813
- };
814
-
815
- warnAboutAccessingKey.isReactWarning = true;
816
- Object.defineProperty(props, 'key', {
817
- get: warnAboutAccessingKey,
818
- configurable: true
819
- });
820
- }
821
- }
822
-
823
- function defineRefPropWarningGetter(props, displayName) {
824
- {
825
- var warnAboutAccessingRef = function () {
826
- if (!specialPropRefWarningShown) {
827
- specialPropRefWarningShown = true;
828
-
829
- 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);
830
- }
831
- };
832
-
833
- warnAboutAccessingRef.isReactWarning = true;
834
- Object.defineProperty(props, 'ref', {
835
- get: warnAboutAccessingRef,
836
- configurable: true
837
- });
838
- }
839
- }
840
- /**
841
- * Factory method to create a new React element. This no longer adheres to
842
- * the class pattern, so do not use new to call it. Also, instanceof check
843
- * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
844
- * if something is a React Element.
845
- *
846
- * @param {*} type
847
- * @param {*} props
848
- * @param {*} key
849
- * @param {string|object} ref
850
- * @param {*} owner
851
- * @param {*} self A *temporary* helper to detect places where `this` is
852
- * different from the `owner` when React.createElement is called, so that we
853
- * can warn. We want to get rid of owner and replace string `ref`s with arrow
854
- * functions, and as long as `this` and owner are the same, there will be no
855
- * change in behavior.
856
- * @param {*} source An annotation object (added by a transpiler or otherwise)
857
- * indicating filename, line number, and/or other information.
858
- * @internal
859
- */
860
-
861
-
862
- var ReactElement = function (type, key, ref, self, source, owner, props) {
863
- var element = {
864
- // This tag allows us to uniquely identify this as a React Element
865
- $$typeof: REACT_ELEMENT_TYPE,
866
- // Built-in properties that belong on the element
867
- type: type,
868
- key: key,
869
- ref: ref,
870
- props: props,
871
- // Record the component responsible for creating this element.
872
- _owner: owner
873
- };
874
-
875
- {
876
- // The validation flag is currently mutative. We put it on
877
- // an external backing store so that we can freeze the whole object.
878
- // This can be replaced with a WeakMap once they are implemented in
879
- // commonly used development environments.
880
- element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
881
- // the validation flag non-enumerable (where possible, which should
882
- // include every environment we run tests in), so the test framework
883
- // ignores it.
884
-
885
- Object.defineProperty(element._store, 'validated', {
886
- configurable: false,
887
- enumerable: false,
888
- writable: true,
889
- value: false
890
- }); // self and source are DEV only properties.
891
-
892
- Object.defineProperty(element, '_self', {
893
- configurable: false,
894
- enumerable: false,
895
- writable: false,
896
- value: self
897
- }); // Two elements created in two different places should be considered
898
- // equal for testing purposes and therefore we hide it from enumeration.
899
-
900
- Object.defineProperty(element, '_source', {
901
- configurable: false,
902
- enumerable: false,
903
- writable: false,
904
- value: source
905
- });
906
-
907
- if (Object.freeze) {
908
- Object.freeze(element.props);
909
- Object.freeze(element);
910
- }
911
- }
912
-
913
- return element;
914
- };
915
- /**
916
- * https://github.com/reactjs/rfcs/pull/107
917
- * @param {*} type
918
- * @param {object} props
919
- * @param {string} key
920
- */
921
-
922
- function jsxDEV(type, config, maybeKey, source, self) {
923
- {
924
- var propName; // Reserved names are extracted
925
-
926
- var props = {};
927
- var key = null;
928
- var ref = null; // Currently, key can be spread in as a prop. This causes a potential
929
- // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
930
- // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
931
- // but as an intermediary step, we will use jsxDEV for everything except
932
- // <div {...props} key="Hi" />, because we aren't currently able to tell if
933
- // key is explicitly declared to be undefined or not.
934
-
935
- if (maybeKey !== undefined) {
936
- {
937
- checkKeyStringCoercion(maybeKey);
938
- }
939
-
940
- key = '' + maybeKey;
941
- }
942
-
943
- if (hasValidKey(config)) {
944
- {
945
- checkKeyStringCoercion(config.key);
946
- }
947
-
948
- key = '' + config.key;
949
- }
950
-
951
- if (hasValidRef(config)) {
952
- ref = config.ref;
953
- warnIfStringRefCannotBeAutoConverted(config, self);
954
- } // Remaining properties are added to a new props object
955
-
956
-
957
- for (propName in config) {
958
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
959
- props[propName] = config[propName];
960
- }
961
- } // Resolve default props
962
-
963
-
964
- if (type && type.defaultProps) {
965
- var defaultProps = type.defaultProps;
966
-
967
- for (propName in defaultProps) {
968
- if (props[propName] === undefined) {
969
- props[propName] = defaultProps[propName];
970
- }
971
- }
972
- }
973
-
974
- if (key || ref) {
975
- var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
976
-
977
- if (key) {
978
- defineKeyPropWarningGetter(props, displayName);
979
- }
980
-
981
- if (ref) {
982
- defineRefPropWarningGetter(props, displayName);
983
- }
984
- }
985
-
986
- return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
987
- }
988
- }
989
-
990
- var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
991
- var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
992
-
993
- function setCurrentlyValidatingElement$1(element) {
994
- {
995
- if (element) {
996
- var owner = element._owner;
997
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
998
- ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
999
- } else {
1000
- ReactDebugCurrentFrame$1.setExtraStackFrame(null);
1001
- }
1002
- }
1003
- }
1004
-
1005
- var propTypesMisspellWarningShown;
1006
-
1007
- {
1008
- propTypesMisspellWarningShown = false;
1009
- }
1010
- /**
1011
- * Verifies the object is a ReactElement.
1012
- * See https://reactjs.org/docs/react-api.html#isvalidelement
1013
- * @param {?object} object
1014
- * @return {boolean} True if `object` is a ReactElement.
1015
- * @final
1016
- */
1017
-
1018
-
1019
- function isValidElement(object) {
1020
- {
1021
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1022
- }
1023
- }
1024
-
1025
- function getDeclarationErrorAddendum() {
1026
- {
1027
- if (ReactCurrentOwner$1.current) {
1028
- var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
1029
-
1030
- if (name) {
1031
- return '\n\nCheck the render method of `' + name + '`.';
1032
- }
1033
- }
1034
-
1035
- return '';
1036
- }
1037
- }
1038
-
1039
- function getSourceInfoErrorAddendum(source) {
1040
- {
1041
- if (source !== undefined) {
1042
- var fileName = source.fileName.replace(/^.*[\\\/]/, '');
1043
- var lineNumber = source.lineNumber;
1044
- return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
1045
- }
1046
-
1047
- return '';
1048
- }
1049
- }
1050
- /**
1051
- * Warn if there's no key explicitly set on dynamic arrays of children or
1052
- * object keys are not valid. This allows us to keep track of children between
1053
- * updates.
1054
- */
1055
-
1056
-
1057
- var ownerHasKeyUseWarning = {};
1058
-
1059
- function getCurrentComponentErrorInfo(parentType) {
1060
- {
1061
- var info = getDeclarationErrorAddendum();
1062
-
1063
- if (!info) {
1064
- var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
1065
-
1066
- if (parentName) {
1067
- info = "\n\nCheck the top-level render call using <" + parentName + ">.";
1068
- }
1069
- }
1070
-
1071
- return info;
1072
- }
1073
- }
1074
- /**
1075
- * Warn if the element doesn't have an explicit key assigned to it.
1076
- * This element is in an array. The array could grow and shrink or be
1077
- * reordered. All children that haven't already been validated are required to
1078
- * have a "key" property assigned to it. Error statuses are cached so a warning
1079
- * will only be shown once.
1080
- *
1081
- * @internal
1082
- * @param {ReactElement} element Element that requires a key.
1083
- * @param {*} parentType element's parent's type.
1084
- */
1085
-
1086
-
1087
- function validateExplicitKey(element, parentType) {
1088
- {
1089
- if (!element._store || element._store.validated || element.key != null) {
1090
- return;
1091
- }
1092
-
1093
- element._store.validated = true;
1094
- var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1095
-
1096
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1097
- return;
1098
- }
1099
-
1100
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
1101
- // property, it may be the creator of the child that's responsible for
1102
- // assigning it a key.
1103
-
1104
- var childOwner = '';
1105
-
1106
- if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
1107
- // Give the component that originally created this child.
1108
- childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
1109
- }
1110
-
1111
- setCurrentlyValidatingElement$1(element);
1112
-
1113
- 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);
1114
-
1115
- setCurrentlyValidatingElement$1(null);
1116
- }
1117
- }
1118
- /**
1119
- * Ensure that every element either is passed in a static location, in an
1120
- * array with an explicit keys property defined, or in an object literal
1121
- * with valid key property.
1122
- *
1123
- * @internal
1124
- * @param {ReactNode} node Statically passed child of any type.
1125
- * @param {*} parentType node's parent's type.
1126
- */
1127
-
1128
-
1129
- function validateChildKeys(node, parentType) {
1130
- {
1131
- if (typeof node !== 'object') {
1132
- return;
1133
- }
1134
-
1135
- if (isArray(node)) {
1136
- for (var i = 0; i < node.length; i++) {
1137
- var child = node[i];
1138
-
1139
- if (isValidElement(child)) {
1140
- validateExplicitKey(child, parentType);
1141
- }
1142
- }
1143
- } else if (isValidElement(node)) {
1144
- // This element was passed in a valid location.
1145
- if (node._store) {
1146
- node._store.validated = true;
1147
- }
1148
- } else if (node) {
1149
- var iteratorFn = getIteratorFn(node);
1150
-
1151
- if (typeof iteratorFn === 'function') {
1152
- // Entry iterators used to provide implicit keys,
1153
- // but now we print a separate warning for them later.
1154
- if (iteratorFn !== node.entries) {
1155
- var iterator = iteratorFn.call(node);
1156
- var step;
1157
-
1158
- while (!(step = iterator.next()).done) {
1159
- if (isValidElement(step.value)) {
1160
- validateExplicitKey(step.value, parentType);
1161
- }
1162
- }
1163
- }
1164
- }
1165
- }
1166
- }
1167
- }
1168
- /**
1169
- * Given an element, validate that its props follow the propTypes definition,
1170
- * provided by the type.
1171
- *
1172
- * @param {ReactElement} element
1173
- */
1174
-
1175
-
1176
- function validatePropTypes(element) {
1177
- {
1178
- var type = element.type;
1179
-
1180
- if (type === null || type === undefined || typeof type === 'string') {
1181
- return;
1182
- }
1183
-
1184
- var propTypes;
1185
-
1186
- if (typeof type === 'function') {
1187
- propTypes = type.propTypes;
1188
- } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
1189
- // Inner props are checked in the reconciler.
1190
- type.$$typeof === REACT_MEMO_TYPE)) {
1191
- propTypes = type.propTypes;
1192
- } else {
1193
- return;
1194
- }
1195
-
1196
- if (propTypes) {
1197
- // Intentionally inside to avoid triggering lazy initializers:
1198
- var name = getComponentNameFromType(type);
1199
- checkPropTypes(propTypes, element.props, 'prop', name, element);
1200
- } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
1201
- propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
1202
-
1203
- var _name = getComponentNameFromType(type);
1204
-
1205
- error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
1206
- }
1207
-
1208
- if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
1209
- error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1210
- }
1211
- }
1212
- }
1213
- /**
1214
- * Given a fragment, validate that it can only be provided with fragment props
1215
- * @param {ReactElement} fragment
1216
- */
1217
-
1218
-
1219
- function validateFragmentProps(fragment) {
1220
- {
1221
- var keys = Object.keys(fragment.props);
1222
-
1223
- for (var i = 0; i < keys.length; i++) {
1224
- var key = keys[i];
1225
-
1226
- if (key !== 'children' && key !== 'key') {
1227
- setCurrentlyValidatingElement$1(fragment);
1228
-
1229
- error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1230
-
1231
- setCurrentlyValidatingElement$1(null);
1232
- break;
1233
- }
1234
- }
1235
-
1236
- if (fragment.ref !== null) {
1237
- setCurrentlyValidatingElement$1(fragment);
1238
-
1239
- error('Invalid attribute `ref` supplied to `React.Fragment`.');
1240
-
1241
- setCurrentlyValidatingElement$1(null);
1242
- }
1243
- }
1244
- }
1245
-
1246
- function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1247
- {
1248
- var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
1249
- // succeed and there will likely be errors in render.
1250
-
1251
- if (!validType) {
1252
- var info = '';
1253
-
1254
- if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1255
- 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.";
1256
- }
1257
-
1258
- var sourceInfo = getSourceInfoErrorAddendum(source);
1259
-
1260
- if (sourceInfo) {
1261
- info += sourceInfo;
1262
- } else {
1263
- info += getDeclarationErrorAddendum();
1264
- }
1265
-
1266
- var typeString;
1267
-
1268
- if (type === null) {
1269
- typeString = 'null';
1270
- } else if (isArray(type)) {
1271
- typeString = 'array';
1272
- } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
1273
- typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
1274
- info = ' Did you accidentally export a JSX literal instead of a component?';
1275
- } else {
1276
- typeString = typeof type;
1277
- }
1278
-
1279
- 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);
1280
- }
1281
-
1282
- var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
1283
- // TODO: Drop this when these are no longer allowed as the type argument.
1284
-
1285
- if (element == null) {
1286
- return element;
1287
- } // Skip key warning if the type isn't valid since our key validation logic
1288
- // doesn't expect a non-string/function type and can throw confusing errors.
1289
- // We don't want exception behavior to differ between dev and prod.
1290
- // (Rendering will throw with a helpful message and as soon as the type is
1291
- // fixed, the key warnings will appear.)
1292
-
1293
-
1294
- if (validType) {
1295
- var children = props.children;
1296
-
1297
- if (children !== undefined) {
1298
- if (isStaticChildren) {
1299
- if (isArray(children)) {
1300
- for (var i = 0; i < children.length; i++) {
1301
- validateChildKeys(children[i], type);
1302
- }
1303
-
1304
- if (Object.freeze) {
1305
- Object.freeze(children);
1306
- }
1307
- } else {
1308
- 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.');
1309
- }
1310
- } else {
1311
- validateChildKeys(children, type);
1312
- }
1313
- }
1314
- }
1315
-
1316
- if (type === REACT_FRAGMENT_TYPE) {
1317
- validateFragmentProps(element);
1318
- } else {
1319
- validatePropTypes(element);
1320
- }
1321
-
1322
- return element;
1323
- }
1324
- } // These two functions exist to still get child warnings in dev
1325
- // even with the prod transform. This means that jsxDEV is purely
1326
- // opt-in behavior for better messages but that we won't stop
1327
- // giving you warnings if you use production apis.
1328
-
1329
- function jsxWithValidationStatic(type, props, key) {
1330
- {
1331
- return jsxWithValidation(type, props, key, true);
1332
- }
1333
- }
1334
- function jsxWithValidationDynamic(type, props, key) {
1335
- {
1336
- return jsxWithValidation(type, props, key, false);
1337
- }
1338
- }
1339
-
1340
- var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
1341
- // for now we can ship identical prod functions
1342
-
1343
- var jsxs = jsxWithValidationStatic ;
1344
-
1345
- reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
1346
- reactJsxRuntime_development.jsx = jsx;
1347
- reactJsxRuntime_development.jsxs = jsxs;
1348
- })();
1349
- }
1350
- return reactJsxRuntime_development;
1351
- }
1352
-
1353
- if (process.env.NODE_ENV === 'production') {
1354
- jsxRuntime.exports = requireReactJsxRuntime_production_min();
1355
- } else {
1356
- jsxRuntime.exports = requireReactJsxRuntime_development();
1357
- }
1358
-
1359
- var jsxRuntimeExports = jsxRuntime.exports;
1360
-
1361
- const baseCls = 'rls-tabular-text';
1362
- const pointers = ['.', ','];
1363
- function charClass(char) {
1364
- return pointers.includes(char) ? `${baseCls}__pointer` : `${baseCls}__char`;
1365
- }
1366
- function RlsTabularText({ value }) {
1367
- return (jsxRuntimeExports.jsx("div", { className: "rls-tabular-text", children: value?.split('').map((char, index) => (jsxRuntimeExports.jsx("span", { className: charClass(char), children: char }, index))) }));
1368
- }
1369
-
1370
- function RlsAmount({ value, decimals, symbol }) {
1371
- return (jsxRuntimeExports.jsxs("div", { className: "rls-amount", children: [symbol && jsxRuntimeExports.jsx("span", { children: symbol }), jsxRuntimeExports.jsx(RlsTabularText, { value: currencyFormat({ value, decimals }) })] }));
1372
- }
1373
-
1374
- function renderClassStatus(base, status = {}) {
1375
- const resultClass = [base];
1376
- Object.entries(status).forEach(([name, value]) => {
1377
- if (value) {
1378
- typeof value === 'string'
1379
- ? resultClass.push(`${base}--${value}`)
1380
- : resultClass.push(`${base}--${name}`);
1381
- }
1382
- });
1383
- return resultClass.join(' ');
1384
- }
1385
-
1386
- function RlsAvatar({ children, rounded, skeleton, rlsTheme }) {
1387
- return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-avatar', { rounded, skeleton }), "rls-theme": rlsTheme, children: children }));
1388
- }
1389
-
1390
- function RlsBreadcrumb({ labels }) {
1391
- 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))) }));
1392
- }
1393
-
1394
- function RlsIcon({ value, skeleton }) {
1395
- return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-icon', { skeleton }), children: jsxRuntimeExports.jsx("i", { className: `rls-icon-${value}` }) }));
1396
- }
1397
-
1398
- function RlsButton({ type, children, disabled, prefixIcon, suffixIcon, rlsTheme, onClick }) {
1399
- 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 })] }) }));
1400
- }
1401
-
1402
- function RlsButtonAction({ icon, disabled, tooltip, onClick }) {
1403
- 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 }) }))] }));
1404
- }
1405
-
1406
- function RlsCheckBox({ checked, disabled, rlsTheme }) {
1407
- return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-checkbox', { checked, disabled }), "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-checkbox__component" }) }));
1408
- }
1409
-
1410
- function RlsInput({ children, defaultValue, disabled, formControl, onValue, placeholder, type }) {
1411
- const [active, setActive] = useState(false);
1412
- function onChange(event) {
1413
- switch (type) {
1414
- case 'number':
1415
- setState(+event.target.value);
1416
- break;
1417
- default:
1418
- setState(event.target.value);
1419
- break;
1420
- }
1421
- }
1422
- function setState(value) {
1423
- formControl?.setState(value);
1424
- if (onValue) {
1425
- onValue(value);
1426
- }
1427
- }
1428
- function onFocus() {
1429
- formControl?.setActive(true);
1430
- setActive(true);
1431
- }
1432
- function onBlur() {
1433
- formControl?.setDirty(true);
1434
- formControl?.setActive(false);
1435
- setActive(false);
1436
- }
1437
- return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-input', {
1438
- active: formControl?.active || active,
1439
- disabled
1440
- }), children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type || 'text', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange, value: formControl?.state || defaultValue || '' }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
1441
- }
1442
-
1443
- function RlsInputMoney({ decimals, defaultValue, disabled, formControl, onValue, placeholder, symbol }) {
1444
- const [value, setValue] = useState(defaultValue || 0);
1445
- useEffect(() => {
1446
- formControl?.subscribe((value) => {
1447
- setValue(value || 0);
1448
- });
1449
- }, []);
1450
- function onMoney(value) {
1451
- if (!formControl) {
1452
- setValue(value);
1453
- }
1454
- if (onValue) {
1455
- onValue(value);
1456
- }
1457
- }
1458
- return (jsxRuntimeExports.jsx("div", { className: "rls-input-money", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", disabled: disabled, placeholder: placeholder, defaultValue: defaultValue, onValue: onMoney, children: jsxRuntimeExports.jsx(RlsAmount, { value: formControl?.state || value, symbol: symbol, decimals: decimals }) }) }));
1459
- }
1460
-
1461
- function RlsInputNumber({ disabled, defaultValue, formControl, onValue, placeholder }) {
1462
- const [value, setValue] = useState(defaultValue || 0);
1463
- useEffect(() => {
1464
- formControl?.subscribe((value) => {
1465
- setValue(value || 0);
1466
- });
1467
- }, []);
1468
- function onNumber(value) {
1469
- if (!formControl) {
1470
- setValue(value);
1471
- }
1472
- if (onValue) {
1473
- onValue(value);
1474
- }
1475
- }
1476
- return (jsxRuntimeExports.jsx("div", { className: "rls-input-number", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", disabled: disabled, placeholder: placeholder, onValue: onNumber, children: formControl?.state || value }) }));
1477
- }
1478
-
1479
- function RlsInputPassword({ disabled, formControl, onValue, placeholder, type }) {
1480
- const [active, setActive] = useState(false);
1481
- function onChange(event) {
1482
- formControl?.setState(event.target.value);
1483
- if (onValue) {
1484
- onValue(event.target.value);
1485
- }
1486
- }
1487
- function onFocus() {
1488
- setActive(true);
1489
- formControl?.setActive(true);
1490
- }
1491
- function onBlur() {
1492
- setActive(false);
1493
- formControl?.setActive(false);
1494
- formControl?.setDirty(true);
1495
- }
1496
- return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-input-password', {
1497
- active: formControl?.active || active,
1498
- disabled
1499
- }), children: jsxRuntimeExports.jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type || 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
1500
- }
1501
-
1502
- function RlsInputText({ defaultValue, disabled, formControl, onValue, placeholder }) {
1503
- const [value, setValue] = useState(defaultValue || '');
1504
- useEffect(() => {
1505
- formControl?.subscribe((value) => {
1506
- setValue(value || '');
1507
- });
1508
- }, []);
1509
- function onText(value) {
1510
- if (!formControl) {
1511
- setValue(value);
1512
- }
1513
- if (onValue) {
1514
- onValue(value);
1515
- }
1516
- }
1517
- return (jsxRuntimeExports.jsx("div", { className: "rls-input-text", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "text", disabled: disabled, placeholder: placeholder, onValue: onText, children: formControl?.state || value }) }));
1518
- }
1519
-
1520
- function RlsPoster({ children, rlsTheme }) {
1521
- return (jsxRuntimeExports.jsx("div", { className: "rls-poster", "rls-theme": rlsTheme, children: children }));
1522
- }
1523
-
1524
- function RlsProgressBar({ indeterminate, percentage, rlsTheme }) {
1525
- 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}%` } }) }));
1526
- }
1527
-
1528
- function RlsRadioButton({ checked, disabled, rlsTheme }) {
1529
- return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-radiobutton', { checked, disabled }), "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-radiobutton__component" }) }));
1530
- }
1531
-
1532
- function RlsSearchInput({ formControl, placeholder, onSearch }) {
1533
- return (jsxRuntimeExports.jsxs("div", { className: "rls-search-input", children: [jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, placeholder: placeholder }), onSearch && jsxRuntimeExports.jsx(RlsButtonAction, { icon: "search", onClick: onSearch })] }));
1534
- }
1535
-
1536
- function RlsSkeleton({ rlsTheme }) {
1537
- return jsxRuntimeExports.jsx("div", { className: "rls-skeleton", "rls-theme": rlsTheme });
1538
- }
1539
-
1540
- function RlsSkeletonText({ active, children, rlsTheme }) {
1541
- return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-skeleton-text', { active }), "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("span", { className: "rls-skeleton-text__value", children: children }) }));
1542
- }
1543
-
1544
- function RlsSwitch({ checked, disabled, rlsTheme, onClick }) {
1545
- return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-switch', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-switch__component" }) }));
1546
- }
1547
-
1548
- function RlsBallot({ bordered, children, img, initials, skeleton, subtitle, rlsTheme }) {
1549
- 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 }) }))] })] }));
1550
- }
1551
-
1552
- function RlsButtonToggle({ options, type, disabled, rlsTheme, onAction }) {
1553
- const contentRef = useRef(null);
1554
- const [firstAction] = options;
1555
- const [action, setAction] = useState(firstAction);
1556
- const [visible, setVisible] = useState(false);
1557
- useEffect(() => {
1558
- function onCloseMenu({ target }) {
1559
- if (!contentRef?.current?.contains(target)) {
1560
- setVisible(false);
1561
- }
1562
- }
1563
- document.addEventListener('click', onCloseMenu);
1564
- return () => {
1565
- document.removeEventListener('click', onCloseMenu);
1566
- };
1567
- }, []);
1568
- function onClickMenu() {
1569
- setVisible((prevValue) => !prevValue);
1570
- }
1571
- function onSelectAction(action) {
1572
- setAction(action);
1573
- setVisible(false);
1574
- }
1575
- return (jsxRuntimeExports.jsxs("div", { className: "rls-button-toggle", ref: contentRef, "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: () => {
1576
- if (onAction) {
1577
- onAction(action.value);
1578
- }
1579
- }, 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', {
1580
- visible,
1581
- hide: !visible
1582
- }), children: jsxRuntimeExports.jsx("ul", { children: options.map((action, index) => (jsxRuntimeExports.jsx("li", { className: "truncate", onClick: () => {
1583
- onSelectAction(action);
1584
- }, children: action.label }, index))) }) })] }));
1585
- }
1586
-
1587
- function RlsCheckBoxLabel({ children, disabled, extended, formControl, rlsTheme }) {
1588
- const [checked, setChecked] = useState(formControl?.value || false);
1589
- useEffect(() => {
1590
- setChecked(formControl?.state || false);
1591
- }, [formControl?.state]);
1592
- function onToggle() {
1593
- if (formControl) {
1594
- formControl?.setState(!formControl.state);
1595
- }
1596
- else {
1597
- setChecked(!checked);
1598
- }
1599
- }
1600
- return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-checkbox-label', {
1601
- disabled,
1602
- extended
1603
- }), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-checkbox-label__component", onClick: onToggle, children: jsxRuntimeExports.jsx(RlsCheckBox, { checked: checked, disabled: disabled }) }), jsxRuntimeExports.jsx("label", { className: "rls-checkbox-label__text", children: children })] }));
1604
- }
1605
-
1606
- let Factory$2 = class Factory {
1607
- constructor(props) {
1608
- const { date, value, maxDate, minDate } = props;
1609
- this.value = value;
1610
- this.date = new Date(date.getTime());
1611
- this.maxDate = maxDate;
1612
- this.minDate = minDate;
1613
- this.date.setDate(1);
1614
- }
1615
- static execute(props) {
1616
- const factory = new Factory(props);
1617
- const firstWeek = factory.createFirstWeek();
1618
- const rightWeeks = factory.createRightWeeks();
1619
- return [firstWeek, ...rightWeeks];
1620
- }
1621
- createFirstWeek() {
1622
- const dayStart = this.date.getDay();
1623
- const days = [];
1624
- let day = 1;
1625
- for (let start = 0; start < dayStart; start++) {
1626
- days.push(this.createDayState());
1627
- }
1628
- for (let end = dayStart; end < 7; end++) {
1629
- days.push(this.createDayState(day));
1630
- day++;
1631
- }
1632
- return { days };
1633
- }
1634
- createRightWeeks() {
1635
- const dayStart = this.date.getDay();
1636
- const rightWeeks = [];
1637
- const dayCount = daysFromMonth(this.date.getFullYear(), this.date.getMonth());
1638
- let days = [];
1639
- let countDaysWeek = 1;
1640
- let day = 8 - dayStart;
1641
- do {
1642
- days.push(this.createDayState(day));
1643
- day++;
1644
- countDaysWeek++;
1645
- if (countDaysWeek > 7) {
1646
- rightWeeks.push({ days });
1647
- days = [];
1648
- countDaysWeek = 1;
1649
- }
1650
- } while (day <= dayCount);
1651
- const daysPending = this.createDaysPending(days.length);
1652
- rightWeeks.push({ days: [...days, ...daysPending] });
1653
- return rightWeeks;
1654
- }
1655
- createDaysPending(daysWeek) {
1656
- const daysPending = [];
1657
- const length = 7 - daysWeek;
1658
- for (let index = 0; index < length; index++) {
1659
- daysPending.push(this.createDayState());
1660
- }
1661
- return daysPending;
1662
- }
1663
- createDayState(value) {
1664
- return {
1665
- disabled: this.overflowDay(value || 0),
1666
- forbidden: !value,
1667
- selected: value === this.value,
1668
- value
1669
- };
1670
- }
1671
- overflowDay(day) {
1672
- return this.minOverflowDay(day) || this.maxOverflowDay(day);
1673
- }
1674
- minOverflowDay(day) {
1675
- return this.minDate
1676
- ? weight(refactorDay(this.date, day)) < weight(this.minDate)
1677
- : false;
1678
- }
1679
- maxOverflowDay(day) {
1680
- return this.maxDate
1681
- ? weight(refactorDay(this.date, day)) > weight(this.maxDate)
1682
- : false;
1683
- }
1684
- };
1685
- function createDayPicker(props) {
1686
- return Factory$2.execute(props);
1687
- }
1688
-
1689
- function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
1690
- const initialDate = date || new Date();
1691
- const initialDay = formControl?.state || initialDate.getDate();
1692
- const [weeks, setWeeks] = useState([]);
1693
- const [value, setValue] = useState(initialDay);
1694
- useEffect(() => {
1695
- setWeeks(createDayPicker({
1696
- date: initialDate,
1697
- value: formControl?.state || value,
1698
- minDate,
1699
- maxDate
1700
- }));
1701
- }, [value, date, minDate, maxDate]);
1702
- useEffect(() => {
1703
- if (date && date.getDate() !== value) {
1704
- onChange(date.getDate());
1705
- }
1706
- }, [date]);
1707
- function onChange(value) {
1708
- setValue(value);
1709
- formControl?.setState(value);
1710
- }
1711
- return (jsxRuntimeExports.jsxs("div", { className: "rls-day-picker", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-day-picker__header", children: DAY_LABELS.map((title, index) => (jsxRuntimeExports.jsx("label", { className: "rls-day-picker__label", children: title }, index))) }), jsxRuntimeExports.jsx("div", { className: "rls-day-picker__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-day-picker__week", children: days.map(({ value, disabled, forbidden, selected }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-day-picker__day', {
1712
- disabled: disabled || disabledPicker,
1713
- forbidden,
1714
- selected
1715
- }), onClick: () => {
1716
- if (value && !disabled) {
1717
- onChange(value);
1718
- }
1719
- }, children: jsxRuntimeExports.jsx("span", { className: "rls-day-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
1720
- }
1721
-
1722
- const FORMAT_DESCRIPTION$1 = 'dd/mm/aa';
1723
- class ListFieldSuggestions {
1724
- constructor(collection) {
1725
- this.collection = collection;
1726
- }
1727
- hasElement(value) {
1728
- const [element] = this.collection.filter((element) => element.compareTo(value));
1729
- return element;
1730
- }
1731
- }
1732
- class DateRange {
1733
- constructor(minDate, maxDate) {
1734
- this.minDate = normalizeMinTime(minDate);
1735
- if (maxDate && isBefore(maxDate, minDate)) {
1736
- this.maxDate = normalizeMinTime(maxDate);
1737
- }
1738
- else {
1739
- this.maxDate = normalizeMinTime(minDate);
1740
- }
1741
- const minFormat = formatDate(this.minDate, FORMAT_DESCRIPTION$1);
1742
- const maxFormat = formatDate(this.maxDate, FORMAT_DESCRIPTION$1);
1743
- this.description = `${minFormat} - ${maxFormat}`;
1744
- }
1745
- recalculate(date) {
1746
- if (isBefore(this.minDate, date)) {
1747
- return new DateRange(date, this.maxDate);
1748
- }
1749
- if (isAfter(this.maxDate, date)) {
1750
- return new DateRange(this.minDate, date);
1751
- }
1752
- const minDifference = timeDifference(date, this.minDate);
1753
- const maxDifference = timeDifference(this.maxDate, date);
1754
- return minDifference > maxDifference
1755
- ? new DateRange(this.minDate, date)
1756
- : new DateRange(date, this.maxDate);
1757
- }
1758
- static now() {
1759
- return new DateRange(new Date());
1760
- }
1761
- }
1762
-
1763
- let Factory$1 = class Factory {
1764
- constructor(props) {
1765
- const { date, range, maxDate, minDate } = props;
1766
- this.date = new Date(date.getTime());
1767
- this.range = range;
1768
- this.maxDate = maxDate;
1769
- this.minDate = minDate;
1770
- this.date.setDate(1);
1771
- }
1772
- static execute(props) {
1773
- const factory = new Factory(props);
1774
- const firstWeek = factory.createFirstWeek();
1775
- const rightWeeks = factory.createRightWeeks();
1776
- return [firstWeek, ...rightWeeks];
1777
- }
1778
- createFirstWeek() {
1779
- const dayStart = this.date.getDay();
1780
- const days = [];
1781
- let day = 1;
1782
- for (let start = 0; start < dayStart; start++) {
1783
- days.push(this.createDayRangeState());
1784
- }
1785
- for (let end = dayStart; end < 7; end++) {
1786
- days.push(this.createDayRangeState(day));
1787
- day++;
1788
- }
1789
- return { days };
1790
- }
1791
- createRightWeeks() {
1792
- const rightWeeks = [];
1793
- const dayStart = this.date.getDay();
1794
- const dayCount = daysFromMonth(this.date.getFullYear(), this.date.getMonth());
1795
- let days = [];
1796
- let countDaysWeek = 1;
1797
- let day = 8 - dayStart;
1798
- do {
1799
- days.push(this.createDayRangeState(day));
1800
- day++;
1801
- countDaysWeek++;
1802
- if (countDaysWeek > 7) {
1803
- rightWeeks.push({ days });
1804
- days = [];
1805
- countDaysWeek = 1;
1806
- }
1807
- } while (day <= dayCount);
1808
- const daysPending = this.createDaysPending(days.length);
1809
- rightWeeks.push({ days: [...days, ...daysPending] });
1810
- return rightWeeks;
1811
- }
1812
- createDaysPending(daysWeek) {
1813
- const daysPending = [];
1814
- const length = 7 - daysWeek;
1815
- for (let index = 0; index < length; index++) {
1816
- daysPending.push(this.createDayRangeState());
1817
- }
1818
- return daysPending;
1819
- }
1820
- createDayRangeState(day) {
1821
- return {
1822
- value: day,
1823
- disabled: this.overflowDay(day || 0),
1824
- forbidden: !day,
1825
- ranged: day ? this.isRangedFromDate(day) : false,
1826
- selected: day ? this.isSelected(day) : false
1827
- };
1828
- }
1829
- isSelected(day) {
1830
- return (this.isSelectedForDate(this.range.minDate, day) ||
1831
- this.isSelectedForDate(this.range.maxDate, day));
1832
- }
1833
- isSelectedForDate(date, day) {
1834
- return (date.getFullYear() === this.date.getFullYear() &&
1835
- date.getMonth() === this.date.getMonth() &&
1836
- day === date.getDate());
1837
- }
1838
- isRangedFromDate(day) {
1839
- return isBetween(this.range.minDate, this.range.maxDate, refactorDay(this.date, day));
1840
- }
1841
- overflowDay(day) {
1842
- return this.minOverflowDay(day) || this.maxOverflowDay(day);
1843
- }
1844
- minOverflowDay(day) {
1845
- return this.minDate
1846
- ? weight(refactorDay(this.date, day)) < weight(this.minDate)
1847
- : false;
1848
- }
1849
- maxOverflowDay(day) {
1850
- return this.maxDate
1851
- ? weight(refactorDay(this.date, day)) > weight(this.maxDate)
1852
- : false;
1853
- }
1854
- };
1855
- function createRangePicker(props) {
1856
- return Factory$1.execute(props);
1857
- }
1858
-
1859
- function RlsDayRangePicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
1860
- const initialRange = formControl?.state || DateRange.now();
1861
- const initialDate = normalizeMinTime(date || initialRange.minDate);
1862
- const [weeks, setWeeks] = useState([]);
1863
- const [range, setRange] = useState(initialRange);
1864
- useEffect(() => {
1865
- setWeeks(createRangePicker({
1866
- date: initialDate,
1867
- range,
1868
- minDate,
1869
- maxDate
1870
- }));
1871
- }, [range, date, minDate, maxDate]);
1872
- function onChange(value) {
1873
- const newRange = range.recalculate(refactorDay(initialDate, value));
1874
- setRange(newRange);
1875
- formControl?.setState(newRange);
1876
- }
1877
- return (jsxRuntimeExports.jsxs("div", { className: "rls-day-range-picker", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-day-range-picker__header", children: DAY_LABELS.map((title, index) => (jsxRuntimeExports.jsx("label", { className: "rls-day-range-picker__label", children: title }, index))) }), jsxRuntimeExports.jsx("div", { className: "rls-day-range-picker__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-day-range-picker__week", children: days.map(({ value, disabled, forbidden, ranged, selected }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-day-range-picker__day', {
1878
- disabled: disabled || disabledPicker,
1879
- forbidden,
1880
- selected,
1881
- ranged
1882
- }), onClick: () => {
1883
- if (value && !disabled) {
1884
- onChange(value);
1885
- }
1886
- }, children: jsxRuntimeExports.jsx("span", { className: "rls-day-range-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
1887
- }
1888
-
1889
- function RlsMoneyField({ children, decimals, disabled, formControl, placeholder, symbol, rlsTheme }) {
1890
- return (jsxRuntimeExports.jsxs("div", { className: 'rls-money-field ' +
1891
- renderClassStatus('rls-box-field', {
1892
- active: formControl?.active,
1893
- error: formControl?.dirty && !formControl?.valid,
1894
- disabled
1895
- }), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-box-field__component", children: jsxRuntimeExports.jsx("div", { className: "rls-box-field__body", children: jsxRuntimeExports.jsx(RlsInputMoney, { formControl: formControl, disabled: disabled, placeholder: placeholder, symbol: symbol, decimals: decimals }) }) }), formControl?.dirty && formControl?.error && (jsxRuntimeExports.jsx("div", { className: "rls-box-field__helper rls-box-field__helper--error", children: jsxRuntimeExports.jsx("span", { children: formControl?.error.message }) }))] }));
1896
- }
1897
-
1898
- const MONTH_MAX_VALUE = Month.January;
1899
- const MONTH_MIN_VALUE = Month.December;
1900
- class Factory {
1901
- constructor(props) {
1902
- const { date, value, maxDate, minDate } = props;
1903
- this.value = value;
1904
- this.date = new Date(date.getTime());
1905
- this.maxDate = maxDate;
1906
- this.minDate = minDate;
1907
- }
1908
- static execute(props) {
1909
- const factory = new Factory(props);
1910
- return [
1911
- factory.createMonth(0),
1912
- factory.createMonth(1),
1913
- factory.createMonth(2),
1914
- factory.createMonth(3),
1915
- factory.createMonth(4),
1916
- factory.createMonth(5),
1917
- factory.createMonth(6),
1918
- factory.createMonth(7),
1919
- factory.createMonth(8),
1920
- factory.createMonth(9),
1921
- factory.createMonth(10),
1922
- factory.createMonth(11)
1923
- ];
1924
- }
1925
- createMonth(value) {
1926
- return {
1927
- value,
1928
- label: MONTH_NAMES[value],
1929
- disabled: this.overflowMonth(value),
1930
- selected: value === this.value
1931
- };
1932
- }
1933
- get minYear() {
1934
- return this.minDate?.getFullYear() || 0;
1935
- }
1936
- get maxYear() {
1937
- return this.maxDate?.getFullYear() || 10000;
1938
- }
1939
- get minMonth() {
1940
- return this.minDate?.getMonth() || MONTH_MIN_VALUE;
1941
- }
1942
- get maxMonth() {
1943
- return this.maxDate?.getMonth() || MONTH_MAX_VALUE;
1944
- }
1945
- overflowMonth(month) {
1946
- return this.minOverflowMonth(month) || this.maxOverflowMonth(month);
1947
- }
1948
- minOverflowMonth(month) {
1949
- return this.date.getFullYear() === this.minYear && month < this.minMonth;
1950
- }
1951
- maxOverflowMonth(month) {
1952
- return this.date.getFullYear() === this.maxYear && month > this.maxMonth;
1953
- }
1954
- }
1955
- function isMinLimitMonth(month, date, maxDate) {
1956
- const minYear = maxDate?.getFullYear() || 0;
1957
- const minMonth = maxDate?.getMonth() || 0;
1958
- return date.getFullYear() === minYear && month <= minMonth;
1959
- }
1960
- function isMaxLimitMonth(month, date, maxDate) {
1961
- const maxYear = maxDate?.getFullYear() || 10000;
1962
- const maxMonth = maxDate?.getMonth() || 11;
1963
- return date.getFullYear() === maxYear && month >= maxMonth;
1964
- }
1965
- function createMonthPicker(props) {
1966
- return Factory.execute(props);
1967
- }
1968
-
1969
- function RlsMonthPicker({ formControl, date, disabled: disabledPicker, maxDate, minDate, rlsTheme }) {
1970
- const initialDate = date || new Date();
1971
- const initialMonth = formControl?.state || initialDate.getMonth();
1972
- const [months, setMonths] = useState([]);
1973
- const [value, setValue] = useState(initialMonth);
1974
- useEffect(() => {
1975
- setMonths(createMonthPicker({
1976
- date: initialDate,
1977
- value: formControl?.state || value,
1978
- minDate,
1979
- maxDate
1980
- }));
1981
- }, [value, date, minDate, maxDate]);
1982
- return (jsxRuntimeExports.jsx("div", { className: "rls-month-picker", "rls-theme": rlsTheme, children: months.map(({ label, value, disabled, selected }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-month-picker__component', {
1983
- disabled: disabled || disabledPicker || false,
1984
- selected
1985
- }), onClick: () => {
1986
- formControl?.setState(value);
1987
- setValue(value);
1988
- }, children: jsxRuntimeExports.jsx("span", { className: "rls-month-picker__span", children: label }) }, index))) }));
1989
- }
1990
-
1991
- function RlsMonthTitlePicker({ monthControl, yearControl, date, maxDate, minDate, onClick }) {
1992
- const { state: month } = monthControl;
1993
- const { state: year } = yearControl;
1994
- const [limitMinMonth, setLimitMinMonth] = useState(false);
1995
- const [limitMaxMonth, setLimitMaxMonth] = useState(false);
1996
- const monthName = MONTH_NAMES[month || 0];
1997
- useEffect(() => {
1998
- if (typeof month === 'number' && date) {
1999
- setLimitMinMonth(isMinLimitMonth(month, date, minDate));
2000
- setLimitMaxMonth(isMaxLimitMonth(month, date, maxDate));
2001
- }
2002
- }, [date]);
2003
- function onPreviousMonth() {
2004
- if (typeof month === 'number' && typeof year === 'number') {
2005
- if (month > MONTH_MIN_VALUE) {
2006
- monthControl.setState(month - 1);
2007
- }
2008
- else {
2009
- monthControl.setState(MONTH_MAX_VALUE);
2010
- yearControl.setState(year - 1);
2011
- }
2012
- }
2013
- }
2014
- function onNextMonth() {
2015
- if (typeof month === 'number' && typeof year === 'number') {
2016
- if (month < MONTH_MAX_VALUE) {
2017
- monthControl.setState(month + 1);
2018
- }
2019
- else {
2020
- monthControl.setState(MONTH_MIN_VALUE);
2021
- yearControl.setState(year + 1);
2022
- }
2023
- }
2024
- }
2025
- return (jsxRuntimeExports.jsxs("div", { className: "rls-month-title-picker", children: [jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPreviousMonth, disabled: limitMinMonth }), jsxRuntimeExports.jsx("span", { onClick: onClick, children: monthName }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onNextMonth, disabled: limitMaxMonth })] }));
2026
- }
2027
-
2028
- function RlsNumberField({ children, disabled, formControl, placeholder, rlsTheme }) {
2029
- return (jsxRuntimeExports.jsxs("div", { className: 'rls-number-field ' +
2030
- renderClassStatus('rls-box-field', {
2031
- active: formControl?.active,
2032
- error: formControl?.dirty && !formControl?.valid,
2033
- disabled
2034
- }), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-box-field__component", children: jsxRuntimeExports.jsx("div", { className: "rls-box-field__body", children: jsxRuntimeExports.jsx(RlsInputNumber, { formControl: formControl, disabled: disabled, placeholder: placeholder }) }) }), formControl?.dirty && formControl?.error && (jsxRuntimeExports.jsx("div", { className: "rls-box-field__helper rls-box-field__helper--error", children: jsxRuntimeExports.jsx("span", { children: formControl?.error.message }) }))] }));
2035
- }
2036
-
2037
- const DEFAULT_COUNT_ELEMENT = 20;
2038
- const MIN_NUMBER_PAGE = 1;
2039
- const FIRST_PAGE = 0;
2040
- const DEFAULT_MAX_VISIBLE = 4;
2041
- function RlsPagination({ elements, count: defaultCount, filter, onElements, onPagination }) {
2042
- const count = defaultCount || DEFAULT_COUNT_ELEMENT;
2043
- const [collection, setCollection] = useState([]);
2044
- const [index, setIndex] = useState(0);
2045
- const [maxPage, setMaxPage] = useState(calculateMaxPage(elements, count));
2046
- const [paginations, setPaginations] = useState([]);
2047
- const [currentPagination, setCurrentPagination] = useState();
2048
- const [description, setDescription] = useState('');
2049
- const [firstPage, setFirstPage] = useState(true);
2050
- const [lastPage, setLastPage] = useState(false);
2051
- useEffect(() => {
2052
- refreshFromElements(elements);
2053
- }, [elements]);
2054
- useEffect(() => {
2055
- const isFirstPage = currentPagination?.value === FIRST_PAGE;
2056
- const isLastPage = currentPagination?.value === maxPage - 1;
2057
- setFirstPage(isFirstPage);
2058
- setLastPage(isLastPage);
2059
- if (onPagination) {
2060
- onPagination({ firstPage: isFirstPage, lastPage: isLastPage });
2061
- }
2062
- }, [currentPagination]);
2063
- useEffect(() => {
2064
- refreshFromFilter(filter);
2065
- }, [filter]);
2066
- function onChangeElements(elements) {
2067
- if (onElements) {
2068
- onElements(elements);
2069
- }
2070
- }
2071
- function calculateMaxPage(collection, count) {
2072
- return collection.length ? Math.ceil(collection.length / count) : 0;
2073
- }
2074
- function onSelectPagination(pagination) {
2075
- const { value } = pagination;
2076
- pagination.active = true;
2077
- setIndex(value);
2078
- setCurrentPagination(pagination);
2079
- refreshFromChanged(createPageProps({ index: value }));
2080
- }
2081
- function goPagination(pagination) {
2082
- if (currentPagination) {
2083
- currentPagination.active = false;
2084
- }
2085
- onSelectPagination(pagination);
2086
- }
2087
- function goPreviousPagination() {
2088
- if (currentPagination) {
2089
- const { prev, value } = currentPagination;
2090
- if (prev) {
2091
- onSelectPagination(prev);
2092
- currentPagination.active = false;
2093
- }
2094
- else {
2095
- const prevIndex = value - MIN_NUMBER_PAGE;
2096
- if (prevIndex >= FIRST_PAGE) {
2097
- refreshFromChanged(createPagePropsFromIndex(prevIndex));
2098
- }
2099
- }
2100
- }
2101
- }
2102
- function goFirstPagination() {
2103
- if (collection.length) {
2104
- refreshFromChanged(createPagePropsFromIndex(FIRST_PAGE));
2105
- }
2106
- }
2107
- function goNextPagination() {
2108
- if (currentPagination) {
2109
- const { next, value } = currentPagination;
2110
- if (next) {
2111
- onSelectPagination(next);
2112
- currentPagination.active = false;
2113
- }
2114
- else {
2115
- const nextIndex = value + 1;
2116
- if (nextIndex <= maxPage) {
2117
- refreshFromChanged(createPagePropsFromIndex(nextIndex));
2118
- }
2119
- }
2120
- }
2121
- }
2122
- function goLastPagination() {
2123
- if (collection.length) {
2124
- refreshFromChanged(createPagePropsFromIndex(maxPage - MIN_NUMBER_PAGE));
2125
- }
2126
- }
2127
- function createPageCollection(props) {
2128
- const { collection, count, index } = props;
2129
- if (collection.length) {
2130
- const finish = (index + MIN_NUMBER_PAGE) * count;
2131
- const start = index * count;
2132
- return collection.slice(start, finish);
2133
- }
2134
- return [];
2135
- }
2136
- function refreshFromElements(elements) {
2137
- elements.length
2138
- ? refreshFromChanged(createRefreshProps(elements, filter))
2139
- : rebootPagination();
2140
- }
2141
- function refreshFromFilter(filter) {
2142
- refreshFromChanged(createRefreshProps(elements, filter));
2143
- }
2144
- function createRefreshProps(elements, filter) {
2145
- const collection = refreshCollection(elements, filter);
2146
- const maxPage = refreshMaxPage(collection, count);
2147
- const index = refreshIndex(collection, maxPage);
2148
- return createPageProps({ collection, index, maxPage });
2149
- }
2150
- function refreshFromChanged(page) {
2151
- refreshPaginations(page);
2152
- refreshDescription(page);
2153
- onChangeElements(createPageCollection(page));
2154
- }
2155
- function refreshCollection(elements, filter) {
2156
- const collection = filter
2157
- ? elements.filter((element) => hasPattern(JSON.stringify(element), filter))
2158
- : elements;
2159
- setCollection(collection);
2160
- return collection;
2161
- }
2162
- function refreshMaxPage(collection, count) {
2163
- const maxPage = calculateMaxPage(collection, count);
2164
- setMaxPage(maxPage);
2165
- return maxPage;
2166
- }
2167
- function refreshIndex(collection, currentMaxPage) {
2168
- const maxPage = currentMaxPage || refreshMaxPage(collection, count);
2169
- if (index < maxPage || index === FIRST_PAGE) {
2170
- return index;
2171
- }
2172
- const newIndex = maxPage - 1;
2173
- setIndex(newIndex);
2174
- return newIndex;
2175
- }
2176
- function rebootPagination() {
2177
- setCollection([]);
2178
- setMaxPage(0);
2179
- setIndex(0);
2180
- setPaginations([]);
2181
- onChangeElements([]);
2182
- }
2183
- function refreshDescription(page) {
2184
- const { collection, count, index } = page;
2185
- const totalCount = elements.length;
2186
- const start = index * count + MIN_NUMBER_PAGE;
2187
- let end = (index + MIN_NUMBER_PAGE) * count;
2188
- if (end > collection.length) {
2189
- end = collection.length;
2190
- }
2191
- setDescription(`${start} - ${end} de ${totalCount}`);
2192
- }
2193
- function refreshPaginations({ index, maxPage }) {
2194
- let maxPageVisible = index + DEFAULT_MAX_VISIBLE;
2195
- if (maxPageVisible > maxPage) {
2196
- maxPageVisible = maxPage;
2197
- }
2198
- let minIndexPage = maxPageVisible - DEFAULT_MAX_VISIBLE;
2199
- if (minIndexPage < 0) {
2200
- minIndexPage = 0;
2201
- }
2202
- if (minIndexPage > index) {
2203
- minIndexPage = index;
2204
- }
2205
- let prevPagination = undefined;
2206
- const paginations = [];
2207
- for (let i = minIndexPage; i < maxPageVisible; i++) {
2208
- const pagination = createPagination(i, index);
2209
- paginations.push(pagination);
2210
- pagination.prev = prevPagination;
2211
- if (prevPagination) {
2212
- prevPagination.next = pagination;
2213
- }
2214
- prevPagination = pagination;
2215
- }
2216
- setPaginations(paginations);
2217
- }
2218
- function createPagination(value, index) {
2219
- const active = value === index;
2220
- const pagination = {
2221
- label: (value + 1).toString(),
2222
- value,
2223
- active
2224
- };
2225
- if (active) {
2226
- setCurrentPagination(pagination);
2227
- }
2228
- return pagination;
2229
- }
2230
- function createPagePropsFromIndex(index) {
2231
- return createPageProps({ index });
2232
- }
2233
- function createPageProps(props) {
2234
- return {
2235
- collection: props.collection || collection,
2236
- index: typeof props.index === 'number' ? props.index : index,
2237
- count: props.count || count,
2238
- maxPage: typeof props.maxPage === 'number' ? props.maxPage : maxPage
2239
- };
2240
- }
2241
- 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: firstPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrowhead-left" }) }), jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goPreviousPagination, disabled: firstPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-left" }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-pagination__pages", children: paginations.map((page, index) => {
2242
- return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-pagination__page', {
2243
- active: page.active
2244
- }), onClick: () => {
2245
- goPagination(page);
2246
- }, children: page.label }, index));
2247
- }) }), jsxRuntimeExports.jsx("div", { className: "rls-pagination__description", children: description }), jsxRuntimeExports.jsxs("div", { className: "rls-pagination__actions", children: [jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goNextPagination, disabled: lastPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-right" }) }), jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goLastPagination, disabled: lastPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrowhead-right" }) })] })] }));
2248
- }
2249
-
2250
- function RlsPasswordField({ children, disabled, formControl, placeholder, rlsTheme }) {
2251
- const [password, setPassword] = useState(true);
2252
- function onToggleInput() {
2253
- setPassword(!password);
2254
- }
2255
- return (jsxRuntimeExports.jsxs("div", { className: 'rls-password-field ' +
2256
- renderClassStatus(' rls-box-field', {
2257
- active: formControl?.active,
2258
- error: formControl?.dirty && !formControl?.valid,
2259
- disabled
2260
- }), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-box-field__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-box-field__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 })] }) }), formControl?.dirty && formControl?.error && (jsxRuntimeExports.jsx("div", { className: "rls-box-field__helper rls-box-field__helper--error", children: jsxRuntimeExports.jsx("span", { children: formControl?.error.message }) }))] }));
2261
- }
2262
-
2263
- function RlsRadioButtonLabel({ children, disabled, extended, formControl, rlsTheme, value }) {
2264
- const [checked, setChecked] = useState(formControl?.state || false);
2265
- useEffect(() => {
2266
- setChecked(formControl?.state === value);
2267
- }, [formControl?.state]);
2268
- function onSelect() {
2269
- if (formControl) {
2270
- formControl?.setState(value);
2271
- }
2272
- }
2273
- return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-radiobutton-label', {
2274
- disabled,
2275
- extended
2276
- }), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-radiobutton-label__component", onClick: onSelect, children: jsxRuntimeExports.jsx(RlsRadioButton, { checked: checked, disabled: disabled }) }), jsxRuntimeExports.jsx("label", { className: "rls-radiobutton-label__text", children: children })] }));
2277
- }
2278
-
2279
- function RlsSwitchLabel({ children, disabled, extended, formControl, rlsTheme }) {
2280
- const [checked, setChecked] = useState(formControl?.value || false);
2281
- useEffect(() => {
2282
- setChecked(formControl?.state || false);
2283
- }, [formControl?.state]);
2284
- function onToggle() {
2285
- if (formControl) {
2286
- formControl?.setState(!formControl.state);
2287
- }
2288
- else {
2289
- setChecked(!checked);
2290
- }
2291
- }
2292
- return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-switch-label', { disabled, extended }), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-switch-label__component", onClick: onToggle, children: jsxRuntimeExports.jsx(RlsSwitch, { checked: checked, disabled: disabled }) }), jsxRuntimeExports.jsx("label", { className: "rls-switch-label__text", children: children })] }));
2293
- }
2294
-
2295
- function RlsTextField({ children, disabled, formControl, placeholder, rlsTheme }) {
2296
- return (jsxRuntimeExports.jsxs("div", { className: 'rls-text-field ' +
2297
- renderClassStatus('rls-box-field', {
2298
- active: formControl?.active,
2299
- error: formControl?.dirty && !formControl?.valid,
2300
- disabled
2301
- }), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-box-field__component", children: jsxRuntimeExports.jsx("div", { className: "rls-box-field__body", children: jsxRuntimeExports.jsx(RlsInputText, { formControl: formControl, disabled: disabled, placeholder: placeholder }) }) }), formControl?.dirty && formControl?.error && (jsxRuntimeExports.jsx("div", { className: "rls-box-field__helper rls-box-field__helper--error", children: jsxRuntimeExports.jsx("span", { children: formControl?.error.message }) }))] }));
2302
- }
2303
-
2304
- function RlsToolbar({ actions, children, subtitle }) {
2305
- 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 caption-semibold", children: subtitle }))] }), actions && (jsxRuntimeExports.jsx("div", { className: "rls-toolbar__actions", children: actions.map((action, index) => (jsxRuntimeExports.jsx("div", { children: action }, index))) }))] }));
2306
- }
2307
-
2308
- const COUNT_YEAR_RANGE = 4;
2309
- class FactoryYearPicker {
2310
- constructor(props) {
2311
- const { value, maxDate, minDate } = props;
2312
- this.value = value;
2313
- this.maxDate = maxDate;
2314
- this.minDate = minDate;
2315
- }
2316
- static execute(props) {
2317
- const factory = new FactoryYearPicker(props);
2318
- let year = props.year;
2319
- if (factory.minOverflowYear(year)) {
2320
- year = factory.minYear;
2321
- }
2322
- else if (factory.maxOverflowYear(year)) {
2323
- year = factory.maxYear;
2324
- }
2325
- const years = factory.createYears(year);
2326
- return {
2327
- hasNext: factory.hasNext,
2328
- hasPrevious: factory.hasPrevious,
2329
- maxRange: factory.maxYearRange,
2330
- minRange: factory.minYearRange,
2331
- years
2332
- };
2333
- }
2334
- createYears(year) {
2335
- const prevYears = [];
2336
- const nextYears = [];
2337
- this.minYearRange = year;
2338
- this.maxYearRange = year;
2339
- for (let index = 0; index < COUNT_YEAR_RANGE; index++) {
2340
- const yearPrev = year - COUNT_YEAR_RANGE + index;
2341
- const yearNext = year + index + 1;
2342
- const valuePrev = yearPrev >= this.minYear ? yearPrev : undefined;
2343
- const valueNext = yearNext <= this.maxYear ? yearNext : undefined;
2344
- const prevState = this.createYear(valuePrev);
2345
- const nextState = this.createYear(valueNext);
2346
- prevYears.push(prevState);
2347
- nextYears.push(nextState);
2348
- this.recalculateRange(prevState, nextState);
2349
- }
2350
- const yearCenter = this.createYear(year);
2351
- return [...prevYears, yearCenter, ...nextYears];
2352
- }
2353
- minOverflowYear(year) {
2354
- return year < this.minYear;
2355
- }
2356
- maxOverflowYear(year) {
2357
- return year > this.maxYear;
2358
- }
2359
- get minYear() {
2360
- return this.minDate?.getFullYear() || 0;
2361
- }
2362
- get maxYear() {
2363
- return this.maxDate?.getFullYear() || 10000;
2364
- }
2365
- get hasPrevious() {
2366
- return this.minYear < this.minYearRange;
2367
- }
2368
- get hasNext() {
2369
- return this.maxYear > this.maxYearRange;
2370
- }
2371
- createYear(value) {
2372
- return {
2373
- value,
2374
- disabled: !value,
2375
- selected: value === this.value
2376
- };
2377
- }
2378
- recalculateRange(prev, next) {
2379
- if (!!prev.value && this.minYearRange > prev.value) {
2380
- this.minYearRange = prev.value;
2381
- }
2382
- if (!!next.value && this.maxYearRange < next.value) {
2383
- this.maxYearRange = next.value;
2384
- }
2385
- }
2386
- }
2387
- function createYearPicker(props) {
2388
- return FactoryYearPicker.execute(props);
2389
- }
2390
-
2391
- function RlsYearPicker({ formControl, date: date, disabled: disabledPicker, maxDate, minDate, rlsTheme }) {
2392
- const initialDate = date || new Date();
2393
- const initialYear = formControl?.state || initialDate.getFullYear();
2394
- const [value, setValue] = useState(initialYear);
2395
- const [year, setYear] = useState(initialYear);
2396
- const [template, setTemplate] = useState(createYearPicker({
2397
- value: formControl?.state || value,
2398
- year: initialYear,
2399
- minDate,
2400
- maxDate
2401
- }));
2402
- useEffect(() => {
2403
- setTemplate(createYearPicker({
2404
- value: formControl?.state || value,
2405
- year,
2406
- minDate,
2407
- maxDate
2408
- }));
2409
- }, [value, year, date, minDate, maxDate]);
2410
- function onClickPrev() {
2411
- setYear(year - 8);
2412
- }
2413
- function onClickNext() {
2414
- setYear(year + 8);
2415
- }
2416
- function onChange(value) {
2417
- formControl?.setState(value);
2418
- setYear(value);
2419
- setValue(value);
2420
- }
2421
- return (jsxRuntimeExports.jsxs("div", { className: "rls-year-picker", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-year-picker__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-year-picker__action rls-year-picker__action--prev", children: jsxRuntimeExports.jsx("button", { disabled: !template.hasPrevious || disabledPicker, onClick: onClickPrev, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-left" }) }) }), jsxRuntimeExports.jsx("div", { className: "rls-year-picker__title", children: jsxRuntimeExports.jsxs("label", { className: "title1-bold", children: [template.minRange, " - ", template.maxRange] }) }), jsxRuntimeExports.jsx("div", { className: "rls-year-picker__action rls-year-picker__action--next", children: jsxRuntimeExports.jsx("button", { disabled: !template.hasNext || disabledPicker, onClick: onClickNext, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-right" }) }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-year-picker__component", children: template.years.map(({ value, disabled, selected }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-year-picker__year', {
2422
- disabled: disabled || disabledPicker,
2423
- selected
2424
- }), onClick: () => {
2425
- if (value) {
2426
- onChange(value);
2427
- }
2428
- }, children: jsxRuntimeExports.jsx("span", { className: "rls-year-picker__year__span body1-medium", children: value || '????' }) }, index))) })] }));
2429
- }
2430
-
2431
- function useReactControl(props = {}) {
2432
- const [state, setState] = useState(props.state);
2433
- const [value, setValue] = useState(props.state);
2434
- const [dirty, setDirty] = useState(false);
2435
- const [active, setActive] = useState(false);
2436
- const [disabled, setDisabled] = useState(false);
2437
- const [initialValue] = useState(props.state);
2438
- const [valid, setValid] = useState(true);
2439
- const [invalid, setInvalid] = useState(false);
2440
- const [validators, setValidators] = useState(props.validators || []);
2441
- const [errors, setErrors] = useState([]);
2442
- const [error, setError] = useState();
2443
- const [subscribers] = useState(new Set());
2444
- const elementRef = useRef(null);
2445
- useEffect(() => {
2446
- updateValueAndValidity();
2447
- if (state) {
2448
- setValue(state);
2449
- }
2450
- subscribers.forEach((subscriber) => {
2451
- subscriber(state);
2452
- });
2453
- }, [state]);
2454
- useEffect(() => {
2455
- updateValueAndValidity();
2456
- }, [validators]);
2457
- function reset() {
2458
- setDirty(false);
2459
- setState(initialValue);
2460
- }
2461
- function subscribe(subscriber) {
2462
- subscribers.add(subscriber);
2463
- }
2464
- function updateValueAndValidity() {
2465
- const errors = validators.reduce((errors, validator) => {
2466
- const error = validator(state);
2467
- if (error) {
2468
- errors.push(error);
2469
- }
2470
- return errors;
2471
- }, []);
2472
- const [error] = errors;
2473
- setErrors(errors);
2474
- setError(error);
2475
- const validState = errors.length === 0;
2476
- setValid(validState);
2477
- setInvalid(!validState);
2478
- }
2479
- return {
2480
- active,
2481
- dirty,
2482
- disabled,
2483
- elementRef,
2484
- errors,
2485
- invalid,
2486
- valid,
2487
- value,
2488
- error,
2489
- state,
2490
- reset,
2491
- setActive,
2492
- setDirty,
2493
- setDisabled,
2494
- setValidators,
2495
- setState,
2496
- subscribe,
2497
- updateValueAndValidity
2498
- };
2499
- }
2500
- function useFormControl(props = {}) {
2501
- return useReactControl(props);
2502
- }
2503
- function useInputControl(props = {}) {
2504
- return useReactControl(props);
2505
- }
2506
-
2507
- function useFormGroup(controls) {
2508
- function valid() {
2509
- return Object.values(controls).reduce((validState, { valid }) => validState && valid, true);
2510
- }
2511
- function invalid() {
2512
- return !valid();
2513
- }
2514
- function reset() {
2515
- Object.values(controls).forEach((control) => control.reset());
2516
- }
2517
- function json() {
2518
- return Object.entries(controls).reduce((json, [key, { state }]) => {
2519
- json[key] = state;
2520
- return json;
2521
- }, {});
2522
- }
2523
- function updateValueAndValidity() {
2524
- Object.values(controls).forEach((control) => control.updateValueAndValidity());
2525
- }
2526
- return { controls, invalid, json, reset, updateValueAndValidity, valid };
2527
- }
2528
-
2529
- const classElement = '.rls-list-field__element';
2530
- const MAX_POSITION_VISIBLE = 4;
2531
- const LIST_SIZE_REM = 16;
2532
- const ELEMENT_SIZE_REM = 4;
2533
- const BASE_SIZE_PX = 16;
2534
- const ELEMENT_SIZE_PX = BASE_SIZE_PX * ELEMENT_SIZE_REM;
2535
- const MAZ_LIST_SIZE_PX = BASE_SIZE_PX * LIST_SIZE_REM;
2536
- function useListControl(suggestions, ignoreHigher = false) {
2537
- const boxContentRef = useRef(null);
2538
- const listRef = useRef(null);
2539
- const inputRef = useRef(null);
2540
- const [suggestionsField, setSuggestionsField] = useState(new ListFieldSuggestions([]));
2541
- const [active, setActive] = useState(false);
2542
- const [visible, setVisible] = useState(false);
2543
- const [value, setValue] = useState('');
2544
- const [higher, setHigher] = useState(false);
2545
- const [positionElement, setPositionElement] = useState(0);
2546
- const [listElements, setListElements] = useState(undefined);
2547
- useEffect(() => {
2548
- function onCloseSuggestions(event) {
2549
- if (!boxContentRef?.current?.contains(event.target)) {
2550
- setVisible(false);
2551
- }
2552
- }
2553
- document.addEventListener('click', onCloseSuggestions);
2554
- return () => {
2555
- document.removeEventListener('click', onCloseSuggestions);
2556
- };
2557
- }, []);
2558
- useEffect(() => {
2559
- setLocationList();
2560
- }, [visible]);
2561
- useEffect(() => {
2562
- setSuggestionsField(new ListFieldSuggestions(suggestions));
2563
- }, [suggestions]);
2564
- function setLocationList() {
2565
- if (boxContentRef?.current) {
2566
- const { top, height } = boxContentRef.current.getBoundingClientRect();
2567
- const overflow = BASE_SIZE_PX / 2;
2568
- const positionEnd = top + height + MAZ_LIST_SIZE_PX + overflow;
2569
- setHigher(positionEnd > window.innerHeight);
2570
- }
2571
- }
2572
- function navigationInput(event) {
2573
- switch (event.code) {
2574
- case 'ArrowUp':
2575
- if (visible && higher) {
2576
- navigationInputUp();
2577
- }
2578
- break;
2579
- case 'ArrowDown':
2580
- if (visible && (ignoreHigher || !higher)) {
2581
- navigationInputDown();
2582
- }
2583
- break;
2584
- }
2585
- }
2586
- function navigationElement(event) {
2587
- switch (event.code) {
2588
- case 'ArrowUp':
2589
- navigationElementUp();
2590
- break;
2591
- case 'ArrowDown':
2592
- navigationElementDown();
2593
- break;
2594
- }
2595
- }
2596
- function navigationInputUp() {
2597
- const elements = listRef?.current?.querySelectorAll(classElement);
2598
- if (elements?.length) {
2599
- const newPosition = elements.length - 1;
2600
- setListElements(elements);
2601
- setPositionElement(newPosition);
2602
- elements.item(newPosition).focus();
2603
- if (positionElement > MAX_POSITION_VISIBLE) {
2604
- const elementPosition = elements.length - MAX_POSITION_VISIBLE;
2605
- setTimeout(() => {
2606
- listRef?.current?.scroll({
2607
- top: ELEMENT_SIZE_PX * elementPosition,
2608
- behavior: 'smooth'
2609
- });
2610
- }, 100);
2611
- }
2612
- }
2613
- }
2614
- function navigationInputDown() {
2615
- const elements = listRef?.current?.querySelectorAll(classElement);
2616
- if (elements?.length) {
2617
- setListElements(elements);
2618
- setPositionElement(0);
2619
- elements.item(0).focus();
2620
- setTimeout(() => {
2621
- listRef?.current?.scroll({
2622
- top: 0,
2623
- behavior: 'smooth'
2624
- });
2625
- }, 100);
2626
- }
2627
- }
2628
- function navigationElementUp() {
2629
- if (positionElement > 0) {
2630
- const newPosition = positionElement - 1;
2631
- setPositionElement(newPosition);
2632
- listElements?.item(newPosition).focus();
2633
- }
2634
- else if (ignoreHigher || !higher) {
2635
- inputRef?.current?.focus();
2636
- }
2637
- }
2638
- function navigationElementDown() {
2639
- const newPosition = positionElement + 1;
2640
- const length = listElements?.length || 0;
2641
- if (newPosition < length) {
2642
- setPositionElement(newPosition);
2643
- listElements?.item(newPosition).focus();
2644
- }
2645
- else if (higher && !ignoreHigher) {
2646
- inputRef?.current?.focus();
2647
- }
2648
- }
2649
- return {
2650
- active,
2651
- boxContentRef,
2652
- higher,
2653
- inputRef,
2654
- listRef,
2655
- suggestionsField,
2656
- value,
2657
- visible,
2658
- setActive,
2659
- setValue,
2660
- setVisible,
2661
- navigationElement,
2662
- navigationInput
2663
- };
2664
- }
2665
-
2666
- const DURATION_ANIMATION$1 = 240;
2667
- const MAX_ELEMENTS = 6;
2668
- function RlsAutocompleteField({ suggestions, children, disabled, formControl, onSearch, onSelect, placeholder, searching, rlsTheme }) {
2669
- const [pattern, setPattern] = useState('');
2670
- const [coincidences, setCoincidences] = useState([]);
2671
- const [store, setStore] = useState({
2672
- pattern: '',
2673
- coincidences: [],
2674
- previous: null
2675
- });
2676
- const { active, boxContentRef, higher, inputRef, listRef, suggestionsField, value, visible, setActive, setValue, setVisible, navigationElement, navigationInput } = useListControl(suggestions, true);
2677
- const [changeInternal, setChangeInternal] = useState(false);
2678
- useEffect(() => {
2679
- filterSuggestions(pattern, true);
2680
- }, [suggestions]);
2681
- useEffect(() => {
2682
- filterSuggestions(pattern);
2683
- }, [pattern]);
2684
- useEffect(() => {
2685
- if (!changeInternal) {
2686
- setValue((formControl?.state &&
2687
- suggestionsField.hasElement(formControl?.state)?.description) ||
2688
- '');
2689
- }
2690
- setChangeInternal(false);
2691
- }, [formControl?.state]);
2692
- function onClickControl() {
2693
- if (!disabled) {
2694
- setVisible(true);
2695
- setTimeout(() => inputRef?.current?.focus(), DURATION_ANIMATION$1);
2696
- }
2697
- }
2698
- function onFocusInput() {
2699
- setActive(true);
2700
- }
2701
- function onBlurInput() {
2702
- setActive(false);
2703
- }
2704
- function onKeydownInput(event) {
2705
- switch (event.code) {
2706
- case 'Escape':
2707
- setVisible(false);
2708
- break;
2709
- case 'Tab':
2710
- setVisible(false);
2711
- break;
2712
- default:
2713
- navigationInput(event);
2714
- break;
2715
- }
2716
- }
2717
- function onClickAction() {
2718
- if (value) {
2719
- setVisible(false);
2720
- setValue('');
2721
- if (formControl) {
2722
- setChangeInternal(true);
2723
- formControl.setState(undefined);
2724
- }
2725
- }
2726
- else {
2727
- setVisible(true);
2728
- setTimeout(() => inputRef?.current?.focus(), DURATION_ANIMATION$1);
2729
- }
2730
- }
2731
- function onClickBackdrop() {
2732
- setVisible(false);
2733
- }
2734
- function onClickItem(element) {
2735
- return () => {
2736
- onChange(element);
2737
- };
2738
- }
2739
- function onKeydownItem(element) {
2740
- return (event) => {
2741
- switch (event.code) {
2742
- case 'Enter':
2743
- onChange(element);
2744
- break;
2745
- default:
2746
- navigationElement(event);
2747
- break;
2748
- }
2749
- };
2750
- }
2751
- function onChange(element) {
2752
- const { description, value } = element;
2753
- setVisible(false);
2754
- if (onSelect) {
2755
- onSelect(value);
2756
- }
2757
- else {
2758
- if (formControl) {
2759
- setChangeInternal(true);
2760
- formControl.setState(value);
2761
- }
2762
- setValue(description);
2763
- }
2764
- }
2765
- function filterSuggestions(pattern, reboot = false) {
2766
- if (pattern) {
2767
- const store = reboot ? createStoreEmpty() : searchForPattern(pattern);
2768
- const filters = store?.coincidences || suggestions;
2769
- const coincidences = filters.filter((element) => element.hasCoincidence(pattern));
2770
- setCoincidences(coincidences.slice(0, MAX_ELEMENTS));
2771
- setStore({
2772
- coincidences,
2773
- pattern,
2774
- previous: store
2775
- });
2776
- }
2777
- else {
2778
- setCoincidences(suggestions.slice(0, MAX_ELEMENTS));
2779
- rebootStore();
2780
- }
2781
- }
2782
- function searchForPattern(value) {
2783
- if (!store.pattern) {
2784
- return null;
2785
- }
2786
- let newStore = store;
2787
- let search = false;
2788
- while (!search && newStore) {
2789
- search = hasPattern(value, newStore.pattern, true);
2790
- if (!search) {
2791
- newStore = newStore.previous;
2792
- }
2793
- }
2794
- return newStore || rebootStore();
2795
- }
2796
- function rebootStore() {
2797
- const newStore = createStoreEmpty();
2798
- setStore(newStore);
2799
- return newStore;
2800
- }
2801
- function createStoreEmpty() {
2802
- return {
2803
- coincidences: undefined,
2804
- pattern: '',
2805
- previous: null
2806
- };
2807
- }
2808
- return (jsxRuntimeExports.jsxs("div", { ref: boxContentRef, className: 'rls-autocomplete-field rls-list-field ' +
2809
- renderClassStatus('rls-box-field', {
2810
- disabled,
2811
- active,
2812
- selected: !!value
2813
- }), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-box-field__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntimeExports.jsx("label", { className: "rls-list-field__control", onClick: onClickControl, children: value ? (jsxRuntimeExports.jsx("span", { className: "rls-list-field__control__description", children: value })) : (jsxRuntimeExports.jsx("span", { className: "rls-list-field__control__placeholder", children: placeholder })) }), jsxRuntimeExports.jsx("button", { className: "rls-list-field__action", disabled: disabled, onClick: onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'list' }) })] }) }), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-list-field__suggestions', {
2814
- visible,
2815
- hide: !visible,
2816
- higher
2817
- }), children: [jsxRuntimeExports.jsxs("ul", { ref: listRef, className: "rls-list-field__ul", children: [jsxRuntimeExports.jsxs("div", { className: "rls-list-field__ul__search", children: [jsxRuntimeExports.jsx("input", { ref: inputRef, className: "rls-list-field__ul__control", type: "text", value: pattern, onChange: ({ target: { value } }) => {
2818
- setPattern(value);
2819
- }, disabled: disabled || searching, onFocus: onFocusInput, onBlur: onBlurInput, onKeyDown: onKeydownInput }), onSearch && (jsxRuntimeExports.jsx("button", { disabled: disabled || searching, onClick: () => {
2820
- onSearch(pattern);
2821
- }, children: jsxRuntimeExports.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntimeExports.jsx(RlsProgressBar, { indeterminate: true }), coincidences.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick: onClickItem(element), onKeyDown: onKeydownItem(element), children: jsxRuntimeExports.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title }) }, index))), !coincidences.length && (jsxRuntimeExports.jsx("li", { className: "rls-list-field__empty", children: jsxRuntimeExports.jsxs("div", { className: "rls-list-field__empty__description", children: [jsxRuntimeExports.jsx("label", { className: "label-bold truncate", children: "Selecci\u00F3n no disponible" }), jsxRuntimeExports.jsx("label", { className: "caption-regular", children: "Lo sentimos, en el momento no hay elementos en el listado" })] }) }))] }), jsxRuntimeExports.jsx("div", { className: "rls-list-field__backdrop", onClick: onClickBackdrop })] })] }));
2822
- }
2823
-
2824
- function RlsCard({ children, outline, rlsTheme }) {
2825
- return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-card', { outline }), "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-card__content", children: children }) }));
2826
- }
2827
-
2828
- class ConfirmationResult extends PartialSealed {
2829
- static approved() {
2830
- return new ConfirmationResult('approved');
2831
- }
2832
- static reject() {
2833
- return new ConfirmationResult('reject');
2834
- }
2835
- }
2836
- function RlsConfirmation({ approved, content, reject, rlsTheme, subtitle, title, visible }) {
2837
- 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__header__title", children: title })), subtitle && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__header__subtitle", children: subtitle }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__body", children: content && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__body__content", children: content })) }), (approved || reject) && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__footer__actions", children: [approved && (jsxRuntimeExports.jsx(RlsButton, { type: "raised", onClick: () => {
2838
- if (approved.onClick) {
2839
- approved.onClick();
2840
- }
2841
- }, children: approved.label })), reject && (jsxRuntimeExports.jsx(RlsButton, { type: "outline", onClick: () => {
2842
- if (reject.onClick) {
2843
- reject.onClick();
2844
- }
2845
- }, children: reject.label }))] }) }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__backdrop" })] }));
2846
- }
2847
- function useConfirmationService() {
2848
- const [config, setConfig] = useState({});
2849
- const [visible, setVisible] = useState(false);
2850
- const rlsConfirmation = ReactDOM.createPortal(jsxRuntimeExports.jsx(RlsConfirmation, { ...config, visible: visible }), document.body);
2851
- function confirmation(config) {
2852
- return new Promise((resolve) => {
2853
- const { content, rlsTheme, subtitle, title, approved, reject } = config;
2854
- setConfig({
2855
- content,
2856
- rlsTheme,
2857
- subtitle,
2858
- title,
2859
- approved: {
2860
- label: approved || 'Aceptar',
2861
- onClick: () => {
2862
- setVisible(false);
2863
- resolve(ConfirmationResult.approved());
2864
- }
2865
- },
2866
- reject: reject
2867
- ? {
2868
- label: reject,
2869
- onClick: () => {
2870
- setVisible(false);
2871
- resolve(ConfirmationResult.reject());
2872
- }
2873
- }
2874
- : undefined
2875
- });
2876
- setVisible(true);
2877
- });
2878
- }
2879
- return {
2880
- RlsConfirmation: rlsConfirmation,
2881
- confirmation
2882
- };
2883
- }
2884
-
2885
- function RlsDatatableHeader({ children }) {
2886
- return jsxRuntimeExports.jsx("tr", { className: "rls-datatable__header", children: children });
2887
- }
2888
- function RlsDatatableTitle({ children, className, control }) {
2889
- return (jsxRuntimeExports.jsx("th", { className: `${className} ` + renderClassStatus('rls-datatable__title', { control }), children: children }));
2890
- }
2891
- function RlsDatatableData({ children, className }) {
2892
- return jsxRuntimeExports.jsx("tr", { className: `rls-datatable__data ${className}`, children: children });
2893
- }
2894
- function RlsDatatableCell({ children, className, control }) {
2895
- return (jsxRuntimeExports.jsx("th", { className: `${className} ` + renderClassStatus('rls-datatable__cell', { control }), children: children }));
2896
- }
2897
- function RlsDatatable({ children, footer, header, rlsTheme }) {
2898
- return (jsxRuntimeExports.jsxs("div", { className: "rls-datatable", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("table", { children: [header && jsxRuntimeExports.jsx("thead", { className: "rls-datatable__thead", children: header }), jsxRuntimeExports.jsx("tbody", { className: "rls-datatable__tbody", children: children })] }), footer && jsxRuntimeExports.jsx("div", { className: "rls-datatable__tfooter", children: footer })] }));
2899
- }
2900
-
2901
- var PickerListenerType;
2902
- (function (PickerListenerType) {
2903
- PickerListenerType["Select"] = "PickerSelect";
2904
- PickerListenerType["Now"] = "PickerNow";
2905
- PickerListenerType["Cancel"] = "PickerCancel";
2906
- })(PickerListenerType || (PickerListenerType = {}));
2907
-
2908
- function verifyDateRange(date, min, max) {
2909
- return min && isBefore(min, date)
2910
- ? min
2911
- : max && isAfter(max, date)
2912
- ? max
2913
- : date;
2914
- }
2915
-
2916
- const FORMAT_DESCRIPTION = 'dw, mx dd de aa';
2917
- const VISIBILITY_STATE$1 = {
2918
- month: false,
2919
- day: false,
2920
- year: false
2921
- };
2922
- const VISIBILITY$1 = {
2923
- DAY: {
2924
- ...VISIBILITY_STATE$1,
2925
- day: true
2926
- },
2927
- MONTH: {
2928
- ...VISIBILITY_STATE$1,
2929
- month: true
2930
- },
2931
- YEAR: {
2932
- ...VISIBILITY_STATE$1,
2933
- year: true
2934
- }
2935
- };
2936
- function RlsDatePicker({ automatic, date, formControl, disabled, maxDate, minDate, onListener, rlsTheme }) {
2937
- const dateInitial = formControl?.state || date || new Date();
2938
- const yearControl = useReactControl({ state: dateInitial.getFullYear() });
2939
- const dayControl = useReactControl({ state: dateInitial.getDate() });
2940
- const monthControl = useReactControl({ state: dateInitial.getMonth() });
2941
- const [value, setValue] = useState(dateInitial);
2942
- const [{ day, month, year }, setVisibility] = useState(VISIBILITY$1.DAY);
2943
- const title = formatDate(value, FORMAT_DESCRIPTION);
2944
- useEffect(() => {
2945
- setValue((prevValue) => {
2946
- return typeof yearControl.state === 'number'
2947
- ? verifyDateRange(refactorYear(prevValue, yearControl.state), minDate, maxDate)
2948
- : prevValue;
2949
- });
2950
- setVisibility(VISIBILITY$1.DAY);
2951
- }, [yearControl.state]);
2952
- useEffect(() => {
2953
- setValue((prevValue) => {
2954
- return typeof monthControl.state === 'number'
2955
- ? verifyDateRange(refactorMonth(prevValue, monthControl.state), minDate, maxDate)
2956
- : prevValue;
2957
- });
2958
- setVisibility(VISIBILITY$1.DAY);
2959
- }, [monthControl.state]);
2960
- useEffect(() => {
2961
- setValue((prevValue) => {
2962
- return typeof dayControl.state === 'number'
2963
- ? verifyDateRange(refactorDay(prevValue, dayControl.state), minDate, maxDate)
2964
- : prevValue;
2965
- });
2966
- }, [dayControl.state]);
2967
- function onVisibilityDay() {
2968
- setVisibility(VISIBILITY$1.DAY);
2969
- }
2970
- function onVisibilityMonth() {
2971
- setVisibility(VISIBILITY$1.MONTH);
2972
- }
2973
- function onVisibilityYear() {
2974
- setVisibility(VISIBILITY$1.YEAR);
2975
- }
2976
- function onCancel() {
2977
- if (onListener) {
2978
- onListener({ type: PickerListenerType.Cancel });
2979
- }
2980
- }
2981
- function onToday() {
2982
- const value = new Date(); // Today date
2983
- formControl?.setState(value);
2984
- setValue(value);
2985
- yearControl.setState(value.getFullYear());
2986
- dayControl.setState(value.getDate());
2987
- monthControl.setState(value.getMonth());
2988
- if (onListener) {
2989
- onListener({ type: PickerListenerType.Now, value });
2990
- }
2991
- }
2992
- function onSelect() {
2993
- formControl?.setState(value);
2994
- if (onListener) {
2995
- onListener({ type: PickerListenerType.Select, value });
2996
- }
2997
- }
2998
- return (jsxRuntimeExports.jsxs("div", { className: "rls-date-picker", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-date-picker__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-date-picker__title rls-date-picker__title--description", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: title }) }), jsxRuntimeExports.jsx("div", { className: "rls-date-picker__title rls-date-picker__title--year", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityYear, children: yearControl.value }) }), jsxRuntimeExports.jsx(RlsMonthTitlePicker, { monthControl: monthControl, yearControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, onClick: onVisibilityMonth })] }), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-date-picker__component', {
2999
- year,
3000
- day,
3001
- month
3002
- }), children: [jsxRuntimeExports.jsx(RlsDayPicker, { formControl: dayControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsMonthPicker, { formControl: monthControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsYearPicker, { formControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: disabled })] }), jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-date-picker__footer', { automatic }), children: jsxRuntimeExports.jsxs("div", { className: "rls-date-picker__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-date-picker__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: "Cancelar" }) }), jsxRuntimeExports.jsx("div", { className: "rls-date-picker__actions--today", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onToday, children: "Hoy" }) }), jsxRuntimeExports.jsx("div", { className: "rls-date-picker__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "raised", onClick: onSelect, children: "Establecer" }) })] }) })] }));
3003
- }
3004
-
3005
- function RlsModal({ children, visible, rlsTheme }) {
3006
- 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);
3007
- }
3008
-
3009
- function RlsDateField({ children, date, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
3010
- const dateInitial = formControl?.state || date || new Date();
3011
- const [value, setValue] = useState(dateInitial);
3012
- const [show, setShow] = useState(false);
3013
- const [description, setDescription] = useState('');
3014
- useEffect(() => {
3015
- setDescription(value ? formatDate(value, 'dd/mx/aa') : '');
3016
- }, [value]);
3017
- function onClickInput() {
3018
- setShow(true);
3019
- }
3020
- function onClean() {
3021
- if (value) {
3022
- formControl?.setState(undefined);
3023
- setValue(undefined);
3024
- }
3025
- else {
3026
- setShow(true);
3027
- }
3028
- }
3029
- return (jsxRuntimeExports.jsxs("div", { className: "rls-date-field", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-box-field", children: [children && jsxRuntimeExports.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-box-field__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-date-field__control", type: "text", value: description, readOnly: true, placeholder: placeholder, onClick: onClickInput }), jsxRuntimeExports.jsx("button", { className: "rls-date-field__action", onClick: onClean, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) })] }), jsxRuntimeExports.jsx(RlsModal, { visible: show, children: jsxRuntimeExports.jsx(RlsDatePicker, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
3030
- if (value) {
3031
- setValue(value);
3032
- }
3033
- setShow(false);
3034
- } }) })] }));
3035
- }
3036
-
3037
- const VISIBILITY_STATE = {
3038
- month: false,
3039
- day: false,
3040
- year: false
3041
- };
3042
- const VISIBILITY = {
3043
- DAY: {
3044
- ...VISIBILITY_STATE,
3045
- day: true
3046
- },
3047
- MONTH: {
3048
- ...VISIBILITY_STATE,
3049
- month: true
3050
- },
3051
- YEAR: {
3052
- ...VISIBILITY_STATE,
3053
- year: true
3054
- }
3055
- };
3056
- function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, rlsTheme, onListener }) {
3057
- const dateInitial = normalizeMinTime(datePicker || new Date());
3058
- const rangeInitial = formControl?.state || DateRange.now();
3059
- const yearControl = useReactControl({ state: dateInitial.getFullYear() });
3060
- const monthControl = useReactControl({ state: dateInitial.getMonth() });
3061
- const dayControl = useReactControl({ state: rangeInitial });
3062
- const [value, setValue] = useState(rangeInitial);
3063
- const [date, setDate] = useState(dateInitial);
3064
- const [{ day, month, year }, setVisibility] = useState(VISIBILITY.DAY);
3065
- useEffect(() => {
3066
- setDate((prevValue) => {
3067
- return typeof yearControl.state === 'number'
3068
- ? refactorYear(prevValue, yearControl.state)
3069
- : prevValue;
3070
- });
3071
- setVisibility(VISIBILITY.DAY);
3072
- }, [yearControl.state]);
3073
- useEffect(() => {
3074
- setDate((prevValue) => {
3075
- return typeof monthControl.state === 'number'
3076
- ? refactorMonth(prevValue, monthControl.state)
3077
- : prevValue;
3078
- });
3079
- setVisibility(VISIBILITY.DAY);
3080
- }, [monthControl.state]);
3081
- useEffect(() => {
3082
- if (dayControl.state) {
3083
- setValue(dayControl.state);
3084
- }
3085
- setVisibility(VISIBILITY.DAY);
3086
- }, [dayControl.state]);
3087
- function onVisibilityDay() {
3088
- setVisibility(VISIBILITY.DAY);
3089
- }
3090
- function onVisibilityMonth() {
3091
- setVisibility(VISIBILITY.MONTH);
3092
- }
3093
- function onVisibilityYear() {
3094
- setVisibility(VISIBILITY.YEAR);
3095
- }
3096
- function onCancel() {
3097
- if (onListener) {
3098
- onListener({ type: PickerListenerType.Cancel });
3099
- }
3100
- }
3101
- function onSelect() {
3102
- formControl?.setState(value);
3103
- if (onListener) {
3104
- onListener({ type: PickerListenerType.Select, value });
3105
- }
3106
- }
3107
- return (jsxRuntimeExports.jsxs("div", { className: "rls-date-range-picker", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-date-range-picker__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-date-range-picker__title rls-date-range-picker__title--description", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: value.description }) }), jsxRuntimeExports.jsx("div", { className: "rls-date-range-picker__title rls-date-range-picker__title--year", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityYear, children: yearControl.state }) }), jsxRuntimeExports.jsx(RlsMonthTitlePicker, { monthControl: monthControl, yearControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, onClick: onVisibilityMonth })] }), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-date-range-picker__component', {
3108
- year,
3109
- day,
3110
- month
3111
- }), children: [jsxRuntimeExports.jsx(RlsDayRangePicker, { formControl: dayControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsMonthPicker, { formControl: monthControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsYearPicker, { formControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled })] }), jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-date-range-picker__footer', {
3112
- automatic
3113
- }), children: jsxRuntimeExports.jsxs("div", { className: "rls-date-range-picker__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-date-range-picker__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: "Cancelar" }) }), jsxRuntimeExports.jsx("div", { className: "rls-date-range-picker__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "raised", onClick: onSelect, children: "Establecer" }) })] }) })] }));
3114
- }
3115
-
3116
- function RlsDateRangeField({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
3117
- const rangeInitial = formControl?.state || DateRange.now();
3118
- const dateInitial = datePicker || new Date();
3119
- const [value, setValue] = useState(rangeInitial);
3120
- const [date] = useState(dateInitial);
3121
- const [show, setShow] = useState(false);
3122
- const [description, setDescription] = useState('');
3123
- useEffect(() => {
3124
- setDescription(value?.description || '');
3125
- }, [value]);
3126
- function onClickInput() {
3127
- setShow(true);
3128
- }
3129
- function onClickAction() {
3130
- if (value) {
3131
- formControl?.setState(undefined);
3132
- setValue(undefined);
3133
- }
3134
- else {
3135
- setShow(true);
3136
- }
3137
- }
3138
- return (jsxRuntimeExports.jsxs("div", { className: "rls-date-field", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-box-field", children: [children && jsxRuntimeExports.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-box-field__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-date-field__control", type: "text", value: description, readOnly: true, placeholder: placeholder, onClick: onClickInput }), jsxRuntimeExports.jsx("button", { className: "rls-date-field__action", onClick: onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) })] }), jsxRuntimeExports.jsx(RlsModal, { visible: show, children: jsxRuntimeExports.jsx(RlsDateRangePicker, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
3139
- if (value) {
3140
- setValue(value);
3141
- }
3142
- setShow(false);
3143
- } }) })] }));
3144
- }
3145
-
3146
- function RlsFormNavigation({ children, visible, rlsTheme }) {
3147
- return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-form-navigation', { visible }), "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-form-navigation__body", children: children }) }));
3148
- }
3149
-
3150
- function RlsSelectField({ suggestions, children, disabled, formControl, onSelect, placeholder, rlsTheme }) {
3151
- const { active, boxContentRef, higher, inputRef, listRef, suggestionsField, value, visible, setActive, setValue, setVisible, navigationElement, navigationInput } = useListControl(suggestions);
3152
- const [changeInternal, setChangeInternal] = useState(false);
3153
- useEffect(() => {
3154
- if (!changeInternal) {
3155
- setValue((formControl?.state &&
3156
- suggestionsField.hasElement(formControl?.state)?.description) ||
3157
- '');
3158
- }
3159
- setChangeInternal(false);
3160
- }, [formControl?.state]);
3161
- function onFocusInput() {
3162
- setActive(true);
3163
- }
3164
- function onBlurInput() {
3165
- setActive(false);
3166
- }
3167
- function onClickInput() {
3168
- setVisible(true);
3169
- }
3170
- function onKeydownInput(event) {
3171
- switch (event.code) {
3172
- case 'Space':
3173
- setVisible(true);
3174
- break;
3175
- case 'Enter':
3176
- setVisible(true);
3177
- break;
3178
- case 'Escape':
3179
- setVisible(false);
3180
- break;
3181
- case 'Tab':
3182
- setVisible(false);
3183
- break;
3184
- default:
3185
- navigationInput(event);
3186
- break;
3187
- }
3188
- }
3189
- function onClickAction() {
3190
- const newVisible = !visible;
3191
- setVisible(newVisible);
3192
- if (newVisible) {
3193
- inputRef?.current?.focus();
3194
- }
3195
- }
3196
- function onClickBackdrop() {
3197
- setVisible(false);
3198
- }
3199
- function onClickItem(element) {
3200
- return () => {
3201
- onChange(element);
3202
- };
3203
- }
3204
- function onKeydownItem(element) {
3205
- return (event) => {
3206
- switch (event.code) {
3207
- case 'Enter':
3208
- onChange(element);
3209
- break;
3210
- default:
3211
- navigationElement(event);
3212
- break;
3213
- }
3214
- };
3215
- }
3216
- function onChange({ description, value }) {
3217
- inputRef?.current?.focus();
3218
- setVisible(false);
3219
- if (onSelect) {
3220
- onSelect(value);
3221
- }
3222
- else {
3223
- if (formControl) {
3224
- setChangeInternal(true);
3225
- formControl.setState(value);
3226
- }
3227
- setValue(description);
3228
- }
3229
- }
3230
- return (jsxRuntimeExports.jsxs("div", { ref: boxContentRef, className: 'rls-select-field rls-list-field ' +
3231
- renderClassStatus('rls-box-field', { active, disabled }), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-box-field__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntimeExports.jsx("input", { ref: inputRef, className: "rls-list-field__control", readOnly: true, disabled: disabled, placeholder: placeholder, value: value, onFocus: onFocusInput, onBlur: onBlurInput, onClick: onClickInput, onKeyDown: onKeydownInput }), jsxRuntimeExports.jsx("button", { className: renderClassStatus('rls-list-field__action', { visible }), disabled: disabled, onClick: onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-down" }) })] }) }), jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-list-field__suggestions', {
3232
- visible,
3233
- hide: !visible,
3234
- higher
3235
- }), children: [jsxRuntimeExports.jsxs("ul", { ref: listRef, className: "rls-list-field__ul", children: [suggestions.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick: onClickItem(element), onKeyDown: onKeydownItem(element), children: jsxRuntimeExports.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title }) }, index))), !suggestions.length && (jsxRuntimeExports.jsx("li", { className: "rls-list-field__empty", children: jsxRuntimeExports.jsxs("div", { className: "rls-list-field__empty__description", children: [jsxRuntimeExports.jsx("label", { className: "label-bold truncate", children: "Selecci\u00F3n no disponible" }), jsxRuntimeExports.jsx("label", { className: "caption-regular", children: "Lo sentimos, en el momento no hay elementos en el listado" })] }) }))] }), jsxRuntimeExports.jsx("div", { className: "rls-list-field__backdrop", onClick: onClickBackdrop })] })] }));
3236
- }
3237
-
3238
- const DURATION_ANIMATION = 240;
3239
- const DURATION_CHAR = 75;
3240
- const DURATION_MAX = 9000;
3241
- const DURATION_MIN = 3000;
3242
- const DURATION_RESET = 480;
3243
- function calculateDuration({ length }) {
3244
- let duration = length * DURATION_CHAR;
3245
- if (duration < DURATION_MIN) {
3246
- duration = DURATION_MIN;
3247
- }
3248
- else if (duration > DURATION_MAX) {
3249
- duration = DURATION_MAX;
3250
- }
3251
- return duration + DURATION_RESET;
3252
- }
3253
- function RlsSnackbar({ content, icon, title, visible, rlsTheme }) {
3254
- 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("label", { className: "rls-snackbar__title", children: title }), jsxRuntimeExports.jsx("div", { className: "rls-snackbar__message", children: content })] })] }));
3255
- }
3256
- function useSnackbarService() {
3257
- const [config, setConfig] = useState({});
3258
- const [duration, setDuration] = useState(4000);
3259
- const [timeoutId, setTimeoutId] = useState();
3260
- const [visible, setVisible] = useState(false);
3261
- const rlsSnackbar = jsxRuntimeExports.jsx(RlsSnackbar, { ...config, visible: visible });
3262
- useEffect(() => {
3263
- if (visible) {
3264
- const timeoutId = setTimeout(() => {
3265
- setVisible(false);
3266
- setTimeoutId(undefined);
3267
- }, duration);
3268
- setTimeoutId(timeoutId);
3269
- }
3270
- else if (timeoutId) {
3271
- clearTimeout(timeoutId);
3272
- setTimeout(() => snackbar(config), DURATION_ANIMATION);
3273
- }
3274
- }, [visible]);
3275
- function snackbar(config) {
3276
- const { content } = config;
3277
- setConfig(config);
3278
- setDuration(calculateDuration(String(content)));
3279
- setVisible(!visible);
3280
- }
3281
- return {
3282
- RlsSnackbar: rlsSnackbar,
3283
- snackbar
3284
- };
3285
- }
3286
-
3287
- const RlsContext = createContext({
3288
- confirmation: () => {
3289
- return Promise.resolve(ConfirmationResult.approved());
3290
- },
3291
- snackbar: () => { }
3292
- });
3293
- function RlsApplication({ children }) {
3294
- const { RlsConfirmation, confirmation } = useConfirmationService();
3295
- const { RlsSnackbar, snackbar } = useSnackbarService();
3296
- return (jsxRuntimeExports.jsxs(RlsContext.Provider, { value: { confirmation, snackbar }, children: [jsxRuntimeExports.jsx("div", { className: "rls-app__body", children: children }), RlsSnackbar, RlsConfirmation] }));
3297
- }
3298
-
3299
- export { ConfirmationResult, DateRange, ListFieldSuggestions, RlsAmount, RlsApplication, RlsAutocompleteField, RlsAvatar, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxLabel, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableHeader, RlsDatatableTitle, RlsDateField, RlsDatePicker, RlsDateRangeField, RlsDateRangePicker, RlsDayPicker, RlsDayRangePicker, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputText, RlsModal, RlsMoneyField, RlsMonthPicker, RlsMonthTitlePicker, RlsNumberField, RlsPagination, RlsPasswordField, RlsPoster, RlsProgressBar, RlsRadioButton, RlsRadioButtonLabel, RlsSearchInput, RlsSelectField, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchLabel, RlsTabularText, RlsTextField, RlsToolbar, RlsYearPicker, renderClassStatus, useConfirmationService, useFormControl, useFormGroup, useInputControl, useListControl, useReactControl, useSnackbarService };
3300
- //# sourceMappingURL=lib.js.map