@cloudtower/eagle 0.34.0 → 0.34.2

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.
Files changed (151) hide show
  1. package/dist/cjs/UIKitProvider/index.js +13 -18
  2. package/dist/cjs/core/Banner/banner.style.js +11 -0
  3. package/dist/cjs/core/Banner/index.js +32 -0
  4. package/dist/cjs/core/BasicCTError/BasicCTError.style.js +5 -0
  5. package/dist/cjs/core/BasicCTError/index.js +40 -0
  6. package/dist/cjs/core/ConfigProvider/index.js +8 -2
  7. package/dist/cjs/core/Fields/FieldsDateTimeRange/index.js +20 -3
  8. package/dist/cjs/core/ImmersiveDialog/index.js +188 -0
  9. package/dist/cjs/core/ImmersiveDialog/styles.js +31 -0
  10. package/dist/cjs/core/LineChart/LineChartLegend.js +7 -5
  11. package/dist/cjs/core/LineChart/TooltipFormatter.js +7 -6
  12. package/dist/cjs/core/MediumDialog/MediumDialog.js +54 -0
  13. package/dist/cjs/core/SmallDialog/SmallDialog.js +144 -0
  14. package/dist/cjs/core/SmallDialog/SmallDialog.style.js +11 -0
  15. package/dist/cjs/core/TableForm/AddRowButton.js +2 -2
  16. package/dist/cjs/core/TableForm/index.js +21 -6
  17. package/dist/cjs/core/Timeline/index.js +13 -7
  18. package/dist/cjs/core/WizardDialog/index.js +170 -0
  19. package/dist/cjs/core/WizardDialog/styles.js +11 -0
  20. package/dist/cjs/core/index.js +9 -9
  21. package/dist/cjs/core/message/index.js +5 -215
  22. package/dist/cjs/core/message/message.js +222 -0
  23. package/dist/cjs/core/message/useMessage.js +12 -0
  24. package/dist/cjs/core/message-group/index.js +2 -2
  25. package/dist/cjs/coreX/DateRangePicker/AbsoluteDate.js +2 -1
  26. package/dist/cjs/coreX/DateRangePicker/Calendar.js +78 -58
  27. package/dist/cjs/coreX/DateRangePicker/index.js +13 -1
  28. package/dist/cjs/coreX/DateRangePicker/utils.js +5 -0
  29. package/dist/cjs/coreX/Dialogs/DeleteDialog/DeleteDialog.js +5 -3
  30. package/dist/cjs/coreX/Dialogs/RejectDialog/RejectDialog.js +1 -1
  31. package/dist/cjs/coreX/KubeConfigModal/KubeConfigModal.style.js +29 -0
  32. package/dist/cjs/coreX/KubeConfigModal/index.js +102 -0
  33. package/dist/cjs/coreX/KubeConfigModal/utils.js +25 -0
  34. package/dist/cjs/hooks/useCTErrorMsg.js +25 -0
  35. package/dist/cjs/index.js +225 -197
  36. package/dist/cjs/legacy-antd.js +81 -81
  37. package/dist/cjs/stats1.html +1 -1
  38. package/dist/cjs/utils/cterror.js +64 -0
  39. package/dist/cjs/utils/unit.js +19 -0
  40. package/dist/components.css +3147 -3859
  41. package/dist/esm/UIKitProvider/index.js +3 -6
  42. package/dist/esm/core/Banner/banner.style.js +6 -0
  43. package/dist/esm/core/Banner/index.js +25 -0
  44. package/dist/esm/core/BasicCTError/BasicCTError.style.js +3 -0
  45. package/dist/esm/core/BasicCTError/index.js +34 -0
  46. package/dist/esm/core/ConfigProvider/index.js +9 -4
  47. package/dist/esm/core/Fields/FieldsDateTimeRange/index.js +20 -3
  48. package/dist/esm/core/ImmersiveDialog/index.js +182 -0
  49. package/dist/esm/core/ImmersiveDialog/styles.js +16 -0
  50. package/dist/esm/core/LineChart/LineChartLegend.js +4 -2
  51. package/dist/esm/core/LineChart/TooltipFormatter.js +7 -6
  52. package/dist/esm/core/MediumDialog/MediumDialog.js +48 -0
  53. package/dist/esm/core/SmallDialog/SmallDialog.js +137 -0
  54. package/dist/esm/core/SmallDialog/SmallDialog.style.js +6 -0
  55. package/dist/esm/core/TableForm/AddRowButton.js +2 -2
  56. package/dist/esm/core/TableForm/index.js +21 -6
  57. package/dist/esm/core/Timeline/index.js +13 -7
  58. package/dist/esm/core/WizardDialog/index.js +164 -0
  59. package/dist/esm/core/WizardDialog/styles.js +6 -0
  60. package/dist/esm/core/message/index.js +4 -184
  61. package/dist/esm/core/message/message.js +186 -0
  62. package/dist/esm/core/message/useMessage.js +9 -0
  63. package/dist/esm/core/message-group/index.js +1 -1
  64. package/dist/esm/coreX/DateRangePicker/AbsoluteDate.js +2 -1
  65. package/dist/esm/coreX/DateRangePicker/Calendar.js +79 -59
  66. package/dist/esm/coreX/DateRangePicker/index.js +13 -1
  67. package/dist/esm/coreX/DateRangePicker/utils.js +3 -0
  68. package/dist/esm/coreX/Dialogs/DeleteDialog/DeleteDialog.js +5 -3
  69. package/dist/esm/coreX/Dialogs/RejectDialog/RejectDialog.js +1 -1
  70. package/dist/esm/coreX/KubeConfigModal/KubeConfigModal.style.js +20 -0
  71. package/dist/esm/coreX/KubeConfigModal/index.js +96 -0
  72. package/dist/esm/coreX/KubeConfigModal/utils.js +22 -0
  73. package/dist/esm/hooks/useCTErrorMsg.js +23 -0
  74. package/dist/esm/index.js +14 -5
  75. package/dist/esm/legacy-antd.js +1 -1
  76. package/dist/esm/stats1.html +1 -1
  77. package/dist/esm/utils/cterror.js +58 -0
  78. package/dist/esm/utils/unit.js +17 -0
  79. package/dist/linaria.merged.scss +3157 -2720
  80. package/dist/src/UIKitProvider/index.d.ts +1 -3
  81. package/dist/src/core/Antd5Flex/index.d.ts +2 -0
  82. package/dist/src/core/Antd5Tree/Antd5Tree.d.ts +1 -0
  83. package/dist/src/core/Antd5Tree/Antd5Tree.type.d.ts +4 -0
  84. package/dist/src/core/Antd5Tree/index.d.ts +2 -0
  85. package/dist/src/core/Banner/banner.style.d.ts +4 -0
  86. package/dist/src/core/Banner/banner.types.d.ts +28 -0
  87. package/dist/src/core/Banner/index.d.ts +3 -0
  88. package/dist/src/core/BasicCTError/BasicCTError.style.d.ts +1 -0
  89. package/dist/src/core/BasicCTError/BasicCTError.type.d.ts +56 -0
  90. package/dist/src/core/BasicCTError/index.d.ts +3 -0
  91. package/dist/src/core/ConfigProvider/index.d.ts +6 -1
  92. package/dist/src/core/ImmersiveDialog/index.d.ts +3 -0
  93. package/dist/src/core/ImmersiveDialog/styles.d.ts +14 -0
  94. package/dist/src/core/ImmersiveDialog/type.d.ts +37 -0
  95. package/dist/src/core/Input/index.d.ts +2 -4
  96. package/dist/src/core/Input/input.type.d.ts +4 -0
  97. package/dist/src/core/LineChart/type.d.ts +1 -0
  98. package/dist/src/core/MediumDialog/MediumDialog.d.ts +3 -0
  99. package/dist/src/core/MediumDialog/index.d.ts +1 -0
  100. package/dist/src/core/SmallDialog/SmallDialog.d.ts +3 -0
  101. package/dist/src/core/SmallDialog/SmallDialog.style.d.ts +4 -0
  102. package/dist/src/{coreX/Dialogs/SmallDialog.d.ts → core/SmallDialog/SmallDialog.type.d.ts} +12 -4
  103. package/dist/src/core/SmallDialog/index.d.ts +3 -0
  104. package/dist/src/core/TableForm/types.d.ts +7 -2
  105. package/dist/src/core/Timeline/Timeline.type.d.ts +27 -7
  106. package/dist/src/core/Timeline/index.d.ts +5 -1
  107. package/dist/src/core/WizardDialog/index.d.ts +3 -0
  108. package/dist/src/core/WizardDialog/styles.d.ts +4 -0
  109. package/dist/src/core/WizardDialog/type.d.ts +31 -0
  110. package/dist/src/core/index.d.ts +10 -14
  111. package/dist/src/core/message/index.d.ts +4 -53
  112. package/dist/src/core/message/message.d.ts +53 -0
  113. package/dist/src/core/message/useMessage.d.ts +4 -0
  114. package/dist/src/coreX/DateRangePicker/__tests__/utils.test.d.ts +1 -0
  115. package/dist/src/coreX/DateRangePicker/dateRangePicker.type.d.ts +10 -2
  116. package/dist/src/coreX/DateRangePicker/utils.d.ts +7 -0
  117. package/dist/src/coreX/Dialogs/DeleteDialog/DeleteDialog.type.d.ts +2 -0
  118. package/dist/src/coreX/Dialogs/index.d.ts +0 -1
  119. package/dist/src/coreX/KubeConfigModal/KubeConfigModal.style.d.ts +9 -0
  120. package/dist/src/coreX/KubeConfigModal/KubeConfigModal.type.d.ts +21 -0
  121. package/dist/src/coreX/KubeConfigModal/index.d.ts +4 -0
  122. package/dist/src/coreX/KubeConfigModal/utils.d.ts +2 -0
  123. package/dist/src/coreX/index.d.ts +2 -0
  124. package/dist/src/hooks/__tests__/useCTErrorMsg.test.d.ts +1 -0
  125. package/dist/src/hooks/index.d.ts +1 -0
  126. package/dist/src/hooks/useCTErrorMsg.d.ts +7 -0
  127. package/dist/src/utils/__test__/cterror.test.d.ts +1 -0
  128. package/dist/src/utils/__test__/unit.spec.d.ts +1 -0
  129. package/dist/src/utils/cterror.d.ts +29 -0
  130. package/dist/src/utils/index.d.ts +1 -0
  131. package/dist/src/utils/type.d.ts +32 -0
  132. package/dist/src/utils/unit.d.ts +14 -0
  133. package/dist/stories/docs/core/Antd5Tree.stories.d.ts +44 -0
  134. package/dist/stories/docs/core/Banner.stories.d.ts +53 -0
  135. package/dist/stories/docs/core/BasicCTError.stories.d.ts +47 -0
  136. package/dist/stories/docs/core/FieldsDateTimeRange.stories.d.ts +1 -0
  137. package/dist/stories/docs/core/ImmersiveDialog.stories.d.ts +96 -0
  138. package/dist/stories/docs/core/Input.simple.stories.d.ts +1 -3
  139. package/dist/stories/docs/core/LineChart.stories.d.ts +1 -0
  140. package/dist/stories/docs/core/MediumDialog.stories.d.ts +35 -0
  141. package/dist/stories/docs/core/Modal.stories.d.ts +0 -2
  142. package/dist/stories/docs/core/SmallDialog.stories.d.ts +37 -0
  143. package/dist/stories/docs/core/Timeline.stories.d.ts +4 -1
  144. package/dist/stories/docs/core/WizardDialog.stories.d.ts +109 -0
  145. package/dist/stories/docs/coreX/DateRangePicker.stories.d.ts +1 -0
  146. package/dist/stories/docs/coreX/Dialogs/DeleteDialog.stories.d.ts +5 -0
  147. package/dist/stories/docs/coreX/KubeConfigModal.stories.d.ts +83 -0
  148. package/dist/style.css +2867 -2469
  149. package/package.json +8 -7
  150. package/dist/cjs/coreX/Dialogs/SmallDialog.js +0 -86
  151. package/dist/esm/coreX/Dialogs/SmallDialog.js +0 -80
