@sunggang/ui-lib 0.4.67 → 0.4.68

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/Form.cjs.js CHANGED
@@ -7517,7 +7517,7 @@ var EditableCombobox = function(param) {
7517
7517
  onChange: handleInputChange,
7518
7518
  onClick: handleInputClick,
7519
7519
  placeholder: placeholder,
7520
- disabled: disabled,
7520
+ readOnly: disabled,
7521
7521
  className: [
7522
7522
  "w-full h-11 rounded-2xl px-4 pr-20 border border-solid border-[#B4B4B4] customInput editable-combobox",
7523
7523
  "transition-colors duration-200",
@@ -8247,8 +8247,9 @@ var FieldArray = function(param) {
8247
8247
  var maxItems = config === null || config === void 0 ? void 0 : config.maxItems;
8248
8248
  var minItems = (config === null || config === void 0 ? void 0 : config.minItems) || 0;
8249
8249
  var defaultItemCount = (config === null || config === void 0 ? void 0 : config.defaultItemCount) || 1;
8250
- var addButtonPosition = (config === null || config === void 0 ? void 0 : config.addButtonPosition) || "bottom";
8250
+ var addButtonPosition = (config === null || config === void 0 ? void 0 : config.addButtonPosition) || "";
8251
8251
  var addButtonClassName = config === null || config === void 0 ? void 0 : config.addButtonClassName;
8252
+ var hideAddButton = (config === null || config === void 0 ? void 0 : config.hideAddButton) || false;
8252
8253
  var canAdd = !maxItems || fields.length < maxItems;
8253
8254
  var canRemove = fields.length > minItems;
8254
8255
  React__default["default"].useEffect(function() {
@@ -8323,7 +8324,7 @@ var FieldArray = function(param) {
8323
8324
  (item === null || item === void 0 ? void 0 : item.label) && /*#__PURE__*/ jsxRuntime.jsx(FieldLabel.FieldLabel, {
8324
8325
  item: item
8325
8326
  }),
8326
- addButtonPosition === "top" && canAdd && /*#__PURE__*/ jsxRuntime.jsxs("button", {
8327
+ addButtonPosition === "top" && canAdd && !hideAddButton && /*#__PURE__*/ jsxRuntime.jsxs("button", {
8327
8328
  type: "button",
8328
8329
  onClick: handleAdd,
8329
8330
  className: addButtonClassName || [
@@ -8392,16 +8393,16 @@ var FieldArray = function(param) {
8392
8393
  };
8393
8394
  }),
8394
8395
  placeholder: fieldConfig.placeholder || fieldConfig.label,
8395
- disabled: (item === null || item === void 0 ? void 0 : item.disable) || (item === null || item === void 0 ? void 0 : item.disabled)
8396
+ disabled: (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.disable) || (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.disabled)
8396
8397
  }) : // ✅ 使用一般 input
8397
8398
  /*#__PURE__*/ jsxRuntime.jsx("input", _object_spread_props(_object_spread({}, controllerField), {
8398
8399
  type: "text",
8399
8400
  className: [
8400
- (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]",
8401
- "w-full h-11 rounded-2xl px-4 border border-solid border-[#B4B4B4]"
8401
+ (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.disable) || (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.disabled) ? "text-[#B0B0B0] bg-[#e5e7eb] cursor-not-allowed" : "bg-white text-[#6f6f6f]",
8402
+ "customInput w-full h-11 rounded-2xl px-4 border border-solid border-[#B4B4B4]"
8402
8403
  ].join(" "),
8403
8404
  placeholder: fieldConfig.placeholder || fieldConfig.label,
8404
- disabled: (item === null || item === void 0 ? void 0 : item.disable) || (item === null || item === void 0 ? void 0 : item.disabled)
8405
+ readOnly: (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.disable) || (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.disabled)
8405
8406
  }))
8406
8407
  });
8407
8408
  }
@@ -8423,7 +8424,7 @@ var FieldArray = function(param) {
8423
8424
  "mt-[30px]"
8424
8425
  ].join(" "),
8425
8426
  children: [
8426
- addButtonPosition === "inline" && canAdd && index === fields.length - 1 && /*#__PURE__*/ jsxRuntime.jsxs("button", {
8427
+ addButtonPosition === "inline" && canAdd && !hideAddButton && index === fields.length - 1 && /*#__PURE__*/ jsxRuntime.jsxs("button", {
8427
8428
  type: "button",
8428
8429
  onClick: handleAdd,
8429
8430
  className: addButtonClassName || [
@@ -8440,7 +8441,7 @@ var FieldArray = function(param) {
8440
8441
  addButtonText
8441
8442
  ]
8442
8443
  }),
8443
- canRemove && fields.length > 1 && /*#__PURE__*/ jsxRuntime.jsx("div", {
8444
+ canRemove && !hideAddButton && fields.length > 1 && /*#__PURE__*/ jsxRuntime.jsx("div", {
8444
8445
  className: "p-2 rounded-2xl text-[#EF5533] bg-white hover:bg-[#FFF5F3] transition-colors duration-200 cursor-pointer",
8445
8446
  children: /*#__PURE__*/ jsxRuntime.jsx(react$1.Icon, {
8446
8447
  icon: "fluent-mdl2:delete",
@@ -8459,7 +8460,7 @@ var FieldArray = function(param) {
8459
8460
  })
8460
8461
  }, field.id);
8461
8462
  }),
8462
- addButtonPosition === "bottom" && canAdd && /*#__PURE__*/ jsxRuntime.jsxs("button", {
8463
+ addButtonPosition === "bottom" && canAdd && !hideAddButton && /*#__PURE__*/ jsxRuntime.jsxs("button", {
8463
8464
  type: "button",
8464
8465
  onClick: handleAdd,
8465
8466
  className: addButtonClassName || [
package/Form.esm.js CHANGED
@@ -7490,7 +7490,7 @@ var EditableCombobox = function(param) {
7490
7490
  onChange: handleInputChange,
7491
7491
  onClick: handleInputClick,
7492
7492
  placeholder: placeholder,
7493
- disabled: disabled,
7493
+ readOnly: disabled,
7494
7494
  className: [
7495
7495
  "w-full h-11 rounded-2xl px-4 pr-20 border border-solid border-[#B4B4B4] customInput editable-combobox",
7496
7496
  "transition-colors duration-200",
@@ -8220,8 +8220,9 @@ var FieldArray = function(param) {
8220
8220
  var maxItems = config === null || config === void 0 ? void 0 : config.maxItems;
8221
8221
  var minItems = (config === null || config === void 0 ? void 0 : config.minItems) || 0;
8222
8222
  var defaultItemCount = (config === null || config === void 0 ? void 0 : config.defaultItemCount) || 1;
8223
- var addButtonPosition = (config === null || config === void 0 ? void 0 : config.addButtonPosition) || "bottom";
8223
+ var addButtonPosition = (config === null || config === void 0 ? void 0 : config.addButtonPosition) || "";
8224
8224
  var addButtonClassName = config === null || config === void 0 ? void 0 : config.addButtonClassName;
8225
+ var hideAddButton = (config === null || config === void 0 ? void 0 : config.hideAddButton) || false;
8225
8226
  var canAdd = !maxItems || fields.length < maxItems;
8226
8227
  var canRemove = fields.length > minItems;
8227
8228
  React__default.useEffect(function() {
@@ -8296,7 +8297,7 @@ var FieldArray = function(param) {
8296
8297
  (item === null || item === void 0 ? void 0 : item.label) && /*#__PURE__*/ jsx$1(FieldLabel, {
8297
8298
  item: item
8298
8299
  }),
8299
- addButtonPosition === "top" && canAdd && /*#__PURE__*/ jsxs("button", {
8300
+ addButtonPosition === "top" && canAdd && !hideAddButton && /*#__PURE__*/ jsxs("button", {
8300
8301
  type: "button",
8301
8302
  onClick: handleAdd,
8302
8303
  className: addButtonClassName || [
@@ -8365,16 +8366,16 @@ var FieldArray = function(param) {
8365
8366
  };
8366
8367
  }),
8367
8368
  placeholder: fieldConfig.placeholder || fieldConfig.label,
8368
- disabled: (item === null || item === void 0 ? void 0 : item.disable) || (item === null || item === void 0 ? void 0 : item.disabled)
8369
+ disabled: (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.disable) || (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.disabled)
8369
8370
  }) : // ✅ 使用一般 input
8370
8371
  /*#__PURE__*/ jsx$1("input", _object_spread_props(_object_spread({}, controllerField), {
8371
8372
  type: "text",
8372
8373
  className: [
8373
- (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]",
8374
- "w-full h-11 rounded-2xl px-4 border border-solid border-[#B4B4B4]"
8374
+ (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.disable) || (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.disabled) ? "text-[#B0B0B0] bg-[#e5e7eb] cursor-not-allowed" : "bg-white text-[#6f6f6f]",
8375
+ "customInput w-full h-11 rounded-2xl px-4 border border-solid border-[#B4B4B4]"
8375
8376
  ].join(" "),
8376
8377
  placeholder: fieldConfig.placeholder || fieldConfig.label,
8377
- disabled: (item === null || item === void 0 ? void 0 : item.disable) || (item === null || item === void 0 ? void 0 : item.disabled)
8378
+ readOnly: (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.disable) || (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.disabled)
8378
8379
  }))
8379
8380
  });
8380
8381
  }
@@ -8396,7 +8397,7 @@ var FieldArray = function(param) {
8396
8397
  "mt-[30px]"
8397
8398
  ].join(" "),
8398
8399
  children: [
8399
- addButtonPosition === "inline" && canAdd && index === fields.length - 1 && /*#__PURE__*/ jsxs("button", {
8400
+ addButtonPosition === "inline" && canAdd && !hideAddButton && index === fields.length - 1 && /*#__PURE__*/ jsxs("button", {
8400
8401
  type: "button",
8401
8402
  onClick: handleAdd,
8402
8403
  className: addButtonClassName || [
@@ -8413,7 +8414,7 @@ var FieldArray = function(param) {
8413
8414
  addButtonText
8414
8415
  ]
8415
8416
  }),
8416
- canRemove && fields.length > 1 && /*#__PURE__*/ jsx$1("div", {
8417
+ canRemove && !hideAddButton && fields.length > 1 && /*#__PURE__*/ jsx$1("div", {
8417
8418
  className: "p-2 rounded-2xl text-[#EF5533] bg-white hover:bg-[#FFF5F3] transition-colors duration-200 cursor-pointer",
8418
8419
  children: /*#__PURE__*/ jsx$1(Icon, {
8419
8420
  icon: "fluent-mdl2:delete",
@@ -8432,7 +8433,7 @@ var FieldArray = function(param) {
8432
8433
  })
8433
8434
  }, field.id);
8434
8435
  }),
8435
- addButtonPosition === "bottom" && canAdd && /*#__PURE__*/ jsxs("button", {
8436
+ addButtonPosition === "bottom" && canAdd && !hideAddButton && /*#__PURE__*/ jsxs("button", {
8436
8437
  type: "button",
8437
8438
  onClick: handleAdd,
8438
8439
  className: addButtonClassName || [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunggang/ui-lib",
3
- "version": "0.4.67",
3
+ "version": "0.4.68",
4
4
  "sideEffects": [
5
5
  "*.css",
6
6
  "./src/style.css",
@@ -14,6 +14,7 @@ export declare const config: (getValues: (name: string) => unknown) => (FormItem
14
14
  name: string;
15
15
  label: string;
16
16
  fieldArrayConfig: {
17
+ hideAddButton: boolean;
17
18
  fields: ({
18
19
  name: string;
19
20
  label: string;
@@ -22,6 +23,7 @@ export declare const config: (getValues: (name: string) => unknown) => (FormItem
22
23
  required: string;
23
24
  validate: (value: any) => true | "姓名至少需要 2 個字元";
24
25
  };
26
+ disabled: boolean;
25
27
  options?: undefined;
26
28
  } | {
27
29
  name: string;
@@ -35,6 +37,7 @@ export declare const config: (getValues: (name: string) => unknown) => (FormItem
35
37
  required: string;
36
38
  validate?: undefined;
37
39
  };
40
+ disabled: boolean;
38
41
  } | {
39
42
  name: string;
40
43
  label: string;
@@ -44,11 +47,13 @@ export declare const config: (getValues: (name: string) => unknown) => (FormItem
44
47
  }[];
45
48
  placeholder?: undefined;
46
49
  validateOption?: undefined;
50
+ disabled?: undefined;
47
51
  } | {
48
52
  name: string;
49
53
  label: string;
50
54
  placeholder: string;
51
55
  validateOption?: undefined;
56
+ disabled?: undefined;
52
57
  options?: undefined;
53
58
  })[];
54
59
  addButtonText: string;
@@ -39,6 +39,8 @@ export interface FieldArrayField {
39
39
  message: string;
40
40
  };
41
41
  };
42
+ disable?: boolean;
43
+ disabled?: boolean;
42
44
  }
43
45
  interface RadioOption {
44
46
  label?: string;
@@ -177,6 +179,7 @@ export interface FormItem {
177
179
  defaultItemCount?: number;
178
180
  addButtonPosition?: 'inline' | 'bottom' | 'top';
179
181
  addButtonClassName?: string;
182
+ hideAddButton?: boolean;
180
183
  };
181
184
  }
182
185
  export interface FormType {