@sunggang/ui-lib 0.3.24 → 0.3.25

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/index.esm2.js CHANGED
@@ -17826,6 +17826,103 @@ var PrimaryDragDropImage = function(param) {
17826
17826
  });
17827
17827
  };
17828
17828
 
17829
+ var ModalContent = function(param) {
17830
+ var title = param.title, setModal = param.setModal, children = param.children, onClick = param.onClick, _param_notice = param.notice, notice = _param_notice === void 0 ? false : _param_notice;
17831
+ return /*#__PURE__*/ jsxs("form", {
17832
+ children: [
17833
+ title && /*#__PURE__*/ jsx("div", {
17834
+ className: "text-2xl text-gray-700 font-medium border-solid border-b border-gray-300 mb-4 p-4",
17835
+ children: title
17836
+ }),
17837
+ children && /*#__PURE__*/ jsx("div", {
17838
+ className: "py-4 px-8",
17839
+ children: children
17840
+ }),
17841
+ /*#__PURE__*/ jsx("div", {
17842
+ className: "flex items-center text-base p-4 px-8 justify-around",
17843
+ children: notice ? /*#__PURE__*/ jsx("button", {
17844
+ type: "button",
17845
+ className: "w-24 h-10 px-2 text-white bg-gray-600 rounded",
17846
+ onClick: setModal,
17847
+ children: "確定"
17848
+ }) : /*#__PURE__*/ jsxs(Fragment$1, {
17849
+ children: [
17850
+ /*#__PURE__*/ jsx("button", {
17851
+ type: "button",
17852
+ className: "w-24 h-10 px-2 text-white bg-gray-600 rounded",
17853
+ onClick: setModal,
17854
+ children: "取消"
17855
+ }),
17856
+ onClick && /*#__PURE__*/ jsx("button", {
17857
+ type: "button",
17858
+ className: "w-24 h-10 mx-3 text-white bg-gray-500 rounded",
17859
+ onClick: onClick,
17860
+ children: "送出"
17861
+ })
17862
+ ]
17863
+ })
17864
+ })
17865
+ ]
17866
+ });
17867
+ };
17868
+
17869
+ var ErrorContent = function(param) {
17870
+ var setModal = param.setModal, errmsg = param.errmsg;
17871
+ return /*#__PURE__*/ jsx(ModalContent, {
17872
+ setModal: setModal,
17873
+ onClick: setModal,
17874
+ notice: true,
17875
+ children: /*#__PURE__*/ jsxs("div", {
17876
+ className: "w-full max-w-xl",
17877
+ children: [
17878
+ /*#__PURE__*/ jsx("div", {
17879
+ className: "flex justify-center items-center mb-6",
17880
+ children: /*#__PURE__*/ jsx(Icon, {
17881
+ icon: "fluent-mdl2:status-error-full",
17882
+ color: "red",
17883
+ height: 60
17884
+ })
17885
+ }),
17886
+ /*#__PURE__*/ jsx("div", {
17887
+ className: "text-center text-lg text-gray-500",
17888
+ children: errmsg
17889
+ })
17890
+ ]
17891
+ })
17892
+ });
17893
+ };
17894
+
17895
+ var Modal = function(param) {
17896
+ var modal = param.modal, _param_unsetModal = param.unsetModal, unsetModal = _param_unsetModal === void 0 ? function() {} : _param_unsetModal;
17897
+ var handleKeyUp = function(e) {
17898
+ var _document_activeElement;
17899
+ if (e.key === "Escape" && ![
17900
+ "INPUT",
17901
+ "SELECT"
17902
+ ].includes((_document_activeElement = document.activeElement) === null || _document_activeElement === void 0 ? void 0 : _document_activeElement.tagName)) {
17903
+ unsetModal();
17904
+ }
17905
+ };
17906
+ useEffect(function() {
17907
+ document.addEventListener("keyup", handleKeyUp);
17908
+ return function() {
17909
+ return document.removeEventListener("keyup", handleKeyUp);
17910
+ };
17911
+ }, [
17912
+ unsetModal
17913
+ ]);
17914
+ return /*#__PURE__*/ jsx("div", {
17915
+ className: "fixed top-0 left-0 h-screen z-[2000] duration-300 transition-opacity bg-[#000000b3] w-full",
17916
+ children: /*#__PURE__*/ jsx("div", {
17917
+ className: "w-full h-full flex justify-center items-center p-6",
17918
+ children: /*#__PURE__*/ jsx("div", {
17919
+ className: "bg-white overflow-y-auto w-full m-auto max-w-[455px] rounded-xl",
17920
+ children: modal
17921
+ })
17922
+ })
17923
+ });
17924
+ };
17925
+
17829
17926
  function _array_like_to_array$n(arr, len) {
17830
17927
  if (len == null || len > arr.length) len = arr.length;
17831
17928
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -17937,15 +18034,16 @@ function _unsupported_iterable_to_array$n(o, minLen) {
17937
18034
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$n(o, minLen);
17938
18035
  }
17939
18036
  var DropImage = function(param) {
17940
- var _param_preview = param.preview, preview = _param_preview === void 0 ? true : _param_preview, setFiles = param.setFiles, imageUrls = param.imageUrls, setImageUrls = param.setImageUrls, _param_imageStyleType = param.imageStyleType, imageStyleType = _param_imageStyleType === void 0 ? "base" : _param_imageStyleType;
18037
+ var _param_preview = param.preview, preview = _param_preview === void 0 ? true : _param_preview, setFiles = param.setFiles, imageUrls = param.imageUrls, setImageUrls = param.setImageUrls, _param_imageStyleType = param.imageStyleType, imageStyleType = _param_imageStyleType === void 0 ? "base" : _param_imageStyleType, _param_limitSize = param.limitSize, limitSize = _param_limitSize === void 0 ? 0 : _param_limitSize;
17941
18038
  var _useState = _sliced_to_array$k(useState([]), 2), previewFiles = _useState[0], setPreviewFiles = _useState[1];
18039
+ var _useState1 = _sliced_to_array$k(useState(null), 2), uploadError = _useState1[0], setUploadError = _useState1[1];
17942
18040
  useEffect(function() {
17943
18041
  setPreviewFiles(imageUrls);
17944
18042
  }, [
17945
18043
  imageUrls
17946
18044
  ]);
17947
- var MAX_SIZE_2MB = 2 * 1024 * 1024;
17948
18045
  var MAX_SIZE_5MB = 5 * 1024 * 1024;
18046
+ var DEFAULT_IMAGE_SIZE_LIMIT_IN_BYTES = limitSize || MAX_SIZE_5MB;
17949
18047
  var _useDropzone = useDropzone({
17950
18048
  accept: {
17951
18049
  "image/png": [
@@ -17957,7 +18055,7 @@ var DropImage = function(param) {
17957
18055
  ]
17958
18056
  },
17959
18057
  maxFiles: 10,
17960
- maxSize: imageStyleType === "primary" ? MAX_SIZE_2MB : MAX_SIZE_5MB,
18058
+ maxSize: DEFAULT_IMAGE_SIZE_LIMIT_IN_BYTES,
17961
18059
  onDrop: function(dropFiles) {
17962
18060
  var newFiles = [];
17963
18061
  setFiles(function(prevFiles) {
@@ -17974,6 +18072,42 @@ var DropImage = function(param) {
17974
18072
  setPreviewFiles(function(prev) {
17975
18073
  return _to_consumable_array$8(prev).concat(_to_consumable_array$8(newFiles));
17976
18074
  });
18075
+ },
18076
+ onDropRejected: function(rejectedFiles) {
18077
+ var errorItems = rejectedFiles.map(function(param) {
18078
+ var file = param.file; param.errors;
18079
+ return /*#__PURE__*/ jsx("div", {
18080
+ children: /*#__PURE__*/ jsxs("div", {
18081
+ className: "text-center text-lg text-gray-500",
18082
+ children: [
18083
+ "檔案太大: ",
18084
+ file.path,
18085
+ " - ",
18086
+ (file.size / 1024 / 1024).toFixed(2),
18087
+ " MB"
18088
+ ]
18089
+ })
18090
+ }, file.path);
18091
+ });
18092
+ setUploadError(/*#__PURE__*/ jsx(ErrorContent, {
18093
+ setModal: function() {
18094
+ return setUploadError(null);
18095
+ },
18096
+ errmsg: /*#__PURE__*/ jsxs(Fragment$1, {
18097
+ children: [
18098
+ errorItems,
18099
+ /*#__PURE__*/ jsxs("div", {
18100
+ className: "pt-4",
18101
+ children: [
18102
+ "上限:",
18103
+ (DEFAULT_IMAGE_SIZE_LIMIT_IN_BYTES / 1024 / 1024).toFixed(2),
18104
+ " ",
18105
+ "MB"
18106
+ ]
18107
+ })
18108
+ ]
18109
+ })
18110
+ }));
17977
18111
  }
17978
18112
  }), getRootProps = _useDropzone.getRootProps, getInputProps = _useDropzone.getInputProps; _useDropzone.isDragActive; _useDropzone.isDragAccept; _useDropzone.isDragReject;
17979
18113
  var onDragEnd = function(result) {
@@ -17994,96 +18128,99 @@ var DropImage = function(param) {
17994
18128
  previewFiles.splice(currentItem, 1);
17995
18129
  setImageUrls(_to_consumable_array$8(previewFiles));
17996
18130
  };
17997
- return /*#__PURE__*/ jsx("section", {
18131
+ return /*#__PURE__*/ jsxs("section", {
17998
18132
  className: "w-full",
17999
- children: /*#__PURE__*/ jsxs(DragDropContext, {
18000
- onDragEnd: onDragEnd,
18001
- children: [
18002
- /*#__PURE__*/ jsxs("div", _object_spread_props$j(_object_spread$n({}, getRootProps({
18003
- className: "dropzone"
18004
- })), {
18005
- children: [
18006
- /*#__PURE__*/ jsx("input", _object_spread$n({}, getInputProps())),
18007
- /*#__PURE__*/ jsx("div", {
18008
- className: "flex justify-between",
18009
- children: imageStyleType === "primary" ? /*#__PURE__*/ jsx("div", {
18010
- className: "w-full",
18011
- children: /*#__PURE__*/ jsxs("div", {
18012
- className: "border-2 border-dashed border-[#17340929] rounded-[22px]",
18013
- children: [
18014
- /*#__PURE__*/ jsx("div", {
18015
- className: "flex justify-center",
18016
- children: /*#__PURE__*/ jsx("div", {
18017
- className: "flex justify-center mt-9 mb-2 py-3 px-6 bg-[#1A1A1A] text-white rounded-[22px] text-sm",
18018
- children: "上傳照片"
18019
- })
18020
- }),
18021
- /*#__PURE__*/ jsxs("div", {
18022
- className: "flex items-center flex-col justify-center",
18023
- children: [
18024
- /*#__PURE__*/ jsx("p", {
18025
- className: "font-normal text-sm text-[#777777] pb-4",
18026
- children: "檔案可為PNG,JPG,檔案大小須小於2M"
18027
- }),
18028
- /*#__PURE__*/ jsx("h5", {
18029
- className: "mb-2 text-xl font-bold tracking-tight text-gray-700 pb-4",
18030
- children: "拖曳圖片至此"
18133
+ children: [
18134
+ /*#__PURE__*/ jsxs(DragDropContext, {
18135
+ onDragEnd: onDragEnd,
18136
+ children: [
18137
+ /*#__PURE__*/ jsxs("div", _object_spread_props$j(_object_spread$n({}, getRootProps({
18138
+ className: "dropzone"
18139
+ })), {
18140
+ children: [
18141
+ /*#__PURE__*/ jsx("input", _object_spread$n({}, getInputProps())),
18142
+ /*#__PURE__*/ jsx("div", {
18143
+ className: "flex justify-between",
18144
+ children: imageStyleType === "primary" ? /*#__PURE__*/ jsx("div", {
18145
+ className: "w-full",
18146
+ children: /*#__PURE__*/ jsxs("div", {
18147
+ className: "border-2 border-dashed border-[#17340929] rounded-[22px]",
18148
+ children: [
18149
+ /*#__PURE__*/ jsx("div", {
18150
+ className: "flex items-center flex-col justify-center",
18151
+ children: /*#__PURE__*/ jsx("div", {
18152
+ className: "text-2xl font-medium text-[#777777] p-[30px]",
18153
+ children: "可拖曳檔案至此區域"
18154
+ })
18155
+ }),
18156
+ /*#__PURE__*/ jsx("div", {
18157
+ className: "font-normal text-[#777777] pb-2 text-center",
18158
+ children: "或用上傳按鈕選擇檔案"
18159
+ }),
18160
+ /*#__PURE__*/ jsx("div", {
18161
+ className: "flex justify-center",
18162
+ children: /*#__PURE__*/ jsx("div", {
18163
+ className: "flex justify-center mb-6 py-3 px-6 bg-[#1A1A1A] text-white rounded-[22px] text-sm",
18164
+ children: "上傳照片"
18031
18165
  })
18032
- ]
18033
- })
18034
- ]
18035
- })
18036
- }) : /*#__PURE__*/ jsx("div", {
18037
- className: "w-full bg-gray-light rounded-lg",
18038
- children: /*#__PURE__*/ jsxs("div", {
18039
- className: "border-2 border-dashed border-[#777777] rounded-lg bg-gray-100",
18040
- children: [
18041
- /*#__PURE__*/ jsx("div", {
18042
- className: "flex justify-center py-8",
18043
- children: /*#__PURE__*/ jsx(Icon, {
18044
- icon: "material-symbols:upload",
18045
- width: "2.5rem",
18046
- height: "2.5rem"
18047
18166
  })
18048
- }),
18049
- /*#__PURE__*/ jsxs("div", {
18050
- className: "flex items-center flex-col justify-center",
18051
- children: [
18052
- /*#__PURE__*/ jsx("p", {
18053
- className: "font-normal text-sm text-[#777777] pb-4",
18054
- children: "圖片僅支援 png、jpg、jpeg"
18055
- }),
18056
- /*#__PURE__*/ jsx("h5", {
18057
- className: "mb-2 text-xl font-bold tracking-tight text-gray-700 pb-4",
18058
- children: "拖曳圖片至此"
18167
+ ]
18168
+ })
18169
+ }) : /*#__PURE__*/ jsx("div", {
18170
+ className: "w-full bg-gray-light rounded-lg",
18171
+ children: /*#__PURE__*/ jsxs("div", {
18172
+ className: "border-2 border-dashed border-[#777777] rounded-lg bg-gray-100",
18173
+ children: [
18174
+ /*#__PURE__*/ jsx("div", {
18175
+ className: "flex justify-center py-8",
18176
+ children: /*#__PURE__*/ jsx(Icon, {
18177
+ icon: "material-symbols:upload",
18178
+ width: "2.5rem",
18179
+ height: "2.5rem"
18059
18180
  })
18060
- ]
18061
- })
18062
- ]
18181
+ }),
18182
+ /*#__PURE__*/ jsxs("div", {
18183
+ className: "flex items-center flex-col justify-center",
18184
+ children: [
18185
+ /*#__PURE__*/ jsx("p", {
18186
+ className: "font-normal text-sm text-[#777777] pb-4",
18187
+ children: "圖片僅支援 png、jpg、jpeg"
18188
+ }),
18189
+ /*#__PURE__*/ jsx("h5", {
18190
+ className: "mb-2 text-xl font-bold tracking-tight text-gray-700 pb-4",
18191
+ children: "拖曳圖片至此"
18192
+ })
18193
+ ]
18194
+ })
18195
+ ]
18196
+ })
18063
18197
  })
18064
18198
  })
18065
- })
18066
- ]
18067
- })),
18068
- preview && /*#__PURE__*/ jsxs("div", {
18069
- className: "flex pt-2 overflow-auto",
18070
- children: [
18071
- imageStyleType === "base" && /*#__PURE__*/ jsx(DragDropImages, {
18072
- imageUrls: previewFiles,
18073
- handleRemove: handleRemove
18074
- }),
18075
- imageStyleType === "custom" && /*#__PURE__*/ jsx(CustomDragDropImages, {
18076
- imageUrls: previewFiles,
18077
- handleRemove: handleRemove
18078
- }),
18079
- imageStyleType === "primary" && /*#__PURE__*/ jsx(PrimaryDragDropImage, {
18080
- imageUrls: previewFiles,
18081
- handleRemove: handleRemove
18082
- })
18083
- ]
18084
- })
18085
- ]
18086
- })
18199
+ ]
18200
+ })),
18201
+ preview && /*#__PURE__*/ jsxs("div", {
18202
+ className: "flex pt-2 overflow-auto",
18203
+ children: [
18204
+ imageStyleType === "base" && /*#__PURE__*/ jsx(DragDropImages, {
18205
+ imageUrls: previewFiles,
18206
+ handleRemove: handleRemove
18207
+ }),
18208
+ imageStyleType === "custom" && /*#__PURE__*/ jsx(CustomDragDropImages, {
18209
+ imageUrls: previewFiles,
18210
+ handleRemove: handleRemove
18211
+ }),
18212
+ imageStyleType === "primary" && /*#__PURE__*/ jsx(PrimaryDragDropImage, {
18213
+ imageUrls: previewFiles,
18214
+ handleRemove: handleRemove
18215
+ })
18216
+ ]
18217
+ })
18218
+ ]
18219
+ }),
18220
+ uploadError ? /*#__PURE__*/ jsx(Modal, {
18221
+ modal: uploadError
18222
+ }) : null
18223
+ ]
18087
18224
  });
18088
18225
  };
18089
18226
 
@@ -18997,103 +19134,6 @@ var DropDown = function(param) {
18997
19134
  });
18998
19135
  };
18999
19136
 
19000
- var ModalContent = function(param) {
19001
- var title = param.title, setModal = param.setModal, children = param.children, onClick = param.onClick, _param_notice = param.notice, notice = _param_notice === void 0 ? false : _param_notice;
19002
- return /*#__PURE__*/ jsxs("form", {
19003
- children: [
19004
- title && /*#__PURE__*/ jsx("div", {
19005
- className: "text-2xl text-gray-700 font-medium border-solid border-b border-gray-300 mb-4 p-4",
19006
- children: title
19007
- }),
19008
- children && /*#__PURE__*/ jsx("div", {
19009
- className: "py-4 px-8",
19010
- children: children
19011
- }),
19012
- /*#__PURE__*/ jsx("div", {
19013
- className: "flex items-center text-base p-4 px-8 justify-around",
19014
- children: notice ? /*#__PURE__*/ jsx("button", {
19015
- type: "button",
19016
- className: "w-24 h-10 px-2 text-white bg-gray-600 rounded",
19017
- onClick: setModal,
19018
- children: "確定"
19019
- }) : /*#__PURE__*/ jsxs(Fragment$1, {
19020
- children: [
19021
- /*#__PURE__*/ jsx("button", {
19022
- type: "button",
19023
- className: "w-24 h-10 px-2 text-white bg-gray-600 rounded",
19024
- onClick: setModal,
19025
- children: "取消"
19026
- }),
19027
- onClick && /*#__PURE__*/ jsx("button", {
19028
- type: "button",
19029
- className: "w-24 h-10 mx-3 text-white bg-gray-500 rounded",
19030
- onClick: onClick,
19031
- children: "送出"
19032
- })
19033
- ]
19034
- })
19035
- })
19036
- ]
19037
- });
19038
- };
19039
-
19040
- var ErrorContent = function(param) {
19041
- var setModal = param.setModal, errmsg = param.errmsg;
19042
- return /*#__PURE__*/ jsx(ModalContent, {
19043
- setModal: setModal,
19044
- onClick: setModal,
19045
- notice: true,
19046
- children: /*#__PURE__*/ jsxs("div", {
19047
- className: "w-full max-w-xl",
19048
- children: [
19049
- /*#__PURE__*/ jsx("div", {
19050
- className: "flex justify-center items-center mb-6",
19051
- children: /*#__PURE__*/ jsx(Icon, {
19052
- icon: "fluent-mdl2:status-error-full",
19053
- color: "red",
19054
- height: 60
19055
- })
19056
- }),
19057
- /*#__PURE__*/ jsx("div", {
19058
- className: "text-center text-lg text-gray-500",
19059
- children: errmsg
19060
- })
19061
- ]
19062
- })
19063
- });
19064
- };
19065
-
19066
- var Modal = function(param) {
19067
- var modal = param.modal, _param_unsetModal = param.unsetModal, unsetModal = _param_unsetModal === void 0 ? function() {} : _param_unsetModal;
19068
- var handleKeyUp = function(e) {
19069
- var _document_activeElement;
19070
- if (e.key === "Escape" && ![
19071
- "INPUT",
19072
- "SELECT"
19073
- ].includes((_document_activeElement = document.activeElement) === null || _document_activeElement === void 0 ? void 0 : _document_activeElement.tagName)) {
19074
- unsetModal();
19075
- }
19076
- };
19077
- useEffect(function() {
19078
- document.addEventListener("keyup", handleKeyUp);
19079
- return function() {
19080
- return document.removeEventListener("keyup", handleKeyUp);
19081
- };
19082
- }, [
19083
- unsetModal
19084
- ]);
19085
- return /*#__PURE__*/ jsx("div", {
19086
- className: "fixed top-0 left-0 h-screen z-[2000] transition-opacity duration-300 transition-opacity bg-[#000000b3] w-full",
19087
- children: /*#__PURE__*/ jsx("div", {
19088
- className: "w-full h-full flex justify-center items-center p-6",
19089
- children: /*#__PURE__*/ jsx("div", {
19090
- className: "bg-white rounded overflow-y-auto w-full m-auto max-w-[455px] rounded-xl",
19091
- children: modal
19092
- })
19093
- })
19094
- });
19095
- };
19096
-
19097
19137
  function _array_like_to_array$l(arr, len) {
19098
19138
  if (len == null || len > arr.length) len = arr.length;
19099
19139
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -19252,7 +19292,7 @@ function _unsupported_iterable_to_array$k(o, minLen) {
19252
19292
  var CustomUpload$1 = function(param) {
19253
19293
  var className = param.className, children = param.children, file = param.file, setFile = param.setFile, imageUrl = param.imageUrl, setImageUrl = param.setImageUrl;
19254
19294
  var imageMimeType = /image\/(png|jpg|jpeg)/i;
19255
- var DEFAULT_IMAGE_SIZE_LIMIT_IN_BYTES = 5120000; // 5000 KB
19295
+ var DEFAULT_IMAGE_SIZE_LIMIT_IN_BYTES = 5242880;
19256
19296
  var _useState = _sliced_to_array$h(useState(null), 2), modal = _useState[0], setModal = _useState[1];
19257
19297
  var hiddenFileInput = useRef(null);
19258
19298
  var handleImageClick = function() {
@@ -22214,6 +22254,357 @@ function createFormControl() {
22214
22254
  formControl: methods
22215
22255
  });
22216
22256
  }
22257
+ var generateId = function() {
22258
+ var d = typeof performance === "undefined" ? Date.now() : performance.now() * 1000;
22259
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
22260
+ var r = (Math.random() * 16 + d) % 16 | 0;
22261
+ return (c == "x" ? r : r & 0x3 | 0x8).toString(16);
22262
+ });
22263
+ };
22264
+ var getFocusFieldName = function(name, index) {
22265
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
22266
+ return options.shouldFocus || isUndefined(options.shouldFocus) ? options.focusName || "".concat(name, ".").concat(isUndefined(options.focusIndex) ? index : options.focusIndex, ".") : "";
22267
+ };
22268
+ var appendAt = function(data, value1) {
22269
+ return _to_consumable_array$6(data).concat(_to_consumable_array$6(convertToArrayPayload(value1)));
22270
+ };
22271
+ var fillEmptyArray = function(value1) {
22272
+ return Array.isArray(value1) ? value1.map(function() {
22273
+ return undefined;
22274
+ }) : undefined;
22275
+ };
22276
+ function insert(data, index, value1) {
22277
+ return _to_consumable_array$6(data.slice(0, index)).concat(_to_consumable_array$6(convertToArrayPayload(value1)), _to_consumable_array$6(data.slice(index)));
22278
+ }
22279
+ var moveArrayAt = function(data, from, to) {
22280
+ if (!Array.isArray(data)) {
22281
+ return [];
22282
+ }
22283
+ if (isUndefined(data[to])) {
22284
+ data[to] = undefined;
22285
+ }
22286
+ data.splice(to, 0, data.splice(from, 1)[0]);
22287
+ return data;
22288
+ };
22289
+ var prependAt = function(data, value1) {
22290
+ return _to_consumable_array$6(convertToArrayPayload(value1)).concat(_to_consumable_array$6(convertToArrayPayload(data)));
22291
+ };
22292
+ function removeAtIndexes(data, indexes) {
22293
+ var i = 0;
22294
+ var temp = _to_consumable_array$6(data);
22295
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
22296
+ try {
22297
+ for(var _iterator = indexes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
22298
+ var index = _step.value;
22299
+ temp.splice(index - i, 1);
22300
+ i++;
22301
+ }
22302
+ } catch (err) {
22303
+ _didIteratorError = true;
22304
+ _iteratorError = err;
22305
+ } finally{
22306
+ try {
22307
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
22308
+ _iterator.return();
22309
+ }
22310
+ } finally{
22311
+ if (_didIteratorError) {
22312
+ throw _iteratorError;
22313
+ }
22314
+ }
22315
+ }
22316
+ return compact(temp).length ? temp : [];
22317
+ }
22318
+ var removeArrayAt = function(data, index) {
22319
+ return isUndefined(index) ? [] : removeAtIndexes(data, convertToArrayPayload(index).sort(function(a, b) {
22320
+ return a - b;
22321
+ }));
22322
+ };
22323
+ var swapArrayAt = function(data, indexA, indexB) {
22324
+ var ref;
22325
+ ref = [
22326
+ data[indexB],
22327
+ data[indexA]
22328
+ ], data[indexA] = ref[0], data[indexB] = ref[1];
22329
+ };
22330
+ var updateAt = function(fieldValues, index, value1) {
22331
+ fieldValues[index] = value1;
22332
+ return fieldValues;
22333
+ };
22334
+ /**
22335
+ * A custom hook that exposes convenient methods to perform operations with a list of dynamic inputs that need to be appended, updated, removed etc. • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn) • [Video](https://youtu.be/4MrbfGSFY2A)
22336
+ *
22337
+ * @remarks
22338
+ * [API](https://react-hook-form.com/docs/usefieldarray) • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn)
22339
+ *
22340
+ * @param props - useFieldArray props
22341
+ *
22342
+ * @returns methods - functions to manipulate with the Field Arrays (dynamic inputs) {@link UseFieldArrayReturn}
22343
+ *
22344
+ * @example
22345
+ * ```tsx
22346
+ * function App() {
22347
+ * const { register, control, handleSubmit, reset, trigger, setError } = useForm({
22348
+ * defaultValues: {
22349
+ * test: []
22350
+ * }
22351
+ * });
22352
+ * const { fields, append } = useFieldArray({
22353
+ * control,
22354
+ * name: "test"
22355
+ * });
22356
+ *
22357
+ * return (
22358
+ * <form onSubmit={handleSubmit(data => console.log(data))}>
22359
+ * {fields.map((item, index) => (
22360
+ * <input key={item.id} {...register(`test.${index}.firstName`)} />
22361
+ * ))}
22362
+ * <button type="button" onClick={() => append({ firstName: "bill" })}>
22363
+ * append
22364
+ * </button>
22365
+ * <input type="submit" />
22366
+ * </form>
22367
+ * );
22368
+ * }
22369
+ * ```
22370
+ */ function useFieldArray(props) {
22371
+ var methods = useFormContext();
22372
+ var _props_control = props.control, control = _props_control === void 0 ? methods.control : _props_control, name = props.name, _props_keyName = props.keyName, keyName = _props_keyName === void 0 ? "id" : _props_keyName, shouldUnregister = props.shouldUnregister, rules = props.rules;
22373
+ var _React_useState = _sliced_to_array$g(React__default.useState(control._getFieldArray(name)), 2), fields = _React_useState[0], setFields = _React_useState[1];
22374
+ var ids = React__default.useRef(control._getFieldArray(name).map(generateId));
22375
+ var _fieldIds = React__default.useRef(fields);
22376
+ var _name = React__default.useRef(name);
22377
+ var _actioned = React__default.useRef(false);
22378
+ _name.current = name;
22379
+ _fieldIds.current = fields;
22380
+ control._names.array.add(name);
22381
+ rules && control.register(name, rules);
22382
+ React__default.useEffect(function() {
22383
+ return control._subjects.array.subscribe({
22384
+ next: function(param) {
22385
+ var values = param.values, fieldArrayName = param.name;
22386
+ if (fieldArrayName === _name.current || !fieldArrayName) {
22387
+ var fieldValues = get$2(values, _name.current);
22388
+ if (Array.isArray(fieldValues)) {
22389
+ setFields(fieldValues);
22390
+ ids.current = fieldValues.map(generateId);
22391
+ }
22392
+ }
22393
+ }
22394
+ }).unsubscribe;
22395
+ }, [
22396
+ control
22397
+ ]);
22398
+ var updateValues = React__default.useCallback(function(updatedFieldArrayValues) {
22399
+ _actioned.current = true;
22400
+ control._setFieldArray(name, updatedFieldArrayValues);
22401
+ }, [
22402
+ control,
22403
+ name
22404
+ ]);
22405
+ var append = function(value1, options) {
22406
+ var appendValue = convertToArrayPayload(cloneObject(value1));
22407
+ var updatedFieldArrayValues = appendAt(control._getFieldArray(name), appendValue);
22408
+ control._names.focus = getFocusFieldName(name, updatedFieldArrayValues.length - 1, options);
22409
+ ids.current = appendAt(ids.current, appendValue.map(generateId));
22410
+ updateValues(updatedFieldArrayValues);
22411
+ setFields(updatedFieldArrayValues);
22412
+ control._setFieldArray(name, updatedFieldArrayValues, appendAt, {
22413
+ argA: fillEmptyArray(value1)
22414
+ });
22415
+ };
22416
+ var prepend = function(value1, options) {
22417
+ var prependValue = convertToArrayPayload(cloneObject(value1));
22418
+ var updatedFieldArrayValues = prependAt(control._getFieldArray(name), prependValue);
22419
+ control._names.focus = getFocusFieldName(name, 0, options);
22420
+ ids.current = prependAt(ids.current, prependValue.map(generateId));
22421
+ updateValues(updatedFieldArrayValues);
22422
+ setFields(updatedFieldArrayValues);
22423
+ control._setFieldArray(name, updatedFieldArrayValues, prependAt, {
22424
+ argA: fillEmptyArray(value1)
22425
+ });
22426
+ };
22427
+ var remove = function(index) {
22428
+ var updatedFieldArrayValues = removeArrayAt(control._getFieldArray(name), index);
22429
+ ids.current = removeArrayAt(ids.current, index);
22430
+ updateValues(updatedFieldArrayValues);
22431
+ setFields(updatedFieldArrayValues);
22432
+ !Array.isArray(get$2(control._fields, name)) && set(control._fields, name, undefined);
22433
+ control._setFieldArray(name, updatedFieldArrayValues, removeArrayAt, {
22434
+ argA: index
22435
+ });
22436
+ };
22437
+ var insert$1 = function(index, value1, options) {
22438
+ var insertValue = convertToArrayPayload(cloneObject(value1));
22439
+ var updatedFieldArrayValues = insert(control._getFieldArray(name), index, insertValue);
22440
+ control._names.focus = getFocusFieldName(name, index, options);
22441
+ ids.current = insert(ids.current, index, insertValue.map(generateId));
22442
+ updateValues(updatedFieldArrayValues);
22443
+ setFields(updatedFieldArrayValues);
22444
+ control._setFieldArray(name, updatedFieldArrayValues, insert, {
22445
+ argA: index,
22446
+ argB: fillEmptyArray(value1)
22447
+ });
22448
+ };
22449
+ var swap = function(indexA, indexB) {
22450
+ var updatedFieldArrayValues = control._getFieldArray(name);
22451
+ swapArrayAt(updatedFieldArrayValues, indexA, indexB);
22452
+ swapArrayAt(ids.current, indexA, indexB);
22453
+ updateValues(updatedFieldArrayValues);
22454
+ setFields(updatedFieldArrayValues);
22455
+ control._setFieldArray(name, updatedFieldArrayValues, swapArrayAt, {
22456
+ argA: indexA,
22457
+ argB: indexB
22458
+ }, false);
22459
+ };
22460
+ var move = function(from, to) {
22461
+ var updatedFieldArrayValues = control._getFieldArray(name);
22462
+ moveArrayAt(updatedFieldArrayValues, from, to);
22463
+ moveArrayAt(ids.current, from, to);
22464
+ updateValues(updatedFieldArrayValues);
22465
+ setFields(updatedFieldArrayValues);
22466
+ control._setFieldArray(name, updatedFieldArrayValues, moveArrayAt, {
22467
+ argA: from,
22468
+ argB: to
22469
+ }, false);
22470
+ };
22471
+ var update = function(index, value1) {
22472
+ var updateValue = cloneObject(value1);
22473
+ var updatedFieldArrayValues = updateAt(control._getFieldArray(name), index, updateValue);
22474
+ ids.current = _to_consumable_array$6(updatedFieldArrayValues).map(function(item, i) {
22475
+ return !item || i === index ? generateId() : ids.current[i];
22476
+ });
22477
+ updateValues(updatedFieldArrayValues);
22478
+ setFields(_to_consumable_array$6(updatedFieldArrayValues));
22479
+ control._setFieldArray(name, updatedFieldArrayValues, updateAt, {
22480
+ argA: index,
22481
+ argB: updateValue
22482
+ }, true, false);
22483
+ };
22484
+ var replace = function(value1) {
22485
+ var updatedFieldArrayValues = convertToArrayPayload(cloneObject(value1));
22486
+ ids.current = updatedFieldArrayValues.map(generateId);
22487
+ updateValues(_to_consumable_array$6(updatedFieldArrayValues));
22488
+ setFields(_to_consumable_array$6(updatedFieldArrayValues));
22489
+ control._setFieldArray(name, _to_consumable_array$6(updatedFieldArrayValues), function(data) {
22490
+ return data;
22491
+ }, {}, true, false);
22492
+ };
22493
+ React__default.useEffect(function() {
22494
+ control._state.action = false;
22495
+ isWatched(name, control._names) && control._subjects.state.next(_object_spread$k({}, control._formState));
22496
+ if (_actioned.current && (!getValidationModes(control._options.mode).isOnSubmit || control._formState.isSubmitted) && !getValidationModes(control._options.reValidateMode).isOnSubmit) {
22497
+ if (control._options.resolver) {
22498
+ control._runSchema([
22499
+ name
22500
+ ]).then(function(result) {
22501
+ var error = get$2(result.errors, name);
22502
+ var existingError = get$2(control._formState.errors, name);
22503
+ if (existingError ? !error && existingError.type || error && (existingError.type !== error.type || existingError.message !== error.message) : error && error.type) {
22504
+ error ? set(control._formState.errors, name, error) : unset(control._formState.errors, name);
22505
+ control._subjects.state.next({
22506
+ errors: control._formState.errors
22507
+ });
22508
+ }
22509
+ });
22510
+ } else {
22511
+ var field = get$2(control._fields, name);
22512
+ if (field && field._f && !(getValidationModes(control._options.reValidateMode).isOnSubmit && getValidationModes(control._options.mode).isOnSubmit)) {
22513
+ validateField(field, control._names.disabled, control._formValues, control._options.criteriaMode === VALIDATION_MODE.all, control._options.shouldUseNativeValidation, true).then(function(error) {
22514
+ return !isEmptyObject(error) && control._subjects.state.next({
22515
+ errors: updateFieldArrayRootError(control._formState.errors, error, name)
22516
+ });
22517
+ });
22518
+ }
22519
+ }
22520
+ }
22521
+ control._subjects.state.next({
22522
+ name: name,
22523
+ values: cloneObject(control._formValues)
22524
+ });
22525
+ control._names.focus && iterateFieldsByAction(control._fields, function(ref, key) {
22526
+ if (control._names.focus && key.startsWith(control._names.focus) && ref.focus) {
22527
+ ref.focus();
22528
+ return 1;
22529
+ }
22530
+ return;
22531
+ });
22532
+ control._names.focus = "";
22533
+ control._setValid();
22534
+ _actioned.current = false;
22535
+ }, [
22536
+ fields,
22537
+ name,
22538
+ control
22539
+ ]);
22540
+ React__default.useEffect(function() {
22541
+ !get$2(control._formValues, name) && control._setFieldArray(name);
22542
+ return function() {
22543
+ var updateMounted = function(name, value1) {
22544
+ var field = get$2(control._fields, name);
22545
+ if (field && field._f) {
22546
+ field._f.mount = value1;
22547
+ }
22548
+ };
22549
+ control._options.shouldUnregister || shouldUnregister ? control.unregister(name) : updateMounted(name, false);
22550
+ };
22551
+ }, [
22552
+ name,
22553
+ control,
22554
+ keyName,
22555
+ shouldUnregister
22556
+ ]);
22557
+ return {
22558
+ swap: React__default.useCallback(swap, [
22559
+ updateValues,
22560
+ name,
22561
+ control
22562
+ ]),
22563
+ move: React__default.useCallback(move, [
22564
+ updateValues,
22565
+ name,
22566
+ control
22567
+ ]),
22568
+ prepend: React__default.useCallback(prepend, [
22569
+ updateValues,
22570
+ name,
22571
+ control
22572
+ ]),
22573
+ append: React__default.useCallback(append, [
22574
+ updateValues,
22575
+ name,
22576
+ control
22577
+ ]),
22578
+ remove: React__default.useCallback(remove, [
22579
+ updateValues,
22580
+ name,
22581
+ control
22582
+ ]),
22583
+ insert: React__default.useCallback(insert$1, [
22584
+ updateValues,
22585
+ name,
22586
+ control
22587
+ ]),
22588
+ update: React__default.useCallback(update, [
22589
+ updateValues,
22590
+ name,
22591
+ control
22592
+ ]),
22593
+ replace: React__default.useCallback(replace, [
22594
+ updateValues,
22595
+ name,
22596
+ control
22597
+ ]),
22598
+ fields: React__default.useMemo(function() {
22599
+ return fields.map(function(field, index) {
22600
+ return _object_spread_props$g(_object_spread$k({}, field), _define_property$l({}, keyName, ids.current[index] || generateId()));
22601
+ });
22602
+ }, [
22603
+ fields,
22604
+ keyName
22605
+ ])
22606
+ };
22607
+ }
22217
22608
  /**
22218
22609
  * Custom hook to manage the entire form.
22219
22610
  *
@@ -46990,7 +47381,7 @@ var CityDistrict = function(param) {
46990
47381
  /*#__PURE__*/ jsxs("select", _object_spread_props$a(_object_spread$d({
46991
47382
  className: [
46992
47383
  isDisabled ? "text-[#B0B0B0] bg-[#e5e7eb] cursor-not-allowed" : "bg-white text-[#6f6f6f]",
46993
- "customSelect w-full h-11 text-[15px] py-2 pr-4 rounded-lg border border-solid border-gray-300",
47384
+ "customSelect w-full h-11 text-[15px] py-2 pr-4 rounded-2xl border border-solid border-[#B4B4B4]",
46994
47385
  (item === null || item === void 0 ? void 0 : item.icon) ? "pl-14" : "pl-4"
46995
47386
  ].join(" "),
46996
47387
  style: item === null || item === void 0 ? void 0 : item.style
@@ -47018,7 +47409,7 @@ var CityDistrict = function(param) {
47018
47409
  className: "relative w-full",
47019
47410
  children: [
47020
47411
  /*#__PURE__*/ jsx("div", {
47021
- className: "absolute w-12 h-11 top-0 right-0 z-5 flex items-center justify-center rounded-r-lg pointer-events-none",
47412
+ className: "absolute w-12 h-11 top-0 right-0 z-5 flex items-center justify-center rounded-r-2xl pointer-events-none",
47022
47413
  children: !(item === null || item === void 0 ? void 0 : item.hiddenArrow) && /*#__PURE__*/ jsx(Icon, {
47023
47414
  className: "h-6 w-6",
47024
47415
  icon: "ri:arrow-down-s-line",
@@ -47028,7 +47419,7 @@ var CityDistrict = function(param) {
47028
47419
  /*#__PURE__*/ jsxs("select", _object_spread_props$a(_object_spread$d({
47029
47420
  className: [
47030
47421
  isDisabled ? "text-[#B0B0B0] bg-[#e5e7eb] cursor-not-allowed" : "bg-white text-[#6f6f6f]",
47031
- "customSelect w-full h-11 text-[15px] py-2 pr-4 rounded-lg border border-solid border-gray-300",
47422
+ "customSelect w-full h-11 text-[15px] py-2 pr-4 rounded-2xl border border-solid border-[#B4B4B4]",
47032
47423
  (item === null || item === void 0 ? void 0 : item.subIcon) ? "pl-14" : "pl-4"
47033
47424
  ].join(" "),
47034
47425
  style: item === null || item === void 0 ? void 0 : item.style
@@ -47111,7 +47502,7 @@ function _unsupported_iterable_to_array$e(o, minLen) {
47111
47502
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$e(o, minLen);
47112
47503
  }
47113
47504
  var BaseTemplate = function(param) {
47114
- var item = param.item, file = param.file, imageUrl = param.imageUrl;
47505
+ var item = param.item, file = param.file, imageUrl = param.imageUrl, field = param.field;
47115
47506
  var _useState = _sliced_to_array$b(useState(null), 2), tempImage = _useState[0], setTempImage = _useState[1];
47116
47507
  useEffect(function() {
47117
47508
  var fileReader;
@@ -47138,45 +47529,112 @@ var BaseTemplate = function(param) {
47138
47529
  ]);
47139
47530
  var imageSource = tempImage || imageUrl;
47140
47531
  var isDisabled = (item === null || item === void 0 ? void 0 : item.disabled) || (item === null || item === void 0 ? void 0 : item.disable);
47141
- return /*#__PURE__*/ jsx("div", {
47142
- className: "bg-white rounded-lg shadow-md overflow-hidden items-center",
47143
- children: /*#__PURE__*/ jsx("div", {
47144
- className: "px-4 py-6 h-56",
47145
- children: imageSource ? /*#__PURE__*/ jsx("img", {
47146
- className: [
47147
- "w-full h-full object-contain border-dashed border-2 border-gray-400 p-6 rounded-lg",
47148
- isDisabled ? "opacity-50 cursor-not-allowed" : ""
47149
- ].join(" "),
47150
- src: imageSource,
47151
- alt: "uploaded or default"
47152
- }) : /*#__PURE__*/ jsx("div", {
47153
- id: "image-preview",
47154
- className: [
47155
- "p-6 bg-gray-100 border-dashed border-2 border-gray-400 rounded-lg items-center mx-auto text-center",
47156
- isDisabled ? "opacity-50 cursor-not-allowed" : ""
47157
- ].join(" "),
47532
+ var type = (item === null || item === void 0 ? void 0 : item.imageStyleType) || "base";
47533
+ return /*#__PURE__*/ jsxs(Fragment$1, {
47534
+ children: [
47535
+ type === "base" && /*#__PURE__*/ jsx("div", {
47536
+ className: "bg-white rounded-lg shadow-md overflow-hidden items-center",
47537
+ children: /*#__PURE__*/ jsx("div", {
47538
+ className: "px-4 py-6 h-56",
47539
+ children: imageSource ? /*#__PURE__*/ jsx("img", {
47540
+ className: [
47541
+ "w-full h-full object-contain border-dashed border-2 border-gray-400 p-6 rounded-lg",
47542
+ isDisabled ? "opacity-50 cursor-not-allowed" : ""
47543
+ ].join(" "),
47544
+ src: imageSource,
47545
+ alt: "uploaded or default"
47546
+ }) : /*#__PURE__*/ jsx("div", {
47547
+ id: "image-preview",
47548
+ className: [
47549
+ "p-6 bg-gray-100 border-dashed border-2 border-gray-400 rounded-lg items-center mx-auto text-center",
47550
+ isDisabled ? "opacity-50 cursor-not-allowed" : ""
47551
+ ].join(" "),
47552
+ children: /*#__PURE__*/ jsxs("div", {
47553
+ children: [
47554
+ /*#__PURE__*/ jsx("div", {
47555
+ className: "flex justify-center",
47556
+ children: /*#__PURE__*/ jsx(Icon, {
47557
+ icon: "material-symbols:upload",
47558
+ width: "2.5rem",
47559
+ height: "2.5rem"
47560
+ })
47561
+ }),
47562
+ /*#__PURE__*/ jsx("p", {
47563
+ className: "font-normal text-sm text-gray-400 py-4",
47564
+ children: "圖片僅支援 png、jpg、jpeg"
47565
+ }),
47566
+ /*#__PURE__*/ jsx("h5", {
47567
+ className: "mb-2 text-xl font-bold tracking-tight text-gray-700",
47568
+ children: "上傳圖片"
47569
+ })
47570
+ ]
47571
+ })
47572
+ })
47573
+ })
47574
+ }),
47575
+ type === "primary" && /*#__PURE__*/ jsx("div", {
47576
+ className: "rounded-[22px] items-center",
47158
47577
  children: /*#__PURE__*/ jsxs("div", {
47578
+ className: [
47579
+ "relative",
47580
+ (item === null || item === void 0 ? void 0 : item.className) || "w-80 lg:w-[364px] h-[330px]"
47581
+ ].join(" "),
47159
47582
  children: [
47160
- /*#__PURE__*/ jsx("div", {
47161
- className: "flex justify-center",
47162
- children: /*#__PURE__*/ jsx(Icon, {
47163
- icon: "material-symbols:upload",
47164
- width: "2.5rem",
47165
- height: "2.5rem"
47583
+ field.value && /*#__PURE__*/ jsx("div", {
47584
+ className: "absolute -right-4 top-0",
47585
+ children: /*#__PURE__*/ jsx("button", {
47586
+ type: "button",
47587
+ onClick: function(e) {
47588
+ e.stopPropagation();
47589
+ field.onChange(null);
47590
+ },
47591
+ className: "text-xl w-9 h-9 font-bold border border-[#000000A6] text-[#000000A6] rounded-full bg-white flex items-center justify-center",
47592
+ children: "✕"
47166
47593
  })
47167
47594
  }),
47168
- /*#__PURE__*/ jsx("p", {
47169
- className: "font-normal text-sm text-gray-400 py-4",
47170
- children: "圖片僅支援 png、jpg、jpeg"
47171
- }),
47172
- /*#__PURE__*/ jsx("h5", {
47173
- className: "mb-2 text-xl font-bold tracking-tight text-gray-700",
47174
- children: "上傳圖片"
47595
+ imageSource ? /*#__PURE__*/ jsx("img", {
47596
+ className: [
47597
+ "w-full h-full rounded-[22px]",
47598
+ isDisabled ? "opacity-50 cursor-not-allowed" : ""
47599
+ ].join(" "),
47600
+ src: imageSource,
47601
+ alt: "uploaded or default"
47602
+ }) : /*#__PURE__*/ jsx("div", {
47603
+ id: "image-preview",
47604
+ className: [
47605
+ "border-dashed border-2 border-[#17340929] rounded-[22px] flex items-center mx-auto justify-center",
47606
+ isDisabled ? "opacity-50 cursor-not-allowed" : "",
47607
+ (item === null || item === void 0 ? void 0 : item.className) || "w-80 lg:w-[364px] h-[330px]"
47608
+ ].join(" "),
47609
+ children: /*#__PURE__*/ jsxs("div", {
47610
+ children: [
47611
+ /*#__PURE__*/ jsx("div", {
47612
+ className: "flex justify-center",
47613
+ children: /*#__PURE__*/ jsx(Icon, {
47614
+ icon: "fluent:image-32-filled",
47615
+ width: "84",
47616
+ height: "84",
47617
+ color: "#C7C7CC"
47618
+ })
47619
+ }),
47620
+ /*#__PURE__*/ jsx("p", {
47621
+ className: "font-medium text-2xl text-[#777777] py-4",
47622
+ children: "選擇檔案上傳"
47623
+ }),
47624
+ /*#__PURE__*/ jsx("div", {
47625
+ className: "flex justify-center",
47626
+ children: /*#__PURE__*/ jsx("div", {
47627
+ className: "flex justify-center mb-6 py-3 px-6 bg-[#1A1A1A] text-white rounded-[22px] text-sm",
47628
+ children: "上傳照片"
47629
+ })
47630
+ })
47631
+ ]
47632
+ })
47175
47633
  })
47176
47634
  ]
47177
47635
  })
47178
47636
  })
47179
- })
47637
+ ]
47180
47638
  });
47181
47639
  };
47182
47640
 
@@ -47236,9 +47694,22 @@ function _unsupported_iterable_to_array$d(o, minLen) {
47236
47694
  var CustomUpload = function(param) {
47237
47695
  var item = param.item, field = param.field;
47238
47696
  var imageMimeType = /image\/(png|jpg|jpeg)/i;
47239
- var DEFAULT_IMAGE_SIZE_LIMIT_IN_BYTES = 5120000;
47697
+ var DEFAULT_IMAGE_SIZE_LIMIT_IN_BYTES = (item === null || item === void 0 ? void 0 : item.limitSize) || 5242880;
47240
47698
  var _useState = _sliced_to_array$a(useState(null), 2), modal = _useState[0], setModal = _useState[1];
47241
47699
  var hiddenFileInput = useRef(null);
47700
+ useEffect(function() {
47701
+ if (modal) {
47702
+ document.body.style.overflow = "hidden"; // 鎖住背景 scroll
47703
+ } else {
47704
+ document.body.style.overflow = ""; // 恢復 scroll
47705
+ }
47706
+ // 當元件卸載時,也恢復 scroll
47707
+ return function() {
47708
+ document.body.style.overflow = "";
47709
+ };
47710
+ }, [
47711
+ modal
47712
+ ]);
47242
47713
  var handleImageClick = function() {
47243
47714
  var _hiddenFileInput_current;
47244
47715
  return (_hiddenFileInput_current = hiddenFileInput.current) === null || _hiddenFileInput_current === void 0 ? void 0 : _hiddenFileInput_current.click();
@@ -47249,14 +47720,18 @@ var CustomUpload = function(param) {
47249
47720
  if (!currentFile) return;
47250
47721
  if (!((_currentFile_type = currentFile.type) === null || _currentFile_type === void 0 ? void 0 : _currentFile_type.match(imageMimeType))) {
47251
47722
  setModal(/*#__PURE__*/ jsx(ErrorContent, {
47252
- setModal: setModal,
47723
+ setModal: function() {
47724
+ return setModal(null);
47725
+ },
47253
47726
  errmsg: "圖片僅支援 png、jpg、jpeg!"
47254
47727
  }));
47255
47728
  return;
47256
47729
  }
47257
47730
  if (currentFile.size > DEFAULT_IMAGE_SIZE_LIMIT_IN_BYTES) {
47258
47731
  setModal(/*#__PURE__*/ jsx(ErrorContent, {
47259
- setModal: setModal,
47732
+ setModal: function() {
47733
+ return setModal(null);
47734
+ },
47260
47735
  errmsg: /*#__PURE__*/ jsxs(Fragment$1, {
47261
47736
  children: [
47262
47737
  "檔案太大:",
@@ -47277,10 +47752,10 @@ var CustomUpload = function(param) {
47277
47752
  return /*#__PURE__*/ jsxs(Fragment$1, {
47278
47753
  children: [
47279
47754
  /*#__PURE__*/ jsx("div", {
47280
- className: "mb-2",
47281
47755
  children: /*#__PURE__*/ jsxs("button", {
47282
47756
  className: [
47283
- (item === null || item === void 0 ? void 0 : item.className) || "w-full"
47757
+ item === null || item === void 0 ? void 0 : item.className,
47758
+ "w-full"
47284
47759
  ].join(" "),
47285
47760
  type: "button",
47286
47761
  onClick: handleImageClick,
@@ -47288,7 +47763,8 @@ var CustomUpload = function(param) {
47288
47763
  /*#__PURE__*/ jsx(BaseTemplate, {
47289
47764
  file: _instanceof$6(field.value, File) ? field.value : undefined,
47290
47765
  imageUrl: previewUrl,
47291
- item: item
47766
+ item: item,
47767
+ field: field
47292
47768
  }),
47293
47769
  /*#__PURE__*/ jsx("input", {
47294
47770
  type: "file",
@@ -47301,7 +47777,7 @@ var CustomUpload = function(param) {
47301
47777
  ]
47302
47778
  })
47303
47779
  }),
47304
- !(item === null || item === void 0 ? void 0 : item.hiddenIcon) && field.value && /*#__PURE__*/ jsx("button", {
47780
+ (item === null || item === void 0 ? void 0 : item.imageStyleType) !== "primary" && !(item === null || item === void 0 ? void 0 : item.hiddenIcon) && field.value && /*#__PURE__*/ jsx("button", {
47305
47781
  type: "button",
47306
47782
  className: "w-6 h-6 text-[#000]",
47307
47783
  onClick: function() {
@@ -47410,7 +47886,7 @@ var SelectTrigger = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
47410
47886
  ]);
47411
47887
  return /*#__PURE__*/ jsxs(SelectPrimitive.Trigger, _object_spread_props$9(_object_spread$c({
47412
47888
  ref: ref,
47413
- className: cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1", className)
47889
+ className: cn("flex h-9 w-full min-w-[8rem] items-center justify-between whitespace-nowrap rounded-2xl border bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-[#1A1A1A] focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1", className)
47414
47890
  }, props), {
47415
47891
  children: [
47416
47892
  children,
@@ -47463,7 +47939,7 @@ var SelectContent = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
47463
47939
  return /*#__PURE__*/ jsx(SelectPrimitive.Portal, {
47464
47940
  children: /*#__PURE__*/ jsxs(SelectPrimitive.Content, _object_spread_props$9(_object_spread$c({
47465
47941
  ref: ref,
47466
- className: cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className),
47942
+ className: cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-2xl border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className),
47467
47943
  position: position
47468
47944
  }, props), {
47469
47945
  children: [
@@ -47495,7 +47971,7 @@ var SelectItem = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
47495
47971
  ]);
47496
47972
  return /*#__PURE__*/ jsxs(SelectPrimitive.Item, _object_spread_props$9(_object_spread$c({
47497
47973
  ref: ref,
47498
- className: cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className)
47974
+ className: cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className)
47499
47975
  }, props), {
47500
47976
  children: [
47501
47977
  /*#__PURE__*/ jsx("span", {
@@ -47537,7 +48013,7 @@ var optionSizeClassMap = {
47537
48013
  var BaseSelect = function(param) {
47538
48014
  var item = param.item;
47539
48015
  var _useFormContext = useFormContext(), control = _useFormContext.control, errors = _useFormContext.formState.errors;
47540
- var _item_className = item.className, className = _item_className === void 0 ? "" : _item_className, _item_size = item.size, size = _item_size === void 0 ? "md" : _item_size, _item_groupLabelColor = item.groupLabelColor, groupLabelColor = _item_groupLabelColor === void 0 ? "" : _item_groupLabelColor, _item_bgColor = item.bgColor, bgColor = _item_bgColor === void 0 ? "" : _item_bgColor, _item_optionHoverColor = item.optionHoverColor, optionHoverColor = _item_optionHoverColor === void 0 ? "" : _item_optionHoverColor, _item_optionSelectedBgColor = item.optionSelectedBgColor, optionSelectedBgColor = _item_optionSelectedBgColor === void 0 ? "" : _item_optionSelectedBgColor, _item_option = item.option, option = _item_option === void 0 ? [] : _item_option;
48016
+ var _item_className = item.className, className = _item_className === void 0 ? "border border-[#B4B4B4]" : _item_className, _item_selectContentClassName = item.selectContentClassName, selectContentClassName = _item_selectContentClassName === void 0 ? "border border-[#B4B4B4]" : _item_selectContentClassName, _item_size = item.size, size = _item_size === void 0 ? "md" : _item_size, _item_groupLabelColor = item.groupLabelColor, groupLabelColor = _item_groupLabelColor === void 0 ? "" : _item_groupLabelColor, _item_bgColor = item.bgColor, bgColor = _item_bgColor === void 0 ? "" : _item_bgColor, _item_optionHoverColor = item.optionHoverColor, optionHoverColor = _item_optionHoverColor === void 0 ? "" : _item_optionHoverColor, _item_optionSelectedBgColor = item.optionSelectedBgColor, optionSelectedBgColor = _item_optionSelectedBgColor === void 0 ? "" : _item_optionSelectedBgColor, _item_option = item.option, option = _item_option === void 0 ? [] : _item_option;
47541
48017
  return /*#__PURE__*/ jsxs("div", {
47542
48018
  children: [
47543
48019
  /*#__PURE__*/ jsx(FieldLabel, {
@@ -47560,6 +48036,7 @@ var BaseSelect = function(param) {
47560
48036
  })
47561
48037
  }),
47562
48038
  /*#__PURE__*/ jsx(SelectContent, {
48039
+ className: selectContentClassName,
47563
48040
  children: option.map(function(item, index) {
47564
48041
  var _item_options, _item_options1;
47565
48042
  return "options" in item ? /*#__PURE__*/ jsxs(SelectGroup, {
@@ -47733,13 +48210,13 @@ var TextField = function(param) {
47733
48210
  children: [
47734
48211
  /*#__PURE__*/ jsx("div", {
47735
48212
  className: [
47736
- validateMsg(errors, item) ? "rounded-lg" : ""
48213
+ validateMsg(errors, item) ? "rounded-2xl" : ""
47737
48214
  ].join(" "),
47738
48215
  children: /*#__PURE__*/ jsx("input", _object_spread_props$8(_object_spread$b({
47739
48216
  type: item === null || item === void 0 ? void 0 : item.type,
47740
48217
  className: [
47741
48218
  isDisabled ? "text-[#B0B0B0] bg-[#e5e7eb] cursor-not-allowed" : "bg-white text-[#6f6f6f]",
47742
- "w-full h-11 rounded-lg customInput pr-4 border border-solid border-gray-300",
48219
+ "w-full h-11 rounded-2xl customInput pr-4 border border-solid border-[#B4B4B4]",
47743
48220
  (item === null || item === void 0 ? void 0 : item.icon) ? "pl-14" : "pl-4"
47744
48221
  ].join(" "),
47745
48222
  placeholder: item === null || item === void 0 ? void 0 : item.placeholder
@@ -47768,7 +48245,7 @@ var TextField = function(param) {
47768
48245
  inputMode: "numeric",
47769
48246
  className: [
47770
48247
  isDisabled ? "text-[#B0B0B0] bg-[#e5e7eb] cursor-not-allowed" : "bg-white text-[#6f6f6f]",
47771
- "w-full h-11 rounded-lg customInput px-4 border border-solid border-gray-300 appearance-none"
48248
+ "w-full h-11 rounded-2xl customInput px-4 border border-solid border-[#B4B4B4] appearance-none"
47772
48249
  ].join(" "),
47773
48250
  placeholder: item === null || item === void 0 ? void 0 : item.placeholder
47774
48251
  }, register(item === null || item === void 0 ? void 0 : item.name, _object_spread$b({}, item === null || item === void 0 ? void 0 : item.validateOption))), {
@@ -47825,7 +48302,7 @@ var SingleSelect = function(param) {
47825
48302
  return /*#__PURE__*/ jsx("select", _object_spread_props$8(_object_spread$b(_object_spread_props$8(_object_spread$b({
47826
48303
  className: [
47827
48304
  (item === null || item === void 0 ? void 0 : item.disable) || (item === null || item === void 0 ? void 0 : item.disabled) ? "text-[#B0B0B0] bg-[#e5e7eb] cursor-not-allowed" : "bg-white text-[#6f6f6f]",
47828
- "customSelect w-full h-11 py-2 pr-4 rounded-lg border border-solid border-gray-300 pl-4"
48305
+ "customSelect w-full h-11 py-2 pr-4 rounded-2xl border border-solid border-[#B4B4B4] pl-4"
47829
48306
  ].join(" "),
47830
48307
  style: item.style
47831
48308
  }, register(item.name, _object_spread$b({}, item === null || item === void 0 ? void 0 : item.validateOption))), {
@@ -47968,7 +48445,7 @@ var Time = function(param) {
47968
48445
  /*#__PURE__*/ jsx("input", _object_spread$b(_object_spread_props$8(_object_spread$b({
47969
48446
  className: [
47970
48447
  (item === null || item === void 0 ? void 0 : item.disable) || (item === null || item === void 0 ? void 0 : item.disabled) ? "text-[#B0B0B0] bg-[#e5e7eb] cursor-not-allowed" : "bg-white text-[#0f172a]",
47971
- "customTime border border-solid border-gray-300 px-3 py-2 rounded-lg w-full text-[16px]"
48448
+ "customTime border border-solid border-[#B4B4B4] px-3 py-2 rounded-2xl w-full text-[16px]"
47972
48449
  ].join(" "),
47973
48450
  type: (item === null || item === void 0 ? void 0 : item.type) || "time",
47974
48451
  placeholder: "ex: 16:00"
@@ -48030,7 +48507,7 @@ var City = function(param) {
48030
48507
  /*#__PURE__*/ jsx("select", _object_spread_props$8(_object_spread$b({
48031
48508
  className: [
48032
48509
  (item === null || item === void 0 ? void 0 : item.disable) || (item === null || item === void 0 ? void 0 : item.disabled) ? "text-[#B0B0B0] bg-[#e5e7eb] cursor-not-allowed" : "bg-white text-[#6f6f6f] cursor-pointer",
48033
- "customSelect w-full h-11 py-2 pr-4 rounded-lg border border-solid border-gray-300 pl-4 mr-6"
48510
+ "customSelect w-full h-11 py-2 pr-4 rounded-2xl border border-solid border-[#B4B4B4] pl-4 mr-6"
48034
48511
  ].join(" "),
48035
48512
  style: item === null || item === void 0 ? void 0 : item.style
48036
48513
  }, register(item.name, _object_spread$b({}, item === null || item === void 0 ? void 0 : item.validateOption))), {
@@ -48269,28 +48746,41 @@ var Fields = function(param) {
48269
48746
  };
48270
48747
  var CustomUploadField = function(param) {
48271
48748
  var item = param.item;
48272
- var control = useFormContext().control;
48749
+ var _useFormContext = useFormContext(), control = _useFormContext.control, errors = _useFormContext.formState.errors;
48273
48750
  return /*#__PURE__*/ jsx(Controller$2, {
48274
48751
  name: item === null || item === void 0 ? void 0 : item.name,
48275
48752
  control: control,
48276
48753
  rules: item === null || item === void 0 ? void 0 : item.validateOption,
48277
48754
  render: function(param) {
48278
- var field = param.field, fieldState = param.fieldState;
48279
- var _fieldState_error;
48755
+ var field = param.field;
48756
+ var _item_validateOption;
48280
48757
  return /*#__PURE__*/ jsxs("div", {
48281
- className: "flex flex-1 flex-col gap-1",
48758
+ className: "flex flex-1 flex-col mb-2",
48282
48759
  children: [
48283
- (item === null || item === void 0 ? void 0 : item.label) && /*#__PURE__*/ jsx("label", {
48760
+ (item === null || item === void 0 ? void 0 : item.label) && /*#__PURE__*/ jsxs("label", {
48284
48761
  className: "font-medium",
48285
- children: item === null || item === void 0 ? void 0 : item.label
48762
+ children: [
48763
+ item === null || item === void 0 ? void 0 : item.label,
48764
+ (item === null || item === void 0 ? void 0 : (_item_validateOption = item.validateOption) === null || _item_validateOption === void 0 ? void 0 : _item_validateOption.required) && /*#__PURE__*/ jsx("span", {
48765
+ className: "text-red-600 font-bold",
48766
+ children: "*"
48767
+ })
48768
+ ]
48769
+ }),
48770
+ (item === null || item === void 0 ? void 0 : item.noticeLabel) && /*#__PURE__*/ jsx("div", {
48771
+ className: "text-[#777777] font-medium pb-2",
48772
+ children: item === null || item === void 0 ? void 0 : item.noticeLabel
48286
48773
  }),
48287
48774
  /*#__PURE__*/ jsx(CustomUpload, {
48288
48775
  item: item,
48289
48776
  field: field
48290
48777
  }),
48291
- ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) && /*#__PURE__*/ jsx("p", {
48292
- className: "text-red-500 text-sm",
48293
- children: fieldState.error.message
48778
+ validateMsg(errors, item) && /*#__PURE__*/ jsxs("div", {
48779
+ className: "pt-1 text-xs text-[#EF5533]",
48780
+ children: [
48781
+ "*",
48782
+ validateMsg(errors, item)
48783
+ ]
48294
48784
  })
48295
48785
  ]
48296
48786
  });
@@ -78292,4 +78782,4 @@ var useLiffContext = function() {
78292
78782
  return context;
78293
78783
  };
78294
78784
 
78295
- export { verifyId as A, BaseSwitch as B, Controller$2 as C, DropImage as D, verifyTaxId as E, FieldLabel as F, BigCalender as G, DnDCalendar as H, InputOTPs as I, CustomSelect as J, LiffProvider as K, LiffContext as L, useLiffContext as M, FormProvider as N, useForm as O, City as P, Textarea as Q, ReactDateRange as R, Spin as S, TabsPanel as T, UiLibrary as U, Fields as V, CustomUploadField as W, Row as X, Form as Y, __spreadArray as _, __read as a, __extends as b, __assign as c, __makeTemplateObject as d, __awaiter as e, __generator as f, commonjsGlobal as g, __values as h, getAugmentedNamespace as i, getDefaultExportFromCjs as j, DropDown as k, CustomUpload$1 as l, Switch as m, DateRangePicker as n, SingleDatePicker as o, propTypes$1 as p, Button as q, buttonVariants as r, StackCards as s, DataTable as t, useFormContext as u, validateMsg as v, BaseTable as w, Drawer as x, Regex as y, verifyTaiwanIdIntermediateString as z };
78785
+ export { CustomUploadField as $, verifyId as A, BaseSwitch as B, Controller$2 as C, DropImage as D, verifyTaxId as E, FieldLabel as F, BigCalender as G, DnDCalendar as H, InputOTPs as I, CustomSelect as J, LiffProvider as K, LiffContext as L, useLiffContext as M, FormProvider as N, useForm as O, useController as P, useFieldArray as Q, ReactDateRange as R, Spin as S, TabsPanel as T, UiLibrary as U, useFormState as V, useWatch as W, City as X, Textarea as Y, Fields as Z, __spreadArray as _, __read as a, Row as a0, Form as a1, __extends as b, __assign as c, __makeTemplateObject as d, __awaiter as e, __generator as f, commonjsGlobal as g, __values as h, getAugmentedNamespace as i, getDefaultExportFromCjs as j, DropDown as k, CustomUpload$1 as l, Switch as m, DateRangePicker as n, SingleDatePicker as o, propTypes$1 as p, Button as q, buttonVariants as r, StackCards as s, DataTable as t, useFormContext as u, validateMsg as v, BaseTable as w, Drawer as x, Regex as y, verifyTaiwanIdIntermediateString as z };