@cloudtower/eagle 0.23.0 → 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.
@@ -1,3 +1,4 @@
1
+ import { ConfigProviderProps } from "antd/lib/config-provider";
1
2
  import React, { PropsWithChildren } from "react";
2
3
  import { BatchHelper } from "../components";
3
4
  import { Kit } from "../spec";
@@ -6,6 +7,7 @@ interface IProps {
6
7
  message?: {
7
8
  batch?: BatchHelper;
8
9
  };
10
+ antdConfig?: ConfigProviderProps;
9
11
  }
10
12
  export declare const kitContext: React.Context<Kit<any, HTMLElement>>;
11
13
  declare const UIKitProvider: (props: PropsWithChildren<IProps>) => JSX.Element;
package/dist/esm/index.js CHANGED
@@ -1,10 +1,9 @@
1
- import { Alert as Alert$1, Badge as Badge$1, Button as Button$1, Tooltip as Tooltip$1, Checkbox as Checkbox$1, DatePicker, Select as Select$1, InputNumber as InputNumber$1, Input as Input$1, TimePicker as TimePicker$1, message, Modal as Modal$1, Steps as Steps$1, Dropdown, Menu, Progress as Progress$1, Radio as Radio$1, Switch as Switch$1, Table as Table$1, Space, Form, List, Tag, Row, Col, Tree, Divider, Skeleton, Layout, AutoComplete, Popover, Timeline, Typography, Cascader, Upload, Calendar, Tabs } from 'antd';
1
+ import { Alert as Alert$1, Badge as Badge$1, Button as Button$1, Tooltip as Tooltip$1, Checkbox as Checkbox$1, DatePicker, Select as Select$1, InputNumber as InputNumber$1, Input as Input$1, TimePicker as TimePicker$1, message, Modal as Modal$1, Steps as Steps$1, Dropdown, Menu, Progress as Progress$1, Radio as Radio$1, Switch as Switch$1, Table as Table$1, Space, Form, List, Tag, Row, Col, Tree, Divider, Skeleton, Layout, AutoComplete, Popover, Timeline, Typography, Cascader, Upload, Calendar, Tabs, ConfigProvider } from 'antd';
2
2
  export { Col, Row } from 'antd';
3
3
  import React, { useState, useMemo, useRef, useCallback, useEffect, Fragment, useLayoutEffect, createContext, memo, useImperativeHandle, useContext } from 'react';
4
4
  import cs from 'classnames';
5
5
  import _, { uniqBy, groupBy, sortBy, toPairs } from 'lodash';
6
- import { parrotI18n } from '@cloudtower/parrot';
7
- export * from '@cloudtower/parrot';
6
+ import { useTranslation, withTranslation, I18nextProvider } from 'react-i18next';
8
7
  import { cx } from '@linaria/core';
9
8
  import { styled } from '@linaria/react';
10
9
  import moment from 'moment';
@@ -16,7 +15,8 @@ import { createDispatchHook, createSelectorHook, Provider } from 'react-redux';
16
15
  import { XmarkRemove16SecondaryIcon, XmarkRemove16RegularRedIcon, HandlePoint816SecondaryIcon, HandlePoint816BlueIcon, CheckmarkDoneSuccessCorrect16BlueIcon } from '@cloudtower/icons-react';
17
16
  import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
18
17
  import TimeZones from 'timezones.json';
19
- import { withTranslation } from 'react-i18next';
18
+ import { parrotI18n } from '@cloudtower/parrot';
19
+ export * from '@cloudtower/parrot';
20
20
  import dayjs from 'dayjs';
21
21
  import 'recharts';
22
22
 
@@ -477,10 +477,11 @@ const Alert = (_a) => {
477
477
  };
478
478
 
