@prorobotech/openapi-k8s-toolkit 0.0.1-alpha.143 → 0.0.1-alpha.145

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.
@@ -46016,6 +46016,39 @@ const getStringByName = (name) => {
46016
46016
  return String(name);
46017
46017
  };
46018
46018
 
46019
+ const listItemBasePath = (fullFieldPath) => {
46020
+ for (let i = fullFieldPath.length - 1; i >= 0; i--) {
46021
+ if (typeof fullFieldPath[i] === "number") {
46022
+ return fullFieldPath.slice(0, i + 1);
46023
+ }
46024
+ }
46025
+ return fullFieldPath.slice(0, -1);
46026
+ };
46027
+ const parseDotPath = (dotPath) => dotPath.split(".").filter(Boolean).map((seg) => seg.match(/^\d+$/) ? Number(seg) : seg);
46028
+ const resolveFormPath = (pathInput, basePathForRelative) => {
46029
+ if (!pathInput) return [];
46030
+ if (Array.isArray(pathInput)) return pathInput;
46031
+ const pathStr = String(pathInput);
46032
+ const isRelative = pathStr.startsWith("./") || pathStr.startsWith("../");
46033
+ if (!isRelative) {
46034
+ return parseDotPath(pathStr);
46035
+ }
46036
+ let resolved = [...basePathForRelative];
46037
+ const parts = pathStr.split("/").filter(Boolean);
46038
+ for (const part of parts) {
46039
+ if (part === ".") {
46040
+ continue;
46041
+ }
46042
+ if (part === "..") {
46043
+ resolved = resolved.slice(0, -1);
46044
+ continue;
46045
+ }
46046
+ resolved.push(...parseDotPath(part));
46047
+ }
46048
+ return resolved;
46049
+ };
46050
+ const normalizeNameToPath = (name) => Array.isArray(name) ? name : [name];
46051
+
46019
46052
  const FormListInput = ({
46020
46053
  name,
46021
46054
  arrKey,
@@ -46039,29 +46072,32 @@ const FormListInput = ({
46039
46072
  const form = Form.useFormInstance();
46040
46073
  const fieldValue = Form.useWatch(name === "nodeName" ? "nodeNameBecauseOfSuddenBug" : name, form);
46041
46074
  const fixedName = name === "nodeName" ? "nodeNameBecauseOfSuddenBug" : name;
46042
- const rawRelatedFieldValue = Form.useWatch(customProps.relatedValuePath, form);
46043
- const relatedFieldValue = customProps.relatedValuePath ? rawRelatedFieldValue : void 0;
46044
- const relatedTouched = customProps.relatedValuePath ? form.isFieldTouched(customProps.relatedValuePath) : "~";
46075
+ const fullFieldPath = normalizeNameToPath(fixedName);
46076
+ const baseForRelative = listItemBasePath(fullFieldPath);
46077
+ const relatedPath = customProps.relatedValuePath ? resolveFormPath(customProps.relatedValuePath, baseForRelative) : void 0;
46078
+ const rawRelatedFieldValue = Form.useWatch(relatedPath, form);
46079
+ const relatedFieldValue = relatedPath ? rawRelatedFieldValue : void 0;
46080
+ const relatedTouched = relatedPath ? form.isFieldTouched(relatedPath) : "~";
46045
46081
  const hasFiredRef = useRef(false);
46046
46082
  const relatedFieldValuePrev = useRef("unset");
46047
46083
  const hasSeededRef = useRef(false);
46048
46084
  useEffect(() => {
46049
- if (customProps.relatedValuePath && relatedTouched) {
46085
+ if (relatedPath && relatedTouched) {
46050
46086
  updateTouched((prev) => ({
46051
46087
  ...prev,
46052
- [customProps.relatedValuePath?.join(".") || "your doing it wrong"]: true
46088
+ [relatedPath.join(".") || "your doing it wrong"]: true
46053
46089
  }));
46054
46090
  }
46055
- }, [customProps.relatedValuePath, relatedTouched, updateTouched]);
46091
+ }, [relatedPath, relatedTouched, updateTouched]);
46056
46092
  useEffect(() => {
46057
- if (customProps.relatedValuePath && isTouchedPeristed[customProps.relatedValuePath.join(".")] && relatedFieldValue && !hasSeededRef.current) {
46093
+ if (relatedPath && isTouchedPeristed[relatedPath.join(".")] && relatedFieldValue && !hasSeededRef.current) {
46058
46094
  relatedFieldValuePrev.current = relatedFieldValue;
46059
46095
  hasSeededRef.current = true;
46060
46096
  form.setFieldValue(arrName || fixedName, void 0);
46061
46097
  onValuesChangeCallBack?.();
46062
46098
  }
46063
46099
  }, [
46064
- customProps.relatedValuePath,
46100
+ relatedPath,
46065
46101
  relatedTouched,
46066
46102
  isTouchedPeristed,
46067
46103
  relatedFieldValue,
@@ -46071,7 +46107,7 @@ const FormListInput = ({
46071
46107
  onValuesChangeCallBack
46072
46108
  ]);
46073
46109
  useEffect(() => {
46074
- if (!customProps.relatedValuePath || relatedFieldValuePrev.current === "unset") {
46110
+ if (!relatedPath || relatedFieldValuePrev.current === "unset") {
46075
46111
  return;
46076
46112
  }
46077
46113
  if ((!relatedFieldValue || relatedFieldValuePrev.current !== "unset" && relatedFieldValuePrev.current !== relatedFieldValue) && !hasFiredRef.current) {
@@ -46082,15 +46118,7 @@ const FormListInput = ({
46082
46118
  } else if (relatedFieldValue && hasFiredRef.current) {
46083
46119
  hasFiredRef.current = false;
46084
46120
  }
46085
- }, [
46086
- customProps.relatedValuePath,
46087
- form,
46088
- arrName,
46089
- fixedName,
46090
- relatedFieldValue,
46091
- onValuesChangeCallBack,
46092
- isTouchedPeristed
46093
- ]);
46121
+ }, [relatedPath, form, arrName, fixedName, relatedFieldValue, onValuesChangeCallBack, isTouchedPeristed]);
46094
46122
  const uri = prepareTemplate({
46095
46123
  template: customProps.valueUri,
46096
46124
  replaceValues: { clusterName, namespace, syntheticProject, relatedFieldValue, entryName }
@@ -46103,7 +46131,7 @@ const FormListInput = ({
46103
46131
  uri,
46104
46132
  refetchInterval: false,
46105
46133
  queryKey: [uri || "", JSON.stringify(name)],
46106
- isEnabled: !!uri && (!customProps.relatedValuePath || customProps.relatedValuePath && !!relatedFieldValue)
46134
+ isEnabled: !!uri && (!relatedPath || relatedPath && !!relatedFieldValue)
46107
46135
  });
46108
46136
  if (isLoadingOptionsObj && (!customProps.relatedValuePath || customProps.relatedValuePath && !!relatedFieldValue)) {
46109
46137
  return /* @__PURE__ */ jsxRuntimeExports.jsx(HeightContainer, { $height: 64, children: "Loading" });
@@ -46176,7 +46204,7 @@ const FormListInput = ({
46176
46204
  placeholder: "Select",
46177
46205
  options: uniqueOptions,
46178
46206
  filterOption: filterSelectOptions,
46179
- disabled: customProps.relatedValuePath && !rawRelatedFieldValue,
46207
+ disabled: relatedPath && !rawRelatedFieldValue,
46180
46208
  allowClear: true,
46181
46209
  showSearch: true
46182
46210
  }
@@ -47994,6 +48022,7 @@ const expandWildcardTemplates = (templates, values, opts) => {
47994
48022
  };
47995
48023
  const isPathArray = (p) => Array.isArray(p);
47996
48024
  const toStringPath = (p) => isPathArray(p) ? p.map(String) : [String(p)];
48025
+ const isPrefix = (full, prefix) => prefix.length <= full.length && prefix.every((seg, i) => full[i] === seg);
47997
48026
 
47998
48027
  const handleSubmitError = ({
47999
48028
  error,
@@ -48348,6 +48377,47 @@ const BlackholeForm = ({
48348
48377
  }
48349
48378
  const newLengths = collectArrayLengths(v);
48350
48379
  const prevLengths = prevArrayLengthsRef.current;
48380
+ for (const [k, prevLen] of prevLengths.entries()) {
48381
+ const newLen = newLengths.get(k) ?? 0;
48382
+ if (newLen < prevLen) {
48383
+ const arrayPath = JSON.parse(k);
48384
+ for (let i = newLen; i < prevLen; i++) {
48385
+ const removedPrefix = [...arrayPath, i];
48386
+ setExpandedKeys(
48387
+ (prev) => prev.filter((p) => {
48388
+ const full = Array.isArray(p) ? p : [p];
48389
+ return !isPrefix(full, removedPrefix);
48390
+ })
48391
+ );
48392
+ setPersistedKeys(
48393
+ (prev) => prev.filter((p) => {
48394
+ const full = Array.isArray(p) ? p : [p];
48395
+ return !isPrefix(full, removedPrefix);
48396
+ })
48397
+ );
48398
+ for (const k2 of [...blockedPathsRef.current]) {
48399
+ const path = JSON.parse(k2);
48400
+ if (isPrefix(path, removedPrefix)) blockedPathsRef.current.delete(k2);
48401
+ }
48402
+ }
48403
+ }
48404
+ }
48405
+ for (const [k, newLen] of newLengths.entries()) {
48406
+ const prevLen = prevLengths.get(k) ?? 0;
48407
+ if (newLen > prevLen) {
48408
+ const arrayPath = JSON.parse(k);
48409
+ for (let i = prevLen; i < newLen; i++) {
48410
+ const itemPath = [...arrayPath, i];
48411
+ const itemVal = form.getFieldValue(itemPath);
48412
+ if (typeof itemVal === "undefined") {
48413
+ form.setFieldValue(itemPath, {});
48414
+ }
48415
+ blockedPathsRef.current.delete(JSON.stringify(itemPath));
48416
+ applyPrefillForNewArrayItem(arrayPath, i);
48417
+ }
48418
+ }
48419
+ }
48420
+ prevArrayLengthsRef.current = newLengths;
48351
48421
  const allKeys = /* @__PURE__ */ new Set([...prevLengths.keys(), ...newLengths.keys()]);
48352
48422
  [...allKeys].forEach((k) => dbg(k, " : ", prevLengths.get(k), "→", newLengths.get(k)));
48353
48423
  for (const [k, newLen] of newLengths.entries()) {