@fluid-app/rep-core 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/dist/chunk-2SIG55BD.cjs +131 -0
  2. package/dist/chunk-2SIG55BD.cjs.map +1 -0
  3. package/dist/chunk-2SPTFZRC.js +72 -0
  4. package/dist/chunk-2SPTFZRC.js.map +1 -0
  5. package/dist/chunk-3I5Y3PEO.js +23 -0
  6. package/dist/chunk-3I5Y3PEO.js.map +1 -0
  7. package/dist/chunk-46PUWB7C.cjs +69 -0
  8. package/dist/chunk-46PUWB7C.cjs.map +1 -0
  9. package/dist/chunk-4WFDFEHC.js +134 -0
  10. package/dist/chunk-4WFDFEHC.js.map +1 -0
  11. package/dist/chunk-5NYM4UTW.cjs +58 -0
  12. package/dist/chunk-5NYM4UTW.cjs.map +1 -0
  13. package/dist/chunk-6YI7VW55.cjs +652 -0
  14. package/dist/chunk-6YI7VW55.cjs.map +1 -0
  15. package/dist/chunk-ESYAYVNK.cjs +136 -0
  16. package/dist/chunk-ESYAYVNK.cjs.map +1 -0
  17. package/dist/{chunk-6QLUUNJL.cjs → chunk-GDY76JA6.cjs} +2 -2
  18. package/dist/chunk-GDY76JA6.cjs.map +1 -0
  19. package/dist/chunk-HGVSPZEL.cjs +119 -0
  20. package/dist/chunk-HGVSPZEL.cjs.map +1 -0
  21. package/dist/chunk-HIDJYVKJ.js +54 -0
  22. package/dist/chunk-HIDJYVKJ.js.map +1 -0
  23. package/dist/chunk-HUR3MSO4.js +25 -0
  24. package/dist/chunk-HUR3MSO4.js.map +1 -0
  25. package/dist/chunk-LVLNO2YQ.cjs +28 -0
  26. package/dist/chunk-LVLNO2YQ.cjs.map +1 -0
  27. package/dist/chunk-N2K6W7FX.cjs +169 -0
  28. package/dist/chunk-N2K6W7FX.cjs.map +1 -0
  29. package/dist/chunk-NAMNXRI5.js +129 -0
  30. package/dist/chunk-NAMNXRI5.js.map +1 -0
  31. package/dist/chunk-OWU7MFJ2.cjs +15 -0
  32. package/dist/chunk-OWU7MFJ2.cjs.map +1 -0
  33. package/dist/chunk-PVTQWD4I.js +166 -0
  34. package/dist/chunk-PVTQWD4I.js.map +1 -0
  35. package/dist/chunk-S663BA25.cjs +29 -0
  36. package/dist/chunk-S663BA25.cjs.map +1 -0
  37. package/dist/chunk-SJQPHJL4.cjs +26 -0
  38. package/dist/chunk-SJQPHJL4.cjs.map +1 -0
  39. package/dist/chunk-UQASMDVE.js +27 -0
  40. package/dist/chunk-UQASMDVE.js.map +1 -0
  41. package/dist/chunk-V7D3QUE6.cjs +42 -0
  42. package/dist/chunk-V7D3QUE6.cjs.map +1 -0
  43. package/dist/chunk-VO4TIGDA.js +607 -0
  44. package/dist/chunk-VO4TIGDA.js.map +1 -0
  45. package/dist/chunk-VRF7QEID.js +67 -0
  46. package/dist/chunk-VRF7QEID.js.map +1 -0
  47. package/dist/chunk-WASVMCZB.js +13 -0
  48. package/dist/chunk-WASVMCZB.js.map +1 -0
  49. package/dist/chunk-WYOHFNNW.js +117 -0
  50. package/dist/chunk-WYOHFNNW.js.map +1 -0
  51. package/dist/chunk-XCNBVV4T.js +38 -0
  52. package/dist/chunk-XCNBVV4T.js.map +1 -0
  53. package/dist/{chunk-EWR5EIBP.js → chunk-YKF5ZFF5.js} +2 -2
  54. package/dist/chunk-YKF5ZFF5.js.map +1 -0
  55. package/dist/chunk-YXJMBVXO.cjs +76 -0
  56. package/dist/chunk-YXJMBVXO.cjs.map +1 -0
  57. package/dist/data-sources/DataAwareWidget.cjs +59 -0
  58. package/dist/data-sources/DataAwareWidget.cjs.map +1 -0
  59. package/dist/data-sources/DataAwareWidget.d.cts +30 -0
  60. package/dist/data-sources/DataAwareWidget.d.ts +30 -0
  61. package/dist/data-sources/DataAwareWidget.js +57 -0
  62. package/dist/data-sources/DataAwareWidget.js.map +1 -0
  63. package/dist/data-sources/ErrorState.cjs +12 -0
  64. package/dist/data-sources/ErrorState.cjs.map +1 -0
  65. package/dist/data-sources/ErrorState.d.cts +5 -0
  66. package/dist/data-sources/ErrorState.d.ts +5 -0
  67. package/dist/data-sources/ErrorState.js +3 -0
  68. package/dist/data-sources/ErrorState.js.map +1 -0
  69. package/dist/data-sources/context.cjs +10 -20
  70. package/dist/data-sources/context.cjs.map +1 -1
  71. package/dist/data-sources/context.d.cts +2 -2
  72. package/dist/data-sources/context.d.ts +2 -2
  73. package/dist/data-sources/context.js +1 -21
  74. package/dist/data-sources/context.js.map +1 -1
  75. package/dist/data-sources/fetchers/api.cjs +12 -0
  76. package/dist/data-sources/fetchers/api.cjs.map +1 -0
  77. package/dist/data-sources/fetchers/api.d.cts +8 -0
  78. package/dist/data-sources/fetchers/api.d.ts +8 -0
  79. package/dist/data-sources/fetchers/api.js +3 -0
  80. package/dist/data-sources/fetchers/api.js.map +1 -0
  81. package/dist/data-sources/fetchers/custom.cjs +12 -0
  82. package/dist/data-sources/fetchers/custom.cjs.map +1 -0
  83. package/dist/data-sources/fetchers/custom.d.cts +15 -0
  84. package/dist/data-sources/fetchers/custom.d.ts +15 -0
  85. package/dist/data-sources/fetchers/custom.js +3 -0
  86. package/dist/data-sources/fetchers/custom.js.map +1 -0
  87. package/dist/data-sources/fetchers/static.cjs +16 -0
  88. package/dist/data-sources/fetchers/static.cjs.map +1 -0
  89. package/dist/data-sources/fetchers/static.d.cts +38 -0
  90. package/dist/data-sources/fetchers/static.d.ts +38 -0
  91. package/dist/data-sources/fetchers/static.js +3 -0
  92. package/dist/data-sources/fetchers/static.js.map +1 -0
  93. package/dist/data-sources/registry-context.cjs +26 -0
  94. package/dist/data-sources/registry-context.cjs.map +1 -0
  95. package/dist/data-sources/registry-context.d.cts +41 -0
  96. package/dist/data-sources/registry-context.d.ts +41 -0
  97. package/dist/data-sources/registry-context.js +9 -0
  98. package/dist/data-sources/registry-context.js.map +1 -0
  99. package/dist/data-sources/registry.cjs +20 -0
  100. package/dist/data-sources/registry.cjs.map +1 -0
  101. package/dist/data-sources/registry.d.cts +17 -0
  102. package/dist/data-sources/registry.d.ts +17 -0
  103. package/dist/data-sources/registry.js +7 -0
  104. package/dist/data-sources/registry.js.map +1 -0
  105. package/dist/data-sources/transformers.cjs +12 -0
  106. package/dist/data-sources/transformers.cjs.map +1 -0
  107. package/dist/data-sources/transformers.d.cts +23 -0
  108. package/dist/data-sources/transformers.d.ts +23 -0
  109. package/dist/data-sources/transformers.js +3 -0
  110. package/dist/data-sources/transformers.js.map +1 -0
  111. package/dist/data-sources/types.d.cts +37 -2
  112. package/dist/data-sources/types.d.ts +37 -2
  113. package/dist/data-sources/use-widget-data.cjs +19 -0
  114. package/dist/data-sources/use-widget-data.cjs.map +1 -0
  115. package/dist/data-sources/use-widget-data.d.cts +16 -0
  116. package/dist/data-sources/use-widget-data.d.ts +16 -0
  117. package/dist/data-sources/use-widget-data.js +10 -0
  118. package/dist/data-sources/use-widget-data.js.map +1 -0
  119. package/dist/registries/index.cjs +8 -15
  120. package/dist/registries/index.cjs.map +1 -1
  121. package/dist/registries/index.d.cts +20 -7
  122. package/dist/registries/index.d.ts +20 -7
  123. package/dist/registries/index.js +8 -15
  124. package/dist/registries/index.js.map +1 -1
  125. package/dist/shareable-item-DkgWpwoU.d.cts +21 -0
  126. package/dist/shareable-item-DkgWpwoU.d.ts +21 -0
  127. package/dist/shell/AppShellLayout.cjs +14 -0
  128. package/dist/shell/AppShellLayout.cjs.map +1 -0
  129. package/dist/shell/AppShellLayout.d.cts +26 -0
  130. package/dist/shell/AppShellLayout.d.ts +26 -0
  131. package/dist/shell/AppShellLayout.js +5 -0
  132. package/dist/shell/AppShellLayout.js.map +1 -0
  133. package/dist/shell/ThemeModeContext.cjs +20 -0
  134. package/dist/shell/ThemeModeContext.cjs.map +1 -0
  135. package/dist/shell/ThemeModeContext.d.cts +27 -0
  136. package/dist/shell/ThemeModeContext.d.ts +27 -0
  137. package/dist/shell/ThemeModeContext.js +3 -0
  138. package/dist/shell/ThemeModeContext.js.map +1 -0
  139. package/dist/shell/index.cjs +135 -0
  140. package/dist/shell/index.cjs.map +1 -0
  141. package/dist/shell/index.d.cts +8 -0
  142. package/dist/shell/index.d.ts +8 -0
  143. package/dist/shell/index.js +6 -0
  144. package/dist/shell/index.js.map +1 -0
  145. package/dist/shell/sidebar.cjs +105 -0
  146. package/dist/shell/sidebar.cjs.map +1 -0
  147. package/dist/shell/sidebar.d.cts +71 -0
  148. package/dist/shell/sidebar.d.ts +71 -0
  149. package/dist/shell/sidebar.js +4 -0
  150. package/dist/shell/sidebar.js.map +1 -0
  151. package/dist/shell/use-mobile.cjs +20 -0
  152. package/dist/shell/use-mobile.cjs.map +1 -0
  153. package/dist/shell/use-mobile.d.cts +5 -0
  154. package/dist/shell/use-mobile.d.ts +5 -0
  155. package/dist/shell/use-mobile.js +3 -0
  156. package/dist/shell/use-mobile.js.map +1 -0
  157. package/dist/theme/index.cjs +599 -970
  158. package/dist/theme/index.cjs.map +1 -1
  159. package/dist/theme/index.d.cts +106 -2655
  160. package/dist/theme/index.d.ts +106 -2655
  161. package/dist/theme/index.js +570 -917
  162. package/dist/theme/index.js.map +1 -1
  163. package/dist/types/index.cjs +17 -17
  164. package/dist/types/index.d.cts +27 -4
  165. package/dist/types/index.d.ts +27 -4
  166. package/dist/types/index.js +1 -1
  167. package/dist/types-R1kV_DKF.d.cts +80 -0
  168. package/dist/types-R1kV_DKF.d.ts +80 -0
  169. package/dist/{shareable-item-DPmNZkE1.d.cts → widget-schema-36uGUTWL.d.cts} +5 -21
  170. package/dist/{shareable-item-DPmNZkE1.d.ts → widget-schema-DxdlJD8E.d.ts} +5 -21
  171. package/dist/widget-utils/index.cjs +3 -3
  172. package/dist/widget-utils/index.d.cts +3 -1
  173. package/dist/widget-utils/index.d.ts +3 -1
  174. package/dist/widget-utils/index.js +1 -1
  175. package/package.json +84 -13
  176. package/dist/chunk-6QLUUNJL.cjs.map +0 -1
  177. package/dist/chunk-EWR5EIBP.js.map +0 -1
  178. package/dist/theme-DrMUYZ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A,MACA,sCAAA;AAAA,MACA;AAAA,KACF;AAAA,IACC,GAAG;AAAA;AACN,CACD;AACD,cAAA,CAAe,WAAA,GAAc,gBAAA;AAE7B,IAAM,kBAAA,GAA2B,KAAA,CAAA,UAAA,CAG/B,CAAC,EAAE,GAAG,KAAA,EAAM,EAAG,GAAA,qBAAQ,GAAA,CAAC,IAAA,EAAA,EAAG,GAAA,EAAW,GAAG,OAAO,CAAE;AACpD,kBAAA,CAAmB,WAAA,GAAc,oBAAA;AAEjC,IAAM,oBAAA,GAA6B,KAAA,CAAA,UAAA,CAOjC,CAAC,EAAE,OAAA,GAAU,KAAA,EAAO,IAAA,GAAO,IAAA,EAAM,QAAA,EAAU,SAAA,EAAW,GAAG,KAAA,IAAS,GAAA,KAAQ;AAC1E,EAAA,MAAM,IAAA,GAAO,UAAU,IAAA,GAAO,GAAA;AAE9B,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,cAAA,EAAa,iBAAA;AAAA,MACb,WAAA,EAAW,IAAA;AAAA,MACX,aAAA,EAAa,QAAA;AAAA,MACb,SAAA,EAAW,EAAA;AAAA,QACT,+eAAA;AAAA,QACA,wFAAA;AAAA,QACA,SAAS,IAAA,IAAQ,SAAA;AAAA,QACjB,SAAS,IAAA,IAAQ,SAAA;AAAA,QACjB,sCAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ,CAAC;AACD,oBAAA,CAAqB,WAAA,GAAc,sBAAA","file":"chunk-VO4TIGDA.js","sourcesContent":["\"use client\";\n\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { type VariantProps, cva } from \"class-variance-authority\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\nimport * as React from \"react\";\n\nimport { useIsMobile } from \"./use-mobile\";\n\n// ---------------------------------------------------------------------------\n// Inlined utilities (avoid importing from builder's UI kit)\n// ---------------------------------------------------------------------------\n\nfunction cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nfunction Separator({\n className,\n orientation = \"horizontal\",\n ...props\n}: React.ComponentPropsWithRef<\"div\"> & {\n orientation?: \"horizontal\" | \"vertical\";\n decorative?: boolean;\n}) {\n return (\n <div\n role=\"separator\"\n aria-orientation={orientation}\n className={cn(\n \"shrink-0 bg-border\",\n orientation === \"horizontal\" ? \"h-px w-full\" : \"h-full w-px\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction Skeleton({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n className={cn(\"animate-pulse rounded-md bg-muted\", className)}\n {...props}\n />\n );\n}\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nconst SIDEBAR_WIDTH = \"13rem\";\nconst SIDEBAR_WIDTH_MOBILE = \"18rem\";\nconst SIDEBAR_WIDTH_ICON = \"3rem\";\nconst SIDEBAR_KEYBOARD_SHORTCUT = \"b\";\n\n// ---------------------------------------------------------------------------\n// Sidebar Context\n// ---------------------------------------------------------------------------\n\ntype SidebarContextValue = {\n state: \"expanded\" | \"collapsed\";\n open: boolean;\n setOpen: (open: boolean) => void;\n openMobile: boolean;\n setOpenMobile: (open: boolean) => void;\n isMobile: boolean;\n toggleSidebar: () => void;\n isPreviewMode: boolean;\n};\n\nexport const SidebarContext = React.createContext<SidebarContextValue | null>(\n null,\n);\n\nfunction useSidebar(): SidebarContextValue {\n const context = React.useContext(SidebarContext);\n if (!context) {\n throw new Error(\"useSidebar must be used within a SidebarProvider.\");\n }\n\n return context;\n}\n\n// ---------------------------------------------------------------------------\n// SidebarProvider\n// ---------------------------------------------------------------------------\n\nconst SidebarProvider = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\"> & {\n defaultOpen?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n viewportWidth?: number;\n previewMode?: boolean;\n }\n>(\n (\n {\n defaultOpen = true,\n open: openProp,\n onOpenChange: setOpenProp,\n viewportWidth,\n previewMode,\n className,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const windowIsMobile = useIsMobile();\n // Use viewportWidth if provided, otherwise use actual window detection\n const isMobile =\n viewportWidth !== undefined ? viewportWidth < 768 : windowIsMobile;\n // Preview mode is active when viewportWidth is provided\n const isPreviewMode = viewportWidth !== undefined || !!previewMode;\n const [openMobile, setOpenMobile] = React.useState(false);\n\n // This is the internal state of the sidebar.\n // We use openProp and setOpenProp for control from outside the component.\n const [_open, _setOpen] = React.useState(defaultOpen);\n const open = openProp ?? _open;\n const setOpen = React.useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const openState = typeof value === \"function\" ? value(open) : value;\n if (setOpenProp) {\n setOpenProp(openState);\n } else {\n _setOpen(openState);\n }\n },\n [setOpenProp, open],\n );\n\n // Helper to toggle the sidebar.\n const toggleSidebar = React.useCallback(() => {\n return isMobile\n ? setOpenMobile((open) => !open)\n : setOpen((open) => !open);\n }, [isMobile, setOpen, setOpenMobile]);\n\n // Adds a keyboard shortcut to toggle the sidebar.\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (\n event.key === SIDEBAR_KEYBOARD_SHORTCUT &&\n (event.metaKey || event.ctrlKey)\n ) {\n // check if composer is focused - if so, let the composer handle the shortcut\n const activeElement = document.activeElement;\n const isComposerFocused =\n activeElement?.closest(\".group\\\\/composer\") ||\n activeElement?.closest(\"[data-toolbar]\") ||\n activeElement?.classList.contains(\"ProseMirror\");\n\n if (isComposerFocused) {\n return; // let the composer handle the shortcut\n }\n\n event.preventDefault();\n toggleSidebar();\n }\n };\n\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => window.removeEventListener(\"keydown\", handleKeyDown);\n }, [toggleSidebar]);\n\n // We add a state so that we can do data-state=\"expanded\" or \"collapsed\".\n // This makes it easier to style the sidebar with Tailwind classes.\n const state = open ? \"expanded\" : \"collapsed\";\n\n const contextValue = React.useMemo<SidebarContextValue>(\n () => ({\n state,\n open,\n setOpen,\n isMobile,\n openMobile,\n setOpenMobile,\n toggleSidebar,\n isPreviewMode,\n }),\n [\n state,\n open,\n setOpen,\n isMobile,\n openMobile,\n setOpenMobile,\n toggleSidebar,\n isPreviewMode,\n ],\n );\n\n return (\n <SidebarContext.Provider value={contextValue}>\n <div\n style={\n {\n \"--sidebar-width\": SIDEBAR_WIDTH,\n \"--sidebar-width-icon\": SIDEBAR_WIDTH_ICON,\n ...style,\n } as React.CSSProperties\n }\n className={cn(\n \"group/sidebar-wrapper flex min-h-0 w-full flex-1\",\n className,\n )}\n ref={ref}\n {...props}\n >\n {children}\n </div>\n </SidebarContext.Provider>\n );\n },\n);\nSidebarProvider.displayName = \"SidebarProvider\";\n\n// ---------------------------------------------------------------------------\n// Sidebar\n// ---------------------------------------------------------------------------\n\nconst Sidebar = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\"> & {\n side?: \"left\" | \"right\";\n variant?: \"sidebar\" | \"floating\" | \"inset\";\n collapsible?: \"offcanvas\" | \"icon\" | \"none\";\n }\n>(\n (\n {\n side = \"left\",\n variant = \"sidebar\",\n collapsible = \"offcanvas\",\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const { isMobile, state, openMobile, setOpenMobile, isPreviewMode } =\n useSidebar();\n\n // Define CSS variables for expanded and collapsed sidebar widths\n const sidebarWidth =\n state === \"expanded\" ? SIDEBAR_WIDTH : SIDEBAR_WIDTH_ICON;\n\n if (collapsible === \"none\") {\n return (\n <div\n className={cn(\n \"flex w-(--sidebar-width) flex-col rounded-tl-lg bg-sidebar text-sidebar-foreground\",\n isPreviewMode ? \"h-full\" : \"h-[97vh]\",\n className,\n )}\n ref={ref}\n {...props}\n >\n {children}\n </div>\n );\n }\n\n if (isMobile) {\n // For mobile, render a slide-out sidebar with overlay\n // Use absolute positioning in preview mode so it stays within the preview container\n const positionClass = isPreviewMode ? \"absolute\" : \"fixed\";\n return (\n <>\n {/* Overlay - only visible when sidebar is open */}\n {openMobile && (\n <div\n className={cn(positionClass, \"inset-0 z-40 bg-black/50\")}\n onClick={() => setOpenMobile(false)}\n aria-hidden=\"true\"\n />\n )}\n\n {/* Sidebar - slides in from left */}\n <div\n data-sidebar=\"sidebar\"\n data-mobile=\"true\"\n className={cn(\n positionClass,\n \"top-0 left-0 z-50 h-full w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground transition-transform duration-300 ease-in-out\",\n openMobile ? \"translate-x-0\" : \"-translate-x-full\",\n className,\n )}\n style={\n {\n \"--sidebar-width\": SIDEBAR_WIDTH_MOBILE,\n } as React.CSSProperties\n }\n ref={ref}\n {...props}\n >\n <div className=\"flex h-full w-full flex-col\">{children}</div>\n </div>\n </>\n );\n }\n\n return (\n <div\n ref={ref}\n className=\"group peer hidden bg-sidebar text-sidebar-foreground md:block\"\n data-state={state}\n data-collapsible={state === \"collapsed\" ? collapsible : \"\"}\n data-variant={variant}\n data-side={side}\n style={\n {\n \"--sidebar-width\": sidebarWidth,\n } as React.CSSProperties\n }\n >\n {/* This is what handles the sidebar gap on desktop */}\n <div\n className={cn(\n \"relative bg-transparent transition-[width] duration-200 ease-linear\",\n \"group-data-[collapsible=offcanvas]:w-0\",\n \"group-data-[side=right]:rotate-180\",\n variant === \"floating\" || variant === \"inset\"\n ? \"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]\"\n : \"group-data-[collapsible=icon]:w-(--sidebar-width-icon)\",\n )}\n />\n <div\n className={cn(\n \"relative inset-y-0 z-[20] hidden w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex\",\n isPreviewMode ? \"h-full\" : \"h-svh\",\n side === \"left\"\n ? \"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]\"\n : \"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]\",\n // Adjust the padding for floating and inset variants.\n variant === \"floating\" || variant === \"inset\"\n ? \"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]\"\n : \"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=right]:border-l\",\n className,\n )}\n {...props}\n >\n <div\n data-sidebar=\"sidebar\"\n className=\"flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm\"\n >\n {children}\n </div>\n </div>\n </div>\n );\n },\n);\nSidebar.displayName = \"Sidebar\";\n\n// ---------------------------------------------------------------------------\n// SidebarRail\n// ---------------------------------------------------------------------------\n\nconst SidebarRail = React.forwardRef<\n HTMLButtonElement,\n React.ComponentProps<\"button\">\n>(({ className, ...props }, ref) => {\n const { toggleSidebar } = useSidebar();\n\n return (\n <button\n ref={ref}\n data-sidebar=\"rail\"\n aria-label=\"Toggle Sidebar\"\n tabIndex={-1}\n onClick={toggleSidebar}\n title=\"Toggle Sidebar\"\n className={cn(\n \"absolute inset-y-0 z-[10] hidden w-4 -translate-x-full transition-all ease-linear group-data-[side=left]:-right-[1.375rem] group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex\",\n \"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize\",\n \"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize\",\n \"group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar\",\n \"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2\",\n \"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2\",\n className,\n )}\n {...props}\n />\n );\n});\nSidebarRail.displayName = \"SidebarRail\";\n\n// ---------------------------------------------------------------------------\n// SidebarInset\n// ---------------------------------------------------------------------------\n\nconst SidebarInset = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"main\">\n>(({ className, ...props }, ref) => {\n const { isPreviewMode } = useSidebar();\n return (\n <main\n ref={ref}\n className={cn(\n \"relative flex flex-1 flex-col\",\n isPreviewMode\n ? \"max-h-[calc(100svh-(--spacing(13)))]\"\n : \"min-h-svh peer-data-[variant=inset]:min-h-[calc(100svh-(--spacing(4)))]\",\n \"md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2\",\n className,\n )}\n {...props}\n />\n );\n});\nSidebarInset.displayName = \"SidebarInset\";\n\n// ---------------------------------------------------------------------------\n// SidebarInput\n// ---------------------------------------------------------------------------\n\nconst SidebarInput = React.forwardRef<\n HTMLInputElement,\n React.ComponentProps<\"input\">\n>(({ className, ...props }, ref) => {\n return (\n <input\n ref={ref}\n data-sidebar=\"input\"\n className={cn(\n \"h-8 w-full rounded-md border bg-background px-3 text-sm shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring focus-visible:outline-none\",\n className,\n )}\n {...props}\n />\n );\n});\nSidebarInput.displayName = \"SidebarInput\";\n\n// ---------------------------------------------------------------------------\n// SidebarHeader / Footer\n// ---------------------------------------------------------------------------\n\nconst SidebarHeader = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n data-sidebar=\"header\"\n className={cn(\"flex flex-col gap-2 p-2\", className)}\n {...props}\n />\n );\n});\nSidebarHeader.displayName = \"SidebarHeader\";\n\nconst SidebarFooter = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n data-sidebar=\"footer\"\n className={cn(\"flex flex-col gap-2 p-2\", className)}\n {...props}\n />\n );\n});\nSidebarFooter.displayName = \"SidebarFooter\";\n\n// ---------------------------------------------------------------------------\n// SidebarSeparator\n// ---------------------------------------------------------------------------\n\nconst SidebarSeparator = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\"> & {\n orientation?: \"horizontal\" | \"vertical\";\n }\n>(({ className, ...props }, ref) => {\n return (\n <Separator\n ref={ref}\n data-sidebar=\"separator\"\n className={cn(\"mx-2 w-auto bg-sidebar-border\", className)}\n {...props}\n />\n );\n});\nSidebarSeparator.displayName = \"SidebarSeparator\";\n\n// ---------------------------------------------------------------------------\n// SidebarContent\n// ---------------------------------------------------------------------------\n\nconst SidebarContent = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n data-sidebar=\"content\"\n className={cn(\n \"scrollbar-none flex min-h-0 flex-1 flex-col gap-2 overflow-auto rounded group-data-[collapsible=icon]:gap-0 group-data-[collapsible=icon]:overflow-hidden group-data-[collapsible=icon]:pt-3\",\n className,\n )}\n {...props}\n />\n );\n});\nSidebarContent.displayName = \"SidebarContent\";\n\n// ---------------------------------------------------------------------------\n// SidebarGroup\n// ---------------------------------------------------------------------------\n\nconst SidebarGroup = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n data-sidebar=\"group\"\n className={cn(\n \"relative flex w-full min-w-0 flex-col p-2 group-data-[collapsible=icon]:py-0 group-data-[collapsible=icon]:pt-4\",\n className,\n )}\n {...props}\n />\n );\n});\nSidebarGroup.displayName = \"SidebarGroup\";\n\nconst SidebarGroupLabel = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\"> & { asChild?: boolean }\n>(({ className, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"div\";\n\n return (\n <Comp\n ref={ref}\n data-sidebar=\"group-label\"\n className={cn(\n \"flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0\",\n \"group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:hidden\",\n className,\n )}\n {...props}\n />\n );\n});\nSidebarGroupLabel.displayName = \"SidebarGroupLabel\";\n\nconst SidebarGroupAction = React.forwardRef<\n HTMLButtonElement,\n React.ComponentProps<\"button\"> & { asChild?: boolean }\n>(({ className, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\";\n\n return (\n <Comp\n ref={ref}\n data-sidebar=\"group-action\"\n className={cn(\n \"absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0\",\n // Increases the hit area of the button on mobile.\n \"after:absolute after:-inset-2 md:after:hidden\",\n \"group-data-[collapsible=icon]:hidden\",\n className,\n )}\n {...props}\n />\n );\n});\nSidebarGroupAction.displayName = \"SidebarGroupAction\";\n\nconst SidebarGroupContent = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n data-sidebar=\"group-content\"\n className={cn(\"w-full text-sm\", className)}\n {...props}\n />\n));\nSidebarGroupContent.displayName = \"SidebarGroupContent\";\n\n// ---------------------------------------------------------------------------\n// SidebarMenu\n// ---------------------------------------------------------------------------\n\nconst SidebarMenu = React.forwardRef<\n HTMLUListElement,\n React.ComponentProps<\"ul\">\n>(({ className, ...props }, ref) => (\n <ul\n ref={ref}\n data-sidebar=\"menu\"\n className={cn(\"flex w-full min-w-0 flex-col gap-1\", className)}\n {...props}\n />\n));\nSidebarMenu.displayName = \"SidebarMenu\";\n\nconst SidebarMenuItem = React.forwardRef<\n HTMLLIElement,\n React.ComponentProps<\"li\">\n>(({ className, ...props }, ref) => (\n <li\n ref={ref}\n data-sidebar=\"menu-item\"\n className={cn(\"group/menu-item relative\", className)}\n {...props}\n />\n));\nSidebarMenuItem.displayName = \"SidebarMenuItem\";\n\n// ---------------------------------------------------------------------------\n// SidebarMenuButton\n// ---------------------------------------------------------------------------\n\nconst sidebarMenuButtonVariants = cva(\n \"peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-primary hover:text-sidebar-primary-foreground focus-visible:ring-2 active:bg-sidebar-primary active:text-sidebar-primary-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-primary data-[active=true]:font-medium data-[active=true]:text-sidebar-primary-foreground data-[state=open]:hover:bg-sidebar-primary data-[state=open]:hover:text-sidebar-primary-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0\",\n {\n variants: {\n variant: {\n default:\n \"hover:bg-sidebar-primary hover:text-sidebar-primary-foreground\",\n outline:\n \"shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-primary hover:text-sidebar-primary-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-primary))]\",\n },\n size: {\n default: \"h-8 text-sm\",\n sm: \"h-7 text-xs\",\n lg: \"h-12 text-sm group-data-[collapsible=icon]:p-0!\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n },\n);\n\nconst SidebarMenuButton = React.forwardRef<\n HTMLButtonElement,\n React.ComponentProps<\"button\"> & {\n asChild?: boolean;\n isActive?: boolean;\n } & VariantProps<typeof sidebarMenuButtonVariants>\n>(\n (\n {\n asChild = false,\n isActive = false,\n variant = \"default\",\n size = \"default\",\n className,\n ...props\n },\n ref,\n ) => {\n const Comp = asChild ? Slot : \"button\";\n\n const button = (\n <Comp\n ref={ref}\n data-sidebar=\"menu-button\"\n data-size={size}\n data-active={isActive}\n className={cn(sidebarMenuButtonVariants({ variant, size }), className)}\n {...props}\n />\n );\n\n return button;\n },\n);\nSidebarMenuButton.displayName = \"SidebarMenuButton\";\n\n// ---------------------------------------------------------------------------\n// SidebarMenuAction / Badge / Skeleton\n// ---------------------------------------------------------------------------\n\nconst SidebarMenuAction = React.forwardRef<\n HTMLButtonElement,\n React.ComponentProps<\"button\"> & {\n asChild?: boolean;\n showOnHover?: boolean;\n }\n>(({ className, asChild = false, showOnHover = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\";\n\n return (\n <Comp\n ref={ref}\n data-sidebar=\"menu-action\"\n className={cn(\n \"absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform peer-hover/menu-button:text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0\",\n // Increases the hit area of the button on mobile.\n \"after:absolute after:-inset-2 md:after:hidden\",\n \"peer-data-[size=sm]/menu-button:top-1\",\n \"peer-data-[size=default]/menu-button:top-1.5\",\n \"peer-data-[size=lg]/menu-button:top-2.5\",\n \"group-data-[collapsible=icon]:hidden\",\n showOnHover &&\n \"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground data-[state=open]:opacity-100 md:opacity-0\",\n className,\n )}\n {...props}\n />\n );\n});\nSidebarMenuAction.displayName = \"SidebarMenuAction\";\n\nconst SidebarMenuBadge = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n data-sidebar=\"menu-badge\"\n className={cn(\n \"pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none\",\n \"peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground\",\n \"peer-data-[size=sm]/menu-button:top-1\",\n \"peer-data-[size=default]/menu-button:top-1.5\",\n \"peer-data-[size=lg]/menu-button:top-2.5\",\n \"group-data-[collapsible=icon]:hidden\",\n className,\n )}\n {...props}\n />\n));\nSidebarMenuBadge.displayName = \"SidebarMenuBadge\";\n\nconst SidebarMenuSkeleton = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<\"div\"> & {\n showIcon?: boolean;\n }\n>(({ className, showIcon = false, ...props }, ref) => {\n // Random width between 50 to 90%.\n const width = React.useMemo(() => {\n return `${Math.floor(Math.random() * 40) + 50}%`;\n }, []);\n\n return (\n <div\n ref={ref}\n data-sidebar=\"menu-skeleton\"\n className={cn(\"flex h-8 items-center gap-2 rounded-md px-2\", className)}\n {...props}\n >\n {showIcon && (\n <Skeleton\n className=\"size-4 rounded-md\"\n data-sidebar=\"menu-skeleton-icon\"\n />\n )}\n <Skeleton\n className=\"h-4 max-w-(--skeleton-width) flex-1\"\n data-sidebar=\"menu-skeleton-text\"\n style={\n {\n \"--skeleton-width\": width,\n } as React.CSSProperties\n }\n />\n </div>\n );\n});\nSidebarMenuSkeleton.displayName = \"SidebarMenuSkeleton\";\n\n// ---------------------------------------------------------------------------\n// SidebarMenuSub\n// ---------------------------------------------------------------------------\n\nconst SidebarMenuSub = React.forwardRef<\n HTMLUListElement,\n React.ComponentProps<\"ul\">\n>(({ className, ...props }, ref) => (\n <ul\n ref={ref}\n data-sidebar=\"menu-sub\"\n className={cn(\n \"mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5\",\n \"group-data-[collapsible=icon]:hidden\",\n className,\n )}\n {...props}\n />\n));\nSidebarMenuSub.displayName = \"SidebarMenuSub\";\n\nconst SidebarMenuSubItem = React.forwardRef<\n HTMLLIElement,\n React.ComponentProps<\"li\">\n>(({ ...props }, ref) => <li ref={ref} {...props} />);\nSidebarMenuSubItem.displayName = \"SidebarMenuSubItem\";\n\nconst SidebarMenuSubButton = React.forwardRef<\n HTMLAnchorElement,\n React.ComponentProps<\"a\"> & {\n asChild?: boolean;\n size?: \"sm\" | \"md\";\n isActive?: boolean;\n }\n>(({ asChild = false, size = \"md\", isActive, className, ...props }, ref) => {\n const Comp = asChild ? Slot : \"a\";\n\n return (\n <Comp\n ref={ref}\n data-sidebar=\"menu-sub-button\"\n data-size={size}\n data-active={isActive}\n className={cn(\n \"flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground\",\n \"data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground\",\n size === \"sm\" && \"text-xs\",\n size === \"md\" && \"text-sm\",\n \"group-data-[collapsible=icon]:hidden\",\n className,\n )}\n {...props}\n />\n );\n});\nSidebarMenuSubButton.displayName = \"SidebarMenuSubButton\";\n\n// ---------------------------------------------------------------------------\n// Exports\n// ---------------------------------------------------------------------------\n\nexport {\n Sidebar,\n SidebarContent,\n SidebarFooter,\n SidebarGroup,\n SidebarGroupAction,\n SidebarGroupContent,\n SidebarGroupLabel,\n SidebarHeader,\n SidebarInput,\n SidebarInset,\n SidebarMenu,\n SidebarMenuAction,\n SidebarMenuBadge,\n SidebarMenuButton,\n SidebarMenuItem,\n SidebarMenuSkeleton,\n SidebarMenuSub,\n SidebarMenuSubButton,\n SidebarMenuSubItem,\n SidebarProvider,\n SidebarRail,\n SidebarSeparator,\n useSidebar,\n};\n"]}
