@dovetail-v2/refine 0.0.44 → 0.0.45-bowen.0

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,4 +1,4 @@
1
- import { j as jsxRuntimeExports } from "./index-72d47bc9.js";
1
+ import { j as jsxRuntimeExports } from "./index-c644b7e1.js";
2
2
  import * as monaco from "monaco-editor";
3
3
  import { useRef, useEffect } from "react";
4
4
  import "i18next";
@@ -9953,7 +9953,7 @@ const ServiceOutClusterAccessComponent = ({
9953
9953
  children: content || "-"
9954
9954
  });
9955
9955
  };
9956
- const index_1wlqq0y = "";
9956
+ const index_10ylmu3 = "";
9957
9957
  const TagWrapper = "t13a6vox";
9958
9958
  const TagStyle = "t12ikbmp";
9959
9959
  const Tags = (props) => {
@@ -9992,23 +9992,24 @@ const StateTag = ({
9992
9992
  const {
9993
9993
  t: t2
9994
9994
  } = useTranslation();
9995
- const colorMap = {
9996
- updating: "blue",
9995
+ const statusMap = {
9996
+ updating: "loading",
9997
9997
  ready: "green",
9998
9998
  completed: "gray",
9999
9999
  failed: "red",
10000
10000
  suspended: "warning",
10001
- running: "blue",
10002
- succeeded: "green",
10003
- unknown: "warning",
10004
- terminating: "red",
10005
- pending: "gray",
10001
+ running: "green",
10002
+ succeeded: "blue",
10003
+ unknown: "gray",
10004
+ terminating: "loading",
10005
+ pending: "warning",
10006
10006
  waiting: "warning",
10007
10007
  terminated: "red"
10008
10008
  };
10009
10009
  return /* @__PURE__ */ jsxRuntimeExports.jsx(kit.statusCapsule, {
10010
10010
  className: cx_default(className, StateTagStyle, hideBackground && "no-background"),
10011
- color: colorMap[state2],
10011
+ color: statusMap[state2] !== "loading" ? statusMap[state2] : void 0,
10012
+ loading: statusMap[state2] === "loading",
10012
10013
  children: t2(`dovetail.${state2 || "updating"}`)
10013
10014
  });
10014
10015
  };
@@ -10683,7 +10684,7 @@ const IngressRulesTable = ({ ingress }) => {
10683
10684
  }
10684
10685
  );
10685
10686
  };
10686
- const KeyValue_1v1utgj = "";
10687
+ const KeyValue_q4vd5r = "";
10687
10688
  const ContentBlockStyle = "c8jy7dc";
10688
10689
  const KeyStyle = "k2sddxl";
10689
10690
  const ValueStyle$2 = "v16vicsr";
@@ -18314,7 +18315,7 @@ function parseJSON(value2) {
18314
18315
  }
18315
18316
  }
18316
18317
  const GlobalStoreContext = createContext({});
18317
- const index_1uuzt53 = "";
18318
+ const index_1xad2h9 = "";
18318
18319
  const SelectStyle = "sj0ggy";
18319
18320
  const DropdownStyle = "d1eo8uqs";
18320
18321
  const SearchInputStyle = "s64gojc";
