@cloudtower/eagle 0.22.40 → 0.23.1

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/dist/umd/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('antd'), require('react'), require('classnames'), require('lodash'), require('@cloudtower/parrot'), require('@linaria/core'), require('@linaria/react'), require('moment'), require('react-dom'), require('react-is'), require('@ant-design/icons'), require('redux'), require('react-redux'), require('@cloudtower/icons-react'), require('react-beautiful-dnd'), require('timezones.json'), require('react-i18next'), require('dayjs'), require('recharts')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'antd', 'react', 'classnames', 'lodash', '@cloudtower/parrot', '@linaria/core', '@linaria/react', 'moment', 'react-dom', 'react-is', '@ant-design/icons', 'redux', 'react-redux', '@cloudtower/icons-react', 'react-beautiful-dnd', 'timezones.json', 'react-i18next', 'dayjs', 'recharts'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.index = {}, global.antd, global.React, global.cs, global._, global.parrot, global.core, global.react, global.moment, global.reactDom, global.reactIs, global.icons, global.redux, global.reactRedux, global.iconsReact, global.reactBeautifulDnd, global.TimeZones, global.reactI18next, global.dayjs));
5
- })(this, (function (exports, antd, React, cs, _, parrot, core, react, moment, reactDom, reactIs, icons, redux, reactRedux, iconsReact, reactBeautifulDnd, TimeZones, reactI18next, dayjs) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('antd'), require('react'), require('classnames'), require('lodash'), require('react-i18next'), require('@linaria/core'), require('@linaria/react'), require('moment'), require('react-dom'), require('react-is'), require('@ant-design/icons'), require('redux'), require('react-redux'), require('@cloudtower/icons-react'), require('react-beautiful-dnd'), require('timezones.json'), require('@cloudtower/parrot'), require('dayjs'), require('recharts')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'antd', 'react', 'classnames', 'lodash', 'react-i18next', '@linaria/core', '@linaria/react', 'moment', 'react-dom', 'react-is', '@ant-design/icons', 'redux', 'react-redux', '@cloudtower/icons-react', 'react-beautiful-dnd', 'timezones.json', '@cloudtower/parrot', 'dayjs', 'recharts'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.index = {}, global.antd, global.React, global.cs, global._, global.reactI18next, global.core, global.react, global.moment, global.reactDom, global.reactIs, global.icons, global.redux, global.reactRedux, global.iconsReact, global.reactBeautifulDnd, global.TimeZones, global.parrot, global.dayjs));
5
+ })(this, (function (exports, antd, React, cs, _, reactI18next, core, react, moment, reactDom, reactIs, icons, redux, reactRedux, iconsReact, reactBeautifulDnd, TimeZones, parrot, dayjs) { 'use strict';
6
6
 
7
7
  const MAGIC_METRIC_NULL = -2;
8
8
  function formatBits(bits, decimals = 2) {
@@ -461,10 +461,11 @@
461
461
  };
462
462
 
463
463
  const Arch = (props) => {
464
+ const { t } = reactI18next.useTranslation();
464
465
  const { architecture } = props;
465
466
  let text = "";
466
467
  if (architecture) {
467
- text = parrot.parrotI18n.t(`components.Architecture_${architecture}`);
468
+ text = t(`components.Architecture_${architecture}`);
468
469
  }
469
470
  return /* @__PURE__ */ React.createElement("span", null, text);
470
471
  };
@@ -959,11 +960,12 @@
959
960
  valueClassName,
960
961
  unitClassName
961
962
  }) => {
963
+ const { t } = reactI18next.useTranslation();
962
964
  if (isEmpty(rawValue)) {
963
965
  return Empty;
964
966
  }
965
967
  if (rawValue === -1) {
966
- return /* @__PURE__ */ React.createElement("span", null, parrot.parrotI18n.t("common.calculation"));
968
+ return /* @__PURE__ */ React.createElement("span", null, t("common.calculation"));
967
969
  }
968
970
  const { value, unit } = formatBytes(rawValue, decimals);
969
971
  if (noUnitOnZero && value === 0) {
@@ -2581,10 +2583,11 @@
2581
2583
  };
2582
2584
  const Modal = (props) => {
2583
2585
  var _b;
2586
+ const { t } = reactI18next.useTranslation();
2584
2587
  const _a = props, {
2585
2588
  error,
2586
- okText = parrot.parrotI18n.t("common.confirm"),
2587
- cancelText = parrot.parrotI18n.t("common.cancel"),
2589
+ okText = t("common.confirm"),
2590
+ cancelText = t("common.cancel"),
2588
2591
  confirmLoading,
2589
2592
  okButtonProps,
2590
2593
  onOk,
@@ -2633,12 +2636,12 @@
2633
2636
  let text = (okButtonProps == null ? void 0 : okButtonProps.children) || okText;
2634
2637
  if (wizard && typeof wizard === "object" && wizard.steps[wizard.step]) {
2635
2638
  const { step, steps } = wizard;
2636
- text = step < steps.length - 1 ? steps[step].okText || parrot.parrotI18n.t("common.next_step") : steps[step].okText || text;
2639
+ text = step < steps.length - 1 ? steps[step].okText || t("common.next_step") : steps[step].okText || text;
2637
2640
  }
2638
2641
  return text;
2639
- }, [okButtonProps, okText, wizard]);
2642
+ }, [okButtonProps == null ? void 0 : okButtonProps.children, okText, t, wizard]);
2640
2643
  const prevText = React.useMemo(() => {
2641
- let text = /* @__PURE__ */ React.createElement("span", null, "< ", parrot.parrotI18n.t("common.prev_step"));
2644
+ let text = /* @__PURE__ */ React.createElement("span", null, "< ", t("common.prev_step"));
2642
2645
  if (wizard && typeof wizard === "object" && wizard.steps[wizard.step]) {
2643
2646
  const { step, steps } = wizard;
2644
2647
  if (typeof steps[step].prevText === "string") {
@@ -2648,7 +2651,7 @@
2648
2651
  }
2649
2652
  }
2650
2653
  return text;
2651
- }, [wizard]);
2654
+ }, [t, wizard]);
2652
2655
  const stepsRef = React.useRef([]);
