@fluid-app/portal-sdk 0.1.237 → 0.1.239

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.
Files changed (134) hide show
  1. package/dist/{CalendarWidget-BaGML5Xh.mjs → CalendarWidget-BXxNxHDV.mjs} +2 -2
  2. package/dist/{CalendarWidget-BaGML5Xh.mjs.map → CalendarWidget-BXxNxHDV.mjs.map} +1 -1
  3. package/dist/{CalendarWidget-oGK122s9.cjs → CalendarWidget-VjQXZW8B.cjs} +2 -2
  4. package/dist/{CalendarWidget-oGK122s9.cjs.map → CalendarWidget-VjQXZW8B.cjs.map} +1 -1
  5. package/dist/{CardWidget-CqYjGkq-.mjs → CardWidget-BNkMlxQ3.mjs} +2 -2
  6. package/dist/{CardWidget-CqYjGkq-.mjs.map → CardWidget-BNkMlxQ3.mjs.map} +1 -1
  7. package/dist/{CardWidget-CSLSlKM6.cjs → CardWidget-C3I9OwgS.cjs} +2 -2
  8. package/dist/{CardWidget-CSLSlKM6.cjs.map → CardWidget-C3I9OwgS.cjs.map} +1 -1
  9. package/dist/{CardWidget-DjhK0yr-.cjs → CardWidget-CraWMttj.cjs} +3 -3
  10. package/dist/{CarouselWidget-DlxYQB5j.cjs → CarouselWidget-CiKlooUF.cjs} +2 -2
  11. package/dist/{CarouselWidget-DlxYQB5j.cjs.map → CarouselWidget-CiKlooUF.cjs.map} +1 -1
  12. package/dist/{CarouselWidget-CdQhlRrW.mjs → CarouselWidget-p8Z6L-G5.mjs} +2 -2
  13. package/dist/{CarouselWidget-CdQhlRrW.mjs.map → CarouselWidget-p8Z6L-G5.mjs.map} +1 -1
  14. package/dist/{CatchUpWidget-BQjtjcGR.mjs → CatchUpWidget-B9DQlzd_.mjs} +2 -2
  15. package/dist/{CatchUpWidget-BQjtjcGR.mjs.map → CatchUpWidget-B9DQlzd_.mjs.map} +1 -1
  16. package/dist/{CatchUpWidget-B1Muaurg.cjs → CatchUpWidget-SY7hOHk6.cjs} +2 -2
  17. package/dist/{CatchUpWidget-B1Muaurg.cjs.map → CatchUpWidget-SY7hOHk6.cjs.map} +1 -1
  18. package/dist/{ContainerWidget-Cjwrq2MS.cjs → ContainerWidget-BXpdj06u.cjs} +2 -2
  19. package/dist/{ContainerWidget-Cjwrq2MS.cjs.map → ContainerWidget-BXpdj06u.cjs.map} +1 -1
  20. package/dist/{ContainerWidget-DYThUtiZ.mjs → ContainerWidget-CpwvcxFm.mjs} +2 -2
  21. package/dist/{ContainerWidget-DYThUtiZ.mjs.map → ContainerWidget-CpwvcxFm.mjs.map} +1 -1
  22. package/dist/ContainerWidget-CyfPYEAv.cjs +8 -0
  23. package/dist/{FluidProvider-BazvsIwu.mjs → FluidProvider-DL5rChtj.mjs} +67 -84
  24. package/dist/FluidProvider-DL5rChtj.mjs.map +1 -0
  25. package/dist/{FluidProvider-Dxn7Ehiz.cjs → FluidProvider-D_PHVlUU.cjs} +67 -84
  26. package/dist/FluidProvider-D_PHVlUU.cjs.map +1 -0
  27. package/dist/{ImageWidget-xcE0sFf-.cjs → ImageWidget-CbQVxMe3.cjs} +2 -2
  28. package/dist/{ImageWidget-xcE0sFf-.cjs.map → ImageWidget-CbQVxMe3.cjs.map} +1 -1
  29. package/dist/{ImageWidget-CFTpbu8X.mjs → ImageWidget-vNWT_O1E.mjs} +2 -2
  30. package/dist/{ImageWidget-CFTpbu8X.mjs.map → ImageWidget-vNWT_O1E.mjs.map} +1 -1
  31. package/dist/{LayoutWidget-CK-SvFQL.cjs → LayoutWidget-BIfNHlVE.cjs} +2 -2
  32. package/dist/{LayoutWidget-CK-SvFQL.cjs.map → LayoutWidget-BIfNHlVE.cjs.map} +1 -1
  33. package/dist/{LayoutWidget-Cx5ZyXSU.mjs → LayoutWidget-CC3oK78H.mjs} +2 -2
  34. package/dist/{LayoutWidget-Cx5ZyXSU.mjs.map → LayoutWidget-CC3oK78H.mjs.map} +1 -1
  35. package/dist/{LayoutWidget-DuueFNAS.cjs → LayoutWidget-LdF_cKrB.cjs} +3 -3
  36. package/dist/{LinkWidget-B14FTQP7.cjs → LinkWidget-BoR7nVbH.cjs} +2 -2
  37. package/dist/{LinkWidget-B14FTQP7.cjs.map → LinkWidget-BoR7nVbH.cjs.map} +1 -1
  38. package/dist/{LinkWidget-CQHmKO-O.mjs → LinkWidget-CO-Cxf7Z.mjs} +2 -2
  39. package/dist/{LinkWidget-CQHmKO-O.mjs.map → LinkWidget-CO-Cxf7Z.mjs.map} +1 -1
  40. package/dist/{LinkWidget-CPmE8gpd.cjs → LinkWidget-M9YzMJT8.cjs} +2 -2
  41. package/dist/{ListWidget-YvCp7XDq.cjs → ListWidget-CuSjvwEw.cjs} +3 -3
  42. package/dist/{ListWidget-wBDnXWxa.cjs → ListWidget-CzljZ1LA.cjs} +3 -3
  43. package/dist/{ListWidget-wBDnXWxa.cjs.map → ListWidget-CzljZ1LA.cjs.map} +1 -1
  44. package/dist/{ListWidget-BnyD2Hpc.mjs → ListWidget-f88QhcGI.mjs} +3 -3
  45. package/dist/{ListWidget-BnyD2Hpc.mjs.map → ListWidget-f88QhcGI.mjs.map} +1 -1
  46. package/dist/{MediaRenderer-CfgWd0cC.cjs → MediaRenderer-CvN8Ku0i.cjs} +4 -4
  47. package/dist/MediaRenderer-CvN8Ku0i.cjs.map +1 -0
  48. package/dist/{MediaRenderer-CqUpv3St.mjs → MediaRenderer-DMdb_5xw.mjs} +4 -4
  49. package/dist/MediaRenderer-DMdb_5xw.mjs.map +1 -0
  50. package/dist/{MessagingScreen-40YCQbX9.cjs → MessagingScreen-Dkh3Dsp7.cjs} +2 -2
  51. package/dist/{MessagingScreen-40YCQbX9.cjs.map → MessagingScreen-Dkh3Dsp7.cjs.map} +1 -1
  52. package/dist/{MessagingScreen-CrdiB4M3.cjs → MessagingScreen-Dxy2VQbO.cjs} +22 -22
  53. package/dist/{MessagingScreen-RItZgONw.mjs → MessagingScreen-mt1u3Bs1.mjs} +2 -2
  54. package/dist/{MessagingScreen-RItZgONw.mjs.map → MessagingScreen-mt1u3Bs1.mjs.map} +1 -1
  55. package/dist/{MySiteWidget-B0dc_7Dc.mjs → MySiteWidget-BnjPrQxE.mjs} +23 -30
  56. package/dist/MySiteWidget-BnjPrQxE.mjs.map +1 -0
  57. package/dist/{MySiteWidget-BkqAS0aY.cjs → MySiteWidget-C8eFWHOT.cjs} +23 -30
  58. package/dist/MySiteWidget-C8eFWHOT.cjs.map +1 -0
  59. package/dist/{NestedWidget-C_2XwnW0.cjs → NestedWidget-CEoAO2sp.cjs} +3 -3
  60. package/dist/{NestedWidget-C_2XwnW0.cjs.map → NestedWidget-CEoAO2sp.cjs.map} +1 -1
  61. package/dist/{NestedWidget-CXIvsJdD.cjs → NestedWidget-CMCZjV6t.cjs} +3 -3
  62. package/dist/{NestedWidget-WJoWOFda.mjs → NestedWidget-RuyrOrFn.mjs} +3 -3
  63. package/dist/{NestedWidget-WJoWOFda.mjs.map → NestedWidget-RuyrOrFn.mjs.map} +1 -1
  64. package/dist/{PointsWidget-DoUljaNY.mjs → PointsWidget-C2KB4k48.mjs} +2 -2
  65. package/dist/{PointsWidget-DoUljaNY.mjs.map → PointsWidget-C2KB4k48.mjs.map} +1 -1
  66. package/dist/{PointsWidget-CLUWrFjZ.cjs → PointsWidget-DLp-PYus.cjs} +2 -2
  67. package/dist/{PointsWidget-CLUWrFjZ.cjs.map → PointsWidget-DLp-PYus.cjs.map} +1 -1
  68. package/dist/{ProfileScreen-CEKbhSRz.cjs → ProfileScreen-BMe-dQi7.cjs} +2 -2
  69. package/dist/{ProfileScreen-CEKbhSRz.cjs.map → ProfileScreen-BMe-dQi7.cjs.map} +1 -1
  70. package/dist/{ProfileScreen-Dex8VHSB.cjs → ProfileScreen-ChCZZ91o.cjs} +22 -22
  71. package/dist/{ProfileScreen-CeD1jq89.mjs → ProfileScreen-_1GlBr7z.mjs} +2 -2
  72. package/dist/{ProfileScreen-CeD1jq89.mjs.map → ProfileScreen-_1GlBr7z.mjs.map} +1 -1
  73. package/dist/{RecentActivityWidget-C6RwlUUw.cjs → RecentActivityWidget-BNW9aFT4.cjs} +2 -2
  74. package/dist/{RecentActivityWidget-C6RwlUUw.cjs.map → RecentActivityWidget-BNW9aFT4.cjs.map} +1 -1
  75. package/dist/{RecentActivityWidget-zQxtUECm.mjs → RecentActivityWidget-DelPdiwR.mjs} +2 -2
  76. package/dist/{RecentActivityWidget-zQxtUECm.mjs.map → RecentActivityWidget-DelPdiwR.mjs.map} +1 -1
  77. package/dist/{ScreenRenderer-Bk23YOtN.mjs → ScreenRenderer-ClYgfQf_.mjs} +2 -2
  78. package/dist/{ScreenRenderer-Bk23YOtN.mjs.map → ScreenRenderer-ClYgfQf_.mjs.map} +1 -1
  79. package/dist/{ScreenRenderer-aYfgv6mR.cjs → ScreenRenderer-Ct1w4PNu.cjs} +2 -2
  80. package/dist/{ScreenRenderer-aYfgv6mR.cjs.map → ScreenRenderer-Ct1w4PNu.cjs.map} +1 -1
  81. package/dist/{ShareablesScreen-Bt0E1aya.cjs → ShareablesScreen-A69L0Nok.cjs} +136 -108
  82. package/dist/ShareablesScreen-A69L0Nok.cjs.map +1 -0
  83. package/dist/{ShareablesScreen-LSyiDa6q.cjs → ShareablesScreen-BUYG-mjj.cjs} +1 -1
  84. package/dist/{ShareablesScreen-D3Hfqg9-.mjs → ShareablesScreen-sieWBlAl.mjs} +136 -108
  85. package/dist/ShareablesScreen-sieWBlAl.mjs.map +1 -0
  86. package/dist/{ShopScreen-dAe71cdL.mjs → ShopScreen-BBfOte5o.mjs} +2 -2
  87. package/dist/{ShopScreen-dAe71cdL.mjs.map → ShopScreen-BBfOte5o.mjs.map} +1 -1
  88. package/dist/{ShopScreen-Cgro0M1d.cjs → ShopScreen-CZ_290EP.cjs} +22 -22
  89. package/dist/{ShopScreen-BiqZPyiB.cjs → ShopScreen-DWLGH2gt.cjs} +2 -2
  90. package/dist/{ShopScreen-BiqZPyiB.cjs.map → ShopScreen-DWLGH2gt.cjs.map} +1 -1
  91. package/dist/{TableWidget-D4jQN-to.cjs → TableWidget-BIn1oRiJ.cjs} +4 -4
  92. package/dist/TableWidget-BIn1oRiJ.cjs.map +1 -0
  93. package/dist/{TableWidget-DWAYgQcl.cjs → TableWidget-C--8TSX7.cjs} +3 -3
  94. package/dist/{TableWidget-B0CRdzNf.mjs → TableWidget-dfUvhH0S.mjs} +4 -4
  95. package/dist/TableWidget-dfUvhH0S.mjs.map +1 -0
  96. package/dist/{ToDoWidget-BbeXt99H.cjs → ToDoWidget-Bjoan2Rm.cjs} +2 -2
  97. package/dist/{ToDoWidget-BbeXt99H.cjs.map → ToDoWidget-Bjoan2Rm.cjs.map} +1 -1
  98. package/dist/{ToDoWidget-VSaNmtWH.mjs → ToDoWidget-CYDsZA0Z.mjs} +2 -2
  99. package/dist/{ToDoWidget-VSaNmtWH.mjs.map → ToDoWidget-CYDsZA0Z.mjs.map} +1 -1
  100. package/dist/{ToDoWidget-YHmoDbVU.cjs → ToDoWidget-C_CvWdLi.cjs} +2 -2
  101. package/dist/{VideoWidget-Bc6ZAAaA.cjs → VideoWidget-CDcV0J5W.cjs} +2 -2
  102. package/dist/{VideoWidget-Bc6ZAAaA.cjs.map → VideoWidget-CDcV0J5W.cjs.map} +1 -1
  103. package/dist/{VideoWidget-DcWm239R.mjs → VideoWidget-Dj9wue7j.mjs} +2 -2
  104. package/dist/{VideoWidget-DcWm239R.mjs.map → VideoWidget-Dj9wue7j.mjs.map} +1 -1
  105. package/dist/WidgetInteractionContext-B1mELhQ_.mjs +28 -0
  106. package/dist/{WidgetInteractionContext-D0TJv70C.mjs.map → WidgetInteractionContext-B1mELhQ_.mjs.map} +1 -1
  107. package/dist/WidgetInteractionContext-DvPmzGqB.cjs +41 -0
  108. package/dist/{WidgetInteractionContext-Bs3LkFFH.cjs.map → WidgetInteractionContext-DvPmzGqB.cjs.map} +1 -1
  109. package/dist/index.cjs +84 -55
  110. package/dist/index.cjs.map +1 -1
  111. package/dist/index.d.cts.map +1 -1
  112. package/dist/index.d.mts.map +1 -1
  113. package/dist/index.mjs +84 -55
  114. package/dist/index.mjs.map +1 -1
  115. package/dist/{registry-context-BDH0vNHR.mjs → registry-context-BahYMRqn.mjs} +12 -20
  116. package/dist/registry-context-BahYMRqn.mjs.map +1 -0
  117. package/dist/{registry-context-C7-RLxVt.cjs → registry-context-bf52ZIJX.cjs} +12 -20
  118. package/dist/registry-context-bf52ZIJX.cjs.map +1 -0
  119. package/package.json +12 -12
  120. package/dist/ContainerWidget-NFBqSeRV.cjs +0 -8
  121. package/dist/FluidProvider-BazvsIwu.mjs.map +0 -1
  122. package/dist/FluidProvider-Dxn7Ehiz.cjs.map +0 -1
  123. package/dist/MediaRenderer-CfgWd0cC.cjs.map +0 -1
  124. package/dist/MediaRenderer-CqUpv3St.mjs.map +0 -1
  125. package/dist/MySiteWidget-B0dc_7Dc.mjs.map +0 -1
  126. package/dist/MySiteWidget-BkqAS0aY.cjs.map +0 -1
  127. package/dist/ShareablesScreen-Bt0E1aya.cjs.map +0 -1
  128. package/dist/ShareablesScreen-D3Hfqg9-.mjs.map +0 -1
  129. package/dist/TableWidget-B0CRdzNf.mjs.map +0 -1
  130. package/dist/TableWidget-D4jQN-to.cjs.map +0 -1
  131. package/dist/WidgetInteractionContext-Bs3LkFFH.cjs +0 -18
  132. package/dist/WidgetInteractionContext-D0TJv70C.mjs +0 -11
  133. package/dist/registry-context-BDH0vNHR.mjs.map +0 -1
  134. package/dist/registry-context-C7-RLxVt.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { n as useDataSourceRegistryConfig } from "./registry-context-BDH0vNHR.mjs";
1
+ import { n as useDataSourceRegistryConfig } from "./registry-context-BahYMRqn.mjs";
2
2
  import { createContext, memo, useCallback, useContext, useMemo, useRef } from "react";
3
3
  import { useQueries } from "@tanstack/react-query";