@@ -7,10 +7,12 @@ import Input from '../../core/Input/index.js';
7
7
  import { Typo } from '../../core/Typo/index.js';
8
8
  import useElementIntersectionRatio from '../../hooks/useElementIntersectionRatio.js';
9
9
  import useParrotTranslation from '../../hooks/useParrotTranslation.js';
10
+ import { parseNumberAndUnit } from '../../utils/unit.js';
10
11
  import dayjs from 'dayjs';
11
- import React__default, { useState, useEffect, useRef } from 'react';
12
+ import React__default, { useState, useEffect, useRef, useMemo } from 'react';
12
13
  import { getDiffMonthAndDate, getTime, checkDateNotInRange, getClassNameForDateBlock } from './common.js';
13
14
  import { CalendarStyle } from './DateRangePicker.style.js';
15
+ import { getFirstDateOfMonth } from './utils.js';
14
16
  import { getCalendarTitle } from '../common/getCalendarTitle.js';
15
17
 
16
18
  const Year = (props) => {
@@ -76,6 +78,7 @@ const MonthItem = (props) => {
76
78
  highlightDay,
77
79
  minDate,
78
80
  maxDate,
81
+ maxRange,
79
82
  parentElement,
80
83
  onRangeChange,
81
84
  onMouseEnter
@@ -125,6 +128,74 @@ const MonthItem = (props) => {
125
128
  }
126
129
  onRangeChange(_range);
127
130
  }
131
+ const datesElements = useMemo(() => {
132
+ return initMonth.dates.map((date) => {
133
+ const _date = getTime(initYear, initMonth.month, date);
134
+ const { number: maxRangeNumber, unit: maxRangeUnit } = parseNumberAndUnit(maxRange || "") || {};
135
+ const dateNotIncludeInRange = checkDateNotInRange(
136
+ _date,
137
+ minDate,
138
+ maxDate
139
+ );
140
+ const isLimitRangeEnd = !!rangeStart && !rangeEnd;
141
+ const isDateBeforeRangeStart = isLimitRangeEnd ? _date.valueOf() < rangeStart.valueOf() : false;
142
+ const isDateNotIncludeInMaxRange = isLimitRangeEnd && maxRangeNumber && maxRangeUnit ? rangeStart.add(maxRangeNumber, maxRangeUnit).valueOf() <= _date.valueOf() : false;
143
+ const disabled = Boolean(isDateBeforeRangeStart || isDateNotIncludeInMaxRange) || !dateNotIncludeInRange;
144
+ const dateClassName = getClassNameForDateBlock(
145
+ range,
146
+ _date,
147
+ mapOfHighlightDay,
148
+ disabled
149
+ );
150
+ const highlightIndex = mapOfHighlightDay.get(_date.format("YYYY-MM-DD"));
151
+ const isFirstDayInWeek = _date.day() === 1;
152
+ const isLastDayInWeek = _date.day() === 0;
153
+ const isFirstDayInMonth = _date.date() === 1;
154
+ const isLastDayInMonth = _date.date() === _date.daysInMonth();
155
+ const isLastDayIsSingleDayInWeek = isLastDayInMonth && isFirstDayInWeek;
156
+ const isFirstHighlight = highlightIndex === 0 || isFirstDayInWeek || isFirstDayInMonth || isLastDayIsSingleDayInWeek;
157
+ const isLastHighlight = highlightIndex === Math.max(mapOfHighlightDay.size - 1, 0) || isLastDayInWeek || isLastDayInMonth;
158
+ return /* @__PURE__ */ React__default.createElement(
159
+ "span",
160
+ {
161
+ key: `date-${date}`,
162
+ className: cx(
163
+ "date-block",
164
+ dateClassName,
165
+ isFirstHighlight && "first-highlight",
166
+ isLastHighlight && "last-highlight"
167
+ ),
168
+ onClick: () => {
169
+ if (disabled) {
170
+ return;
171
+ }
172
+ clickDate(date);
173
+ },
174
+ onMouseEnter: () => {
175
+ if (disabled) {
176
+ onMouseEnter(null);
177
+ } else if (rangeStart && !rangeEnd) {
178
+ onMouseEnter(_date);
179
+ }
180
+ }
181
+ },
182
+ /* @__PURE__ */ React__default.createElement("span", { className: cx("date-text", dateClassName) }, date)
183
+ );
184
+ });
185
+ }, [
186
+ initMonth.dates,
187
+ initMonth.month,
188
+ initYear,
189
+ maxRange,
190
+ minDate,
191
+ maxDate,
192
+ rangeStart,
193
+ rangeEnd,
194
+ range,
195
+ mapOfHighlightDay,
196
+ clickDate,
197
+ onMouseEnter
198
+ ]);
128
199
  return /* @__PURE__ */ React__default.createElement("li", { className: "month-container", ref: containerRef }, /* @__PURE__ */ React__default.createElement(
129
200
  "header",
130
201
  {
@@ -132,62 +203,10 @@ const MonthItem = (props) => {
132
203
  ref: headerRef
133
204
  },
134
205
  getCalendarTitle(initMonth.month.toString(), parrotI18n.t, parrotI18n)
135
- ), /* @__PURE__ */ React__default.createElement("div", { className: "dates-in-month", ref: datesContainerRef }, new Array(initMonth.firstDateOfDay).fill(null).map((value, index) => /* @__PURE__ */ React__default.createElement("span", { key: `blank-date-${index}`, className: "blank" })), initMonth.dates.map((date) => {
136
- const _date = getTime(initYear, initMonth.month, date);
137
- const dateNotIncludeInRange = checkDateNotInRange(
138
- _date,
139
- minDate,
140
- maxDate
141
- );
142
- const disabled = Boolean(
143
- rangeStart && !rangeEnd && rangeStart.valueOf() > _date.valueOf()
144
- ) || !dateNotIncludeInRange;
145
- const dateClassName = getClassNameForDateBlock(
146
- range,
147
- _date,
148
- mapOfHighlightDay,
149
- disabled
150
- );
151
- const highlightIndex = mapOfHighlightDay.get(
152
- _date.format("YYYY-MM-DD")
153
- );
154
- const isFirstDayInWeek = _date.day() === 1;
155
- const isLastDayInWeek = _date.day() === 0;
156
- const isFirstDayInMonth = _date.date() === 1;
157
- const isLastDayInMonth = _date.date() === _date.daysInMonth();
158
- const isLastDayIsSingleDayInWeek = isLastDayInMonth && isFirstDayInWeek;
159
- const isFirstHighlight = highlightIndex === 0 || isFirstDayInWeek || isFirstDayInMonth || isLastDayIsSingleDayInWeek;
160
- const isLastHighlight = highlightIndex === Math.max(mapOfHighlightDay.size - 1, 0) || isLastDayInWeek || isLastDayInMonth;
161
- return /* @__PURE__ */ React__default.createElement(
162
- "span",
163
- {
164
- key: `date-${date}`,
165
- className: cx(
166
- "date-block",
167
- dateClassName,
168
- isFirstHighlight && "first-highlight",
169
- isLastHighlight && "last-highlight"
170
- ),
171
- onClick: () => {
172
- if (disabled) {
173
- return;
174
- }
175
- clickDate(date);
176
- },
177
- onMouseEnter: () => {
178
- if (disabled) {
179
- onMouseEnter(null);
180
- } else if (rangeStart && !rangeEnd) {
181
- onMouseEnter(_date);
182
- }
183
- }
184
- },
185
- /* @__PURE__ */ React__default.createElement("span", { className: cx("date-text", dateClassName) }, date)
186
- );
187
- })));
206
+ ), /* @__PURE__ */ React__default.createElement("div", { className: "dates-in-month", ref: datesContainerRef }, new Array(initMonth.firstDateOfDay).fill(null).map((value, index) => /* @__PURE__ */ React__default.createElement("span", { key: `blank-date-${index}`, className: "blank" })), datesElements));
188
207
  };