2653
2656
  if (wizard && typeof wizard === "object" && !wizard.destroyOtherStep && wizard.steps[wizard.step]) {
2654
2657
  stepsRef.current[wizard.step] = wizard.steps[wizard.step].render;
@@ -2765,6 +2768,9 @@
2765
2768
  selectorVisible = true
2766
2769
  } = props;
2767
2770
  const sizeRef = React.useRef(size);
2771
+ const {
2772
+ t
2773
+ } = reactI18next.useTranslation();
2768
2774
  React.useEffect(() => {
2769
2775
  if (sizeRef.current === size) return;
2770
2776
  sizeRef.current = size;
@@ -2779,18 +2785,18 @@
2779
2785
  const lastRange2 = value + size;
2780
2786
  return {
2781
2787
  value: i + 1,
2782
- text: parrot.parrotI18n.t("components.pagination_range", {
2788
+ text: t("components.pagination_range", {
2783
2789
  range1: value + 1,
2784
2790
  range2: lastRange2 > count ? count : lastRange2
2785
2791
  })
2786
2792
  };
2787
2793
  });
2788
- }, [selectorVisible, count, size]);
2794
+ }, [selectorVisible, count, size, t]);
2789
2795
  let lastRange = current * size;
2790
2796
  lastRange = lastRange > count ? count : lastRange;
2791
2797
  const renderLeft = () => {
2792
2798
  if (!showTotal) return null;
2793
- const content = parrot.parrotI18n.t("components.pagination_total", {
2799
+ const content = t("components.pagination_total", {
2794
2800
  range1: (current - 1) * size + 1,
2795
2801
  range2: lastRange,
2796
2802
  total: count
@@ -2800,7 +2806,7 @@
2800
2806
  placement: "topLeft",
2801
2807
  overlayClassName: DropdownOverlayStyle,
2802
2808
  overlay: /* @__PURE__ */React.createElement(antd.Menu, null, /* @__PURE__ */React.createElement(antd.Menu.ItemGroup, {
2803
- title: parrot.parrotI18n.t("components.push_to")
2809
+ title: t("components.push_to")
2804
2810
  }, selectOptions.map(option => /* @__PURE__ */React.createElement(antd.Menu.Item, {
2805
2811
  key: option.value,
2806
2812
  onClick: () => onChange(option.value)
@@ -2835,7 +2841,7 @@
2835
2841
  onClick: () => {
2836
2842
  onChange == null ? void 0 : onChange(current - 1);
2837
2843
  }
2838
- }, parrot.parrotI18n.t("components.previous_items", {
2844
+ }, t("components.previous_items", {
2839
2845
  size
2840
2846
  })), current * size < count && /* @__PURE__ */React.createElement(Button, {
2841
2847
  className: "next-btn",
@@ -2848,7 +2854,7 @@
2848
2854
  onClick: () => {
2849
2855
  onChange == null ? void 0 : onChange(current + 1);
2850
2856
  }
2851
- }, parrot.parrotI18n.t("components.next_items", {
2857
+ }, t("components.next_items", {
2852
2858
  size
2853
2859
  }))));
2854
2860
  };
@@ -3059,11 +3065,12 @@
3059
3065
  unitClassName,
3060
3066
  abbreviate
3061
3067
  }) => {
3068
+ const { t } = reactI18next.useTranslation();
3062
3069
  if (isEmpty(rawValue)) {
3063
3070
  return Empty;
3064
3071
  }
3065
3072
  const { value, unit } = formatSeconds(rawValue, decimals);
3066
- return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: core.cx("value", valueClassName) }, value, " "), /* @__PURE__ */ React.createElement("span", { className: core.cx("unit", unitClassName) }, parrot.parrotI18n.t(`common.${abbreviate ? `${unit}_abbreviation` : unit}`)));
3073
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: core.cx("value", valueClassName) }, value, " "), /* @__PURE__ */ React.createElement("span", { className: core.cx("unit", unitClassName) }, t(`common.${abbreviate ? `${unit}_abbreviation` : unit}`)));
3067
3074
  };
3068
3075
 
3069
3076
  const inputStyle = "igz4le8";
@@ -3075,6 +3082,9 @@
3075
3082
  size,
3076
3083
  onPageChange
3077
3084
  } = props;
3085
+ const {
3086
+ t
3087
+ } = reactI18next.useTranslation();
3078
3088
  const pageLength = Math.ceil(count / size);
3079
3089
  const showPrev = current > 1;
3080
3090
  const showNext = current * size < count;
@@ -3090,7 +3100,7 @@
3090
3100
  className: cs(PaginationStyle, "pagination-wrapper", className)