@@ -18350,6 +18351,7 @@ const NamespacesFilter = ({
18350
18351
  t: t2
18351
18352
  } = useTranslation();
18352
18353
  const [search, setSearch] = useState("");
18354
+ const [tagMaxWidth, setTagMaxWidth] = useState("");
18353
18355
  const {
18354
18356
  data: data2,
18355
18357
  isLoading
@@ -18364,91 +18366,144 @@ const NamespacesFilter = ({
18364
18366
  }
18365
18367
  });
18366
18368
  const [value2, setValue] = useLocalStorage(NS_STORE_KEY, [ALL_NS]);
18369
+ const [open, setOpen] = useState(false);
18367
18370
  const debouncedSetSearch = debounce(setSearch, 100);
18368
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(kit.select, {
18369
- loading: isLoading,
18370
- style: {
18371
- width: 278
18372
- },
18373
- className: cx_default(SelectStyle, className),
18374
- dropdownClassName: DropdownStyle,
18375
- searchValue: search,
18376
- virtual: false,
18377
- input: {
18378
- value: value2,
18379
- onChange(value22) {
18380
- if (last(value22) === ALL_NS || value22.length === 0) {
18381
- setValue([ALL_NS]);
18382
- } else {
18383
- setValue(value22.filter((namespace2) => namespace2 !== ALL_NS));
18371
+ const MAX_TAG_COUNT = 8;
18372
+ const COUNT_TAG_WIDTH = 22;
18373
+ const TAG_GAP = 4;
18374
+ const PADDING = 36;
18375
+ const hasCountTag = value2.length > MAX_TAG_COUNT;
18376
+ const WRAPPER_CLASS = "d2-namespace-select-wrapper";
18377
+ const SELECT_CLASS = "d2-namespace-select";
18378
+ const calcTagMaxWidth = useCallback(() => {
18379
+ const wrapper = document.querySelector(`.${WRAPPER_CLASS}`);
18380
+ const n2 = Math.min(value2.length, MAX_TAG_COUNT);
18381
+ const tagWidth = ((wrapper == null ? void 0 : wrapper.offsetWidth) || 0) / n2;
18382
+ const gapsWidth = (Math.min(value2.length, MAX_TAG_COUNT + 1) - 1) * TAG_GAP;
18383
+ const paddingAndCountTagWidth = PADDING + (hasCountTag ? COUNT_TAG_WIDTH : 0);
18384
+ const perTagMaxWidth = tagWidth - (paddingAndCountTagWidth + gapsWidth) / n2;
18385
+ setTagMaxWidth(`${perTagMaxWidth}px`);
18386
+ }, [value2, hasCountTag]);
18387
+ useEffect(() => {
18388
+ calcTagMaxWidth();
18389
+ }, [calcTagMaxWidth]);
18390
+ useEffect(() => {
18391
+ window.addEventListener("resize", calcTagMaxWidth);
18392
+ return () => {
18393
+ window.removeEventListener("resize", calcTagMaxWidth);
18394
+ };
18395
+ }, [calcTagMaxWidth]);
18396
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
18397
+ className: WRAPPER_CLASS,
18398
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(kit.select, {
18399
+ loading: isLoading,
18400
+ className: cx_default(SelectStyle, SELECT_CLASS, className),
18401
+ style: {
18402
+ "--tag-max-width": tagMaxWidth
18403
+ },
18404
+ dropdownClassName: DropdownStyle,
18405
+ searchValue: search,
18406
+ virtual: false,
18407
+ input: {
18408
+ value: value2,
18409
+ onChange(value22) {
18410
+ if (last(value22) === ALL_NS || value22.length === 0) {
18411
+ setValue([ALL_NS]);
18412
+ } else {
18413
+ setValue(value22.filter((namespace2) => namespace2 !== ALL_NS));
18414
+ }
18384
18415
  }
18385
- }
18386
- },
18387
- dropdownRender: (menu) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
18388
- className: SelectContentStyle,
18389
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.searchInput, {
18390
- style: {
18391
- width: "100%"
18392
- },
18393
- className: SearchInputStyle,
18394
- onChange: debouncedSetSearch,
18395
- placeholder: t2("dovetail.please_input")
18396
- }), menu, isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.loading, {}) : null]
18397
- }),
18398
- tagRender: ({
18399
- label: label2,
18400
- value: value22,
18401
- closable,
18402
- onClose
18403
- }) => {
18404
- const isCountToken = label2 !== value22 && typeof label2 === "string";
18405
- const isAll = value22 === ALL_NS;
18406
- return isAll ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
18407
- style: {
18408
- marginLeft: 8
18409
- },
18410
- children: label2
18411
- }) : /* @__PURE__ */ jsxRuntimeExports.jsx(kit.token, {
18412
- className: cx_default(isCountToken ? CountTokenStyle : TokenStyle, isCountToken ? "" : "closable-token"),
18416
+ },
18417
+ dropdownRender: (menu) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
18418
+ className: SelectContentStyle,
18419
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.searchInput, {
18420
+ style: {
18421
+ width: "100%"
18422
+ },
18423
+ className: SearchInputStyle,
18424
+ onChange: debouncedSetSearch,
18425
+ placeholder: t2("dovetail.please_input")
18426
+ }), menu, isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.loading, {}) : null]
18427
+ }),
18428
+ tagRender: ({
18429
+ label: label2,
18430
+ value: namespaceValue,
18413
18431
  closable,
18414
- size: "medium",
18415
- onClose,
18432
+ onClose
18433
+ }) => {
18434
+ const isCountToken = label2 !== namespaceValue && typeof label2 === "string";
18435
+ const isAll = namespaceValue === ALL_NS;
18436
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
18437
+ onClick: () => {
18438
+ setOpen(!open);
18439
+ },
18440
+ children: isAll ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", {
18441
+ style: {
18442
+ marginLeft: 8
18443
+ },
18444
+ children: [label2, "..."]
18445
+ }) : /* @__PURE__ */ jsxRuntimeExports.jsx(kit.token, {
18446
+ className: cx_default(isCountToken ? CountTokenStyle : TokenStyle, isCountToken ? "" : "closable-token"),
18447
+ closable,
18448
+ size: "medium",
18449
+ onClose,
18450
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18451
+ content: isCountToken ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.tooltip, {
18452
+ title: isCountToken ? value2.slice(MAX_TAG_COUNT).map((namespace2, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
18453
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx("div", {
18454
+ children: namespace2
18455
+ }), index !== value2.length - 1 - MAX_TAG_COUNT ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.divider, {
18456
+ style: {
18457
+ margin: "6px 0",
18458
+ borderColor: "rgba(107, 128, 167, 0.60)"
18459
+ }
18460
+ }) : null]
18461
+ })) : null,
18462
+ trigger: ["hover"],
18463
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
18464
+ children: label2.replace(/[\s\.]/g, "")
18465
+ })
18466
+ }) : label2
18467
+ })
18468
+ })
18469
+ });
18470
+ },
18471
+ maxTagCount: MAX_TAG_COUNT,
18472
+ optionLabelProp: "label",
18473
+ showArrow: true,
18474
+ showSearch: false,
18475
+ open,
18476
+ onDropdownVisibleChange: (open2) => {
18477
+ setOpen(open2);
18478
+ },
18479
+ multiple: true,
18480
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18481
+ value: "_all",
18482
+ label: t2("dovetail.all_namespaces"),
18483
+ className: AllNamespaceOptionStyle,
18416
18484
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18417
- content: isCountToken ? label2.replace(/[\s\.]/g, "") : label2
18485
+ content: t2("dovetail.all_namespaces"),
18486
+ className: LabelWrapperStyle
18418
18487
  })