189
208
  const Month = (props) => {
190
- const { year, range, minDate, maxDate, onRangeChange } = props;
209
+ const { year, range, minDate, maxDate, maxRange, onRangeChange } = props;
191
210
  const monthContainerRef = useRef(null);
192
211
  const [month, setMonth] = useState([]);
193
212
  const [highlightDay, setHighlightDay] = useState(() => {
@@ -203,11 +222,10 @@ const Month = (props) => {
203
222
  const time = dayjs(`${year}-${month2}`, "YYYY-M");
204
223
  const allDateInMonth = time.daysInMonth();
205
224
  const dates = new Array(allDateInMonth).fill(1).map((value, index) => index + 1);
206
- const firstDateOfDay = time.set("date", dates[0]).day();
207
225
  monthAndDate.push({
208
226
  month: month2,
209
227
  dates,
210
- firstDateOfDay: Math.max(firstDateOfDay - 1, 0)
228
+ firstDateOfDay: getFirstDateOfMonth(time)
211
229
  });
212
230
  }
213
231
  setMonth(monthAndDate);
@@ -246,7 +264,8 @@ const Month = (props) => {
246
264
  range,
247
265
  minDate,
248
266
  maxDate,
249
- highlightDay: highlightDay || controlHighlightDay || [],
267
+ maxRange,
268
+ highlightDay: controlHighlightDay || highlightDay || [],
250
269
  parentElement: monthContainerRef,
251
270
  onRangeChange,
252
271
  onMouseEnter: handleMouseEnterDate
@@ -259,7 +278,7 @@ const Week = () => {
259
278
  return /* @__PURE__ */ React__default.createElement(CalendarStyle.Week, null, /* @__PURE__ */ React__default.createElement("li", { className: Typo.Label.l1_regular }, t("components.monday-simple")), /* @__PURE__ */ React__default.createElement("li", { className: Typo.Label.l1_regular }, t("components.tuesday-simple")), /* @__PURE__ */ React__default.createElement("li", { className: Typo.Label.l1_regular }, t("components.wednesday-simple")), /* @__PURE__ */ React__default.createElement("li", { className: Typo.Label.l1_regular }, t("components.thursday-simple")), /* @__PURE__ */ React__default.createElement("li", { className: Typo.Label.l1_regular }, t("components.friday-simple")), /* @__PURE__ */ React__default.createElement("li", { className: Typo.Label.l1_regular }, t("components.saturday-simple")), /* @__PURE__ */ React__default.createElement("li", { className: Typo.Label.l1_regular }, t("components.sunday-simple")));
260
279
  };
261
280
  const Calendar = (props) => {
262
- const { range: initRange, minDate, maxDate, onChange } = props;
281
+ const { range: initRange, minDate, maxDate, maxRange, onChange } = props;
263
282
  const [year, setYear] = useState(dayjs().year());
264
283
  const [range, setRange] = useState(
265
284
  initRange || [null, null]
@@ -278,6 +297,7 @@ const Calendar = (props) => {
278
297
  range,
279
298
  minDate,
280
299
  maxDate,
300
+ maxRange,
281
301
  onRangeChange: handleRangeChange
282
302
  }
283
303
  ));
@@ -42,6 +42,7 @@ const TimeRange = (props) => {
42
42
  mode = ["relative", "absolute"],
43
43
  minDate,
44
44
  maxDate,
45
+ maxRange,
45
46
  onTypeChange,
46
47
  onRelativeTimeChange,
47
48
  onAbsoluteTimeOk,
@@ -101,13 +102,22 @@ const TimeRange = (props) => {
101
102
  range: range || [null, null],
102
103
  minDate,
103
104
  maxDate,
105
+ maxRange,
104
106
  onChange: (range2) => onAbsoluteTimeChange == null ? void 0 : onAbsoluteTimeChange(range2),
105
107
  onOk: (range2) => onAbsoluteTimeOk == null ? void 0 : onAbsoluteTimeOk(range2)
106
108
  }
107
109
  ))
108
110
  }
109
111
  ].filter((item) => mode.includes(item.key));
110
- return /* @__PURE__ */ React__default.createElement(TabMenu, { selectedKey: type, tabs, onChange: onTypeChange });
112
+ return /* @__PURE__ */ React__default.createElement(
113
+ TabMenu,
114
+ {
115
+ selectedKey: type,
116
+ tabs,
117
+ onChange: onTypeChange,
118
+ size: "small"
119
+ }
120
+ );
111
121
  }