3091
3101
  }, /* @__PURE__ */React.createElement("span", {
3092
3102
  className: Typo.Label.l3_regular_title
3093
- }, parrot.parrotI18n.t("components.pagination_lots_total", {
3103
+ }, t("components.pagination_lots_total", {
3094
3104
  total: count
3095
3105
  })), /* @__PURE__ */React.createElement("span", {
3096
3106
  className: "pagination-right"
@@ -3524,6 +3534,7 @@
3524
3534
  updateData,
3525
3535
  data
3526
3536
  } = props;
3537
+ const { t } = reactI18next.useTranslation();
3527
3538
  const _a = buttonProps || {}, {
3528
3539
  disabled: disabledFromProp,
3529
3540
  onClick
@@ -3564,7 +3575,7 @@
3564
3575
  },
3565
3576
  disabled
3566
3577
  }),
3567
- CustomizedButtonText || parrot.parrotI18n.t("components.add")
3578
+ CustomizedButtonText || t("components.add")
3568
3579
  ), typeof maximum === "number" ? /* @__PURE__ */ React.createElement(
3569
3580
  "span",
3570
3581
  {
@@ -3574,7 +3585,7 @@
3574
3585
  disabled && "disabled"
3575
3586
  )
3576
3587
  },
3577
- parrot.parrotI18n.t("components.maximum_row_count_desc", {
3588
+ t("components.maximum_row_count_desc", {
3578
3589
  count: maximum
3579
3590
  })
3580
3591
  ) : null);