18419
- });
18420
- },
18421
- maxTagCount: 1,
18422
- optionLabelProp: "label",
18423
- showArrow: true,
18424
- showSearch: false,
18425
- multiple: true,
18426
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18427
- value: "_all",
18428
- label: t2("dovetail.all_namespaces"),
18429
- className: AllNamespaceOptionStyle,
18430
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18431
- content: t2("dovetail.all_namespaces"),
18432
- className: LabelWrapperStyle
18433
- })
18434
- }, "_all"), /* @__PURE__ */ jsxRuntimeExports.jsx(kit.selectOptGroup, {
18435
- label: "",
18436
- className: SelectOptionGroupStyle,
18437
- children: data2 == null ? void 0 : data2.data.map((namespace2) => {
18438
- const {
18439
- name: name2
18440
- } = namespace2.metadata;
18441
- return /* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18442
- value: name2,
18443
- label: name2,
18444
- className: OptionStyle,
18445
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18446
- content: name2,
18447
- className: LabelWrapperStyle
18448
- })
18449
- }, name2);
18450
- })
18451
- })]
18488
+ }, "_all"), /* @__PURE__ */ jsxRuntimeExports.jsx(kit.selectOptGroup, {
18489
+ label: "",
18490
+ className: SelectOptionGroupStyle,
18491
+ children: data2 == null ? void 0 : data2.data.map((namespace2) => {
18492
+ const {
18493
+ name: name2
18494
+ } = namespace2.metadata;
18495
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18496
+ value: name2,
18497
+ label: name2,
18498
+ className: OptionStyle,
18499
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18500
+ content: name2,
18501
+ className: LabelWrapperStyle
18502
+ })
18503
+ }, name2);
18504
+ })
18505
+ })]
18506
+ })
18452
18507
  });
18453
18508
  };
18454
18509
  const index_hp158y = "";
@@ -22453,7 +22508,6 @@ const useForm = ({
22453
22508
  };
22454
22509
  };
22455
22510
  const useRefineForm = (props) => {
22456
- var _a;
22457
22511
  const { config, id, refineProps } = props;
22458
22512
  const [responseErrorMsg, setResponseErrorMsg] = useState("");
22459
22513
  const i18n2 = useTranslation();
@@ -22486,15 +22540,15 @@ const useRefineForm = (props) => {
22486
22540
  defaultValues: config == null ? void 0 : config.initValue
22487
22541
  });
22488
22542
  useEffect(() => {
22489
- var _a2, _b;
22490
- const response = (_a2 = result.refineCore.mutationResult.error) == null ? void 0 : _a2.response;
22543
+ var _a, _b;
22544
+ const response = (_a = result.refineCore.mutationResult.error) == null ? void 0 : _a.response;
22491
22545
  if (response && !(response == null ? void 0 : response.bodyUsed)) {
22492
22546
  (_b = response.json) == null ? void 0 : _b.call(response).then((body) => {
22493
- var _a3, _b2;
22494
- setResponseErrorMsg(((_b2 = (_a3 = config.formConfig) == null ? void 0 : _a3.formatError) == null ? void 0 : _b2.call(_a3, body)) || body.message);
22547
+ var _a2, _b2;
22548
+ setResponseErrorMsg(((_b2 = (_a2 = config.formConfig) == null ? void 0 : _a2.formatError) == null ? void 0 : _b2.call(_a2, body)) || body.message);
22495
22549
  });
22496
22550
  }
22497
- }, [config.formConfig, (_a = result.refineCore.mutationResult.error) == null ? void 0 : _a.response]);
22551
+ }, [config.formConfig, result]);
22498
22552
  return { formResult: result, responseErrorMsg };
22499
22553
  };
22500
22554
  const index_12sfrn = "";
@@ -22505,7 +22559,7 @@ const Separator = () => {
22505
22559
  });
22506
22560
  };
22507
22561
  const MonacoYamlEditor = React__default.lazy(() => Promise.resolve().then(() => MonacoYamlEditor$2));
