@sunggang/ui-lib 0.4.8 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/baseSwitch.esm.js CHANGED
@@ -4,6 +4,7 @@ import React__default, { useState, useCallback, useLayoutEffect, useContext, use
4
4
  import * as SwitchPrimitives from '@radix-ui/react-switch';
5
5
  import { c as cn } from './utils.esm.js';
6
6
  import { a as useFormContext, C as Controller } from './index.esm.esm.js';
7
+ import dynamic from 'next/dynamic';
7
8
  import { _ as _objectSpread2, a as _typeof, b as _defineProperty, c as _extends$1 } from './setPrototypeOf.esm.js';
8
9
  import { _ as _objectWithoutProperties, a as _slicedToArray, b as _isNativeReflectConstruct, c as _getPrototypeOf, d as _possibleConstructorReturn, m as memoizeOne, e as _inherits, f as _classCallCheck, g as _toConsumableArray, h as _createClass } from './memoize-one.esm.esm.js';
9
10
  import { keyframes, jsx, css as css$2 } from '@emotion/react';
@@ -17,6 +18,7 @@ import * as SelectPrimitive from '@radix-ui/react-select';
17
18
  import { ChevronUpIcon, ChevronDownIcon, CheckIcon } from '@radix-ui/react-icons';
18
19
  import flatpickr from 'flatpickr';
19
20
  import Mandarin from 'flatpickr/dist/l10n/zh-tw.js';
21
+ import 'flatpickr/dist/flatpickr.min.css';
20
22
 
21
23
  var _excluded$6 = [
22
24
  "defaultInputValue",
@@ -242,16 +244,16 @@ function getFrameElement(win) {
242
244
  return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
243
245
  }
244
246
 
245
- function _array_like_to_array$6(arr, len) {
247
+ function _array_like_to_array$5(arr, len) {
246
248
  if (len == null || len > arr.length) len = arr.length;
247
249
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
248
250
  return arr2;
249
251
  }
250
- function _array_with_holes$6(arr) {
252
+ function _array_with_holes$5(arr) {
251
253
  if (Array.isArray(arr)) return arr;
252
254
  }
253
255
  function _array_without_holes(arr) {
254
- if (Array.isArray(arr)) return _array_like_to_array$6(arr);
256
+ if (Array.isArray(arr)) return _array_like_to_array$5(arr);
255
257
  }
256
258
  function _define_property$5(obj, key, value) {
257
259
  if (key in obj) {
@@ -269,7 +271,7 @@ function _define_property$5(obj, key, value) {
269
271
  function _iterable_to_array(iter) {
270
272
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
271
273
  }
272
- function _iterable_to_array_limit$6(arr, i) {
274
+ function _iterable_to_array_limit$5(arr, i) {
273
275
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
274
276
  if (_i == null) return;
275
277
  var _arr = [];
@@ -293,7 +295,7 @@ function _iterable_to_array_limit$6(arr, i) {
293
295
  }
294
296
  return _arr;
295
297
  }
296
- function _non_iterable_rest$6() {
298
+ function _non_iterable_rest$5() {
297
299
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
298
300
  }
299
301
  function _non_iterable_spread() {
@@ -338,19 +340,19 @@ function _object_spread_props$5(target, source) {
338
340
  }
339
341
  return target;
340
342
  }
341
- function _sliced_to_array$6(arr, i) {
342
- return _array_with_holes$6(arr) || _iterable_to_array_limit$6(arr, i) || _unsupported_iterable_to_array$6(arr, i) || _non_iterable_rest$6();
343
+ function _sliced_to_array$5(arr, i) {
344
+ return _array_with_holes$5(arr) || _iterable_to_array_limit$5(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$5();
343
345
  }
344
346
  function _to_consumable_array(arr) {
345
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$6(arr) || _non_iterable_spread();
347
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread();
346
348
  }
347
- function _unsupported_iterable_to_array$6(o, minLen) {
349
+ function _unsupported_iterable_to_array$5(o, minLen) {
348
350
  if (!o) return;
349
- if (typeof o === "string") return _array_like_to_array$6(o, minLen);
351
+ if (typeof o === "string") return _array_like_to_array$5(o, minLen);
350
352
  var n = Object.prototype.toString.call(o).slice(8, -1);
351
353
  if (n === "Object" && o.constructor) n = o.constructor.name;
352
354
  if (n === "Map" || n === "Set") return Array.from(n);
353
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
355
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
354
356
  }
355
357
  function getCssDimensions(element) {
356
358
  var css = getComputedStyle$1(element);
@@ -576,7 +578,7 @@ function observeMove(element, onMove) {
576
578
  var resizeObserver = null;
577
579
  if (elementResize) {
578
580
  resizeObserver = new ResizeObserver(function(_ref) {
579
- var _$_ref = _sliced_to_array$6(_ref, 1), firstEntry = _$_ref[0];
581
+ var _$_ref = _sliced_to_array$5(_ref, 1), firstEntry = _$_ref[0];
580
582
  if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
581
583
  // Prevent update loops when using the `size` middleware.
582
584
  // https://github.com/floating-ui/floating-ui/issues/1740
@@ -21136,12 +21138,12 @@ var validateMsg = function(errors, item) {
21136
21138
  return errorMsg;
21137
21139
  };
21138
21140
 
21139
- /* eslint-disable react/jsx-props-no-spreading */ function _array_like_to_array$5(arr, len) {
21141
+ /* eslint-disable react/jsx-props-no-spreading */ function _array_like_to_array$4(arr, len) {
21140
21142
  if (len == null || len > arr.length) len = arr.length;
21141
21143
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
21142
21144
  return arr2;
21143
21145
  }
21144
- function _array_with_holes$5(arr) {
21146
+ function _array_with_holes$4(arr) {
21145
21147
  if (Array.isArray(arr)) return arr;
21146
21148
  }
21147
21149
  function _define_property$4(obj, key, value) {
@@ -21157,7 +21159,7 @@ function _define_property$4(obj, key, value) {
21157
21159
  }
21158
21160
  return obj;
21159
21161
  }
21160
- function _iterable_to_array_limit$5(arr, i) {
21162
+ function _iterable_to_array_limit$4(arr, i) {
21161
21163
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
21162
21164
  if (_i == null) return;
21163
21165
  var _arr = [];
@@ -21181,7 +21183,7 @@ function _iterable_to_array_limit$5(arr, i) {
21181
21183
  }
21182
21184
  return _arr;
21183
21185
  }
21184
- function _non_iterable_rest$5() {
21186
+ function _non_iterable_rest$4() {
21185
21187
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
21186
21188
  }
21187
21189
  function _object_spread$4(target) {
@@ -21223,16 +21225,16 @@ function _object_spread_props$4(target, source) {
21223
21225
  }
21224
21226
  return target;
21225
21227
  }
21226
- function _sliced_to_array$5(arr, i) {
21227
- return _array_with_holes$5(arr) || _iterable_to_array_limit$5(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$5();
21228
+ function _sliced_to_array$4(arr, i) {
21229
+ return _array_with_holes$4(arr) || _iterable_to_array_limit$4(arr, i) || _unsupported_iterable_to_array$4(arr, i) || _non_iterable_rest$4();
21228
21230
  }
21229
- function _unsupported_iterable_to_array$5(o, minLen) {
21231
+ function _unsupported_iterable_to_array$4(o, minLen) {
21230
21232
  if (!o) return;
21231
- if (typeof o === "string") return _array_like_to_array$5(o, minLen);
21233
+ if (typeof o === "string") return _array_like_to_array$4(o, minLen);
21232
21234
  var n = Object.prototype.toString.call(o).slice(8, -1);
21233
21235
  if (n === "Object" && o.constructor) n = o.constructor.name;
21234
21236
  if (n === "Map" || n === "Set") return Array.from(n);
21235
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
21237
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
21236
21238
  }
21237
21239
  // interface CityDistrictProps {
21238
21240
  // item?: {
@@ -21261,9 +21263,9 @@ var CityDistrict = function(param) {
21261
21263
  var item = param.item;
21262
21264
  var _errors_city, _errors_district;
21263
21265
  var _useFormContext = useFormContext(), register = _useFormContext.register, setValue = _useFormContext.setValue, getValues = _useFormContext.getValues, errors = _useFormContext.formState.errors;
21264
- var _useState = _sliced_to_array$5(useState(null), 2), currentCity = _useState[0], setCurrentCity = _useState[1];
21265
- var _useState1 = _sliced_to_array$5(useState(DistrictData), 1), city = _useState1[0];
21266
- var _useState2 = _sliced_to_array$5(useState([]), 2), district = _useState2[0], setDistrict = _useState2[1];
21266
+ var _useState = _sliced_to_array$4(useState(null), 2), currentCity = _useState[0], setCurrentCity = _useState[1];
21267
+ var _useState1 = _sliced_to_array$4(useState(DistrictData), 1), city = _useState1[0];
21268
+ var _useState2 = _sliced_to_array$4(useState([]), 2), district = _useState2[0], setDistrict = _useState2[1];
21267
21269
  var cityValue = getValues().city;
21268
21270
  var districtValue = getValues().district;
21269
21271
  useEffect(function() {
@@ -21399,15 +21401,15 @@ var CityDistrict = function(param) {
21399
21401
  }, v4());
21400
21402
  };
21401
21403
 
21402
- function _array_like_to_array$4(arr, len) {
21404
+ function _array_like_to_array$3(arr, len) {
21403
21405
  if (len == null || len > arr.length) len = arr.length;
21404
21406
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
21405
21407
  return arr2;
21406
21408
  }
21407
- function _array_with_holes$4(arr) {
21409
+ function _array_with_holes$3(arr) {
21408
21410
  if (Array.isArray(arr)) return arr;
21409
21411
  }
21410
- function _iterable_to_array_limit$4(arr, i) {
21412
+ function _iterable_to_array_limit$3(arr, i) {
21411
21413
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
21412
21414
  if (_i == null) return;
21413
21415
  var _arr = [];
@@ -21431,23 +21433,23 @@ function _iterable_to_array_limit$4(arr, i) {
21431
21433
  }
21432
21434
  return _arr;
21433
21435
  }
21434
- function _non_iterable_rest$4() {
21436
+ function _non_iterable_rest$3() {
21435
21437
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
21436
21438
  }
21437
- function _sliced_to_array$4(arr, i) {
21438
- return _array_with_holes$4(arr) || _iterable_to_array_limit$4(arr, i) || _unsupported_iterable_to_array$4(arr, i) || _non_iterable_rest$4();
21439
+ function _sliced_to_array$3(arr, i) {
21440
+ return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
21439
21441
  }
21440
- function _unsupported_iterable_to_array$4(o, minLen) {
21442
+ function _unsupported_iterable_to_array$3(o, minLen) {
21441
21443
  if (!o) return;
21442
- if (typeof o === "string") return _array_like_to_array$4(o, minLen);
21444
+ if (typeof o === "string") return _array_like_to_array$3(o, minLen);
21443
21445
  var n = Object.prototype.toString.call(o).slice(8, -1);
21444
21446
  if (n === "Object" && o.constructor) n = o.constructor.name;
21445
21447
  if (n === "Map" || n === "Set") return Array.from(n);
21446
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
21448
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
21447
21449
  }
21448
21450
  var BaseTemplate = function(param) {
21449
21451
  var item = param.item, file = param.file, imageUrl = param.imageUrl, field = param.field;
21450
- var _useState = _sliced_to_array$4(useState(null), 2), tempImage = _useState[0], setTempImage = _useState[1];
21452
+ var _useState = _sliced_to_array$3(useState(null), 2), tempImage = _useState[0], setTempImage = _useState[1];
21451
21453
  useEffect(function() {
21452
21454
  var fileReader;
21453
21455
  var isCancel = false;
@@ -21581,12 +21583,12 @@ var BaseTemplate = function(param) {
21581
21583
  });
21582
21584
  };
21583
21585
 
21584
- function _array_like_to_array$3(arr, len) {
21586
+ function _array_like_to_array$2(arr, len) {
21585
21587
  if (len == null || len > arr.length) len = arr.length;
21586
21588
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
21587
21589
  return arr2;
21588
21590
  }
21589
- function _array_with_holes$3(arr) {
21591
+ function _array_with_holes$2(arr) {
21590
21592
  if (Array.isArray(arr)) return arr;
21591
21593
  }
21592
21594
  function _instanceof(left, right) {
@@ -21596,7 +21598,7 @@ function _instanceof(left, right) {
21596
21598
  return left instanceof right;
21597
21599
  }
21598
21600
  }
21599
- function _iterable_to_array_limit$3(arr, i) {
21601
+ function _iterable_to_array_limit$2(arr, i) {
21600
21602
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
21601
21603
  if (_i == null) return;
21602
21604
  var _arr = [];
@@ -21620,25 +21622,25 @@ function _iterable_to_array_limit$3(arr, i) {
21620
21622
  }
21621
21623
  return _arr;
21622
21624
  }
21623
- function _non_iterable_rest$3() {
21625
+ function _non_iterable_rest$2() {
21624
21626
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
21625
21627
  }
21626
- function _sliced_to_array$3(arr, i) {
21627
- return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
21628
+ function _sliced_to_array$2(arr, i) {
21629
+ return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
21628
21630
  }
21629
- function _unsupported_iterable_to_array$3(o, minLen) {
21631
+ function _unsupported_iterable_to_array$2(o, minLen) {
21630
21632
  if (!o) return;
21631
- if (typeof o === "string") return _array_like_to_array$3(o, minLen);
21633
+ if (typeof o === "string") return _array_like_to_array$2(o, minLen);
21632
21634
  var n = Object.prototype.toString.call(o).slice(8, -1);
21633
21635
  if (n === "Object" && o.constructor) n = o.constructor.name;
21634
21636
  if (n === "Map" || n === "Set") return Array.from(n);
21635
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
21637
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
21636
21638
  }
21637
21639
  var CustomUpload = function(param) {
21638
21640
  var item = param.item, field = param.field;
21639
21641
  var imageMimeType = /image\/(png|jpg|jpeg)/i;
21640
21642
  var DEFAULT_IMAGE_SIZE_LIMIT_IN_BYTES = (item === null || item === void 0 ? void 0 : item.limitSize) || 5242880;
21641
- var _useState = _sliced_to_array$3(useState(null), 2), modal = _useState[0], setModal = _useState[1];
21643
+ var _useState = _sliced_to_array$2(useState(null), 2), modal = _useState[0], setModal = _useState[1];
21642
21644
  var hiddenFileInput = useRef(null);
21643
21645
  useEffect(function() {
21644
21646
  if (modal) {
@@ -22018,15 +22020,15 @@ var BaseSelect = function(param) {
22018
22020
  });
22019
22021
  };
22020
22022
 
22021
- function _array_like_to_array$2(arr, len) {
22023
+ function _array_like_to_array$1(arr, len) {
22022
22024
  if (len == null || len > arr.length) len = arr.length;
22023
22025
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
22024
22026
  return arr2;
22025
22027
  }
22026
- function _array_with_holes$2(arr) {
22028
+ function _array_with_holes$1(arr) {
22027
22029
  if (Array.isArray(arr)) return arr;
22028
22030
  }
22029
- function _iterable_to_array_limit$2(arr, i) {
22031
+ function _iterable_to_array_limit$1(arr, i) {
22030
22032
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
22031
22033
  if (_i == null) return;
22032
22034
  var _arr = [];
@@ -22050,27 +22052,27 @@ function _iterable_to_array_limit$2(arr, i) {
22050
22052
  }
22051
22053
  return _arr;
22052
22054
  }
22053
- function _non_iterable_rest$2() {
22055
+ function _non_iterable_rest$1() {
22054
22056
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
22055
22057
  }
22056
- function _sliced_to_array$2(arr, i) {
22057
- return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
22058
+ function _sliced_to_array$1(arr, i) {
22059
+ return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
22058
22060
  }
22059
- function _unsupported_iterable_to_array$2(o, minLen) {
22061
+ function _unsupported_iterable_to_array$1(o, minLen) {
22060
22062
  if (!o) return;
22061
- if (typeof o === "string") return _array_like_to_array$2(o, minLen);
22063
+ if (typeof o === "string") return _array_like_to_array$1(o, minLen);
22062
22064
  var n = Object.prototype.toString.call(o).slice(8, -1);
22063
22065
  if (n === "Object" && o.constructor) n = o.constructor.name;
22064
22066
  if (n === "Map" || n === "Set") return Array.from(n);
22065
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
22067
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
22066
22068
  }
22067
22069
  var DropdownList = function(param) {
22068
22070
  var item = param.item, onUtilsReady = param.onUtilsReady;
22069
22071
  var _item_option, _item_validateOption, _errors_funeralLocation;
22070
22072
  var _useFormContext = useFormContext(), control = _useFormContext.control, errors = _useFormContext.formState.errors;
22071
22073
  var dropdownRef = useRef(null);
22072
- var _useState = _sliced_to_array$2(useState(""), 2), query = _useState[0], setQuery = _useState[1];
22073
- var _useState1 = _sliced_to_array$2(useState(false), 2), open = _useState1[0], setOpen = _useState1[1];
22074
+ var _useState = _sliced_to_array$1(useState(""), 2), query = _useState[0], setQuery = _useState[1];
22075
+ var _useState1 = _sliced_to_array$1(useState(false), 2), open = _useState1[0], setOpen = _useState1[1];
22074
22076
  var filtered = (item === null || item === void 0 ? void 0 : (_item_option = item.option) === null || _item_option === void 0 ? void 0 : _item_option.filter(function(opt) {
22075
22077
  var _opt_name;
22076
22078
  return opt === null || opt === void 0 ? void 0 : (_opt_name = opt.name) === null || _opt_name === void 0 ? void 0 : _opt_name.toLowerCase().includes(query.toLowerCase());
@@ -22322,7 +22324,9 @@ var FlatpickrInput = /*#__PURE__*/ forwardRef(function(param, ref) {
22322
22324
  instance.close();
22323
22325
  }, 50);
22324
22326
  }
22325
- } else if (mode === "multiple" || (item === null || item === void 0 ? void 0 : item.flatpickrType) === "time") ; else {
22327
+ } else if (mode === "multiple" || (item === null || item === void 0 ? void 0 : item.flatpickrType) === "time") {
22328
+ onChange(selectedDates);
22329
+ } else {
22326
22330
  // Single mode: 返回單一日期,預設行為會自動關閉
22327
22331
  onChange(selectedDates.length > 0 ? selectedDates[0] : null);
22328
22332
  }
@@ -22399,7 +22403,8 @@ var FlatpickrInput = /*#__PURE__*/ forwardRef(function(param, ref) {
22399
22403
  placeholder: (item === null || item === void 0 ? void 0 : item.placeholder) || "請選擇日期",
22400
22404
  style: item === null || item === void 0 ? void 0 : item.style,
22401
22405
  disabled: isDisabled,
22402
- readOnly: true
22406
+ readOnly: true,
22407
+ autoComplete: "off"
22403
22408
  }),
22404
22409
  (item === null || item === void 0 ? void 0 : item.icon) && /*#__PURE__*/ jsx$1("div", {
22405
22410
  className: "absolute right-3 top-1/2 transform -translate-y-1/2 pointer-events-none",
@@ -22454,319 +22459,6 @@ var FlatpickrField = function(param) {
22454
22459
  });
22455
22460
  };
22456
22461
 
22457
- function _array_like_to_array$1(arr, len) {
22458
- if (len == null || len > arr.length) len = arr.length;
22459
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
22460
- return arr2;
22461
- }
22462
- function _array_with_holes$1(arr) {
22463
- if (Array.isArray(arr)) return arr;
22464
- }
22465
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
22466
- try {
22467
- var info = gen[key](arg);
22468
- var value = info.value;
22469
- } catch (error) {
22470
- reject(error);
22471
- return;
22472
- }
22473
- if (info.done) {
22474
- resolve(value);
22475
- } else {
22476
- Promise.resolve(value).then(_next, _throw);
22477
- }
22478
- }
22479
- function _async_to_generator(fn) {
22480
- return function() {
22481
- var self = this, args = arguments;
22482
- return new Promise(function(resolve, reject) {
22483
- var gen = fn.apply(self, args);
22484
- function _next(value) {
22485
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22486
- }
22487
- function _throw(err) {
22488
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
22489
- }
22490
- _next(undefined);
22491
- });
22492
- };
22493
- }
22494
- function _iterable_to_array_limit$1(arr, i) {
22495
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
22496
- if (_i == null) return;
22497
- var _arr = [];
22498
- var _n = true;
22499
- var _d = false;
22500
- var _s, _e;
22501
- try {
22502
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
22503
- _arr.push(_s.value);
22504
- if (i && _arr.length === i) break;
22505
- }
22506
- } catch (err) {
22507
- _d = true;
22508
- _e = err;
22509
- } finally{
22510
- try {
22511
- if (!_n && _i["return"] != null) _i["return"]();
22512
- } finally{
22513
- if (_d) throw _e;
22514
- }
22515
- }
22516
- return _arr;
22517
- }
22518
- function _non_iterable_rest$1() {
22519
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
22520
- }
22521
- function _sliced_to_array$1(arr, i) {
22522
- return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
22523
- }
22524
- function _unsupported_iterable_to_array$1(o, minLen) {
22525
- if (!o) return;
22526
- if (typeof o === "string") return _array_like_to_array$1(o, minLen);
22527
- var n = Object.prototype.toString.call(o).slice(8, -1);
22528
- if (n === "Object" && o.constructor) n = o.constructor.name;
22529
- if (n === "Map" || n === "Set") return Array.from(n);
22530
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
22531
- }
22532
- function _ts_generator(thisArg, body) {
22533
- var f, y, t, g, _ = {
22534
- label: 0,
22535
- sent: function() {
22536
- if (t[0] & 1) throw t[1];
22537
- return t[1];
22538
- },
22539
- trys: [],
22540
- ops: []
22541
- };
22542
- return g = {
22543
- next: verb(0),
22544
- "throw": verb(1),
22545
- "return": verb(2)
22546
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
22547
- return this;
22548
- }), g;
22549
- function verb(n) {
22550
- return function(v) {
22551
- return step([
22552
- n,
22553
- v
22554
- ]);
22555
- };
22556
- }
22557
- function step(op) {
22558
- if (f) throw new TypeError("Generator is already executing.");
22559
- while(_)try {
22560
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
22561
- if (y = 0, t) op = [
22562
- op[0] & 2,
22563
- t.value
22564
- ];
22565
- switch(op[0]){
22566
- case 0:
22567
- case 1:
22568
- t = op;
22569
- break;
22570
- case 4:
22571
- _.label++;
22572
- return {
22573
- value: op[1],
22574
- done: false
22575
- };
22576
- case 5:
22577
- _.label++;
22578
- y = op[1];
22579
- op = [
22580
- 0
22581
- ];
22582
- continue;
22583
- case 7:
22584
- op = _.ops.pop();
22585
- _.trys.pop();
22586
- continue;
22587
- default:
22588
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
22589
- _ = 0;
22590
- continue;
22591
- }
22592
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
22593
- _.label = op[1];
22594
- break;
22595
- }
22596
- if (op[0] === 6 && _.label < t[1]) {
22597
- _.label = t[1];
22598
- t = op;
22599
- break;
22600
- }
22601
- if (t && _.label < t[2]) {
22602
- _.label = t[2];
22603
- _.ops.push(op);
22604
- break;
22605
- }
22606
- if (t[2]) _.ops.pop();
22607
- _.trys.pop();
22608
- continue;
22609
- }
22610
- op = body.call(thisArg, _);
22611
- } catch (e) {
22612
- op = [
22613
- 6,
22614
- e
22615
- ];
22616
- y = 0;
22617
- } finally{
22618
- f = t = 0;
22619
- }
22620
- if (op[0] & 5) throw op[1];
22621
- return {
22622
- value: op[0] ? op[1] : void 0,
22623
- done: true
22624
- };
22625
- }
22626
- }
22627
- // 動態組件載入映射表 - 使用 webpack 魔法註釋進行條件載入
22628
- var componentLoaders = {
22629
- ckEditor: /*#__PURE__*/ _async_to_generator(function() {
22630
- var module;
22631
- return _ts_generator(this, function(_state) {
22632
- switch(_state.label){
22633
- case 0:
22634
- return [
22635
- 4,
22636
- import(/* webpackChunkName: "ck-editor" */ /* webpackPreload: false */ './BaseCkeditor.esm.js')
22637
- ];
22638
- case 1:
22639
- module = _state.sent();
22640
- return [
22641
- 2,
22642
- module.default || module
22643
- ];
22644
- }
22645
- });
22646
- })
22647
- };
22648
- // 分析配置中實際使用的類型
22649
- function analyzeUsedTypes(formConfig) {
22650
- var usedTypes = new Set();
22651
- var traverseConfig = function(items) {
22652
- if (Array.isArray(items)) {
22653
- if (items.length > 0 && Array.isArray(items[0])) {
22654
- // 這是 FormItem[][]
22655
- items.forEach(function(row) {
22656
- return traverseConfig(row);
22657
- });
22658
- } else {
22659
- // 這是 FormItem[]
22660
- items.forEach(function(item) {
22661
- return traverseConfig(item);
22662
- });
22663
- }
22664
- } else if (items && typeof items === "object") {
22665
- if (items.type) {
22666
- usedTypes.add(items.type);
22667
- }
22668
- }
22669
- };
22670
- traverseConfig(formConfig);
22671
- return usedTypes;
22672
- }
22673
- // 動態載入 Hook
22674
- function useDynamicComponents(formConfig) {
22675
- var _useState = _sliced_to_array$1(useState({}), 2), loadedComponents = _useState[0], setLoadedComponents = _useState[1];
22676
- var _useState1 = _sliced_to_array$1(useState(true), 2), isLoading = _useState1[0], setIsLoading = _useState1[1];
22677
- useEffect(function() {
22678
- var usedTypes = analyzeUsedTypes(formConfig);
22679
- // 如果配置中沒有需要動態載入的組件,直接結束
22680
- var needToLoad = Object.keys(componentLoaders).filter(function(key) {
22681
- return usedTypes.has(key);
22682
- });
22683
- if (needToLoad.length === 0) {
22684
- setIsLoading(false);
22685
- return;
22686
- }
22687
- // 記錄哪些組件類型需要載入
22688
- console.log("需要動態載入的組件類型:", needToLoad);
22689
- // 載入需要的組件
22690
- var loadPromises = needToLoad.map(function() {
22691
- var _ref = _async_to_generator(function(key) {
22692
- var component, error;
22693
- return _ts_generator(this, function(_state) {
22694
- switch(_state.label){
22695
- case 0:
22696
- _state.trys.push([
22697
- 0,
22698
- 2,
22699
- ,
22700
- 3
22701
- ]);
22702
- console.log("開始載入組件: ".concat(key));
22703
- return [
22704
- 4,
22705
- componentLoaders[key]()
22706
- ];
22707
- case 1:
22708
- component = _state.sent();
22709
- console.log("成功載入組件: ".concat(key));
22710
- return [
22711
- 2,
22712
- {
22713
- key: key,
22714
- component: component
22715
- }
22716
- ];
22717
- case 2:
22718
- error = _state.sent();
22719
- console.error("Failed to load component ".concat(key, ":"), error);
22720
- return [
22721
- 2,
22722
- {
22723
- key: key,
22724
- component: null
22725
- }
22726
- ];
22727
- case 3:
22728
- return [
22729
- 2
22730
- ];
22731
- }
22732
- });
22733
- });
22734
- return function(key) {
22735
- return _ref.apply(this, arguments);
22736
- };
22737
- }());
22738
- Promise.all(loadPromises).then(function(results) {
22739
- var loadedMap = {};
22740
- results.forEach(function(param) {
22741
- var key = param.key, component = param.component;
22742
- if (component) {
22743
- loadedMap[key] = component;
22744
- }
22745
- });
22746
- console.log("所有動態組件載入完成:", Object.keys(loadedMap));
22747
- setLoadedComponents(loadedMap);
22748
- setIsLoading(false);
22749
- }).catch(function(error) {
22750
- console.error("Failed to load dynamic components:", error);
22751
- setIsLoading(false);
22752
- });
22753
- }, [
22754
- formConfig
22755
- ]);
22756
- return {
22757
- loadedComponents: loadedComponents,
22758
- isLoading: isLoading
22759
- };
22760
- }
22761
- // 創建一個動態組件渲染器
22762
- function createDynamicComponent(type, loadedComponents) {
22763
- if (type === "ckEditor" && loadedComponents.ckEditor) {
22764
- return loadedComponents.ckEditor;
22765
- }
22766
- // 如果組件沒有載入,返回 null
22767
- return null;
22768
- }
22769
-
22770
22462
  /* eslint-disable react/no-array-index-key */ /* eslint-disable react/prop-types */ function _array_like_to_array(arr, len) {
22771
22463
  if (len == null || len > arr.length) len = arr.length;
22772
22464
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -22865,6 +22557,11 @@ function _unsupported_iterable_to_array(o, minLen) {
22865
22557
  if (n === "Map" || n === "Set") return Array.from(n);
22866
22558
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
22867
22559
  }
22560
+ var BaseCkeditor = dynamic(function() {
22561
+ return import('./BaseCkeditor.esm.js');
22562
+ }, {
22563
+ ssr: false
22564
+ });
22868
22565
  var TextField = function(param) {
22869
22566
  var item = param.item;
22870
22567
  var _useFormContext = useFormContext(), register = _useFormContext.register, setValue = _useFormContext.setValue, errors = _useFormContext.formState.errors;
@@ -23429,8 +23126,6 @@ var FieldLabel = function(param) {
23429
23126
  };
23430
23127
  var Fields = function(param) {
23431
23128
  var formConfig = param.formConfig, _param_fieldsClass = param.fieldsClass, fieldsClass = _param_fieldsClass === void 0 ? "gap-2" : _param_fieldsClass;
23432
- var _useDynamicComponents = useDynamicComponents(formConfig), loadedComponents = _useDynamicComponents.loadedComponents, isLoading = _useDynamicComponents.isLoading;
23433
- if (isLoading) return null;
23434
23129
  return !!(formConfig === null || formConfig === void 0 ? void 0 : formConfig.length) && (formConfig === null || formConfig === void 0 ? void 0 : formConfig.map(function(item, index) {
23435
23130
  return /*#__PURE__*/ jsx$1(StyleField, {
23436
23131
  children: /*#__PURE__*/ jsx$1("div", {
@@ -23439,8 +23134,7 @@ var Fields = function(param) {
23439
23134
  "justify-start"
23440
23135
  ].join(" "),
23441
23136
  children: /*#__PURE__*/ jsx$1(Row, {
23442
- rowItems: item,
23443
- loadedComponents: loadedComponents
23137
+ rowItems: item
23444
23138
  })
23445
23139
  })
23446
23140
  }, "mainField-".concat(index));
@@ -23490,7 +23184,7 @@ var CustomUploadField = function(param) {
23490
23184
  });
23491
23185
  };
23492
23186
  var Row = function(param) {
23493
- var rowItems = param.rowItems, _param_loadedComponents = param.loadedComponents, loadedComponents = _param_loadedComponents === void 0 ? {} : _param_loadedComponents;
23187
+ var rowItems = param.rowItems;
23494
23188
  return rowItems.map(function(item, index) {
23495
23189
  var baseConfig = {
23496
23190
  item: item
@@ -23549,16 +23243,9 @@ var Row = function(param) {
23549
23243
  key: "rowField-".concat(index)
23550
23244
  }));
23551
23245
  case "ckEditor":
23552
- {
23553
- var DynamicCkEditor = createDynamicComponent("ckEditor", loadedComponents);
23554
- if (DynamicCkEditor) {
23555
- return /*#__PURE__*/ createElement(DynamicCkEditor, _object_spread_props$1(_object_spread$1({}, baseConfig), {
23556
- key: "rowField-".concat(index)
23557
- }));
23558
- }
23559
- // 如果 CkEditor 沒有載入,顯示佔位符
23560
- return null;
23561
- }
23246
+ return /*#__PURE__*/ createElement(BaseCkeditor, _object_spread_props$1(_object_spread$1({}, baseConfig), {
23247
+ key: "rowField-".concat(index)
23248
+ }));
23562
23249
  case "upload":
23563
23250
  return /*#__PURE__*/ createElement(CustomUploadField, _object_spread_props$1(_object_spread$1({}, baseConfig), {
23564
23251
  key: "rowField-".concat(index)
@@ -23586,10 +23273,7 @@ var Form = {
23586
23273
  City: City,
23587
23274
  CityDistrict: CityDistrict,
23588
23275
  CheckboxField: CheckboxField,
23589
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23590
- BaseCkeditor: function() {
23591
- return null;
23592
- },
23276
+ BaseCkeditor: BaseCkeditor,
23593
23277
  Dropdown: DropdownList,
23594
23278
  FlatpickrField: FlatpickrField
23595
23279
  };