@octaviaflow/core 3.1.0-beta.63 → 3.1.0-beta.65

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
@@ -254,6 +254,28 @@ function ActionRow({
254
254
  e.dataTransfer.setData(dragMimeType, JSON.stringify(payload));
255
255
  e.dataTransfer.setData("text/plain", item.label);
256
256
  e.dataTransfer.effectAllowed = "copy";
257
+ if (typeof document !== "undefined") {
258
+ const ghost = document.createElement("div");
259
+ ghost.textContent = item.label;
260
+ ghost.setAttribute("aria-hidden", "true");
261
+ const s = ghost.style;
262
+ s.position = "fixed";
263
+ s.top = "-1000px";
264
+ s.left = "-1000px";
265
+ s.padding = "6px 12px";
266
+ s.borderRadius = "6px";
267
+ s.background = "var(--ods-surface-canvas, #ffffff)";
268
+ s.color = "var(--ods-text-primary, #111827)";
269
+ s.border = "1px solid var(--ods-border-strong, #9ca3af)";
270
+ s.font = "500 13px var(--ods-font-family-sans, sans-serif)";
271
+ s.boxShadow = "0 4px 12px rgba(0,0,0,0.18)";
272
+ s.whiteSpace = "nowrap";
273
+ s.pointerEvents = "none";
274
+ s.zIndex = "9999";
275
+ document.body.appendChild(ghost);
276
+ e.dataTransfer.setDragImage(ghost, 12, 16);
277
+ window.setTimeout(() => ghost.remove(), 0);
278
+ }
257
279
  onDragStart?.(item);
258
280
  },
259
281
  [item, dragMimeType, onDragStart]
@@ -9825,6 +9847,7 @@ FieldPicker.displayName = "FieldPicker";
9825
9847
  // src/components/KeyValueEditor/KeyValueEditor.tsx
9826
9848
  import { AddIcon as AddIcon2, CloseIcon as CloseIcon5 } from "@octaviaflow/icons";
9827
9849
  import { jsx as jsx44, jsxs as jsxs42 } from "react/jsx-runtime";
9850
+ var isRowEnabled = (pair) => pair.enabled !== false;
9828
9851
  function KeyValueEditor({
9829
9852
  pairs,
9830
9853
  onChange,
@@ -9832,9 +9855,12 @@ function KeyValueEditor({
9832
9855
  helperText,
9833
9856
  keyPlaceholder = "key",
9834
9857
  valuePlaceholder = "value",
9858
+ descriptionPlaceholder = "description",
9835
9859
  addLabel = "Add",
9836
9860
  keyOptions,
9837
9861
  valueOptions,
9862
+ rowToggle = false,
9863
+ showDescription = false,
9838
9864
  size = "md",
9839
9865
  disabled = false,
9840
9866
  error = false,
@@ -9845,7 +9871,7 @@ function KeyValueEditor({
9845
9871
  }) {
9846
9872
  const setAt = (i, patch) => onChange(pairs.map((p, j) => j === i ? { ...p, ...patch } : p));
9847
9873
  const removeAt = (i) => onChange(pairs.filter((_, j) => j !== i));
9848
- const add = () => onChange([...pairs, { key: "", value: "" }]);
9874
+ const add = () => onChange([...pairs, { key: "", value: "", ...rowToggle ? { enabled: true } : {} }]);
9849
9875
  const canAdd = !disabled && (maxRows === void 0 || pairs.length < maxRows);
9850
9876
  return /* @__PURE__ */ jsxs42(
9851
9877
  "div",
@@ -9854,68 +9880,101 @@ function KeyValueEditor({
9854
9880
  "ods-kv-editor",
9855
9881
  `ods-kv-editor--${size}`,
9856
9882
  error && "ods-kv-editor--error",
9883
+ showDescription && "ods-kv-editor--with-description",
9857
9884
  className
9858
9885
  ),
9859
9886
  children: [
9860
9887
  label && /* @__PURE__ */ jsx44("div", { className: "ods-kv-editor__label", children: label }),
9861
9888
  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",
9889
+ pairs.map((pair, i) => {
9890
+ const rowOff = rowToggle && !isRowEnabled(pair);
9891
+ const fieldsDisabled = disabled || rowOff;
9892
+ return /* @__PURE__ */ jsxs42(
9893
+ "div",
9909
9894
  {
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)),
9895
+ className: cn("ods-kv-editor__row", rowOff && "ods-kv-editor__row--disabled"),
9896
+ children: [
9897
+ rowToggle && /* @__PURE__ */ jsx44(
9898
+ Checkbox,
9899
+ {
9900
+ size: size === "lg" ? "md" : size,
9901
+ "aria-label": "Enable row",
9902
+ checked: isRowEnabled(pair),
9903
+ onChange: (on) => setAt(i, { enabled: on }),
9904
+ disabled
9905
+ }
9906
+ ),
9907
+ keyOptions ? /* @__PURE__ */ jsx44(
9908
+ Combobox,
9909
+ {
9910
+ ariaLabel: "Key",
9911
+ size,
9912
+ value: pair.key,
9913
+ options: keyOptions,
9914
+ onChange: (v) => setAt(i, { key: v }),
9915
+ placeholder: keyPlaceholder,
9916
+ disabled: fieldsDisabled
9917
+ }
9918
+ ) : /* @__PURE__ */ jsx44(
9919
+ "input",
9920
+ {
9921
+ className: "ods-kv-editor__input",
9922
+ "aria-label": "Key",
9923
+ value: pair.key,
9924
+ onChange: (e) => setAt(i, { key: e.target.value }),
9925
+ placeholder: keyPlaceholder,
9926
+ disabled: fieldsDisabled
9927
+ }
9928
+ ),
9929
+ valueOptions ? /* @__PURE__ */ jsx44(
9930
+ Combobox,
9931
+ {
9932
+ ariaLabel: "Value",
9933
+ size,
9934
+ value: pair.value,
9935
+ options: valueOptions,
9936
+ onChange: (v) => setAt(i, { value: v }),
9937
+ placeholder: valuePlaceholder,
9938
+ disabled: fieldsDisabled
9939
+ }
9940
+ ) : /* @__PURE__ */ jsx44(
9941
+ "input",
9942
+ {
9943
+ className: "ods-kv-editor__input",
9944
+ "aria-label": "Value",
9945
+ value: pair.value,
9946
+ onChange: (e) => setAt(i, { value: e.target.value }),
9947
+ placeholder: valuePlaceholder,
9948
+ disabled: fieldsDisabled
9949
+ }
9950
+ ),
9951
+ showDescription && /* @__PURE__ */ jsx44(
9952
+ "input",
9953
+ {
9954
+ className: "ods-kv-editor__input ods-kv-editor__input--description",
9955
+ "aria-label": "Description",
9956
+ value: pair.description ?? "",
9957
+ onChange: (e) => setAt(i, { description: e.target.value }),
9958
+ placeholder: descriptionPlaceholder,
9959
+ disabled: fieldsDisabled
9960
+ }
9961
+ ),
9962
+ /* @__PURE__ */ jsx44(
9963
+ "button",
9964
+ {
9965
+ type: "button",
9966
+ className: "ods-kv-editor__remove",
9967
+ "aria-label": "Remove row",
9968
+ onClick: () => removeAt(i),
9969
+ disabled,
9970
+ children: /* @__PURE__ */ jsx44(CloseIcon5, { width: 14, height: 14, "aria-hidden": "true" })
9971
+ }
9972
+ )
9973
+ ]
9974
+ },
9975
+ i
9976
+ );
9977
+ }),
9919
9978
  canAdd && /* @__PURE__ */ jsxs42("button", { type: "button", className: "ods-kv-editor__add", onClick: add, children: [
9920
9979
  /* @__PURE__ */ jsx44(AddIcon2, { width: 14, height: 14, "aria-hidden": "true" }),
9921
9980
  addLabel