22508
- const MonacoYamlDiffEditor = React__default.lazy(() => import("./MonacoYamlDiffEditor-71c3ccc4.js"));
22562
+ const MonacoYamlDiffEditor = React__default.lazy(() => import("./MonacoYamlDiffEditor-5ce46809.js"));
22509
22563
  const YamlEditorComponent = forwardRef(
22510
22564
  function YamlEditorComponent2(props, ref) {
22511
22565
  const {
@@ -23020,9 +23074,18 @@ const useYamlForm = ({
23020
23074
  setEditorErrors(errors);
23021
23075
  return;
23022
23076
  }
23023
- const objectValues = editor.current ? yaml.load(((_a2 = editor.current) == null ? void 0 : _a2.getEditorValue()) || "") : values;
23024
- const finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
23025
- return onFinish(finalValues);
23077
+ try {
23078
+ const objectValues = editor.current ? yaml.load(((_a2 = editor.current) == null ? void 0 : _a2.getEditorValue()) || "") : values;
23079
+ const finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
23080
+ return onFinish(finalValues);
23081
+ } catch (error) {
23082
+ if (error instanceof Error) {
23083
+ if (error.message === "expected a single document in the stream, but found more") {
23084
+ setEditorErrors([t2("dovetail.only_support_one_yaml")]);
23085
+ return;
23086
+ }
23087
+ }
23088
+ }
23026
23089
  },
23027
23090
  onKeyUp,
23028
23091
  onValuesChange,
package/dist/refine.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b6, bK, A, az, aB, aj, bm, aJ, G, bA, bo, at, w, C, g, bO, am, aN, Y, bQ, a0, a7, bZ, ab, bp, bn, c0, ap, aT, t, ah, aY, b$, bL, b0, D, aG, b2, b_, aH, ax, b9, bN, bP, by, ak, a1, p, o, bR, I, aQ, aw, q, bq, bT, ao, aP, ac, ad, T, ae, aA, ai, aZ, b1, U, M, bz, b5, N, H, b, ay, O, b8, aV, aU, bS, bk, e, bs, V, P, aL, s, Z, bj, aI, bX, bW, aE, aR, n, an, aK, v, aS, aF, c4, bM, b3, ba, bb, al, R, $, a5, a4, b4, a2, bY, a3, a8, f, bF, bI, bE, bD, bG, bH, bB, bt, bw, bx, bv, bu, br, bc, aq, aO, af, k, bf, i, aC, c3, m, bg, aD, l, av, aM, h, c2, as, au, aX, aW, ar, S, a$, a_, c1, bC, bl, bh, bi, X, bV, _, W, bU, a6, aa, a9, c, bJ, ag, bd, x, J, d, Q, L, K, r, a, z, y, B, E, b7, F, be, u } from "./index-72d47bc9.js";
1
+ import { b6, bK, A, az, aB, aj, bm, aJ, G, bA, bo, at, w, C, g, bO, am, aN, Y, bQ, a0, a7, bZ, ab, bp, bn, c0, ap, aT, t, ah, aY, b$, bL, b0, D, aG, b2, b_, aH, ax, b9, bN, bP, by, ak, a1, p, o, bR, I, aQ, aw, q, bq, bT, ao, aP, ac, ad, T, ae, aA, ai, aZ, b1, U, M, bz, b5, N, H, b, ay, O, b8, aV, aU, bS, bk, e, bs, V, P, aL, s, Z, bj, aI, bX, bW, aE, aR, n, an, aK, v, aS, aF, c4, bM, b3, ba, bb, al, R, $, a5, a4, b4, a2, bY, a3, a8, f, bF, bI, bE, bD, bG, bH, bB, bt, bw, bx, bv, bu, br, bc, aq, aO, af, k, bf, i, aC, c3, m, bg, aD, l, av, aM, h, c2, as, au, aX, aW, ar, S, a$, a_, c1, bC, bl, bh, bi, X, bV, _, W, bU, a6, aa, a9, c, bJ, ag, bd, x, J, d, Q, L, K, r, a, z, y, B, E, b7, F, be, u } from "./index-c644b7e1.js";
2
2
  import "@cloudtower/eagle";
3
3
  import "@refinedev/core";
4
4
  import "@cloudtower/icons-react";
@@ -9959,7 +9959,7 @@ var __publicField = (obj, key, value) => {
9959
9959
  children: content || "-"
9960
9960
  });
9961
9961
  };
9962
- const index_1wlqq0y = "";
9962
+ const index_10ylmu3 = "";
9963
9963
  const TagWrapper = "t13a6vox";
9964
9964
  const TagStyle = "t12ikbmp";