4
4
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -671,4 +671,4 @@ function ScreenRenderer(props) {
671
671
  //#endregion
672
672
  export { assertNever as a, useScreenRenderer as c, DataSourceApiProvider as d, assertDefined as i, RegistryProvider as l, DataAwareWidget as n, isWidgetType as o, WIDGET_TYPE_NAMES as r, isWidgetTypeName as s, ScreenRenderer as t, useRegistry as u };
673
673
 
674
- //# sourceMappingURL=ScreenRenderer-Bk23YOtN.mjs.map
674
+ //# sourceMappingURL=ScreenRenderer-ClYgfQf_.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScreenRenderer-Bk23YOtN.mjs","names":[],"sources":["../../core/src/data-source-api-context.ts","../../widgets/src/contexts/RegistryContext.tsx","../../widgets/src/contexts/ScreenRendererContext.tsx","../../core/src/types/widget-schema.ts","../../core/src/data-sources/presets.ts","../../react/src/data-sources/use-widget-data.ts","../../react/src/data-sources/ErrorState.tsx","../../react/src/data-sources/DataAwareWidget.tsx","../../widgets/src/core/ScreenRenderer.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { DataSourceApi } from \"./data-source-api\";\n\nconst DataSourceApiContext = createContext<DataSourceApi | null>(null);\n\nexport const DataSourceApiProvider = DataSourceApiContext.Provider;\n\n/**\n * Access the DataSourceApi adapter.\n * Throws if no DataSourceApiProvider ancestor exists.\n */\nexport function useDataSourceApi(): DataSourceApi {\n const api = useContext(DataSourceApiContext);\n if (!api) {\n throw new Error(\n \"useDataSourceApi must be used within a DataSourceApiProvider\",\n );\n }\n return api;\n}\n\n/**\n * Access the DataSourceApi adapter without throwing.\n * Returns null when no DataSourceApiProvider ancestor exists.\n * Use in isolated rendering contexts (Storybook, unit tests) where the\n * full provider stack may not be wired.\n */\nexport function useDataSourceApiOptional(): DataSourceApi | null {\n return useContext(DataSourceApiContext);\n}\n","import React, {\n createContext,\n useContext,\n type ComponentType,\n type ReactNode,\n} from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\n\n/**\n * Base props interface for widget components.\n * All widgets receive at least these props from the ScreenRenderer.\n */\nexport interface WidgetBaseProps {\n readonly widget: WidgetSchema;\n readonly path?: readonly number[];\n}\n\n/**\n * Generic widget component type.\n * Widgets receive WidgetBaseProps and may have additional props.\n */\nexport type WidgetComponent<P extends WidgetBaseProps = WidgetBaseProps> =\n ComponentType<P>;\n\n/**\n * Registry mapping widget type names to their components.\n * The keys are widget type strings (e.g., \"TextWidget\", \"ButtonWidget\").\n * Using WidgetComponent for the value type provides better type safety than `any`.\n */\nexport type WidgetRegistry = Readonly<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Widget props vary by type\n Record<string, WidgetComponent<any>>\n>;\n\n/**\n * Context for providing the widget registry to all components in the tree.\n * This eliminates prop drilling and makes the registry accessible anywhere.\n *\n * Default to undefined - registry must be provided by a RegistryProvider.\n */\nexport const RegistryContext: React.Context<WidgetRegistry | undefined> =\n createContext<WidgetRegistry | undefined>(undefined);\n\nexport interface RegistryProviderProps {\n registry?: WidgetRegistry;\n children: ReactNode;\n}\n\n/**\n * Provider component that makes the widget registry available to all descendants.\n * A registry must be provided either via props or by nesting within another RegistryProvider.\n */\nexport function RegistryProvider({\n registry,\n children,\n}: RegistryProviderProps): React.JSX.Element {\n // If no registry provided, inherit from parent provider\n const parentRegistry = useContext(RegistryContext);\n const contextValue = registry ?? parentRegistry;\n\n if (!contextValue) {\n throw new Error(\n \"RegistryProvider requires a registry prop or must be nested within another RegistryProvider.\",\n );\n }\n\n return (\n <RegistryContext.Provider value={contextValue}>\n {children}\n </RegistryContext.Provider>\n );\n}\n\n/**\n * Hook to access the widget registry from anywhere in the component tree.\n * Must be used within a RegistryProvider that has a registry prop.\n */\nexport function useRegistry(): WidgetRegistry {\n const registry = useContext(RegistryContext);\n\n if (!registry) {\n throw new Error(\n \"useRegistry must be used within a RegistryProvider with a registry prop.\",\n );\n }\n\n return registry;\n}\n","import React, { createContext, useContext, type ComponentType } from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\nimport type { WidgetRegistry } from \"./RegistryContext\";\n\n/**\n * Props that any ScreenRenderer must accept.\n * This is the minimal interface used by container widgets (e.g. LayoutWidget)\n * to render their children.\n */\nexport interface ScreenRendererComponentProps {\n screen: WidgetSchema[];\n registry?: WidgetRegistry;\n className?: string;\n}\n\n/**\n * Context for providing an alternative ScreenRenderer component.\n *\n * This allows packages like portal-builder to inject their own ScreenRenderer\n * (with edit mode, drag-and-drop, etc.) so that container widgets in portal-widgets\n * use the richer renderer instead of the basic view-only one.\n *\n * Default is undefined — container widgets fall back to the local ScreenRenderer import.\n */\nexport const ScreenRendererContext: React.Context<\n ComponentType<ScreenRendererComponentProps> | undefined\n> = createContext<ComponentType<ScreenRendererComponentProps> | undefined>(\n undefined,\n);\n\n/**\n * Hook to get the ScreenRenderer component from context.\n * Returns undefined if no override has been provided.\n */\nexport function useScreenRenderer():\n | ComponentType<ScreenRendererComponentProps>\n | undefined {\n return useContext(ScreenRendererContext);\n}\n","import type { DataSourceConfig } from \"../data-sources/types\";\n\n/**\n * Generic component type — avoids React dependency in core.\n * Accepts both function components and class component constructors.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyComponent = ((props: any) => any) | (new (props: any) => any);\n\n/**\n * Widget type names as a const object.\n * This serves as the single source of truth for widget discriminants.\n * Use `as const` for literal type inference (safety-as-const-deep-readonly rule).\n */\nexport const WIDGET_TYPE_NAMES = {\n Alert: \"AlertWidget\",\n BulletList: \"BulletListWidget\",\n Calendar: \"CalendarWidget\",\n Card: \"CardWidget\",\n Carousel: \"CarouselWidget\",\n CatchUp: \"CatchUpWidget\",\n Chart: \"ChartWidget\",\n Container: \"ContainerWidget\",\n Embed: \"EmbedWidget\",\n Image: \"ImageWidget\",\n Layout: \"LayoutWidget\",\n Link: \"LinkWidget\",\n List: \"ListWidget\",\n MySite: \"MySiteWidget\",\n Nested: \"NestedWidget\",\n Points: \"PointsWidget\",\n QuickLinks: \"QuickLinksWidget\",\n QuickShare: \"QuickShareWidget\",\n RecentActivity: \"RecentActivityWidget\",\n Separator: \"SeparatorWidget\",\n Spacer: \"SpacerWidget\",\n Table: \"TableWidget\",\n Text: \"TextWidget\",\n ToDo: \"ToDoWidget\",\n Video: \"VideoWidget\",\n} as const;\n\n/**\n * Union of all known widget type names.\n * Derived from WIDGET_TYPE_NAMES to avoid duplication (deriving-typeof-for-object-keys rule).\n */\nexport type WidgetTypeName =\n (typeof WIDGET_TYPE_NAMES)[keyof typeof WIDGET_TYPE_NAMES];\n\n/**\n * Legacy alias for backwards compatibility.\n * Prefer using WidgetTypeName for new code when you need the union type.\n */\nexport type WidgetType = string;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type WidgetRegistry = Record<WidgetType, AnyComponent>;\n\n/**\n * Base widget schema with loose typing for runtime data.\n * Use TypedWidgetSchema<T> when you have a known registry for better type safety.\n */\nexport type WidgetSchema = {\n readonly type: WidgetType;\n readonly props: Readonly<Record<string, unknown>>;\n readonly id?: string; // Optional unique identifier for drag-and-drop\n /** Optional data source configuration for data-bound widgets */\n readonly dataSource?: DataSourceConfig | undefined;\n /** Column index for masonry layouts (0-indexed) */\n readonly columnIndex?: number;\n};\n\n/**\n * Type-safe widget schema based on registry.\n * Uses discriminated unions - the `type` field serves as discriminant.\n * When narrowed (e.g., `if (widget.type === \"AlertWidget\")`),\n * TypeScript automatically knows the correct props type.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type TypedWidgetSchema<T extends Record<string, AnyComponent>> = {\n [K in keyof T]: {\n readonly type: K;\n readonly props: Readonly<\n T[K] extends (props: infer P) => any\n ? P\n : T[K] extends new (props: infer P) => any\n ? P\n : never\n >;\n readonly id?: string;\n readonly dataSource?: DataSourceConfig | undefined;\n /** Column index for masonry layouts (0-indexed) */\n readonly columnIndex?: number;\n };\n}[keyof T];\n\n/**\n * Widget path in the tree - array of indices.\n * Readonly tuple to prevent accidental mutation.\n */\nexport type WidgetPath = readonly number[];\n\n// ============================================================================\n// Type Guards and Assertion Functions\n// ============================================================================\n\n/**\n * Type predicate to check if a string is a known widget type name.\n * Use for runtime validation of widget types.\n *\n * @example\n * if (isWidgetTypeName(widget.type)) {\n * // TypeScript knows widget.type is WidgetTypeName\n * }\n */\nexport function isWidgetTypeName(type: string): type is WidgetTypeName {\n // Type assertion required in type guard: Object.values() returns string[], but we\n // need to check against WidgetTypeName values. The assertion is safe because we're\n // checking membership, and the return type predicate ensures correct narrowing.\n return Object.values(WIDGET_TYPE_NAMES).includes(type as WidgetTypeName);\n}\n\n/**\n * Type predicate to check if a widget has a specific type.\n * Enables type-safe widget narrowing without `as` assertions.\n *\n * @example\n * if (isWidgetType(widget, \"LayoutWidget\")) {\n * // TypeScript knows widget.type === \"LayoutWidget\"\n * // and widget.props is LayoutWidget props\n * }\n */\nexport function isWidgetType<T extends WidgetTypeName>(\n widget: WidgetSchema | null | undefined,\n typeName: T,\n): widget is WidgetSchema & { readonly type: T } {\n return widget != null && widget.type === typeName;\n}\n\n/**\n * Helper for exhaustive switch statements on widget types.\n * Use in the default case to ensure all widget types are handled.\n *\n * @example\n * switch (widget.type) {\n * case \"AlertWidget\": return handleAlert();\n * case \"TextWidget\": return handleText();\n * // ... all other widget types\n * default: return assertNever(widget.type, \"widget type\");\n * }\n */\nexport function assertNever(value: never, context?: string): never {\n const message = context\n ? `Unexpected ${context}: ${String(value)}`\n : `Unexpected value: ${String(value)}`;\n throw new Error(message);\n}\n\n/**\n * Assertion function that throws if value is undefined.\n * Narrows the type to exclude undefined.\n *\n * @example\n * const widget = screen[0];\n * assertDefined(widget, \"widget at index 0\");\n * // TypeScript knows widget is defined here\n */\nexport function assertDefined<T>(\n value: T | undefined | null,\n name?: string,\n): asserts value is T {\n if (value == null) {\n throw new Error(name ? `${name} is required` : \"Value is required\");\n }\n}\n","/**\n * Data Source Presets Registry\n *\n * Configurable presets that allow users to select options via sub-menus\n * and fine-tune parameters in a detail panel.\n */\n\nimport type {\n SelectFieldSchema,\n NumberFieldSchema,\n} from \"../registries/property-schema-types\";\nimport type { DataSource } from \"./types\";\n\n/** Widget types that can use data sources */\nexport type DataSourceCompatibleWidget =\n | \"CarouselWidget\"\n | \"ChartWidget\"\n | \"EmbedWidget\"\n | \"ImageWidget\"\n | \"ListWidget\"\n | \"NestedWidget\"\n | \"TableWidget\"\n | \"VideoWidget\";\n\n/** Field types supported in preset config panels */\nexport type PresetConfigField = SelectFieldSchema<string> | NumberFieldSchema;\n\n/** A preset data source configuration */\nexport interface DataSourcePreset {\n /** Unique identifier for the preset */\n id: string;\n /** Human-readable name for display */\n name: string;\n /** Description of what data this endpoint provides */\n description: string;\n /** The API endpoint path (can include {variable} placeholders) */\n endpoint: string;\n /** Transformer name to apply to the data */\n transform?: string;\n /** Optional path to extract data from response (e.g., \"data.items\") */\n resultPath?: string;\n /** Which widgets this preset is compatible with */\n compatibleWidgets: DataSourceCompatibleWidget[];\n /** Optional select field shown as a sub-menu. The field's key becomes a variable in the endpoint URL. */\n menuField?: SelectFieldSchema<string>;\n /** Optional config fields rendered in the detail panel below the popover. Each field's key becomes a variable. */\n configFields?: PresetConfigField[];\n}\n\n/**\n * Pre-configured data source presets\n */\nexport const DATA_SOURCE_PRESETS: DataSourcePreset[] = [\n {\n id: \"rep-most-shared\",\n name: \"Most Shared Visits\",\n description: \"Content with the most share-link click-throughs\",\n endpoint:\n \"/v2025-06/reps/{rep_id}/most_shared?shareable_type={shareable_type}&limit={limit}&period={period}&language_iso={language_iso}\",\n resultPath: \"resources\",\n compatibleWidgets: [\n \"CarouselWidget\",\n \"ListWidget\",\n \"NestedWidget\",\n \"TableWidget\",\n ],\n menuField: {\n key: \"shareable_type\",\n label: \"Content Type\",\n type: \"select\",\n options: [\n { label: \"Products\", value: \"products\" },\n { label: \"Media\", value: \"media\" },\n { label: \"Pages\", value: \"pages\" },\n { label: \"Libraries\", value: \"libraries\" },\n { label: \"Enrollment Packs\", value: \"enrollment_packs\" },\n ],\n defaultValue: \"products\",\n },\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 20,\n description: \"Maximum number of items to show\",\n },\n {\n key: \"period\",\n label: \"Time Range\",\n type: \"select\",\n options: [\n { label: \"7 days\", value: \"7d\" },\n { label: \"30 days\", value: \"30d\" },\n { label: \"90 days\", value: \"90d\" },\n { label: \"1 year\", value: \"1y\" },\n { label: \"All time\", value: \"all\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n {\n id: \"rep-most-viewed\",\n name: \"Most Viewed\",\n description: \"Most viewed content\",\n endpoint:\n \"/v2025-06/reps/{rep_id}/most_viewed?shareable_type={shareable_type}&limit={limit}&period={period}&language_iso={language_iso}\",\n resultPath: \"resources\",\n compatibleWidgets: [\n \"CarouselWidget\",\n \"ListWidget\",\n \"NestedWidget\",\n \"TableWidget\",\n ],\n menuField: {\n key: \"shareable_type\",\n label: \"Content Type\",\n type: \"select\",\n options: [\n { label: \"Products\", value: \"products\" },\n { label: \"Media\", value: \"media\" },\n { label: \"Pages\", value: \"pages\" },\n { label: \"Libraries\", value: \"libraries\" },\n { label: \"Enrollment Packs\", value: \"enrollment_packs\" },\n ],\n defaultValue: \"products\",\n },\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 20,\n description: \"Maximum number of items to show\",\n },\n {\n key: \"period\",\n label: \"Time Range\",\n type: \"select\",\n options: [\n { label: \"7 days\", value: \"7d\" },\n { label: \"30 days\", value: \"30d\" },\n { label: \"90 days\", value: \"90d\" },\n { label: \"1 year\", value: \"1y\" },\n { label: \"All time\", value: \"all\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n {\n id: \"customer-orders\",\n name: \"Orders\",\n description: \"Customer order history\",\n endpoint:\n \"/v202506/orders?customer_id={customer_id}&page[limit]={limit}&status={status}\",\n resultPath: \"orders\",\n transform: \"toOrderTableProps\",\n compatibleWidgets: [\"TableWidget\"],\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 50,\n description: \"Maximum number of orders to show\",\n },\n {\n key: \"status\",\n label: \"Status\",\n type: \"select\",\n options: [\n { label: \"All\", value: \"all\" },\n { label: \"Paid\", value: \"paid\" },\n { label: \"Unpaid\", value: \"unpaid\" },\n { label: \"Refunded\", value: \"refunded\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n {\n id: \"customer-subscriptions\",\n name: \"Subscriptions\",\n description: \"Customer subscriptions\",\n // Subscriptions endpoint is unversioned (legacy API), orders uses v202506\n endpoint:\n \"/subscriptions?customer_id={customer_id}&per_page={limit}&status={status}\",\n resultPath: \"subscriptions\",\n transform: \"toSubscriptionTableProps\",\n compatibleWidgets: [\"TableWidget\"],\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 50,\n description: \"Maximum number of subscriptions to show\",\n },\n {\n key: \"status\",\n label: \"Status\",\n type: \"select\",\n options: [\n { label: \"All\", value: \"all\" },\n { label: \"Active\", value: \"active\" },\n { label: \"Paused\", value: \"paused\" },\n { label: \"Cancelled\", value: \"cancelled\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n];\n\n/** Lookup map for O(1) preset resolution */\nconst PRESET_MAP = new Map<string, DataSourcePreset>(\n DATA_SOURCE_PRESETS.map((p) => [p.id, p]),\n);\n\n/**\n * Resolves a preset by ID, returning the current preset definition.\n * Returns undefined if the preset ID is not recognized.\n */\nexport function resolvePreset(presetId: string): DataSourcePreset | undefined {\n return PRESET_MAP.get(presetId);\n}\n\n/**\n * If the source is an API source with a presetId, returns a copy with\n * endpoint, resultPath, and transform resolved from the current preset.\n * Falls back to stored values if the preset is unknown.\n * Non-API sources are returned as-is.\n */\nexport function resolveSource<T extends DataSource>(source: T): T {\n if (source.type !== \"api\" || !source.presetId) return source;\n\n const preset = resolvePreset(source.presetId);\n if (!preset) {\n console.warn(\n `[DataSource] Unknown preset \"${source.presetId}\", falling back to stored values`,\n );\n return source;\n }\n\n return {\n ...source,\n endpoint: preset.endpoint,\n resultPath: preset.resultPath,\n transform: preset.transform ?? source.transform,\n } as T;\n}\n","import { useQueries } from \"@tanstack/react-query\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\nimport type {\n DataSourceRegistry,\n WidgetDataResult,\n DataSourceContext,\n DataSource,\n} from \"@fluid-app/portal-core/data-sources/types\";\nimport { resolveSource } from \"@fluid-app/portal-core/data-sources/presets\";\nimport { useDataSourceApiOptional } from \"@fluid-app/portal-core/data-source-api-context\";\nimport { useDataSourceRegistryConfig } from \"./registry-context\";\n\ninterface UseWidgetDataOptions {\n /** Override the default registry from context */\n registry?: DataSourceRegistry | undefined;\n /** Base URL for API calls (e.g., \"https://api.fluid.app/api\") */\n baseUrl?: string | undefined;\n}\n\n/**\n * Generates a cache key for the raw data fetch (endpoint/items identity only).\n * Transforms and targetProps are NOT included — they are applied per-widget\n * after reading from the shared cache.\n */\nfunction getSourceKey(source: DataSource): string {\n if (source.type === \"api\") {\n const varsKey = source.variables\n ? `:${JSON.stringify(source.variables)}`\n : \"\";\n // Use presetId as identity when available — keeps cache key stable across preset endpoint changes\n const identity = source.presetId ?? source.endpoint;\n return `${identity}${varsKey}`;\n }\n if (source.type === \"custom\") {\n const itemKeys =\n source.selectedItems?.map((item) => {\n return `${item.shareableType}:${item.id}`;\n }) ?? [];\n return `custom:${itemKeys.join(\",\")}`;\n }\n if (source.type === \"static\") {\n return `static:${source.staticType}:${source.selectedId}`;\n }\n return \"unknown\";\n}\n\n/**\n * Resolves cached raw data into widget props by applying each widget's own\n * transforms and targetProps mapping.\n */\nfunction resolvePropsFromQueries<T>(\n queryResults: ReadonlyArray<{\n data?: unknown;\n isLoading: boolean;\n error: Error | null;\n }>,\n sources: DataSource[],\n registry: DataSourceRegistry,\n errorConfig?: { fallback?: unknown },\n): T | undefined {\n if (sources.length === 0) return undefined;\n if (queryResults.some((q) => q.isLoading && !q.data)) return undefined;\n\n const failedQuery = queryResults.find((q) => q.error);\n const hasError = !!failedQuery?.error;\n\n if (hasError && errorConfig?.fallback) {\n return errorConfig.fallback as T;\n }\n\n if (hasError) {\n return undefined;\n }\n\n const resolvedProps: Record<string, unknown> = {};\n\n for (let i = 0; i < queryResults.length; i++) {\n const query = queryResults[i];\n const source = sources[i];\n if (!query?.data || !source) continue;\n\n // Sentry fix: FLUID-ADMIN-1DH — source or targetProps can be undefined from malformed widget config\n if (!source.targetProps) continue;\n\n // Apply this widget's transform to the cached raw data\n let result: unknown = query.data;\n if (source.transform) {\n const transformer = registry.transformers[source.transform];\n if (transformer) {\n result = transformer(result, source);\n } else {\n console.warn(`Transform \"${source.transform}\" not found in registry`);\n }\n }\n\n // Map to this widget's targetProps\n if (\n result !== null &&\n typeof result === \"object\" &&\n !Array.isArray(result) &&\n source.targetProps.length > 1\n ) {\n const resultObj = result as Record<string, unknown>;\n for (const prop of source.targetProps) {\n if (prop in resultObj) {\n resolvedProps[prop] = resultObj[prop];\n }\n }\n } else {\n for (const prop of source.targetProps) {\n resolvedProps[prop] = result;\n }\n }\n }\n\n return resolvedProps as T;\n}\n\n/**\n * Hook that fetches and resolves data sources for a widget using React Query.\n *\n * Raw API data is cached and shared across widgets with the same data source.\n * Transforms and targetProps mapping are applied per-widget after cache reads,\n * so multiple widgets can share one fetch but resolve data independently.\n */\nexport function useWidgetData<T = Record<string, unknown>>(\n widget: WidgetSchema,\n options?: UseWidgetDataOptions,\n): WidgetDataResult<T> {\n const config = useDataSourceRegistryConfig();\n const registry = options?.registry ?? config.registry;\n const baseUrl = options?.baseUrl ?? config.baseUrl;\n const getApiHeaders = config.getApiHeaders;\n const variables = config.variables;\n // useDataSourceApiOptional returns null outside a DataSourceApiProvider.\n // This allows widgets with zero data sources to render in isolation\n // (Storybook, unit tests). Fetchers that require api will throw at call\n // time if it's missing — not at render time for every widget.\n const api = useDataSourceApiOptional() ?? undefined;\n\n // Resolve preset-backed sources to their current endpoint/resultPath/transform\n const sources = useMemo(\n () => (widget.dataSource?.sources ?? []).map(resolveSource),\n [widget.dataSource?.sources],\n );\n const errorConfig = widget.dataSource?.error;\n const widgetId = widget.id ?? \"unknown\";\n const widgetType = widget.type;\n\n const queryResultsRef = useRef<Array<{ refetch: () => void }>>([]);\n\n // Cache only raw fetched data — no transforms or source objects stored\n const results = useQueries({\n queries: sources.map((source: DataSource) => ({\n queryKey: [\n \"portal-widget-data\",\n getSourceKey(source),\n baseUrl,\n variables,\n ] as const,\n queryFn: async ({\n signal,\n }: {\n signal: AbortSignal;\n }): Promise<unknown> => {\n const context: DataSourceContext = {\n widgetId,\n widgetType,\n signal,\n baseUrl,\n getApiHeaders,\n variables,\n api,\n };\n\n const fetcher = registry.fetchers[source.type];\n if (!fetcher) {\n throw new Error(\n `No fetcher registered for source type: ${source.type}`,\n );\n }\n\n return fetcher(source, context);\n },\n enabled: sources.length > 0,\n retry: errorConfig?.retryCount ?? 0,\n retryDelay: errorConfig?.retryDelay ?? 1000,\n refetchInterval: source.refreshInterval || false,\n })),\n });\n\n // Update ref for refetch callback\n queryResultsRef.current = results;\n\n // Aggregate loading state\n const isLoading = results.some((q) => q.isLoading);\n\n // Get first error from any failed query\n const failedQuery = results.find((q) => q.error);\n const error =\n failedQuery?.error instanceof Error\n ? failedQuery.error\n : failedQuery?.error\n ? new Error(String(failedQuery.error))\n : null;\n\n // Stable fingerprint that changes only when query data or loading states change\n const queryFingerprint = results\n .map((r) => `${r.dataUpdatedAt}:${r.isLoading}`)\n .join(\",\");\n\n // Resolve data: apply per-widget transforms and map to targetProps\n const resultsRef = useRef(results);\n resultsRef.current = results;\n\n const data = useMemo(() => {\n const querySnapshots = resultsRef.current.map((q) => ({\n data: q.data,\n isLoading: q.isLoading,\n error: q.error instanceof Error ? q.error : null,\n }));\n return resolvePropsFromQueries<T>(\n querySnapshots,\n sources,\n registry,\n errorConfig,\n );\n }, [queryFingerprint, sources, registry, errorConfig]);\n\n // Stable refetch callback using ref\n const refetch = useCallback(() => {\n queryResultsRef.current.forEach((q) => q.refetch());\n }, []);\n\n return {\n data,\n isLoading,\n error,\n refetch,\n };\n}\n","import type React from \"react\";\n\nexport function ErrorState(): React.JSX.Element {\n return (\n <div className=\"flex min-h-[120px] flex-col items-center justify-center p-6 text-center\">\n <p className=\"text-lg font-semibold\">Something Went Wrong</p>\n <p className=\"text-muted-foreground text-sm\">\n Please contact a company admin for help\n </p>\n </div>\n );\n}\n","import type React from \"react\";\nimport { memo, useMemo, type ComponentType, type ReactNode } from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\nimport { useWidgetData } from \"./use-widget-data\";\nimport { ErrorState } from \"./ErrorState\";\n\nexport interface DataAwareWidgetProps {\n widget: WidgetSchema;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Component: ComponentType<any>;\n /** Additional props to pass through (e.g., edit mode callbacks) */\n additionalProps?: Record<string, unknown>;\n /** Custom loading component */\n loadingComponent?: ReactNode;\n /** Custom error component */\n errorComponent?: (error: Error) => ReactNode;\n /** Base URL for API calls (e.g., \"https://api.fluid.app/api\") */\n baseUrl?: string | undefined;\n}\n\n// Empty object constant to avoid creating new references\nconst EMPTY_OBJECT: Record<string, unknown> = {};\n\n/**\n * Wrapper component that resolves data sources before rendering the widget.\n * Merges resolved data with static props.\n */\nfunction DataAwareWidgetImpl({\n widget,\n Component,\n additionalProps,\n loadingComponent,\n errorComponent,\n baseUrl,\n}: DataAwareWidgetProps): React.JSX.Element | null {\n // Use stable empty object if no additionalProps provided\n const stableAdditionalProps = additionalProps ?? EMPTY_OBJECT;\n const { data, isLoading, error } = useWidgetData(widget, { baseUrl });\n\n // Merge static props with resolved data\n // Data takes precedence (allows overriding defaults)\n // Memoized to prevent unnecessary child re-renders\n // Note: Must be called before any early returns to satisfy Rules of Hooks\n const mergedProps = useMemo(\n () => ({\n ...widget.props,\n ...data,\n ...stableAdditionalProps,\n }),\n [widget.props, data, stableAdditionalProps],\n );\n\n // Show loading state\n if (isLoading && widget.dataSource?.loading?.showSkeleton !== false) {\n if (loadingComponent) {\n return <>{loadingComponent}</>;\n }\n // Default skeleton - can be customized\n return (\n <div\n className=\"bg-muted animate-pulse rounded-md\"\n style={{ minHeight: 100 }}\n >\n <span className=\"sr-only\">Loading...</span>\n </div>\n );\n }\n\n // Show error state (if no fallback was applied)\n if (error && !data) {\n if (errorComponent) {\n return <>{errorComponent(error)}</>;\n }\n // Default error display\n return <ErrorState />;\n }\n\n return <Component {...mergedProps} />;\n}\n\n/**\n * Memoized wrapper component that resolves data sources before rendering the widget.\n * Prevents re-renders when parent re-renders but props haven't changed.\n */\nexport const DataAwareWidget: React.NamedExoticComponent<DataAwareWidgetProps> =\n memo(DataAwareWidgetImpl);\n","import type { ComponentType } from \"react\";\nimport { useCallback } from \"react\";\nimport type React from \"react\";\nimport type {\n WidgetSchema,\n TypedWidgetSchema,\n WidgetPath,\n} from \"@fluid-app/portal-core/types\";\nimport { WIDGET_TYPE_NAMES } from \"@fluid-app/portal-core/types\";\nimport { DataAwareWidget } from \"@fluid-app/portal-react/data-sources/DataAwareWidget\";\nimport { RegistryProvider, useRegistry } from \"../contexts/RegistryContext\";\n\nexport interface ScreenRendererProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, ComponentType<any>>,\n> {\n /** Array of widget schemas to render */\n screen: TypedWidgetSchema<T>[] | WidgetSchema[];\n /** Widget registry mapping type names to components */\n registry?: T;\n /** Container widgets (like LayoutWidget) receive these additional props */\n containerWidgetTypes?: string[];\n /** Additional CSS classes for the wrapper div */\n className?: string;\n}\n\ninterface ScreenRendererContentProps {\n screen: WidgetSchema[];\n containerWidgetTypes: string[];\n className?: string | undefined;\n}\n\n/**\n * Internal component that uses the registry from context.\n * This allows us to avoid prop drilling the registry.\n */\nfunction ScreenRendererContent({\n screen,\n containerWidgetTypes,\n className,\n}: ScreenRendererContentProps) {\n const registry = useRegistry();\n\n // Check if a widget type is a container\n const isContainerWidget = useCallback(\n (widgetType: string) => containerWidgetTypes.includes(widgetType),\n [containerWidgetTypes],\n );\n\n // Render widgets recursively with path tracking\n const renderWidget = useCallback(\n (widget: WidgetSchema, index: number, currentPath: WidgetPath) => {\n const Component = registry[widget.type];\n if (!Component) {\n console.warn(\n `Widget type \"${String(widget.type)}\" not found in registry`,\n );\n return null;\n }\n\n const widgetPath = [...currentPath, index];\n\n // Build additional props for container widgets\n const additionalProps = isContainerWidget(widget.type)\n ? {\n widgetId: widget.id,\n widgetPath,\n }\n : {};\n\n const props = {\n ...widget.props,\n ...additionalProps,\n };\n\n // Wrap data-bound widgets with DataAwareWidget to resolve data sources\n if (widget.dataSource) {\n return (\n <div\n key={widget.id || index}\n className=\"h-full w-full overflow-x-hidden\"\n >\n <DataAwareWidget widget={widget} Component={Component} />\n </div>\n );\n }\n\n return (\n <div\n key={widget.id || index}\n className=\"h-full w-full overflow-x-hidden\"\n >\n <Component {...props} />\n </div>\n );\n },\n [registry, isContainerWidget],\n );\n\n return (\n <div className={className || \"h-full w-full\"}>\n {screen?.map((item, index) => {\n // Skip null items (empty grid cells)\n if (!item) return null;\n return renderWidget(item, index, []);\n })}\n </div>\n );\n}\n\n/**\n * ScreenRenderer - View-only component for rendering widget screens.\n *\n * This is a simplified version designed for the SDK that only handles\n * rendering widgets without edit mode or drag-and-drop functionality.\n *\n * Features:\n * - Static rendering of widgets\n * - Registry context: No prop drilling for widget registry\n * - Container widget support with path tracking\n *\n * Usage:\n * ```tsx\n * import { ScreenRenderer } from '@fluid-app/portal-widgets/core';\n * import { WIDGET_REGISTRY } from '@fluid-app/portal-widgets/widgets';\n *\n * <ScreenRenderer\n * screen={widgets}\n * registry={WIDGET_REGISTRY}\n * />\n * ```\n */\nexport function ScreenRenderer<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, ComponentType<any>>,\n>(props: ScreenRendererProps<T>): React.JSX.Element {\n const {\n screen,\n registry,\n containerWidgetTypes = [\n WIDGET_TYPE_NAMES.Layout,\n WIDGET_TYPE_NAMES.Container,\n ],\n className,\n } = props;\n\n // Conditionally pass registry prop to satisfy exactOptionalPropertyTypes\n // When registry is undefined, we omit it entirely and let RegistryProvider inherit from parent\n const registryProviderProps = registry !== undefined ? { registry } : {};\n\n return (\n <RegistryProvider {...registryProviderProps}>\n {/* Type assertion required: TypedWidgetSchema<T>[] is a subtype of WidgetSchema[]\n when T's components accept props compatible with WidgetSchema props.\n This enables type-safe widget rendering with custom registries while allowing\n the internal renderer to work with the base WidgetSchema type. */}\n <ScreenRendererContent\n screen={screen as WidgetSchema[]}\n containerWidgetTypes={containerWidgetTypes}\n className={className}\n />\n </RegistryProvider>\n );\n}\n"],"mappings":";;;;;AAGA,MAAM,uBAAuB,cAAoC,KAAK;AAEtE,MAAa,wBAAwB,qBAAqB;;;;;;;AAsB1D,SAAgB,2BAAiD;AAC/D,QAAO,WAAW,qBAAqB;;;;;;;;;;ACYzC,MAAa,kBACX,cAA0C,KAAA,EAAU;;;;;AAWtD,SAAgB,iBAAiB,EAC/B,UACA,YAC2C;CAE3C,MAAM,iBAAiB,WAAW,gBAAgB;CAClD,MAAM,eAAe,YAAY;AAEjC,KAAI,CAAC,aACH,OAAM,IAAI,MACR,+FACD;AAGH,QACE,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;EAC9B;EACwB,CAAA;;;;;;AAQ/B,SAAgB,cAA8B;CAC5C,MAAM,WAAW,WAAW,gBAAgB;AAE5C,KAAI,CAAC,SACH,OAAM,IAAI,MACR,2EACD;AAGH,QAAO;;;;;;;;;;;;;AC9DT,MAAa,wBAET,cACF,KAAA,EACD;;;;;AAMD,SAAgB,oBAEF;AACZ,QAAO,WAAW,sBAAsB;;;;;;;;;ACvB1C,MAAa,oBAAoB;CAC/B,OAAO;CACP,YAAY;CACZ,UAAU;CACV,MAAM;CACN,UAAU;CACV,SAAS;CACT,OAAO;CACP,WAAW;CACX,OAAO;CACP,OAAO;CACP,QAAQ;CACR,MAAM;CACN,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,YAAY;CACZ,gBAAgB;CAChB,WAAW;C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,MAAM,YAAY,SAAS,OAAO;AAClC,MAAI,CAAC,WAAW;AACd,WAAQ,KACN,gBAAgB,OAAO,OAAO,KAAK,CAAC,yBACrC;AACD,UAAO;;EAGT,MAAM,aAAa,CAAC,GAAG,aAAa,MAAM;EAG1C,MAAM,kBAAkB,kBAAkB,OAAO,KAAK,GAClD;GACE,UAAU,OAAO;GACjB;GACD,GACD,EAAE;EAEN,MAAM,QAAQ;GACZ,GAAG,OAAO;GACV,GAAG;GACJ;AAGD,MAAI,OAAO,WACT,QACE,oBAAC,OAAD;GAEE,WAAU;aAEV,oBAAC,iBAAD;IAAyB;IAAmB;IAAa,CAAA;GACrD,EAJC,OAAO,MAAM,MAId;AAIV,SACE,oBAAC,OAAD;GAEE,WAAU;aAEV,oBAAC,WAAD,EAAW,GAAI,OAAS,CAAA;GACpB,EAJC,OAAO,MAAM,MAId;IAGV,CAAC,UAAU,kBAAkB,CAC9B;AAED,QACE,oBAAC,OAAD;EAAK,WAAW,aAAa;YAC1B,QAAQ,KAAK,MAAM,UAAU;AAE5B,OAAI,CAAC,KAAM,QAAO;AAClB,UAAO,aAAa,MAAM,OAAO,EAAE,CAAC;IACpC;EACE,CAAA;;;;;;;;;;;;;;;;;;;;;;;;AA0BV,SAAgB,eAGd,OAAkD;CAClD,MAAM,EACJ,QACA,UACA,uBAAuB,CACrB,kBAAkB,QAClB,kBAAkB,UACnB,EACD,cACE;AAMJ,QACE,oBAAC,kBAAD;EAAkB,GAHU,aAAa,KAAA,IAAY,EAAE,UAAU,GAAG,EAAE;YAQpE,oBAAC,uBAAD;GACU;GACc;GACX;GACX,CAAA;EACe,CAAA"}
1
+ {"version":3,"file":"ScreenRenderer-ClYgfQf_.mjs","names":[],"sources":["../../core/src/data-source-api-context.ts","../../widgets/src/contexts/RegistryContext.tsx","../../widgets/src/contexts/ScreenRendererContext.tsx","../../core/src/types/widget-schema.ts","../../core/src/data-sources/presets.ts","../../react/src/data-sources/use-widget-data.ts","../../react/src/data-sources/ErrorState.tsx","../../react/src/data-sources/DataAwareWidget.tsx","../../widgets/src/core/ScreenRenderer.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { DataSourceApi } from \"./data-source-api\";\n\nconst DataSourceApiContext = createContext<DataSourceApi | null>(null);\n\nexport const DataSourceApiProvider = DataSourceApiContext.Provider;\n\n/**\n * Access the DataSourceApi adapter.\n * Throws if no DataSourceApiProvider ancestor exists.\n */\nexport function useDataSourceApi(): DataSourceApi {\n const api = useContext(DataSourceApiContext);\n if (!api) {\n throw new Error(\n \"useDataSourceApi must be used within a DataSourceApiProvider\",\n );\n }\n return api;\n}\n\n/**\n * Access the DataSourceApi adapter without throwing.\n * Returns null when no DataSourceApiProvider ancestor exists.\n * Use in isolated rendering contexts (Storybook, unit tests) where the\n * full provider stack may not be wired.\n */\nexport function useDataSourceApiOptional(): DataSourceApi | null {\n return useContext(DataSourceApiContext);\n}\n","import React, {\n createContext,\n useContext,\n type ComponentType,\n type ReactNode,\n} from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\n\n/**\n * Base props interface for widget components.\n * All widgets receive at least these props from the ScreenRenderer.\n */\nexport interface WidgetBaseProps {\n readonly widget: WidgetSchema;\n readonly path?: readonly number[];\n}\n\n/**\n * Generic widget component type.\n * Widgets receive WidgetBaseProps and may have additional props.\n */\nexport type WidgetComponent<P extends WidgetBaseProps = WidgetBaseProps> =\n ComponentType<P>;\n\n/**\n * Registry mapping widget type names to their components.\n * The keys are widget type strings (e.g., \"TextWidget\", \"ButtonWidget\").\n * Using WidgetComponent for the value type provides better type safety than `any`.\n */\nexport type WidgetRegistry = Readonly<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Widget props vary by type\n Record<string, WidgetComponent<any>>\n>;\n\n/**\n * Context for providing the widget registry to all components in the tree.\n * This eliminates prop drilling and makes the registry accessible anywhere.\n *\n * Default to undefined - registry must be provided by a RegistryProvider.\n */\nexport const RegistryContext: React.Context<WidgetRegistry | undefined> =\n createContext<WidgetRegistry | undefined>(undefined);\n\nexport interface RegistryProviderProps {\n registry?: WidgetRegistry;\n children: ReactNode;\n}\n\n/**\n * Provider component that makes the widget registry available to all descendants.\n * A registry must be provided either via props or by nesting within another RegistryProvider.\n */\nexport function RegistryProvider({\n registry,\n children,\n}: RegistryProviderProps): React.JSX.Element {\n // If no registry provided, inherit from parent provider\n const parentRegistry = useContext(RegistryContext);\n const contextValue = registry ?? parentRegistry;\n\n if (!contextValue) {\n throw new Error(\n \"RegistryProvider requires a registry prop or must be nested within another RegistryProvider.\",\n );\n }\n\n return (\n <RegistryContext.Provider value={contextValue}>\n {children}\n </RegistryContext.Provider>\n );\n}\n\n/**\n * Hook to access the widget registry from anywhere in the component tree.\n * Must be used within a RegistryProvider that has a registry prop.\n */\nexport function useRegistry(): WidgetRegistry {\n const registry = useContext(RegistryContext);\n\n if (!registry) {\n throw new Error(\n \"useRegistry must be used within a RegistryProvider with a registry prop.\",\n );\n }\n\n return registry;\n}\n","import React, { createContext, useContext, type ComponentType } from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\nimport type { WidgetRegistry } from \"./RegistryContext\";\n\n/**\n * Props that any ScreenRenderer must accept.\n * This is the minimal interface used by container widgets (e.g. LayoutWidget)\n * to render their children.\n */\nexport interface ScreenRendererComponentProps {\n screen: WidgetSchema[];\n registry?: WidgetRegistry;\n className?: string;\n}\n\n/**\n * Context for providing an alternative ScreenRenderer component.\n *\n * This allows packages like portal-builder to inject their own ScreenRenderer\n * (with edit mode, drag-and-drop, etc.) so that container widgets in portal-widgets\n * use the richer renderer instead of the basic view-only one.\n *\n * Default is undefined — container widgets fall back to the local ScreenRenderer import.\n */\nexport const ScreenRendererContext: React.Context<\n ComponentType<ScreenRendererComponentProps> | undefined\n> = createContext<ComponentType<ScreenRendererComponentProps> | undefined>(\n undefined,\n);\n\n/**\n * Hook to get the ScreenRenderer component from context.\n * Returns undefined if no override has been provided.\n */\nexport function useScreenRenderer():\n | ComponentType<ScreenRendererComponentProps>\n | undefined {\n return useContext(ScreenRendererContext);\n}\n","import type { DataSourceConfig } from \"../data-sources/types\";\n\n/**\n * Generic component type — avoids React dependency in core.\n * Accepts both function components and class component constructors.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyComponent = ((props: any) => any) | (new (props: any) => any);\n\n/**\n * Widget type names as a const object.\n * This serves as the single source of truth for widget discriminants.\n * Use `as const` for literal type inference (safety-as-const-deep-readonly rule).\n */\nexport const WIDGET_TYPE_NAMES = {\n Alert: \"AlertWidget\",\n BulletList: \"BulletListWidget\",\n Calendar: \"CalendarWidget\",\n Card: \"CardWidget\",\n Carousel: \"CarouselWidget\",\n CatchUp: \"CatchUpWidget\",\n Chart: \"ChartWidget\",\n Container: \"ContainerWidget\",\n Embed: \"EmbedWidget\",\n Image: \"ImageWidget\",\n Layout: \"LayoutWidget\",\n Link: \"LinkWidget\",\n List: \"ListWidget\",\n MySite: \"MySiteWidget\",\n Nested: \"NestedWidget\",\n Points: \"PointsWidget\",\n QuickLinks: \"QuickLinksWidget\",\n QuickShare: \"QuickShareWidget\",\n RecentActivity: \"RecentActivityWidget\",\n Separator: \"SeparatorWidget\",\n Spacer: \"SpacerWidget\",\n Table: \"TableWidget\",\n Text: \"TextWidget\",\n ToDo: \"ToDoWidget\",\n Video: \"VideoWidget\",\n} as const;\n\n/**\n * Union of all known widget type names.\n * Derived from WIDGET_TYPE_NAMES to avoid duplication (deriving-typeof-for-object-keys rule).\n */\nexport type WidgetTypeName =\n (typeof WIDGET_TYPE_NAMES)[keyof typeof WIDGET_TYPE_NAMES];\n\n/**\n * Legacy alias for backwards compatibility.\n * Prefer using WidgetTypeName for new code when you need the union type.\n */\nexport type WidgetType = string;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type WidgetRegistry = Record<WidgetType, AnyComponent>;\n\n/**\n * Base widget schema with loose typing for runtime data.\n * Use TypedWidgetSchema<T> when you have a known registry for better type safety.\n */\nexport type WidgetSchema = {\n readonly type: WidgetType;\n readonly props: Readonly<Record<string, unknown>>;\n readonly id?: string; // Optional unique identifier for drag-and-drop\n /** Optional data source configuration for data-bound widgets */\n readonly dataSource?: DataSourceConfig | undefined;\n /** Column index for masonry layouts (0-indexed) */\n readonly columnIndex?: number;\n};\n\n/**\n * Type-safe widget schema based on registry.\n * Uses discriminated unions - the `type` field serves as discriminant.\n * When narrowed (e.g., `if (widget.type === \"AlertWidget\")`),\n * TypeScript automatically knows the correct props type.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type TypedWidgetSchema<T extends Record<string, AnyComponent>> = {\n [K in keyof T]: {\n readonly type: K;\n readonly props: Readonly<\n T[K] extends (props: infer P) => any\n ? P\n : T[K] extends new (props: infer P) => any\n ? P\n : never\n >;\n readonly id?: string;\n readonly dataSource?: DataSourceConfig | undefined;\n /** Column index for masonry layouts (0-indexed) */\n readonly columnIndex?: number;\n };\n}[keyof T];\n\n/**\n * Widget path in the tree - array of indices.\n * Readonly tuple to prevent accidental mutation.\n */\nexport type WidgetPath = readonly number[];\n\n// ============================================================================\n// Type Guards and Assertion Functions\n// ============================================================================\n\n/**\n * Type predicate to check if a string is a known widget type name.\n * Use for runtime validation of widget types.\n *\n * @example\n * if (isWidgetTypeName(widget.type)) {\n * // TypeScript knows widget.type is WidgetTypeName\n * }\n */\nexport function isWidgetTypeName(type: string): type is WidgetTypeName {\n // Type assertion required in type guard: Object.values() returns string[], but we\n // need to check against WidgetTypeName values. The assertion is safe because we're\n // checking membership, and the return type predicate ensures correct narrowing.\n return Object.values(WIDGET_TYPE_NAMES).includes(type as WidgetTypeName);\n}\n\n/**\n * Type predicate to check if a widget has a specific type.\n * Enables type-safe widget narrowing without `as` assertions.\n *\n * @example\n * if (isWidgetType(widget, \"LayoutWidget\")) {\n * // TypeScript knows widget.type === \"LayoutWidget\"\n * // and widget.props is LayoutWidget props\n * }\n */\nexport function isWidgetType<T extends WidgetTypeName>(\n widget: WidgetSchema | null | undefined,\n typeName: T,\n): widget is WidgetSchema & { readonly type: T } {\n return widget != null && widget.type === typeName;\n}\n\n/**\n * Helper for exhaustive switch statements on widget types.\n * Use in the default case to ensure all widget types are handled.\n *\n * @example\n * switch (widget.type) {\n * case \"AlertWidget\": return handleAlert();\n * case \"TextWidget\": return handleText();\n * // ... all other widget types\n * default: return assertNever(widget.type, \"widget type\");\n * }\n */\nexport function assertNever(value: never, context?: string): never {\n const message = context\n ? `Unexpected ${context}: ${String(value)}`\n : `Unexpected value: ${String(value)}`;\n throw new Error(message);\n}\n\n/**\n * Assertion function that throws if value is undefined.\n * Narrows the type to exclude undefined.\n *\n * @example\n * const widget = screen[0];\n * assertDefined(widget, \"widget at index 0\");\n * // TypeScript knows widget is defined here\n */\nexport function assertDefined<T>(\n value: T | undefined | null,\n name?: string,\n): asserts value is T {\n if (value == null) {\n throw new Error(name ? `${name} is required` : \"Value is required\");\n }\n}\n","/**\n * Data Source Presets Registry\n *\n * Configurable presets that allow users to select options via sub-menus\n * and fine-tune parameters in a detail panel.\n */\n\nimport type {\n SelectFieldSchema,\n NumberFieldSchema,\n} from \"../registries/property-schema-types\";\nimport type { DataSource } from \"./types\";\n\n/** Widget types that can use data sources */\nexport type DataSourceCompatibleWidget =\n | \"CarouselWidget\"\n | \"ChartWidget\"\n | \"EmbedWidget\"\n | \"ImageWidget\"\n | \"ListWidget\"\n | \"NestedWidget\"\n | \"TableWidget\"\n | \"VideoWidget\";\n\n/** Field types supported in preset config panels */\nexport type PresetConfigField = SelectFieldSchema<string> | NumberFieldSchema;\n\n/** A preset data source configuration */\nexport interface DataSourcePreset {\n /** Unique identifier for the preset */\n id: string;\n /** Human-readable name for display */\n name: string;\n /** Description of what data this endpoint provides */\n description: string;\n /** The API endpoint path (can include {variable} placeholders) */\n endpoint: string;\n /** Transformer name to apply to the data */\n transform?: string;\n /** Optional path to extract data from response (e.g., \"data.items\") */\n resultPath?: string;\n /** Which widgets this preset is compatible with */\n compatibleWidgets: DataSourceCompatibleWidget[];\n /** Optional select field shown as a sub-menu. The field's key becomes a variable in the endpoint URL. */\n menuField?: SelectFieldSchema<string>;\n /** Optional config fields rendered in the detail panel below the popover. Each field's key becomes a variable. */\n configFields?: PresetConfigField[];\n}\n\n/**\n * Pre-configured data source presets\n */\nexport const DATA_SOURCE_PRESETS: DataSourcePreset[] = [\n {\n id: \"rep-most-shared\",\n name: \"Most Shared Visits\",\n description: \"Content with the most share-link click-throughs\",\n endpoint:\n \"/v2025-06/reps/{rep_id}/most_shared?shareable_type={shareable_type}&limit={limit}&period={period}&language_iso={language_iso}\",\n resultPath: \"resources\",\n compatibleWidgets: [\n \"CarouselWidget\",\n \"ListWidget\",\n \"NestedWidget\",\n \"TableWidget\",\n ],\n menuField: {\n key: \"shareable_type\",\n label: \"Content Type\",\n type: \"select\",\n options: [\n { label: \"Products\", value: \"products\" },\n { label: \"Media\", value: \"media\" },\n { label: \"Pages\", value: \"pages\" },\n { label: \"Libraries\", value: \"libraries\" },\n { label: \"Enrollment Packs\", value: \"enrollment_packs\" },\n ],\n defaultValue: \"products\",\n },\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 20,\n description: \"Maximum number of items to show\",\n },\n {\n key: \"period\",\n label: \"Time Range\",\n type: \"select\",\n options: [\n { label: \"7 days\", value: \"7d\" },\n { label: \"30 days\", value: \"30d\" },\n { label: \"90 days\", value: \"90d\" },\n { label: \"1 year\", value: \"1y\" },\n { label: \"All time\", value: \"all\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n {\n id: \"rep-most-viewed\",\n name: \"Most Viewed\",\n description: \"Most viewed content\",\n endpoint:\n \"/v2025-06/reps/{rep_id}/most_viewed?shareable_type={shareable_type}&limit={limit}&period={period}&language_iso={language_iso}\",\n resultPath: \"resources\",\n compatibleWidgets: [\n \"CarouselWidget\",\n \"ListWidget\",\n \"NestedWidget\",\n \"TableWidget\",\n ],\n menuField: {\n key: \"shareable_type\",\n label: \"Content Type\",\n type: \"select\",\n options: [\n { label: \"Products\", value: \"products\" },\n { label: \"Media\", value: \"media\" },\n { label: \"Pages\", value: \"pages\" },\n { label: \"Libraries\", value: \"libraries\" },\n { label: \"Enrollment Packs\", value: \"enrollment_packs\" },\n ],\n defaultValue: \"products\",\n },\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 20,\n description: \"Maximum number of items to show\",\n },\n {\n key: \"period\",\n label: \"Time Range\",\n type: \"select\",\n options: [\n { label: \"7 days\", value: \"7d\" },\n { label: \"30 days\", value: \"30d\" },\n { label: \"90 days\", value: \"90d\" },\n { label: \"1 year\", value: \"1y\" },\n { label: \"All time\", value: \"all\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n {\n id: \"customer-orders\",\n name: \"Orders\",\n description: \"Customer order history\",\n endpoint:\n \"/v202506/orders?customer_id={customer_id}&page[limit]={limit}&status={status}\",\n resultPath: \"orders\",\n transform: \"toOrderTableProps\",\n compatibleWidgets: [\"TableWidget\"],\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 50,\n description: \"Maximum number of orders to show\",\n },\n {\n key: \"status\",\n label: \"Status\",\n type: \"select\",\n options: [\n { label: \"All\", value: \"all\" },\n { label: \"Paid\", value: \"paid\" },\n { label: \"Unpaid\", value: \"unpaid\" },\n { label: \"Refunded\", value: \"refunded\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n {\n id: \"customer-subscriptions\",\n name: \"Subscriptions\",\n description: \"Customer subscriptions\",\n // Subscriptions endpoint is unversioned (legacy API), orders uses v202506\n endpoint:\n \"/subscriptions?customer_id={customer_id}&per_page={limit}&status={status}\",\n resultPath: \"subscriptions\",\n transform: \"toSubscriptionTableProps\",\n compatibleWidgets: [\"TableWidget\"],\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 50,\n description: \"Maximum number of subscriptions to show\",\n },\n {\n key: \"status\",\n label: \"Status\",\n type: \"select\",\n options: [\n { label: \"All\", value: \"all\" },\n { label: \"Active\", value: \"active\" },\n { label: \"Paused\", value: \"paused\" },\n { label: \"Cancelled\", value: \"cancelled\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n];\n\n/** Lookup map for O(1) preset resolution */\nconst PRESET_MAP = new Map<string, DataSourcePreset>(\n DATA_SOURCE_PRESETS.map((p) => [p.id, p]),\n);\n\n/**\n * Resolves a preset by ID, returning the current preset definition.\n * Returns undefined if the preset ID is not recognized.\n */\nexport function resolvePreset(presetId: string): DataSourcePreset | undefined {\n return PRESET_MAP.get(presetId);\n}\n\n/**\n * If the source is an API source with a presetId, returns a copy with\n * endpoint, resultPath, and transform resolved from the current preset.\n * Falls back to stored values if the preset is unknown.\n * Non-API sources are returned as-is.\n */\nexport function resolveSource<T extends DataSource>(source: T): T {\n if (source.type !== \"api\" || !source.presetId) return source;\n\n const preset = resolvePreset(source.presetId);\n if (!preset) {\n console.warn(\n `[DataSource] Unknown preset \"${source.presetId}\", falling back to stored values`,\n );\n return source;\n }\n\n return {\n ...source,\n endpoint: preset.endpoint,\n resultPath: preset.resultPath,\n transform: preset.transform ?? source.transform,\n } as T;\n}\n","import { useQueries } from \"@tanstack/react-query\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\nimport type {\n DataSourceRegistry,\n WidgetDataResult,\n DataSourceContext,\n DataSource,\n} from \"@fluid-app/portal-core/data-sources/types\";\nimport { resolveSource } from \"@fluid-app/portal-core/data-sources/presets\";\nimport { useDataSourceApiOptional } from \"@fluid-app/portal-core/data-source-api-context\";\nimport { useDataSourceRegistryConfig } from \"./registry-context\";\n\ninterface UseWidgetDataOptions {\n /** Override the default registry from context */\n registry?: DataSourceRegistry | undefined;\n /** Base URL for API calls (e.g., \"https://api.fluid.app/api\") */\n baseUrl?: string | undefined;\n}\n\n/**\n * Generates a cache key for the raw data fetch (endpoint/items identity only).\n * Transforms and targetProps are NOT included — they are applied per-widget\n * after reading from the shared cache.\n */\nfunction getSourceKey(source: DataSource): string {\n if (source.type === \"api\") {\n const varsKey = source.variables\n ? `:${JSON.stringify(source.variables)}`\n : \"\";\n // Use presetId as identity when available — keeps cache key stable across preset endpoint changes\n const identity = source.presetId ?? source.endpoint;\n return `${identity}${varsKey}`;\n }\n if (source.type === \"custom\") {\n const itemKeys =\n source.selectedItems?.map((item) => {\n return `${item.shareableType}:${item.id}`;\n }) ?? [];\n return `custom:${itemKeys.join(\",\")}`;\n }\n if (source.type === \"static\") {\n return `static:${source.staticType}:${source.selectedId}`;\n }\n return \"unknown\";\n}\n\n/**\n * Resolves cached raw data into widget props by applying each widget's own\n * transforms and targetProps mapping.\n */\nfunction resolvePropsFromQueries<T>(\n queryResults: ReadonlyArray<{\n data?: unknown;\n isLoading: boolean;\n error: Error | null;\n }>,\n sources: DataSource[],\n registry: DataSourceRegistry,\n errorConfig?: { fallback?: unknown },\n): T | undefined {\n if (sources.length === 0) return undefined;\n if (queryResults.some((q) => q.isLoading && !q.data)) return undefined;\n\n const failedQuery = queryResults.find((q) => q.error);\n const hasError = !!failedQuery?.error;\n\n if (hasError && errorConfig?.fallback) {\n return errorConfig.fallback as T;\n }\n\n if (hasError) {\n return undefined;\n }\n\n const resolvedProps: Record<string, unknown> = {};\n\n for (let i = 0; i < queryResults.length; i++) {\n const query = queryResults[i];\n const source = sources[i];\n if (!query?.data || !source) continue;\n\n // Sentry fix: FLUID-ADMIN-1DH — source or targetProps can be undefined from malformed widget config\n if (!source.targetProps) continue;\n\n // Apply this widget's transform to the cached raw data\n let result: unknown = query.data;\n if (source.transform) {\n const transformer = registry.transformers[source.transform];\n if (transformer) {\n result = transformer(result, source);\n } else {\n console.warn(`Transform \"${source.transform}\" not found in registry`);\n }\n }\n\n // Map to this widget's targetProps\n if (\n result !== null &&\n typeof result === \"object\" &&\n !Array.isArray(result) &&\n source.targetProps.length > 1\n ) {\n const resultObj = result as Record<string, unknown>;\n for (const prop of source.targetProps) {\n if (prop in resultObj) {\n resolvedProps[prop] = resultObj[prop];\n }\n }\n } else {\n for (const prop of source.targetProps) {\n resolvedProps[prop] = result;\n }\n }\n }\n\n return resolvedProps as T;\n}\n\n/**\n * Hook that fetches and resolves data sources for a widget using React Query.\n *\n * Raw API data is cached and shared across widgets with the same data source.\n * Transforms and targetProps mapping are applied per-widget after cache reads,\n * so multiple widgets can share one fetch but resolve data independently.\n */\nexport function useWidgetData<T = Record<string, unknown>>(\n widget: WidgetSchema,\n options?: UseWidgetDataOptions,\n): WidgetDataResult<T> {\n const config = useDataSourceRegistryConfig();\n const registry = options?.registry ?? config.registry;\n const baseUrl = options?.baseUrl ?? config.baseUrl;\n const getApiHeaders = config.getApiHeaders;\n const variables = config.variables;\n // useDataSourceApiOptional returns null outside a DataSourceApiProvider.\n // This allows widgets with zero data sources to render in isolation\n // (Storybook, unit tests). Fetchers that require api will throw at call\n // time if it's missing — not at render time for every widget.\n const api = useDataSourceApiOptional() ?? undefined;\n\n // Resolve preset-backed sources to their current endpoint/resultPath/transform\n const sources = useMemo(\n () => (widget.dataSource?.sources ?? []).map(resolveSource),\n [widget.dataSource?.sources],\n );\n const errorConfig = widget.dataSource?.error;\n const widgetId = widget.id ?? \"unknown\";\n const widgetType = widget.type;\n\n const queryResultsRef = useRef<Array<{ refetch: () => void }>>([]);\n\n // Cache only raw fetched data — no transforms or source objects stored\n const results = useQueries({\n queries: sources.map((source: DataSource) => ({\n queryKey: [\n \"portal-widget-data\",\n getSourceKey(source),\n baseUrl,\n variables,\n ] as const,\n queryFn: async ({\n signal,\n }: {\n signal: AbortSignal;\n }): Promise<unknown> => {\n const context: DataSourceContext = {\n widgetId,\n widgetType,\n signal,\n baseUrl,\n getApiHeaders,\n variables,\n api,\n };\n\n const fetcher = registry.fetchers[source.type];\n if (!fetcher) {\n throw new Error(\n `No fetcher registered for source type: ${source.type}`,\n );\n }\n\n return fetcher(source, context);\n },\n enabled: sources.length > 0,\n retry: errorConfig?.retryCount ?? 0,\n retryDelay: errorConfig?.retryDelay ?? 1000,\n refetchInterval: source.refreshInterval || false,\n })),\n });\n\n // Update ref for refetch callback\n queryResultsRef.current = results;\n\n // Aggregate loading state\n const isLoading = results.some((q) => q.isLoading);\n\n // Get first error from any failed query\n const failedQuery = results.find((q) => q.error);\n const error =\n failedQuery?.error instanceof Error\n ? failedQuery.error\n : failedQuery?.error\n ? new Error(String(failedQuery.error))\n : null;\n\n // Stable fingerprint that changes only when query data or loading states change\n const queryFingerprint = results\n .map((r) => `${r.dataUpdatedAt}:${r.isLoading}`)\n .join(\",\");\n\n // Resolve data: apply per-widget transforms and map to targetProps\n const resultsRef = useRef(results);\n resultsRef.current = results;\n\n const data = useMemo(() => {\n const querySnapshots = resultsRef.current.map((q) => ({\n data: q.data,\n isLoading: q.isLoading,\n error: q.error instanceof Error ? q.error : null,\n }));\n return resolvePropsFromQueries<T>(\n querySnapshots,\n sources,\n registry,\n errorConfig,\n );\n }, [queryFingerprint, sources, registry, errorConfig]);\n\n // Stable refetch callback using ref\n const refetch = useCallback(() => {\n queryResultsRef.current.forEach((q) => q.refetch());\n }, []);\n\n return {\n data,\n isLoading,\n error,\n refetch,\n };\n}\n","import type React from \"react\";\n\nexport function ErrorState(): React.JSX.Element {\n return (\n <div className=\"flex min-h-[120px] flex-col items-center justify-center p-6 text-center\">\n <p className=\"text-lg font-semibold\">Something Went Wrong</p>\n <p className=\"text-muted-foreground text-sm\">\n Please contact a company admin for help\n </p>\n </div>\n );\n}\n","import type React from \"react\";\nimport { memo, useMemo, type ComponentType, type ReactNode } from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\nimport { useWidgetData } from \"./use-widget-data\";\nimport { ErrorState } from \"./ErrorState\";\n\nexport interface DataAwareWidgetProps {\n widget: WidgetSchema;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Component: ComponentType<any>;\n /** Additional props to pass through (e.g., edit mode callbacks) */\n additionalProps?: Record<string, unknown>;\n /** Custom loading component */\n loadingComponent?: ReactNode;\n /** Custom error component */\n errorComponent?: (error: Error) => ReactNode;\n /** Base URL for API calls (e.g., \"https://api.fluid.app/api\") */\n baseUrl?: string | undefined;\n}\n\n// Empty object constant to avoid creating new references\nconst EMPTY_OBJECT: Record<string, unknown> = {};\n\n/**\n * Wrapper component that resolves data sources before rendering the widget.\n * Merges resolved data with static props.\n */\nfunction DataAwareWidgetImpl({\n widget,\n Component,\n additionalProps,\n loadingComponent,\n errorComponent,\n baseUrl,\n}: DataAwareWidgetProps): React.JSX.Element | null {\n // Use stable empty object if no additionalProps provided\n const stableAdditionalProps = additionalProps ?? EMPTY_OBJECT;\n const { data, isLoading, error } = useWidgetData(widget, { baseUrl });\n\n // Merge static props with resolved data\n // Data takes precedence (allows overriding defaults)\n // Memoized to prevent unnecessary child re-renders\n // Note: Must be called before any early returns to satisfy Rules of Hooks\n const mergedProps = useMemo(\n () => ({\n ...widget.props,\n ...data,\n ...stableAdditionalProps,\n }),\n [widget.props, data, stableAdditionalProps],\n );\n\n // Show loading state\n if (isLoading && widget.dataSource?.loading?.showSkeleton !== false) {\n if (loadingComponent) {\n return <>{loadingComponent}</>;\n }\n // Default skeleton - can be customized\n return (\n <div\n className=\"bg-muted animate-pulse rounded-md\"\n style={{ minHeight: 100 }}\n >\n <span className=\"sr-only\">Loading...</span>\n </div>\n );\n }\n\n // Show error state (if no fallback was applied)\n if (error && !data) {\n if (errorComponent) {\n return <>{errorComponent(error)}</>;\n }\n // Default error display\n return <ErrorState />;\n }\n\n return <Component {...mergedProps} />;\n}\n\n/**\n * Memoized wrapper component that resolves data sources before rendering the widget.\n * Prevents re-renders when parent re-renders but props haven't changed.\n */\nexport const DataAwareWidget: React.NamedExoticComponent<DataAwareWidgetProps> =\n memo(DataAwareWidgetImpl);\n","import type { ComponentType } from \"react\";\nimport { useCallback } from \"react\";\nimport type React from \"react\";\nimport type {\n WidgetSchema,\n TypedWidgetSchema,\n WidgetPath,\n} from \"@fluid-app/portal-core/types\";\nimport { WIDGET_TYPE_NAMES } from \"@fluid-app/portal-core/types\";\nimport { DataAwareWidget } from \"@fluid-app/portal-react/data-sources/DataAwareWidget\";\nimport { RegistryProvider, useRegistry } from \"../contexts/RegistryContext\";\n\nexport interface ScreenRendererProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, ComponentType<any>>,\n> {\n /** Array of widget schemas to render */\n screen: TypedWidgetSchema<T>[] | WidgetSchema[];\n /** Widget registry mapping type names to components */\n registry?: T;\n /** Container widgets (like LayoutWidget) receive these additional props */\n containerWidgetTypes?: string[];\n /** Additional CSS classes for the wrapper div */\n className?: string;\n}\n\ninterface ScreenRendererContentProps {\n screen: WidgetSchema[];\n containerWidgetTypes: string[];\n className?: string | undefined;\n}\n\n/**\n * Internal component that uses the registry from context.\n * This allows us to avoid prop drilling the registry.\n */\nfunction ScreenRendererContent({\n screen,\n containerWidgetTypes,\n className,\n}: ScreenRendererContentProps) {\n const registry = useRegistry();\n\n // Check if a widget type is a container\n const isContainerWidget = useCallback(\n (widgetType: string) => containerWidgetTypes.includes(widgetType),\n [containerWidgetTypes],\n );\n\n // Render widgets recursively with path tracking\n const renderWidget = useCallback(\n (widget: WidgetSchema, index: number, currentPath: WidgetPath) => {\n const Component = registry[widget.type];\n if (!Component) {\n console.warn(\n `Widget type \"${String(widget.type)}\" not found in registry`,\n );\n return null;\n }\n\n const widgetPath = [...currentPath, index];\n\n // Build additional props for container widgets\n const additionalProps = isContainerWidget(widget.type)\n ? {\n widgetId: widget.id,\n widgetPath,\n }\n : {};\n\n const props = {\n ...widget.props,\n ...additionalProps,\n };\n\n // Wrap data-bound widgets with DataAwareWidget to resolve data sources\n if (widget.dataSource) {\n return (\n <div\n key={widget.id || index}\n className=\"h-full w-full overflow-x-hidden\"\n >\n <DataAwareWidget widget={widget} Component={Component} />\n </div>\n );\n }\n\n return (\n <div\n key={widget.id || index}\n className=\"h-full w-full overflow-x-hidden\"\n >\n <Component {...props} />\n </div>\n );\n },\n [registry, isContainerWidget],\n );\n\n return (\n <div className={className || \"h-full w-full\"}>\n {screen?.map((item, index) => {\n // Skip null items (empty grid cells)\n if (!item) return null;\n return renderWidget(item, index, []);\n })}\n </div>\n );\n}\n\n/**\n * ScreenRenderer - View-only component for rendering widget screens.\n *\n * This is a simplified version designed for the SDK that only handles\n * rendering widgets without edit mode or drag-and-drop functionality.\n *\n * Features:\n * - Static rendering of widgets\n * - Registry context: No prop drilling for widget registry\n * - Container widget support with path tracking\n *\n * Usage:\n * ```tsx\n * import { ScreenRenderer } from '@fluid-app/portal-widgets/core';\n * import { WIDGET_REGISTRY } from '@fluid-app/portal-widgets/widgets';\n *\n * <ScreenRenderer\n * screen={widgets}\n * registry={WIDGET_REGISTRY}\n * />\n * ```\n */\nexport function ScreenRenderer<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, ComponentType<any>>,\n>(props: ScreenRendererProps<T>): React.JSX.Element {\n const {\n screen,\n registry,\n containerWidgetTypes = [\n WIDGET_TYPE_NAMES.Layout,\n WIDGET_TYPE_NAMES.Container,\n ],\n className,\n } = props;\n\n // Conditionally pass registry prop to satisfy exactOptionalPropertyTypes\n // When registry is undefined, we omit it entirely and let RegistryProvider inherit from parent\n const registryProviderProps = registry !== undefined ? { registry } : {};\n\n return (\n <RegistryProvider {...registryProviderProps}>\n {/* Type assertion required: TypedWidgetSchema<T>[] is a subtype of WidgetSchema[]\n when T's components accept props compatible with WidgetSchema props.\n This enables type-safe widget rendering with custom registries while allowing\n the internal renderer to work with the base WidgetSchema type. */}\n <ScreenRendererContent\n screen={screen as WidgetSchema[]}\n containerWidgetTypes={containerWidgetTypes}\n className={className}\n />\n </RegistryProvider>\n );\n}\n"],"mappings":";;;;;AAGA,MAAM,uBAAuB,cAAoC,KAAK;AAEtE,MAAa,wBAAwB,qBAAqB;;;;;;;AAsB1D,SAAgB,2BAAiD;AAC/D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GAEE,WAAU;aAEV,oBAAC,WAAD,EAAW,GAAI,OAAS,CAAA;GACpB,EAJC,OAAO,MAAM,MAId;IAGV,CAAC,UAAU,kBAAkB,CAC9B;AAED,QACE,oBAAC,OAAD;EAAK,WAAW,aAAa;YAC1B,QAAQ,KAAK,MAAM,UAAU;AAE5B,OAAI,CAAC,KAAM,QAAO;AAClB,UAAO,aAAa,MAAM,OAAO,EAAE,CAAC;IACpC;EACE,CAAA;;;;;;;;;;;;;;;;;;;;;;;;AA0BV,SAAgB,eAGd,OAAkD;CAClD,MAAM,EACJ,QACA,UACA,uBAAuB,CACrB,kBAAkB,QAClB,kBAAkB,UACnB,EACD,cACE;AAMJ,QACE,oBAAC,kBAAD;EAAkB,GAHU,aAAa,KAAA,IAAY,EAAE,UAAU,GAAG,EAAE;YAQpE,oBAAC,uBAAD;GACU;GACc;GACX;GACX,CAAA;EACe,CAAA"}
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-9hOWP6kD.cjs");
2
- const require_registry_context = require("./registry-context-C7-RLxVt.cjs");
2
+ const require_registry_context = require("./registry-context-bf52ZIJX.cjs");
3
3
  let react = require("react");
4
4
  react = require_chunk.__toESM(react);
5
5
  let _tanstack_react_query = require("@tanstack/react-query");
@@ -738,4 +738,4 @@ Object.defineProperty(exports, "useScreenRenderer", {
738
738
  }
739
739
  });
