@flytedan/flytebot-design-system 0.13.0 → 0.14.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.
package/dist/index.cjs CHANGED
@@ -8673,6 +8673,30 @@ function BudgetReallocator({
8673
8673
  setDraft(spend);
8674
8674
  if (onCancel) onCancel();
8675
8675
  };
8676
+ const trackRef = React39.useRef(null);
8677
+ const chipRef = React39.useRef(null);
8678
+ const [chipLeft, setChipLeft] = React39.useState(null);
8679
+ React39.useLayoutEffect(() => {
8680
+ const track = trackRef.current;
8681
+ if (!dirty || !track) {
8682
+ setChipLeft(null);
8683
+ return;
8684
+ }
8685
+ const measure = () => {
8686
+ const chip = chipRef.current;
8687
+ if (!chip) return;
8688
+ const trackWidth = track.clientWidth;
8689
+ const chipWidth = chip.offsetWidth;
8690
+ const half = chipWidth / 2;
8691
+ const desired = pct / 100 * trackWidth;
8692
+ setChipLeft(Math.min(Math.max(desired, half), Math.max(trackWidth - half, half)));
8693
+ };
8694
+ measure();
8695
+ if (typeof ResizeObserver !== "function") return;
8696
+ const ro = new ResizeObserver(measure);
8697
+ ro.observe(track);
8698
+ return () => ro.disconnect();
8699
+ }, [dirty, pct]);
8676
8700
  return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
8677
8701
  "div",
8678
8702
  {
@@ -8687,9 +8711,20 @@ function BudgetReallocator({
8687
8711
  /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(CsiBadge, { band: nextBand, crp: nextCrp, size: "medium", preview: true })
8688
8712
  ] }) : null
8689
8713
  ] }),
8690
- /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "fd-slider", children: [
8714
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "fd-slider", ref: trackRef, children: [
8691
8715
  /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "fd-slider-fill", style: { width: pct + "%" } }),
8692
- dirty ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "fd-slider-chip", style: { left: pct + "%", background: delta < 0 ? "var(--danger-solid)" : "var(--ok-solid)" }, children: (delta < 0 ? "\u2212$" : "+$") + Math.abs(delta).toLocaleString() }) : null,
8716
+ dirty ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
8717
+ "span",
8718
+ {
8719
+ ref: chipRef,
8720
+ className: "fd-slider-chip",
8721
+ style: {
8722
+ left: chipLeft === null ? pct + "%" : chipLeft,
8723
+ background: delta < 0 ? "var(--danger-solid)" : "var(--ok-solid)"
8724
+ },
8725
+ children: (delta < 0 ? "\u2212$" : "+$") + Math.abs(delta).toLocaleString()
8726
+ }
8727
+ ) : null,
8693
8728
  /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
8694
8729
  "input",
8695
8730
  {
@@ -10857,6 +10892,7 @@ function FileBrowser({
10857
10892
  onMoveFile,
10858
10893
  onOpenFile,
10859
10894
  onRemoveFile,
10895
+ onDeleteFolder,
10860
10896
  onUpload,
10861
10897
  loading = false,
10862
10898
  permissions,
@@ -10868,10 +10904,12 @@ function FileBrowser({
10868
10904
  const canMove = perm.canMove !== false && (!!onMoveFolder || !!onMoveFile);
10869
10905
  const canUpload = perm.canUpload !== false && !!onUpload;
10870
10906
  const canRemoveFile = perm.canRemoveFile !== false && !!onRemoveFile;
10907
+ const canDeleteFolder = perm.canDeleteFolder !== false && !!onDeleteFolder;
10871
10908
  const [createOpen, setCreateOpen] = React48.useState(false);
10872
10909
  const [createName, setCreateName] = React48.useState("");
10873
10910
  const [renameTarget, setRenameTarget] = React48.useState(null);
10874
10911
  const [renameValue, setRenameValue] = React48.useState("");
10912
+ const [deleteTarget, setDeleteTarget] = React48.useState(null);
10875
10913
  const uploadInputRef = React48.useRef(null);
10876
10914
  const crumbFolders = React48.useMemo(() => ancestorsOf(folders, currentFolderId), [folders, currentFolderId]);
10877
10915
  const subfolders = React48.useMemo(() => childrenOf(folders, currentFolderId), [folders, currentFolderId]);
@@ -10907,6 +10945,13 @@ function FileBrowser({
10907
10945
  if (name && renameTarget && onRenameFolder) onRenameFolder(renameTarget.id, name);
10908
10946
  setRenameTarget(null);
10909
10947
  };
10948
+ const openDelete = (folder) => {
10949
+ setDeleteTarget(folder);
10950
+ };
10951
+ const confirmDelete = () => {
10952
+ if (deleteTarget && onDeleteFolder) onDeleteFolder(deleteTarget);
10953
+ setDeleteTarget(null);
10954
+ };
10910
10955
  const content = /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: ["fd-fb", className].filter(Boolean).join(" "), children: [
10911
10956
  /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "fd-fb-head", children: [
10912
10957
  /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("nav", { className: "fd-fb-crumbs", "aria-label": "Folder path", children: [
@@ -11010,7 +11055,8 @@ function FileBrowser({
11010
11055
  destinations: flattenDestinations(folders, f.id),
11011
11056
  onPick: (target) => moveIntoFolder({ kind: "folder", id: f.id }, target)
11012
11057
  }
11013
- ) : null
11058
+ ) : null,
11059
+ canDeleteFolder ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(IconButton, { icon: "trash-simple", label: "Delete " + f.name, size: "sm", variant: "ghost", onClick: () => openDelete(f) }) : null
11014
11060
  ] })
11015
11061
  },
11016
11062
  f.id
@@ -11074,7 +11120,20 @@ function FileBrowser({
11074
11120
  "aria-label": "Folder name",
11075
11121
  autoFocus: true
11076
11122
  }
11077
- ) })
11123
+ ) }),
11124
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
11125
+ Modal,
11126
+ {
11127
+ open: deleteTarget != null,
11128
+ title: deleteTarget ? "Delete \u201C" + deleteTarget.name + "\u201D?" : "Delete folder?",
11129
+ description: "This can't be undone. The folder must be empty.",
11130
+ onClose: () => setDeleteTarget(null),
11131
+ footer: /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_jsx_runtime79.Fragment, { children: [
11132
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Button, { variant: "secondary", onClick: () => setDeleteTarget(null), children: "Cancel" }),
11133
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Button, { variant: "danger", onClick: confirmDelete, children: "Delete" })
11134
+ ] })
11135
+ }
11136
+ )
11078
11137
  ] });
11079
11138
  if (!canUpload) return content;
11080
11139
  return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Dropzone, { className: "fd-fb-dropzone", onFiles: (picked) => onUpload && onUpload(picked, currentFolderId), label: "Drop files to upload", children: content });