9965
9965
  const Tags = (props) => {
@@ -9998,23 +9998,24 @@ var __publicField = (obj, key, value) => {
9998
9998
  const {
9999
9999
  t: t2
10000
10000
  } = useTranslation();
10001
- const colorMap = {
10002
- updating: "blue",
10001
+ const statusMap = {
10002
+ updating: "loading",
10003
10003
  ready: "green",
10004
10004
  completed: "gray",
10005
10005
  failed: "red",
10006
10006
  suspended: "warning",
10007
- running: "blue",
10008
- succeeded: "green",
10009
- unknown: "warning",
10010
- terminating: "red",
10011
- pending: "gray",
10007
+ running: "green",
10008
+ succeeded: "blue",
10009
+ unknown: "gray",
10010
+ terminating: "loading",
10011
+ pending: "warning",
10012
10012
  waiting: "warning",
10013
10013
  terminated: "red"
10014
10014
  };
10015
10015
  return /* @__PURE__ */ jsxRuntimeExports.jsx(kit.statusCapsule, {
10016
10016
  className: cx_default(className, StateTagStyle, hideBackground && "no-background"),
10017
- color: colorMap[state2],
10017
+ color: statusMap[state2] !== "loading" ? statusMap[state2] : void 0,
10018
+ loading: statusMap[state2] === "loading",
10018
10019
  children: t2(`dovetail.${state2 || "updating"}`)
10019
10020
  });
10020
10021
  };
@@ -10689,7 +10690,7 @@ var __publicField = (obj, key, value) => {
10689
10690
  }
10690
10691
  );
10691
10692
  };
10692
- const KeyValue_1v1utgj = "";
10693
+ const KeyValue_q4vd5r = "";
10693
10694
  const ContentBlockStyle = "c8jy7dc";
10694
10695
  const KeyStyle = "k2sddxl";
10695
10696
  const ValueStyle$2 = "v16vicsr";
@@ -18320,7 +18321,7 @@ var __publicField = (obj, key, value) => {
18320
18321
  }
18321
18322
  }
18322
18323
  const GlobalStoreContext = React.createContext({});
18323
- const index_1uuzt53 = "";
18324
+ const index_1xad2h9 = "";
18324
18325
  const SelectStyle = "sj0ggy";
18325
18326
  const DropdownStyle = "d1eo8uqs";
18326
18327
  const SearchInputStyle = "s64gojc";
@@ -18356,6 +18357,7 @@ var __publicField = (obj, key, value) => {
18356
18357
  t: t2
18357
18358
  } = useTranslation();
18358
18359
  const [search, setSearch] = React.useState("");
18360
+ const [tagMaxWidth, setTagMaxWidth] = React.useState("");
18359
18361
  const {
18360
18362
  data: data2,
18361
18363
  isLoading
@@ -18370,91 +18372,144 @@ var __publicField = (obj, key, value) => {
18370
18372
  }
18371
18373
  });
18372
18374
  const [value2, setValue] = useLocalStorage(NS_STORE_KEY, [ALL_NS]);
18375
+ const [open, setOpen] = React.useState(false);
18373
18376
  const debouncedSetSearch = lodashEs.debounce(setSearch, 100);