479
479
  const Arch = (props) => {
480
+ const { t } = useTranslation();
480
481
  const { architecture } = props;
481
482
  let text = "";
482
483
  if (architecture) {
483
- text = parrotI18n.t(`components.Architecture_${architecture}`);
484
+ text = t(`components.Architecture_${architecture}`);
484
485
  }
485
486
  return /* @__PURE__ */ React.createElement("span", null, text);
486
487
  };
@@ -975,11 +976,12 @@ const Byte = ({
975
976
  valueClassName,
976
977
  unitClassName
977
978
  }) => {
979
+ const { t } = useTranslation();
978
980
  if (isEmpty(rawValue)) {
979
981
  return Empty;
980
982
  }
981
983
  if (rawValue === -1) {
982
- return /* @__PURE__ */ React.createElement("span", null, parrotI18n.t("common.calculation"));
984
+ return /* @__PURE__ */ React.createElement("span", null, t("common.calculation"));
983
985
  }
984
986
  const { value, unit } = formatBytes(rawValue, decimals);
985
987
  if (noUnitOnZero && value === 0) {
@@ -2597,10 +2599,11 @@ var __objRest$5 = (source, exclude) => {
2597
2599
  };
2598
2600
  const Modal = (props) => {
2599
2601
  var _b;
2602
+ const { t } = useTranslation();
2600
2603
  const _a = props, {
2601
2604
  error,
2602
- okText = parrotI18n.t("common.confirm"),
2603
- cancelText = parrotI18n.t("common.cancel"),
2605
+ okText = t("common.confirm"),
2606
+ cancelText = t("common.cancel"),
2604
2607
  confirmLoading,
2605
2608
  okButtonProps,
2606
2609
  onOk,
@@ -2649,12 +2652,12 @@ const Modal = (props) => {
2649
2652
  let text = (okButtonProps == null ? void 0 : okButtonProps.children) || okText;
2650
2653
  if (wizard && typeof wizard === "object" && wizard.steps[wizard.step]) {
2651
2654
  const { step, steps } = wizard;
2652
- text = step < steps.length - 1 ? steps[step].okText || parrotI18n.t("common.next_step") : steps[step].okText || text;
2655
+ text = step < steps.length - 1 ? steps[step].okText || t("common.next_step") : steps[step].okText || text;
2653
2656
  }
2654
2657
  return text;
2655
- }, [okButtonProps, okText, wizard]);
2658
+ }, [okButtonProps == null ? void 0 : okButtonProps.children, okText, t, wizard]);
2656
2659
  const prevText = useMemo(() => {
2657
- let text = /* @__PURE__ */ React.createElement("span", null, "< ", parrotI18n.t("common.prev_step"));
2660
+ let text = /* @__PURE__ */ React.createElement("span", null, "< ", t("common.prev_step"));
2658
2661
  if (wizard && typeof wizard === "object" && wizard.steps[wizard.step]) {
2659
2662
  const { step, steps } = wizard;
2660
2663
  if (typeof steps[step].prevText === "string") {
@@ -2664,7 +2667,7 @@ const Modal = (props) => {
2664
2667
  }
2665
2668
  }
2666
2669
  return text;
2667
- }, [wizard]);
2670
+ }, [t, wizard]);
2668
2671
  const stepsRef = useRef([]);
2669
2672
  if (wizard && typeof wizard === "object" && !wizard.destroyOtherStep && wizard.steps[wizard.step]) {
2670
2673
  stepsRef.current[wizard.step] = wizard.steps[wizard.step].render;
@@ -2781,6 +2784,9 @@ const Pagination = props => {
2781
2784
  selectorVisible = true
2782
2785
  } = props;
2783
2786
  const sizeRef = useRef(size);
2787
+ const {
2788
+ t
2789
+ } = useTranslation();
2784
2790
  useEffect(() => {
2785
2791
  if (sizeRef.current === size) return;
2786
2792
  sizeRef.current = size;
@@ -2795,18 +2801,18 @@ const Pagination = props => {
2795
2801
  const lastRange2 = value + size;
2796
2802
  return {
2797
2803
  value: i + 1,
2798
- text: parrotI18n.t("components.pagination_range", {
2804
+ text: t("components.pagination_range", {
2799
2805
  range1: value + 1,
2800
2806
  range2: lastRange2 > count ? count : lastRange2
2801
2807
  })
2802
2808
  };
2803
2809
  });
2804
- }, [selectorVisible, count, size]);
2810
+ }, [selectorVisible, count, size, t]);
2805
2811
  let lastRange = current * size;
