@octaviaflow/core 3.1.0-beta.62 → 3.1.0-beta.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9825,6 +9825,7 @@ FieldPicker.displayName = "FieldPicker";
9825
9825
  // src/components/KeyValueEditor/KeyValueEditor.tsx
9826
9826
  import { AddIcon as AddIcon2, CloseIcon as CloseIcon5 } from "@octaviaflow/icons";
9827
9827
  import { jsx as jsx44, jsxs as jsxs42 } from "react/jsx-runtime";
9828
+ var isRowEnabled = (pair) => pair.enabled !== false;
9828
9829
  function KeyValueEditor({
9829
9830
  pairs,
9830
9831
  onChange,
@@ -9832,9 +9833,12 @@ function KeyValueEditor({
9832
9833
  helperText,
9833
9834
  keyPlaceholder = "key",
9834
9835
  valuePlaceholder = "value",
9836
+ descriptionPlaceholder = "description",
9835
9837
  addLabel = "Add",
9836
9838
  keyOptions,
9837
9839
  valueOptions,
9840
+ rowToggle = false,
9841
+ showDescription = false,
9838
9842
  size = "md",
9839
9843
  disabled = false,
9840
9844
  error = false,
@@ -9845,7 +9849,7 @@ function KeyValueEditor({
9845
9849
  }) {
9846
9850
  const setAt = (i, patch) => onChange(pairs.map((p, j) => j === i ? { ...p, ...patch } : p));
9847
9851
  const removeAt = (i) => onChange(pairs.filter((_, j) => j !== i));
9848
- const add = () => onChange([...pairs, { key: "", value: "" }]);
9852
+ const add = () => onChange([...pairs, { key: "", value: "", ...rowToggle ? { enabled: true } : {} }]);
9849
9853
  const canAdd = !disabled && (maxRows === void 0 || pairs.length < maxRows);
9850
9854
  return /* @__PURE__ */ jsxs42(
9851
9855
  "div",
@@ -9854,68 +9858,101 @@ function KeyValueEditor({
9854
9858
  "ods-kv-editor",
9855
9859
  `ods-kv-editor--${size}`,
9856
9860
  error && "ods-kv-editor--error",
9861
+ showDescription && "ods-kv-editor--with-description",
9857
9862
  className
9858
9863
  ),
9859
9864
  children: [
9860
9865
  label && /* @__PURE__ */ jsx44("div", { className: "ods-kv-editor__label", children: label }),
9861
9866
  pairs.length === 0 && emptyLabel && /* @__PURE__ */ jsx44("div", { className: "ods-kv-editor__empty", children: emptyLabel }),
9862
- pairs.map((pair, i) => /* @__PURE__ */ jsxs42("div", { className: "ods-kv-editor__row", children: [
9863
- keyOptions ? /* @__PURE__ */ jsx44(
9864
- Combobox,
9865
- {
9866
- ariaLabel: "Key",
9867
- size,
9868
- value: pair.key,
9869
- options: keyOptions,
9870
- onChange: (v) => setAt(i, { key: v }),
9871
- placeholder: keyPlaceholder,
9872
- disabled
9873
- }
9874
- ) : /* @__PURE__ */ jsx44(
9875
- "input",
9876
- {
9877
- className: "ods-kv-editor__input",
9878
- "aria-label": "Key",
9879
- value: pair.key,
9880
- onChange: (e) => setAt(i, { key: e.target.value }),
9881
- placeholder: keyPlaceholder,
9882
- disabled
9883
- }
9884
- ),
9885
- valueOptions ? /* @__PURE__ */ jsx44(
9886
- Combobox,
9887
- {
9888
- ariaLabel: "Value",
9889
- size,
9890
- value: pair.value,
9891
- options: valueOptions,
9892
- onChange: (v) => setAt(i, { value: v }),
9893
- placeholder: valuePlaceholder,
9894
- disabled
9895
- }
9896
- ) : /* @__PURE__ */ jsx44(
9897
- "input",
9898
- {
9899
- className: "ods-kv-editor__input",
9900
- "aria-label": "Value",
9901
- value: pair.value,
9902
- onChange: (e) => setAt(i, { value: e.target.value }),
9903
- placeholder: valuePlaceholder,
9904
- disabled
9905
- }
9906
- ),
9907
- /* @__PURE__ */ jsx44(
9908
- "button",
9867
+ pairs.map((pair, i) => {
9868
+ const rowOff = rowToggle && !isRowEnabled(pair);
9869
+ const fieldsDisabled = disabled || rowOff;
9870
+ return /* @__PURE__ */ jsxs42(
9871
+ "div",
9909
9872
  {
9910
- type: "button",
9911
- className: "ods-kv-editor__remove",
9912
- "aria-label": "Remove row",
9913
- onClick: () => removeAt(i),
9914
- disabled,
9915
- children: /* @__PURE__ */ jsx44(CloseIcon5, { width: 14, height: 14, "aria-hidden": "true" })
9916
- }
9917
- )
9918
- ] }, i)),
9873
+ className: cn("ods-kv-editor__row", rowOff && "ods-kv-editor__row--disabled"),
9874
+ children: [
9875
+ rowToggle && /* @__PURE__ */ jsx44(
9876
+ Checkbox,
9877
+ {
9878
+ size: size === "lg" ? "md" : size,
9879
+ "aria-label": "Enable row",
9880
+ checked: isRowEnabled(pair),
9881
+ onChange: (on) => setAt(i, { enabled: on }),
9882
+ disabled
9883
+ }
9884
+ ),
9885
+ keyOptions ? /* @__PURE__ */ jsx44(
9886
+ Combobox,
9887
+ {
9888
+ ariaLabel: "Key",
9889
+ size,
9890
+ value: pair.key,
9891
+ options: keyOptions,
9892
+ onChange: (v) => setAt(i, { key: v }),
9893
+ placeholder: keyPlaceholder,
9894
+ disabled: fieldsDisabled
9895
+ }
9896
+ ) : /* @__PURE__ */ jsx44(
9897
+ "input",
9898
+ {
9899
+ className: "ods-kv-editor__input",
9900
+ "aria-label": "Key",
9901
+ value: pair.key,
9902
+ onChange: (e) => setAt(i, { key: e.target.value }),
9903
+ placeholder: keyPlaceholder,
9904
+ disabled: fieldsDisabled
9905
+ }
9906
+ ),
9907
+ valueOptions ? /* @__PURE__ */ jsx44(
9908
+ Combobox,
9909
+ {
9910
+ ariaLabel: "Value",
9911
+ size,
9912
+ value: pair.value,
9913
+ options: valueOptions,
9914
+ onChange: (v) => setAt(i, { value: v }),
9915
+ placeholder: valuePlaceholder,
9916
+ disabled: fieldsDisabled
9917
+ }
9918
+ ) : /* @__PURE__ */ jsx44(
9919
+ "input",
9920
+ {
9921
+ className: "ods-kv-editor__input",
9922
+ "aria-label": "Value",
9923
+ value: pair.value,
9924
+ onChange: (e) => setAt(i, { value: e.target.value }),
9925
+ placeholder: valuePlaceholder,
9926
+ disabled: fieldsDisabled
9927
+ }
9928
+ ),
9929
+ showDescription && /* @__PURE__ */ jsx44(
9930
+ "input",
9931
+ {
9932
+ className: "ods-kv-editor__input ods-kv-editor__input--description",
9933
+ "aria-label": "Description",
9934
+ value: pair.description ?? "",
9935
+ onChange: (e) => setAt(i, { description: e.target.value }),
9936
+ placeholder: descriptionPlaceholder,
9937
+ disabled: fieldsDisabled
9938
+ }
9939
+ ),
9940
+ /* @__PURE__ */ jsx44(
9941
+ "button",
9942
+ {
9943
+ type: "button",
9944
+ className: "ods-kv-editor__remove",
9945
+ "aria-label": "Remove row",
9946
+ onClick: () => removeAt(i),
9947
+ disabled,
9948
+ children: /* @__PURE__ */ jsx44(CloseIcon5, { width: 14, height: 14, "aria-hidden": "true" })
9949
+ }
9950
+ )
9951
+ ]
9952
+ },
9953
+ i
9954
+ );
9955
+ }),
9919
9956
  canAdd && /* @__PURE__ */ jsxs42("button", { type: "button", className: "ods-kv-editor__add", onClick: add, children: [
9920
9957
  /* @__PURE__ */ jsx44(AddIcon2, { width: 14, height: 14, "aria-hidden": "true" }),
9921
9958
  addLabel