18374
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(kit.select, {
18375
- loading: isLoading,
18376
- style: {
18377
- width: 278
18378
- },
18379
- className: cx_default(SelectStyle, className),
18380
- dropdownClassName: DropdownStyle,
18381
- searchValue: search,
18382
- virtual: false,
18383
- input: {
18384
- value: value2,
18385
- onChange(value22) {
18386
- if (lodashEs.last(value22) === ALL_NS || value22.length === 0) {
18387
- setValue([ALL_NS]);
18388
- } else {
18389
- setValue(value22.filter((namespace2) => namespace2 !== ALL_NS));
18377
+ const MAX_TAG_COUNT = 8;
18378
+ const COUNT_TAG_WIDTH = 22;
18379
+ const TAG_GAP = 4;
18380
+ const PADDING = 36;
18381
+ const hasCountTag = value2.length > MAX_TAG_COUNT;
18382
+ const WRAPPER_CLASS = "d2-namespace-select-wrapper";
18383
+ const SELECT_CLASS = "d2-namespace-select";
18384
+ const calcTagMaxWidth = React.useCallback(() => {
18385
+ const wrapper = document.querySelector(`.${WRAPPER_CLASS}`);
18386
+ const n2 = Math.min(value2.length, MAX_TAG_COUNT);
18387
+ const tagWidth = ((wrapper == null ? void 0 : wrapper.offsetWidth) || 0) / n2;
18388
+ const gapsWidth = (Math.min(value2.length, MAX_TAG_COUNT + 1) - 1) * TAG_GAP;
18389
+ const paddingAndCountTagWidth = PADDING + (hasCountTag ? COUNT_TAG_WIDTH : 0);
18390
+ const perTagMaxWidth = tagWidth - (paddingAndCountTagWidth + gapsWidth) / n2;
18391
+ setTagMaxWidth(`${perTagMaxWidth}px`);
18392
+ }, [value2, hasCountTag]);
18393
+ React.useEffect(() => {
18394
+ calcTagMaxWidth();
18395
+ }, [calcTagMaxWidth]);
18396
+ React.useEffect(() => {
18397
+ window.addEventListener("resize", calcTagMaxWidth);
18398
+ return () => {
18399
+ window.removeEventListener("resize", calcTagMaxWidth);
18400
+ };
18401
+ }, [calcTagMaxWidth]);
18402
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
18403
+ className: WRAPPER_CLASS,
18404
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(kit.select, {
18405
+ loading: isLoading,
18406
+ className: cx_default(SelectStyle, SELECT_CLASS, className),
18407
+ style: {
18408
+ "--tag-max-width": tagMaxWidth
18409
+ },
18410
+ dropdownClassName: DropdownStyle,
18411
+ searchValue: search,
18412
+ virtual: false,
18413
+ input: {
18414
+ value: value2,
18415
+ onChange(value22) {
18416
+ if (lodashEs.last(value22) === ALL_NS || value22.length === 0) {
18417
+ setValue([ALL_NS]);
18418
+ } else {
18419
+ setValue(value22.filter((namespace2) => namespace2 !== ALL_NS));
18420
+ }
18390
18421
  }
18391
- }
18392
- },
18393
- dropdownRender: (menu) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
18394
- className: SelectContentStyle,
18395
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.searchInput, {
18396
- style: {
18397
- width: "100%"
18398
- },
18399
- className: SearchInputStyle,
18400
- onChange: debouncedSetSearch,
18401
- placeholder: t2("dovetail.please_input")
18402
- }), menu, isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.loading, {}) : null]
18403
- }),
18404
- tagRender: ({
18405
- label: label2,
18406
- value: value22,
18407
- closable,
18408
- onClose
18409
- }) => {
18410
- const isCountToken = label2 !== value22 && typeof label2 === "string";
18411
- const isAll = value22 === ALL_NS;
18412
- return isAll ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
18413
- style: {
18414
- marginLeft: 8
18415
- },
18416
- children: label2
18417
- }) : /* @__PURE__ */ jsxRuntimeExports.jsx(kit.token, {
18418
- className: cx_default(isCountToken ? CountTokenStyle : TokenStyle, isCountToken ? "" : "closable-token"),
18422
+ },
18423
+ dropdownRender: (menu) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
18424
+ className: SelectContentStyle,
18425
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.searchInput, {
18426
+ style: {
18427
+ width: "100%"
18428
+ },
18429
+ className: SearchInputStyle,
18430
+ onChange: debouncedSetSearch,
18431
+ placeholder: t2("dovetail.please_input")
18432
+ }), menu, isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.loading, {}) : null]
18433
+ }),
18434
+ tagRender: ({
18435
+ label: label2,
18436
+ value: namespaceValue,
18419
18437
  closable,
18420
- size: "medium",
18421
- onClose,
18438
+ onClose
18439
+ }) => {
18440
+ const isCountToken = label2 !== namespaceValue && typeof label2 === "string";
18441
+ const isAll = namespaceValue === ALL_NS;
18442
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
18443
+ onClick: () => {
18444
+ setOpen(!open);
18445
+ },
18446
+ children: isAll ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", {
18447
+ style: {
18448
+ marginLeft: 8
18449
+ },
18450
+ children: [label2, "..."]
18451
+ }) : /* @__PURE__ */ jsxRuntimeExports.jsx(kit.token, {
18452
+ className: cx_default(isCountToken ? CountTokenStyle : TokenStyle, isCountToken ? "" : "closable-token"),
18453
+ closable,
18454
+ size: "medium",
18455
+ onClose,
18456
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18457
+ content: isCountToken ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.tooltip, {
18458
+ title: isCountToken ? value2.slice(MAX_TAG_COUNT).map((namespace2, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
18459
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx("div", {
18460
+ children: namespace2
18461
+ }), index !== value2.length - 1 - MAX_TAG_COUNT ? /* @__PURE__ */ jsxRuntimeExports.jsx(kit.divider, {
18462
+ style: {
18463
+ margin: "6px 0",
18464
+ borderColor: "rgba(107, 128, 167, 0.60)"
18465
+ }
18466
+ }) : null]
18467
+ })) : null,
18468
+ trigger: ["hover"],
18469
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
18470
+ children: label2.replace(/[\s\.]/g, "")
18471
+ })
18472
+ }) : label2
18473
+ })
18474
+ })
18475
+ });
18476
+ },
18477
+ maxTagCount: MAX_TAG_COUNT,
18478
+ optionLabelProp: "label",
18479
+ showArrow: true,
18480
+ showSearch: false,
18481
+ open,
18482
+ onDropdownVisibleChange: (open2) => {
18483
+ setOpen(open2);
18484
+ },
18485
+ multiple: true,
18486
+ children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18487
+ value: "_all",
18488
+ label: t2("dovetail.all_namespaces"),
18489
+ className: AllNamespaceOptionStyle,
18422
18490
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18423
- content: isCountToken ? label2.replace(/[\s\.]/g, "") : label2
18491
+ content: t2("dovetail.all_namespaces"),
18492
+ className: LabelWrapperStyle
18424
18493
  })
