@burdenoff/microfe-coolandlovely 2026.1110.2 → 2026.1112.1

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.
@@ -7,6 +7,8 @@ interface ImageUploadFieldProps {
7
7
  onChange: (fileId: string) => void;
8
8
  /** Destination folder in wspace-files (see COO_FILE_FOLDERS). */
9
9
  folder?: string;
10
+ /** Only catalog forms opt into this choice. Personal wardrobe never does. */
11
+ allowWorkspace?: boolean;
10
12
  hint?: string;
11
13
  /** `accept` for the input; images only by default. */
12
14
  accept?: string;
@@ -2,151 +2,174 @@ import { FieldShell as e } from "./Field.js";
2
2
  import { useCoolAndLovely as t } from "../context/CoolAndLovelyContext.js";
3
3
  import { uploadImageToFilesWithProgress as n, useFileUrl as r } from "../hooks/useFiles.js";
4
4
  import { cn as i } from "../utils/cn.js";
5
- import { useEffect as a, useId as o, useRef as s, useState as c } from "react";
6
- import { ImagePlus as l, Loader2 as u, UploadCloud as d, X as f } from "lucide-react";
7
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
5
+ import { uploadVisibility as a } from "../hooks/uploadVisibility.js";
6
+ import { useTr as o } from "../hooks/useTr.js";
7
+ import { useEffect as s, useId as c, useRef as l, useState as u } from "react";
8
+ import { ImagePlus as d, Loader2 as f, UploadCloud as p, X as m } from "lucide-react";
9
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
8
10
  // src/coolandlovely/components/ImageUploadField.tsx
9
- var h = 10485760;
10
- function g(e) {
11
+ var ee = 10485760;
12
+ function _(e) {
11
13
  if (e < 1024) return `${e} B`;
12
14
  let t = e / 1024;
13
15
  return t < 1024 ? `${t < 10 ? t.toFixed(1) : Math.round(t)} KB` : `${(t / 1024).toFixed(1)} MB`;
14
16
  }
15
- var _ = ({ label: _, value: v, onChange: y, folder: b, hint: x, accept: S = "image/*", disabled: C = !1, className: w, aspect: T = "square" }) => {
16
- let { apiGatewayUrl: E } = t(), D = s(null), O = o(), [k, A] = c(!1), [j, M] = c(null), [N, P] = c(null), [F, I] = c(null), [L, R] = c(!1), [z, B] = c();
17
- a(() => () => {
18
- F && URL.revokeObjectURL(F);
19
- }, [F]);
20
- let V = r(k ? void 0 : v || void 0).data ?? null, H = C || k, U = async (e) => {
17
+ var v = ({ label: v, value: y, onChange: b, folder: x, allowWorkspace: S = !1, hint: C, accept: w = "image/*", disabled: T = !1, className: E, aspect: D = "square" }) => {
18
+ let O = o(), { apiGatewayUrl: k } = t(), A = l(null), j = c(), [M, N] = u(!1), [P, F] = u(null), [I, L] = u(null), [R, z] = u(null), [B, V] = u(!1), [H, U] = u(), [W, G] = u("PRIVATE"), K = l(!1);
19
+ s(() => () => {
20
+ R && URL.revokeObjectURL(R);
21
+ }, [R]);
22
+ let q = r(M ? void 0 : y || void 0).data ?? null, J = T || M, Y = async (e) => {
23
+ if (T || K.current) return;
21
24
  if (!e.type.startsWith("image/")) {
22
- B("Please choose an image file (JPG or PNG).");
25
+ U("Please choose an image file (JPG or PNG).");
23
26
  return;
24
27
  }
25
- if (e.size > h) {
26
- B("That image is over 10 MB — please choose a smaller file.");
28
+ if (e.size > ee) {
29
+ U("That image is over 10 MB — please choose a smaller file.");
27
30
  return;
28
31
  }
29
- B(void 0), P(e.name);
32
+ U(void 0), L(e.name);
30
33
  let t = URL.createObjectURL(e);
31
- I(t), M({
34
+ z(t), F({
32
35
  loaded: 0,
33
36
  total: e.size,
34
37
  pct: 0
35
- }), A(!0);
38
+ }), K.current = !0, N(!0);
36
39
  try {
37
- y((await n(e, E, b, (e) => M(e))).id);
40
+ b((await n(e, k, x, F, S ? W : "PRIVATE")).id);
38
41
  } catch (e) {
39
- B(e instanceof Error ? e.message : "Upload failed — please try again.");
42
+ U(e instanceof Error ? e.message : "Upload failed — please try again.");
40
43
  } finally {
41
- A(!1), M(null), P(null), I(null);
44
+ K.current = !1, N(!1), F(null), L(null), z(null);
42
45
  }
43
- }, W = (e) => {
46
+ }, X = (e) => {
44
47
  let t = e.target.files?.[0];
45
- e.target.value = "", t && U(t);
46
- }, G = (e) => {
47
- if (e.preventDefault(), R(!1), H) return;
48
+ e.target.value = "", t && Y(t);
49
+ }, Z = (e) => {
50
+ if (e.preventDefault(), V(!1), J) return;
48
51
  let t = e.dataTransfer.files?.[0];
49
- t && U(t);
50
- }, K = (e) => {
51
- e.preventDefault(), H || R(!0);
52
- }, q = (e) => {
53
- e.preventDefault(), R(!1);
54
- }, J = j?.pct ?? 0;
55
- return /* @__PURE__ */ m(e, {
56
- label: _,
57
- htmlFor: O,
58
- hint: x,
59
- error: z,
60
- className: w,
61
- children: [/* @__PURE__ */ p("div", {
62
- onDragEnter: K,
63
- onDragOver: K,
64
- onDragLeave: q,
65
- onDrop: G,
66
- children: k ? /* @__PURE__ */ m("div", {
67
- className: "flex items-center gap-3 rounded-lg border border-border-seam bg-bg-surface p-3",
68
- children: [/* @__PURE__ */ p("div", {
69
- className: "flex h-14 w-14 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-bg-sunken",
70
- children: F ? /* @__PURE__ */ p("img", {
71
- src: F,
52
+ t && Y(t);
53
+ }, Q = (e) => {
54
+ e.preventDefault(), J || V(!0);
55
+ }, te = (e) => {
56
+ e.preventDefault(), V(!1);
57
+ }, $ = P?.pct ?? 0;
58
+ return /* @__PURE__ */ g(e, {
59
+ label: v,
60
+ htmlFor: j,
61
+ hint: C,
62
+ error: H,
63
+ className: E,
64
+ children: [
65
+ S ? /* @__PURE__ */ g("label", {
66
+ className: "mb-2 block text-sm text-text-secondary",
67
+ children: [O("coolandlovely.upload.audience", "New image audience"), /* @__PURE__ */ g("select", {
68
+ value: W,
69
+ disabled: J,
70
+ onChange: (e) => G(a(e.target.value)),
71
+ className: "ml-2 rounded-lg border border-border-seam bg-bg-surface p-2 text-text-primary",
72
+ children: [/* @__PURE__ */ h("option", {
73
+ value: "PRIVATE",
74
+ children: O("coolandlovely.upload.private", "Only me")
75
+ }), /* @__PURE__ */ h("option", {
76
+ value: "WORKSPACE",
77
+ children: O("coolandlovely.upload.workspace", "Workspace members")
78
+ })]
79
+ })]
80
+ }) : null,
81
+ /* @__PURE__ */ h("div", {
82
+ onDragEnter: Q,
83
+ onDragOver: Q,
84
+ onDragLeave: te,
85
+ onDrop: Z,
86
+ children: M ? /* @__PURE__ */ g("div", {
87
+ className: "flex items-center gap-3 rounded-lg border border-border-seam bg-bg-surface p-3",
88
+ children: [/* @__PURE__ */ h("div", {
89
+ className: "flex h-14 w-14 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-bg-sunken",
90
+ children: R ? /* @__PURE__ */ h("img", {
91
+ src: R,
92
+ alt: "",
93
+ className: "h-full w-full object-cover"
94
+ }) : /* @__PURE__ */ h(f, { className: "h-5 w-5 animate-spin text-text-secondary" })
95
+ }), /* @__PURE__ */ g("div", {
96
+ className: "min-w-0 flex-1",
97
+ children: [
98
+ /* @__PURE__ */ h("p", {
99
+ className: "truncate text-sm font-medium text-text-primary",
100
+ children: I ?? "Uploading…"
101
+ }),
102
+ /* @__PURE__ */ h("div", {
103
+ className: "mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-bg-sunken",
104
+ children: /* @__PURE__ */ h("div", {
105
+ className: "h-full rounded-full bg-accent-primary transition-[width] duration-200",
106
+ style: { width: `${$}%` }
107
+ })
108
+ }),
109
+ /* @__PURE__ */ g("p", {
110
+ className: "mt-1 text-xs text-text-secondary tabular-nums",
111
+ children: [
112
+ $,
113
+ "%",
114
+ P ? ` · ${_(P.loaded)} of ${_(P.total)}` : ""
115
+ ]
116
+ })
117
+ ]
118
+ })]
119
+ }) : q ? /* @__PURE__ */ g("div", {
120
+ className: "relative overflow-hidden rounded-lg border border-border-seam bg-bg-sunken",
121
+ children: [/* @__PURE__ */ h("img", {
122
+ src: q,
72
123
  alt: "",
73
- className: "h-full w-full object-cover"
74
- }) : /* @__PURE__ */ p(u, { className: "h-5 w-5 animate-spin text-text-secondary" })
75
- }), /* @__PURE__ */ m("div", {
76
- className: "min-w-0 flex-1",
124
+ className: i("w-full object-cover", D === "wide" ? "aspect-video" : "aspect-square max-h-64")
125
+ }), /* @__PURE__ */ g("div", {
126
+ className: "absolute inset-x-0 bottom-0 flex justify-end gap-2 bg-gradient-to-t from-bg-canvas/85 to-transparent p-2",
127
+ children: [/* @__PURE__ */ g("button", {
128
+ type: "button",
129
+ disabled: J,
130
+ onClick: () => A.current?.click(),
131
+ className: "inline-flex items-center gap-1.5 rounded-lg bg-bg-surface/90 px-3 py-1.5 text-sm font-medium text-text-primary shadow-sm backdrop-blur transition-colors hover:bg-bg-surface disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]",
132
+ children: [/* @__PURE__ */ h(d, { className: "h-4 w-4" }), " Replace"]
133
+ }), /* @__PURE__ */ g("button", {
134
+ type: "button",
135
+ disabled: T,
136
+ onClick: () => b(""),
137
+ className: "inline-flex items-center gap-1 rounded-lg bg-bg-surface/90 px-3 py-1.5 text-sm text-text-secondary shadow-sm backdrop-blur transition-colors hover:bg-status-error-bg-subtle hover:text-status-error-text disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]",
138
+ children: [/* @__PURE__ */ h(m, { className: "h-4 w-4" }), " Remove"]
139
+ })]
140
+ })]
141
+ }) : /* @__PURE__ */ g("button", {
142
+ type: "button",
143
+ disabled: J,
144
+ onClick: () => A.current?.click(),
145
+ className: i("flex min-h-40 w-full flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed p-6 text-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] disabled:opacity-50", B ? "border-accent-primary bg-[var(--color-accent-soft)]" : "border-border-seam hover:border-accent-primary/60 hover:bg-bg-sunken"),
77
146
  children: [
78
- /* @__PURE__ */ p("p", {
79
- className: "truncate text-sm font-medium text-text-primary",
80
- children: N ?? "Uploading…"
147
+ /* @__PURE__ */ h(p, {
148
+ className: "h-8 w-8 text-text-secondary",
149
+ "aria-hidden": "true"
81
150
  }),
82
- /* @__PURE__ */ p("div", {
83
- className: "mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-bg-sunken",
84
- children: /* @__PURE__ */ p("div", {
85
- className: "h-full rounded-full bg-accent-primary transition-[width] duration-200",
86
- style: { width: `${J}%` }
87
- })
151
+ /* @__PURE__ */ h("span", {
152
+ className: "text-sm font-medium text-text-primary",
153
+ children: "Drag & drop an image here, or click to browse"
88
154
  }),
89
- /* @__PURE__ */ m("p", {
90
- className: "mt-1 text-xs text-text-secondary tabular-nums",
91
- children: [
92
- J,
93
- "%",
94
- j ? ` · ${g(j.loaded)} of ${g(j.total)}` : ""
95
- ]
155
+ /* @__PURE__ */ h("span", {
156
+ className: "text-xs text-text-secondary",
157
+ children: "JPG · PNG · up to 10 MB"
96
158
  })
97
159
  ]
98
- })]
99
- }) : V ? /* @__PURE__ */ m("div", {
100
- className: "relative overflow-hidden rounded-lg border border-border-seam bg-bg-sunken",
101
- children: [/* @__PURE__ */ p("img", {
102
- src: V,
103
- alt: "",
104
- className: i("w-full object-cover", T === "wide" ? "aspect-video" : "aspect-square max-h-64")
105
- }), /* @__PURE__ */ m("div", {
106
- className: "absolute inset-x-0 bottom-0 flex justify-end gap-2 bg-gradient-to-t from-bg-canvas/85 to-transparent p-2",
107
- children: [/* @__PURE__ */ m("button", {
108
- type: "button",
109
- disabled: H,
110
- onClick: () => D.current?.click(),
111
- className: "inline-flex items-center gap-1.5 rounded-lg bg-bg-surface/90 px-3 py-1.5 text-sm font-medium text-text-primary shadow-sm backdrop-blur transition-colors hover:bg-bg-surface disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]",
112
- children: [/* @__PURE__ */ p(l, { className: "h-4 w-4" }), " Replace"]
113
- }), /* @__PURE__ */ m("button", {
114
- type: "button",
115
- disabled: C,
116
- onClick: () => y(""),
117
- className: "inline-flex items-center gap-1 rounded-lg bg-bg-surface/90 px-3 py-1.5 text-sm text-text-secondary shadow-sm backdrop-blur transition-colors hover:bg-status-error-bg-subtle hover:text-status-error-text disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]",
118
- children: [/* @__PURE__ */ p(f, { className: "h-4 w-4" }), " Remove"]
119
- })]
120
- })]
121
- }) : /* @__PURE__ */ m("button", {
122
- type: "button",
123
- disabled: H,
124
- onClick: () => D.current?.click(),
125
- className: i("flex min-h-40 w-full flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed p-6 text-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] disabled:opacity-50", L ? "border-accent-primary bg-[var(--color-accent-soft)]" : "border-border-seam hover:border-accent-primary/60 hover:bg-bg-sunken"),
126
- children: [
127
- /* @__PURE__ */ p(d, {
128
- className: "h-8 w-8 text-text-secondary",
129
- "aria-hidden": "true"
130
- }),
131
- /* @__PURE__ */ p("span", {
132
- className: "text-sm font-medium text-text-primary",
133
- children: "Drag & drop an image here, or click to browse"
134
- }),
135
- /* @__PURE__ */ p("span", {
136
- className: "text-xs text-text-secondary",
137
- children: "JPG · PNG · up to 10 MB"
138
- })
139
- ]
160
+ })
161
+ }),
162
+ /* @__PURE__ */ h("input", {
163
+ ref: A,
164
+ id: j,
165
+ type: "file",
166
+ accept: w,
167
+ disabled: J,
168
+ className: "sr-only",
169
+ "aria-label": v,
170
+ onChange: X
140
171
  })
141
- }), /* @__PURE__ */ p("input", {
142
- ref: D,
143
- id: O,
144
- type: "file",
145
- accept: S,
146
- className: "sr-only",
147
- "aria-label": _,
148
- onChange: W
149
- })]
172
+ ]
150
173
  });
151
174
  };
152
- export { _ as ImageUploadField };
175
+ export { v as ImageUploadField };
@@ -0,0 +1,2 @@
1
+ export type UploadVisibility = 'PRIVATE' | 'WORKSPACE';
2
+ export declare function uploadVisibility(value?: unknown): UploadVisibility;
@@ -0,0 +1,6 @@
1
+ // src/coolandlovely/hooks/uploadVisibility.ts
2
+ function e(e = "PRIVATE") {
3
+ if (e !== "PRIVATE" && e !== "WORKSPACE") throw Error("Upload visibility must be PRIVATE or WORKSPACE");
4
+ return e;
5
+ }
6
+ export { e as uploadVisibility };
@@ -25,7 +25,7 @@ async function f(e, t, n, i) {
25
25
  let o = await a.blob();
26
26
  if (!o.type.startsWith("image/") || o.size === 0 || o.size > c) return null;
27
27
  let s = new File([o], d(e, t, o.type), { type: o.type });
28
- return (await r(s, i, n)).id;
28
+ return (await r(s, i, n, "PRIVATE")).id;
29
29
  } catch {
30
30
  return null;
31
31
  }
@@ -1,26 +1,4 @@
1
- /**
2
- * File hooks — image upload + display via wspace-files-svc (NO duplication).
3
- * @module coolandlovely/hooks
4
- *
5
- * CoolAndLovely never stores blobs. Brand logos/covers, collection covers,
6
- * style-item photos, look photos, wardrobe photos and lookbook covers are
7
- * wspace-files `File` records referenced by id (the coo* inputs take *FileId;
8
- * the coo* types expose logo/cover/image: File resolved via federation).
9
- *
10
- * Upload uses the SAME graphqlFetch transport as every other coo* call — NOT
11
- * Apollo — driving the wspace-files 3-step presigned flow directly:
12
- * ensureFolderByPath -> initiateUpload -> HTTP PUT -> completeUpload
13
- * Display resolves a File id to a short-lived presigned URL via
14
- * getFileDownloadUrl.
15
- *
16
- * Two fleet gotchas are handled here:
17
- * (a) `fileSize` is REQUIRED on completeUpload even though this MFE's generated
18
- * `CompleteUploadInput` is stale and omits it. Because we send a hand-written
19
- * query with `Record<string, unknown>` variables (not typed against the
20
- * generated input) we simply include it and it works at runtime.
21
- * (b) `getFileDownloadUrl(expiresIn)` must be <= 604800 (S3 7-day cap → 500).
22
- * We use 21600 (6h); do NOT raise it.
23
- */
1
+ import { UploadVisibility } from './uploadVisibility';
24
2
  /** Per-entity folders in wspace-files. */
25
3
  export declare const COO_FILE_FOLDERS: {
26
4
  readonly brands: "/CoolAndLovely/Brands";
@@ -50,12 +28,12 @@ export interface UploadProgress {
50
28
  * caller persists `id` (e.g. cooUpdateBrand({ logoFileId })); `url` is for an
51
29
  * immediate preview. `baseUrl` is the shell's apiGatewayUrl.
52
30
  */
53
- export declare function uploadImageToFiles(file: File, baseUrl?: string, folderPath?: string): Promise<UploadedImage>;
31
+ export declare function uploadImageToFiles(file: File, baseUrl?: string, folderPath?: string, visibility?: UploadVisibility): Promise<UploadedImage>;
54
32
  /**
55
33
  * Same as {@link uploadImageToFiles} but reports transfer progress via
56
34
  * `onProgress` (XHR `upload.onprogress`) so callers can render a live progress
57
35
  * bar. `baseUrl` is the shell's apiGatewayUrl.
58
36
  */
59
- export declare function uploadImageToFilesWithProgress(file: File, baseUrl?: string, folderPath?: string, onProgress?: (progress: UploadProgress) => void): Promise<UploadedImage>;
37
+ export declare function uploadImageToFilesWithProgress(file: File, baseUrl?: string, folderPath?: string, onProgress?: (progress: UploadProgress) => void, visibility?: UploadVisibility): Promise<UploadedImage>;
60
38
  /** Resolve a wspace-files File id to a presigned URL for display. */
61
39
  export declare function useFileUrl(fileId?: string | null): import('@tanstack/react-query').UseQueryResult<string | null, Error>;
@@ -1,10 +1,11 @@
1
1
  import { useCoolAndLovely as e } from "../context/CoolAndLovelyContext.js";
2
2
  import "../context/index.js";
3
- import { useQuery as t } from "@tanstack/react-query";
4
- import { graphqlFetch as n } from "@burdenoff/fe-libs/shared/graphql";
5
- import { clearGraphqlFetchResponseCache as r } from "@burdenoff/fe-libs/shared/graphql/fetch";
3
+ import { uploadVisibility as t } from "./uploadVisibility.js";
4
+ import { useQuery as n } from "@tanstack/react-query";
5
+ import { graphqlFetch as r } from "@burdenoff/fe-libs/shared/graphql";
6
+ import { clearGraphqlFetchResponseCache as i } from "@burdenoff/fe-libs/shared/graphql/fetch";
6
7
  // src/coolandlovely/hooks/useFiles.ts
7
- var i = 21600, a = {
8
+ var a = 21600, o = {
8
9
  brands: "/CoolAndLovely/Brands",
9
10
  collections: "/CoolAndLovely/Collections",
10
11
  items: "/CoolAndLovely/Items",
@@ -12,24 +13,24 @@ var i = 21600, a = {
12
13
  wardrobe: "/CoolAndLovely/Wardrobe",
13
14
  lookbooks: "/CoolAndLovely/Lookbooks"
14
15
  };
15
- async function o(e, t, i) {
16
- let a = await n({
16
+ async function s(e, t, n) {
17
+ let a = await r({
17
18
  gateway: "workspace",
18
- baseUrl: i,
19
+ baseUrl: n,
19
20
  query: e,
20
21
  variables: t,
21
22
  workspaceToken: !0
22
23
  });
23
24
  if (a.errors?.length) throw Error(a.errors[0]?.message ?? "Files request failed");
24
25
  if (!a.data) throw Error("Files response did not include data");
25
- return /^\s*mutation\b/.test(e) && r(), a.data;
26
+ return /^\s*mutation\b/.test(e) && i(), a.data;
26
27
  }
27
- var s = "\n mutation CooEnsureFolder($path: String!) {\n ensureFolderByPath(path: $path) { id }\n }\n", c = "\n mutation CooInitiateUpload($input: InitiateUploadInput!) {\n initiateUpload(input: $input) {\n uploadUrl\n session { id }\n }\n }\n", l = "\n mutation CooCompleteUpload($input: CompleteUploadInput!) {\n completeUpload(input: $input) {\n fileId\n file { id name }\n }\n }\n", u = "\n query CooGetFileDownloadUrl($id: ID!, $expiresIn: Int) {\n getFileDownloadUrl(id: $id, expiresIn: $expiresIn)\n }\n";
28
- function d(e, t) {
28
+ var c = "\n mutation CooEnsureFolder($path: String!) {\n ensureFolderByPath(path: $path) { id }\n }\n", l = "\n mutation CooInitiateUpload($input: InitiateUploadInput!) {\n initiateUpload(input: $input) {\n uploadUrl\n session { id }\n }\n }\n", u = "\n mutation CooCompleteUpload($input: CompleteUploadInput!) {\n completeUpload(input: $input) {\n fileId\n file { id name }\n }\n }\n", d = "\n query CooGetFileDownloadUrl($id: ID!, $expiresIn: Int) {\n getFileDownloadUrl(id: $id, expiresIn: $expiresIn)\n }\n";
29
+ function f(e, t) {
29
30
  let n = e.lastIndexOf(".");
30
31
  return n > -1 && n < e.length - 1 ? e.slice(n + 1).toLowerCase() : (t.split("/")[1] ?? "bin").toLowerCase();
31
32
  }
32
- function f(e, t, n, r) {
33
+ function p(e, t, n, r) {
33
34
  return new Promise((i, a) => {
34
35
  let o = new XMLHttpRequest();
35
36
  o.open("PUT", e, !0), o.setRequestHeader("Content-Type", n), r && (o.upload.onprogress = (e) => {
@@ -48,64 +49,65 @@ function f(e, t, n, r) {
48
49
  }, o.onerror = () => a(/* @__PURE__ */ Error("Upload to storage failed — a network error occurred.")), o.onabort = () => a(/* @__PURE__ */ Error("Upload was cancelled.")), o.send(t);
49
50
  });
50
51
  }
51
- async function p(e, t, n = a.items, r) {
52
- let p = e.type || "application/octet-stream", m = String(e.size), h;
52
+ async function m(e, n, r = o.items, i, m) {
53
+ let h = t(m), g = e.type || "application/octet-stream", _ = String(e.size), v;
53
54
  try {
54
- h = (await o(s, { path: n }, t)).ensureFolderByPath?.id ?? void 0;
55
+ v = (await s(c, { path: r }, n)).ensureFolderByPath?.id ?? void 0;
55
56
  } catch {
56
- h = void 0;
57
+ v = void 0;
57
58
  }
58
- let g = await o(c, { input: {
59
+ let y = await s(l, { input: {
59
60
  fileName: e.name,
60
- extension: d(e.name, p),
61
- fileSize: m,
62
- mimeType: p,
63
- ...h ? { folderId: h } : {}
64
- } }, t), _ = g.initiateUpload?.uploadUrl, v = g.initiateUpload?.session.id;
65
- if (!_ || !v) throw Error("The files service did not return an upload URL.");
66
- await f(_, e, p, r);
67
- let y = await o(l, { input: {
68
- sessionId: v,
69
- fileSize: m,
70
- ...h ? { folderId: h } : {}
71
- } }, t), b = y.completeUpload?.file, x = y.completeUpload?.fileId ?? b?.id;
72
- if (!x) throw Error("The upload could not be finalized.");
73
- let S = "";
61
+ extension: f(e.name, g),
62
+ fileSize: _,
63
+ mimeType: g,
64
+ visibility: h,
65
+ ...v ? { folderId: v } : {}
66
+ } }, n), b = y.initiateUpload?.uploadUrl, x = y.initiateUpload?.session.id;
67
+ if (!b || !x) throw Error("The files service did not return an upload URL.");
68
+ await p(b, e, g, i);
69
+ let S = await s(u, { input: {
70
+ sessionId: x,
71
+ fileSize: _,
72
+ ...v ? { folderId: v } : {}
73
+ } }, n), C = S.completeUpload?.file, w = S.completeUpload?.fileId ?? C?.id;
74
+ if (!w) throw Error("The upload could not be finalized.");
75
+ let T = "";
74
76
  try {
75
- S = (await o(u, {
76
- id: x,
77
- expiresIn: i
78
- }, t)).getFileDownloadUrl ?? "";
77
+ T = (await s(d, {
78
+ id: w,
79
+ expiresIn: a
80
+ }, n)).getFileDownloadUrl ?? "";
79
81
  } catch {
80
- S = "";
82
+ T = "";
81
83
  }
82
84
  return {
83
- id: x,
84
- url: S,
85
- name: b?.name ?? e.name
85
+ id: w,
86
+ url: T,
87
+ name: C?.name ?? e.name
86
88
  };
87
89
  }
88
- async function m(e, t, n = a.items) {
89
- return p(e, t, n);
90
+ async function h(e, t, n = o.items, r) {
91
+ return m(e, t, n, void 0, r);
90
92
  }
91
- async function h(e, t, n = a.items, r) {
92
- return p(e, t, n, r);
93
+ async function g(e, t, n = o.items, r, i) {
94
+ return m(e, t, n, r, i);
93
95
  }
94
- function g(n) {
96
+ function _(t) {
95
97
  let { apiGatewayUrl: r } = e();
96
- return t({
98
+ return n({
97
99
  queryKey: [
98
100
  "coolandlovely",
99
101
  "file-url",
100
- n ?? ""
102
+ t ?? ""
101
103
  ],
102
- enabled: !!n,
104
+ enabled: !!t,
103
105
  staleTime: 12e5,
104
106
  retry: 1,
105
- queryFn: async () => (await o(u, {
106
- id: n,
107
- expiresIn: i
107
+ queryFn: async () => (await s(d, {
108
+ id: t,
109
+ expiresIn: a
108
110
  }, r)).getFileDownloadUrl ?? null
109
111
  });
110
112
  }
111
- export { a as COO_FILE_FOLDERS, m as uploadImageToFiles, h as uploadImageToFilesWithProgress, g as useFileUrl };
113
+ export { o as COO_FILE_FOLDERS, h as uploadImageToFiles, g as uploadImageToFilesWithProgress, _ as useFileUrl };
@@ -181,12 +181,14 @@ function C() {
181
181
  /* @__PURE__ */ b("div", {
182
182
  className: "mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2",
183
183
  children: [/* @__PURE__ */ y(l, {
184
+ allowWorkspace: !0,
184
185
  label: "Logo",
185
186
  value: k.logoFileId,
186
187
  onChange: (e) => N("logoFileId", e),
187
188
  folder: d.brands,
188
189
  hint: "Square storefront logo"
189
190
  }), /* @__PURE__ */ y(l, {
191
+ allowWorkspace: !0,
190
192
  label: "Cover",
191
193
  aspect: "wide",
192
194
  value: k.coverFileId,
@@ -200,6 +200,7 @@ function j() {
200
200
  className: "mt-4"
201
201
  }),
202
202
  /* @__PURE__ */ w(u, {
203
+ allowWorkspace: !0,
203
204
  label: "Cover image",
204
205
  aspect: "wide",
205
206
  value: z.coverFileId,
@@ -213,6 +213,7 @@ function M() {
213
213
  className: "mt-4"
214
214
  }),
215
215
  /* @__PURE__ */ D(d, {
216
+ allowWorkspace: !0,
216
217
  label: "Product photo",
217
218
  value: B.imageFileId,
218
219
  onChange: (e) => G("imageFileId", e),
@@ -92,6 +92,7 @@ function E() {
92
92
  className: "mt-4"
93
93
  }),
94
94
  /* @__PURE__ */ S(d, {
95
+ allowWorkspace: !0,
95
96
  label: D("coolandlovely.field.coverImage", "Cover image"),
96
97
  aspect: "wide",
97
98
  value: B,
@@ -128,6 +128,7 @@ function x() {
128
128
  className: "mt-4"
129
129
  }),
130
130
  /* @__PURE__ */ g(ee, {
131
+ allowWorkspace: !0,
131
132
  label: "Look photo",
132
133
  aspect: "wide",
133
134
  value: L,
@@ -213,6 +213,7 @@ function w() {
213
213
  className: "mt-4"
214
214
  }),
215
215
  /* @__PURE__ */ y(i, {
216
+ allowWorkspace: !1,
216
217
  label: "Photo",
217
218
  value: D.imageFileId,
218
219
  onChange: (e) => N("imageFileId", e),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-coolandlovely",
3
- "version": "2026.1110.2",
3
+ "version": "2026.1112.1",
4
4
  "description": "Burdenoff CoolAndLovely Microfrontend",
5
5
  "type": "module",
6
6
  "files": [