2806
2812
  lastRange = lastRange > count ? count : lastRange;
2807
2813
  const renderLeft = () => {
2808
2814
  if (!showTotal) return null;
2809
- const content = parrotI18n.t("components.pagination_total", {
2815
+ const content = t("components.pagination_total", {
2810
2816
  range1: (current - 1) * size + 1,
2811
2817
  range2: lastRange,
2812
2818
  total: count
@@ -2816,7 +2822,7 @@ const Pagination = props => {
2816
2822
  placement: "topLeft",
2817
2823
  overlayClassName: DropdownOverlayStyle,
2818
2824
  overlay: /* @__PURE__ */React.createElement(Menu, null, /* @__PURE__ */React.createElement(Menu.ItemGroup, {
2819
- title: parrotI18n.t("components.push_to")
2825
+ title: t("components.push_to")
2820
2826
  }, selectOptions.map(option => /* @__PURE__ */React.createElement(Menu.Item, {
2821
2827
  key: option.value,
2822
2828
  onClick: () => onChange(option.value)
@@ -2851,7 +2857,7 @@ const Pagination = props => {
2851
2857
  onClick: () => {
2852
2858
  onChange == null ? void 0 : onChange(current - 1);
2853
2859
  }
2854
- }, parrotI18n.t("components.previous_items", {
2860
+ }, t("components.previous_items", {
2855
2861
  size
2856
2862
  })), current * size < count && /* @__PURE__ */React.createElement(Button, {
2857
2863
  className: "next-btn",
@@ -2864,7 +2870,7 @@ const Pagination = props => {
2864
2870
  onClick: () => {
2865
2871
  onChange == null ? void 0 : onChange(current + 1);
2866
2872
  }
2867
- }, parrotI18n.t("components.next_items", {
2873
+ }, t("components.next_items", {
2868
2874
  size
2869
2875
  }))));
2870
2876
  };
@@ -3075,11 +3081,12 @@ const Second = ({
3075
3081
  unitClassName,
3076
3082
  abbreviate
3077
3083
  }) => {
3084
+ const { t } = useTranslation();
3078
3085
  if (isEmpty(rawValue)) {
3079
3086
  return Empty;
3080
3087
  }
3081
3088
  const { value, unit } = formatSeconds(rawValue, decimals);
3082
- return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: cx("value", valueClassName) }, value, " "), /* @__PURE__ */ React.createElement("span", { className: cx("unit", unitClassName) }, parrotI18n.t(`common.${abbreviate ? `${unit}_abbreviation` : unit}`)));
3089
+ return /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", { className: cx("value", valueClassName) }, value, " "), /* @__PURE__ */ React.createElement("span", { className: cx("unit", unitClassName) }, t(`common.${abbreviate ? `${unit}_abbreviation` : unit}`)));
3083
3090
  };
3084
3091
 
3085
3092
  const inputStyle = "igz4le8";
@@ -3091,6 +3098,9 @@ const SimplePagination = props => {
3091
3098
  size,
3092
3099
  onPageChange
3093
3100
  } = props;
3101
+ const {
3102
+ t
3103
+ } = useTranslation();
3094
3104
  const pageLength = Math.ceil(count / size);
3095
3105
  const showPrev = current > 1;
3096
3106
  const showNext = current * size < count;
@@ -3106,7 +3116,7 @@ const SimplePagination = props => {
3106
3116
  className: cs(PaginationStyle, "pagination-wrapper", className)
3107
3117
  }, /* @__PURE__ */React.createElement("span", {
3108
3118
  className: Typo.Label.l3_regular_title
3109
- }, parrotI18n.t("components.pagination_lots_total", {
3119
+ }, t("components.pagination_lots_total", {
3110
3120
  total: count
3111
3121
  })), /* @__PURE__ */React.createElement("span", {
3112
3122
  className: "pagination-right"
@@ -3540,6 +3550,7 @@ const AddRowButton = (props) => {
3540
3550
  updateData,
3541
3551
  data
3542
3552
  } = props;
3553
+ const { t } = useTranslation();
3543
3554
  const _a = buttonProps || {}, {
3544
3555
  disabled: disabledFromProp,
3545
3556
  onClick
@@ -3580,7 +3591,7 @@ const AddRowButton = (props) => {
3580
3591
  },
3581
3592
  disabled
3582
3593
  }),
3583
- CustomizedButtonText || parrotI18n.t("components.add")
3594
+ CustomizedButtonText || t("components.add")
3584
3595
  ), typeof maximum === "number" ? /* @__PURE__ */ React.createElement(
3585
3596
  "span",
3586
3597
  {
@@ -3590,7 +3601,7 @@ const AddRowButton = (props) => {
3590
3601
  disabled && "disabled"
3591
3602
  )
3592
3603
  },
3593
- parrotI18n.t("components.maximum_row_count_desc", {
3604
+ t("components.maximum_row_count_desc", {
3594
3605
  count: maximum
3595
3606
  })
3596
3607
  ) : null);
@@ -3599,6 +3610,7 @@ const AddRowButton = (props) => {
3599
3610
  const AffixColumnHeaderCell = ({ data, column, onChange, onBlur }) => {
3600
3611
  const [suffix, setSuffix] = useState("");
3601
3612
  const [prefix, setPrefix] = useState("");
3613
+ const { t } = useTranslation();
3602
3614
  const onPrefixChange = useCallback(
3603
3615
  (e) => {
3604
3616
  const newPrefix = e.target.value;
@@ -3619,7 +3631,7 @@ const AffixColumnHeaderCell = ({ data, column, onChange, onBlur }) => {
3619
3631
  Input$1,
3620
3632
  {
3621
3633
  value: prefix,
3622
- placeholder: parrotI18n.t("components.prefix"),
3634
+ placeholder: t("components.prefix"),
3623
3635
  size: "small",
3624
3636
  onChange: onPrefixChange,
3625
3637
  onBlur
@@ -3628,7 +3640,7 @@ const AffixColumnHeaderCell = ({ data, column, onChange, onBlur }) => {
3628
3640
  Input$1,
3629
3641
  {
3630
3642
  value: suffix,
3631
- placeholder: parrotI18n.t("components.suffix"),
3643
+ placeholder: t("components.suffix"),
3632
3644
  size: "small",
3633
3645
  onChange: onSuffixChange,
3634
3646
  onBlur
@@ -4019,6 +4031,7 @@ const TableFormRow = (props) => {
4019
4031
  rowValidator,
4020
4032
  validateAll
4021
4033
  } = props;
4034
+ const { t } = useTranslation();
4022
4035
  const rowData = data[rowIndex];
4023
4036
  const [rowError, setRowError] = useState();
4024
4037
  const deleteRow = useCallback(
@@ -4049,7 +4062,7 @@ const TableFormRow = (props) => {
4049
4062
  }
4050
4063
  }
4051
4064
  );
4052
- const FinalRenderIcon = isRowDeleteDisabled ? DeleteIcon : /* @__PURE__ */ React.createElement(Tooltip, { title: parrotI18n.t("components.remove") }, DeleteIcon);
4065
+ const FinalRenderIcon = isRowDeleteDisabled ? DeleteIcon : /* @__PURE__ */ React.createElement(Tooltip, { title: t("components.remove") }, DeleteIcon);
4053
4066
  return (deleteConfig == null ? void 0 : deleteConfig.deletable) ? [FinalRenderIcon] : void 0;
4054
4067
  }, [rowIndex, deleteConfig, data, deleteRow]);
4055
4068
  const getRowValidateResult = useCallback(
@@ -4446,6 +4459,9 @@ const TimeZoneSelect = props => {
4446
4459
  defaultOptionValue
4447
4460
  } = props;
4448
4461
  const [innerValue, setInnerValue] = useState(value);
4462
+ const {
4463
+ t
4464
+ } = useTranslation();
4449
4465
  const defaultTz = useMemo(() => {
4450
4466
  return allTimeZones.find(tz => tz.value === defaultOptionValue);
4451
4467
  }, [defaultOptionValue]);
@@ -4488,7 +4504,7 @@ const TimeZoneSelect = props => {
4488
4504
  return /* @__PURE__ */React.createElement(Select, {
4489
4505
  className: cx(SelectStyle, className),
4490
4506
  dropdownClassName: DropdownStyle,
4491
- placeholder: /* @__PURE__ */React.createElement("span", null, placeholder || parrotI18n.t("components.time_zone_select_placeholder")),
4507
+ placeholder: /* @__PURE__ */React.createElement("span", null, placeholder || t("components.time_zone_select_placeholder")),
4492
4508
  value: innerValue,
4493
4509
  onChange: _onChange,
4494
4510
  showSearch: true,
@@ -4500,26 +4516,26 @@ const TimeZoneSelect = props => {
4500
4516
  input: {}
4501
4517
  }, defaultTz ? /* @__PURE__ */React.createElement(Select$1.Option, {
4502
4518
  value: DefaultTimeValue,
4503
- label: `${parrotI18n.t("components.default_time_zone")} (${getUTCOffsetText(defaultTz.offset)})`,
4519
+ label: `${t("components.default_time_zone")} (${getUTCOffsetText(defaultTz.offset)})`,
4504
4520
  className: OptionWrapperStyle
4505
4521
  }, /* @__PURE__ */React.createElement(TimeZoneOption, {
4506
4522
  key: DefaultTimeValue,
4507
- customLabel: parrotI18n.t("components.default_time_zone"),
4523
+ customLabel: t("components.default_time_zone"),
4508
4524
  timeZone: defaultTz
4509
4525
  })) : void 0, /* @__PURE__ */React.createElement(Select$1.Option, {
4510
4526
  value: BrowserTimeValue,
4511
- label: `${parrotI18n.t("components.browser_time_zone")} (${getUTCOffsetText(browserTz.offset)})`,
4527
+ label: `${t("components.browser_time_zone")} (${getUTCOffsetText(browserTz.offset)})`,
4512
4528
  className: OptionWrapperStyle
4513
4529
  }, /* @__PURE__ */React.createElement(TimeZoneOption, {
4514
4530
  key: BrowserTimeValue,
4515
- customLabel: parrotI18n.t("components.browser_time_zone"),
4531
+ customLabel: t("components.browser_time_zone"),
4516
4532
  timeZone: browserTz
4517
4533
  })), /* @__PURE__ */React.createElement(Select$1.Option, {
4518
4534
  value: "UTC",
4519
4535
  className: OptionWrapperStyle
4520
4536
  }, /* @__PURE__ */React.createElement(TimeZoneOption, {
4521
4537
  key: "utc",
4522
- customLabel: parrotI18n.t("components.coorddinated_universal_time"),
4538
+ customLabel: t("components.coorddinated_universal_time"),
4523
4539
  timeZone: {
4524
4540
  value: "UTC",
4525
4541
  text: "UTC",
@@ -4565,6 +4581,7 @@ function getAntdKit() {
4565
4581
  pagination: Pagination,
4566
4582
  select: Select,
4567
4583
  option: Select$1.Option,
4584
+ selectOptGroup: Select$1.OptGroup,
4568
4585
  table: Table,
4569
4586
  row: Row,
4570
4587
  col: Col,
@@ -4636,7 +4653,8 @@ function getAntdKit() {
4636
4653
  antdMessage: message,
4637
4654
  antdButton: Button$1,
4638
4655
  antdSelect: Select$1,
4639
- antdTooltip: Tooltip$1
4656
+ antdTooltip: Tooltip$1,
4657
+ antdModal: Modal$1
4640
4658
  };
4641
4659
  kit.option.isSelectOption = true;
4642
4660
  kit.button.__ANT_BUTTON = true;
@@ -4670,6 +4688,9 @@ const FailedLoad = props => {
4670
4688
  title,
4671
4689
  refetchText
4672
4690
  } = props;
4691
+ const {
4692
+ t
4693
+ } = useTranslation();
4673
4694
  return /* @__PURE__ */React.createElement("div", {
4674
4695
  className: cs(FailedLoadStyle, className),
4675
4696
  title
@@ -4678,7 +4699,7 @@ const FailedLoad = props => {
4678
4699
  }, String(error)), /* @__PURE__ */React.createElement(Button, {
4679
4700
  type: "ordinary",
4680
4701
  onClick: () => refetch()
4681
- }, refetchText || parrotI18n.t("common.retry")));
4702
+ }, refetchText || t("common.retry")));
4682
4703
  };
4683
4704
 
4684
4705
  function getRangeTimestamp(dateRange) {
@@ -4781,7 +4802,7 @@ var __spreadValues = (a, b) => {
4781
4802
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
4782
4803
  const kitContext = createContext(antdKit);
4783
4804
  const UIKitProvider = (props) => {
4784
- const { children, kit = antdKit, message } = props;
4805
+ const { children, kit = antdKit, message, antdConfig } = props;
4785
4806
  const _kit = useMemo(() => {
4786
4807
  if ((message == null ? void 0 : message.batch) != null) {
4787
4808
  return __spreadProps(__spreadValues({}, kit), {
@@ -4790,10 +4811,10 @@ const UIKitProvider = (props) => {
4790
4811
  }
4791
4812
  return kit;
4792
4813
  }, [kit, message == null ? void 0 : message.batch]);
4793
- return /* @__PURE__ */ React.createElement(kitContext.Provider, { value: _kit }, children);
4814
+ return /* @__PURE__ */ React.createElement(I18nextProvider, { i18n: parrotI18n }, /* @__PURE__ */ React.createElement(kitContext.Provider, { value: _kit }, /* @__PURE__ */ React.createElement(ConfigProvider, __spreadValues({ autoInsertSpaceInButton: false }, antdConfig), children)));
4794
4815
  };
4795
4816
  const useUIKit = () => {
4796
4817
  return useContext(kitContext);
4797
4818
  };
4798
4819
 
4799
- export { Architecture, Button, ButtonStyle, EntityAsyncStatus, FailedLoad, Icon, InputTagItem, KitStoreProvider, ModalActions, ModalStack, TaskStatus, Typo, UIKitProvider, UIKitStore, UserSource, ValidateTriggerType, antdKit, closeModal, createBatchMessageMethods, kitContext, popModal, pushModal, tableStyleCover, tickFormatter, useElementsSize, useKitDispatch, useKitSelector, useUIKit };
4820
+ export { Architecture, Button, ButtonStyle, EntityAsyncStatus, FailedLoad, FullView, Icon, InputTagItem, KitStoreProvider, ModalActions, ModalStack, TaskStatus, Typo, UIKitProvider, UIKitStore, UserSource, ValidateTriggerType, WizardBody, antdKit, closeModal, createBatchMessageMethods, kitContext, popModal, pushModal, tableStyleCover, tickFormatter, useElementsSize, useKitDispatch, useKitSelector, useUIKit };