@@ -3583,6 +3594,7 @@
3583
3594
  const AffixColumnHeaderCell = ({ data, column, onChange, onBlur }) => {
3584
3595
  const [suffix, setSuffix] = React.useState("");
3585
3596
  const [prefix, setPrefix] = React.useState("");
3597
+ const { t } = reactI18next.useTranslation();
3586
3598
  const onPrefixChange = React.useCallback(
3587
3599
  (e) => {
3588
3600
  const newPrefix = e.target.value;
@@ -3603,7 +3615,7 @@
3603
3615
  antd.Input,
3604
3616
  {
3605
3617
  value: prefix,
3606
- placeholder: parrot.parrotI18n.t("components.prefix"),
3618
+ placeholder: t("components.prefix"),
3607
3619
  size: "small",
3608
3620
  onChange: onPrefixChange,
3609
3621
  onBlur
@@ -3612,7 +3624,7 @@
3612
3624
  antd.Input,
3613
3625
  {
3614
3626
  value: suffix,
3615
- placeholder: parrot.parrotI18n.t("components.suffix"),
3627
+ placeholder: t("components.suffix"),
3616
3628
  size: "small",
3617
3629
  onChange: onSuffixChange,
3618
3630
  onBlur
@@ -3620,6 +3632,15 @@
3620
3632
  ) : void 0);
3621
3633
  };
3622
3634
 
3635
+ const CheckboxColumnHeaderCell = ({ onChange }) => {
3636
+ const _onChange = React.useCallback(
3637
+ (e) => {
3638
+ onChange(e.target.checked, true);
3639
+ },
3640
+ [onChange]
3641
+ );
3642
+ return /* @__PURE__ */ React.createElement(antd.Checkbox, { onChange: _onChange });
3643
+ };
3623
3644
  const CheckboxColumnBodyCell = ({ data, column, index, onChange }) => {
3624
3645
  const value = data[index][column.key] === void 0 ? column.defaultValue : data[index][column.key];
3625
3646
  const _onChange = React.useCallback(
@@ -3757,11 +3778,7 @@
3757
3778
  column.subTitle
3758
3779
  );
3759
3780
  };
3760
- const TextColumnBodyCell = ({
3761
- data,
3762
- column,
3763
- index
3764
- }) => {
3781
+ const TextColumnBodyCell = ({ data, column, index }) => {
3765
3782
  const text = column.displayText || data[index][column.key];
3766
3783
  const CellDescription = React.useMemo(() => {
3767
3784
  var _a, _b;
@@ -3790,7 +3807,7 @@
3790
3807
  input: InputColumnHeaderCell,
3791
3808
  password: InputColumnHeaderCell,
3792
3809
  affix: AffixColumnHeaderCell,
3793
- checkbox: TextColumnHeaderCell
3810
+ checkbox: CheckboxColumnHeaderCell
3794
3811
  };
3795
3812
  const ColumnBodyImpls = {
3796
3813
  text: TextColumnBodyCell,
@@ -3810,10 +3827,17 @@
3810
3827
  return /* @__PURE__ */React.createElement(antd.Form.Item, {
3811
3828
  className: FormItemStyle,
3812
3829
  validateStatus,
3813
- help: validateStatus ? message : ""
3830
+ help: validateStatus && message ? message : void 0
3814
3831
  }, children);
3815
3832
  };
3816
3833
 
3834
+ var ValidateTriggerType = /* @__PURE__ */ ((ValidateTriggerType2) => {
3835
+ ValidateTriggerType2[ValidateTriggerType2["Normal"] = 0] = "Normal";
3836
+ ValidateTriggerType2[ValidateTriggerType2["Aggressive"] = 1] = "Aggressive";
3837
+ ValidateTriggerType2[ValidateTriggerType2["Lazy"] = 2] = "Lazy";
3838
+ return ValidateTriggerType2;
3839
+ })(ValidateTriggerType || {});
3840
+
3817
3841
  var __defProp$5 = Object.defineProperty;
3818
3842
  var __defProps$5 = Object.defineProperties;
3819
3843
  var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
@@ -3836,40 +3860,77 @@
3836
3860
  const TableFormBodyCell = (props) => {
3837
3861
  const {
3838
3862
  column,
3839
- disabled,
3840
3863
  index: rowIndex,
3841
3864
  data,
3842
- onChange,
3843
3865
  latestData,
3866
+ validateTriggerType,
3844
3867
  isRowError,
3845
- onBlur
3868
+ getRowValidateResult,
3869
+ disabled,
3870
+ onChange,
3871
+ onBlur,
3872
+ validateAll
3846
3873
  } = props;
3874
+ const [validateResult, setValidateResult] = React.useState();
3875
+ const isTouched = React.useRef(false);
3847
3876
  const width = typeof column.width === "number" ? column.width + "px" : column.width;
3848
- const _onChange = React.useCallback(
3849
- (value, data2) => {
3850
- const newData = data2.map(
3851
- (row, i) => i === rowIndex ? __spreadProps$5(__spreadValues$5({}, row), { [column.key]: value }) : row
3852
- );
3853
- onChange == null ? void 0 : onChange(newData, rowIndex, column.key);
3877
+ const triggerValidate = React.useCallback(
3878
+ (currentValue) => {
3879
+ var _a;
3880
+ const value = currentValue || data[rowIndex][column.key];
3881
+ const rowData = __spreadProps$5(__spreadValues$5({}, data[rowIndex]), { [column.key]: value });
3882
+ const rowValidateRes = getRowValidateResult(rowData);
3883
+ if (rowValidateRes) {
3884
+ return;
3885
+ }
3886
+ const result = (_a = column.validator) == null ? void 0 : _a.call(column, {
3887
+ value,
3888
+ rowIndex,
3889
+ rowData: data[rowIndex]
3890
+ });
3891
+ const isError = result ? typeof result === "string" : false;
3892
+ setValidateResult({ msg: result || "", isError });
3854
3893
  },
3855
- [rowIndex, onChange, column]
3894
+ [data, column, rowIndex, getRowValidateResult]
3856
3895
  );
3896
+ React.useEffect(() => {
3897
+ if (validateAll) {
3898
+ isTouched.current = true;
3899
+ triggerValidate();
3900
+ }
3901
+ }, [validateAll, triggerValidate]);
3902
+ const _onChange = (value, data2) => {
3903
+ const newData = data2.map(
3904
+ (row, i) => i === rowIndex ? __spreadProps$5(__spreadValues$5({}, row), { [column.key]: value }) : row
3905
+ );
3906
+ onChange == null ? void 0 : onChange(newData, rowIndex, column.key);
3907
+ if (validateTriggerType === ValidateTriggerType.Normal && isTouched.current || validateTriggerType === ValidateTriggerType.Aggressive) {
3908
+ triggerValidate(value);
3909
+ }
3910
+ };
3857
3911
  const _onBlur = React.useCallback(() => {
3912
+ isTouched.current = true;
3913
+ triggerValidate();
3858
3914
  onBlur == null ? void 0 : onBlur(data, rowIndex, column.key);
3859
- }, [rowIndex, column, onBlur, data]);
3915
+ }, [rowIndex, column, onBlur, data, triggerValidate]);
3860
3916
  const renderDefaultComponent = () => {
3861
3917
  if (!column.type)
3862
3918
  return null;
3863
3919
  const CellComponent = ColumnBodyImpls[column.type];
3864
3920
  return /* @__PURE__ */ React.createElement(
3865
3921
  CellComponent,
3866
- __spreadProps$5(__spreadValues$5({}, props), {
3867
- customData: column.customData,
3922
+ {
3923
+ disabled,
3924
+ data,
3925
+ index: rowIndex,
3926
+ latestData,
3927
+ column,
3928
+ visible: props.visible,
3868
3929
  onChange: (val) => {
3869
3930
  _onChange(val, data);
3870
3931
  },
3871
3932
  onBlur: _onBlur
3872
- })
3933
+ }
3873
3934
  );
3874
3935
  };
3875
3936
  const Cell = column.render ? column.render({
@@ -3894,24 +3955,6 @@
3894
3955
  })) || null;
3895
3956
  return typeof Result === "string" ? /* @__PURE__ */ React.createElement("p", { className: core.cx(Typo.Label.l4_regular, "cell-description") }, Result) : Result;
3896
3957
  }, [rowIndex, data, latestData, column]);
3897
- const validateResult = React.useMemo(() => {
3898
- var _a;
3899
- if (isRowError) {
3900
- return {
3901
- msg: "",
3902
- isError: true
3903
- };
3904
- }
3905
- const value = data[rowIndex][column.key];
3906
- const result = (_a = column.validator) == null ? void 0 : _a.call(column, {
3907
- value,
3908
- rowIndex,
3909
- rowData: data[rowIndex]
3910
- });
3911
- if (typeof result === "string" && result) {
3912
- return { msg: result, isError: true };
3913
- }
3914
- }, [data, column, rowIndex, isRowError]);
3915
3958
  return /* @__PURE__ */ React.createElement(
3916
3959
  "div",
3917
3960
  {
@@ -3925,8 +3968,8 @@
3925
3968
  /* @__PURE__ */ React.createElement(
3926
3969
  FormItem,
3927
3970
  {
3928
- validateStatus: (validateResult == null ? void 0 : validateResult.isError) ? "error" : "",
3929
- message: (validateResult == null ? void 0 : validateResult.isError) && validateResult.msg ? validateResult.msg : void 0
3971
+ validateStatus: isRowError || (validateResult == null ? void 0 : validateResult.isError) ? "error" : "",
3972
+ message: isRowError ? "" : validateResult == null ? void 0 : validateResult.msg
3930
3973
  },
3931
3974
  Cell
3932
3975
  ),
@@ -3960,24 +4003,36 @@
3960
4003
  latestData,
3961
4004
  disabled,
3962
4005
  passwordVisible,
3963
- deletable,
4006
+ deleteConfig,
3964
4007
  draggable,
3965
4008
  rowIndex,
3966
4009
  provided,
3967
4010
  snapshot,
4011
+ validateTriggerType = ValidateTriggerType.Normal,
3968
4012
  updateData,
3969
4013
  onBodyBlur,
3970
4014
  renderRowDescription,
3971
- rowValidator
4015
+ rowValidator,
4016
+ validateAll
3972
4017
  } = props;
4018
+ const { t } = reactI18next.useTranslation();
3973
4019
  const rowData = data[rowIndex];
3974
- const deleteRow = (index, data2) => {
3975
- const newData = [...data2];
3976
- newData.splice(index, 1);
3977
- updateData(newData);
3978
- };
3979
- const getRowActions = (index, rowDeletable) => {
3980
- const isRowDeleteDisabled = rowDeletable === false;
4020
+ const [rowError, setRowError] = React.useState();
4021
+ const deleteRow = React.useCallback(
4022
+ (index, data2) => {
4023
+ const newData = [...data2];
4024
+ newData.splice(index, 1);
4025
+ updateData(newData);
4026
+ },
4027
+ [updateData]
4028
+ );
4029
+ const RowActions = React.useMemo(() => {
4030
+ var _a;
4031
+ const isRowDeleteDisabled = (_a = deleteConfig == null ? void 0 : deleteConfig.specifyRowDeleteDisabled) == null ? void 0 : _a.call(
4032
+ deleteConfig,
4033
+ rowIndex,
4034
+ data
4035
+ );
3981
4036
  const DeleteIcon = /* @__PURE__ */ React.createElement(
3982
4037
  Icon,
3983
4038
  {
@@ -3987,20 +4042,21 @@
3987
4042
  onClick: () => {
3988
4043
  if (isRowDeleteDisabled)
3989
4044
  return;
3990
- deleteRow(index, data);
4045
+ deleteRow(rowIndex, data);
3991
4046
  }
3992
4047
  }
3993
4048
  );
3994
- const FinalRenderIcon = isRowDeleteDisabled ? DeleteIcon : /* @__PURE__ */ React.createElement(Tooltip, { title: parrot.parrotI18n.t("components.remove") }, DeleteIcon);
3995
- return deletable ? [FinalRenderIcon] : void 0;
3996
- };
3997
- const RowValidateResult = React.useMemo(() => {
3998
- const result = rowValidator == null ? void 0 : rowValidator(rowIndex, data[rowIndex]);
3999
- if (typeof result === "string" && result) {
4000
- return /* @__PURE__ */ React.createElement("p", { className: core.cx(Typo.Label.l4_regular, "row-error-message") }, result);
4001
- }
4002
- return null;
4003
- }, [rowValidator, rowIndex, data]);
4049
+ const FinalRenderIcon = isRowDeleteDisabled ? DeleteIcon : /* @__PURE__ */ React.createElement(Tooltip, { title: t("components.remove") }, DeleteIcon);
4050
+ return (deleteConfig == null ? void 0 : deleteConfig.deletable) ? [FinalRenderIcon] : void 0;
4051
+ }, [rowIndex, deleteConfig, data, deleteRow]);
4052
+ const getRowValidateResult = React.useCallback(
4053
+ (rowData2) => {
4054
+ const result = rowValidator == null ? void 0 : rowValidator(rowIndex, rowData2);
4055
+ setRowError(result);
4056
+ return result;
4057
+ },
4058
+ [rowValidator, rowIndex]
4059
+ );
4004
4060
  const Cells = columns.map((col) => {
4005
4061
  return /* @__PURE__ */ React.createElement(
4006
4062
  TableFormBodyCell,
@@ -4014,7 +4070,10 @@
4014
4070
  onChange: updateData,
4015
4071
  onBlur: onBodyBlur,
4016
4072
  visible: passwordVisible,
4017
- isRowError: !!RowValidateResult
4073
+ validateTriggerType,
4074
+ isRowError: !!rowError,
4075
+ getRowValidateResult,
4076
+ validateAll
4018
4077
  }
4019
4078
  );
4020
4079
  });
@@ -4044,11 +4103,11 @@
4044
4103
  "eagle-table-form-row",
4045
4104
  (snapshot == null ? void 0 : snapshot.isDragging) && "isDragging"
4046
4105
  ),
4047
- actions: getRowActions(rowIndex, rowData.deletable)
4106
+ actions: RowActions
4048
4107
  },
4049
4108
  DraggableHandle,
4050
4109
  Cells,
4051
- RowValidateResult,
4110
+ rowError ? /* @__PURE__ */ React.createElement("p", { className: core.cx(Typo.Label.l4_regular, "row-error-message") }, rowError) : null,
4052
4111
  RowDescription
4053
4112
  );