740
740
 
741
- //# sourceMappingURL=ScreenRenderer-aYfgv6mR.cjs.map
741
+ //# sourceMappingURL=ScreenRenderer-Ct1w4PNu.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScreenRenderer-aYfgv6mR.cjs","names":["useDataSourceRegistryConfig"],"sources":["../../core/src/data-source-api-context.ts","../../widgets/src/contexts/RegistryContext.tsx","../../widgets/src/contexts/ScreenRendererContext.tsx","../../core/src/types/widget-schema.ts","../../core/src/data-sources/presets.ts","../../react/src/data-sources/use-widget-data.ts","../../react/src/data-sources/ErrorState.tsx","../../react/src/data-sources/DataAwareWidget.tsx","../../widgets/src/core/ScreenRenderer.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { DataSourceApi } from \"./data-source-api\";\n\nconst DataSourceApiContext = createContext<DataSourceApi | null>(null);\n\nexport const DataSourceApiProvider = DataSourceApiContext.Provider;\n\n/**\n * Access the DataSourceApi adapter.\n * Throws if no DataSourceApiProvider ancestor exists.\n */\nexport function useDataSourceApi(): DataSourceApi {\n const api = useContext(DataSourceApiContext);\n if (!api) {\n throw new Error(\n \"useDataSourceApi must be used within a DataSourceApiProvider\",\n );\n }\n return api;\n}\n\n/**\n * Access the DataSourceApi adapter without throwing.\n * Returns null when no DataSourceApiProvider ancestor exists.\n * Use in isolated rendering contexts (Storybook, unit tests) where the\n * full provider stack may not be wired.\n */\nexport function useDataSourceApiOptional(): DataSourceApi | null {\n return useContext(DataSourceApiContext);\n}\n","import React, {\n createContext,\n useContext,\n type ComponentType,\n type ReactNode,\n} from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\n\n/**\n * Base props interface for widget components.\n * All widgets receive at least these props from the ScreenRenderer.\n */\nexport interface WidgetBaseProps {\n readonly widget: WidgetSchema;\n readonly path?: readonly number[];\n}\n\n/**\n * Generic widget component type.\n * Widgets receive WidgetBaseProps and may have additional props.\n */\nexport type WidgetComponent<P extends WidgetBaseProps = WidgetBaseProps> =\n ComponentType<P>;\n\n/**\n * Registry mapping widget type names to their components.\n * The keys are widget type strings (e.g., \"TextWidget\", \"ButtonWidget\").\n * Using WidgetComponent for the value type provides better type safety than `any`.\n */\nexport type WidgetRegistry = Readonly<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Widget props vary by type\n Record<string, WidgetComponent<any>>\n>;\n\n/**\n * Context for providing the widget registry to all components in the tree.\n * This eliminates prop drilling and makes the registry accessible anywhere.\n *\n * Default to undefined - registry must be provided by a RegistryProvider.\n */\nexport const RegistryContext: React.Context<WidgetRegistry | undefined> =\n createContext<WidgetRegistry | undefined>(undefined);\n\nexport interface RegistryProviderProps {\n registry?: WidgetRegistry;\n children: ReactNode;\n}\n\n/**\n * Provider component that makes the widget registry available to all descendants.\n * A registry must be provided either via props or by nesting within another RegistryProvider.\n */\nexport function RegistryProvider({\n registry,\n children,\n}: RegistryProviderProps): React.JSX.Element {\n // If no registry provided, inherit from parent provider\n const parentRegistry = useContext(RegistryContext);\n const contextValue = registry ?? parentRegistry;\n\n if (!contextValue) {\n throw new Error(\n \"RegistryProvider requires a registry prop or must be nested within another RegistryProvider.\",\n );\n }\n\n return (\n <RegistryContext.Provider value={contextValue}>\n {children}\n </RegistryContext.Provider>\n );\n}\n\n/**\n * Hook to access the widget registry from anywhere in the component tree.\n * Must be used within a RegistryProvider that has a registry prop.\n */\nexport function useRegistry(): WidgetRegistry {\n const registry = useContext(RegistryContext);\n\n if (!registry) {\n throw new Error(\n \"useRegistry must be used within a RegistryProvider with a registry prop.\",\n );\n }\n\n return registry;\n}\n","import React, { createContext, useContext, type ComponentType } from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\nimport type { WidgetRegistry } from \"./RegistryContext\";\n\n/**\n * Props that any ScreenRenderer must accept.\n * This is the minimal interface used by container widgets (e.g. LayoutWidget)\n * to render their children.\n */\nexport interface ScreenRendererComponentProps {\n screen: WidgetSchema[];\n registry?: WidgetRegistry;\n className?: string;\n}\n\n/**\n * Context for providing an alternative ScreenRenderer component.\n *\n * This allows packages like portal-builder to inject their own ScreenRenderer\n * (with edit mode, drag-and-drop, etc.) so that container widgets in portal-widgets\n * use the richer renderer instead of the basic view-only one.\n *\n * Default is undefined — container widgets fall back to the local ScreenRenderer import.\n */\nexport const ScreenRendererContext: React.Context<\n ComponentType<ScreenRendererComponentProps> | undefined\n> = createContext<ComponentType<ScreenRendererComponentProps> | undefined>(\n undefined,\n);\n\n/**\n * Hook to get the ScreenRenderer component from context.\n * Returns undefined if no override has been provided.\n */\nexport function useScreenRenderer():\n | ComponentType<ScreenRendererComponentProps>\n | undefined {\n return useContext(ScreenRendererContext);\n}\n","import type { DataSourceConfig } from \"../data-sources/types\";\n\n/**\n * Generic component type — avoids React dependency in core.\n * Accepts both function components and class component constructors.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyComponent = ((props: any) => any) | (new (props: any) => any);\n\n/**\n * Widget type names as a const object.\n * This serves as the single source of truth for widget discriminants.\n * Use `as const` for literal type inference (safety-as-const-deep-readonly rule).\n */\nexport const WIDGET_TYPE_NAMES = {\n Alert: \"AlertWidget\",\n BulletList: \"BulletListWidget\",\n Calendar: \"CalendarWidget\",\n Card: \"CardWidget\",\n Carousel: \"CarouselWidget\",\n CatchUp: \"CatchUpWidget\",\n Chart: \"ChartWidget\",\n Container: \"ContainerWidget\",\n Embed: \"EmbedWidget\",\n Image: \"ImageWidget\",\n Layout: \"LayoutWidget\",\n Link: \"LinkWidget\",\n List: \"ListWidget\",\n MySite: \"MySiteWidget\",\n Nested: \"NestedWidget\",\n Points: \"PointsWidget\",\n QuickLinks: \"QuickLinksWidget\",\n QuickShare: \"QuickShareWidget\",\n RecentActivity: \"RecentActivityWidget\",\n Separator: \"SeparatorWidget\",\n Spacer: \"SpacerWidget\",\n Table: \"TableWidget\",\n Text: \"TextWidget\",\n ToDo: \"ToDoWidget\",\n Video: \"VideoWidget\",\n} as const;\n\n/**\n * Union of all known widget type names.\n * Derived from WIDGET_TYPE_NAMES to avoid duplication (deriving-typeof-for-object-keys rule).\n */\nexport type WidgetTypeName =\n (typeof WIDGET_TYPE_NAMES)[keyof typeof WIDGET_TYPE_NAMES];\n\n/**\n * Legacy alias for backwards compatibility.\n * Prefer using WidgetTypeName for new code when you need the union type.\n */\nexport type WidgetType = string;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type WidgetRegistry = Record<WidgetType, AnyComponent>;\n\n/**\n * Base widget schema with loose typing for runtime data.\n * Use TypedWidgetSchema<T> when you have a known registry for better type safety.\n */\nexport type WidgetSchema = {\n readonly type: WidgetType;\n readonly props: Readonly<Record<string, unknown>>;\n readonly id?: string; // Optional unique identifier for drag-and-drop\n /** Optional data source configuration for data-bound widgets */\n readonly dataSource?: DataSourceConfig | undefined;\n /** Column index for masonry layouts (0-indexed) */\n readonly columnIndex?: number;\n};\n\n/**\n * Type-safe widget schema based on registry.\n * Uses discriminated unions - the `type` field serves as discriminant.\n * When narrowed (e.g., `if (widget.type === \"AlertWidget\")`),\n * TypeScript automatically knows the correct props type.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type TypedWidgetSchema<T extends Record<string, AnyComponent>> = {\n [K in keyof T]: {\n readonly type: K;\n readonly props: Readonly<\n T[K] extends (props: infer P) => any\n ? P\n : T[K] extends new (props: infer P) => any\n ? P\n : never\n >;\n readonly id?: string;\n readonly dataSource?: DataSourceConfig | undefined;\n /** Column index for masonry layouts (0-indexed) */\n readonly columnIndex?: number;\n };\n}[keyof T];\n\n/**\n * Widget path in the tree - array of indices.\n * Readonly tuple to prevent accidental mutation.\n */\nexport type WidgetPath = readonly number[];\n\n// ============================================================================\n// Type Guards and Assertion Functions\n// ============================================================================\n\n/**\n * Type predicate to check if a string is a known widget type name.\n * Use for runtime validation of widget types.\n *\n * @example\n * if (isWidgetTypeName(widget.type)) {\n * // TypeScript knows widget.type is WidgetTypeName\n * }\n */\nexport function isWidgetTypeName(type: string): type is WidgetTypeName {\n // Type assertion required in type guard: Object.values() returns string[], but we\n // need to check against WidgetTypeName values. The assertion is safe because we're\n // checking membership, and the return type predicate ensures correct narrowing.\n return Object.values(WIDGET_TYPE_NAMES).includes(type as WidgetTypeName);\n}\n\n/**\n * Type predicate to check if a widget has a specific type.\n * Enables type-safe widget narrowing without `as` assertions.\n *\n * @example\n * if (isWidgetType(widget, \"LayoutWidget\")) {\n * // TypeScript knows widget.type === \"LayoutWidget\"\n * // and widget.props is LayoutWidget props\n * }\n */\nexport function isWidgetType<T extends WidgetTypeName>(\n widget: WidgetSchema | null | undefined,\n typeName: T,\n): widget is WidgetSchema & { readonly type: T } {\n return widget != null && widget.type === typeName;\n}\n\n/**\n * Helper for exhaustive switch statements on widget types.\n * Use in the default case to ensure all widget types are handled.\n *\n * @example\n * switch (widget.type) {\n * case \"AlertWidget\": return handleAlert();\n * case \"TextWidget\": return handleText();\n * // ... all other widget types\n * default: return assertNever(widget.type, \"widget type\");\n * }\n */\nexport function assertNever(value: never, context?: string): never {\n const message = context\n ? `Unexpected ${context}: ${String(value)}`\n : `Unexpected value: ${String(value)}`;\n throw new Error(message);\n}\n\n/**\n * Assertion function that throws if value is undefined.\n * Narrows the type to exclude undefined.\n *\n * @example\n * const widget = screen[0];\n * assertDefined(widget, \"widget at index 0\");\n * // TypeScript knows widget is defined here\n */\nexport function assertDefined<T>(\n value: T | undefined | null,\n name?: string,\n): asserts value is T {\n if (value == null) {\n throw new Error(name ? `${name} is required` : \"Value is required\");\n }\n}\n","/**\n * Data Source Presets Registry\n *\n * Configurable presets that allow users to select options via sub-menus\n * and fine-tune parameters in a detail panel.\n */\n\nimport type {\n SelectFieldSchema,\n NumberFieldSchema,\n} from \"../registries/property-schema-types\";\nimport type { DataSource } from \"./types\";\n\n/** Widget types that can use data sources */\nexport type DataSourceCompatibleWidget =\n | \"CarouselWidget\"\n | \"ChartWidget\"\n | \"EmbedWidget\"\n | \"ImageWidget\"\n | \"ListWidget\"\n | \"NestedWidget\"\n | \"TableWidget\"\n | \"VideoWidget\";\n\n/** Field types supported in preset config panels */\nexport type PresetConfigField = SelectFieldSchema<string> | NumberFieldSchema;\n\n/** A preset data source configuration */\nexport interface DataSourcePreset {\n /** Unique identifier for the preset */\n id: string;\n /** Human-readable name for display */\n name: string;\n /** Description of what data this endpoint provides */\n description: string;\n /** The API endpoint path (can include {variable} placeholders) */\n endpoint: string;\n /** Transformer name to apply to the data */\n transform?: string;\n /** Optional path to extract data from response (e.g., \"data.items\") */\n resultPath?: string;\n /** Which widgets this preset is compatible with */\n compatibleWidgets: DataSourceCompatibleWidget[];\n /** Optional select field shown as a sub-menu. The field's key becomes a variable in the endpoint URL. */\n menuField?: SelectFieldSchema<string>;\n /** Optional config fields rendered in the detail panel below the popover. Each field's key becomes a variable. */\n configFields?: PresetConfigField[];\n}\n\n/**\n * Pre-configured data source presets\n */\nexport const DATA_SOURCE_PRESETS: DataSourcePreset[] = [\n {\n id: \"rep-most-shared\",\n name: \"Most Shared Visits\",\n description: \"Content with the most share-link click-throughs\",\n endpoint:\n \"/v2025-06/reps/{rep_id}/most_shared?shareable_type={shareable_type}&limit={limit}&period={period}&language_iso={language_iso}\",\n resultPath: \"resources\",\n compatibleWidgets: [\n \"CarouselWidget\",\n \"ListWidget\",\n \"NestedWidget\",\n \"TableWidget\",\n ],\n menuField: {\n key: \"shareable_type\",\n label: \"Content Type\",\n type: \"select\",\n options: [\n { label: \"Products\", value: \"products\" },\n { label: \"Media\", value: \"media\" },\n { label: \"Pages\", value: \"pages\" },\n { label: \"Libraries\", value: \"libraries\" },\n { label: \"Enrollment Packs\", value: \"enrollment_packs\" },\n ],\n defaultValue: \"products\",\n },\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 20,\n description: \"Maximum number of items to show\",\n },\n {\n key: \"period\",\n label: \"Time Range\",\n type: \"select\",\n options: [\n { label: \"7 days\", value: \"7d\" },\n { label: \"30 days\", value: \"30d\" },\n { label: \"90 days\", value: \"90d\" },\n { label: \"1 year\", value: \"1y\" },\n { label: \"All time\", value: \"all\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n {\n id: \"rep-most-viewed\",\n name: \"Most Viewed\",\n description: \"Most viewed content\",\n endpoint:\n \"/v2025-06/reps/{rep_id}/most_viewed?shareable_type={shareable_type}&limit={limit}&period={period}&language_iso={language_iso}\",\n resultPath: \"resources\",\n compatibleWidgets: [\n \"CarouselWidget\",\n \"ListWidget\",\n \"NestedWidget\",\n \"TableWidget\",\n ],\n menuField: {\n key: \"shareable_type\",\n label: \"Content Type\",\n type: \"select\",\n options: [\n { label: \"Products\", value: \"products\" },\n { label: \"Media\", value: \"media\" },\n { label: \"Pages\", value: \"pages\" },\n { label: \"Libraries\", value: \"libraries\" },\n { label: \"Enrollment Packs\", value: \"enrollment_packs\" },\n ],\n defaultValue: \"products\",\n },\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 20,\n description: \"Maximum number of items to show\",\n },\n {\n key: \"period\",\n label: \"Time Range\",\n type: \"select\",\n options: [\n { label: \"7 days\", value: \"7d\" },\n { label: \"30 days\", value: \"30d\" },\n { label: \"90 days\", value: \"90d\" },\n { label: \"1 year\", value: \"1y\" },\n { label: \"All time\", value: \"all\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n {\n id: \"customer-orders\",\n name: \"Orders\",\n description: \"Customer order history\",\n endpoint:\n \"/v202506/orders?customer_id={customer_id}&page[limit]={limit}&status={status}\",\n resultPath: \"orders\",\n transform: \"toOrderTableProps\",\n compatibleWidgets: [\"TableWidget\"],\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 50,\n description: \"Maximum number of orders to show\",\n },\n {\n key: \"status\",\n label: \"Status\",\n type: \"select\",\n options: [\n { label: \"All\", value: \"all\" },\n { label: \"Paid\", value: \"paid\" },\n { label: \"Unpaid\", value: \"unpaid\" },\n { label: \"Refunded\", value: \"refunded\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n {\n id: \"customer-subscriptions\",\n name: \"Subscriptions\",\n description: \"Customer subscriptions\",\n // Subscriptions endpoint is unversioned (legacy API), orders uses v202506\n endpoint:\n \"/subscriptions?customer_id={customer_id}&per_page={limit}&status={status}\",\n resultPath: \"subscriptions\",\n transform: \"toSubscriptionTableProps\",\n compatibleWidgets: [\"TableWidget\"],\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 50,\n description: \"Maximum number of subscriptions to show\",\n },\n {\n key: \"status\",\n label: \"Status\",\n type: \"select\",\n options: [\n { label: \"All\", value: \"all\" },\n { label: \"Active\", value: \"active\" },\n { label: \"Paused\", value: \"paused\" },\n { label: \"Cancelled\", value: \"cancelled\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n];\n\n/** Lookup map for O(1) preset resolution */\nconst PRESET_MAP = new Map<string, DataSourcePreset>(\n DATA_SOURCE_PRESETS.map((p) => [p.id, p]),\n);\n\n/**\n * Resolves a preset by ID, returning the current preset definition.\n * Returns undefined if the preset ID is not recognized.\n */\nexport function resolvePreset(presetId: string): DataSourcePreset | undefined {\n return PRESET_MAP.get(presetId);\n}\n\n/**\n * If the source is an API source with a presetId, returns a copy with\n * endpoint, resultPath, and transform resolved from the current preset.\n * Falls back to stored values if the preset is unknown.\n * Non-API sources are returned as-is.\n */\nexport function resolveSource<T extends DataSource>(source: T): T {\n if (source.type !== \"api\" || !source.presetId) return source;\n\n const preset = resolvePreset(source.presetId);\n if (!preset) {\n console.warn(\n `[DataSource] Unknown preset \"${source.presetId}\", falling back to stored values`,\n );\n return source;\n }\n\n return {\n ...source,\n endpoint: preset.endpoint,\n resultPath: preset.resultPath,\n transform: preset.transform ?? source.transform,\n } as T;\n}\n","import { useQueries } from \"@tanstack/react-query\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\nimport type {\n DataSourceRegistry,\n WidgetDataResult,\n DataSourceContext,\n DataSource,\n} from \"@fluid-app/portal-core/data-sources/types\";\nimport { resolveSource } from \"@fluid-app/portal-core/data-sources/presets\";\nimport { useDataSourceApiOptional } from \"@fluid-app/portal-core/data-source-api-context\";\nimport { useDataSourceRegistryConfig } from \"./registry-context\";\n\ninterface UseWidgetDataOptions {\n /** Override the default registry from context */\n registry?: DataSourceRegistry | undefined;\n /** Base URL for API calls (e.g., \"https://api.fluid.app/api\") */\n baseUrl?: string | undefined;\n}\n\n/**\n * Generates a cache key for the raw data fetch (endpoint/items identity only).\n * Transforms and targetProps are NOT included — they are applied per-widget\n * after reading from the shared cache.\n */\nfunction getSourceKey(source: DataSource): string {\n if (source.type === \"api\") {\n const varsKey = source.variables\n ? `:${JSON.stringify(source.variables)}`\n : \"\";\n // Use presetId as identity when available — keeps cache key stable across preset endpoint changes\n const identity = source.presetId ?? source.endpoint;\n return `${identity}${varsKey}`;\n }\n if (source.type === \"custom\") {\n const itemKeys =\n source.selectedItems?.map((item) => {\n return `${item.shareableType}:${item.id}`;\n }) ?? [];\n return `custom:${itemKeys.join(\",\")}`;\n }\n if (source.type === \"static\") {\n return `static:${source.staticType}:${source.selectedId}`;\n }\n return \"unknown\";\n}\n\n/**\n * Resolves cached raw data into widget props by applying each widget's own\n * transforms and targetProps mapping.\n */\nfunction resolvePropsFromQueries<T>(\n queryResults: ReadonlyArray<{\n data?: unknown;\n isLoading: boolean;\n error: Error | null;\n }>,\n sources: DataSource[],\n registry: DataSourceRegistry,\n errorConfig?: { fallback?: unknown },\n): T | undefined {\n if (sources.length === 0) return undefined;\n if (queryResults.some((q) => q.isLoading && !q.data)) return undefined;\n\n const failedQuery = queryResults.find((q) => q.error);\n const hasError = !!failedQuery?.error;\n\n if (hasError && errorConfig?.fallback) {\n return errorConfig.fallback as T;\n }\n\n if (hasError) {\n return undefined;\n }\n\n const resolvedProps: Record<string, unknown> = {};\n\n for (let i = 0; i < queryResults.length; i++) {\n const query = queryResults[i];\n const source = sources[i];\n if (!query?.data || !source) continue;\n\n // Sentry fix: FLUID-ADMIN-1DH — source or targetProps can be undefined from malformed widget config\n if (!source.targetProps) continue;\n\n // Apply this widget's transform to the cached raw data\n let result: unknown = query.data;\n if (source.transform) {\n const transformer = registry.transformers[source.transform];\n if (transformer) {\n result = transformer(result, source);\n } else {\n console.warn(`Transform \"${source.transform}\" not found in registry`);\n }\n }\n\n // Map to this widget's targetProps\n if (\n result !== null &&\n typeof result === \"object\" &&\n !Array.isArray(result) &&\n source.targetProps.length > 1\n ) {\n const resultObj = result as Record<string, unknown>;\n for (const prop of source.targetProps) {\n if (prop in resultObj) {\n resolvedProps[prop] = resultObj[prop];\n }\n }\n } else {\n for (const prop of source.targetProps) {\n resolvedProps[prop] = result;\n }\n }\n }\n\n return resolvedProps as T;\n}\n\n/**\n * Hook that fetches and resolves data sources for a widget using React Query.\n *\n * Raw API data is cached and shared across widgets with the same data source.\n * Transforms and targetProps mapping are applied per-widget after cache reads,\n * so multiple widgets can share one fetch but resolve data independently.\n */\nexport function useWidgetData<T = Record<string, unknown>>(\n widget: WidgetSchema,\n options?: UseWidgetDataOptions,\n): WidgetDataResult<T> {\n const config = useDataSourceRegistryConfig();\n const registry = options?.registry ?? config.registry;\n const baseUrl = options?.baseUrl ?? config.baseUrl;\n const getApiHeaders = config.getApiHeaders;\n const variables = config.variables;\n // useDataSourceApiOptional returns null outside a DataSourceApiProvider.\n // This allows widgets with zero data sources to render in isolation\n // (Storybook, unit tests). Fetchers that require api will throw at call\n // time if it's missing — not at render time for every widget.\n const api = useDataSourceApiOptional() ?? undefined;\n\n // Resolve preset-backed sources to their current endpoint/resultPath/transform\n const sources = useMemo(\n () => (widget.dataSource?.sources ?? []).map(resolveSource),\n [widget.dataSource?.sources],\n );\n const errorConfig = widget.dataSource?.error;\n const widgetId = widget.id ?? \"unknown\";\n const widgetType = widget.type;\n\n const queryResultsRef = useRef<Array<{ refetch: () => void }>>([]);\n\n // Cache only raw fetched data — no transforms or source objects stored\n const results = useQueries({\n queries: sources.map((source: DataSource) => ({\n queryKey: [\n \"portal-widget-data\",\n getSourceKey(source),\n baseUrl,\n variables,\n ] as const,\n queryFn: async ({\n signal,\n }: {\n signal: AbortSignal;\n }): Promise<unknown> => {\n const context: DataSourceContext = {\n widgetId,\n widgetType,\n signal,\n baseUrl,\n getApiHeaders,\n variables,\n api,\n };\n\n const fetcher = registry.fetchers[source.type];\n if (!fetcher) {\n throw new Error(\n `No fetcher registered for source type: ${source.type}`,\n );\n }\n\n return fetcher(source, context);\n },\n enabled: sources.length > 0,\n retry: errorConfig?.retryCount ?? 0,\n retryDelay: errorConfig?.retryDelay ?? 1000,\n refetchInterval: source.refreshInterval || false,\n })),\n });\n\n // Update ref for refetch callback\n queryResultsRef.current = results;\n\n // Aggregate loading state\n const isLoading = results.some((q) => q.isLoading);\n\n // Get first error from any failed query\n const failedQuery = results.find((q) => q.error);\n const error =\n failedQuery?.error instanceof Error\n ? failedQuery.error\n : failedQuery?.error\n ? new Error(String(failedQuery.error))\n : null;\n\n // Stable fingerprint that changes only when query data or loading states change\n const queryFingerprint = results\n .map((r) => `${r.dataUpdatedAt}:${r.isLoading}`)\n .join(\",\");\n\n // Resolve data: apply per-widget transforms and map to targetProps\n const resultsRef = useRef(results);\n resultsRef.current = results;\n\n const data = useMemo(() => {\n const querySnapshots = resultsRef.current.map((q) => ({\n data: q.data,\n isLoading: q.isLoading,\n error: q.error instanceof Error ? q.error : null,\n }));\n return resolvePropsFromQueries<T>(\n querySnapshots,\n sources,\n registry,\n errorConfig,\n );\n }, [queryFingerprint, sources, registry, errorConfig]);\n\n // Stable refetch callback using ref\n const refetch = useCallback(() => {\n queryResultsRef.current.forEach((q) => q.refetch());\n }, []);\n\n return {\n data,\n isLoading,\n error,\n refetch,\n };\n}\n","import type React from \"react\";\n\nexport function ErrorState(): React.JSX.Element {\n return (\n <div className=\"flex min-h-[120px] flex-col items-center justify-center p-6 text-center\">\n <p className=\"text-lg font-semibold\">Something Went Wrong</p>\n <p className=\"text-muted-foreground text-sm\">\n Please contact a company admin for help\n </p>\n </div>\n );\n}\n","import type React from \"react\";\nimport { memo, useMemo, type ComponentType, type ReactNode } from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\nimport { useWidgetData } from \"./use-widget-data\";\nimport { ErrorState } from \"./ErrorState\";\n\nexport interface DataAwareWidgetProps {\n widget: WidgetSchema;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Component: ComponentType<any>;\n /** Additional props to pass through (e.g., edit mode callbacks) */\n additionalProps?: Record<string, unknown>;\n /** Custom loading component */\n loadingComponent?: ReactNode;\n /** Custom error component */\n errorComponent?: (error: Error) => ReactNode;\n /** Base URL for API calls (e.g., \"https://api.fluid.app/api\") */\n baseUrl?: string | undefined;\n}\n\n// Empty object constant to avoid creating new references\nconst EMPTY_OBJECT: Record<string, unknown> = {};\n\n/**\n * Wrapper component that resolves data sources before rendering the widget.\n * Merges resolved data with static props.\n */\nfunction DataAwareWidgetImpl({\n widget,\n Component,\n additionalProps,\n loadingComponent,\n errorComponent,\n baseUrl,\n}: DataAwareWidgetProps): React.JSX.Element | null {\n // Use stable empty object if no additionalProps provided\n const stableAdditionalProps = additionalProps ?? EMPTY_OBJECT;\n const { data, isLoading, error } = useWidgetData(widget, { baseUrl });\n\n // Merge static props with resolved data\n // Data takes precedence (allows overriding defaults)\n // Memoized to prevent unnecessary child re-renders\n // Note: Must be called before any early returns to satisfy Rules of Hooks\n const mergedProps = useMemo(\n () => ({\n ...widget.props,\n ...data,\n ...stableAdditionalProps,\n }),\n [widget.props, data, stableAdditionalProps],\n );\n\n // Show loading state\n if (isLoading && widget.dataSource?.loading?.showSkeleton !== false) {\n if (loadingComponent) {\n return <>{loadingComponent}</>;\n }\n // Default skeleton - can be customized\n return (\n <div\n className=\"bg-muted animate-pulse rounded-md\"\n style={{ minHeight: 100 }}\n >\n <span className=\"sr-only\">Loading...</span>\n </div>\n );\n }\n\n // Show error state (if no fallback was applied)\n if (error && !data) {\n if (errorComponent) {\n return <>{errorComponent(error)}</>;\n }\n // Default error display\n return <ErrorState />;\n }\n\n return <Component {...mergedProps} />;\n}\n\n/**\n * Memoized wrapper component that resolves data sources before rendering the widget.\n * Prevents re-renders when parent re-renders but props haven't changed.\n */\nexport const DataAwareWidget: React.NamedExoticComponent<DataAwareWidgetProps> =\n memo(DataAwareWidgetImpl);\n","import type { ComponentType } from \"react\";\nimport { useCallback } from \"react\";\nimport type React from \"react\";\nimport type {\n WidgetSchema,\n TypedWidgetSchema,\n WidgetPath,\n} from \"@fluid-app/portal-core/types\";\nimport { WIDGET_TYPE_NAMES } from \"@fluid-app/portal-core/types\";\nimport { DataAwareWidget } from \"@fluid-app/portal-react/data-sources/DataAwareWidget\";\nimport { RegistryProvider, useRegistry } from \"../contexts/RegistryContext\";\n\nexport interface ScreenRendererProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, ComponentType<any>>,\n> {\n /** Array of widget schemas to render */\n screen: TypedWidgetSchema<T>[] | WidgetSchema[];\n /** Widget registry mapping type names to components */\n registry?: T;\n /** Container widgets (like LayoutWidget) receive these additional props */\n containerWidgetTypes?: string[];\n /** Additional CSS classes for the wrapper div */\n className?: string;\n}\n\ninterface ScreenRendererContentProps {\n screen: WidgetSchema[];\n containerWidgetTypes: string[];\n className?: string | undefined;\n}\n\n/**\n * Internal component that uses the registry from context.\n * This allows us to avoid prop drilling the registry.\n */\nfunction ScreenRendererContent({\n screen,\n containerWidgetTypes,\n className,\n}: ScreenRendererContentProps) {\n const registry = useRegistry();\n\n // Check if a widget type is a container\n const isContainerWidget = useCallback(\n (widgetType: string) => containerWidgetTypes.includes(widgetType),\n [containerWidgetTypes],\n );\n\n // Render widgets recursively with path tracking\n const renderWidget = useCallback(\n (widget: WidgetSchema, index: number, currentPath: WidgetPath) => {\n const Component = registry[widget.type];\n if (!Component) {\n console.warn(\n `Widget type \"${String(widget.type)}\" not found in registry`,\n );\n return null;\n }\n\n const widgetPath = [...currentPath, index];\n\n // Build additional props for container widgets\n const additionalProps = isContainerWidget(widget.type)\n ? {\n widgetId: widget.id,\n widgetPath,\n }\n : {};\n\n const props = {\n ...widget.props,\n ...additionalProps,\n };\n\n // Wrap data-bound widgets with DataAwareWidget to resolve data sources\n if (widget.dataSource) {\n return (\n <div\n key={widget.id || index}\n className=\"h-full w-full overflow-x-hidden\"\n >\n <DataAwareWidget widget={widget} Component={Component} />\n </div>\n );\n }\n\n return (\n <div\n key={widget.id || index}\n className=\"h-full w-full overflow-x-hidden\"\n >\n <Component {...props} />\n </div>\n );\n },\n [registry, isContainerWidget],\n );\n\n return (\n <div className={className || \"h-full w-full\"}>\n {screen?.map((item, index) => {\n // Skip null items (empty grid cells)\n if (!item) return null;\n return renderWidget(item, index, []);\n })}\n </div>\n );\n}\n\n/**\n * ScreenRenderer - View-only component for rendering widget screens.\n *\n * This is a simplified version designed for the SDK that only handles\n * rendering widgets without edit mode or drag-and-drop functionality.\n *\n * Features:\n * - Static rendering of widgets\n * - Registry context: No prop drilling for widget registry\n * - Container widget support with path tracking\n *\n * Usage:\n * ```tsx\n * import { ScreenRenderer } from '@fluid-app/portal-widgets/core';\n * import { WIDGET_REGISTRY } from '@fluid-app/portal-widgets/widgets';\n *\n * <ScreenRenderer\n * screen={widgets}\n * registry={WIDGET_REGISTRY}\n * />\n * ```\n */\nexport function ScreenRenderer<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, ComponentType<any>>,\n>(props: ScreenRendererProps<T>): React.JSX.Element {\n const {\n screen,\n registry,\n containerWidgetTypes = [\n WIDGET_TYPE_NAMES.Layout,\n WIDGET_TYPE_NAMES.Container,\n ],\n className,\n } = props;\n\n // Conditionally pass registry prop to satisfy exactOptionalPropertyTypes\n // When registry is undefined, we omit it entirely and let RegistryProvider inherit from parent\n const registryProviderProps = registry !== undefined ? { registry } : {};\n\n return (\n <RegistryProvider {...registryProviderProps}>\n {/* Type assertion required: TypedWidgetSchema<T>[] is a subtype of WidgetSchema[]\n when T's components accept props compatible with WidgetSchema props.\n This enables type-safe widget rendering with custom registries while allowing\n the internal renderer to work with the base WidgetSchema type. */}\n <ScreenRendererContent\n screen={screen as WidgetSchema[]}\n containerWidgetTypes={containerWidgetTypes}\n className={className}\n />\n </RegistryProvider>\n );\n}\n"],"mappings":";;;;;;;AAGA,MAAM,wBAAA,GAAA,MAAA,eAA2D,KAAK;AAEtE,MAAa,wBAAwB,qBAAqB;;;;;;;AAsB1D,SAAgB,2BAAiD;AAC/D,SAAA,GAAA,MAAA,YAAkB,qB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,gBAAgB,OAAO,OAAO,KAAK,CAAC,yBACrC;AACD,UAAO;;EAGT,MAAM,aAAa,CAAC,GAAG,aAAa,MAAM;EAG1C,MAAM,kBAAkB,kBAAkB,OAAO,KAAK,GAClD;GACE,UAAU,OAAO;GACjB;GACD,GACD,EAAE;EAEN,MAAM,QAAQ;GACZ,GAAG,OAAO;GACV,GAAG;GACJ;AAGD,MAAI,OAAO,WACT,QACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;GAEE,WAAU;aAEV,iBAAA,GAAA,kBAAA,KAAC,iBAAD;IAAyB;IAAmB;IAAa,CAAA;GACrD,EAJC,OAAO,MAAM,MAId;AAIV,SACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;GAEE,WAAU;aAEV,iBAAA,GAAA,kBAAA,KAAC,WAAD,EAAW,GAAI,OAAS,CAAA;GACpB,EAJC,OAAO,MAAM,MAId;IAGV,CAAC,UAAU,kBAAkB,CAC9B;AAED,QACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EAAK,WAAW,aAAa;YAC1B,QAAQ,KAAK,MAAM,UAAU;AAE5B,OAAI,CAAC,KAAM,QAAO;AAClB,UAAO,aAAa,MAAM,OAAO,EAAE,CAAC;IACpC;EACE,CAAA;;;;;;;;;;;;;;;;;;;;;;;;AA0BV,SAAgB,eAGd,OAAkD;CAClD,MAAM,EACJ,QACA,UACA,uBAAuB,CACrB,kBAAkB,QAClB,kBAAkB,UACnB,EACD,cACE;AAMJ,QACE,iBAAA,GAAA,kBAAA,KAAC,kBAAD;EAAkB,GAHU,aAAa,KAAA,IAAY,EAAE,UAAU,GAAG,EAAE;YAQpE,iBAAA,GAAA,kBAAA,KAAC,uBAAD;GACU;GACc;GACX;GACX,CAAA;EACe,CAAA"}
1
+ {"version":3,"file":"ScreenRenderer-Ct1w4PNu.cjs","names":["useDataSourceRegistryConfig"],"sources":["../../core/src/data-source-api-context.ts","../../widgets/src/contexts/RegistryContext.tsx","../../widgets/src/contexts/ScreenRendererContext.tsx","../../core/src/types/widget-schema.ts","../../core/src/data-sources/presets.ts","../../react/src/data-sources/use-widget-data.ts","../../react/src/data-sources/ErrorState.tsx","../../react/src/data-sources/DataAwareWidget.tsx","../../widgets/src/core/ScreenRenderer.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { DataSourceApi } from \"./data-source-api\";\n\nconst DataSourceApiContext = createContext<DataSourceApi | null>(null);\n\nexport const DataSourceApiProvider = DataSourceApiContext.Provider;\n\n/**\n * Access the DataSourceApi adapter.\n * Throws if no DataSourceApiProvider ancestor exists.\n */\nexport function useDataSourceApi(): DataSourceApi {\n const api = useContext(DataSourceApiContext);\n if (!api) {\n throw new Error(\n \"useDataSourceApi must be used within a DataSourceApiProvider\",\n );\n }\n return api;\n}\n\n/**\n * Access the DataSourceApi adapter without throwing.\n * Returns null when no DataSourceApiProvider ancestor exists.\n * Use in isolated rendering contexts (Storybook, unit tests) where the\n * full provider stack may not be wired.\n */\nexport function useDataSourceApiOptional(): DataSourceApi | null {\n return useContext(DataSourceApiContext);\n}\n","import React, {\n createContext,\n useContext,\n type ComponentType,\n type ReactNode,\n} from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\n\n/**\n * Base props interface for widget components.\n * All widgets receive at least these props from the ScreenRenderer.\n */\nexport interface WidgetBaseProps {\n readonly widget: WidgetSchema;\n readonly path?: readonly number[];\n}\n\n/**\n * Generic widget component type.\n * Widgets receive WidgetBaseProps and may have additional props.\n */\nexport type WidgetComponent<P extends WidgetBaseProps = WidgetBaseProps> =\n ComponentType<P>;\n\n/**\n * Registry mapping widget type names to their components.\n * The keys are widget type strings (e.g., \"TextWidget\", \"ButtonWidget\").\n * Using WidgetComponent for the value type provides better type safety than `any`.\n */\nexport type WidgetRegistry = Readonly<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Widget props vary by type\n Record<string, WidgetComponent<any>>\n>;\n\n/**\n * Context for providing the widget registry to all components in the tree.\n * This eliminates prop drilling and makes the registry accessible anywhere.\n *\n * Default to undefined - registry must be provided by a RegistryProvider.\n */\nexport const RegistryContext: React.Context<WidgetRegistry | undefined> =\n createContext<WidgetRegistry | undefined>(undefined);\n\nexport interface RegistryProviderProps {\n registry?: WidgetRegistry;\n children: ReactNode;\n}\n\n/**\n * Provider component that makes the widget registry available to all descendants.\n * A registry must be provided either via props or by nesting within another RegistryProvider.\n */\nexport function RegistryProvider({\n registry,\n children,\n}: RegistryProviderProps): React.JSX.Element {\n // If no registry provided, inherit from parent provider\n const parentRegistry = useContext(RegistryContext);\n const contextValue = registry ?? parentRegistry;\n\n if (!contextValue) {\n throw new Error(\n \"RegistryProvider requires a registry prop or must be nested within another RegistryProvider.\",\n );\n }\n\n return (\n <RegistryContext.Provider value={contextValue}>\n {children}\n </RegistryContext.Provider>\n );\n}\n\n/**\n * Hook to access the widget registry from anywhere in the component tree.\n * Must be used within a RegistryProvider that has a registry prop.\n */\nexport function useRegistry(): WidgetRegistry {\n const registry = useContext(RegistryContext);\n\n if (!registry) {\n throw new Error(\n \"useRegistry must be used within a RegistryProvider with a registry prop.\",\n );\n }\n\n return registry;\n}\n","import React, { createContext, useContext, type ComponentType } from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\nimport type { WidgetRegistry } from \"./RegistryContext\";\n\n/**\n * Props that any ScreenRenderer must accept.\n * This is the minimal interface used by container widgets (e.g. LayoutWidget)\n * to render their children.\n */\nexport interface ScreenRendererComponentProps {\n screen: WidgetSchema[];\n registry?: WidgetRegistry;\n className?: string;\n}\n\n/**\n * Context for providing an alternative ScreenRenderer component.\n *\n * This allows packages like portal-builder to inject their own ScreenRenderer\n * (with edit mode, drag-and-drop, etc.) so that container widgets in portal-widgets\n * use the richer renderer instead of the basic view-only one.\n *\n * Default is undefined — container widgets fall back to the local ScreenRenderer import.\n */\nexport const ScreenRendererContext: React.Context<\n ComponentType<ScreenRendererComponentProps> | undefined\n> = createContext<ComponentType<ScreenRendererComponentProps> | undefined>(\n undefined,\n);\n\n/**\n * Hook to get the ScreenRenderer component from context.\n * Returns undefined if no override has been provided.\n */\nexport function useScreenRenderer():\n | ComponentType<ScreenRendererComponentProps>\n | undefined {\n return useContext(ScreenRendererContext);\n}\n","import type { DataSourceConfig } from \"../data-sources/types\";\n\n/**\n * Generic component type — avoids React dependency in core.\n * Accepts both function components and class component constructors.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyComponent = ((props: any) => any) | (new (props: any) => any);\n\n/**\n * Widget type names as a const object.\n * This serves as the single source of truth for widget discriminants.\n * Use `as const` for literal type inference (safety-as-const-deep-readonly rule).\n */\nexport const WIDGET_TYPE_NAMES = {\n Alert: \"AlertWidget\",\n BulletList: \"BulletListWidget\",\n Calendar: \"CalendarWidget\",\n Card: \"CardWidget\",\n Carousel: \"CarouselWidget\",\n CatchUp: \"CatchUpWidget\",\n Chart: \"ChartWidget\",\n Container: \"ContainerWidget\",\n Embed: \"EmbedWidget\",\n Image: \"ImageWidget\",\n Layout: \"LayoutWidget\",\n Link: \"LinkWidget\",\n List: \"ListWidget\",\n MySite: \"MySiteWidget\",\n Nested: \"NestedWidget\",\n Points: \"PointsWidget\",\n QuickLinks: \"QuickLinksWidget\",\n QuickShare: \"QuickShareWidget\",\n RecentActivity: \"RecentActivityWidget\",\n Separator: \"SeparatorWidget\",\n Spacer: \"SpacerWidget\",\n Table: \"TableWidget\",\n Text: \"TextWidget\",\n ToDo: \"ToDoWidget\",\n Video: \"VideoWidget\",\n} as const;\n\n/**\n * Union of all known widget type names.\n * Derived from WIDGET_TYPE_NAMES to avoid duplication (deriving-typeof-for-object-keys rule).\n */\nexport type WidgetTypeName =\n (typeof WIDGET_TYPE_NAMES)[keyof typeof WIDGET_TYPE_NAMES];\n\n/**\n * Legacy alias for backwards compatibility.\n * Prefer using WidgetTypeName for new code when you need the union type.\n */\nexport type WidgetType = string;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type WidgetRegistry = Record<WidgetType, AnyComponent>;\n\n/**\n * Base widget schema with loose typing for runtime data.\n * Use TypedWidgetSchema<T> when you have a known registry for better type safety.\n */\nexport type WidgetSchema = {\n readonly type: WidgetType;\n readonly props: Readonly<Record<string, unknown>>;\n readonly id?: string; // Optional unique identifier for drag-and-drop\n /** Optional data source configuration for data-bound widgets */\n readonly dataSource?: DataSourceConfig | undefined;\n /** Column index for masonry layouts (0-indexed) */\n readonly columnIndex?: number;\n};\n\n/**\n * Type-safe widget schema based on registry.\n * Uses discriminated unions - the `type` field serves as discriminant.\n * When narrowed (e.g., `if (widget.type === \"AlertWidget\")`),\n * TypeScript automatically knows the correct props type.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type TypedWidgetSchema<T extends Record<string, AnyComponent>> = {\n [K in keyof T]: {\n readonly type: K;\n readonly props: Readonly<\n T[K] extends (props: infer P) => any\n ? P\n : T[K] extends new (props: infer P) => any\n ? P\n : never\n >;\n readonly id?: string;\n readonly dataSource?: DataSourceConfig | undefined;\n /** Column index for masonry layouts (0-indexed) */\n readonly columnIndex?: number;\n };\n}[keyof T];\n\n/**\n * Widget path in the tree - array of indices.\n * Readonly tuple to prevent accidental mutation.\n */\nexport type WidgetPath = readonly number[];\n\n// ============================================================================\n// Type Guards and Assertion Functions\n// ============================================================================\n\n/**\n * Type predicate to check if a string is a known widget type name.\n * Use for runtime validation of widget types.\n *\n * @example\n * if (isWidgetTypeName(widget.type)) {\n * // TypeScript knows widget.type is WidgetTypeName\n * }\n */\nexport function isWidgetTypeName(type: string): type is WidgetTypeName {\n // Type assertion required in type guard: Object.values() returns string[], but we\n // need to check against WidgetTypeName values. The assertion is safe because we're\n // checking membership, and the return type predicate ensures correct narrowing.\n return Object.values(WIDGET_TYPE_NAMES).includes(type as WidgetTypeName);\n}\n\n/**\n * Type predicate to check if a widget has a specific type.\n * Enables type-safe widget narrowing without `as` assertions.\n *\n * @example\n * if (isWidgetType(widget, \"LayoutWidget\")) {\n * // TypeScript knows widget.type === \"LayoutWidget\"\n * // and widget.props is LayoutWidget props\n * }\n */\nexport function isWidgetType<T extends WidgetTypeName>(\n widget: WidgetSchema | null | undefined,\n typeName: T,\n): widget is WidgetSchema & { readonly type: T } {\n return widget != null && widget.type === typeName;\n}\n\n/**\n * Helper for exhaustive switch statements on widget types.\n * Use in the default case to ensure all widget types are handled.\n *\n * @example\n * switch (widget.type) {\n * case \"AlertWidget\": return handleAlert();\n * case \"TextWidget\": return handleText();\n * // ... all other widget types\n * default: return assertNever(widget.type, \"widget type\");\n * }\n */\nexport function assertNever(value: never, context?: string): never {\n const message = context\n ? `Unexpected ${context}: ${String(value)}`\n : `Unexpected value: ${String(value)}`;\n throw new Error(message);\n}\n\n/**\n * Assertion function that throws if value is undefined.\n * Narrows the type to exclude undefined.\n *\n * @example\n * const widget = screen[0];\n * assertDefined(widget, \"widget at index 0\");\n * // TypeScript knows widget is defined here\n */\nexport function assertDefined<T>(\n value: T | undefined | null,\n name?: string,\n): asserts value is T {\n if (value == null) {\n throw new Error(name ? `${name} is required` : \"Value is required\");\n }\n}\n","/**\n * Data Source Presets Registry\n *\n * Configurable presets that allow users to select options via sub-menus\n * and fine-tune parameters in a detail panel.\n */\n\nimport type {\n SelectFieldSchema,\n NumberFieldSchema,\n} from \"../registries/property-schema-types\";\nimport type { DataSource } from \"./types\";\n\n/** Widget types that can use data sources */\nexport type DataSourceCompatibleWidget =\n | \"CarouselWidget\"\n | \"ChartWidget\"\n | \"EmbedWidget\"\n | \"ImageWidget\"\n | \"ListWidget\"\n | \"NestedWidget\"\n | \"TableWidget\"\n | \"VideoWidget\";\n\n/** Field types supported in preset config panels */\nexport type PresetConfigField = SelectFieldSchema<string> | NumberFieldSchema;\n\n/** A preset data source configuration */\nexport interface DataSourcePreset {\n /** Unique identifier for the preset */\n id: string;\n /** Human-readable name for display */\n name: string;\n /** Description of what data this endpoint provides */\n description: string;\n /** The API endpoint path (can include {variable} placeholders) */\n endpoint: string;\n /** Transformer name to apply to the data */\n transform?: string;\n /** Optional path to extract data from response (e.g., \"data.items\") */\n resultPath?: string;\n /** Which widgets this preset is compatible with */\n compatibleWidgets: DataSourceCompatibleWidget[];\n /** Optional select field shown as a sub-menu. The field's key becomes a variable in the endpoint URL. */\n menuField?: SelectFieldSchema<string>;\n /** Optional config fields rendered in the detail panel below the popover. Each field's key becomes a variable. */\n configFields?: PresetConfigField[];\n}\n\n/**\n * Pre-configured data source presets\n */\nexport const DATA_SOURCE_PRESETS: DataSourcePreset[] = [\n {\n id: \"rep-most-shared\",\n name: \"Most Shared Visits\",\n description: \"Content with the most share-link click-throughs\",\n endpoint:\n \"/v2025-06/reps/{rep_id}/most_shared?shareable_type={shareable_type}&limit={limit}&period={period}&language_iso={language_iso}\",\n resultPath: \"resources\",\n compatibleWidgets: [\n \"CarouselWidget\",\n \"ListWidget\",\n \"NestedWidget\",\n \"TableWidget\",\n ],\n menuField: {\n key: \"shareable_type\",\n label: \"Content Type\",\n type: \"select\",\n options: [\n { label: \"Products\", value: \"products\" },\n { label: \"Media\", value: \"media\" },\n { label: \"Pages\", value: \"pages\" },\n { label: \"Libraries\", value: \"libraries\" },\n { label: \"Enrollment Packs\", value: \"enrollment_packs\" },\n ],\n defaultValue: \"products\",\n },\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 20,\n description: \"Maximum number of items to show\",\n },\n {\n key: \"period\",\n label: \"Time Range\",\n type: \"select\",\n options: [\n { label: \"7 days\", value: \"7d\" },\n { label: \"30 days\", value: \"30d\" },\n { label: \"90 days\", value: \"90d\" },\n { label: \"1 year\", value: \"1y\" },\n { label: \"All time\", value: \"all\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n {\n id: \"rep-most-viewed\",\n name: \"Most Viewed\",\n description: \"Most viewed content\",\n endpoint:\n \"/v2025-06/reps/{rep_id}/most_viewed?shareable_type={shareable_type}&limit={limit}&period={period}&language_iso={language_iso}\",\n resultPath: \"resources\",\n compatibleWidgets: [\n \"CarouselWidget\",\n \"ListWidget\",\n \"NestedWidget\",\n \"TableWidget\",\n ],\n menuField: {\n key: \"shareable_type\",\n label: \"Content Type\",\n type: \"select\",\n options: [\n { label: \"Products\", value: \"products\" },\n { label: \"Media\", value: \"media\" },\n { label: \"Pages\", value: \"pages\" },\n { label: \"Libraries\", value: \"libraries\" },\n { label: \"Enrollment Packs\", value: \"enrollment_packs\" },\n ],\n defaultValue: \"products\",\n },\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 20,\n description: \"Maximum number of items to show\",\n },\n {\n key: \"period\",\n label: \"Time Range\",\n type: \"select\",\n options: [\n { label: \"7 days\", value: \"7d\" },\n { label: \"30 days\", value: \"30d\" },\n { label: \"90 days\", value: \"90d\" },\n { label: \"1 year\", value: \"1y\" },\n { label: \"All time\", value: \"all\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n {\n id: \"customer-orders\",\n name: \"Orders\",\n description: \"Customer order history\",\n endpoint:\n \"/v202506/orders?customer_id={customer_id}&page[limit]={limit}&status={status}\",\n resultPath: \"orders\",\n transform: \"toOrderTableProps\",\n compatibleWidgets: [\"TableWidget\"],\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 50,\n description: \"Maximum number of orders to show\",\n },\n {\n key: \"status\",\n label: \"Status\",\n type: \"select\",\n options: [\n { label: \"All\", value: \"all\" },\n { label: \"Paid\", value: \"paid\" },\n { label: \"Unpaid\", value: \"unpaid\" },\n { label: \"Refunded\", value: \"refunded\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n {\n id: \"customer-subscriptions\",\n name: \"Subscriptions\",\n description: \"Customer subscriptions\",\n // Subscriptions endpoint is unversioned (legacy API), orders uses v202506\n endpoint:\n \"/subscriptions?customer_id={customer_id}&per_page={limit}&status={status}\",\n resultPath: \"subscriptions\",\n transform: \"toSubscriptionTableProps\",\n compatibleWidgets: [\"TableWidget\"],\n configFields: [\n {\n key: \"limit\",\n label: \"Limit\",\n type: \"number\",\n defaultValue: 10,\n min: 1,\n max: 50,\n description: \"Maximum number of subscriptions to show\",\n },\n {\n key: \"status\",\n label: \"Status\",\n type: \"select\",\n options: [\n { label: \"All\", value: \"all\" },\n { label: \"Active\", value: \"active\" },\n { label: \"Paused\", value: \"paused\" },\n { label: \"Cancelled\", value: \"cancelled\" },\n ],\n defaultValue: \"all\",\n },\n ],\n },\n];\n\n/** Lookup map for O(1) preset resolution */\nconst PRESET_MAP = new Map<string, DataSourcePreset>(\n DATA_SOURCE_PRESETS.map((p) => [p.id, p]),\n);\n\n/**\n * Resolves a preset by ID, returning the current preset definition.\n * Returns undefined if the preset ID is not recognized.\n */\nexport function resolvePreset(presetId: string): DataSourcePreset | undefined {\n return PRESET_MAP.get(presetId);\n}\n\n/**\n * If the source is an API source with a presetId, returns a copy with\n * endpoint, resultPath, and transform resolved from the current preset.\n * Falls back to stored values if the preset is unknown.\n * Non-API sources are returned as-is.\n */\nexport function resolveSource<T extends DataSource>(source: T): T {\n if (source.type !== \"api\" || !source.presetId) return source;\n\n const preset = resolvePreset(source.presetId);\n if (!preset) {\n console.warn(\n `[DataSource] Unknown preset \"${source.presetId}\", falling back to stored values`,\n );\n return source;\n }\n\n return {\n ...source,\n endpoint: preset.endpoint,\n resultPath: preset.resultPath,\n transform: preset.transform ?? source.transform,\n } as T;\n}\n","import { useQueries } from \"@tanstack/react-query\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\nimport type {\n DataSourceRegistry,\n WidgetDataResult,\n DataSourceContext,\n DataSource,\n} from \"@fluid-app/portal-core/data-sources/types\";\nimport { resolveSource } from \"@fluid-app/portal-core/data-sources/presets\";\nimport { useDataSourceApiOptional } from \"@fluid-app/portal-core/data-source-api-context\";\nimport { useDataSourceRegistryConfig } from \"./registry-context\";\n\ninterface UseWidgetDataOptions {\n /** Override the default registry from context */\n registry?: DataSourceRegistry | undefined;\n /** Base URL for API calls (e.g., \"https://api.fluid.app/api\") */\n baseUrl?: string | undefined;\n}\n\n/**\n * Generates a cache key for the raw data fetch (endpoint/items identity only).\n * Transforms and targetProps are NOT included — they are applied per-widget\n * after reading from the shared cache.\n */\nfunction getSourceKey(source: DataSource): string {\n if (source.type === \"api\") {\n const varsKey = source.variables\n ? `:${JSON.stringify(source.variables)}`\n : \"\";\n // Use presetId as identity when available — keeps cache key stable across preset endpoint changes\n const identity = source.presetId ?? source.endpoint;\n return `${identity}${varsKey}`;\n }\n if (source.type === \"custom\") {\n const itemKeys =\n source.selectedItems?.map((item) => {\n return `${item.shareableType}:${item.id}`;\n }) ?? [];\n return `custom:${itemKeys.join(\",\")}`;\n }\n if (source.type === \"static\") {\n return `static:${source.staticType}:${source.selectedId}`;\n }\n return \"unknown\";\n}\n\n/**\n * Resolves cached raw data into widget props by applying each widget's own\n * transforms and targetProps mapping.\n */\nfunction resolvePropsFromQueries<T>(\n queryResults: ReadonlyArray<{\n data?: unknown;\n isLoading: boolean;\n error: Error | null;\n }>,\n sources: DataSource[],\n registry: DataSourceRegistry,\n errorConfig?: { fallback?: unknown },\n): T | undefined {\n if (sources.length === 0) return undefined;\n if (queryResults.some((q) => q.isLoading && !q.data)) return undefined;\n\n const failedQuery = queryResults.find((q) => q.error);\n const hasError = !!failedQuery?.error;\n\n if (hasError && errorConfig?.fallback) {\n return errorConfig.fallback as T;\n }\n\n if (hasError) {\n return undefined;\n }\n\n const resolvedProps: Record<string, unknown> = {};\n\n for (let i = 0; i < queryResults.length; i++) {\n const query = queryResults[i];\n const source = sources[i];\n if (!query?.data || !source) continue;\n\n // Sentry fix: FLUID-ADMIN-1DH — source or targetProps can be undefined from malformed widget config\n if (!source.targetProps) continue;\n\n // Apply this widget's transform to the cached raw data\n let result: unknown = query.data;\n if (source.transform) {\n const transformer = registry.transformers[source.transform];\n if (transformer) {\n result = transformer(result, source);\n } else {\n console.warn(`Transform \"${source.transform}\" not found in registry`);\n }\n }\n\n // Map to this widget's targetProps\n if (\n result !== null &&\n typeof result === \"object\" &&\n !Array.isArray(result) &&\n source.targetProps.length > 1\n ) {\n const resultObj = result as Record<string, unknown>;\n for (const prop of source.targetProps) {\n if (prop in resultObj) {\n resolvedProps[prop] = resultObj[prop];\n }\n }\n } else {\n for (const prop of source.targetProps) {\n resolvedProps[prop] = result;\n }\n }\n }\n\n return resolvedProps as T;\n}\n\n/**\n * Hook that fetches and resolves data sources for a widget using React Query.\n *\n * Raw API data is cached and shared across widgets with the same data source.\n * Transforms and targetProps mapping are applied per-widget after cache reads,\n * so multiple widgets can share one fetch but resolve data independently.\n */\nexport function useWidgetData<T = Record<string, unknown>>(\n widget: WidgetSchema,\n options?: UseWidgetDataOptions,\n): WidgetDataResult<T> {\n const config = useDataSourceRegistryConfig();\n const registry = options?.registry ?? config.registry;\n const baseUrl = options?.baseUrl ?? config.baseUrl;\n const getApiHeaders = config.getApiHeaders;\n const variables = config.variables;\n // useDataSourceApiOptional returns null outside a DataSourceApiProvider.\n // This allows widgets with zero data sources to render in isolation\n // (Storybook, unit tests). Fetchers that require api will throw at call\n // time if it's missing — not at render time for every widget.\n const api = useDataSourceApiOptional() ?? undefined;\n\n // Resolve preset-backed sources to their current endpoint/resultPath/transform\n const sources = useMemo(\n () => (widget.dataSource?.sources ?? []).map(resolveSource),\n [widget.dataSource?.sources],\n );\n const errorConfig = widget.dataSource?.error;\n const widgetId = widget.id ?? \"unknown\";\n const widgetType = widget.type;\n\n const queryResultsRef = useRef<Array<{ refetch: () => void }>>([]);\n\n // Cache only raw fetched data — no transforms or source objects stored\n const results = useQueries({\n queries: sources.map((source: DataSource) => ({\n queryKey: [\n \"portal-widget-data\",\n getSourceKey(source),\n baseUrl,\n variables,\n ] as const,\n queryFn: async ({\n signal,\n }: {\n signal: AbortSignal;\n }): Promise<unknown> => {\n const context: DataSourceContext = {\n widgetId,\n widgetType,\n signal,\n baseUrl,\n getApiHeaders,\n variables,\n api,\n };\n\n const fetcher = registry.fetchers[source.type];\n if (!fetcher) {\n throw new Error(\n `No fetcher registered for source type: ${source.type}`,\n );\n }\n\n return fetcher(source, context);\n },\n enabled: sources.length > 0,\n retry: errorConfig?.retryCount ?? 0,\n retryDelay: errorConfig?.retryDelay ?? 1000,\n refetchInterval: source.refreshInterval || false,\n })),\n });\n\n // Update ref for refetch callback\n queryResultsRef.current = results;\n\n // Aggregate loading state\n const isLoading = results.some((q) => q.isLoading);\n\n // Get first error from any failed query\n const failedQuery = results.find((q) => q.error);\n const error =\n failedQuery?.error instanceof Error\n ? failedQuery.error\n : failedQuery?.error\n ? new Error(String(failedQuery.error))\n : null;\n\n // Stable fingerprint that changes only when query data or loading states change\n const queryFingerprint = results\n .map((r) => `${r.dataUpdatedAt}:${r.isLoading}`)\n .join(\",\");\n\n // Resolve data: apply per-widget transforms and map to targetProps\n const resultsRef = useRef(results);\n resultsRef.current = results;\n\n const data = useMemo(() => {\n const querySnapshots = resultsRef.current.map((q) => ({\n data: q.data,\n isLoading: q.isLoading,\n error: q.error instanceof Error ? q.error : null,\n }));\n return resolvePropsFromQueries<T>(\n querySnapshots,\n sources,\n registry,\n errorConfig,\n );\n }, [queryFingerprint, sources, registry, errorConfig]);\n\n // Stable refetch callback using ref\n const refetch = useCallback(() => {\n queryResultsRef.current.forEach((q) => q.refetch());\n }, []);\n\n return {\n data,\n isLoading,\n error,\n refetch,\n };\n}\n","import type React from \"react\";\n\nexport function ErrorState(): React.JSX.Element {\n return (\n <div className=\"flex min-h-[120px] flex-col items-center justify-center p-6 text-center\">\n <p className=\"text-lg font-semibold\">Something Went Wrong</p>\n <p className=\"text-muted-foreground text-sm\">\n Please contact a company admin for help\n </p>\n </div>\n );\n}\n","import type React from \"react\";\nimport { memo, useMemo, type ComponentType, type ReactNode } from \"react\";\nimport type { WidgetSchema } from \"@fluid-app/portal-core/types\";\nimport { useWidgetData } from \"./use-widget-data\";\nimport { ErrorState } from \"./ErrorState\";\n\nexport interface DataAwareWidgetProps {\n widget: WidgetSchema;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Component: ComponentType<any>;\n /** Additional props to pass through (e.g., edit mode callbacks) */\n additionalProps?: Record<string, unknown>;\n /** Custom loading component */\n loadingComponent?: ReactNode;\n /** Custom error component */\n errorComponent?: (error: Error) => ReactNode;\n /** Base URL for API calls (e.g., \"https://api.fluid.app/api\") */\n baseUrl?: string | undefined;\n}\n\n// Empty object constant to avoid creating new references\nconst EMPTY_OBJECT: Record<string, unknown> = {};\n\n/**\n * Wrapper component that resolves data sources before rendering the widget.\n * Merges resolved data with static props.\n */\nfunction DataAwareWidgetImpl({\n widget,\n Component,\n additionalProps,\n loadingComponent,\n errorComponent,\n baseUrl,\n}: DataAwareWidgetProps): React.JSX.Element | null {\n // Use stable empty object if no additionalProps provided\n const stableAdditionalProps = additionalProps ?? EMPTY_OBJECT;\n const { data, isLoading, error } = useWidgetData(widget, { baseUrl });\n\n // Merge static props with resolved data\n // Data takes precedence (allows overriding defaults)\n // Memoized to prevent unnecessary child re-renders\n // Note: Must be called before any early returns to satisfy Rules of Hooks\n const mergedProps = useMemo(\n () => ({\n ...widget.props,\n ...data,\n ...stableAdditionalProps,\n }),\n [widget.props, data, stableAdditionalProps],\n );\n\n // Show loading state\n if (isLoading && widget.dataSource?.loading?.showSkeleton !== false) {\n if (loadingComponent) {\n return <>{loadingComponent}</>;\n }\n // Default skeleton - can be customized\n return (\n <div\n className=\"bg-muted animate-pulse rounded-md\"\n style={{ minHeight: 100 }}\n >\n <span className=\"sr-only\">Loading...</span>\n </div>\n );\n }\n\n // Show error state (if no fallback was applied)\n if (error && !data) {\n if (errorComponent) {\n return <>{errorComponent(error)}</>;\n }\n // Default error display\n return <ErrorState />;\n }\n\n return <Component {...mergedProps} />;\n}\n\n/**\n * Memoized wrapper component that resolves data sources before rendering the widget.\n * Prevents re-renders when parent re-renders but props haven't changed.\n */\nexport const DataAwareWidget: React.NamedExoticComponent<DataAwareWidgetProps> =\n memo(DataAwareWidgetImpl);\n","import type { ComponentType } from \"react\";\nimport { useCallback } from \"react\";\nimport type React from \"react\";\nimport type {\n WidgetSchema,\n TypedWidgetSchema,\n WidgetPath,\n} from \"@fluid-app/portal-core/types\";\nimport { WIDGET_TYPE_NAMES } from \"@fluid-app/portal-core/types\";\nimport { DataAwareWidget } from \"@fluid-app/portal-react/data-sources/DataAwareWidget\";\nimport { RegistryProvider, useRegistry } from \"../contexts/RegistryContext\";\n\nexport interface ScreenRendererProps<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, ComponentType<any>>,\n> {\n /** Array of widget schemas to render */\n screen: TypedWidgetSchema<T>[] | WidgetSchema[];\n /** Widget registry mapping type names to components */\n registry?: T;\n /** Container widgets (like LayoutWidget) receive these additional props */\n containerWidgetTypes?: string[];\n /** Additional CSS classes for the wrapper div */\n className?: string;\n}\n\ninterface ScreenRendererContentProps {\n screen: WidgetSchema[];\n containerWidgetTypes: string[];\n className?: string | undefined;\n}\n\n/**\n * Internal component that uses the registry from context.\n * This allows us to avoid prop drilling the registry.\n */\nfunction ScreenRendererContent({\n screen,\n containerWidgetTypes,\n className,\n}: ScreenRendererContentProps) {\n const registry = useRegistry();\n\n // Check if a widget type is a container\n const isContainerWidget = useCallback(\n (widgetType: string) => containerWidgetTypes.includes(widgetType),\n [containerWidgetTypes],\n );\n\n // Render widgets recursively with path tracking\n const renderWidget = useCallback(\n (widget: WidgetSchema, index: number, currentPath: WidgetPath) => {\n const Component = registry[widget.type];\n if (!Component) {\n console.warn(\n `Widget type \"${String(widget.type)}\" not found in registry`,\n );\n return null;\n }\n\n const widgetPath = [...currentPath, index];\n\n // Build additional props for container widgets\n const additionalProps = isContainerWidget(widget.type)\n ? {\n widgetId: widget.id,\n widgetPath,\n }\n : {};\n\n const props = {\n ...widget.props,\n ...additionalProps,\n };\n\n // Wrap data-bound widgets with DataAwareWidget to resolve data sources\n if (widget.dataSource) {\n return (\n <div\n key={widget.id || index}\n className=\"h-full w-full overflow-x-hidden\"\n >\n <DataAwareWidget widget={widget} Component={Component} />\n </div>\n );\n }\n\n return (\n <div\n key={widget.id || index}\n className=\"h-full w-full overflow-x-hidden\"\n >\n <Component {...props} />\n </div>\n );\n },\n [registry, isContainerWidget],\n );\n\n return (\n <div className={className || \"h-full w-full\"}>\n {screen?.map((item, index) => {\n // Skip null items (empty grid cells)\n if (!item) return null;\n return renderWidget(item, index, []);\n })}\n </div>\n );\n}\n\n/**\n * ScreenRenderer - View-only component for rendering widget screens.\n *\n * This is a simplified version designed for the SDK that only handles\n * rendering widgets without edit mode or drag-and-drop functionality.\n *\n * Features:\n * - Static rendering of widgets\n * - Registry context: No prop drilling for widget registry\n * - Container widget support with path tracking\n *\n * Usage:\n * ```tsx\n * import { ScreenRenderer } from '@fluid-app/portal-widgets/core';\n * import { WIDGET_REGISTRY } from '@fluid-app/portal-widgets/widgets';\n *\n * <ScreenRenderer\n * screen={widgets}\n * registry={WIDGET_REGISTRY}\n * />\n * ```\n */\nexport function ScreenRenderer<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, ComponentType<any>>,\n>(props: ScreenRendererProps<T>): React.JSX.Element {\n const {\n screen,\n registry,\n containerWidgetTypes = [\n WIDGET_TYPE_NAMES.Layout,\n WIDGET_TYPE_NAMES.Container,\n ],\n className,\n } = props;\n\n // Conditionally pass registry prop to satisfy exactOptionalPropertyTypes\n // When registry is undefined, we omit it entirely and let RegistryProvider inherit from parent\n const registryProviderProps = registry !== undefined ? { registry } : {};\n\n return (\n <RegistryProvider {...registryProviderProps}>\n {/* Type assertion required: TypedWidgetSchema<T>[] is a subtype of WidgetSchema[]\n when T's components accept props compatible with WidgetSchema props.\n This enables type-safe widget rendering with custom registries while allowing\n the internal renderer to work with the base WidgetSchema type. */}\n <ScreenRendererContent\n screen={screen as WidgetSchema[]}\n containerWidgetTypes={containerWidgetTypes}\n className={className}\n />\n </RegistryProvider>\n );\n}\n"],"mappings":";;;;;;;AAGA,MAAM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