18425
- });
18426
- },
18427
- maxTagCount: 1,
18428
- optionLabelProp: "label",
18429
- showArrow: true,
18430
- showSearch: false,
18431
- multiple: true,
18432
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18433
- value: "_all",
18434
- label: t2("dovetail.all_namespaces"),
18435
- className: AllNamespaceOptionStyle,
18436
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18437
- content: t2("dovetail.all_namespaces"),
18438
- className: LabelWrapperStyle
18439
- })
18440
- }, "_all"), /* @__PURE__ */ jsxRuntimeExports.jsx(kit.selectOptGroup, {
18441
- label: "",
18442
- className: SelectOptionGroupStyle,
18443
- children: data2 == null ? void 0 : data2.data.map((namespace2) => {
18444
- const {
18445
- name: name2
18446
- } = namespace2.metadata;
18447
- return /* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18448
- value: name2,
18449
- label: name2,
18450
- className: OptionStyle,
18451
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18452
- content: name2,
18453
- className: LabelWrapperStyle
18454
- })
18455
- }, name2);
18456
- })
18457
- })]
18494
+ }, "_all"), /* @__PURE__ */ jsxRuntimeExports.jsx(kit.selectOptGroup, {
18495
+ label: "",
18496
+ className: SelectOptionGroupStyle,
18497
+ children: data2 == null ? void 0 : data2.data.map((namespace2) => {
18498
+ const {
18499
+ name: name2
18500
+ } = namespace2.metadata;
18501
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(kit.option, {
18502
+ value: name2,
18503
+ label: name2,
18504
+ className: OptionStyle,
18505
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(kit.overflowTooltip, {
18506
+ content: name2,
18507
+ className: LabelWrapperStyle
18508
+ })
18509
+ }, name2);
18510
+ })
18511
+ })]
18512
+ })
18458
18513
  });
18459
18514
  };
18460
18515
  const index_hp158y = "";
@@ -22459,7 +22514,6 @@ var __publicField = (obj, key, value) => {
22459
22514
  };
22460
22515
  };
22461
22516
  const useRefineForm = (props) => {
22462
- var _a;
22463
22517
  const { config, id, refineProps } = props;
22464
22518
  const [responseErrorMsg, setResponseErrorMsg] = React.useState("");
22465
22519
  const i18n2 = useTranslation();
@@ -22492,15 +22546,15 @@ var __publicField = (obj, key, value) => {
22492
22546
  defaultValues: config == null ? void 0 : config.initValue
22493
22547
  });
22494
22548
  React.useEffect(() => {
22495
- var _a2, _b;
22496
- const response = (_a2 = result.refineCore.mutationResult.error) == null ? void 0 : _a2.response;
22549
+ var _a, _b;
22550
+ const response = (_a = result.refineCore.mutationResult.error) == null ? void 0 : _a.response;
22497
22551
  if (response && !(response == null ? void 0 : response.bodyUsed)) {
22498
22552
  (_b = response.json) == null ? void 0 : _b.call(response).then((body) => {
22499
- var _a3, _b2;
22500
- setResponseErrorMsg(((_b2 = (_a3 = config.formConfig) == null ? void 0 : _a3.formatError) == null ? void 0 : _b2.call(_a3, body)) || body.message);
22553
+ var _a2, _b2;
22554
+ setResponseErrorMsg(((_b2 = (_a2 = config.formConfig) == null ? void 0 : _a2.formatError) == null ? void 0 : _b2.call(_a2, body)) || body.message);
22501
22555
  });
22502
22556
  }
22503
- }, [config.formConfig, (_a = result.refineCore.mutationResult.error) == null ? void 0 : _a.response]);
22557
+ }, [config.formConfig, result]);
22504
22558
  return { formResult: result, responseErrorMsg };
22505
22559
  };
22506
22560
  const index_12sfrn = "";
@@ -23026,9 +23080,18 @@ var __publicField = (obj, key, value) => {
23026
23080
  setEditorErrors(errors);
23027
23081
  return;
23028
23082
  }
23029
- const objectValues = editor.current ? yaml.load(((_a2 = editor.current) == null ? void 0 : _a2.getEditorValue()) || "") : values;
23030
- const finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
23031
- return onFinish(finalValues);
23083
+ try {
23084
+ const objectValues = editor.current ? yaml.load(((_a2 = editor.current) == null ? void 0 : _a2.getEditorValue()) || "") : values;
23085
+ const finalValues = (transformApplyValues == null ? void 0 : transformApplyValues(objectValues)) || objectValues;
23086
+ return onFinish(finalValues);
23087
+ } catch (error) {
23088
+ if (error instanceof Error) {
23089
+ if (error.message === "expected a single document in the stream, but found more") {
23090
+ setEditorErrors([t2("dovetail.only_support_one_yaml")]);
23091
+ return;
23092
+ }
23093
+ }
23094
+ }
23032
23095
  },
23033
23096
  onKeyUp,
23034
23097
  onValuesChange,