4054
4113
  };
@@ -4116,7 +4175,7 @@
4116
4175
  const [errMsg, setErrMsg] = React.useState();
4117
4176
  const width = Number.isNaN(Number(column.width)) ? column.width : column.width + "px";
4118
4177
  const headerOnChange = React.useCallback(
4119
- (value) => {
4178
+ (value, shouldUpdateData = false) => {
4120
4179
  var _a;
4121
4180
  const err = (_a = column.validator) == null ? void 0 : _a.call(column, { value, isHeader: true });
4122
4181
  setErrMsg(err || void 0);
@@ -4126,7 +4185,7 @@
4126
4185
  [column.key]: shouldAutoIncrease && typeof value === "string" ? increaseLastNumber(value, rowIndex) : value
4127
4186
  });
4128
4187
  });
4129
- onChange == null ? void 0 : onChange(newData, column.key);
4188
+ onChange == null ? void 0 : onChange(newData, column.key, shouldUpdateData);
4130
4189
  },
4131
4190
  [onChange, data, column]
4132
4191
  );
@@ -4162,14 +4221,14 @@
4162
4221
  visibility: column.hidden ? "hidden" : "visible"
4163
4222
  }
4164
4223
  },
4165
- /* @__PURE__ */ React.createElement(
4224
+ /* @__PURE__ */ React.createElement("p", { className: core.cx(Typo.Label.l3_bold_title, TitleStyle) }, column.title),
4225
+ disableBatchFilling ? null : /* @__PURE__ */ React.createElement(
4166
4226
  FormItem,
4167
4227
  {
4168
4228
  validateStatus: typeof errMsg === "string" && errMsg ? "error" : "",
4169
4229
  message: errMsg || void 0
4170
4230
  },
4171
- /* @__PURE__ */ React.createElement("p", { className: core.cx(Typo.Label.l3_bold_title, TitleStyle) }, column.title),
4172
- disableBatchFilling ? null : renderCell()
4231
+ renderCell()
4173
4232
  )
4174
4233
  );