@@ -0,0 +1,67 @@
1
+ // src/data-sources/fetchers/api.ts
2
+ function getByPath(obj, path) {
3
+ return path.split(".").reduce((current, key) => {
4
+ if (current && typeof current === "object" && key in current) {
5
+ return current[key];
6
+ }
7
+ return void 0;
8
+ }, obj);
9
+ }
10
+ function interpolateVariables(endpoint, variables) {
11
+ if (!variables) return endpoint;
12
+ const resolved = endpoint.replace(
13
+ /\{(\w+)\}/g,
14
+ (match, key) => variables[key] ?? match
15
+ );
16
+ const unresolved = resolved.match(/\{(\w+)\}/g);
17
+ if (unresolved) {
18
+ console.warn(
19
+ `[DataSource] Unresolved variable placeholders in endpoint: ${unresolved.join(", ")}. Endpoint: "${endpoint}". Available variables: ${Object.keys(variables).join(", ") || "(none)"}`
20
+ );
21
+ }
22
+ return resolved;
23
+ }
24
+ function resolveEndpointUrl(endpoint, baseUrl, variables) {
25
+ const resolved = interpolateVariables(endpoint, variables);
26
+ if (resolved.startsWith("http://") || resolved.startsWith("https://")) {
27
+ return resolved;
28
+ }
29
+ if (baseUrl) {
30
+ const base = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
31
+ const path = resolved.startsWith("/") ? resolved : `/${resolved}`;
32
+ return `${base}${path}`;
33
+ }
34
+ return resolved;
35
+ }
36
+ async function apiFetcher(source, context) {
37
+ const { endpoint, method = "GET", headers = {}, body } = source;
38
+ const mergedVariables = { ...context.variables, ...source.variables };
39
+ const url = resolveEndpointUrl(endpoint, context.baseUrl, mergedVariables);
40
+ const fetchOptions = {
41
+ method,
42
+ headers: {
43
+ "content-type": "application/json",
44
+ ...context.getApiHeaders?.(),
45
+ ...headers
46
+ },
47
+ signal: context.signal
48
+ };
49
+ if (body && (method === "POST" || method === "PUT")) {
50
+ fetchOptions.body = JSON.stringify(body);
51
+ }
52
+ const response = await fetch(url, fetchOptions);
53
+ if (!response.ok) {
54
+ throw new Error(
55
+ `API request failed: ${response.status} ${response.statusText}`
56
+ );
57
+ }
58
+ const data = await response.json();
59
+ if (source.resultPath) {
60
+ return getByPath(data, source.resultPath);
61
+ }
62
+ return data;
63
+ }
64
+
65
+ export { apiFetcher };
66
+ //# sourceMappingURL=chunk-VRF7QEID.js.map
67
+ //# sourceMappingURL=chunk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oBAAA,EAAuB,QAAA,CAAS,MAAM,CAAA,CAAA,EAAI,SAAS,UAAU,CAAA;AAAA,KAC/D;AAAA,EACF;AAEA,EAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,IAAA,EAAK;AAGjC,EAAA,IAAI,OAAO,UAAA,EAAY;AACrB,IAAA,OAAO,SAAA,CAAU,IAAA,EAAM,MAAA,CAAO,UAAU,CAAA;AAAA,EAC1C;AAEA,EAAA,OAAO,IAAA;AACT","file":"chunk-VRF7QEID.js","sourcesContent":["import type { ApiDataSource, DataSourceContext } from \"../types\";\n\n/**\n * Extracts a value from an object using dot notation path\n * e.g., getByPath({ data: { items: [1,2,3] } }, 'data.items') => [1,2,3]\n */\nfunction getByPath(obj: unknown, path: string): unknown {\n return path.split(\".\").reduce((current, key) => {\n if (current && typeof current === \"object\" && key in current) {\n return (current as Record<string, unknown>)[key];\n }\n return undefined;\n }, obj);\n}\n\n/**\n * Replaces {variable} placeholders in an endpoint path with values from the\n * variables map. E.g., \"/reps/{rep_id}/most_shared\" with { rep_id: \"42\" }\n * becomes \"/reps/42/most_shared\".\n */\nfunction interpolateVariables(\n endpoint: string,\n variables?: Record<string, string>,\n): string {\n if (!variables) return endpoint;\n const resolved = endpoint.replace(\n /\\{(\\w+)\\}/g,\n (match, key: string) => variables[key] ?? match,\n );\n const unresolved = resolved.match(/\\{(\\w+)\\}/g);\n if (unresolved) {\n console.warn(\n `[DataSource] Unresolved variable placeholders in endpoint: ${unresolved.join(\", \")}. ` +\n `Endpoint: \"${endpoint}\". Available variables: ${Object.keys(variables).join(\", \") || \"(none)\"}`,\n );\n }\n return resolved;\n}\n\n/**\n * Resolves the full URL for an endpoint.\n * - Substitutes {variable} placeholders from context variables\n * - Absolute URLs (starting with http:// or https://) are used as-is\n * - Relative paths are prefixed with the context's baseUrl\n */\nfunction resolveEndpointUrl(\n endpoint: string,\n baseUrl?: string,\n variables?: Record<string, string>,\n): string {\n const resolved = interpolateVariables(endpoint, variables);\n\n // If endpoint is already absolute, use it directly\n if (resolved.startsWith(\"http://\") || resolved.startsWith(\"https://\")) {\n return resolved;\n }\n\n // If we have a baseUrl, prepend it to the relative endpoint\n if (baseUrl) {\n // Ensure proper joining (no double slashes)\n const base = baseUrl.endsWith(\"/\") ? baseUrl.slice(0, -1) : baseUrl;\n const path = resolved.startsWith(\"/\") ? resolved : `/${resolved}`;\n return `${base}${path}`;\n }\n\n // No baseUrl provided, return endpoint as-is (will likely fail for relative paths)\n return resolved;\n}\n\n/**\n * Default API fetcher implementation\n */\nexport async function apiFetcher(\n source: ApiDataSource,\n context: DataSourceContext,\n): Promise<unknown> {\n const { endpoint, method = \"GET\", headers = {}, body } = source;\n\n // Merge context variables with per-source variables (source overrides context)\n const mergedVariables = { ...context.variables, ...source.variables };\n\n // Resolve the full URL, substituting variables and using baseUrl for relative endpoints\n const url = resolveEndpointUrl(endpoint, context.baseUrl, mergedVariables);\n\n const fetchOptions: RequestInit = {\n method,\n headers: {\n \"content-type\": \"application/json\",\n ...context.getApiHeaders?.(),\n ...headers,\n },\n signal: context.signal,\n };\n\n if (body && (method === \"POST\" || method === \"PUT\")) {\n fetchOptions.body = JSON.stringify(body);\n }\n\n const response = await fetch(url, fetchOptions);\n\n if (!response.ok) {\n throw new Error(\n `API request failed: ${response.status} ${response.statusText}`,\n );\n }\n\n const data = await response.json();\n\n // Extract data at resultPath if specified\n if (source.resultPath) {\n return getByPath(data, source.resultPath);\n }\n\n return data;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+
3
+ // src/data-sources/ErrorState.tsx
4
+ function ErrorState() {
5
+ return /* @__PURE__ */ jsxs("div", { className: "flex min-h-[120px] flex-col items-center justify-center p-6 text-center", children: [
6
+ /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold", children: "Something Went Wrong" }),
7
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Please contact a company admin for help" })
8
+ ] });
9
+ }
10
+
11
+ export { ErrorState };
12
+ //# sourceMappingURL=chunk-WASVMCZB.js.map
13
+ //# sourceMappingURL=chunk-WASVMCZB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/data-sources/ErrorState.tsx"],"names":[],"mappings":";;;AAAO,SAAS,UAAA,GAAa;AAC3B,EAAA,uBACE,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,yEAAA,EACb,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,uBAAA,EAAwB,QAAA,EAAA,sBAAA,EAAoB,CAAA;AAAA,oBACzD,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,+BAAA,EAAgC,QAAA,EAAA,yCAAA,EAE7C;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-WASVMCZB.js","sourcesContent":["export function ErrorState() {\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-sm text-muted-foreground\">\n Please contact a company admin for help\n </p>\n </div>\n );\n}\n"]}
@@ -0,0 +1,117 @@
1
+ // src/data-sources/fetchers/custom.ts
2
+ var SHAREABLE_ENDPOINTS = {
3
+ Medium: (id) => `/company/media/${id}`,
4
+ Page: (id) => `/company/pages/${id}`,
5
+ Library: (id) => `/company/libraries/${id}`,
6
+ Product: (id) => `/company/v1/products/${id}`,
7
+ EnrollmentPack: (id) => `/enrollment_packs/${id}`
8
+ };
9
+ function extractResourceData(json, shareableType) {
10
+ const resource = json.resource;
11
+ if (resource) {
12
+ const typeKey = shareableType.toLowerCase().replace("pack", "_pack");
13
+ if (resource[typeKey]) {
14
+ return resource[typeKey];
15
+ }
16
+ if (resource.product) return resource.product;
17
+ if (resource.enrollment_pack)
18
+ return resource.enrollment_pack;
19
+ }
20
+ const directKey = shareableType.toLowerCase().replace("pack", "_pack");
21
+ if (json[directKey]) {
22
+ return json[directKey];
23
+ }
24
+ if (json.data) return json.data;
25
+ if (json.medium) return json.medium;
26
+ if (json.page) return json.page;
27
+ if (json.library) return json.library;
28
+ if (json.product) return json.product;
29
+ if (json.enrollment_pack)
30
+ return json.enrollment_pack;
31
+ return json;
32
+ }
33
+ async function fetchSingleItem(item, signal, baseUrl = "", getApiHeaders) {
34
+ const getEndpoint = SHAREABLE_ENDPOINTS[item.shareableType];
35
+ if (!getEndpoint) {
36
+ return {
37
+ item,
38
+ data: null,
39
+ error: new Error(`Unknown shareable type: ${item.shareableType}`)
40
+ };
41
+ }
42
+ const endpoint = `${baseUrl}${getEndpoint(item.id)}`;
43
+ try {
44
+ const response = await fetch(endpoint, {
45
+ method: "GET",
46
+ headers: {
47
+ ...getApiHeaders?.(),
48
+ "Content-Type": "application/json"
49
+ },
50
+ signal
51
+ });
52
+ if (!response.ok) {
53
+ return {
54
+ item,
55
+ data: null,
56
+ error: new Error(
57
+ `Failed to fetch ${item.shareableType} with ID ${item.id}: ${response.status}`
58
+ )
59
+ };
60
+ }
61
+ const json = await response.json();
62
+ const resourceData = extractResourceData(json, item.shareableType);
63
+ if (resourceData && typeof resourceData === "object") {
64
+ resourceData.shareable_type = item.shareableType;
65
+ }
66
+ return { item, data: resourceData };
67
+ } catch (error) {
68
+ return {
69
+ item,
70
+ data: null,
71
+ error: error instanceof Error ? error : new Error(
72
+ `Unknown error fetching ${item.shareableType} ${item.id}`
73
+ )
74
+ };
75
+ }
76
+ }
77
+ async function customFetcher(source, context) {
78
+ const { selectedItems } = source;
79
+ if (!selectedItems || selectedItems.length === 0) {
80
+ return [];
81
+ }
82
+ const results = await Promise.all(
83
+ selectedItems.map(
84
+ (item) => fetchSingleItem(
85
+ item,
86
+ context.signal,
87
+ context.baseUrl,
88
+ context.getApiHeaders
89
+ )
90
+ )
91
+ );
92
+ const successfulData = [];
93
+ const errors = [];
94
+ for (const result of results) {
95
+ if (result.error) {
96
+ console.warn(
97
+ `[CustomFetcher] Failed to fetch ${result.item.shareableType} #${result.item.id}:`,
98
+ result.error.message
99
+ );
100
+ errors.push(result.error);
101
+ continue;
102
+ }
103
+ if (result.data) {
104
+ successfulData.push(result.data);
105
+ }
106
+ }
107
+ if (successfulData.length === 0 && errors.length > 0) {
108
+ throw new Error(
109
+ `Failed to fetch all ${errors.length} item(s): ${errors[0]?.message || "Unknown error"}`
110
+ );
111
+ }
112
+ return successfulData;
113
+ }
114
+
115
+ export { customFetcher };
116
+ //# sourceMappingURL=chunk-WYOHFNNW.js.map
117
+ //# sourceMappingURL=chunk-WYOHFNNW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/data-sources/fetchers/custom.ts"],"names":[],"mappings":";AAWA,IAAM,mBAAA,GAGF;AAAA,EACF,MAAA,EAAQ,CAAC,EAAA,KAAO,CAAA,eAAA,EAAkB,EAAE,CAAA,CAAA;AAAA,EACpC,IAAA,EAAM,CAAC,EAAA,KAAO,CAAA,eAAA,EAAkB,EAAE,CAAA,CAAA;AAAA,EAClC,OAAA,EAAS,CAAC,EAAA,KAAO,CAAA,mBAAA,EAAsB,EAAE,CAAA,CAAA;AAAA,EACzC,OAAA,EAAS,CAAC,EAAA,KAAO,CAAA,qBAAA,EAAwB,EAAE,CAAA,CAAA;AAAA,EAC3C,cAAA,EAAgB,CAAC,EAAA,KAAO,CAAA,kBAAA,EAAqB,EAAE,CAAA;AACjD,CAAA;AASA,SAAS,mBAAA,CACP,MACA,aAAA,EACyB;AAEzB,EAAA,MAAM,WAAW,IAAA,CAAK,QAAA;AACtB,EAAA,IAAI,QAAA,EAAU;AAEZ,IAAA,MAAM,UAAU,aAAA,CAAc,WAAA,EAAY,CAAE,OAAA,CAAQ,QAAQ,OAAO,CAAA;AACnE,IAAA,IAAI,QAAA,CAAS,OAAO,CAAA,EAAG;AACrB,MAAA,OAAO,SAAS,OAAO,CAAA;AAAA,IACzB;AAEA,IAAA,IAAI,QAAA,CAAS,OAAA,EAAS,OAAO,QAAA,CAAS,OAAA;AACtC,IAAA,IAAI,QAAA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,OAAA,CAAQ,GAAA;AAAA,IAC5B,aAAA,CAAc,GAAA;AAAA,MAAI,CAAC,IAAA,KACjB,eAAA;AAAA,QACE,IAAA;AAAA,QACA,OAAA,CAAQ,MAAA;AAAA,QACR,OAAA,CAAQ,OAAA;AAAA,QACR,OAAA,CAAQ;AAAA;AACV;AACF,GACF;AAGA,EAAA,MAAM,iBAA4B,EAAC;AACnC,EAAA,MAAM,SAAkB,EAAC;AAEzB,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,IAAA,IAAI,OAAO,KAAA,EAAO;AAChB,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN,mCAAmC,MAAA,CAAO,IAAA,CAAK,aAAa,CAAA,EAAA,EAAK,MAAA,CAAO,KAAK,EAAE,CAAA,CAAA,CAAA;AAAA,QAC/E,OAAO,KAAA,CAAM;AAAA,OACf;AACA,MAAA,MAAA,CAAO,IAAA,CAAK,OAAO,KAAK,CAAA;AACxB,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,OAAO,IAAA,EAAM;AACf,MAAA,cAAA,CAAe,IAAA,CAAK,OAAO,IAAI,CAAA;AAAA,IACjC;AAAA,EACF;AAGA,EAAA,IAAI,cAAA,CAAe,MAAA,KAAW,CAAA,IAAK,MAAA,CAAO,SAAS,CAAA,EAAG;AACpD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,oBAAA,EAAuB,OAAO,MAAM,CAAA,UAAA,EAAa,OAAO,CAAC,CAAA,EAAG,WAAW,eAAe,CAAA;AAAA,KACxF;AAAA,EACF;AAEA,EAAA,OAAO,cAAA;AACT","file":"chunk-WYOHFNNW.js","sourcesContent":["import type {\n CustomDataSource,\n DataSourceContext,\n SelectedItem,\n ShareableType,\n} from \"../types\";\n\n/**\n * Individual resource endpoints for each shareable type.\n * These fetch single items by ID from the company API.\n */\nconst SHAREABLE_ENDPOINTS: Record<\n ShareableType,\n (id: string | number) => string\n> = {\n Medium: (id) => `/company/media/${id}`,\n Page: (id) => `/company/pages/${id}`,\n Library: (id) => `/company/libraries/${id}`,\n Product: (id) => `/company/v1/products/${id}`,\n EnrollmentPack: (id) => `/enrollment_packs/${id}`,\n};\n\n/**\n * Extract the actual resource data from various API response structures.\n * Different endpoints wrap their data differently:\n * - Product: { status, resource: { product: {...} } }\n * - EnrollmentPack: { status, resource: { enrollment_pack: {...} } }\n * - Medium/Page/Library: Direct root or { medium: {...} }\n */\nfunction extractResourceData(\n json: Record<string, unknown>,\n shareableType: ShareableType,\n): Record<string, unknown> {\n // Try nested resource structure first (Product, EnrollmentPack)\n const resource = json.resource as Record<string, unknown> | undefined;\n if (resource) {\n // Check for type-specific key within resource\n const typeKey = shareableType.toLowerCase().replace(\"pack\", \"_pack\");\n if (resource[typeKey]) {\n return resource[typeKey] as Record<string, unknown>;\n }\n // Check common keys\n if (resource.product) return resource.product as Record<string, unknown>;\n if (resource.enrollment_pack)\n return resource.enrollment_pack as Record<string, unknown>;\n }\n\n // Try direct type key (e.g., { medium: {...} })\n const directKey = shareableType.toLowerCase().replace(\"pack\", \"_pack\");\n if (json[directKey]) {\n return json[directKey] as Record<string, unknown>;\n }\n\n // Try common response shapes\n if (json.data) return json.data as Record<string, unknown>;\n if (json.medium) return json.medium as Record<string, unknown>;\n if (json.page) return json.page as Record<string, unknown>;\n if (json.library) return json.library as Record<string, unknown>;\n if (json.product) return json.product as Record<string, unknown>;\n if (json.enrollment_pack)\n return json.enrollment_pack as Record<string, unknown>;\n\n // Return as-is if no wrapper found (Library uses direct serialization)\n return json;\n}\n\n/**\n * Result from fetching a single shareable item\n */\ninterface FetchResult {\n item: SelectedItem;\n data: unknown;\n error?: Error;\n}\n\n/**\n * Fetch a single shareable item by ID from the individual resource endpoint.\n */\nasync function fetchSingleItem(\n item: SelectedItem,\n signal: AbortSignal,\n baseUrl: string = \"\",\n getApiHeaders?: () => Record<string, string>,\n): Promise<FetchResult> {\n const getEndpoint = SHAREABLE_ENDPOINTS[item.shareableType];\n if (!getEndpoint) {\n return {\n item,\n data: null,\n error: new Error(`Unknown shareable type: ${item.shareableType}`),\n };\n }\n\n const endpoint = `${baseUrl}${getEndpoint(item.id)}`;\n\n try {\n const response = await fetch(endpoint, {\n method: \"GET\",\n headers: {\n ...getApiHeaders?.(),\n \"Content-Type\": \"application/json\",\n },\n signal,\n });\n\n if (!response.ok) {\n return {\n item,\n data: null,\n error: new Error(\n `Failed to fetch ${item.shareableType} with ID ${item.id}: ${response.status}`,\n ),\n };\n }\n\n const json = await response.json();\n\n // Extract the actual resource data from the response wrapper\n const resourceData = extractResourceData(json, item.shareableType);\n\n // Add shareable_type to the response for transformer compatibility\n if (resourceData && typeof resourceData === \"object\") {\n (resourceData as Record<string, unknown>).shareable_type =\n item.shareableType;\n }\n\n return { item, data: resourceData };\n } catch (error) {\n return {\n item,\n data: null,\n error:\n error instanceof Error\n ? error\n : new Error(\n `Unknown error fetching ${item.shareableType} ${item.id}`,\n ),\n };\n }\n}\n\n/**\n * Custom fetcher that fetches selected items.\n *\n * Fetches items from individual resource endpoints using the configured\n * getApiHeaders for authentication.\n *\n * Fetches all items in parallel for performance.\n * Returns an array of successfully fetched items, preserving order.\n * Logs warnings for failed fetches but doesn't throw.\n */\nexport async function customFetcher(\n source: CustomDataSource,\n context: DataSourceContext,\n): Promise<unknown[]> {\n const { selectedItems } = source;\n if (!selectedItems || selectedItems.length === 0) {\n return [];\n }\n\n // Fallback: fetch from individual endpoints (no auth)\n const results = await Promise.all(\n selectedItems.map((item) =>\n fetchSingleItem(\n item,\n context.signal,\n context.baseUrl,\n context.getApiHeaders,\n ),\n ),\n );\n\n // Process results, collecting successful data and tracking errors\n const successfulData: unknown[] = [];\n const errors: Error[] = [];\n\n for (const result of results) {\n if (result.error) {\n console.warn(\n `[CustomFetcher] Failed to fetch ${result.item.shareableType} #${result.item.id}:`,\n result.error.message,\n );\n errors.push(result.error);\n continue;\n }\n\n if (result.data) {\n successfulData.push(result.data);\n }\n }\n\n // Throw error if all fetches failed\n if (successfulData.length === 0 && errors.length > 0) {\n throw new Error(\n `Failed to fetch all ${errors.length} item(s): ${errors[0]?.message || \"Unknown error\"}`,\n );\n }\n\n return successfulData;\n}\n"]}
@@ -0,0 +1,38 @@
1
+ import { DataSourceProvider } from './chunk-3I5Y3PEO.js';
2
+ import { DEFAULT_DATA_SOURCE_REGISTRY } from './chunk-HUR3MSO4.js';
3
+ import { createContext, useMemo, useContext } from 'react';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ var DataSourceRegistryContext = createContext(
7
+ {
8
+ registry: DEFAULT_DATA_SOURCE_REGISTRY
9
+ }
10
+ );
11
+ function DataSourceRegistryProvider({
12
+ registry,
13
+ baseUrl,
14
+ getApiHeaders,
15
+ variables,
16
+ children
17
+ }) {
18
+ const value = useMemo(
19
+ () => ({
20
+ registry: registry ?? DEFAULT_DATA_SOURCE_REGISTRY,
21
+ baseUrl,
22
+ getApiHeaders,
23
+ variables
24
+ }),
25
+ [registry, baseUrl, getApiHeaders, variables]
26
+ );
27
+ return /* @__PURE__ */ jsx(DataSourceRegistryContext.Provider, { value, children: /* @__PURE__ */ jsx(DataSourceProvider, { baseUrl, getApiHeaders, children }) });
28
+ }
29
+ function useDataSourceRegistry() {
30
+ return useContext(DataSourceRegistryContext).registry;
31
+ }
32
+ function useDataSourceRegistryConfig() {
33
+ return useContext(DataSourceRegistryContext);
34
+ }
35
+
36
+ export { DataSourceRegistryProvider, useDataSourceRegistry, useDataSourceRegistryConfig };
37
+ //# sourceMappingURL=chunk-XCNBVV4T.js.map
38
+ //# sourceMappingURL=chunk-XCNBVV4T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/data-sources/registry-context.tsx"],"names":[],"mappings":";;;;;AAcA,IAAM,yBAAA,GAA4B,aAAA;AAAA,EAChC;AAAA,IACE,QAAA,EAAU;AAAA;AAEd,CAAA;AAqBO,SAAS,0BAAA,CAA2B;AAAA,EACzC,QAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAA,EAAoC;AAClC,EAAA,MAAM,KAAA,GAAQ,OAAA;AAAA,IACZ,OAAO;AAAA,MACL,UAAU,QAAA,IAAY,4BAAA;AAAA,MACtB,OAAA;AAAA,MACA,aAAA;AAAA,MACA;AAAA,KACF,CAAA;AAAA,IACA,CAAC,QAAA,EAAU,OAAA,EAAS,aAAA,EAAe,SAAS;AAAA,GAC9C;AAEA,EAAA,uBACE,GAAA,CAAC,yBAAA,CAA0B,QAAA,EAA1B,EAAmC,KAAA,EAClC,8BAAC,kBAAA,EAAA,EAAmB,OAAA,EAAkB,aAAA,EACnC,QAAA,EACH,CAAA,EACF,CAAA;AAEJ;AAKO,SAAS,qBAAA,GAA4C;AAC1D,EAAA,OAAO,UAAA,CAAW,yBAAyB,CAAA,CAAE,QAAA;AAC/C;AAKO,SAAS,2BAAA,GAA8D;AAC5E,EAAA,OAAO,WAAW,yBAAyB,CAAA;AAC7C","file":"chunk-XCNBVV4T.js","sourcesContent":["import { createContext, useContext, useMemo, type ReactNode } from \"react\";\nimport type { DataSourceRegistry } from \"./types\";\nimport { DEFAULT_DATA_SOURCE_REGISTRY } from \"./registry\";\nimport { DataSourceProvider } from \"./context\";\n\ninterface DataSourceRegistryContextValue {\n registry: DataSourceRegistry;\n baseUrl?: string | undefined;\n /** Get API headers function */\n getApiHeaders?: (() => Record<string, string>) | undefined;\n /** Dynamic variables for endpoint path substitution (e.g., { rep_id: \"123\" }) */\n variables?: Record<string, string> | undefined;\n}\n\nconst DataSourceRegistryContext = createContext<DataSourceRegistryContextValue>(\n {\n registry: DEFAULT_DATA_SOURCE_REGISTRY,\n },\n);\n\nexport interface DataSourceRegistryProviderProps {\n registry?: DataSourceRegistry | undefined;\n /** Base URL for API calls (e.g., \"https://api.fluid.app/api\") */\n baseUrl?: string | undefined;\n /**\n * Get API headers function\n */\n getApiHeaders?: (() => Record<string, string>) | undefined;\n /** Dynamic variables for endpoint path substitution (e.g., { rep_id: \"123\" }) */\n variables?: Record<string, string> | undefined;\n children: ReactNode;\n}\n\n/**\n * Provides data source registry and configuration to all descendants.\n * If no registry is provided, uses the default.\n * Also provides the shared DataSourceProvider from rep-core so that\n * rep-widgets hooks can access baseUrl and getApiHeaders.\n */\nexport function DataSourceRegistryProvider({\n registry,\n baseUrl,\n getApiHeaders,\n variables,\n children,\n}: DataSourceRegistryProviderProps) {\n const value = useMemo(\n () => ({\n registry: registry ?? DEFAULT_DATA_SOURCE_REGISTRY,\n baseUrl,\n getApiHeaders,\n variables,\n }),\n [registry, baseUrl, getApiHeaders, variables],\n );\n\n return (\n <DataSourceRegistryContext.Provider value={value}>\n <DataSourceProvider baseUrl={baseUrl} getApiHeaders={getApiHeaders}>\n {children}\n </DataSourceProvider>\n </DataSourceRegistryContext.Provider>\n );\n}\n\n/**\n * Hook to access the data source registry.\n */\nexport function useDataSourceRegistry(): DataSourceRegistry {\n return useContext(DataSourceRegistryContext).registry;\n}\n\n/**\n * Hook to access the full data source registry context (registry + config).\n */\nexport function useDataSourceRegistryConfig(): DataSourceRegistryContextValue {\n return useContext(DataSourceRegistryContext);\n}\n"]}
@@ -132,5 +132,5 @@ var SECTION_LAYOUT_CONFIG = {
132
132
  var sectionLayoutConfig = SECTION_LAYOUT_CONFIG;
133
133
 
134
134
  export { BACKGROUND_TYPES, BORDER_RADIUS_OPTIONS, BUTTON_SIZE_OPTIONS, COLOR_OPTIONS, FONT_SIZE_OPTIONS, GAP_OPTIONS, HORIZONTAL_ALIGN_OPTIONS, PADDING_VALUES, SECTION_LAYOUT_CONFIG, VERTICAL_ALIGN_OPTIONS, WIDGET_TYPE_NAMES, assertDefined, assertNever, isWidgetType, isWidgetTypeName, sectionLayoutConfig };
135
- //# sourceMappingURL=chunk-EWR5EIBP.js.map
136
- //# sourceMappingURL=chunk-EWR5EIBP.js.map
135
+ //# sourceMappingURL=chunk-YKF5ZFF5.js.map
136
+ //# sourceMappingURL=chunk-YKF5ZFF5.js.map
@@ -0,0 +1 @@
1
+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,EAAO,KAAK,CAAA;AAAA,IAC5B,WAAA,EAAa;AAAA,GACf;AAAA,EACA,iBAAA,EAAmB;AAAA,IACjB,OAAA,EAAS,CAAA;AAAA,IACT,MAAA,EAAQ,CAAC,KAAA,EAAO,KAAA,EAAO,KAAK,CAAA;AAAA,IAC5B,WAAA,EAAa;AAAA;AAEjB;AAgBO,IAAM,mBAAA,GAAsB","file":"chunk-YKF5ZFF5.js","sourcesContent":["import type { ComponentType } from \"react\";\nimport type { DataSourceConfig } from \"../data-sources/types\";\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 Calendar: \"CalendarWidget\",\n Carousel: \"CarouselWidget\",\n CatchUp: \"CatchUpWidget\",\n Chart: \"ChartWidget\",\n Container: \"ContainerWidget\",\n Embed: \"EmbedWidget\",\n Image: \"ImageWidget\",\n Layout: \"LayoutWidget\",\n List: \"ListWidget\",\n MySite: \"MySiteWidget\",\n Nested: \"NestedWidget\",\n QuickShare: \"QuickShareWidget\",\n RecentActivity: \"RecentActivityWidget\",\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, ComponentType<any>>;\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, ComponentType<any>>> = {\n [K in keyof T]: {\n readonly type: K;\n readonly props: Readonly<React.ComponentProps<T[K]>>;\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","import type { ShareableItem } from \"./shareable-item\";\n\n// ============================================================================\n// Color Options - Derive type from constant for single source of truth\n// ============================================================================\n\n/**\n * Color options constant - single source of truth for color values.\n * Use COLOR_OPTIONS.primary instead of \"primary\" for type-safe comparisons.\n */\nexport const COLOR_OPTIONS = {\n background: \"background\",\n foreground: \"foreground\",\n primary: \"primary\",\n secondary: \"secondary\",\n accent: \"accent\",\n muted: \"muted\",\n destructive: \"destructive\",\n} as const;\n\n/**\n * Union type of all color options, derived from COLOR_OPTIONS constant.\n * @see deriving-typeof-for-object-keys pattern\n */\nexport type ColorOptions = (typeof COLOR_OPTIONS)[keyof typeof COLOR_OPTIONS];\n\n// ============================================================================\n// Size Options - Derive types from constants for single source of truth\n// ============================================================================\n\nexport const FONT_SIZE_OPTIONS = {\n \"2xl\": \"2xl\",\n xl: \"xl\",\n lg: \"lg\",\n md: \"md\",\n sm: \"sm\",\n xs: \"xs\",\n} as const;\n\nexport type FontSizeOptions =\n (typeof FONT_SIZE_OPTIONS)[keyof typeof FONT_SIZE_OPTIONS];\n\nexport const BORDER_RADIUS_OPTIONS = {\n none: \"none\",\n sm: \"sm\",\n md: \"md\",\n lg: \"lg\",\n xl: \"xl\",\n full: \"full\",\n} as const;\n\nexport type BorderRadiusOptions =\n (typeof BORDER_RADIUS_OPTIONS)[keyof typeof BORDER_RADIUS_OPTIONS];\n\n/** Padding values - numeric, so we use a tuple for derivation */\nexport const PADDING_VALUES = [0, 2, 4, 6, 8, 10] as const;\nexport type PaddingOptions = (typeof PADDING_VALUES)[number];\n\nexport const BUTTON_SIZE_OPTIONS = {\n sm: \"sm\",\n default: \"default\",\n lg: \"lg\",\n xl: \"xl\",\n} as const;\n\nexport type ButtonSizeOptions =\n (typeof BUTTON_SIZE_OPTIONS)[keyof typeof BUTTON_SIZE_OPTIONS];\n\nexport const GAP_OPTIONS = {\n none: \"none\",\n xs: \"xs\",\n sm: \"sm\",\n md: \"md\",\n lg: \"lg\",\n xl: \"xl\",\n} as const;\n\nexport type GapOptions = (typeof GAP_OPTIONS)[keyof typeof GAP_OPTIONS];\n\n// ============================================================================\n// Alignment Options - Derive from constants\n// ============================================================================\n\nexport const VERTICAL_ALIGN_OPTIONS = {\n top: \"top\",\n center: \"center\",\n bottom: \"bottom\",\n} as const;\n\nexport type VerticalAlign =\n (typeof VERTICAL_ALIGN_OPTIONS)[keyof typeof VERTICAL_ALIGN_OPTIONS];\n\nexport const HORIZONTAL_ALIGN_OPTIONS = {\n left: \"left\",\n center: \"center\",\n right: \"right\",\n} as const;\n\nexport type HorizontalAlign =\n (typeof HORIZONTAL_ALIGN_OPTIONS)[keyof typeof HORIZONTAL_ALIGN_OPTIONS];\n\nexport type AlignOptions = {\n vertical?: VerticalAlign;\n horizontal?: HorizontalAlign;\n};\n\n// ============================================================================\n// Background Options - Derive from constant\n// ============================================================================\n\nexport const BACKGROUND_TYPES = {\n solid: \"solid\",\n image: \"image\",\n} as const;\n\nexport type BackgroundType =\n (typeof BACKGROUND_TYPES)[keyof typeof BACKGROUND_TYPES];\nexport interface BackgroundValue {\n type: BackgroundType;\n color?: ColorOptions;\n resource?: ShareableItem;\n}\n\n// ============================================================================\n// Section Layout - Derive type from config keys (single source of truth)\n// ============================================================================\n\n/**\n * Section layout configuration - single source of truth for layout types.\n * SectionLayoutType is derived from these keys to prevent drift.\n */\nexport const SECTION_LAYOUT_CONFIG = {\n \"single-column\": { columns: 1, widths: [\"1fr\"], gridClasses: \"\" },\n \"2c-equal\": {\n columns: 2,\n widths: [\"1fr\", \"1fr\"],\n gridClasses: \"@md:grid-cols-2\",\n },\n \"2c-left-wider\": {\n columns: 2,\n widths: [\"2fr\", \"1fr\"],\n gridClasses: \"@md:grid-cols-[2fr_1fr]\",\n },\n \"2c-right-wider\": {\n columns: 2,\n widths: [\"1fr\", \"2fr\"],\n gridClasses: \"@md:grid-cols-[1fr_2fr]\",\n },\n \"2c-left-narrow\": {\n columns: 2,\n widths: [\"1fr\", \"3fr\"],\n gridClasses: \"@md:grid-cols-[1fr_3fr]\",\n },\n \"2c-right-narrow\": {\n columns: 2,\n widths: [\"3fr\", \"1fr\"],\n gridClasses: \"@md:grid-cols-[3fr_1fr]\",\n },\n \"3c-equal\": {\n columns: 3,\n widths: [\"1fr\", \"1fr\", \"1fr\"],\n gridClasses: \"@md:grid-cols-3\",\n },\n \"3c-middle-wider\": {\n columns: 3,\n widths: [\"1fr\", \"2fr\", \"1fr\"],\n gridClasses: \"@md:grid-cols-[1fr_2fr_1fr]\",\n },\n} as const satisfies Record<\n string,\n {\n readonly columns: number;\n readonly widths: readonly string[];\n readonly gridClasses: string;\n }\n>;\n\n/**\n * Union type of all section layout types, derived from SECTION_LAYOUT_CONFIG keys.\n * @see deriving-typeof-for-object-keys pattern\n */\nexport type SectionLayoutType = keyof typeof SECTION_LAYOUT_CONFIG;\n\n/** @deprecated Use SECTION_LAYOUT_CONFIG instead */\nexport const sectionLayoutConfig = SECTION_LAYOUT_CONFIG;\n"]}
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+
6
+ // src/shell/ThemeModeContext.tsx
7
+ var ThemeModeContext = react.createContext(null);
8
+ var darkMediaQuery = typeof window !== "undefined" ? window.matchMedia("(prefers-color-scheme: dark)") : null;
9
+ function subscribeToPrefersColorScheme(callback) {
10
+ darkMediaQuery?.addEventListener("change", callback);
11
+ return () => darkMediaQuery?.removeEventListener("change", callback);
12
+ }
13
+ function getSystemPrefersDark() {
14
+ return darkMediaQuery?.matches ?? false;
15
+ }
16
+ function getServerSnapshot() {
17
+ return false;
18
+ }
19
+ function ThemeModeProvider({
20
+ children,
21
+ mode,
22
+ onModeChange,
23
+ autoModeEnabled = true
24
+ }) {
25
+ const systemPrefersDark = react.useSyncExternalStore(
26
+ subscribeToPrefersColorScheme,
27
+ getSystemPrefersDark,
28
+ getServerSnapshot
29
+ );
30
+ const systemMode = systemPrefersDark ? "dark" : "light";
31
+ const displayMode = mode === "auto" ? systemMode : mode;
32
+ const cycleMode = react.useCallback(() => {
33
+ if (autoModeEnabled) {
34
+ const target = displayMode === "light" ? "dark" : "light";
35
+ onModeChange(target === systemMode ? "auto" : target);
36
+ } else {
37
+ onModeChange(mode === "light" ? "dark" : "light");
38
+ }
39
+ }, [mode, displayMode, systemMode, onModeChange, autoModeEnabled]);
40
+ const dataAttribute = getThemeModeAttribute(mode);
41
+ const value = react.useMemo(
42
+ () => ({
43
+ mode,
44
+ displayMode,
45
+ setMode: onModeChange,
46
+ autoModeEnabled,
47
+ cycleMode,
48
+ dataAttribute
49
+ }),
50
+ [
51
+ mode,
52
+ displayMode,
53
+ onModeChange,
54
+ autoModeEnabled,
55
+ cycleMode,
56
+ dataAttribute
57
+ ]
58
+ );
59
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeModeContext.Provider, { value, children });
60
+ }
61
+ function useThemeMode() {
62
+ const ctx = react.useContext(ThemeModeContext);
63
+ if (!ctx) {
64
+ throw new Error("useThemeMode must be used within a ThemeModeProvider");
65
+ }
66
+ return ctx;
67
+ }
68
+ function getThemeModeAttribute(mode) {
69
+ return mode === "auto" ? void 0 : mode;
70
+ }
71
+
72
+ exports.ThemeModeProvider = ThemeModeProvider;
73
+ exports.getThemeModeAttribute = getThemeModeAttribute;
74
+ exports.useThemeMode = useThemeMode;
75
+ //# sourceMappingURL=chunk-YXJMBVXO.cjs.map
76
+ //# sourceMappingURL=chunk-YXJMBVXO.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shell/ThemeModeContext.tsx"],"names":["createContext","useSyncExternalStore","useCallback","useMemo","jsx","useContext"],"mappings":";;;;;;AAwBA,IAAM,gBAAA,GAAmBA,oBAA4C,IAAI,CAAA;AAEzE,IAAM,iBACJ,OAAO,MAAA,KAAW,cACd,MAAA,CAAO,UAAA,CAAW,8BAA8B,CAAA,GAChD,IAAA;AAEN,SAAS,8BAA8B,QAAA,EAAsB;AAC3D,EAAA,cAAA,EAAgB,gBAAA,CAAiB,UAAU,QAAQ,CAAA;AACnD,EAAA,OAAO,MAAM,cAAA,EAAgB,mBAAA,CAAoB,QAAA,EAAU,QAAQ,CAAA;AACrE;AAEA,SAAS,oBAAA,GAAgC;AACvC,EAAA,OAAO,gBAAgB,OAAA,IAAW,KAAA;AACpC;AAEA,SAAS,iBAAA,GAA6B;AACpC,EAAA,OAAO,KAAA;AACT;AAUO,SAAS,iBAAA,CAAkB;AAAA,EAChC,QAAA;AAAA,EACA,IAAA;AAAA,EACA,YAAA;AAAA,EACA,eAAA,GAAkB;AACpB,CAAA,EAA2B;AACzB,EAAA,MAAM,iBAAA,GAAoBC,0BAAA;AAAA,IACxB,6BAAA;AAAA,IACA,oBAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,MAAM,UAAA,GAA0B,oBAAoB,MAAA,GAAS,OAAA;AAE7D,EAAA,MAAM,WAAA,GAA2B,IAAA,KAAS,MAAA,GAAS,UAAA,GAAa,IAAA;AAEhE,EAAA,MAAM,SAAA,GAAYC,kBAAY,MAAM;AAClC,IAAA,IAAI,eAAA,EAAiB;AAEnB,MAAA,MAAM,MAAA,GAAsB,WAAA,KAAgB,OAAA,GAAU,MAAA,GAAS,OAAA;AAC/D,MAAA,YAAA,CAAa,MAAA,KAAW,UAAA,GAAa,MAAA,GAAS,MAAM,CAAA;AAAA,IACtD,CAAA,MAAO;AAEL,MAAA,YAAA,CAAa,IAAA,KAAS,OAAA,GAAU,MAAA,GAAS,OAAO,CAAA;AAAA,IAClD;AAAA,EACF,GAAG,CAAC,IAAA,EAAM,aAAa,UAAA,EAAY,YAAA,EAAc,eAAe,CAAC,CAAA;AAEjE,EAAA,MAAM,aAAA,GAAgB,sBAAsB,IAAI,CAAA;AAEhD,EAAA,MAAM,KAAA,GAAQC,aAAA;AAAA,IACZ,OAAO;AAAA,MACL,IAAA;AAAA,MACA,WAAA;AAAA,MACA,OAAA,EAAS,YAAA;AAAA,MACT,eAAA;AAAA,MACA,SAAA;AAAA,MACA;AAAA,KACF,CAAA;AAAA,IACA;AAAA,MACE,IAAA;AAAA,MACA,WAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,SAAA;AAAA,MACA;AAAA;AACF,GACF;AAEA,EAAA,uBACEC,cAAA,CAAC,gBAAA,CAAiB,QAAA,EAAjB,EAA0B,OACxB,QAAA,EACH,CAAA;AAEJ;AAGO,SAAS,YAAA,GAAsC;AACpD,EAAA,MAAM,GAAA,GAAMC,iBAAW,gBAAgB,CAAA;AACvC,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,MAAM,sDAAsD,CAAA;AAAA,EACxE;AACA,EAAA,OAAO,GAAA;AACT;AAGO,SAAS,sBAAsB,IAAA,EAAqC;AACzE,EAAA,OAAO,IAAA,KAAS,SAAS,MAAA,GAAY,IAAA;AACvC","file":"chunk-YXJMBVXO.cjs","sourcesContent":["\"use client\";\n\nimport {\n createContext,\n useContext,\n useCallback,\n useMemo,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\n\nexport type ThemeMode = \"auto\" | \"light\" | \"dark\";\n\nexport type DisplayMode = \"light\" | \"dark\";\n\nexport interface ThemeModeContextValue {\n mode: ThemeMode;\n displayMode: DisplayMode;\n setMode: (mode: ThemeMode) => void;\n autoModeEnabled: boolean;\n cycleMode: () => void;\n dataAttribute: string | undefined;\n}\n\nconst ThemeModeContext = createContext<ThemeModeContextValue | null>(null);\n\nconst darkMediaQuery =\n typeof window !== \"undefined\"\n ? window.matchMedia(\"(prefers-color-scheme: dark)\")\n : null;\n\nfunction subscribeToPrefersColorScheme(callback: () => void) {\n darkMediaQuery?.addEventListener(\"change\", callback);\n return () => darkMediaQuery?.removeEventListener(\"change\", callback);\n}\n\nfunction getSystemPrefersDark(): boolean {\n return darkMediaQuery?.matches ?? false;\n}\n\nfunction getServerSnapshot(): boolean {\n return false;\n}\n\ninterface ThemeModeProviderProps {\n children: ReactNode;\n mode: ThemeMode;\n onModeChange: (mode: ThemeMode) => void;\n /** When false, auto mode is skipped in the cycle (light↔dark only). Default true. */\n autoModeEnabled?: boolean;\n}\n\nexport function ThemeModeProvider({\n children,\n mode,\n onModeChange,\n autoModeEnabled = true,\n}: ThemeModeProviderProps) {\n const systemPrefersDark = useSyncExternalStore(\n subscribeToPrefersColorScheme,\n getSystemPrefersDark,\n getServerSnapshot,\n );\n\n const systemMode: DisplayMode = systemPrefersDark ? \"dark\" : \"light\";\n\n const displayMode: DisplayMode = mode === \"auto\" ? systemMode : mode;\n\n const cycleMode = useCallback(() => {\n if (autoModeEnabled) {\n // Toggle displayed mode. If target matches system preference, use \"auto\".\n const target: DisplayMode = displayMode === \"light\" ? \"dark\" : \"light\";\n onModeChange(target === systemMode ? \"auto\" : target);\n } else {\n // light ↔ dark\n onModeChange(mode === \"light\" ? \"dark\" : \"light\");\n }\n }, [mode, displayMode, systemMode, onModeChange, autoModeEnabled]);\n\n const dataAttribute = getThemeModeAttribute(mode);\n\n const value = useMemo(\n () => ({\n mode,\n displayMode,\n setMode: onModeChange,\n autoModeEnabled,\n cycleMode,\n dataAttribute,\n }),\n [\n mode,\n displayMode,\n onModeChange,\n autoModeEnabled,\n cycleMode,\n dataAttribute,\n ],\n );\n\n return (\n <ThemeModeContext.Provider value={value}>\n {children}\n </ThemeModeContext.Provider>\n );\n}\n\n/** Access the current theme mode, setter, and cycle helper. Must be used within a `ThemeModeProvider`. */\nexport function useThemeMode(): ThemeModeContextValue {\n const ctx = useContext(ThemeModeContext);\n if (!ctx) {\n throw new Error(\"useThemeMode must be used within a ThemeModeProvider\");\n }\n return ctx;\n}\n\n/** Maps a ThemeMode to the value for `data-theme-mode`. Returns undefined for \"auto\". */\nexport function getThemeModeAttribute(mode: ThemeMode): string | undefined {\n return mode === \"auto\" ? undefined : mode;\n}\n"]}
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ var chunkOWU7MFJ2_cjs = require('../chunk-OWU7MFJ2.cjs');
4
+ var chunkESYAYVNK_cjs = require('../chunk-ESYAYVNK.cjs');
5
+ require('../chunk-V7D3QUE6.cjs');
6
+ require('../chunk-SJQPHJL4.cjs');
7
+ require('../chunk-LVLNO2YQ.cjs');
8
+ require('../chunk-46PUWB7C.cjs');
9
+ require('../chunk-HGVSPZEL.cjs');
10
+ require('../chunk-N2K6W7FX.cjs');
11
+ require('../chunk-2SIG55BD.cjs');
12
+ var react = require('react');
13
+ var jsxRuntime = require('react/jsx-runtime');
14
+
15
+ var EMPTY_OBJECT = {};
16
+ function DataAwareWidgetImpl({
17
+ widget,
18
+ Component,
19
+ additionalProps,
20
+ loadingComponent,
21
+ errorComponent,
22
+ baseUrl
23
+ }) {
24
+ const stableAdditionalProps = additionalProps ?? EMPTY_OBJECT;
25
+ const { data, isLoading, error } = chunkESYAYVNK_cjs.useWidgetData(widget, { baseUrl });
26
+ const mergedProps = react.useMemo(
27
+ () => ({
28
+ ...widget.props,
29
+ ...data,
30
+ ...stableAdditionalProps
31
+ }),
32
+ [widget.props, data, stableAdditionalProps]
33
+ );
34
+ if (isLoading && widget.dataSource?.loading?.showSkeleton !== false) {
35
+ if (loadingComponent) {
36
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: loadingComponent });
37
+ }
38
+ return /* @__PURE__ */ jsxRuntime.jsx(
39
+ "div",
40
+ {
41
+ className: "animate-pulse rounded-md bg-muted",
42
+ style: { minHeight: 100 },
43
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading..." })
44
+ }
45
+ );
46
+ }
47
+ if (error && !data) {
48
+ if (errorComponent) {
49
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: errorComponent(error) });
50
+ }
51
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkOWU7MFJ2_cjs.ErrorState, {});
52
+ }
53
+ return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...mergedProps });
54
+ }
55
+ var DataAwareWidget = react.memo(DataAwareWidgetImpl);
56
+
57
+ exports.DataAwareWidget = DataAwareWidget;
58
+ //# sourceMappingURL=DataAwareWidget.cjs.map
59
+ //# sourceMappingURL=DataAwareWidget.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/data-sources/DataAwareWidget.tsx"],"names":["useWidgetData","useMemo","jsx","Fragment","ErrorState","memo"],"mappings":";;;;;;;;;;;;;;AAoBA,IAAM,eAAwC,EAAC;AAM/C,SAAS,mBAAA,CAAoB;AAAA,EAC3B,MAAA;AAAA,EACA,SAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAA,EAAyB;AAEvB,EAAA,MAAM,wBAAwB,eAAA,IAAmB,YAAA;AACjD,EAAA,MAAM,EAAE,MAAM,SAAA,EAAW,KAAA,KAAUA,+BAAA,CAAc,MAAA,EAAQ,EAAE,OAAA,EAAS,CAAA;AAMpE,EAAA,MAAM,WAAA,GAAcC,aAAA;AAAA,IAClB,OAAO;AAAA,MACL,GAAG,MAAA,CAAO,KAAA;AAAA,MACV,GAAG,IAAA;AAAA,MACH,GAAG;AAAA,KACL,CAAA;AAAA,IACA,CAAC,MAAA,CAAO,KAAA,EAAO,IAAA,EAAM,qBAAqB;AAAA,GAC5C;AAGA,EAAA,IAAI,SAAA,IAAa,MAAA,CAAO,UAAA,EAAY,OAAA,EAAS,iBAAiB,KAAA,EAAO;AACnE,IAAA,IAAI,gBAAA,EAAkB;AACpB,MAAA,6DAAU,QAAA,EAAA,gBAAA,EAAiB,CAAA;AAAA,IAC7B;AAEA,IAAA,uBACEC,cAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,SAAA,EAAU,mCAAA;AAAA,QACV,KAAA,EAAO,EAAE,SAAA,EAAW,GAAA,EAAI;AAAA,QAExB,QAAA,kBAAAA,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAU,QAAA,EAAA,YAAA,EAAU;AAAA;AAAA,KACtC;AAAA,EAEJ;AAGA,EAAA,IAAI,KAAA,IAAS,CAAC,IAAA,EAAM;AAClB,IAAA,IAAI,cAAA,EAAgB;AAClB,MAAA,uBAAOA,cAAA,CAAAC,mBAAA,EAAA,EAAG,QAAA,EAAA,cAAA,CAAe,KAAK,CAAA,EAAE,CAAA;AAAA,IAClC;AAEA,IAAA,sCAAQC,4BAAA,EAAA,EAAW,CAAA;AAAA,EACrB;AAEA,EAAA,uBAAOF,cAAA,CAAC,SAAA,EAAA,EAAW,GAAG,WAAA,EAAa,CAAA;AACrC;AAMO,IAAM,eAAA,GAAkBG,WAAK,mBAAmB","file":"DataAwareWidget.cjs","sourcesContent":["import { memo, useMemo, type ComponentType, type ReactNode } from \"react\";\nimport type { WidgetSchema } from \"../types/widget-schema\";\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) {\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=\"animate-pulse rounded-md bg-muted\"\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 = memo(DataAwareWidgetImpl);\n"]}