@octaviaflow/core 3.1.0-beta.82 → 3.1.0-beta.83

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.
@@ -50,6 +50,11 @@ export interface FilePickerProps {
50
50
  closeOnEsc?: boolean;
51
51
  /** Empty-folder copy. */
52
52
  emptyTitle?: string;
53
+ /** Display names for opaque paths. Some backends use ids as "paths"
54
+ * (cloud drives) — seed this with known `path → name` pairs (e.g. a saved
55
+ * value's display name) so crumbs and the folder footer never show raw
56
+ * ids. Names discovered while browsing are learned automatically. */
57
+ pathLabels?: Record<string, string>;
53
58
  /** Hidden input name for form submission. */
54
59
  name?: string;
55
60
  form?: string;
@@ -57,7 +62,7 @@ export interface FilePickerProps {
57
62
  className?: string;
58
63
  "aria-label"?: string;
59
64
  }
60
- export declare function FilePicker({ value: valueProp, defaultValue, onChange, loadChildren, rootPath, rootLabel, separator, selectMode, initialPath, placeholder, disabled, size, error, helperText, label, required, clearable, searchable, onSearch, searchDepth, searchLimit, closeOnEsc, emptyTitle, name, form, id, className, "aria-label": ariaLabel, }: FilePickerProps): import("react/jsx-runtime").JSX.Element;
65
+ export declare function FilePicker({ value: valueProp, defaultValue, onChange, loadChildren, rootPath, rootLabel, separator, selectMode, initialPath, placeholder, disabled, size, error, helperText, label, required, clearable, searchable, onSearch, searchDepth, searchLimit, closeOnEsc, emptyTitle, pathLabels, name, form, id, className, "aria-label": ariaLabel, }: FilePickerProps): import("react/jsx-runtime").JSX.Element;
61
66
  export declare namespace FilePicker {
62
67
  var displayName: string;
63
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker.d.ts","sourceRoot":"","sources":["../../../src/components/FilePicker/FilePicker.tsx"],"names":[],"mappings":"AAeA,OAAO,EAEL,KAAK,SAAS,EAOf,MAAM,OAAO,CAAC;AAQf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgBhD,MAAM,MAAM,oBAAoB,GAAG,MAAM,G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IACtD,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yBAAyB;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAoDD,wBAAgB,UAAU,CAAC,EACzB,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,QAAc,EACd,SAAkB,EAClB,SAAe,EACf,UAAmB,EACnB,WAAW,EACX,WAA8B,EAC9B,QAAgB,EAChB,IAAW,EACX,KAAK,EACL,UAAU,EACV,KAAK,EACL,QAAgB,EAChB,SAAgB,EAChB,UAAkB,EAClB,QAAQ,EACR,WAAe,EACf,WAAiB,EACjB,UAAiB,EACjB,UAAmC,EACnC,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,SAAS,EACT,YAAY,EAAE,SAAS,GACxB,EAAE,eAAe,2CAwejB;yBArgBe,UAAU"}
1
+ {"version":3,"file":"FilePicker.d.ts","sourceRoot":"","sources":["../../../src/components/FilePicker/FilePicker.tsx"],"names":[],"mappings":"AAeA,OAAO,EAEL,KAAK,SAAS,EAOf,MAAM,OAAO,CAAC;AAQf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgBhD,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC9D,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,kCAAkC;IAClC,KAAK,CAAC,E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,yBAAyB;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;0EAGsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAoDD,wBAAgB,UAAU,CAAC,EACzB,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,QAAc,EACd,SAAkB,EAClB,SAAe,EACf,UAAmB,EACnB,WAAW,EACX,WAA8B,EAC9B,QAAgB,EAChB,IAAW,EACX,KAAK,EACL,UAAU,EACV,KAAK,EACL,QAAgB,EAChB,SAAgB,EAChB,UAAkB,EAClB,QAAQ,EACR,WAAe,EACf,WAAiB,EACjB,UAAiB,EACjB,UAAmC,EACnC,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,SAAS,EACT,YAAY,EAAE,SAAS,GACxB,EAAE,eAAe,2CAuhBjB;yBArjBe,UAAU"}
package/dist/index.cjs CHANGED
@@ -19889,6 +19889,7 @@ function FilePicker({
19889
19889
  searchLimit = 200,
19890
19890
  closeOnEsc = true,
19891
19891
  emptyTitle = "This folder is empty",
19892
+ pathLabels,
19892
19893
  name,
19893
19894
  form,
19894
19895
  id,
@@ -19903,6 +19904,8 @@ function FilePicker({
19903
19904
  const value = valueProp ?? valueState;
19904
19905
  const [open, setOpen] = (0, import_react97.useState)(false);
19905
19906
  const [navPath, setNavPath] = (0, import_react97.useState)(rootPath);
19907
+ const [trail, setTrail] = (0, import_react97.useState)([]);
19908
+ const [nameByPath, setNameByPath] = (0, import_react97.useState)({});
19906
19909
  const [cache, setCache] = (0, import_react97.useState)({});
19907
19910
  const cacheRef = (0, import_react97.useRef)(cache);
19908
19911
  cacheRef.current = cache;
@@ -19924,6 +19927,11 @@ function FilePicker({
19924
19927
  try {
19925
19928
  const items2 = await loadChildren(folder);
19926
19929
  setCache((prev) => ({ ...prev, [folder]: { status: "loaded", items: items2 } }));
19930
+ setNameByPath((prev) => {
19931
+ const next = { ...prev };
19932
+ for (const it of items2) next[it.path] = it.name;
19933
+ return next;
19934
+ });
19927
19935
  return items2;
19928
19936
  } catch (e) {
19929
19937
  const err = e?.message || "Failed to load folder.";
@@ -19936,6 +19944,7 @@ function FilePicker({
19936
19944
  const openAt = (0, import_react97.useCallback)(() => {
19937
19945
  const start = initialPath ?? (value ? parentOf(value, rootPath, separator) ?? rootPath : rootPath);
19938
19946
  setNavPath(start);
19947
+ setTrail([]);
19939
19948
  setQuery("");
19940
19949
  setActiveIndex(-1);
19941
19950
  setOpen(true);
@@ -20020,12 +20029,13 @@ function FilePicker({
20020
20029
  (item) => {
20021
20030
  if (item.disabled) return;
20022
20031
  if (item.isDirectory) {
20032
+ setTrail((t) => navPath === rootPath ? t : [...t, navPath]);
20023
20033
  navigate(item.path);
20024
20034
  } else if (canSelectFiles) {
20025
20035
  commit(item.path, item);
20026
20036
  }
20027
20037
  },
20028
- [navigate, canSelectFiles, commit]
20038
+ [navigate, canSelectFiles, commit, navPath, rootPath]
20029
20039
  );
20030
20040
  (0, import_react97.useEffect)(() => {
20031
20041
  if (!open) return;
@@ -20058,11 +20068,30 @@ function FilePicker({
20058
20068
  if (isSearching) return search?.results ?? [];
20059
20069
  return [...rawItems].sort(folderFirstThenName);
20060
20070
  }, [isSearching, search, rawItems]);
20071
+ const displayName = (0, import_react97.useCallback)(
20072
+ (p) => p === rootPath ? rootLabel : nameByPath[p] ?? pathLabels?.[p] ?? baseName(p, separator),
20073
+ [rootPath, rootLabel, nameByPath, pathLabels, separator]
20074
+ );
20061
20075
  const crumbs = (0, import_react97.useMemo)(() => {
20062
- const chain = ancestorsOf(navPath, rootPath, separator);
20063
- return chain.map((p, i) => ({ path: p, label: i === 0 ? rootLabel : baseName(p, separator) }));
20064
- }, [navPath, rootPath, rootLabel, separator]);
20065
- const parent = parentOf(navPath, rootPath, separator);
20076
+ if (navPath === rootPath) return [{ path: rootPath, label: rootLabel }];
20077
+ const derived = ancestorsOf(navPath, rootPath, separator);
20078
+ const derivedValid = derived[derived.length - 1] === navPath;
20079
+ const chain = derivedValid && (derived.length > 2 || trail.length === 0) ? derived : [rootPath, ...trail.filter((p) => p !== rootPath), navPath];
20080
+ return chain.map((p, i) => ({ path: p, label: i === 0 ? rootLabel : displayName(p) }));
20081
+ }, [navPath, rootPath, rootLabel, separator, trail, displayName]);
20082
+ const parent = trail.length ? trail[trail.length - 1] : parentOf(navPath, rootPath, separator);
20083
+ const goUp = (0, import_react97.useCallback)(() => {
20084
+ if (!parent) return;
20085
+ setTrail((t) => t.length ? t.slice(0, -1) : t);
20086
+ navigate(parent);
20087
+ }, [parent, navigate]);
20088
+ const goToCrumb = (0, import_react97.useCallback)(
20089
+ (path, index) => {
20090
+ setTrail(crumbs.slice(1, index).map((c) => c.path));
20091
+ navigate(path);
20092
+ },
20093
+ [crumbs, navigate]
20094
+ );
20066
20095
  const onPopoverKeyDown = (e) => {
20067
20096
  const inSearch = e.target?.tagName === "INPUT";
20068
20097
  if (e.key === "ArrowDown") {
@@ -20172,7 +20201,7 @@ function FilePicker({
20172
20201
  className: "ods-file-picker__up",
20173
20202
  "aria-label": "Up one folder",
20174
20203
  disabled: !parent,
20175
- onClick: () => parent && navigate(parent),
20204
+ onClick: goUp,
20176
20205
  children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_icons36.FolderParentIcon, { size: "sm" })
20177
20206
  }
20178
20207
  ),
@@ -20189,7 +20218,7 @@ function FilePicker({
20189
20218
  ),
20190
20219
  "aria-current": isLast ? "page" : void 0,
20191
20220
  disabled: isLast,
20192
- onClick: () => !isLast && navigate(c.path),
20221
+ onClick: () => !isLast && goToCrumb(c.path, i),
20193
20222
  children: c.label
20194
20223
  }
20195
20224
  ),
@@ -20241,7 +20270,7 @@ function FilePicker({
20241
20270
  {
20242
20271
  icon: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_icons36.FolderIcon, {}),
20243
20272
  title: isSearching ? "No matches" : emptyTitle,
20244
- description: isSearching ? `Nothing under \u201C${baseName(navPath, separator) || rootLabel}\u201D matches \u201C${query.trim()}\u201D.` : void 0
20273
+ description: isSearching ? `Nothing under \u201C${displayName(navPath) || rootLabel}\u201D matches \u201C${query.trim()}\u201D.` : void 0
20245
20274
  }
20246
20275
  ) }) : items.map((it, i) => {
20247
20276
  const active = i === activeIndex;
@@ -20286,14 +20315,14 @@ function FilePicker({
20286
20315
  showFooter && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "ods-file-picker__footer", children: [
20287
20316
  /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("span", { className: "ods-file-picker__footer-path", title: navPath, children: [
20288
20317
  /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "ods-file-picker__footer-label", children: "Selected" }),
20289
- navPath
20318
+ displayName(navPath)
20290
20319
  ] }),
20291
20320
  /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
20292
20321
  "button",
20293
20322
  {
20294
20323
  type: "button",
20295
20324
  className: "ods-file-picker__use",
20296
- onClick: () => commit(navPath, { name: baseName(navPath, separator), path: navPath, isDirectory: true }),
20325
+ onClick: () => commit(navPath, { name: displayName(navPath), path: navPath, isDirectory: true }),
20297
20326
  children: [
20298
20327
  "Use this folder",
20299
20328
  /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_icons36.ChevronRightIcon, { size: "sm", "aria-hidden": "true" })