112
122
  };
113
123
  const TimePickerHistory = (props) => {
@@ -144,6 +154,7 @@ const DateRangePicker = (props) => {
144
154
  mode = ["relative", "absolute"],
145
155
  minDate,
146
156
  maxDate,
157
+ maxRange,
147
158
  onChange,
148
159
  relativeTimeSelectOptions
149
160
  } = props;
@@ -278,6 +289,7 @@ const DateRangePicker = (props) => {
278
289
  mode,
279
290
  minDate,
280
291
  maxDate,
292
+ maxRange,
281
293
  onTypeChange: setType,
282
294
  onRelativeTimeChange: (time) => {
283
295
  handleChange("relative", time);
@@ -0,0 +1,3 @@
1
+ const getFirstDateOfMonth = (date, weekStartOnMonday = true) => (date.set("date", 1).day() - Number(weekStartOnMonday) + 7) % 7;
2
+
3
+ export { getFirstDateOfMonth };
@@ -2,7 +2,7 @@ import { cx } from '@linaria/core';
2
2
  import { Typo } from '../../../core/Typo/index.js';
3
3
  import useParrotTranslation from '../../../hooks/useParrotTranslation.js';
4
4
  import React__default from 'react';
5
- import { SmallDialog } from '../SmallDialog.js';
5
+ import { SmallDialog } from '../../../core/SmallDialog/SmallDialog.js';
6
6
 
7
7
  const ContentStyle = "E_cevhqx7";
8
8
  const SecondaryDescStyle = "E_snbqlt4";
@@ -18,7 +18,8 @@ const DeleteDialog = props => {
18
18
  okText = t("common.delete"),
19
19
  onOk,
20
20
  onCancel,
21
- className
21
+ className,
22
+ confirmLoading
22
23
  } = props;
23
24
  return /* @__PURE__ */React__default.createElement(SmallDialog, {
24
25
  title,
@@ -30,7 +31,8 @@ const DeleteDialog = props => {
30
31
  cancelText,
31
32
  okButtonProps: {
32
33
  danger: true
33
- }
34
+ },
35
+ confirmLoading
34
36
  }, description && /* @__PURE__ */React__default.createElement("div", {
35
37
  className: cx(ContentStyle, Typo.Label.l2_regular)
36
38
  }, description), secondaryDesc && /* @__PURE__ */React__default.createElement("div", {
@@ -1,7 +1,7 @@
1
1
  import { cx } from '@linaria/core';
2
2
  import { Typo } from '../../../core/Typo/index.js';
3
3
  import React__default from 'react';
4
- import { SmallDialog } from '../SmallDialog.js';
4
+ import { SmallDialog } from '../../../core/SmallDialog/SmallDialog.js';
5
5
  import { RejectDialogType } from './RejectDialog.type.js';
6
6
 
7
7
  const ContentList = "E_c1ss4prm";
@@ -0,0 +1,20 @@
1
+ import { styled } from '@linaria/react';
2
+
3
+ const KubeConfigModalStyle = "E_kr6am0s";
4
+ const KubeConfigWrapperStyle = "E_k1h3cl5q";
5
+ const KubeConfigTitleStyle = "E_k1a6j97w";
6
+ const KubeConfigTipStyle = "E_k1uim1fg";
7
+ const KubeConfigContentStyle = "E_kobelzt";
8
+ const KubeConfigFooterStyle = "E_kxzv3id";
9
+ const ErrorWrapper = /*#__PURE__*/styled('div')({
10
+ name: "ErrorWrapper",
11
+ class: "E_eld9lt",
12
+ propsAsIs: false
13
+ });
14
+ const ErrorContentWrapper = /*#__PURE__*/styled('div')({
15
+ name: "ErrorContentWrapper",
16
+ class: "E_e1505fqc",
17
+ propsAsIs: false
18
+ });
19
+
20
+ export { ErrorContentWrapper, ErrorWrapper, KubeConfigContentStyle, KubeConfigFooterStyle, KubeConfigModalStyle, KubeConfigTipStyle, KubeConfigTitleStyle, KubeConfigWrapperStyle };
@@ -0,0 +1,96 @@
1
+ import React__default, { useCallback } from 'react';
2
+ import Modal from '../../core/Modal/index.js';
3
+ import { ClipboardCopy16GradientGrayIcon, ClipboardCopy16GradientBlueIcon } from '@cloudtower/icons-react';
4
+ import useParrotTranslation from '../../hooks/useParrotTranslation.js';
5
+ import { cx } from '@linaria/core';
6
+ import { copy, download } from './utils.js';
7
+ import { KubeConfigModalStyle, KubeConfigFooterStyle, KubeConfigWrapperStyle, KubeConfigTitleStyle, KubeConfigTipStyle, KubeConfigContentStyle, ErrorWrapper, ErrorContentWrapper } from './KubeConfigModal.style.js';
8
+ import { usePopModal } from '../../core/KitStoreProvider/index.js';
9
+ import _message from '../../core/message/message.js';
10
+ import Button from '../../core/Button/index.js';
11
+ import Icon from '../../core/Icon/index.js';
12
+ import Loading from '../../core/Loading/index.js';
13
+ import { Typo } from '../../core/Typo/index.js';
14
+
15
+ const ErrorContent = (props) => {
16
+ const { refetch, errorText } = props;
17
+ const { t } = useParrotTranslation();
18
+ return /* @__PURE__ */ React__default.createElement(ErrorWrapper, { className: props.className, style: props.style }, /* @__PURE__ */ React__default.createElement(ErrorContentWrapper, null, /* @__PURE__ */ React__default.createElement("p", { className: cx(Typo.Label.l1_regular_title, "title") }, errorText || t("common.obtain_data_error")), !refetch ? null : /* @__PURE__ */ React__default.createElement(
19
+ Button,
20
+ {
21
+ size: "small",
22
+ type: "ordinary",
23
+ onClick: (e) => {
24
+ e.stopPropagation();
25
+ refetch == null ? void 0 : refetch();
26
+ }
27
+ },
28
+ t("common.retry")
29
+ )));
30
+ };
31
+ const KubeConfigModal = ({
32
+ downloadName,
33
+ customDesc,
34
+ loading,
35
+ data,
36
+ error,
37
+ refetch
38
+ }) => {
39
+ const { t } = useParrotTranslation();
40
+ const popModal = usePopModal();
41
+ const onCopy = useCallback(() => {
42
+ copy(data);
43
+ _message.success(t("common.copy_kubeconfig_success"));
44
+ }, [data, t]);
45
+ const onDownload = useCallback(() => {
46
+ download(`${downloadName}.yaml`, data);
47
+ popModal();
48
+ }, [data, popModal, downloadName]);
49
+ return /* @__PURE__ */ React__default.createElement(
50
+ Modal,
51
+ {
52
+ visible: true,
53
+ fullscreen: true,
54
+ className: KubeConfigModalStyle,
55
+ onCancel: () => {
56
+ popModal();
57
+ },
58
+ footer: /* @__PURE__ */ React__default.createElement("div", { className: KubeConfigFooterStyle }, /* @__PURE__ */ React__default.createElement(
59
+ Button,
60
+ {
61
+ type: "default",
62
+ prefixIcon: /* @__PURE__ */ React__default.createElement(
63
+ Icon,
64
+ {
65
+ src: ClipboardCopy16GradientGrayIcon,
66
+ hoverSrc: ClipboardCopy16GradientBlueIcon
67
+ }
68
+ ),
69
+ onClick: onCopy
70
+ },
71
+ t("common.copy")
72
+ ), /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(
73
+ Button,
74
+ {
75
+ type: "text",
76
+ onClick: () => {
77
+ popModal();
78
+ }
79
+ },
80
+ t("common.cancel")
81
+ ), /* @__PURE__ */ React__default.createElement(
82
+ Button,
83
+ {
84
+ type: "primary",
85
+ onClick: onDownload,
86
+ disabled: loading || !!error
87
+ },
88
+ t("common.download")
89
+ )))
90
+ },
91
+ /* @__PURE__ */ React__default.createElement("div", { className: KubeConfigWrapperStyle }, /* @__PURE__ */ React__default.createElement("div", { className: cx(KubeConfigTitleStyle, Typo.Display.d1s_bold_title) }, t("common.download_kubeconfig")), /* @__PURE__ */ React__default.createElement("div", { className: cx(KubeConfigTipStyle, Typo.Label.l1_regular) }, customDesc || t("common.download_kubeconfig_tip")), loading ? /* @__PURE__ */ React__default.createElement(Loading, { fullView: true }) : error ? /* @__PURE__ */ React__default.createElement("div", { className: KubeConfigContentStyle }, /* @__PURE__ */ React__default.createElement(ErrorContent, { refetch, errorText: error })) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: KubeConfigContentStyle }, data)))
92
+ );
93
+ };
94
+ var KubeConfigModal$1 = KubeConfigModal;
95
+
96
+ export { KubeConfigModal$1 as default };
@@ -0,0 +1,22 @@
1
+ function download(filename, content) {
2
+ const element = document.createElement("a");
3
+ element.setAttribute(
4
+ "href",
5
+ "data:text/plain;charset=utf-8," + encodeURIComponent(content)
6
+ );
7
+ element.setAttribute("download", filename);
8
+ element.style.display = "none";
9
+ document.body.appendChild(element);
10
+ element.click();
11
+ document.body.removeChild(element);
12
+ }
13
+ function copy(content) {
14
+ const textarea = document.createElement("textarea");
15
+ textarea.value = content;
16
+ document.body.appendChild(textarea);
17
+ textarea.select();
18
+ document.execCommand("Copy");
19
+ document.body.removeChild(textarea);
20
+ }
21
+
22
+ export { copy, download };
@@ -0,0 +1,23 @@
1
+ import useParrotTranslation from './useParrotTranslation.js';
2
+ import { parseCTError } from '../utils/cterror.js';
3
+ import { useMemo } from 'react';
4
+ import { merge } from 'lodash';
5
+ import { useConfig } from '../core/ConfigProvider/index.js';
6
+
7
+ const useCTErrorMsg = (error, options) => {
8
+ const { t } = useParrotTranslation();
9
+ const globalConfig = useConfig();
10
+ const err = parseCTError(error);
11
+ const ns = (options == null ? void 0 : options.CTErrorI18nNs) || (globalConfig == null ? void 0 : globalConfig.CTErrorI18nNs) || "CTError";
12
+ const errMsg = useMemo(() => {
13
+ return err.map((e) => {
14
+ if ("code" in e) {
15
+ return t(`${ns}.${e.code}`, merge(options == null ? void 0 : options.tOptions, e.params));
16
+ }
17
+ return e.message;
18
+ });
19
+ }, [err, t, ns, options == null ? void 0 : options.tOptions]);
20
+ return errMsg;
21
+ };
22
+
23
+ export { useCTErrorMsg };
package/dist/esm/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  export { units as Units, units } from './core/index.js';
2
2
  export { UIKitStore, closeModal, popModal, pushModal } from './store/index.js';
3
- export { MessageContext, default as UIKitProvider, kitContext, useMessage, useUIKit } from './UIKitProvider/index.js';
3
+ export { default as UIKitProvider, kitContext, useUIKit } from './UIKitProvider/index.js';
4
4
  export * from '@cloudtower/parrot';
5
5
  export { AntdModal, AntdOption, AntdSelectOptGroup, AntdTimelineItem, DatePickerRangePicker, ListItem, MenuItemGroup, SkeletonButton, TabsTabPane, TypographyText, UploadDragger } from './antd.js';
6
6
  export { antdKit, getAntdKit } from './legacy-antd.js';
7
7
  export { default as useElementsSize } from './hooks/useElementsSize.js';
8
+ export { DEFAULT_DURATION, attachTypeApi, getKeyThenIncreaseKey, default as message } from './core/message/message.js';
9
+ export { MessageContext, useMessage } from './core/message/useMessage.js';
8
10
  export { ModalActions } from './store/modal.js';
9
11
  export { default as AccordionCard } from './core/AccordionCard/index.js';
10
12
  export { default as Alert } from './core/Alert/index.js';
@@ -45,11 +47,10 @@ export { AntdPasswordInputStyled, default as InputPassword } from './core/InputP
45
47
  export { default as InputTagItem } from './core/InputTagItem/index.js';
46
48
  export { default as KitStoreProvider, useCloseModal, useKitDispatch, useKitSelector, usePopModal, usePushModal, useResetModal } from './core/KitStoreProvider/index.js';
47
49
  export { default as LegacySelect } from './core/LegacySelect/index.js';
50
+ export { default as Legend, LegendIcon, LegendPresetColors } from './core/Legend/index.js';
48
51
  export { default as LineChart } from './core/LineChart/index.js';
49
52
  export { default as Link } from './core/Link/index.js';
50
53
  export { default as Loading } from './core/Loading/index.js';
51
- export { default as Legend, LegendIcon, LegendPresetColors } from './core/Legend/index.js';
52
- export { DEFAULT_DURATION, attachTypeApi, getKeyThenIncreaseKey, default as message } from './core/message/index.js';
53
54
  export { default as Metric } from './core/Metric/index.js';
54
55
  export { default as Modal } from './core/Modal/index.js';
55
56
  export { default as ModalStack } from './core/ModalStack/index.js';
@@ -79,18 +80,23 @@ export { default as Token, TokenPresetColors } from './core/Token/index.js';
79
80
  export { default as Tooltip } from './core/Tooltip/index.js';
80
81
  export { default as Truncate } from './core/Truncate/index.js';
81
82
  export { Antd5Dropdown } from './core/Antd5Dropdown/Antd5Dropdown.js';
83
+ export { Flex as Antd5Flex, Tree as Antd5Tree } from 'antd5';
82
84
  export { Architecture } from './core/Arch/arch.type.js';
85
+ export { Banner } from './core/Banner/index.js';
86
+ export { BasicCTError } from './core/BasicCTError/index.js';
83
87
  export { CascaderDefaultHeader, CascaderDefaultHeaderContainer, CascaderDefaultHeaderSearch, CascaderDefaultOptionLabel, CascaderDropdown, CascaderInputStyle, CascaderLargeDropdown, CascaderNotData, CascaderSmallDropdown, DoubleRowOptionStyleWrapper, Hide } from './core/Cascader/cascader.style.js';
84
88
  export { CascaderDoubleRowOption, CascaderOptionWithCount, NotDataContent, PresetCascaderHeader, PresetCascaderRender, defaultTagRender } from './core/Cascader/cascader.widget.js';
85
89
  export { Cascader } from './core/Cascader/index.js';
86
- export { ConfigProvider } from './core/ConfigProvider/index.js';
90
+ export { ConfigProvider, useConfig } from './core/ConfigProvider/index.js';
87
91
  export { default as ExpandableContainer } from './core/ExpandableList/ExpandableContainer.js';
88
92
  export { default as ExpandableItem } from './core/ExpandableList/ExpandableItem.js';
89
93
  export { default as ExpandIcon } from './core/ExpandableList/ExpandIcon.js';
90
94
  export { default as RoundOrder } from './core/ExpandableList/RoundOrder.js';
95
+ export { ImmersiveDialog } from './core/ImmersiveDialog/index.js';
91
96
  export { LineChartColorBlock, default as LineChartLegend } from './core/LineChart/LineChartLegend.js';
92
97
  export { ILineChartGraphType, ILineChartMetricUnit, ILineChartTimeUnit } from './core/LineChart/type.js';
93
98
  export { UNIT_FORMATTER, addMissingDataWithZero, convertLineChartDataStruct, convertLineChartUnit, deletePointsOutOfRange, filterLineChartDataOverlapping, filterLineChartOverlappingMetric, filterLineChartPointsByDateRange, getFirstExpectedTimestamp, getLineChartRangeTimestamp, getLineChartStep, getLineChartXAxisDomain, getLineChartYDataMax, getYAxisDomain, getYAxisUpperBound, lineChartTickFormatter, lineChartXaxisCal, lineChartYaxisTickFormatter, parseLineChartRange } from './core/LineChart/utils.js';
99
+ export { MediumDialog } from './core/MediumDialog/MediumDialog.js';
94
100
  export { Batcher, createBatchMessageMethods, makeUUID } from './core/message-group/index.js';
95
101
  export { default as MetricActions } from './core/Metric/MetricActions.js';
96
102
  export { ColorBlock, LegendComponent, default as MetricLegend } from './core/Metric/MetricLegend.js';
@@ -106,6 +112,8 @@ export { getOptions } from './core/Select/select.widgets.js';
106
112
  export { SidebarMenu } from './core/SidebarMenu/SidebarMenu.js';
107
113
  export { default as Skeleton } from './core/Skeleton/index.js';
108
114
  export { default as SkeletonContent } from './core/Skeleton/Content.js';
115
+ export { SmallDialog } from './core/SmallDialog/SmallDialog.js';
116
+ export { CloseIconStyle, DialogStyle, ErrorTextStyle, FooterStyle } from './core/SmallDialog/SmallDialog.style.js';
109
117
  export { CircleProgress } from './core/StepProgress/index.js';
110
118
  export { CannotOperationInfo, CommonContent, ContentWrapper, Desc, Description, Divider, Dot, ErrorSpan, ExpandArrow, FieldTitle, FormField, FormItemDiv, FormSectionTitle, FormWrapper, FullView, HorizontalWizardModalCompactStyle, HorizontalWizardModalLooseStyle, InfoAlert, InputStyle, KitInputStyle, LeftEndInputStyle, LeftEndSelectStyle, LightDesc, LoadingWrapper, ModalBody, ModalWrapper, NameTag, NormalAlert, NoticeAlert, OperationWraper, RadioDesc, RightEndInputStyle, RightEndSelectStyle, SelectOptionDisabledText, TagSpan, TertiaryText, UnitStyle, WarningAlert, WizardBody, radioStyle } from './core/Styled/index.js';
111
119
  export { useTableBodyHasScrollBar } from './core/Table/common.js';
@@ -114,6 +122,7 @@ export { ColumnTitle, EmptyRowMenu, KitTableContext, TableLoading } from './core
114
122
  export { ValidateTriggerType } from './core/TableForm/types.js';
115
123
  export { Timeline } from './core/Timeline/index.js';
116
124
  export { Typo } from './core/Typo/index.js';
125
+ export { WizardDialog } from './core/WizardDialog/index.js';
117
126
  export { default as BarChart, getWidth } from './coreX/BarChart/index.js';
118
127
  export { default as BatchOperation, renderBatchOperationMenuItem } from './coreX/BatchOperation/index.js';
119
128
  export { default as ChartWithTooltip, ChartWithUnit } from './coreX/ChartWithTooltip/index.js';
@@ -135,6 +144,7 @@ export { default as SummaryTable, SummaryTableRow } from './coreX/SummaryTable/i
135
144
  export { default as SwitchWithText } from './coreX/SwitchWithText/index.js';
136
145
  export { default as TabMenu } from './coreX/TabMenu/index.js';
137
146
  export { default as UnitWithChart, UnitWrapper } from './coreX/UnitWithChart/index.js';
147
+ export { default as KubeConfigModal } from './coreX/KubeConfigModal/index.js';
138
148
  export { CheckPointItem, CheckPointList } from './coreX/CheckPointList/index.js';
139
149
  export { getCalendarTitle } from './coreX/common/getCalendarTitle.js';
140
150
  export { default as AbsoluteDate } from './coreX/DateRangePicker/AbsoluteDate.js';
@@ -144,7 +154,6 @@ export { default as RelativeTime } from './coreX/DateRangePicker/RelativeTime.js
144
154
  export { DeleteDialog } from './coreX/Dialogs/DeleteDialog/DeleteDialog.js';
145
155
  export { RejectDialog } from './coreX/Dialogs/RejectDialog/RejectDialog.js';
146
156
  export { RejectDialogType } from './coreX/Dialogs/RejectDialog/RejectDialog.type.js';
147
- export { SmallDialog } from './coreX/Dialogs/SmallDialog.js';
148
157
  export { InfoRowList } from './coreX/InfoRowList/InfoRowList.js';
149
158
  export { Show } from './coreX/Show/index.js';
150
159
  export { Animation, Keyframes } from './styles/token/animation.js';
@@ -31,7 +31,7 @@ import InputGroup from './core/InputGroup/index.js';
31
31
  import LegacySelect from './core/LegacySelect/index.js';
32
32
  import Link from './core/Link/index.js';
33
33
  import Loading from './core/Loading/index.js';
34
- import _message from './core/message/index.js';
34
+ import _message from './core/message/message.js';
35
35
  import Modal from './core/Modal/index.js';
36
36
  import Pagination from './core/Pagination/index.js';
37
37
  import Percent from './core/Percent/index.js';