package/dist/style.css CHANGED
@@ -12,7 +12,7 @@
12
12
  .b1vtjd4k.ant-btn.ant-btn-link{display:block;}
13
13
  .luro4rx.ant-btn.ant-btn-link{line-height:18px;height:18px;}
14
14
  .t13a6vox{-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;max-width:100%;gap:8px 8px;}
15
- .t12ikbmp.ant-tag{overflow:hidden;text-overflow:ellipsis;color:#1D326C;}.t12ikbmp.ant-tag.outside-tag{background-color:rgba(211,218,235,0.60);}.t12ikbmp.ant-tag .inside-tag{background-color:rgba(192,203,224,0.60);}
15
+ .t12ikbmp.ant-tag{overflow:hidden;text-overflow:ellipsis;color:#1D326C;}.t12ikbmp.ant-tag.outside-tag{border:1px solid #A3B4CC;background-color:#E4E9F2;}.t12ikbmp.ant-tag .inside-tag{background-color:#CCD4E3;}
16
16
  .s8qkbck.ant-tag{padding:3px 16px;height:24px;}.s8qkbck.no-background{background-color:transparent !important;padding:0;}
17
17
  .t19ustft{display:inline-block;line-height:18px;height:18px;border-bottom:1px dashed rgba(107,128,167,0.6);}
18
18
  .t1v3ienx{padding:12px 24px;}
@@ -22,7 +22,7 @@
22
22
  .w16agr8o.ant-space{width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}
23
23
  .i1u1f5zp{white-space:pre-line;}
24
24
  .c8jy7dc{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding:8px 10px;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;gap:8px;-webkit-align-self:stretch;-ms-flex-item-align:stretch;align-self:stretch;border-radius:4px;background:rgba(237,241,250,0.6);}.c8jy7dc:not(:last-of-type){margin-bottom:8px;}
25
- .k2sddxl{color:rgba(44,56,82,0.6);width:calc(30% - 4px);margin-right:8px;word-break:break-all;}
25
+ .k2sddxl{color:rgba(44,56,82,0.75);width:calc(30% - 4px);margin-right:8px;word-break:break-all;}
26
26
  .v16vicsr{word-break:break-all;white-space:pre-wrap;width:calc(70% - 4px);}
27
27
  .w14056kz{width:100%;}
28
28
  .hisq2gt{width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.hisq2gt.expanded{margin-bottom:8px;}
@@ -1506,12 +1506,12 @@
1506
1506
  .e1cjl2b8{border-radius:8px;border:1px solid rgba(211,218,235,0.60);}.e1cjl2b8 .monaco-editor,.e1cjl2b8 .monaco-scrollable-element,.e1cjl2b8 .overflow-guard > .margin{border-radius:8px;}
1507
1507
  .w1akirqw{height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}
1508
1508
  .t30srnq{line-height:32px !important;}
1509
- .sj0ggy.ant-select .ant-select-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;overflow:hidden;gap:4px;}.sj0ggy.ant-select .ant-select-selector > span{max-width:calc(100% - 76px);-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}.sj0ggy.ant-select .ant-select-selection-search{display:none;}.sj0ggy.ant-select .zoom-leave{opacity:0;position:absolute;}
1509
+ .sj0ggy.ant-select{-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start;min-width:276px;max-width:100%;}.sj0ggy.ant-select .ant-select-selector{display:block;overflow:hidden;padding-right:32px;white-space:nowrap;}.sj0ggy.ant-select .ant-select-selector > span:nth-child(-n + 8):not(.ant-select-selection-search){display:inline-block;max-width:var(--tag-max-width);margin-right:4px;}.sj0ggy.ant-select .ant-select-selection-search{display:none;}.sj0ggy.ant-select .zoom-leave{opacity:0;position:absolute;}
1510
1510
  .d1eo8uqs{border-radius:6px;}
1511
1511
  .s64gojc.s64gojc.ant-input-affix-wrapper{border:unset;border-bottom:1px solid rgba(211,218,235,.6);border-radius:unset;box-shadow:unset;outline:unset;padding:5px 18px;}.s64gojc.s64gojc.ant-input-affix-wrapper:hover,.s64gojc.s64gojc.ant-input-affix-wrapper:focus{box-shadow:unset;outline:unset;}
1512
1512
  .s16fqgtu .ant-select-item-group{border-bottom:1px solid rgba(211,218,235,0.6);min-height:0;padding:0;overflow:hidden;margin:6px 0;}
1513
1513
  .tgaujbg{max-width:100%;margin-right:0 !important;}
1514
- .c1vbd54v{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;margin-right:0;}
1514
+ .c1vbd54v{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;margin-right:0 !important;}
1515
1515
 
1516
1516
  .lqrghwd{margin-right:8px;}
1517
1517
  .api7z1z{border-radius:4px;margin:6px;margin-bottom:0;padding:4px 8px 4px 12px;}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dovetail-v2/refine",
3
- "version": "0.0.44",
3
+ "version": "0.0.45-bowen.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",