funda-ui 4.7.111 → 4.7.115

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.
@@ -0,0 +1,475 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("react"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define(["react"], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["RPB"] = factory(require("react"));
8
+ else
9
+ root["RPB"] = factory(root["React"]);
10
+ })(this, (__WEBPACK_EXTERNAL_MODULE__787__) => {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ 787:
16
+ /***/ ((module) => {
17
+
18
+ module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
19
+
20
+ /***/ })
21
+
22
+ /******/ });
23
+ /************************************************************************/
24
+ /******/ // The module cache
25
+ /******/ var __webpack_module_cache__ = {};
26
+ /******/
27
+ /******/ // The require function
28
+ /******/ function __webpack_require__(moduleId) {
29
+ /******/ // Check if module is in cache
30
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
31
+ /******/ if (cachedModule !== undefined) {
32
+ /******/ return cachedModule.exports;
33
+ /******/ }
34
+ /******/ // Create a new module (and put it into the cache)
35
+ /******/ var module = __webpack_module_cache__[moduleId] = {
36
+ /******/ // no module.id needed
37
+ /******/ // no module.loaded needed
38
+ /******/ exports: {}
39
+ /******/ };
40
+ /******/
41
+ /******/ // Execute the module function
42
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
43
+ /******/
44
+ /******/ // Return the exports of the module
45
+ /******/ return module.exports;
46
+ /******/ }
47
+ /******/
48
+ /************************************************************************/
49
+ /******/ /* webpack/runtime/compat get default export */
50
+ /******/ (() => {
51
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
52
+ /******/ __webpack_require__.n = (module) => {
53
+ /******/ var getter = module && module.__esModule ?
54
+ /******/ () => (module['default']) :
55
+ /******/ () => (module);
56
+ /******/ __webpack_require__.d(getter, { a: getter });
57
+ /******/ return getter;
58
+ /******/ };
59
+ /******/ })();
60
+ /******/
61
+ /******/ /* webpack/runtime/define property getters */
62
+ /******/ (() => {
63
+ /******/ // define getter functions for harmony exports
64
+ /******/ __webpack_require__.d = (exports, definition) => {
65
+ /******/ for(var key in definition) {
66
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
67
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
68
+ /******/ }
69
+ /******/ }
70
+ /******/ };
71
+ /******/ })();
72
+ /******/
73
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
74
+ /******/ (() => {
75
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
76
+ /******/ })();
77
+ /******/
78
+ /******/ /* webpack/runtime/make namespace object */
79
+ /******/ (() => {
80
+ /******/ // define __esModule on exports
81
+ /******/ __webpack_require__.r = (exports) => {
82
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
83
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
84
+ /******/ }
85
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
86
+ /******/ };
87
+ /******/ })();
88
+ /******/
89
+ /************************************************************************/
90
+ var __webpack_exports__ = {};
91
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
92
+ (() => {
93
+ __webpack_require__.r(__webpack_exports__);
94
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
95
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
96
+ /* harmony export */ });
97
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(787);
98
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
99
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
100
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
101
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
102
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
103
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
104
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
105
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
106
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
107
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
108
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
109
+ /**
110
+ * History Tracker
111
+ *
112
+ * @usage:
113
+
114
+ const App = () => {
115
+ const {
116
+ history,
117
+ forwardHistory,
118
+ currentUrl,
119
+ firstUrl,
120
+ clearHistory,
121
+ goBack
122
+ } = useHistoryTracker({
123
+ onChange: ({
124
+ isReady,
125
+ history,
126
+ forwardHistory,
127
+ currentUrl,
128
+ firstUrl,
129
+ canGoBack,
130
+ canGoForward
131
+ } : {
132
+ isReady: boolean;
133
+ history: string[];
134
+ forwardHistory: string[];
135
+ currentUrl: string;
136
+ firstUrl: string;
137
+ canGoBack: boolean;
138
+ canGoForward: boolean;
139
+ }) => {
140
+ console.log('--> onChange: ',
141
+ isReady,
142
+ history,
143
+ forwardHistory,
144
+ currentUrl,
145
+ firstUrl,
146
+ canGoBack,
147
+ canGoForward
148
+ );
149
+ }
150
+ });
151
+
152
+ return (
153
+ <div>
154
+
155
+ <div>
156
+ <h3>First URL:</h3>
157
+ <p>{firstUrl}</p>
158
+ </div>
159
+
160
+ <div>
161
+ <h3>Current URL:</h3>
162
+ <p>{currentUrl}</p>
163
+ </div>
164
+
165
+ <div>
166
+ <h3>History ({history.length}):</h3>
167
+ <ul>
168
+ {history.map((url, index) => (
169
+ <li key={index}>{url}</li>
170
+ ))}
171
+ </ul>
172
+ </div>
173
+
174
+ <div>
175
+ <h3>Forward History ({forwardHistory.length}):</h3>
176
+ <ul>
177
+ {forwardHistory.map((url, index) => (
178
+ <li key={index}>{url}</li>
179
+ ))}
180
+ </ul>
181
+ </div>
182
+
183
+
184
+
185
+ <button onClick={clearHistory}>
186
+ Clear History
187
+ </button>
188
+
189
+ <button onClick={async () => {
190
+ try {
191
+ const {
192
+ isReady,
193
+ history,
194
+ forwardHistory,
195
+ canGoBack,
196
+ canGoForward
197
+ } : {
198
+ isReady: boolean;
199
+ history: string[];
200
+ forwardHistory: string[];
201
+ canGoBack: boolean;
202
+ canGoForward: boolean;
203
+ } = await goBack();
204
+
205
+ console.log('--> goBack: ',
206
+ isReady,
207
+ history,
208
+ forwardHistory,
209
+ currentUrl,
210
+ firstUrl,
211
+ canGoBack,
212
+ canGoForward
213
+ );
214
+ } catch (error) {
215
+ console.error('Navigation failed', error);
216
+ }
217
+
218
+ }}>
219
+ Back
220
+ </button>
221
+
222
+ </div>
223
+ );
224
+ };
225
+
226
+ */
227
+
228
+ // Create a secure version of useLayoutEffect that is downgraded to useEffect when SSR
229
+ var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? react__WEBPACK_IMPORTED_MODULE_0__.useLayoutEffect : react__WEBPACK_IMPORTED_MODULE_0__.useEffect;
230
+ var useHistoryTracker = function useHistoryTracker(props) {
231
+ var onChange = props.onChange;
232
+ var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
233
+ _useState2 = _slicedToArray(_useState, 2),
234
+ isReady = _useState2[0],
235
+ setIsReady = _useState2[1];
236
+ var historyRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)([]);
237
+ var forwardHistoryRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)([]);
238
+ var firstUrlRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)('');
239
+ var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),
240
+ _useState4 = _slicedToArray(_useState3, 2),
241
+ currentUrl = _useState4[0],
242
+ setCurrentUrl = _useState4[1];
243
+ var initialize = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
244
+ if (typeof window === 'undefined') return;
245
+ var currentLocation = window.location.href;
246
+
247
+ // If the history is empty, set the first record
248
+ if (historyRef.current.length === 0) {
249
+ firstUrlRef.current = currentLocation;
250
+ historyRef.current = [currentLocation];
251
+ setCurrentUrl(currentLocation);
252
+ onChange === null || onChange === void 0 ? void 0 : onChange({
253
+ isReady: false,
254
+ history: [currentLocation],
255
+ forwardHistory: [],
256
+ currentUrl: currentLocation,
257
+ firstUrl: currentLocation,
258
+ canGoBack: false,
259
+ canGoForward: false
260
+ });
261
+ }
262
+ setIsReady(true);
263
+ }, []);
264
+ useIsomorphicLayoutEffect(function () {
265
+ initialize();
266
+ }, [initialize]);
267
+ var clearHistory = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
268
+ if (typeof window === 'undefined') return;
269
+ historyRef.current = [];
270
+ forwardHistoryRef.current = [];
271
+ firstUrlRef.current = '';
272
+ setCurrentUrl('');
273
+ onChange === null || onChange === void 0 ? void 0 : onChange({
274
+ isReady: true,
275
+ history: [],
276
+ forwardHistory: [],
277
+ currentUrl: '',
278
+ firstUrl: '',
279
+ canGoBack: false,
280
+ canGoForward: false
281
+ });
282
+ }, [onChange]); // only "onChange"
283
+
284
+ var goToHistory = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (index) {
285
+ if (typeof window === 'undefined') return;
286
+ if (index < 0 || index >= historyRef.current.length) return;
287
+ var targetUrl = historyRef.current[index];
288
+ if (targetUrl && targetUrl !== window.location.href) {
289
+ window.location.href = targetUrl;
290
+ }
291
+ }, []);
292
+ var goBack = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
293
+ if (typeof window === 'undefined') return Promise.reject('Window is undefined');
294
+ if (historyRef.current.length <= 1) return Promise.reject('Cannot go back');
295
+ return new Promise(function (resolve) {
296
+ // Moves the current URL into the forward history
297
+ var removedUrl = historyRef.current.pop();
298
+ forwardHistoryRef.current.push(removedUrl);
299
+ var newCurrentUrl = historyRef.current[historyRef.current.length - 1];
300
+ setCurrentUrl(newCurrentUrl);
301
+
302
+ // Create initial data object
303
+ var data = {
304
+ isReady: true,
305
+ history: _toConsumableArray(historyRef.current),
306
+ forwardHistory: _toConsumableArray(forwardHistoryRef.current),
307
+ currentUrl: newCurrentUrl,
308
+ firstUrl: firstUrlRef.current,
309
+ canGoBack: canGoBack(),
310
+ canGoForward: canGoForward()
311
+ };
312
+
313
+ // Notify about the history change
314
+ onChange === null || onChange === void 0 ? void 0 : onChange(data);
315
+
316
+ // Create one-time listener for popstate
317
+ var handlePopState = function handlePopState() {
318
+ // Remove the listener after it's called
319
+ window.removeEventListener('popstate', handlePopState);
320
+
321
+ // Get the final data after URL has changed
322
+ var finalData = {
323
+ isReady: true,
324
+ history: _toConsumableArray(historyRef.current),
325
+ forwardHistory: _toConsumableArray(forwardHistoryRef.current),
326
+ currentUrl: window.location.href,
327
+ firstUrl: firstUrlRef.current,
328
+ canGoBack: canGoBack(),
329
+ canGoForward: canGoForward()
330
+ };
331
+ resolve(finalData);
332
+ };
333
+
334
+ // Add the listener
335
+ window.addEventListener('popstate', handlePopState);
336
+
337
+ // Trigger the navigation
338
+ window.history.go(-1);
339
+ });
340
+ }, [onChange]);
341
+ var goForward = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
342
+ if (typeof window === 'undefined') return Promise.reject('Window is undefined');
343
+ if (forwardHistoryRef.current.length === 0) return Promise.reject('Cannot go forward');
344
+ return new Promise(function (resolve) {
345
+ // Take the URL from the forward history and add it to the main history
346
+ var nextUrl = forwardHistoryRef.current.pop();
347
+ historyRef.current.push(nextUrl);
348
+ setCurrentUrl(nextUrl);
349
+
350
+ // Create initial data object
351
+ var data = {
352
+ isReady: true,
353
+ history: _toConsumableArray(historyRef.current),
354
+ forwardHistory: _toConsumableArray(forwardHistoryRef.current),
355
+ currentUrl: nextUrl,
356
+ firstUrl: firstUrlRef.current,
357
+ canGoBack: canGoBack(),
358
+ canGoForward: canGoForward()
359
+ };
360
+ onChange === null || onChange === void 0 ? void 0 : onChange(data);
361
+
362
+ // Create one-time listener for popstate
363
+ var handlePopState = function handlePopState() {
364
+ // Remove the listener after it's called
365
+ window.removeEventListener('popstate', handlePopState);
366
+
367
+ // Get the final data after URL has changed
368
+ var finalData = {
369
+ isReady: true,
370
+ history: _toConsumableArray(historyRef.current),
371
+ forwardHistory: _toConsumableArray(forwardHistoryRef.current),
372
+ currentUrl: window.location.href,
373
+ firstUrl: firstUrlRef.current,
374
+ canGoBack: canGoBack(),
375
+ canGoForward: canGoForward()
376
+ };
377
+ resolve(finalData);
378
+ };
379
+
380
+ // Add the listener
381
+ window.addEventListener('popstate', handlePopState);
382
+
383
+ // Trigger the navigation
384
+ window.history.go(1);
385
+ });
386
+ }, [onChange]);
387
+ var canGoBack = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
388
+ return historyRef.current.length > 1;
389
+ }, []);
390
+ var canGoForward = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
391
+ return forwardHistoryRef.current.length > 0;
392
+ }, []);
393
+ var handleUrlChange = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
394
+ if (typeof window === 'undefined') return;
395
+ var newUrl = window.location.href;
396
+
397
+ // If the history is empty, set to the first URL
398
+ if (historyRef.current.length === 0) {
399
+ firstUrlRef.current = newUrl;
400
+ }
401
+
402
+ // Avoid recording the same URL
403
+ if (historyRef.current[historyRef.current.length - 1] !== newUrl) {
404
+ historyRef.current.push(newUrl);
405
+
406
+ // Clear the advance history, as new navigation invalidates the advance history
407
+ forwardHistoryRef.current = [];
408
+ setCurrentUrl(newUrl);
409
+ onChange === null || onChange === void 0 ? void 0 : onChange({
410
+ isReady: true,
411
+ history: _toConsumableArray(historyRef.current),
412
+ forwardHistory: _toConsumableArray(forwardHistoryRef.current),
413
+ currentUrl: newUrl,
414
+ firstUrl: firstUrlRef.current || newUrl,
415
+ // Make sure there is always a value
416
+ canGoBack: canGoBack(),
417
+ canGoForward: canGoForward()
418
+ });
419
+ }
420
+ }, [onChange]); // only "onChange"
421
+
422
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
423
+ if (typeof window === 'undefined') return;
424
+
425
+ // Listen for popstate events (browser forward/back)
426
+ window.addEventListener('popstate', handleUrlChange);
427
+
428
+ // Listen for hashchange events
429
+ window.addEventListener('hashchange', handleUrlChange);
430
+
431
+ // Listen for DOM and property changes
432
+ var observer = new MutationObserver(function (mutations) {
433
+ mutations.forEach(function (mutation) {
434
+ if (mutation.type === 'childList' || mutation.type === 'attributes') {
435
+ handleUrlChange();
436
+ }
437
+ });
438
+ });
439
+ observer.observe(document.body, {
440
+ childList: true,
441
+ // monitor the addition and deletion of child nodes
442
+ subtree: true,
443
+ // monitor all descendant nodes
444
+ attributes: true,
445
+ // monitor attribute changes
446
+ attributeFilter: ['href'] // only monitor changes in the href attribute
447
+ });
448
+
449
+ return function () {
450
+ window.removeEventListener('popstate', handleUrlChange);
451
+ window.removeEventListener('hashchange', handleUrlChange);
452
+ observer.disconnect();
453
+ };
454
+ }, [handleUrlChange]);
455
+ return {
456
+ isReady: isReady,
457
+ history: historyRef.current,
458
+ forwardHistory: forwardHistoryRef.current,
459
+ currentUrl: currentUrl,
460
+ firstUrl: firstUrlRef.current,
461
+ clearHistory: clearHistory,
462
+ goToHistory: goToHistory,
463
+ goBack: goBack,
464
+ goForward: goForward,
465
+ canGoBack: canGoBack,
466
+ canGoForward: canGoForward
467
+ };
468
+ };
469
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (useHistoryTracker);
470
+ })();
471
+
472
+ /******/ return __webpack_exports__;
473
+ /******/ })()
474
+ ;
475
+ });
@@ -257,6 +257,8 @@ const Stepper = forwardRef<StepperRef, StepperProps>((props, ref) => {
257
257
  '--stepper-progress-height': `${progress}%`
258
258
  } as React.CSSProperties;
259
259
  } else {
260
+
261
+ const defaultProgress = (activeIndex / (panels.length - 1)) * 100;
260
262
  const firstItem = stepItems[0] as HTMLDivElement;
261
263
  const lastItem = stepItems[stepItems.length - 1] as HTMLDivElement;
262
264
  if (!firstItem || !lastItem) return {};
@@ -269,10 +271,10 @@ const Stepper = forwardRef<StepperRef, StepperProps>((props, ref) => {
269
271
  if (!currentItem) return {};
270
272
 
271
273
  const currentCenter = currentItem.offsetLeft + (currentItem.clientWidth / 2);
272
- const progress = ((currentCenter - firstCenter) / totalWidth) * 100;
274
+ const progress = defaultProgress !== 0 && activeIndex > 0 ? defaultProgress : ((currentCenter - firstCenter) / totalWidth) * 100;
273
275
 
274
276
  return {
275
- '--stepper-progress-width': `${progress}%`
277
+ '--stepper-progress-width': `${isNaN(progress) ? 0 : progress}%`
276
278
  } as React.CSSProperties;
277
279
  }
278
280
  };