@fluid-app/portal-sdk 0.1.184 → 0.1.185
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/{PortalContentApiProvider-eSOgc4Nv.cjs → PortalContentApiProvider-C2G-u4O2.cjs} +99 -89
- package/dist/PortalContentApiProvider-C2G-u4O2.cjs.map +1 -0
- package/dist/{PortalContentApiProvider-C5BcaBSL.mjs → PortalContentApiProvider-Cei2eKh_.mjs} +94 -90
- package/dist/PortalContentApiProvider-Cei2eKh_.mjs.map +1 -0
- package/dist/{ProductsScreen-C2mx-086.cjs → ProductsScreen-BJBagajA.cjs} +2 -2
- package/dist/{ProductsScreen-CIT--Mnq.mjs → ProductsScreen-BNpjtlYx.mjs} +2 -2
- package/dist/{ProductsScreen-P4n3OFln.mjs → ProductsScreen-Ba2wcgYy.mjs} +2 -2
- package/dist/{ProductsScreen-P4n3OFln.mjs.map → ProductsScreen-Ba2wcgYy.mjs.map} +1 -1
- package/dist/{ProductsScreen-CJPwyXvT.cjs → ProductsScreen-ClOJgwBf.cjs} +2 -2
- package/dist/{ProductsScreen-CJPwyXvT.cjs.map → ProductsScreen-ClOJgwBf.cjs.map} +1 -1
- package/dist/{ShareablesScreen-C_KC7Ey1.cjs → ShareablesScreen-9j2YlYM5.cjs} +2 -2
- package/dist/{ShareablesScreen-CBrJ8Vzm.cjs → ShareablesScreen-CkaXzERa.cjs} +5 -4
- package/dist/ShareablesScreen-CkaXzERa.cjs.map +1 -0
- package/dist/{ShareablesScreen-BII-fIRD.mjs → ShareablesScreen-lLzBYQ9u.mjs} +5 -4
- package/dist/ShareablesScreen-lLzBYQ9u.mjs.map +1 -0
- package/dist/{ShareablesScreen-BLNcb2M-.mjs → ShareablesScreen-yYzOCGaX.mjs} +2 -2
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -7
- package/package.json +10 -10
- package/dist/PortalContentApiProvider-C5BcaBSL.mjs.map +0 -1
- package/dist/PortalContentApiProvider-eSOgc4Nv.cjs.map +0 -1
- package/dist/ShareablesScreen-BII-fIRD.mjs.map +0 -1
- package/dist/ShareablesScreen-CBrJ8Vzm.cjs.map +0 -1
|
@@ -7,9 +7,9 @@ require("./dist-BRT-FAUb.cjs");
|
|
|
7
7
|
require("./es-Dr47illR.cjs");
|
|
8
8
|
require("./SearchSort-BgHSdG1l.cjs");
|
|
9
9
|
require("./dist-DbiSKQz4.cjs");
|
|
10
|
-
require("./PortalContentApiProvider-
|
|
10
|
+
require("./PortalContentApiProvider-C2G-u4O2.cjs");
|
|
11
11
|
require("./dist-DWs3-WOI.cjs");
|
|
12
12
|
require("./PortalProductsApiProvider-Duj-EjQj.cjs");
|
|
13
|
-
const require_ProductsScreen = require("./ProductsScreen-
|
|
13
|
+
const require_ProductsScreen = require("./ProductsScreen-ClOJgwBf.cjs");
|
|
14
14
|
exports.ProductsScreen = require_ProductsScreen.ProductsScreen;
|
|
15
15
|
exports.productsScreenPropertySchema = require_ProductsScreen.productsScreenPropertySchema;
|
|
@@ -6,8 +6,8 @@ import "./ScreenHeaderContext-FYyYk97y.mjs";
|
|
|
6
6
|
import "./dist-BETEuYfn.mjs";
|
|
7
7
|
import "./SearchSort-CFbJNJDL.mjs";
|
|
8
8
|
import "./dist-DiBoTZfl.mjs";
|
|
9
|
-
import "./PortalContentApiProvider-
|
|
9
|
+
import "./PortalContentApiProvider-Cei2eKh_.mjs";
|
|
10
10
|
import "./sortable.esm-CJLSD-Ce.mjs";
|
|
11
11
|
import "./PortalProductsApiProvider-BALswRao.mjs";
|
|
12
|
-
import { n as productsScreenPropertySchema, t as ProductsScreen } from "./ProductsScreen-
|
|
12
|
+
import { n as productsScreenPropertySchema, t as ProductsScreen } from "./ProductsScreen-Ba2wcgYy.mjs";
|
|
13
13
|
export { ProductsScreen, productsScreenPropertySchema };
|
|
@@ -2,7 +2,7 @@ import { _ as fluidToast } from "./src-BZbWkXOU.mjs";
|
|
|
2
2
|
import { t as useAccount } from "./use-account-B16Tor2Q.mjs";
|
|
3
3
|
import { t as useStore } from "./use-store-BnHhQDYo.mjs";
|
|
4
4
|
import { n as useAppNavigation } from "./AppNavigationContext-BW3lSpfT.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { c as ShareablesCoreProvider, i as ProductsApp, n as usePortalContentContext, s as ShareablesUIProvider, t as PortalContentApiProvider } from "./PortalContentApiProvider-Cei2eKh_.mjs";
|
|
6
6
|
import { t as PortalProductsApiProvider } from "./PortalProductsApiProvider-BALswRao.mjs";
|
|
7
7
|
import { useCallback, useMemo } from "react";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -87,4 +87,4 @@ const productsScreenPropertySchema = {
|
|
|
87
87
|
//#endregion
|
|
88
88
|
export { productsScreenPropertySchema as n, ProductsScreen as t };
|
|
89
89
|
|
|
90
|
-
//# sourceMappingURL=ProductsScreen-
|
|
90
|
+
//# sourceMappingURL=ProductsScreen-Ba2wcgYy.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductsScreen-
|
|
1
|
+
{"version":3,"file":"ProductsScreen-Ba2wcgYy.mjs","names":[],"sources":["../src/screens/ProductsScreen.tsx"],"sourcesContent":["import { useCallback, useMemo, type ComponentProps } from \"react\";\nimport { fluidToast } from \"@fluid-app/ui-primitives\";\nimport type {\n BackgroundValue,\n BorderRadiusOptions,\n ColorOptions,\n PaddingOptions,\n} from \"../types\";\nimport type { WidgetPropertySchema } from \"../registries/property-schema-types\";\nimport { ShareablesCoreProvider } from \"@fluid-app/shareables-core\";\nimport { ShareablesUIProvider, ProductsApp } from \"@fluid-app/shareables-ui\";\nimport { useAppNavigation } from \"../shell/AppNavigationContext\";\nimport { useAccount } from \"../hooks/use-account\";\nimport { useStore } from \"../hooks/use-store\";\nimport { PortalProductsApiProvider } from \"../products/PortalProductsApiProvider\";\nimport {\n PortalContentApiProvider,\n usePortalContentContext,\n} from \"../content/PortalContentApiProvider\";\n\ntype ProductsScreenProps = ComponentProps<\"div\"> & {\n background?: BackgroundValue;\n textColor?: ColorOptions;\n accentColor?: ColorOptions;\n padding?: PaddingOptions;\n borderRadius?: BorderRadiusOptions;\n};\n\nexport function ProductsScreen({\n /* eslint-disable @typescript-eslint/no-unused-vars -- destructured to exclude from divProps spread */\n background,\n textColor,\n accentColor,\n padding,\n borderRadius,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ...divProps\n}: ProductsScreenProps): React.JSX.Element {\n return (\n <div {...divProps} className={`h-full ${divProps.className ?? \"\"}`}>\n <PortalProductsApiProvider>\n <PortalContentApiProvider>\n <ProductsScreenContent />\n </PortalContentApiProvider>\n </PortalProductsApiProvider>\n </div>\n );\n}\n\n/** Inner component rendered inside providers so hooks can access context. */\nfunction ProductsScreenContent(): React.JSX.Element {\n const { productsApi: portalProductsApi } = usePortalContentContext();\n const { data: account } = useAccount();\n const { data: store } = useStore();\n const { currentSlug, navigate } = useAppNavigation();\n\n const fetchProducts = useCallback(\n async (search: string, cursor?: string, limit?: number) => {\n if (search) {\n return portalProductsApi.searchProducts(search, { cursor, limit });\n }\n return portalProductsApi.listProducts({ cursor, limit });\n },\n [portalProductsApi],\n );\n\n const fetchProduct = useCallback(\n async (id: string | number) => portalProductsApi.getProduct(id),\n [portalProductsApi],\n );\n\n // Extract product ID from slug: \"products/123\" → \"123\"\n const productId = useMemo(() => {\n const match = currentSlug.match(/^products\\/(.+)/);\n return match?.[1] ?? null;\n }, [currentSlug]);\n\n const handleSelectProduct = useCallback(\n (id: string) => {\n navigate(`products/${id}`);\n },\n [navigate],\n );\n\n const handleBack = useCallback(() => {\n navigate(\"products\");\n }, [navigate]);\n\n const coreConfig = useMemo(\n () => ({\n user: account ? { id: account.id } : null,\n repContext: true,\n }),\n [account],\n );\n\n const uiConfig = useMemo(\n () => ({\n user: account\n ? {\n id: account.id,\n company: { logo_url: store?.logo_url ?? null },\n }\n : undefined,\n basePath: \"\",\n navigate: (path: string) => {\n navigate(path);\n },\n showToast: (opts: {\n title: string;\n type: \"success\" | \"error\" | \"warning\";\n }) => {\n fluidToast(opts);\n },\n }),\n [account, store, navigate],\n );\n\n return (\n <ShareablesCoreProvider config={coreConfig}>\n <ShareablesUIProvider config={uiConfig}>\n <ProductsApp\n countryCode={undefined}\n companyLogoUrl={store?.logo_url ?? undefined}\n fetchProducts={fetchProducts}\n fetchProduct={fetchProduct}\n productId={productId}\n onSelectProduct={handleSelectProduct}\n onBack={handleBack}\n />\n </ShareablesUIProvider>\n </ShareablesCoreProvider>\n );\n}\n\nexport const productsScreenPropertySchema: WidgetPropertySchema = {\n widgetType: \"ProductsScreen\",\n displayName: \"Products Screen\",\n tabsConfig: [{ id: \"styling\", label: \"Styling\" }],\n fields: [],\n} as const satisfies WidgetPropertySchema;\n"],"mappings":";;;;;;;;;AA4BA,SAAgB,eAAe,EAE7B,YACA,WACA,aACA,SACA,cAEA,GAAG,YACsC;AACzC,QACE,oBAAC,OAAD;EAAK,GAAI;EAAU,WAAW,UAAU,SAAS,aAAa;YAC5D,oBAAC,2BAAD,EAAA,UACE,oBAAC,0BAAD,EAAA,UACE,oBAAC,uBAAD,EAAyB,CAAA,EACA,CAAA,EACD,CAAA;EACxB,CAAA;;;AAKV,SAAS,wBAA2C;CAClD,MAAM,EAAE,aAAa,sBAAsB,yBAAyB;CACpE,MAAM,EAAE,MAAM,YAAY,YAAY;CACtC,MAAM,EAAE,MAAM,UAAU,UAAU;CAClC,MAAM,EAAE,aAAa,aAAa,kBAAkB;CAEpD,MAAM,gBAAgB,YACpB,OAAO,QAAgB,QAAiB,UAAmB;AACzD,MAAI,OACF,QAAO,kBAAkB,eAAe,QAAQ;GAAE;GAAQ;GAAO,CAAC;AAEpE,SAAO,kBAAkB,aAAa;GAAE;GAAQ;GAAO,CAAC;IAE1D,CAAC,kBAAkB,CACpB;CAED,MAAM,eAAe,YACnB,OAAO,OAAwB,kBAAkB,WAAW,GAAG,EAC/D,CAAC,kBAAkB,CACpB;CAGD,MAAM,YAAY,cAAc;AAE9B,SADc,YAAY,MAAM,kBAAkB,GACnC,MAAM;IACpB,CAAC,YAAY,CAAC;CAEjB,MAAM,sBAAsB,aACzB,OAAe;AACd,WAAS,YAAY,KAAK;IAE5B,CAAC,SAAS,CACX;CAED,MAAM,aAAa,kBAAkB;AACnC,WAAS,WAAW;IACnB,CAAC,SAAS,CAAC;AAgCd,QACE,oBAAC,wBAAD;EAAwB,QA/BP,eACV;GACL,MAAM,UAAU,EAAE,IAAI,QAAQ,IAAI,GAAG;GACrC,YAAY;GACb,GACD,CAAC,QAAQ,CACV;YA0BG,oBAAC,sBAAD;GAAsB,QAxBT,eACR;IACL,MAAM,UACF;KACE,IAAI,QAAQ;KACZ,SAAS,EAAE,UAAU,OAAO,YAAY,MAAM;KAC/C,GACD,KAAA;IACJ,UAAU;IACV,WAAW,SAAiB;AAC1B,cAAS,KAAK;;IAEhB,YAAY,SAGN;AACJ,gBAAW,KAAK;;IAEnB,GACD;IAAC;IAAS;IAAO;IAAS,CAC3B;aAKK,oBAAC,aAAD;IACE,aAAa,KAAA;IACb,gBAAgB,OAAO,YAAY,KAAA;IACpB;IACD;IACH;IACX,iBAAiB;IACjB,QAAQ;IACR,CAAA;GACmB,CAAA;EACA,CAAA;;AAI7B,MAAa,+BAAqD;CAChE,YAAY;CACZ,aAAa;CACb,YAAY,CAAC;EAAE,IAAI;EAAW,OAAO;EAAW,CAAC;CACjD,QAAQ,EAAE;CACX"}
|
|
@@ -3,7 +3,7 @@ const require_src = require("./src-CvtwdzKm.cjs");
|
|
|
3
3
|
const require_use_account = require("./use-account-BWdcuCCW.cjs");
|
|
4
4
|
const require_use_store = require("./use-store-DvtLtZ3f.cjs");
|
|
5
5
|
const require_AppNavigationContext = require("./AppNavigationContext-BKszSW5R.cjs");
|
|
6
|
-
const require_PortalContentApiProvider = require("./PortalContentApiProvider-
|
|
6
|
+
const require_PortalContentApiProvider = require("./PortalContentApiProvider-C2G-u4O2.cjs");
|
|
7
7
|
const require_PortalProductsApiProvider = require("./PortalProductsApiProvider-Duj-EjQj.cjs");
|
|
8
8
|
let react = require("react");
|
|
9
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -99,4 +99,4 @@ Object.defineProperty(exports, "productsScreenPropertySchema", {
|
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
//# sourceMappingURL=ProductsScreen-
|
|
102
|
+
//# sourceMappingURL=ProductsScreen-ClOJgwBf.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductsScreen-
|
|
1
|
+
{"version":3,"file":"ProductsScreen-ClOJgwBf.cjs","names":["PortalProductsApiProvider","PortalContentApiProvider","usePortalContentContext","useAccount","useStore","useAppNavigation","ShareablesCoreProvider","ShareablesUIProvider","ProductsApp"],"sources":["../src/screens/ProductsScreen.tsx"],"sourcesContent":["import { useCallback, useMemo, type ComponentProps } from \"react\";\nimport { fluidToast } from \"@fluid-app/ui-primitives\";\nimport type {\n BackgroundValue,\n BorderRadiusOptions,\n ColorOptions,\n PaddingOptions,\n} from \"../types\";\nimport type { WidgetPropertySchema } from \"../registries/property-schema-types\";\nimport { ShareablesCoreProvider } from \"@fluid-app/shareables-core\";\nimport { ShareablesUIProvider, ProductsApp } from \"@fluid-app/shareables-ui\";\nimport { useAppNavigation } from \"../shell/AppNavigationContext\";\nimport { useAccount } from \"../hooks/use-account\";\nimport { useStore } from \"../hooks/use-store\";\nimport { PortalProductsApiProvider } from \"../products/PortalProductsApiProvider\";\nimport {\n PortalContentApiProvider,\n usePortalContentContext,\n} from \"../content/PortalContentApiProvider\";\n\ntype ProductsScreenProps = ComponentProps<\"div\"> & {\n background?: BackgroundValue;\n textColor?: ColorOptions;\n accentColor?: ColorOptions;\n padding?: PaddingOptions;\n borderRadius?: BorderRadiusOptions;\n};\n\nexport function ProductsScreen({\n /* eslint-disable @typescript-eslint/no-unused-vars -- destructured to exclude from divProps spread */\n background,\n textColor,\n accentColor,\n padding,\n borderRadius,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ...divProps\n}: ProductsScreenProps): React.JSX.Element {\n return (\n <div {...divProps} className={`h-full ${divProps.className ?? \"\"}`}>\n <PortalProductsApiProvider>\n <PortalContentApiProvider>\n <ProductsScreenContent />\n </PortalContentApiProvider>\n </PortalProductsApiProvider>\n </div>\n );\n}\n\n/** Inner component rendered inside providers so hooks can access context. */\nfunction ProductsScreenContent(): React.JSX.Element {\n const { productsApi: portalProductsApi } = usePortalContentContext();\n const { data: account } = useAccount();\n const { data: store } = useStore();\n const { currentSlug, navigate } = useAppNavigation();\n\n const fetchProducts = useCallback(\n async (search: string, cursor?: string, limit?: number) => {\n if (search) {\n return portalProductsApi.searchProducts(search, { cursor, limit });\n }\n return portalProductsApi.listProducts({ cursor, limit });\n },\n [portalProductsApi],\n );\n\n const fetchProduct = useCallback(\n async (id: string | number) => portalProductsApi.getProduct(id),\n [portalProductsApi],\n );\n\n // Extract product ID from slug: \"products/123\" → \"123\"\n const productId = useMemo(() => {\n const match = currentSlug.match(/^products\\/(.+)/);\n return match?.[1] ?? null;\n }, [currentSlug]);\n\n const handleSelectProduct = useCallback(\n (id: string) => {\n navigate(`products/${id}`);\n },\n [navigate],\n );\n\n const handleBack = useCallback(() => {\n navigate(\"products\");\n }, [navigate]);\n\n const coreConfig = useMemo(\n () => ({\n user: account ? { id: account.id } : null,\n repContext: true,\n }),\n [account],\n );\n\n const uiConfig = useMemo(\n () => ({\n user: account\n ? {\n id: account.id,\n company: { logo_url: store?.logo_url ?? null },\n }\n : undefined,\n basePath: \"\",\n navigate: (path: string) => {\n navigate(path);\n },\n showToast: (opts: {\n title: string;\n type: \"success\" | \"error\" | \"warning\";\n }) => {\n fluidToast(opts);\n },\n }),\n [account, store, navigate],\n );\n\n return (\n <ShareablesCoreProvider config={coreConfig}>\n <ShareablesUIProvider config={uiConfig}>\n <ProductsApp\n countryCode={undefined}\n companyLogoUrl={store?.logo_url ?? undefined}\n fetchProducts={fetchProducts}\n fetchProduct={fetchProduct}\n productId={productId}\n onSelectProduct={handleSelectProduct}\n onBack={handleBack}\n />\n </ShareablesUIProvider>\n </ShareablesCoreProvider>\n );\n}\n\nexport const productsScreenPropertySchema: WidgetPropertySchema = {\n widgetType: \"ProductsScreen\",\n displayName: \"Products Screen\",\n tabsConfig: [{ id: \"styling\", label: \"Styling\" }],\n fields: [],\n} as const satisfies WidgetPropertySchema;\n"],"mappings":";;;;;;;;;;AA4BA,SAAgB,eAAe,EAE7B,YACA,WACA,aACA,SACA,cAEA,GAAG,YACsC;AACzC,QACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EAAK,GAAI;EAAU,WAAW,UAAU,SAAS,aAAa;YAC5D,iBAAA,GAAA,kBAAA,KAACA,kCAAAA,2BAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAACC,iCAAAA,0BAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAC,uBAAD,EAAyB,CAAA,EACA,CAAA,EACD,CAAA;EACxB,CAAA;;;AAKV,SAAS,wBAA2C;CAClD,MAAM,EAAE,aAAa,sBAAsBC,iCAAAA,yBAAyB;CACpE,MAAM,EAAE,MAAM,YAAYC,oBAAAA,YAAY;CACtC,MAAM,EAAE,MAAM,UAAUC,kBAAAA,UAAU;CAClC,MAAM,EAAE,aAAa,aAAaC,6BAAAA,kBAAkB;CAEpD,MAAM,iBAAA,GAAA,MAAA,aACJ,OAAO,QAAgB,QAAiB,UAAmB;AACzD,MAAI,OACF,QAAO,kBAAkB,eAAe,QAAQ;GAAE;GAAQ;GAAO,CAAC;AAEpE,SAAO,kBAAkB,aAAa;GAAE;GAAQ;GAAO,CAAC;IAE1D,CAAC,kBAAkB,CACpB;CAED,MAAM,gBAAA,GAAA,MAAA,aACJ,OAAO,OAAwB,kBAAkB,WAAW,GAAG,EAC/D,CAAC,kBAAkB,CACpB;CAGD,MAAM,aAAA,GAAA,MAAA,eAA0B;AAE9B,SADc,YAAY,MAAM,kBAAkB,GACnC,MAAM;IACpB,CAAC,YAAY,CAAC;CAEjB,MAAM,uBAAA,GAAA,MAAA,cACH,OAAe;AACd,WAAS,YAAY,KAAK;IAE5B,CAAC,SAAS,CACX;CAED,MAAM,cAAA,GAAA,MAAA,mBAA+B;AACnC,WAAS,WAAW;IACnB,CAAC,SAAS,CAAC;AAgCd,QACE,iBAAA,GAAA,kBAAA,KAACC,iCAAAA,wBAAD;EAAwB,SAAA,GAAA,MAAA,gBA9BjB;GACL,MAAM,UAAU,EAAE,IAAI,QAAQ,IAAI,GAAG;GACrC,YAAY;GACb,GACD,CAAC,QAAQ,CACV;YA0BG,iBAAA,GAAA,kBAAA,KAACC,iCAAAA,sBAAD;GAAsB,SAAA,GAAA,MAAA,gBAvBjB;IACL,MAAM,UACF;KACE,IAAI,QAAQ;KACZ,SAAS,EAAE,UAAU,OAAO,YAAY,MAAM;KAC/C,GACD,KAAA;IACJ,UAAU;IACV,WAAW,SAAiB;AAC1B,cAAS,KAAK;;IAEhB,YAAY,SAGN;AACJ,iBAAA,WAAW,KAAK;;IAEnB,GACD;IAAC;IAAS;IAAO;IAAS,CAC3B;aAKK,iBAAA,GAAA,kBAAA,KAACC,iCAAAA,aAAD;IACE,aAAa,KAAA;IACb,gBAAgB,OAAO,YAAY,KAAA;IACpB;IACD;IACH;IACX,iBAAiB;IACjB,QAAQ;IACR,CAAA;GACmB,CAAA;EACA,CAAA;;AAI7B,MAAa,+BAAqD;CAChE,YAAY;CACZ,aAAa;CACb,YAAY,CAAC;EAAE,IAAI;EAAW,OAAO;EAAW,CAAC;CACjD,QAAQ,EAAE;CACX"}
|
|
@@ -7,10 +7,10 @@ require("./dist-BRT-FAUb.cjs");
|
|
|
7
7
|
require("./es-Dr47illR.cjs");
|
|
8
8
|
require("./SearchSort-BgHSdG1l.cjs");
|
|
9
9
|
require("./dist-DbiSKQz4.cjs");
|
|
10
|
-
require("./PortalContentApiProvider-
|
|
10
|
+
require("./PortalContentApiProvider-C2G-u4O2.cjs");
|
|
11
11
|
require("./dist-DWs3-WOI.cjs");
|
|
12
12
|
require("./PortalProductsApiProvider-Duj-EjQj.cjs");
|
|
13
13
|
require("./use-mysite-portal-DzDYRU0u.cjs");
|
|
14
|
-
const require_ShareablesScreen = require("./ShareablesScreen-
|
|
14
|
+
const require_ShareablesScreen = require("./ShareablesScreen-CkaXzERa.cjs");
|
|
15
15
|
exports.ShareablesScreen = require_ShareablesScreen.ShareablesScreen;
|
|
16
16
|
exports.shareablesScreenPropertySchema = require_ShareablesScreen.shareablesScreenPropertySchema;
|
|
@@ -2,7 +2,7 @@ require("./chunk-9hOWP6kD.cjs");
|
|
|
2
2
|
const require_PortalTenantClientProvider = require("./PortalTenantClientProvider-CVv-4rQ9.cjs");
|
|
3
3
|
const require_use_account = require("./use-account-BWdcuCCW.cjs");
|
|
4
4
|
const require_AppNavigationContext = require("./AppNavigationContext-BKszSW5R.cjs");
|
|
5
|
-
const require_PortalContentApiProvider = require("./PortalContentApiProvider-
|
|
5
|
+
const require_PortalContentApiProvider = require("./PortalContentApiProvider-C2G-u4O2.cjs");
|
|
6
6
|
const require_PortalProductsApiProvider = require("./PortalProductsApiProvider-Duj-EjQj.cjs");
|
|
7
7
|
const require_use_mysite_portal = require("./use-mysite-portal-DzDYRU0u.cjs");
|
|
8
8
|
let react = require("react");
|
|
@@ -48,6 +48,7 @@ function ShareablesScreen({ background, textColor, accentColor, padding, borderR
|
|
|
48
48
|
function ShareablesScreenContent() {
|
|
49
49
|
const shareablesCtx = require_PortalContentApiProvider.usePortalContentContext();
|
|
50
50
|
const { productsApi: portalProductsApi } = shareablesCtx;
|
|
51
|
+
const filePickerApi = require_PortalContentApiProvider.useFilePickerApi();
|
|
51
52
|
const { data: account } = require_use_account.useAccount();
|
|
52
53
|
const { currentSlug, navigate } = require_AppNavigationContext.useAppNavigation();
|
|
53
54
|
const isCustomer = account?.member_type === "customer";
|
|
@@ -96,7 +97,7 @@ function ShareablesScreenContent() {
|
|
|
96
97
|
showToast: (opts) => {
|
|
97
98
|
console.warn(`[Shareables] ${opts.type}: ${opts.title}`);
|
|
98
99
|
},
|
|
99
|
-
filePickerApi
|
|
100
|
+
filePickerApi,
|
|
100
101
|
onToggleFavorite: async (params) => {
|
|
101
102
|
const result = await require_PortalContentApiProvider.toggleFavorite(client, params.favoriteableId, params.favoriteableType);
|
|
102
103
|
queryClient.invalidateQueries({ queryKey: require_use_mysite_portal.PORTAL_MYSITE_KEYS.favorites() });
|
|
@@ -124,7 +125,7 @@ function ShareablesScreenContent() {
|
|
|
124
125
|
}), [
|
|
125
126
|
account,
|
|
126
127
|
navigate,
|
|
127
|
-
|
|
128
|
+
filePickerApi,
|
|
128
129
|
isCustomer,
|
|
129
130
|
shareablesCtx.playlistsAdapter,
|
|
130
131
|
shareablesCtx.mediaProductsAdapter,
|
|
@@ -169,4 +170,4 @@ Object.defineProperty(exports, "shareablesScreenPropertySchema", {
|
|
|
169
170
|
}
|
|
170
171
|
});
|
|
171
172
|
|
|
172
|
-
//# sourceMappingURL=ShareablesScreen-
|
|
173
|
+
//# sourceMappingURL=ShareablesScreen-CkaXzERa.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShareablesScreen-CkaXzERa.cjs","names":["PortalProductsApiProvider","PortalContentApiProvider","usePortalContentContext","useFilePickerApi","useAccount","useAppNavigation","usePortalTenantClient","ShareablesCoreProvider","ShareablesUIProvider","toggleFavorite","PORTAL_MYSITE_KEYS","ShareablesApp"],"sources":["../src/screens/ShareablesScreen.tsx"],"sourcesContent":["import { useCallback, useMemo, type ComponentProps } from \"react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { PORTAL_MYSITE_KEYS } from \"@fluid-app/mysite-ui/portal/hooks/use-mysite-portal\";\nimport type {\n BackgroundValue,\n BorderRadiusOptions,\n ColorOptions,\n PaddingOptions,\n} from \"../types\";\nimport type { WidgetPropertySchema } from \"../registries/property-schema-types\";\nimport { ShareablesCoreProvider } from \"@fluid-app/shareables-core\";\nimport { ShareablesUIProvider, ShareablesApp } from \"@fluid-app/shareables-ui\";\nimport { useFilePickerApi } from \"@fluid-app/file-picker-core\";\nimport { useAppNavigation } from \"../shell/AppNavigationContext\";\nimport { useAccount } from \"../hooks/use-account\";\nimport { PortalProductsApiProvider } from \"../products/PortalProductsApiProvider\";\nimport {\n PortalContentApiProvider,\n usePortalContentContext,\n} from \"../content/PortalContentApiProvider\";\nimport { toggleFavorite } from \"../adapters/content-api-adapter\";\nimport { usePortalTenantClient } from \"../providers/PortalTenantClientProvider\";\n\ntype ShareablesScreenProps = ComponentProps<\"div\"> & {\n background?: BackgroundValue;\n textColor?: ColorOptions;\n accentColor?: ColorOptions;\n padding?: PaddingOptions;\n borderRadius?: BorderRadiusOptions;\n};\n\n/**\n * Parse the current shareables sub-route from the full slug.\n *\n * System nav slugs are \"share/products\", \"share/media\", \"share/playlists\".\n * Detail pages append an ID: \"share/products/123\", \"share/media/456\".\n *\n * \"share/products\" → screen=\"products\", detailId=null\n * \"share/products/123\" → screen=\"products\", detailId=\"123\"\n * \"share/media/456\" → screen=\"media\", detailId=\"456\"\n * \"share/playlists\" → screen=\"playlists\", detailId=null\n * \"share/playlists/789\" → screen=\"playlists\", detailId=\"789\"\n * \"share/files\" → screen=\"files\", detailId=null\n * \"share\" → screen=null (default to products)\n */\nfunction parseShareablesRoute(currentSlug: string): {\n screen: string | null;\n detailId: string | null;\n action: string | null;\n} {\n // Strip the \"share\" prefix\n const slugWithoutPrefix = currentSlug.replace(/^share\\/?/, \"\");\n if (!slugWithoutPrefix) {\n return { screen: null, detailId: null, action: null };\n }\n\n const parts = slugWithoutPrefix.split(\"/\");\n const screen = parts[0] || null;\n const detailId = parts[1] || null;\n const action = parts[2] || null;\n return { screen, detailId, action };\n}\n\nexport function ShareablesScreen({\n /* eslint-disable @typescript-eslint/no-unused-vars -- destructured to exclude from divProps spread */\n background,\n textColor,\n accentColor,\n padding,\n borderRadius,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ...divProps\n}: ShareablesScreenProps): React.JSX.Element {\n return (\n <div {...divProps} className={`h-full ${divProps.className ?? \"\"}`}>\n <PortalProductsApiProvider>\n <PortalContentApiProvider>\n <ShareablesScreenContent />\n </PortalContentApiProvider>\n </PortalProductsApiProvider>\n </div>\n );\n}\n\n/** Inner component rendered inside providers so hooks can access context. */\nfunction ShareablesScreenContent(): React.JSX.Element {\n const shareablesCtx = usePortalContentContext();\n const { productsApi: portalProductsApi } = shareablesCtx;\n const filePickerApi = useFilePickerApi();\n const { data: account } = useAccount();\n const { currentSlug, navigate } = useAppNavigation();\n const isCustomer = account?.member_type === \"customer\";\n const client = usePortalTenantClient();\n const queryClient = useQueryClient();\n\n const fetchProducts = useCallback(\n async (search: string, cursor?: string, limit?: number) => {\n if (search) {\n return portalProductsApi.searchProducts(search, { cursor, limit });\n }\n return portalProductsApi.listProducts({ cursor, limit });\n },\n [portalProductsApi],\n );\n\n const fetchProduct = useCallback(\n async (id: string | number) => portalProductsApi.getProduct(id),\n [portalProductsApi],\n );\n\n const { screen, detailId, action } = parseShareablesRoute(currentSlug);\n\n const handleNavigate = useCallback(\n (subScreen: string, id?: string) => {\n const path = id ? `share/${subScreen}/${id}` : `share/${subScreen}`;\n navigate(path);\n },\n [navigate],\n );\n\n const handleBack = useCallback(() => {\n if (detailId && screen) {\n navigate(`share/${screen}`);\n } else {\n navigate(\"share/products\");\n }\n }, [navigate, detailId, screen]);\n\n const coreConfig = useMemo(\n () => ({\n user: account ? { id: account.id } : null,\n repContext: true,\n }),\n [account],\n );\n\n const uiConfig = useMemo(\n () => ({\n user: account\n ? {\n id: account.id,\n company: null, // TODO(portal-tenant): company branding not available from /api/account\n }\n : undefined,\n // TODO(portal-tenant): affiliate_id not available from /api/account\n affiliateId: null,\n basePath: \"\",\n navigate: (path: string) => {\n const cleanPath = path.replace(/^\\//, \"\");\n const prefixed = cleanPath.startsWith(\"share/\")\n ? cleanPath\n : `share/${cleanPath}`;\n navigate(prefixed);\n },\n showToast: (opts: {\n title: string;\n type: \"success\" | \"error\" | \"warning\";\n }) => {\n console.warn(`[Shareables] ${opts.type}: ${opts.title}`);\n },\n filePickerApi,\n onToggleFavorite: async (params: {\n favoriteableId: number;\n favoriteableType: string;\n }) => {\n const result = await toggleFavorite(\n client,\n params.favoriteableId,\n params.favoriteableType,\n );\n void queryClient.invalidateQueries({\n queryKey: PORTAL_MYSITE_KEYS.favorites(),\n });\n return result;\n },\n onDeletePlaylist: isCustomer\n ? undefined\n : async (playlistId: number) => {\n await shareablesCtx.playlistsAdapter.deletePlaylist(playlistId);\n },\n mediaProductsApi: isCustomer\n ? undefined\n : shareablesCtx.mediaProductsAdapter,\n searchProducts: isCustomer\n ? undefined\n : async (query: string) => {\n const result = await portalProductsApi.searchProducts(query);\n return (result.products ?? []).map(\n (p: {\n id?: number;\n title?: string;\n name?: string;\n image_url?: string | null;\n price?: string | null;\n }) => ({\n id: p.id ?? 0,\n name: p.name ?? p.title ?? \"Untitled\",\n image_url: p.image_url ?? null,\n price: p.price ?? null,\n }),\n );\n },\n readOnly: isCustomer,\n uploadThumbnail: isCustomer\n ? undefined\n : async (blob: Blob, filename: string) => {\n const formData = new FormData();\n formData.append(\"asset[name]\", filename);\n formData.append(\"asset[file]\", blob, filename);\n const response = await client.requestWithFormData<{\n asset?: { default_variant_url?: string | null };\n }>(\"/api/content/dam/assets\", formData);\n return response.asset?.default_variant_url ?? \"\";\n },\n }),\n [\n account,\n navigate,\n filePickerApi,\n isCustomer,\n shareablesCtx.playlistsAdapter,\n shareablesCtx.mediaProductsAdapter,\n portalProductsApi,\n client,\n queryClient,\n ],\n );\n\n return (\n <ShareablesCoreProvider config={coreConfig}>\n <ShareablesUIProvider config={uiConfig}>\n <ShareablesApp\n screen={screen}\n detailId={detailId}\n action={action}\n companyLogoUrl={undefined}\n countryCode={undefined}\n fetchProducts={fetchProducts}\n fetchProduct={fetchProduct}\n onNavigate={handleNavigate}\n onBack={handleBack}\n />\n </ShareablesUIProvider>\n </ShareablesCoreProvider>\n );\n}\n\nexport const shareablesScreenPropertySchema: WidgetPropertySchema = {\n widgetType: \"ShareablesScreen\",\n displayName: \"Shareables Screen\",\n tabsConfig: [{ id: \"styling\", label: \"Styling\" }],\n fields: [],\n} as const satisfies WidgetPropertySchema;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAS,qBAAqB,aAI5B;CAEA,MAAM,oBAAoB,YAAY,QAAQ,aAAa,GAAG;AAC9D,KAAI,CAAC,kBACH,QAAO;EAAE,QAAQ;EAAM,UAAU;EAAM,QAAQ;EAAM;CAGvD,MAAM,QAAQ,kBAAkB,MAAM,IAAI;AAI1C,QAAO;EAAE,QAHM,MAAM,MAAM;EAGV,UAFA,MAAM,MAAM;EAEF,QADZ,MAAM,MAAM;EACQ;;AAGrC,SAAgB,iBAAiB,EAE/B,YACA,WACA,aACA,SACA,cAEA,GAAG,YACwC;AAC3C,QACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EAAK,GAAI;EAAU,WAAW,UAAU,SAAS,aAAa;YAC5D,iBAAA,GAAA,kBAAA,KAACA,kCAAAA,2BAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAACC,iCAAAA,0BAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAC,yBAAD,EAA2B,CAAA,EACF,CAAA,EACD,CAAA;EACxB,CAAA;;;AAKV,SAAS,0BAA6C;CACpD,MAAM,gBAAgBC,iCAAAA,yBAAyB;CAC/C,MAAM,EAAE,aAAa,sBAAsB;CAC3C,MAAM,gBAAgBC,iCAAAA,kBAAkB;CACxC,MAAM,EAAE,MAAM,YAAYC,oBAAAA,YAAY;CACtC,MAAM,EAAE,aAAa,aAAaC,6BAAAA,kBAAkB;CACpD,MAAM,aAAa,SAAS,gBAAgB;CAC5C,MAAM,SAASC,mCAAAA,uBAAuB;CACtC,MAAM,eAAA,GAAA,sBAAA,iBAA8B;CAEpC,MAAM,iBAAA,GAAA,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O,gBACP,OAAO,iBACR;AACI,iBAAY,kBAAkB,EACjC,UAAUC,0BAAAA,mBAAmB,WAAW,EACzC,CAAC;AACF,YAAO;;IAET,kBAAkB,aACd,KAAA,IACA,OAAO,eAAuB;AAC5B,WAAM,cAAc,iBAAiB,eAAe,WAAW;;IAErE,kBAAkB,aACd,KAAA,IACA,cAAc;IAClB,gBAAgB,aACZ,KAAA,IACA,OAAO,UAAkB;AAEvB,cADe,MAAM,kBAAkB,eAAe,MAAM,EAC7C,YAAY,EAAE,EAAE,KAC5B,OAMM;MACL,IAAI,EAAE,MAAM;MACZ,MAAM,EAAE,QAAQ,EAAE,SAAS;MAC3B,WAAW,EAAE,aAAa;MAC1B,OAAO,EAAE,SAAS;MACnB,EACF;;IAEP,UAAU;IACV,iBAAiB,aACb,KAAA,IACA,OAAO,MAAY,aAAqB;KACtC,MAAM,WAAW,IAAI,UAAU;AAC/B,cAAS,OAAO,eAAe,SAAS;AACxC,cAAS,OAAO,eAAe,MAAM,SAAS;AAI9C,aAHiB,MAAM,OAAO,oBAE3B,2BAA2B,SAAS,EACvB,OAAO,uBAAuB;;IAErD,GACD;IACE;IACA;IACA;IACA;IACA,cAAc;IACd,cAAc;IACd;IACA;IACA;IACD,CACF;aAKK,iBAAA,GAAA,kBAAA,KAACC,iCAAAA,eAAD;IACU;IACE;IACF;IACR,gBAAgB,KAAA;IAChB,aAAa,KAAA;IACE;IACD;IACd,YAAY;IACZ,QAAQ;IACR,CAAA;GACmB,CAAA;EACA,CAAA;;AAI7B,MAAa,iCAAuD;CAClE,YAAY;CACZ,aAAa;CACb,YAAY,CAAC;EAAE,IAAI;EAAW,OAAO;EAAW,CAAC;CACjD,QAAQ,EAAE;CACX"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as usePortalTenantClient } from "./PortalTenantClientProvider-4ZmY6hac.mjs";
|
|
2
2
|
import { t as useAccount } from "./use-account-B16Tor2Q.mjs";
|
|
3
3
|
import { n as useAppNavigation } from "./AppNavigationContext-BW3lSpfT.mjs";
|
|
4
|
-
import { a as ShareablesApp, n as usePortalContentContext, o as
|
|
4
|
+
import { a as ShareablesApp, c as ShareablesCoreProvider, n as usePortalContentContext, o as useFilePickerApi, r as toggleFavorite, s as ShareablesUIProvider, t as PortalContentApiProvider } from "./PortalContentApiProvider-Cei2eKh_.mjs";
|
|
5
5
|
import { t as PortalProductsApiProvider } from "./PortalProductsApiProvider-BALswRao.mjs";
|
|
6
6
|
import { t as PORTAL_MYSITE_KEYS } from "./use-mysite-portal-BV-BP3CE.mjs";
|
|
7
7
|
import { useCallback, useMemo } from "react";
|
|
@@ -47,6 +47,7 @@ function ShareablesScreen({ background, textColor, accentColor, padding, borderR
|
|
|
47
47
|
function ShareablesScreenContent() {
|
|
48
48
|
const shareablesCtx = usePortalContentContext();
|
|
49
49
|
const { productsApi: portalProductsApi } = shareablesCtx;
|
|
50
|
+
const filePickerApi = useFilePickerApi();
|
|
50
51
|
const { data: account } = useAccount();
|
|
51
52
|
const { currentSlug, navigate } = useAppNavigation();
|
|
52
53
|
const isCustomer = account?.member_type === "customer";
|
|
@@ -95,7 +96,7 @@ function ShareablesScreenContent() {
|
|
|
95
96
|
showToast: (opts) => {
|
|
96
97
|
console.warn(`[Shareables] ${opts.type}: ${opts.title}`);
|
|
97
98
|
},
|
|
98
|
-
filePickerApi
|
|
99
|
+
filePickerApi,
|
|
99
100
|
onToggleFavorite: async (params) => {
|
|
100
101
|
const result = await toggleFavorite(client, params.favoriteableId, params.favoriteableType);
|
|
101
102
|
queryClient.invalidateQueries({ queryKey: PORTAL_MYSITE_KEYS.favorites() });
|
|
@@ -123,7 +124,7 @@ function ShareablesScreenContent() {
|
|
|
123
124
|
}), [
|
|
124
125
|
account,
|
|
125
126
|
navigate,
|
|
126
|
-
|
|
127
|
+
filePickerApi,
|
|
127
128
|
isCustomer,
|
|
128
129
|
shareablesCtx.playlistsAdapter,
|
|
129
130
|
shareablesCtx.mediaProductsAdapter,
|
|
@@ -157,4 +158,4 @@ const shareablesScreenPropertySchema = {
|
|
|
157
158
|
//#endregion
|
|
158
159
|
export { shareablesScreenPropertySchema as n, ShareablesScreen as t };
|
|
159
160
|
|
|
160
|
-
//# sourceMappingURL=ShareablesScreen-
|
|
161
|
+
//# sourceMappingURL=ShareablesScreen-lLzBYQ9u.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShareablesScreen-lLzBYQ9u.mjs","names":[],"sources":["../src/screens/ShareablesScreen.tsx"],"sourcesContent":["import { useCallback, useMemo, type ComponentProps } from \"react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { PORTAL_MYSITE_KEYS } from \"@fluid-app/mysite-ui/portal/hooks/use-mysite-portal\";\nimport type {\n BackgroundValue,\n BorderRadiusOptions,\n ColorOptions,\n PaddingOptions,\n} from \"../types\";\nimport type { WidgetPropertySchema } from \"../registries/property-schema-types\";\nimport { ShareablesCoreProvider } from \"@fluid-app/shareables-core\";\nimport { ShareablesUIProvider, ShareablesApp } from \"@fluid-app/shareables-ui\";\nimport { useFilePickerApi } from \"@fluid-app/file-picker-core\";\nimport { useAppNavigation } from \"../shell/AppNavigationContext\";\nimport { useAccount } from \"../hooks/use-account\";\nimport { PortalProductsApiProvider } from \"../products/PortalProductsApiProvider\";\nimport {\n PortalContentApiProvider,\n usePortalContentContext,\n} from \"../content/PortalContentApiProvider\";\nimport { toggleFavorite } from \"../adapters/content-api-adapter\";\nimport { usePortalTenantClient } from \"../providers/PortalTenantClientProvider\";\n\ntype ShareablesScreenProps = ComponentProps<\"div\"> & {\n background?: BackgroundValue;\n textColor?: ColorOptions;\n accentColor?: ColorOptions;\n padding?: PaddingOptions;\n borderRadius?: BorderRadiusOptions;\n};\n\n/**\n * Parse the current shareables sub-route from the full slug.\n *\n * System nav slugs are \"share/products\", \"share/media\", \"share/playlists\".\n * Detail pages append an ID: \"share/products/123\", \"share/media/456\".\n *\n * \"share/products\" → screen=\"products\", detailId=null\n * \"share/products/123\" → screen=\"products\", detailId=\"123\"\n * \"share/media/456\" → screen=\"media\", detailId=\"456\"\n * \"share/playlists\" → screen=\"playlists\", detailId=null\n * \"share/playlists/789\" → screen=\"playlists\", detailId=\"789\"\n * \"share/files\" → screen=\"files\", detailId=null\n * \"share\" → screen=null (default to products)\n */\nfunction parseShareablesRoute(currentSlug: string): {\n screen: string | null;\n detailId: string | null;\n action: string | null;\n} {\n // Strip the \"share\" prefix\n const slugWithoutPrefix = currentSlug.replace(/^share\\/?/, \"\");\n if (!slugWithoutPrefix) {\n return { screen: null, detailId: null, action: null };\n }\n\n const parts = slugWithoutPrefix.split(\"/\");\n const screen = parts[0] || null;\n const detailId = parts[1] || null;\n const action = parts[2] || null;\n return { screen, detailId, action };\n}\n\nexport function ShareablesScreen({\n /* eslint-disable @typescript-eslint/no-unused-vars -- destructured to exclude from divProps spread */\n background,\n textColor,\n accentColor,\n padding,\n borderRadius,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ...divProps\n}: ShareablesScreenProps): React.JSX.Element {\n return (\n <div {...divProps} className={`h-full ${divProps.className ?? \"\"}`}>\n <PortalProductsApiProvider>\n <PortalContentApiProvider>\n <ShareablesScreenContent />\n </PortalContentApiProvider>\n </PortalProductsApiProvider>\n </div>\n );\n}\n\n/** Inner component rendered inside providers so hooks can access context. */\nfunction ShareablesScreenContent(): React.JSX.Element {\n const shareablesCtx = usePortalContentContext();\n const { productsApi: portalProductsApi } = shareablesCtx;\n const filePickerApi = useFilePickerApi();\n const { data: account } = useAccount();\n const { currentSlug, navigate } = useAppNavigation();\n const isCustomer = account?.member_type === \"customer\";\n const client = usePortalTenantClient();\n const queryClient = useQueryClient();\n\n const fetchProducts = useCallback(\n async (search: string, cursor?: string, limit?: number) => {\n if (search) {\n return portalProductsApi.searchProducts(search, { cursor, limit });\n }\n return portalProductsApi.listProducts({ cursor, limit });\n },\n [portalProductsApi],\n );\n\n const fetchProduct = useCallback(\n async (id: string | number) => portalProductsApi.getProduct(id),\n [portalProductsApi],\n );\n\n const { screen, detailId, action } = parseShareablesRoute(currentSlug);\n\n const handleNavigate = useCallback(\n (subScreen: string, id?: string) => {\n const path = id ? `share/${subScreen}/${id}` : `share/${subScreen}`;\n navigate(path);\n },\n [navigate],\n );\n\n const handleBack = useCallback(() => {\n if (detailId && screen) {\n navigate(`share/${screen}`);\n } else {\n navigate(\"share/products\");\n }\n }, [navigate, detailId, screen]);\n\n const coreConfig = useMemo(\n () => ({\n user: account ? { id: account.id } : null,\n repContext: true,\n }),\n [account],\n );\n\n const uiConfig = useMemo(\n () => ({\n user: account\n ? {\n id: account.id,\n company: null, // TODO(portal-tenant): company branding not available from /api/account\n }\n : undefined,\n // TODO(portal-tenant): affiliate_id not available from /api/account\n affiliateId: null,\n basePath: \"\",\n navigate: (path: string) => {\n const cleanPath = path.replace(/^\\//, \"\");\n const prefixed = cleanPath.startsWith(\"share/\")\n ? cleanPath\n : `share/${cleanPath}`;\n navigate(prefixed);\n },\n showToast: (opts: {\n title: string;\n type: \"success\" | \"error\" | \"warning\";\n }) => {\n console.warn(`[Shareables] ${opts.type}: ${opts.title}`);\n },\n filePickerApi,\n onToggleFavorite: async (params: {\n favoriteableId: number;\n favoriteableType: string;\n }) => {\n const result = await toggleFavorite(\n client,\n params.favoriteableId,\n params.favoriteableType,\n );\n void queryClient.invalidateQueries({\n queryKey: PORTAL_MYSITE_KEYS.favorites(),\n });\n return result;\n },\n onDeletePlaylist: isCustomer\n ? undefined\n : async (playlistId: number) => {\n await shareablesCtx.playlistsAdapter.deletePlaylist(playlistId);\n },\n mediaProductsApi: isCustomer\n ? undefined\n : shareablesCtx.mediaProductsAdapter,\n searchProducts: isCustomer\n ? undefined\n : async (query: string) => {\n const result = await portalProductsApi.searchProducts(query);\n return (result.products ?? []).map(\n (p: {\n id?: number;\n title?: string;\n name?: string;\n image_url?: string | null;\n price?: string | null;\n }) => ({\n id: p.id ?? 0,\n name: p.name ?? p.title ?? \"Untitled\",\n image_url: p.image_url ?? null,\n price: p.price ?? null,\n }),\n );\n },\n readOnly: isCustomer,\n uploadThumbnail: isCustomer\n ? undefined\n : async (blob: Blob, filename: string) => {\n const formData = new FormData();\n formData.append(\"asset[name]\", filename);\n formData.append(\"asset[file]\", blob, filename);\n const response = await client.requestWithFormData<{\n asset?: { default_variant_url?: string | null };\n }>(\"/api/content/dam/assets\", formData);\n return response.asset?.default_variant_url ?? \"\";\n },\n }),\n [\n account,\n navigate,\n filePickerApi,\n isCustomer,\n shareablesCtx.playlistsAdapter,\n shareablesCtx.mediaProductsAdapter,\n portalProductsApi,\n client,\n queryClient,\n ],\n );\n\n return (\n <ShareablesCoreProvider config={coreConfig}>\n <ShareablesUIProvider config={uiConfig}>\n <ShareablesApp\n screen={screen}\n detailId={detailId}\n action={action}\n companyLogoUrl={undefined}\n countryCode={undefined}\n fetchProducts={fetchProducts}\n fetchProduct={fetchProduct}\n onNavigate={handleNavigate}\n onBack={handleBack}\n />\n </ShareablesUIProvider>\n </ShareablesCoreProvider>\n );\n}\n\nexport const shareablesScreenPropertySchema: WidgetPropertySchema = {\n widgetType: \"ShareablesScreen\",\n displayName: \"Shareables Screen\",\n tabsConfig: [{ id: \"styling\", label: \"Styling\" }],\n fields: [],\n} as const satisfies WidgetPropertySchema;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAS,qBAAqB,aAI5B;CAEA,MAAM,oBAAoB,YAAY,QAAQ,aAAa,GAAG;AAC9D,KAAI,CAAC,kBACH,QAAO;EAAE,QAAQ;EAAM,UAAU;EAAM,QAAQ;EAAM;CAGvD,MAAM,QAAQ,kBAAkB,MAAM,IAAI;AAI1C,QAAO;EAAE,QAHM,MAAM,MAAM;EAGV,UAFA,MAAM,MAAM;EAEF,QADZ,MAAM,MAAM;EACQ;;AAGrC,SAAgB,iBAAiB,EAE/B,YACA,WACA,aACA,SACA,cAEA,GAAG,YACwC;AAC3C,QACE,oBAAC,OAAD;EAAK,GAAI;EAAU,WAAW,UAAU,SAAS,aAA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YAAY,CAAC;EAAE,IAAI;EAAW,OAAO;EAAW,CAAC;CACjD,QAAQ,EAAE;CACX"}
|
|
@@ -6,9 +6,9 @@ import "./ScreenHeaderContext-FYyYk97y.mjs";
|
|
|
6
6
|
import "./dist-BETEuYfn.mjs";
|
|
7
7
|
import "./SearchSort-CFbJNJDL.mjs";
|
|
8
8
|
import "./dist-DiBoTZfl.mjs";
|
|
9
|
-
import "./PortalContentApiProvider-
|
|
9
|
+
import "./PortalContentApiProvider-Cei2eKh_.mjs";
|
|
10
10
|
import "./sortable.esm-CJLSD-Ce.mjs";
|
|
11
11
|
import "./PortalProductsApiProvider-BALswRao.mjs";
|
|
12
12
|
import "./use-mysite-portal-BV-BP3CE.mjs";
|
|
13
|
-
import { n as shareablesScreenPropertySchema, t as ShareablesScreen } from "./ShareablesScreen-
|
|
13
|
+
import { n as shareablesScreenPropertySchema, t as ShareablesScreen } from "./ShareablesScreen-lLzBYQ9u.mjs";
|
|
14
14
|
export { ShareablesScreen, shareablesScreenPropertySchema };
|
package/dist/index.cjs
CHANGED
|
@@ -57,13 +57,13 @@ require("./src-BukXixXu.cjs");
|
|
|
57
57
|
require("./dist-DbiSKQz4.cjs");
|
|
58
58
|
const require_OrdersScreen = require("./OrdersScreen-tEz4rZn_.cjs");
|
|
59
59
|
const require_SubscriptionsScreen = require("./SubscriptionsScreen-Dr0FmZZH.cjs");
|
|
60
|
-
require("./PortalContentApiProvider-
|
|
60
|
+
require("./PortalContentApiProvider-C2G-u4O2.cjs");
|
|
61
61
|
require("./dist-DWs3-WOI.cjs");
|
|
62
62
|
require("./PortalProductsApiProvider-Duj-EjQj.cjs");
|
|
63
|
-
const require_ProductsScreen = require("./ProductsScreen-
|
|
63
|
+
const require_ProductsScreen = require("./ProductsScreen-ClOJgwBf.cjs");
|
|
64
64
|
require("./use-mysite-portal-DzDYRU0u.cjs");
|
|
65
65
|
const require_MySiteScreen = require("./MySiteScreen-B_ue0dF6.cjs");
|
|
66
|
-
const require_ShareablesScreen = require("./ShareablesScreen-
|
|
66
|
+
const require_ShareablesScreen = require("./ShareablesScreen-CkaXzERa.cjs");
|
|
67
67
|
const require_ShopScreen = require("./ShopScreen-BojtrxZ9.cjs");
|
|
68
68
|
require("./UpgradeScreen-BwWZYjrw.cjs");
|
|
69
69
|
require("./AppDownloadScreen-DXkRe6MQ.cjs");
|
|
@@ -2142,8 +2142,8 @@ const MessagingScreen$1 = (0, react.lazy)(() => Promise.resolve().then(() => req
|
|
|
2142
2142
|
const ContactsScreen$1 = (0, react.lazy)(() => Promise.resolve().then(() => require("./ContactsScreen-f9MvO-hX.cjs")).then((m) => ({ default: m.ContactsScreen })));
|
|
2143
2143
|
const ShopScreen$1 = (0, react.lazy)(() => Promise.resolve().then(() => require("./ShopScreen-DkDh2aGx.cjs")).then((m) => ({ default: m.ShopScreen })));
|
|
2144
2144
|
const CustomersScreen$1 = (0, react.lazy)(() => Promise.resolve().then(() => require("./CustomersScreen-DRcCBHkL.cjs")).then((n) => n.CustomersScreen_exports).then((m) => ({ default: m.CustomersScreen })));
|
|
2145
|
-
const ProductsScreen$1 = (0, react.lazy)(() => Promise.resolve().then(() => require("./ProductsScreen-
|
|
2146
|
-
const ShareablesScreen$1 = (0, react.lazy)(() => Promise.resolve().then(() => require("./ShareablesScreen-
|
|
2145
|
+
const ProductsScreen$1 = (0, react.lazy)(() => Promise.resolve().then(() => require("./ProductsScreen-BJBagajA.cjs")).then((m) => ({ default: m.ProductsScreen })));
|
|
2146
|
+
const ShareablesScreen$1 = (0, react.lazy)(() => Promise.resolve().then(() => require("./ShareablesScreen-9j2YlYM5.cjs")).then((m) => ({ default: m.ShareablesScreen })));
|
|
2147
2147
|
const MySiteScreen$1 = (0, react.lazy)(() => Promise.resolve().then(() => require("./MySiteScreen-W907mNoB.cjs")).then((m) => ({ default: m.MySiteScreen })));
|
|
2148
2148
|
const UpgradeScreen = (0, react.lazy)(() => Promise.resolve().then(() => require("./UpgradeScreen-DqpdSO-F.cjs")).then((m) => ({ default: m.UpgradeScreen })));
|
|
2149
2149
|
const AppDownloadScreen = (0, react.lazy)(() => Promise.resolve().then(() => require("./AppDownloadScreen-DXkRe6MQ.cjs")).then((n) => n.AppDownloadScreen_exports).then((m) => ({ default: m.AppDownloadScreen })));
|
|
@@ -3636,9 +3636,9 @@ const screenPropertySchemas = {
|
|
|
3636
3636
|
OrdersScreen: () => Promise.resolve().then(() => require("./OrdersScreen-COGBqaif.cjs")).then((m) => m.ordersScreenPropertySchema),
|
|
3637
3637
|
SubscriptionsScreen: () => Promise.resolve().then(() => require("./SubscriptionsScreen-CYIUXxrJ.cjs")).then((m) => m.subscriptionsScreenPropertySchema),
|
|
3638
3638
|
CustomersScreen: () => Promise.resolve().then(() => require("./CustomersScreen-DRcCBHkL.cjs")).then((n) => n.CustomersScreen_exports).then((m) => m.customersScreenPropertySchema),
|
|
3639
|
-
ProductsScreen: () => Promise.resolve().then(() => require("./ProductsScreen-
|
|
3639
|
+
ProductsScreen: () => Promise.resolve().then(() => require("./ProductsScreen-BJBagajA.cjs")).then((m) => m.productsScreenPropertySchema),
|
|
3640
3640
|
MySiteScreen: () => Promise.resolve().then(() => require("./MySiteScreen-W907mNoB.cjs")).then((m) => m.mySiteScreenPropertySchema),
|
|
3641
|
-
ShareablesScreen: () => Promise.resolve().then(() => require("./ShareablesScreen-
|
|
3641
|
+
ShareablesScreen: () => Promise.resolve().then(() => require("./ShareablesScreen-9j2YlYM5.cjs")).then((m) => m.shareablesScreenPropertySchema),
|
|
3642
3642
|
ShopScreen: () => Promise.resolve().then(() => require("./ShopScreen-DkDh2aGx.cjs")).then((m) => m.shopScreenPropertySchema),
|
|
3643
3643
|
UpgradeScreen: () => Promise.resolve().then(() => require("./UpgradeScreen-DqpdSO-F.cjs")).then((m) => m.upgradeScreenPropertySchema),
|
|
3644
3644
|
AppDownloadScreen: () => Promise.resolve().then(() => require("./AppDownloadScreen-DXkRe6MQ.cjs")).then((n) => n.AppDownloadScreen_exports).then((m) => m.appDownloadScreenPropertySchema)
|