@fluid-app/portal-sdk 0.1.219 → 0.1.220
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/{AppDownloadScreen-CZ0EOIZ5.mjs → AppDownloadScreen-Bhix461K.mjs} +1 -1
- package/dist/{AppDownloadScreen-CZ0EOIZ5.mjs.map → AppDownloadScreen-Bhix461K.mjs.map} +1 -1
- package/dist/{AppDownloadScreen-CBoC31wL.cjs → AppDownloadScreen-DwBzuPcF.cjs} +1 -1
- package/dist/{AppDownloadScreen-CBoC31wL.cjs.map → AppDownloadScreen-DwBzuPcF.cjs.map} +1 -1
- package/dist/{MySiteScreen-CyzM9hX3.mjs → MySiteScreen-BAPWqDfm.mjs} +2 -3
- package/dist/{MySiteScreen-CyzM9hX3.mjs.map → MySiteScreen-BAPWqDfm.mjs.map} +1 -1
- package/dist/{MySiteScreen-DPQ66oRs.cjs → MySiteScreen-CEX1qxdj.cjs} +2 -3
- package/dist/{MySiteScreen-DxLcG3-S.cjs → MySiteScreen-DaNlmVSi.cjs} +15 -16
- package/dist/{MySiteScreen-DxLcG3-S.cjs.map → MySiteScreen-DaNlmVSi.cjs.map} +1 -1
- package/dist/{PortalProductsApiProvider-CE71zDj9.mjs → PortalProductsApiProvider-BwIRudl_.mjs} +1 -1
- package/dist/{PortalProductsApiProvider-CE71zDj9.mjs.map → PortalProductsApiProvider-BwIRudl_.mjs.map} +1 -1
- package/dist/{PortalProductsApiProvider-Ca1oeTtJ.cjs → PortalProductsApiProvider-CRaocswH.cjs} +1 -1
- package/dist/{PortalProductsApiProvider-Ca1oeTtJ.cjs.map → PortalProductsApiProvider-CRaocswH.cjs.map} +1 -1
- package/dist/{ShareablesScreen-YlMqyP-B.cjs → ShareablesScreen-CqvPzH1v.cjs} +3 -5
- package/dist/{PortalContentApiProvider-x81DXmOR.mjs → ShareablesScreen-DV2nikzp.mjs} +188 -38
- package/dist/ShareablesScreen-DV2nikzp.mjs.map +1 -0
- package/dist/{PortalContentApiProvider-DXnplIOD.cjs → ShareablesScreen-DwnMBftJ.cjs} +185 -75
- package/dist/ShareablesScreen-DwnMBftJ.cjs.map +1 -0
- package/dist/{ShopScreen-BOjri6Dm.cjs → ShopScreen-C-Ki6fuh.cjs} +2 -2
- package/dist/{ShopScreen-B4afB5sE.mjs → ShopScreen-C2K1C2tt.mjs} +2 -2
- package/dist/{ShopScreen-B4afB5sE.mjs.map → ShopScreen-C2K1C2tt.mjs.map} +1 -1
- package/dist/{ShopScreen-Untg6XBY.cjs → ShopScreen-smzNn37E.cjs} +2 -2
- package/dist/{ShopScreen-Untg6XBY.cjs.map → ShopScreen-smzNn37E.cjs.map} +1 -1
- package/dist/{UpgradeScreen-BdY0rCoF.cjs → UpgradeScreen-CNXQ1hcP.cjs} +1 -1
- package/dist/{UpgradeScreen-Dau5Elx4.mjs → UpgradeScreen-ChLiVSf7.mjs} +1 -1
- package/dist/{UpgradeScreen-Dau5Elx4.mjs.map → UpgradeScreen-ChLiVSf7.mjs.map} +1 -1
- package/dist/{UpgradeScreen-DrBa2uzD.cjs → UpgradeScreen-DMJUK4dl.cjs} +1 -1
- package/dist/{UpgradeScreen-DrBa2uzD.cjs.map → UpgradeScreen-DMJUK4dl.cjs.map} +1 -1
- package/dist/{dist-DWs3-WOI.cjs → dist-Bxa9x0H9.cjs} +218 -1
- package/dist/{dist-DWs3-WOI.cjs.map → dist-Bxa9x0H9.cjs.map} +1 -1
- package/dist/index.cjs +17 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -20
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -20
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +18 -45
- package/dist/index.mjs.map +1 -1
- package/dist/{sortable.esm-CJLSD-Ce.mjs → sortable.esm-fSGrAZU2.mjs} +141 -2
- package/dist/sortable.esm-fSGrAZU2.mjs.map +1 -0
- package/package.json +12 -12
- package/dist/PortalContentApiProvider-DXnplIOD.cjs.map +0 -1
- package/dist/PortalContentApiProvider-x81DXmOR.mjs.map +0 -1
- package/dist/ProductsScreen-3yjIMjYY.cjs +0 -15
- package/dist/ProductsScreen-BVyLOe2K.mjs +0 -13
- package/dist/ProductsScreen-R0MfWYZJ.cjs +0 -103
- package/dist/ProductsScreen-R0MfWYZJ.cjs.map +0 -1
- package/dist/ProductsScreen-z9hXfFeJ.mjs +0 -91
- package/dist/ProductsScreen-z9hXfFeJ.mjs.map +0 -1
- package/dist/ShareablesScreen-Co_gFZva.cjs +0 -200
- package/dist/ShareablesScreen-Co_gFZva.cjs.map +0 -1
- package/dist/ShareablesScreen-DpwFh0ky.mjs +0 -15
- package/dist/ShareablesScreen-tkaf9R5N.mjs +0 -188
- package/dist/ShareablesScreen-tkaf9R5N.mjs.map +0 -1
- package/dist/sortable.esm-CJLSD-Ce.mjs.map +0 -1
- package/dist/use-mysite-portal-D29HLD1z.mjs +0 -142
- package/dist/use-mysite-portal-D29HLD1z.mjs.map +0 -1
- package/dist/use-mysite-portal-DxNQ3uTi.cjs +0 -220
- package/dist/use-mysite-portal-DxNQ3uTi.cjs.map +0 -1
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
require("./chunk-9hOWP6kD.cjs");
|
|
2
|
-
require("./account-api-context-DZP9IiGg.cjs");
|
|
3
|
-
require("./store-api-context-D1gZn22Z.cjs");
|
|
4
|
-
require("./src-aItPhUAR.cjs");
|
|
5
|
-
require("./ScreenHeaderContext-BXgWydjB.cjs");
|
|
6
|
-
require("./dist-CGuUUVNt.cjs");
|
|
7
|
-
require("./es-DHLLltoR.cjs");
|
|
8
|
-
require("./SearchSort-DHDDqero.cjs");
|
|
9
|
-
require("./dist-DDZMFlal.cjs");
|
|
10
|
-
require("./PortalContentApiProvider-DXnplIOD.cjs");
|
|
11
|
-
require("./dist-DWs3-WOI.cjs");
|
|
12
|
-
require("./PortalProductsApiProvider-Ca1oeTtJ.cjs");
|
|
13
|
-
const require_ProductsScreen = require("./ProductsScreen-R0MfWYZJ.cjs");
|
|
14
|
-
exports.ProductsScreen = require_ProductsScreen.ProductsScreen;
|
|
15
|
-
exports.productsScreenPropertySchema = require_ProductsScreen.productsScreenPropertySchema;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import "./es-Cw_Kikmu.mjs";
|
|
2
|
-
import "./account-api-context-BIZ_aibJ.mjs";
|
|
3
|
-
import "./store-api-context-C1lXT_3d.mjs";
|
|
4
|
-
import "./src-BEKH1DXO.mjs";
|
|
5
|
-
import "./ScreenHeaderContext-BDjNSUfr.mjs";
|
|
6
|
-
import "./dist-D39Yezrv.mjs";
|
|
7
|
-
import "./SearchSort-DXBt-uj0.mjs";
|
|
8
|
-
import "./dist-Cis8L6HV.mjs";
|
|
9
|
-
import "./PortalContentApiProvider-x81DXmOR.mjs";
|
|
10
|
-
import "./sortable.esm-CJLSD-Ce.mjs";
|
|
11
|
-
import "./PortalProductsApiProvider-CE71zDj9.mjs";
|
|
12
|
-
import { n as productsScreenPropertySchema, t as ProductsScreen } from "./ProductsScreen-z9hXfFeJ.mjs";
|
|
13
|
-
export { ProductsScreen, productsScreenPropertySchema };
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
require("./chunk-9hOWP6kD.cjs");
|
|
2
|
-
const require_src = require("./src-aItPhUAR.cjs");
|
|
3
|
-
const require_use_account = require("./use-account-C5QI6NSe.cjs");
|
|
4
|
-
const require_use_store = require("./use-store-BLcehk1A.cjs");
|
|
5
|
-
const require_AppNavigationContext = require("./AppNavigationContext-CbK8uCjS.cjs");
|
|
6
|
-
const require_PortalContentApiProvider = require("./PortalContentApiProvider-DXnplIOD.cjs");
|
|
7
|
-
const require_PortalProductsApiProvider = require("./PortalProductsApiProvider-Ca1oeTtJ.cjs");
|
|
8
|
-
let react = require("react");
|
|
9
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
-
//#region src/screens/ProductsScreen.tsx
|
|
11
|
-
function ProductsScreen({ background, textColor, accentColor, padding, borderRadius, ...divProps }) {
|
|
12
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
13
|
-
...divProps,
|
|
14
|
-
className: `h-full ${divProps.className ?? ""}`,
|
|
15
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PortalProductsApiProvider.PortalProductsApiProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PortalContentApiProvider.PortalContentApiProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProductsScreenContent, {}) }) })
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
/** Inner component rendered inside providers so hooks can access context. */
|
|
19
|
-
function ProductsScreenContent() {
|
|
20
|
-
const { productsApi: portalProductsApi } = require_PortalContentApiProvider.usePortalContentContext();
|
|
21
|
-
const { data: account } = require_use_account.useAccount();
|
|
22
|
-
const { data: store } = require_use_store.useStore();
|
|
23
|
-
const { currentSlug, navigate } = require_AppNavigationContext.useAppNavigation();
|
|
24
|
-
const fetchProducts = (0, react.useCallback)(async (search, cursor, limit, sort) => {
|
|
25
|
-
if (search) return portalProductsApi.searchProducts(search, {
|
|
26
|
-
cursor,
|
|
27
|
-
limit
|
|
28
|
-
});
|
|
29
|
-
return portalProductsApi.listProducts({
|
|
30
|
-
cursor,
|
|
31
|
-
limit,
|
|
32
|
-
sort
|
|
33
|
-
});
|
|
34
|
-
}, [portalProductsApi]);
|
|
35
|
-
const fetchProduct = (0, react.useCallback)(async (id) => portalProductsApi.getProduct(id), [portalProductsApi]);
|
|
36
|
-
const productId = (0, react.useMemo)(() => {
|
|
37
|
-
return currentSlug.match(/^products\/(.+)/)?.[1] ?? null;
|
|
38
|
-
}, [currentSlug]);
|
|
39
|
-
const handleSelectProduct = (0, react.useCallback)((id) => {
|
|
40
|
-
navigate(`products/${id}`);
|
|
41
|
-
}, [navigate]);
|
|
42
|
-
const handleBack = (0, react.useCallback)(() => {
|
|
43
|
-
navigate("products");
|
|
44
|
-
}, [navigate]);
|
|
45
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PortalContentApiProvider.ShareablesCoreProvider, {
|
|
46
|
-
config: (0, react.useMemo)(() => ({
|
|
47
|
-
user: account ? { id: account.id } : null,
|
|
48
|
-
repContext: true
|
|
49
|
-
}), [account]),
|
|
50
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PortalContentApiProvider.ShareablesUIProvider, {
|
|
51
|
-
config: (0, react.useMemo)(() => ({
|
|
52
|
-
user: account ? {
|
|
53
|
-
id: account.id,
|
|
54
|
-
company: { logo_url: store?.logo_url ?? null }
|
|
55
|
-
} : void 0,
|
|
56
|
-
basePath: "",
|
|
57
|
-
navigate: (path) => {
|
|
58
|
-
navigate(path);
|
|
59
|
-
},
|
|
60
|
-
showToast: (opts) => {
|
|
61
|
-
require_src.fluidToast(opts);
|
|
62
|
-
}
|
|
63
|
-
}), [
|
|
64
|
-
account,
|
|
65
|
-
store,
|
|
66
|
-
navigate
|
|
67
|
-
]),
|
|
68
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PortalContentApiProvider.ProductsApp, {
|
|
69
|
-
countryCode: void 0,
|
|
70
|
-
companyLogoUrl: store?.logo_url ?? void 0,
|
|
71
|
-
fetchProducts,
|
|
72
|
-
fetchProduct,
|
|
73
|
-
productId,
|
|
74
|
-
onSelectProduct: handleSelectProduct,
|
|
75
|
-
onBack: handleBack
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
const productsScreenPropertySchema = {
|
|
81
|
-
widgetType: "ProductsScreen",
|
|
82
|
-
displayName: "Products Screen",
|
|
83
|
-
tabsConfig: [{
|
|
84
|
-
id: "styling",
|
|
85
|
-
label: "Styling"
|
|
86
|
-
}],
|
|
87
|
-
fields: []
|
|
88
|
-
};
|
|
89
|
-
//#endregion
|
|
90
|
-
Object.defineProperty(exports, "ProductsScreen", {
|
|
91
|
-
enumerable: true,
|
|
92
|
-
get: function() {
|
|
93
|
-
return ProductsScreen;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
Object.defineProperty(exports, "productsScreenPropertySchema", {
|
|
97
|
-
enumerable: true,
|
|
98
|
-
get: function() {
|
|
99
|
-
return productsScreenPropertySchema;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
//# sourceMappingURL=ProductsScreen-R0MfWYZJ.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProductsScreen-R0MfWYZJ.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, sort?: string) => {\n if (search) {\n return portalProductsApi.searchProducts(search, { cursor, limit });\n }\n return portalProductsApi.listProducts({ cursor, limit, sort });\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,OAAgB,SAAkB;AACxE,MAAI,OACF,QAAO,kBAAkB,eAAe,QAAQ;GAAE;GAAQ;GAAO,CAAC;AAEpE,SAAO,kBAAkB,aAAa;GAAE;GAAQ;GAAO;GAAM,CAAC;IAEhE,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"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { b as fluidToast } from "./src-BEKH1DXO.mjs";
|
|
2
|
-
import { t as useAccount } from "./use-account-Cvig0exB.mjs";
|
|
3
|
-
import { t as useStore } from "./use-store-efmQhKpB.mjs";
|
|
4
|
-
import { n as useAppNavigation } from "./AppNavigationContext-Cq3BDKSf.mjs";
|
|
5
|
-
import { c as ShareablesCoreProvider, i as ProductsApp, n as usePortalContentContext, s as ShareablesUIProvider, t as PortalContentApiProvider } from "./PortalContentApiProvider-x81DXmOR.mjs";
|
|
6
|
-
import { t as PortalProductsApiProvider } from "./PortalProductsApiProvider-CE71zDj9.mjs";
|
|
7
|
-
import { useCallback, useMemo } from "react";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
//#region src/screens/ProductsScreen.tsx
|
|
10
|
-
function ProductsScreen({ background, textColor, accentColor, padding, borderRadius, ...divProps }) {
|
|
11
|
-
return /* @__PURE__ */ jsx("div", {
|
|
12
|
-
...divProps,
|
|
13
|
-
className: `h-full ${divProps.className ?? ""}`,
|
|
14
|
-
children: /* @__PURE__ */ jsx(PortalProductsApiProvider, { children: /* @__PURE__ */ jsx(PortalContentApiProvider, { children: /* @__PURE__ */ jsx(ProductsScreenContent, {}) }) })
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
/** Inner component rendered inside providers so hooks can access context. */
|
|
18
|
-
function ProductsScreenContent() {
|
|
19
|
-
const { productsApi: portalProductsApi } = usePortalContentContext();
|
|
20
|
-
const { data: account } = useAccount();
|
|
21
|
-
const { data: store } = useStore();
|
|
22
|
-
const { currentSlug, navigate } = useAppNavigation();
|
|
23
|
-
const fetchProducts = useCallback(async (search, cursor, limit, sort) => {
|
|
24
|
-
if (search) return portalProductsApi.searchProducts(search, {
|
|
25
|
-
cursor,
|
|
26
|
-
limit
|
|
27
|
-
});
|
|
28
|
-
return portalProductsApi.listProducts({
|
|
29
|
-
cursor,
|
|
30
|
-
limit,
|
|
31
|
-
sort
|
|
32
|
-
});
|
|
33
|
-
}, [portalProductsApi]);
|
|
34
|
-
const fetchProduct = useCallback(async (id) => portalProductsApi.getProduct(id), [portalProductsApi]);
|
|
35
|
-
const productId = useMemo(() => {
|
|
36
|
-
return currentSlug.match(/^products\/(.+)/)?.[1] ?? null;
|
|
37
|
-
}, [currentSlug]);
|
|
38
|
-
const handleSelectProduct = useCallback((id) => {
|
|
39
|
-
navigate(`products/${id}`);
|
|
40
|
-
}, [navigate]);
|
|
41
|
-
const handleBack = useCallback(() => {
|
|
42
|
-
navigate("products");
|
|
43
|
-
}, [navigate]);
|
|
44
|
-
return /* @__PURE__ */ jsx(ShareablesCoreProvider, {
|
|
45
|
-
config: useMemo(() => ({
|
|
46
|
-
user: account ? { id: account.id } : null,
|
|
47
|
-
repContext: true
|
|
48
|
-
}), [account]),
|
|
49
|
-
children: /* @__PURE__ */ jsx(ShareablesUIProvider, {
|
|
50
|
-
config: useMemo(() => ({
|
|
51
|
-
user: account ? {
|
|
52
|
-
id: account.id,
|
|
53
|
-
company: { logo_url: store?.logo_url ?? null }
|
|
54
|
-
} : void 0,
|
|
55
|
-
basePath: "",
|
|
56
|
-
navigate: (path) => {
|
|
57
|
-
navigate(path);
|
|
58
|
-
},
|
|
59
|
-
showToast: (opts) => {
|
|
60
|
-
fluidToast(opts);
|
|
61
|
-
}
|
|
62
|
-
}), [
|
|
63
|
-
account,
|
|
64
|
-
store,
|
|
65
|
-
navigate
|
|
66
|
-
]),
|
|
67
|
-
children: /* @__PURE__ */ jsx(ProductsApp, {
|
|
68
|
-
countryCode: void 0,
|
|
69
|
-
companyLogoUrl: store?.logo_url ?? void 0,
|
|
70
|
-
fetchProducts,
|
|
71
|
-
fetchProduct,
|
|
72
|
-
productId,
|
|
73
|
-
onSelectProduct: handleSelectProduct,
|
|
74
|
-
onBack: handleBack
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
const productsScreenPropertySchema = {
|
|
80
|
-
widgetType: "ProductsScreen",
|
|
81
|
-
displayName: "Products Screen",
|
|
82
|
-
tabsConfig: [{
|
|
83
|
-
id: "styling",
|
|
84
|
-
label: "Styling"
|
|
85
|
-
}],
|
|
86
|
-
fields: []
|
|
87
|
-
};
|
|
88
|
-
//#endregion
|
|
89
|
-
export { productsScreenPropertySchema as n, ProductsScreen as t };
|
|
90
|
-
|
|
91
|
-
//# sourceMappingURL=ProductsScreen-z9hXfFeJ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProductsScreen-z9hXfFeJ.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, sort?: string) => {\n if (search) {\n return portalProductsApi.searchProducts(search, { cursor, limit });\n }\n return portalProductsApi.listProducts({ cursor, limit, sort });\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,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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"}
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
require("./chunk-9hOWP6kD.cjs");
|
|
2
|
-
const require_PortalTenantClientProvider = require("./PortalTenantClientProvider-CVv-4rQ9.cjs");
|
|
3
|
-
const require_src = require("./src-aItPhUAR.cjs");
|
|
4
|
-
const require_use_account = require("./use-account-C5QI6NSe.cjs");
|
|
5
|
-
const require_use_store = require("./use-store-BLcehk1A.cjs");
|
|
6
|
-
const require_AppNavigationContext = require("./AppNavigationContext-CbK8uCjS.cjs");
|
|
7
|
-
const require_PortalContentApiProvider = require("./PortalContentApiProvider-DXnplIOD.cjs");
|
|
8
|
-
const require_PortalProductsApiProvider = require("./PortalProductsApiProvider-Ca1oeTtJ.cjs");
|
|
9
|
-
const require_use_mysite_portal = require("./use-mysite-portal-DxNQ3uTi.cjs");
|
|
10
|
-
let react = require("react");
|
|
11
|
-
let _tanstack_react_query = require("@tanstack/react-query");
|
|
12
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
|
-
//#region src/screens/ShareablesScreen.tsx
|
|
14
|
-
/**
|
|
15
|
-
* Parse the current shareables sub-route from the full slug.
|
|
16
|
-
*
|
|
17
|
-
* System nav slugs are "share/products", "share/media", "share/playlists".
|
|
18
|
-
* Detail pages append an ID: "share/products/123", "share/media/456".
|
|
19
|
-
*
|
|
20
|
-
* "share/products" → screen="products", detailId=null
|
|
21
|
-
* "share/products/123" → screen="products", detailId="123"
|
|
22
|
-
* "share/media/456" → screen="media", detailId="456"
|
|
23
|
-
* "share/playlists" → screen="playlists", detailId=null
|
|
24
|
-
* "share/playlists/789" → screen="playlists", detailId="789"
|
|
25
|
-
* "share/files" → screen="files", detailId=null
|
|
26
|
-
* "share" → screen=null (default to products)
|
|
27
|
-
*/
|
|
28
|
-
function parseShareablesRoute(currentSlug) {
|
|
29
|
-
const slugWithoutPrefix = currentSlug.replace(/^share\/?/, "");
|
|
30
|
-
if (!slugWithoutPrefix) return {
|
|
31
|
-
screen: null,
|
|
32
|
-
detailId: null,
|
|
33
|
-
action: null
|
|
34
|
-
};
|
|
35
|
-
const parts = slugWithoutPrefix.split("/");
|
|
36
|
-
return {
|
|
37
|
-
screen: parts[0] || null,
|
|
38
|
-
detailId: parts[1] || null,
|
|
39
|
-
action: parts[2] || null
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function ShareablesScreen({ background, textColor, accentColor, padding, borderRadius, ...divProps }) {
|
|
43
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
44
|
-
...divProps,
|
|
45
|
-
className: `h-full ${divProps.className ?? ""}`,
|
|
46
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PortalProductsApiProvider.PortalProductsApiProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PortalContentApiProvider.PortalContentApiProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShareablesScreenContent, {}) }) })
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/** Inner component rendered inside providers so hooks can access context. */
|
|
50
|
-
function ShareablesScreenContent() {
|
|
51
|
-
const shareablesCtx = require_PortalContentApiProvider.usePortalContentContext();
|
|
52
|
-
const { productsApi: portalProductsApi } = shareablesCtx;
|
|
53
|
-
const filePickerApi = require_PortalContentApiProvider.useFilePickerApi();
|
|
54
|
-
const { data: account } = require_use_account.useAccount();
|
|
55
|
-
const { data: store } = require_use_store.useStore();
|
|
56
|
-
const { currentSlug, navigate } = require_AppNavigationContext.useAppNavigation();
|
|
57
|
-
const isCustomer = account?.member_type === "customer";
|
|
58
|
-
const client = require_PortalTenantClientProvider.usePortalTenantClient();
|
|
59
|
-
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
60
|
-
const fetchProducts = (0, react.useCallback)(async (search, cursor, limit, sort) => {
|
|
61
|
-
if (search) return portalProductsApi.searchProducts(search, {
|
|
62
|
-
cursor,
|
|
63
|
-
limit
|
|
64
|
-
});
|
|
65
|
-
return portalProductsApi.listProducts({
|
|
66
|
-
cursor,
|
|
67
|
-
limit,
|
|
68
|
-
sort
|
|
69
|
-
});
|
|
70
|
-
}, [portalProductsApi]);
|
|
71
|
-
const fetchProduct = (0, react.useCallback)(async (id) => portalProductsApi.getProduct(id), [portalProductsApi]);
|
|
72
|
-
const { screen, detailId, action } = parseShareablesRoute(currentSlug);
|
|
73
|
-
const handleNavigate = (0, react.useCallback)((subScreen, id) => {
|
|
74
|
-
navigate(id ? `share/${subScreen}/${id}` : `share/${subScreen}`);
|
|
75
|
-
}, [navigate]);
|
|
76
|
-
const handleBack = (0, react.useCallback)(() => {
|
|
77
|
-
if (detailId && screen) navigate(`share/${screen}`);
|
|
78
|
-
else navigate("share/products");
|
|
79
|
-
}, [
|
|
80
|
-
navigate,
|
|
81
|
-
detailId,
|
|
82
|
-
screen
|
|
83
|
-
]);
|
|
84
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PortalContentApiProvider.ShareablesCoreProvider, {
|
|
85
|
-
config: (0, react.useMemo)(() => ({
|
|
86
|
-
user: account ? { id: account.id } : null,
|
|
87
|
-
repContext: true
|
|
88
|
-
}), [account]),
|
|
89
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PortalContentApiProvider.ShareablesUIProvider, {
|
|
90
|
-
config: (0, react.useMemo)(() => ({
|
|
91
|
-
user: account ? {
|
|
92
|
-
id: account.id,
|
|
93
|
-
company: { logo_url: store?.logo_url ?? null }
|
|
94
|
-
} : void 0,
|
|
95
|
-
affiliateId: null,
|
|
96
|
-
basePath: "",
|
|
97
|
-
navigate: (path) => {
|
|
98
|
-
const cleanPath = path.replace(/^\//, "");
|
|
99
|
-
navigate(cleanPath.startsWith("share/") ? cleanPath : `share/${cleanPath}`);
|
|
100
|
-
},
|
|
101
|
-
showToast: (opts) => {
|
|
102
|
-
require_src.fluidToast({
|
|
103
|
-
title: opts.title,
|
|
104
|
-
type: opts.type
|
|
105
|
-
});
|
|
106
|
-
if (opts.error) console.error("[Shareables]", opts.error);
|
|
107
|
-
},
|
|
108
|
-
filePickerApi,
|
|
109
|
-
onToggleFavorite: async (params) => {
|
|
110
|
-
const result = await require_PortalContentApiProvider.toggleFavorite(client, params.favoriteableId, params.favoriteableType);
|
|
111
|
-
queryClient.invalidateQueries({ queryKey: require_use_mysite_portal.PORTAL_MYSITE_KEYS.favorites() });
|
|
112
|
-
return result;
|
|
113
|
-
},
|
|
114
|
-
onMySiteShare: async (params) => {
|
|
115
|
-
await require_PortalContentApiProvider.toggleFavorite(client, params.relateable_id, params.relateable_type);
|
|
116
|
-
queryClient.invalidateQueries({ queryKey: require_use_mysite_portal.PORTAL_MYSITE_KEYS.favorites() });
|
|
117
|
-
},
|
|
118
|
-
onDeletePlaylist: isCustomer ? void 0 : async (playlistId) => {
|
|
119
|
-
await shareablesCtx.playlistsAdapter.deletePlaylist(playlistId);
|
|
120
|
-
},
|
|
121
|
-
mediaProductsApi: isCustomer ? void 0 : shareablesCtx.mediaProductsAdapter,
|
|
122
|
-
searchProducts: isCustomer ? void 0 : async (query, options) => {
|
|
123
|
-
const limit = options?.limit ?? 25;
|
|
124
|
-
const cursor = options?.cursor ?? void 0;
|
|
125
|
-
const result = query.trim().length > 0 ? await portalProductsApi.searchProducts(query, {
|
|
126
|
-
cursor,
|
|
127
|
-
limit
|
|
128
|
-
}) : await portalProductsApi.listProducts({
|
|
129
|
-
cursor,
|
|
130
|
-
limit
|
|
131
|
-
});
|
|
132
|
-
return {
|
|
133
|
-
products: (result.products ?? []).map((p) => p.id != null ? {
|
|
134
|
-
id: p.id,
|
|
135
|
-
name: p.name ?? p.title ?? "Untitled",
|
|
136
|
-
image_url: p.image_url ?? null,
|
|
137
|
-
price: p.price ?? null
|
|
138
|
-
} : null).filter((p) => p !== null),
|
|
139
|
-
nextCursor: result.meta?.pagination?.next_cursor ?? null
|
|
140
|
-
};
|
|
141
|
-
},
|
|
142
|
-
readOnly: isCustomer,
|
|
143
|
-
uploadThumbnail: isCustomer ? void 0 : async (blob, filename) => {
|
|
144
|
-
const formData = new FormData();
|
|
145
|
-
formData.append("asset[name]", filename);
|
|
146
|
-
formData.append("asset[file]", blob, filename);
|
|
147
|
-
const url = (await client.requestWithFormData("/api/content/dam/assets", formData)).asset?.default_variant_url;
|
|
148
|
-
if (!url) throw new Error("Thumbnail upload succeeded but no URL returned");
|
|
149
|
-
return url;
|
|
150
|
-
}
|
|
151
|
-
}), [
|
|
152
|
-
account,
|
|
153
|
-
store,
|
|
154
|
-
navigate,
|
|
155
|
-
filePickerApi,
|
|
156
|
-
isCustomer,
|
|
157
|
-
shareablesCtx.playlistsAdapter,
|
|
158
|
-
shareablesCtx.mediaProductsAdapter,
|
|
159
|
-
portalProductsApi,
|
|
160
|
-
client,
|
|
161
|
-
queryClient
|
|
162
|
-
]),
|
|
163
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PortalContentApiProvider.ShareablesApp, {
|
|
164
|
-
screen,
|
|
165
|
-
detailId,
|
|
166
|
-
action,
|
|
167
|
-
companyLogoUrl: void 0,
|
|
168
|
-
countryCode: void 0,
|
|
169
|
-
fetchProducts,
|
|
170
|
-
fetchProduct,
|
|
171
|
-
onNavigate: handleNavigate,
|
|
172
|
-
onBack: handleBack
|
|
173
|
-
})
|
|
174
|
-
})
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
const shareablesScreenPropertySchema = {
|
|
178
|
-
widgetType: "ShareablesScreen",
|
|
179
|
-
displayName: "Shareables Screen",
|
|
180
|
-
tabsConfig: [{
|
|
181
|
-
id: "styling",
|
|
182
|
-
label: "Styling"
|
|
183
|
-
}],
|
|
184
|
-
fields: []
|
|
185
|
-
};
|
|
186
|
-
//#endregion
|
|
187
|
-
Object.defineProperty(exports, "ShareablesScreen", {
|
|
188
|
-
enumerable: true,
|
|
189
|
-
get: function() {
|
|
190
|
-
return ShareablesScreen;
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
Object.defineProperty(exports, "shareablesScreenPropertySchema", {
|
|
194
|
-
enumerable: true,
|
|
195
|
-
get: function() {
|
|
196
|
-
return shareablesScreenPropertySchema;
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
//# sourceMappingURL=ShareablesScreen-Co_gFZva.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShareablesScreen-Co_gFZva.cjs","names":["PortalProductsApiProvider","PortalContentApiProvider","usePortalContentContext","useFilePickerApi","useAccount","useStore","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 { fluidToast } from \"@fluid-app/ui-primitives\";\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 { useStore } from \"../hooks/use-store\";\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 { data: store } = useStore();\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, sort?: string) => {\n if (search) {\n return portalProductsApi.searchProducts(search, { cursor, limit });\n }\n return portalProductsApi.listProducts({ cursor, limit, sort });\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: { logo_url: store?.logo_url ?? null },\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 error?: unknown;\n }) => {\n fluidToast({ title: opts.title, type: opts.type });\n if (opts.error) console.error(\"[Shareables]\", opts.error);\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 onMySiteShare: async (params: {\n shareLink: string;\n relateable_id: number;\n relateable_type: string;\n }) => {\n await toggleFavorite(\n client,\n params.relateable_id,\n params.relateable_type,\n );\n void queryClient.invalidateQueries({\n queryKey: PORTAL_MYSITE_KEYS.favorites(),\n });\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 (\n query: string,\n options?: { cursor?: string | null; limit?: number },\n ) => {\n // Empty query → listProducts so the tag modal opens with\n // suggestions instead of a blank state. Non-empty → real search.\n // Both APIs forward cursor/limit so the tag modal can paginate.\n const limit = options?.limit ?? 25;\n const cursor = options?.cursor ?? undefined;\n const result =\n query.trim().length > 0\n ? await portalProductsApi.searchProducts(query, {\n cursor,\n limit,\n })\n : await portalProductsApi.listProducts({ cursor, limit });\n // Filter out products without an id — mapping an id-less record\n // to `id: 0` would let a subsequent add/remove tag operation\n // silently run on id=0 (confusing 404/422 at best, incorrect\n // mutation at worst).\n const mapped = (result.products ?? [])\n .map(\n (p: {\n id?: number;\n title?: string;\n name?: string;\n image_url?: string | null;\n price?: string | null;\n }) =>\n p.id != null\n ? {\n id: p.id,\n name: p.name ?? p.title ?? \"Untitled\",\n image_url: p.image_url ?? null,\n price: p.price ?? null,\n }\n : null,\n )\n .filter((p): p is NonNullable<typeof p> => p !== null);\n return {\n products: mapped,\n nextCursor: result.meta?.pagination?.next_cursor ?? null,\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 const url = response.asset?.default_variant_url;\n if (!url) {\n // DAM accepted the upload but didn't return a playable URL.\n // Throwing here lets the caller (MediaEditScreen catch handler)\n // surface a toast and keeps the pending thumbnail state clean —\n // returning \"\" silently would corrupt the save payload with an\n // empty thumbnail URL.\n throw new Error(\"Thumbnail upload succeeded but no URL returned\");\n }\n return url;\n },\n }),\n [\n account,\n store,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,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,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import "./account-api-context-BIZ_aibJ.mjs";
|
|
3
|
-
import "./store-api-context-C1lXT_3d.mjs";
|
|
4
|
-
import "./mysite-api-context-bXtZ8Gbm.mjs";
|
|
5
|
-
import "./src-BEKH1DXO.mjs";
|
|
6
|
-
import "./ScreenHeaderContext-BDjNSUfr.mjs";
|
|
7
|
-
import "./dist-D39Yezrv.mjs";
|
|
8
|
-
import "./SearchSort-DXBt-uj0.mjs";
|
|
9
|
-
import "./dist-Cis8L6HV.mjs";
|
|
10
|
-
import "./PortalContentApiProvider-x81DXmOR.mjs";
|
|
11
|
-
import "./sortable.esm-CJLSD-Ce.mjs";
|
|
12
|
-
import "./PortalProductsApiProvider-CE71zDj9.mjs";
|
|
13
|
-
import "./use-mysite-portal-D29HLD1z.mjs";
|
|
14
|
-
import { n as shareablesScreenPropertySchema, t as ShareablesScreen } from "./ShareablesScreen-tkaf9R5N.mjs";
|
|
15
|
-
export { ShareablesScreen, shareablesScreenPropertySchema };
|