4175
4234
  };
@@ -4196,16 +4255,18 @@
4196
4255
  const DEFAULT_ROW_COUNT = 3;
4197
4256
  const TableForm = React.forwardRef(
4198
4257
  ({
4199
- defaultData,
4258
+ defaultData = [],
4200
4259
  columns,
4201
4260
  disabled,
4202
4261
  rowAddConfig,
4203
- deletable,
4262
+ deleteConfig,
4204
4263
  size = "default",
4205
4264
  className,
4206
4265
  draggable,
4207
4266
  disableBatchFilling = false,
4208
4267
  rowSplitType = "border",
4268
+ validateTriggerType,
4269
+ maxHeight,
4209
4270
  renderRowDescription,
4210
4271
  rowValidator,
4211
4272
  onHeaderChange,
@@ -4213,12 +4274,10 @@
4213
4274
  onBodyChange,
4214
4275
  onBodyBlur
4215
4276
  }, ref) => {
4216
- const treatedDefaultData = React.useMemo(() => {
4217
- return defaultData || [...Array(DEFAULT_ROW_COUNT)].map(() => genEmptyRow(columns));
4218
- }, [defaultData, columns]);
4219
- const [data, setData] = React.useState(treatedDefaultData);
4277
+ const [data, setData] = React.useState(defaultData);
4220
4278
  const [passwordVisible, setPasswordVisible] = React.useState(false);
4221
- const [latestData, setLatestData] = React.useState(treatedDefaultData);
4279
+ const [latestData, setLatestData] = React.useState(defaultData);
4280
+ const [validateAll, setValidateAll] = React.useState(false);
4222
4281
  const updateData = React.useCallback(
4223
4282
  (value, rowIndex, columnKey) => {
4224
4283
  setLatestData(value);
@@ -4227,12 +4286,23 @@
4227
4286
  },
4228
4287
  [onBodyChange]
4229
4288
  );
4289
+ React.useLayoutEffect(() => {
4290
+ if (defaultData.length === 0) {
4291
+ updateData(
4292
+ [...Array(DEFAULT_ROW_COUNT)].map(() => genEmptyRow(columns))
4293
+ );
4294
+ }
4295
+ }, []);
4230
4296
  const handleBatchChange = React.useCallback(
4231
- (newData, columnKey) => {
4297
+ (newData, columnKey, shouldUpdateData) => {
4232
4298
  setLatestData(newData);
4233
4299
  onHeaderChange == null ? void 0 : onHeaderChange(newData, columnKey);
4300
+ if (shouldUpdateData) {
4301
+ setData(newData);
4302
+ onBodyChange == null ? void 0 : onBodyChange(newData, void 0, columnKey);
4303
+ }
4234
4304
  },
4235
- [onHeaderChange]
4305
+ [onHeaderChange, onBodyChange]
4236
4306
  );
4237
4307
  const handleBatchBlur = React.useCallback(
4238
4308
  (key, error) => {
@@ -4257,6 +4327,9 @@
4257
4327
  () => ({
4258
4328
  setData: (data2) => {
4259
4329
  updateData(data2);
4330
+ },
4331
+ validateWholeFields() {
4332
+ setValidateAll(true);
4260
4333
  }
4261
4334
  }),
4262
4335
  [updateData]
@@ -4277,31 +4350,46 @@
4277
4350
  }
4278
4351
  );
4279
4352
  });
4280
- return /* @__PURE__ */ React.createElement("div", { className }, /* @__PURE__ */ React.createElement(TableFormWrapper, { className: `table-form row-split-by-${rowSplitType}` }, /* @__PURE__ */ React.createElement(antd.List, { size, className: `size-${size}` }, /* @__PURE__ */ React.createElement(
4281
- antd.List.Item,
4353
+ const tableFormWrapperStyle = React.useMemo(
4354
+ () => maxHeight ? {
4355
+ maxHeight: typeof maxHeight === "number" ? maxHeight + "px" : maxHeight
4356
+ } : void 0,
4357
+ []
4358
+ );
4359
+ return /* @__PURE__ */ React.createElement("div", { className }, /* @__PURE__ */ React.createElement(
4360
+ TableFormWrapper,
4282
4361
  {
4283
- className: "eagle-table-form-header",
4284
- actions: deletable ? [/* @__PURE__ */ React.createElement(React.Fragment, null)] : void 0
4362
+ className: `table-form row-split-by-${rowSplitType}`,
4363
+ style: tableFormWrapperStyle
4285
4364
  },
4286
- draggable ? /* @__PURE__ */ React.createElement(DraggableHandleWrapper, null) : null,
4287
- headerCells
4288
- ), /* @__PURE__ */ React.createElement(
4289
- TableFormBodyRows,
4290
- {
4291
- data,
4292
- latestData,
4293
- columns,
4294
- passwordVisible,
4295
- deletable,
4296
- disabled,
4297
- draggable,
4298
- rowSplitType,
4299
- onBodyBlur,
4300
- updateData,
4301
- renderRowDescription,
4302
- rowValidator
4303
- }
4304
- ))), (rowAddConfig == null ? void 0 : rowAddConfig.addible) ? /* @__PURE__ */ React.createElement(
4365
+ /* @__PURE__ */ React.createElement(antd.List, { size, className: `size-${size}` }, /* @__PURE__ */ React.createElement(
4366
+ antd.List.Item,
4367
+ {
4368
+ className: "eagle-table-form-header",
4369
+ actions: (deleteConfig == null ? void 0 : deleteConfig.deletable) ? [/* @__PURE__ */ React.createElement(React.Fragment, null)] : void 0
4370
+ },
4371
+ draggable ? /* @__PURE__ */ React.createElement(DraggableHandleWrapper, null) : null,
4372
+ headerCells
4373
+ ), /* @__PURE__ */ React.createElement(
4374
+ TableFormBodyRows,
4375
+ {
4376
+ data,
4377
+ latestData,
4378
+ columns,
4379
+ passwordVisible,
4380
+ deleteConfig,
4381
+ disabled,
4382
+ draggable,
4383
+ rowSplitType,
4384
+ validateTriggerType,
4385
+ onBodyBlur,
4386
+ updateData,
4387
+ renderRowDescription,
4388
+ rowValidator,
4389
+ validateAll
4390
+ }
4391
+ ))
4392
+ ), (rowAddConfig == null ? void 0 : rowAddConfig.addible) ? /* @__PURE__ */ React.createElement(
4305
4393
  AddRowButton,
4306
4394
  {
4307
4395
  config: rowAddConfig,
@@ -4355,6 +4443,9 @@
4355
4443
  defaultOptionValue
4356
4444
  } = props;
4357
4445
  const [innerValue, setInnerValue] = React.useState(value);
4446
+ const {
4447
+ t
4448
+ } = reactI18next.useTranslation();
4358
4449
  const defaultTz = React.useMemo(() => {
4359
4450
  return allTimeZones.find(tz => tz.value === defaultOptionValue);
4360
4451
  }, [defaultOptionValue]);
@@ -4397,7 +4488,7 @@
4397
4488
  return /* @__PURE__ */React.createElement(Select, {
4398
4489
  className: core.cx(SelectStyle, className),
4399
4490
  dropdownClassName: DropdownStyle,
4400
- placeholder: /* @__PURE__ */React.createElement("span", null, placeholder || parrot.parrotI18n.t("components.time_zone_select_placeholder")),
4491
+ placeholder: /* @__PURE__ */React.createElement("span", null, placeholder || t("components.time_zone_select_placeholder")),
4401
4492
  value: innerValue,
4402
4493
  onChange: _onChange,
4403
4494
  showSearch: true,
@@ -4409,26 +4500,26 @@
4409
4500
  input: {}
4410
4501
  }, defaultTz ? /* @__PURE__ */React.createElement(antd.Select.Option, {
4411
4502
  value: DefaultTimeValue,
4412
- label: parrot.parrotI18n.t("components.default_time_zone"),
4503
+ label: `${t("components.default_time_zone")} (${getUTCOffsetText(defaultTz.offset)})`,
4413
4504
  className: OptionWrapperStyle
4414
4505
  }, /* @__PURE__ */React.createElement(TimeZoneOption, {
4415
4506
  key: DefaultTimeValue,
4416
- customLabel: parrot.parrotI18n.t("components.default_time_zone"),
4507
+ customLabel: t("components.default_time_zone"),
4417
4508
  timeZone: defaultTz
4418
4509
  })) : void 0, /* @__PURE__ */React.createElement(antd.Select.Option, {
4419
4510
  value: BrowserTimeValue,
4420
- label: parrot.parrotI18n.t("components.browser_time_zone"),
4511
+ label: `${t("components.browser_time_zone")} (${getUTCOffsetText(browserTz.offset)})`,
4421
4512
  className: OptionWrapperStyle
4422
4513
  }, /* @__PURE__ */React.createElement(TimeZoneOption, {
4423
4514
  key: BrowserTimeValue,
4424
- customLabel: parrot.parrotI18n.t("components.browser_time_zone"),
4515
+ customLabel: t("components.browser_time_zone"),
4425
4516
  timeZone: browserTz
4426
4517
  })), /* @__PURE__ */React.createElement(antd.Select.Option, {
4427
4518
  value: "UTC",
4428
4519
  className: OptionWrapperStyle
4429
4520
  }, /* @__PURE__ */React.createElement(TimeZoneOption, {
4430
4521
  key: "utc",
4431
- customLabel: parrot.parrotI18n.t("components.coorddinated_universal_time"),
4522
+ customLabel: t("components.coorddinated_universal_time"),
4432
4523
  timeZone: {
4433
4524
  value: "UTC",
4434
4525
  text: "UTC",
@@ -4437,18 +4528,20 @@
4437
4528
  }
4438
4529
  })), timeZoneOptionGroups);
4439
4530
  };
4531
+ function getUTCOffsetText(offset) {
4532
+ if (offset === 0) {
4533
+ return "UTC";
4534
+ } else if (offset < 0) {
4535
+ return `UTC${offset}:00`;
4536
+ } else {
4537
+ return `UTC+${offset}:00`;
4538
+ }
4539
+ }
4440
4540
  const TimeZoneOption = ({
4441
4541
  timeZone,
4442
4542
  customLabel
4443
4543
  }) => {
4444
- let tagText = "";
4445
- if (timeZone.offset === 0) {
4446
- tagText = "UTC";
4447
- } else if (timeZone.offset < 0) {
4448
- tagText = `UTC${timeZone.offset}:00`;
4449
- } else {
4450
- tagText = `UTC+${timeZone.offset}:00`;
4451
- }
4544
+ let tagText = getUTCOffsetText(timeZone.offset);
4452
4545
  return /* @__PURE__ */React.createElement(React.Fragment, null, /* @__PURE__ */React.createElement("div", {
4453
4546
  className: OptionFirstLineStyle
4454
4547
  }, /* @__PURE__ */React.createElement("span", {
@@ -4472,6 +4565,7 @@
4472
4565
  pagination: Pagination,
4473
4566
  select: Select,
4474
4567
  option: antd.Select.Option,
4568
+ selectOptGroup: antd.Select.OptGroup,
4475
4569
  table: Table,
4476
4570
  row: antd.Row,
4477
4571
  col: antd.Col,
@@ -4543,7 +4637,8 @@
4543
4637
  antdMessage: antd.message,
4544
4638
  antdButton: antd.Button,
4545
4639
  antdSelect: antd.Select,
4546
- antdTooltip: antd.Tooltip
4640
+ antdTooltip: antd.Tooltip,
4641
+ antdModal: antd.Modal
4547
4642
  };
4548
4643
  kit.option.isSelectOption = true;
4549
4644
  kit.button.__ANT_BUTTON = true;
@@ -4577,6 +4672,9 @@
4577
4672
  title,
4578
4673
  refetchText
4579
4674
  } = props;
4675
+ const {
4676
+ t
4677
+ } = reactI18next.useTranslation();
4580
4678
  return /* @__PURE__ */React.createElement("div", {
4581
4679
  className: cs(FailedLoadStyle, className),
4582
4680
  title
@@ -4585,7 +4683,7 @@
4585
4683
  }, String(error)), /* @__PURE__ */React.createElement(Button, {
4586
4684
  type: "ordinary",
4587
4685
  onClick: () => refetch()
4588
- }, refetchText || parrot.parrotI18n.t("common.retry")));
4686
+ }, refetchText || t("common.retry")));
4589
4687
  };
4590
4688
 
4591
4689
  function getRangeTimestamp(dateRange) {
@@ -4688,7 +4786,7 @@
4688
4786
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
4689
4787
  const kitContext = React.createContext(antdKit);
4690
4788
  const UIKitProvider = (props) => {
4691
- const { children, kit = antdKit, message } = props;
4789
+ const { children, kit = antdKit, message, antdConfig } = props;
4692
4790
  const _kit = React.useMemo(() => {
4693
4791
  if ((message == null ? void 0 : message.batch) != null) {
4694
4792
  return __spreadProps(__spreadValues({}, kit), {
@@ -4697,7 +4795,7 @@
4697
4795
  }
4698
4796
  return kit;
4699
4797
  }, [kit, message == null ? void 0 : message.batch]);
4700
- return /* @__PURE__ */ React.createElement(kitContext.Provider, { value: _kit }, children);
4798
+ return /* @__PURE__ */ React.createElement(reactI18next.I18nextProvider, { i18n: parrot.parrotI18n }, /* @__PURE__ */ React.createElement(kitContext.Provider, { value: _kit }, /* @__PURE__ */ React.createElement(antd.ConfigProvider, __spreadValues({ autoInsertSpaceInButton: false }, antdConfig), children)));
4701
4799
  };
4702
4800
  const useUIKit = () => {
4703
4801
  return React.useContext(kitContext);
@@ -4716,6 +4814,7 @@
4716
4814
  exports.ButtonStyle = ButtonStyle;
4717
4815
  exports.EntityAsyncStatus = EntityAsyncStatus;
4718
4816
  exports.FailedLoad = FailedLoad;
4817
+ exports.FullView = FullView;
4719
4818
  exports.Icon = Icon;
4720
4819
  exports.InputTagItem = InputTagItem;
4721
4820
  exports.KitStoreProvider = KitStoreProvider;
@@ -4726,6 +4825,8 @@
4726
4825
  exports.UIKitProvider = UIKitProvider;
4727
4826
  exports.UIKitStore = UIKitStore;
4728
4827
  exports.UserSource = UserSource;
4828
+ exports.ValidateTriggerType = ValidateTriggerType;
4829
+ exports.WizardBody = WizardBody;
4729
4830
  exports.antdKit = antdKit;
4730
4831
  exports.closeModal = closeModal;
4731
4832
  exports.createBatchMessageMethods = createBatchMessageMethods;