@fluid-app/portal-widgets 0.1.17

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 (145) hide show
  1. package/dist/AlertWidget-AS_8Jjbd.cjs +39 -0
  2. package/dist/AlertWidget-AS_8Jjbd.cjs.map +1 -0
  3. package/dist/AlertWidget-Dy6pBmXm.mjs +22 -0
  4. package/dist/AlertWidget-Dy6pBmXm.mjs.map +1 -0
  5. package/dist/CalendarWidget-DAHnT9Wn.mjs +424 -0
  6. package/dist/CalendarWidget-DAHnT9Wn.mjs.map +1 -0
  7. package/dist/CalendarWidget-DW7q6Q7_.cjs +441 -0
  8. package/dist/CalendarWidget-DW7q6Q7_.cjs.map +1 -0
  9. package/dist/CarouselWidget-BJvLjY7H.mjs +436 -0
  10. package/dist/CarouselWidget-BJvLjY7H.mjs.map +1 -0
  11. package/dist/CarouselWidget-Bdn0LVXT.cjs +453 -0
  12. package/dist/CarouselWidget-Bdn0LVXT.cjs.map +1 -0
  13. package/dist/CatchUpWidget-CZMptzf8.cjs +264 -0
  14. package/dist/CatchUpWidget-CZMptzf8.cjs.map +1 -0
  15. package/dist/CatchUpWidget-vEP5scfy.mjs +247 -0
  16. package/dist/CatchUpWidget-vEP5scfy.mjs.map +1 -0
  17. package/dist/ChartWidget-B3GcdLqH.mjs +415 -0
  18. package/dist/ChartWidget-B3GcdLqH.mjs.map +1 -0
  19. package/dist/ChartWidget-DQB7K6S0.cjs +432 -0
  20. package/dist/ChartWidget-DQB7K6S0.cjs.map +1 -0
  21. package/dist/ContainerWidget-B-4hcPKJ.mjs +44 -0
  22. package/dist/ContainerWidget-B-4hcPKJ.mjs.map +1 -0
  23. package/dist/ContainerWidget-CHa4gVvV.cjs +2 -0
  24. package/dist/ContainerWidget-rGsakG66.cjs +51 -0
  25. package/dist/ContainerWidget-rGsakG66.cjs.map +1 -0
  26. package/dist/EmbedWidget-ChLVA_9a.mjs +156 -0
  27. package/dist/EmbedWidget-ChLVA_9a.mjs.map +1 -0
  28. package/dist/EmbedWidget-mv5ce32s.cjs +173 -0
  29. package/dist/EmbedWidget-mv5ce32s.cjs.map +1 -0
  30. package/dist/ImageWidget-DFt4mJJx.cjs +167 -0
  31. package/dist/ImageWidget-DFt4mJJx.cjs.map +1 -0
  32. package/dist/ImageWidget-DMubcgat.mjs +150 -0
  33. package/dist/ImageWidget-DMubcgat.mjs.map +1 -0
  34. package/dist/LayoutWidget-BEi0yFpz.mjs +107 -0
  35. package/dist/LayoutWidget-BEi0yFpz.mjs.map +1 -0
  36. package/dist/LayoutWidget-C4-ka0Ge.cjs +114 -0
  37. package/dist/LayoutWidget-C4-ka0Ge.cjs.map +1 -0
  38. package/dist/LayoutWidget-D4haEqTQ.cjs +2 -0
  39. package/dist/ListWidget-C-jcsCb4.mjs +901 -0
  40. package/dist/ListWidget-C-jcsCb4.mjs.map +1 -0
  41. package/dist/ListWidget-RHQ2fQXa.cjs +919 -0
  42. package/dist/ListWidget-RHQ2fQXa.cjs.map +1 -0
  43. package/dist/MediaRenderer-CcJvyOJ1.cjs +181 -0
  44. package/dist/MediaRenderer-CcJvyOJ1.cjs.map +1 -0
  45. package/dist/MediaRenderer-Uq90PZcY.mjs +163 -0
  46. package/dist/MediaRenderer-Uq90PZcY.mjs.map +1 -0
  47. package/dist/MySiteWidget-A_cYFgxJ.cjs +279 -0
  48. package/dist/MySiteWidget-A_cYFgxJ.cjs.map +1 -0
  49. package/dist/MySiteWidget-DariqlfU.mjs +262 -0
  50. package/dist/MySiteWidget-DariqlfU.mjs.map +1 -0
  51. package/dist/NestedWidget-CNkwGwhM.mjs +330 -0
  52. package/dist/NestedWidget-CNkwGwhM.mjs.map +1 -0
  53. package/dist/NestedWidget-ofk9O-t1.cjs +346 -0
  54. package/dist/NestedWidget-ofk9O-t1.cjs.map +1 -0
  55. package/dist/QuickShareWidget-DWvgEy74.cjs +262 -0
  56. package/dist/QuickShareWidget-DWvgEy74.cjs.map +1 -0
  57. package/dist/QuickShareWidget-DXq5lcDn.mjs +245 -0
  58. package/dist/QuickShareWidget-DXq5lcDn.mjs.map +1 -0
  59. package/dist/RecentActivityWidget-BvncOdax.mjs +391 -0
  60. package/dist/RecentActivityWidget-BvncOdax.mjs.map +1 -0
  61. package/dist/RecentActivityWidget-wODng8dt.cjs +408 -0
  62. package/dist/RecentActivityWidget-wODng8dt.cjs.map +1 -0
  63. package/dist/RegistryContext-CscXrsRa.mjs +36 -0
  64. package/dist/RegistryContext-CscXrsRa.mjs.map +1 -0
  65. package/dist/RegistryContext-xjea4xVV.cjs +55 -0
  66. package/dist/RegistryContext-xjea4xVV.cjs.map +1 -0
  67. package/dist/ScreenRenderer-D52h5VQr.mjs +76 -0
  68. package/dist/ScreenRenderer-D52h5VQr.mjs.map +1 -0
  69. package/dist/ScreenRenderer-DZAxcg7x.cjs +82 -0
  70. package/dist/ScreenRenderer-DZAxcg7x.cjs.map +1 -0
  71. package/dist/ScreenRendererContext-CK1IsFTn.cjs +36 -0
  72. package/dist/ScreenRendererContext-CK1IsFTn.cjs.map +1 -0
  73. package/dist/ScreenRendererContext-DKcdcmiT.mjs +23 -0
  74. package/dist/ScreenRendererContext-DKcdcmiT.mjs.map +1 -0
  75. package/dist/SpacerWidget-Bgz6701y.cjs +60 -0
  76. package/dist/SpacerWidget-Bgz6701y.cjs.map +1 -0
  77. package/dist/SpacerWidget-DHGoW6eu.mjs +43 -0
  78. package/dist/SpacerWidget-DHGoW6eu.mjs.map +1 -0
  79. package/dist/TableWidget--yLJTqoW.mjs +438 -0
  80. package/dist/TableWidget--yLJTqoW.mjs.map +1 -0
  81. package/dist/TableWidget-TfQfFHft.cjs +455 -0
  82. package/dist/TableWidget-TfQfFHft.cjs.map +1 -0
  83. package/dist/TextWidget-CL2H3vei.mjs +129 -0
  84. package/dist/TextWidget-CL2H3vei.mjs.map +1 -0
  85. package/dist/TextWidget-D6Ug_2Z1.cjs +146 -0
  86. package/dist/TextWidget-D6Ug_2Z1.cjs.map +1 -0
  87. package/dist/ToDoWidget-D8YIsl7y.mjs +274 -0
  88. package/dist/ToDoWidget-D8YIsl7y.mjs.map +1 -0
  89. package/dist/ToDoWidget-Dvs0GDkx.cjs +291 -0
  90. package/dist/ToDoWidget-Dvs0GDkx.cjs.map +1 -0
  91. package/dist/VideoWidget-D6C_jHOF.mjs +192 -0
  92. package/dist/VideoWidget-D6C_jHOF.mjs.map +1 -0
  93. package/dist/VideoWidget-SODAPZO4.cjs +209 -0
  94. package/dist/VideoWidget-SODAPZO4.cjs.map +1 -0
  95. package/dist/chunk-CZWwpsFl.cjs +43 -0
  96. package/dist/components/index.cjs +14 -0
  97. package/dist/components/index.cjs.map +1 -0
  98. package/dist/components/index.d.cts +11 -0
  99. package/dist/components/index.d.cts.map +1 -0
  100. package/dist/components/index.d.mts +11 -0
  101. package/dist/components/index.d.mts.map +1 -0
  102. package/dist/components/index.mjs +11 -0
  103. package/dist/components/index.mjs.map +1 -0
  104. package/dist/contexts/index.cjs +8 -0
  105. package/dist/contexts/index.d.cts +77 -0
  106. package/dist/contexts/index.d.cts.map +1 -0
  107. package/dist/contexts/index.d.mts +77 -0
  108. package/dist/contexts/index.d.mts.map +1 -0
  109. package/dist/contexts/index.mjs +3 -0
  110. package/dist/core/index.cjs +51 -0
  111. package/dist/core/index.d.cts +77 -0
  112. package/dist/core/index.d.cts.map +1 -0
  113. package/dist/core/index.d.mts +77 -0
  114. package/dist/core/index.d.mts.map +1 -0
  115. package/dist/core/index.mjs +4 -0
  116. package/dist/error-state-DErSxZwH.mjs +18 -0
  117. package/dist/error-state-DErSxZwH.mjs.map +1 -0
  118. package/dist/error-state-DSzVUtEl.cjs +24 -0
  119. package/dist/error-state-DSzVUtEl.cjs.map +1 -0
  120. package/dist/fields-4FC6JUNH.d.mts +2 -0
  121. package/dist/fields-DjLFJmz6.d.cts +2 -0
  122. package/dist/fields-wPOk-SmZ.mjs +2 -0
  123. package/dist/rolldown-runtime-wcPFST8Q.mjs +13 -0
  124. package/dist/scroll-arrows-BZIlsE_x.cjs +35 -0
  125. package/dist/scroll-arrows-BZIlsE_x.cjs.map +1 -0
  126. package/dist/scroll-arrows-BevCYRNT.mjs +29 -0
  127. package/dist/scroll-arrows-BevCYRNT.mjs.map +1 -0
  128. package/dist/ui/index.cjs +101 -0
  129. package/dist/ui/index.d.cts +15 -0
  130. package/dist/ui/index.d.cts.map +1 -0
  131. package/dist/ui/index.d.mts +15 -0
  132. package/dist/ui/index.d.mts.map +1 -0
  133. package/dist/ui/index.mjs +3 -0
  134. package/dist/widgets/index.cjs +92 -0
  135. package/dist/widgets/index.cjs.map +1 -0
  136. package/dist/widgets/index.d.cts +689 -0
  137. package/dist/widgets/index.d.cts.map +1 -0
  138. package/dist/widgets/index.d.mts +689 -0
  139. package/dist/widgets/index.d.mts.map +1 -0
  140. package/dist/widgets/index.mjs +46 -0
  141. package/dist/widgets/index.mjs.map +1 -0
  142. package/package.json +104 -0
  143. package/src/styles/globals.css +23 -0
  144. package/src/styles/index.ts +1 -0
  145. package/tailwind.config.ts +61 -0
@@ -0,0 +1,264 @@
1
+ const require_chunk = require("./chunk-CZWwpsFl.cjs");
2
+ const require_error_state = require("./error-state-DSzVUtEl.cjs");
3
+ let react_jsx_runtime = require("react/jsx-runtime");
4
+ let _tanstack_react_query = require("@tanstack/react-query");
5
+ let _fluid_app_portal_core_data_sources_context = require("@fluid-app/portal-core/data-sources/context");
6
+ let _fluid_app_portal_core_data_sources_preview_context = require("@fluid-app/portal-core/data-sources/preview-context");
7
+ let _fortawesome_react_fontawesome = require("@fortawesome/react-fontawesome");
8
+ let _fortawesome_pro_regular_svg_icons = require("@fortawesome/pro-regular-svg-icons");
9
+ let _fluid_app_portal_core_registries = require("@fluid-app/portal-core/registries");
10
+ //#region src/hooks/use-catchups.preview.ts
11
+ const PREVIEW_DATA = [
12
+ {
13
+ id: 1,
14
+ suggestion_title: "Check in with Sarah about her recent order"
15
+ },
16
+ {
17
+ id: 2,
18
+ suggestion_title: "Follow up with Mike on product samples"
19
+ },
20
+ {
21
+ id: 3,
22
+ suggestion_title: "Reconnect with Lisa — last contact 30 days ago"
23
+ },
24
+ {
25
+ id: 4,
26
+ suggestion_title: "Thank Alex for their referral last week"
27
+ },
28
+ {
29
+ id: 5,
30
+ suggestion_title: "Share new catalog with Jordan"
31
+ }
32
+ ];
33
+ //#endregion
34
+ //#region src/hooks/use-catchups.ts
35
+ function useCatchUps() {
36
+ const { baseUrl, getApiHeaders } = (0, _fluid_app_portal_core_data_sources_context.useDataSourceConfig)();
37
+ const { isPreview } = (0, _fluid_app_portal_core_data_sources_preview_context.useWidgetPreviewContext)();
38
+ return (0, _tanstack_react_query.useQuery)({
39
+ queryKey: [
40
+ "portal-widget-use",
41
+ "catchups",
42
+ isPreview ? "preview" : baseUrl
43
+ ],
44
+ queryFn: async ({ signal }) => {
45
+ const url = baseUrl ? `${baseUrl}/affiliate_catch_up_actions.json` : "/affiliate_catch_up_actions.json";
46
+ const response = await fetch(url, {
47
+ headers: {
48
+ "content-type": "application/json",
49
+ ...getApiHeaders?.()
50
+ },
51
+ signal
52
+ });
53
+ if (!response.ok) throw new Error(`Failed to fetch catch ups: ${response.status}`);
54
+ return response.json();
55
+ },
56
+ enabled: !isPreview,
57
+ ...isPreview && { placeholderData: PREVIEW_DATA }
58
+ });
59
+ }
60
+ //#endregion
61
+ //#region src/widgets/CatchUpWidget.tsx
62
+ var CatchUpWidget_exports = /* @__PURE__ */ require_chunk.__exportAll({
63
+ CatchUpWidget: () => CatchUpWidget,
64
+ catchUpWidgetPropertySchema: () => catchUpWidgetPropertySchema
65
+ });
66
+ const fontSizeClasses = {
67
+ "2xl": "text-2xl",
68
+ xl: "text-xl",
69
+ lg: "text-lg",
70
+ md: "text-base",
71
+ sm: "text-sm",
72
+ xs: "text-xs"
73
+ };
74
+ function CatchUpWidget({ titleEnabled = true, titleText = "Catch Ups", titleFontSize = "xl", titleColor = "foreground", background = {
75
+ type: "solid",
76
+ color: "background"
77
+ }, textColor = "foreground", accentColor = "primary", padding = 4, borderRadius = "md", maxItems = 5, className, ...props }) {
78
+ const backgroundColor = background.color || "background";
79
+ const backgroundImage = (background.resource?.image_url || background.resource?.imageUrl) && background.type === "image" ? `url(${background.resource.image_url || background.resource.imageUrl})` : "none";
80
+ const { data = [], isLoading, isError } = useCatchUps();
81
+ const catchUpsToShow = data.slice(0, maxItems);
82
+ const moreCatchUps = data.length - catchUpsToShow.length;
83
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
84
+ className: `flex flex-col rounded-${borderRadius} bg-${backgroundColor} p-${padding} text-${textColor} ${className || ""}`,
85
+ style: { backgroundImage },
86
+ ...props,
87
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
88
+ className: "flex items-center justify-between",
89
+ children: [titleEnabled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
90
+ className: `${fontSizeClasses[titleFontSize]} font-semibold text-${titleColor}`,
91
+ children: titleText
92
+ }), !isLoading && !isError && data.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
93
+ className: `text-3xl font-bold text-${accentColor}`,
94
+ children: data.length
95
+ })]
96
+ }), isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
97
+ className: "flex min-h-[150px] flex-1 items-center justify-center",
98
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fortawesome_react_fontawesome.FontAwesomeIcon, {
99
+ icon: _fortawesome_pro_regular_svg_icons.faSpinnerThird,
100
+ spin: true,
101
+ className: `h-8 w-8 text-${accentColor}`
102
+ })
103
+ }) : isError ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_error_state.ErrorState, {}) : data.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
104
+ className: "flex min-h-[150px] flex-1 flex-col items-center justify-center gap-2",
105
+ children: [
106
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fortawesome_react_fontawesome.FontAwesomeIcon, {
107
+ icon: _fortawesome_pro_regular_svg_icons.faSparkles,
108
+ className: `h-8 w-8 text-${accentColor}`
109
+ }),
110
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
111
+ className: "text-center font-semibold",
112
+ children: "You're all caught up."
113
+ }),
114
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
115
+ className: "text-sm opacity-60",
116
+ children: "See you next time!"
117
+ })
118
+ ]
119
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
120
+ className: "mt-3 flex-1",
121
+ children: catchUpsToShow.map((catchUp, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
122
+ className: `py-2 ${index !== catchUpsToShow.length - 1 ? "border-b border-current/10" : ""}`,
123
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
124
+ className: "line-clamp-1 text-sm",
125
+ children: catchUp.suggestion_title
126
+ })
127
+ }, catchUp.id || index))
128
+ }), moreCatchUps > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
129
+ className: "mt-2 text-sm opacity-60",
130
+ children: [
131
+ moreCatchUps,
132
+ " more catch up",
133
+ moreCatchUps > 1 ? "s" : ""
134
+ ]
135
+ })] })]
136
+ });
137
+ }
138
+ const catchUpWidgetPropertySchema = {
139
+ widgetType: "CatchUpWidget",
140
+ displayName: "Catch Up Widget",
141
+ tabsConfig: [{
142
+ id: "styling",
143
+ label: "Styling"
144
+ }],
145
+ fields: [
146
+ {
147
+ key: "titleEnabled",
148
+ label: "Widget Title",
149
+ type: "boolean",
150
+ description: "Enable the title displayed above the catch ups",
151
+ defaultValue: true,
152
+ tab: "styling",
153
+ group: "Title"
154
+ },
155
+ {
156
+ key: "titleText",
157
+ label: "Title",
158
+ type: "text",
159
+ description: "Title text displayed above the catch ups",
160
+ defaultValue: "Catch Ups",
161
+ tab: "styling",
162
+ group: "Title",
163
+ requiresKeyToBeTrue: "titleEnabled"
164
+ },
165
+ (0, _fluid_app_portal_core_registries.getFontSizeField)({
166
+ key: "titleFontSize",
167
+ label: "Title Font Size",
168
+ description: "Font size for the widget title",
169
+ defaultValue: "xl",
170
+ tab: "styling",
171
+ group: "Title",
172
+ requiresKeyToBeTrue: "titleEnabled"
173
+ }),
174
+ (0, _fluid_app_portal_core_registries.getColorField)({
175
+ key: "titleColor",
176
+ label: "Title Color",
177
+ description: "Color for the widget title",
178
+ defaultValue: "foreground",
179
+ tab: "styling",
180
+ group: "Title",
181
+ requiresKeyToBeTrue: "titleEnabled"
182
+ }),
183
+ {
184
+ type: "background",
185
+ key: "background",
186
+ label: "Background",
187
+ description: "Background for the container",
188
+ defaultValue: "background",
189
+ tab: "styling",
190
+ group: "Design"
191
+ },
192
+ (0, _fluid_app_portal_core_registries.getColorField)({
193
+ key: "textColor",
194
+ label: "Text Color",
195
+ description: "Default text color for catch up items",
196
+ defaultValue: "foreground",
197
+ tab: "styling",
198
+ group: "Design"
199
+ }),
200
+ (0, _fluid_app_portal_core_registries.getColorField)({
201
+ key: "accentColor",
202
+ label: "Accent Color",
203
+ description: "Color used for count display and icons",
204
+ defaultValue: "primary",
205
+ tab: "styling",
206
+ group: "Design"
207
+ }),
208
+ {
209
+ key: "separator",
210
+ type: "separator",
211
+ label: "Separator",
212
+ tab: "styling",
213
+ group: "Design"
214
+ },
215
+ {
216
+ key: "maxItems",
217
+ label: "Max Items",
218
+ type: "number",
219
+ description: "Maximum number of catch ups to display",
220
+ defaultValue: 5,
221
+ min: 1,
222
+ max: 10,
223
+ tab: "styling",
224
+ group: "Design"
225
+ },
226
+ (0, _fluid_app_portal_core_registries.getPaddingField)({
227
+ key: "padding",
228
+ label: "Padding",
229
+ description: "Padding around the container",
230
+ defaultValue: 4,
231
+ tab: "styling",
232
+ group: "Design"
233
+ }),
234
+ (0, _fluid_app_portal_core_registries.getBorderRadiusField)({
235
+ key: "borderRadius",
236
+ label: "Border Radius",
237
+ description: "Border radius for the container",
238
+ defaultValue: "md",
239
+ tab: "styling",
240
+ group: "Design"
241
+ })
242
+ ]
243
+ };
244
+ //#endregion
245
+ Object.defineProperty(exports, "CatchUpWidget", {
246
+ enumerable: true,
247
+ get: function() {
248
+ return CatchUpWidget;
249
+ }
250
+ });
251
+ Object.defineProperty(exports, "CatchUpWidget_exports", {
252
+ enumerable: true,
253
+ get: function() {
254
+ return CatchUpWidget_exports;
255
+ }
256
+ });
257
+ Object.defineProperty(exports, "catchUpWidgetPropertySchema", {
258
+ enumerable: true,
259
+ get: function() {
260
+ return catchUpWidgetPropertySchema;
261
+ }
262
+ });
263
+
264
+ //# sourceMappingURL=CatchUpWidget-CZMptzf8.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CatchUpWidget-CZMptzf8.cjs","names":["FontAwesomeIcon","faSpinnerThird","ErrorState","faSparkles"],"sources":["../src/hooks/use-catchups.preview.ts","../src/hooks/use-catchups.ts","../src/widgets/CatchUpWidget.tsx"],"sourcesContent":["import type { CatchUp } from \"./use-catchups.types\";\n\nexport const PREVIEW_DATA: CatchUp[] = [\n { id: 1, suggestion_title: \"Check in with Sarah about her recent order\" },\n { id: 2, suggestion_title: \"Follow up with Mike on product samples\" },\n { id: 3, suggestion_title: \"Reconnect with Lisa — last contact 30 days ago\" },\n { id: 4, suggestion_title: \"Thank Alex for their referral last week\" },\n { id: 5, suggestion_title: \"Share new catalog with Jordan\" },\n];\n","import { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useDataSourceConfig } from \"@fluid-app/portal-core/data-sources/context\";\nimport { useWidgetPreviewContext } from \"@fluid-app/portal-core/data-sources/preview-context\";\nimport { PREVIEW_DATA } from \"./use-catchups.preview\";\n\nimport type { CatchUp } from \"./use-catchups.types\";\n\nexport type { CatchUp } from \"./use-catchups.types\";\n\nexport function useCatchUps(): UseQueryResult<CatchUp[], Error> {\n const { baseUrl, getApiHeaders } = useDataSourceConfig();\n const { isPreview } = useWidgetPreviewContext();\n\n return useQuery({\n queryKey: [\n \"portal-widget-use\",\n \"catchups\",\n isPreview ? \"preview\" : baseUrl,\n ] as const,\n queryFn: async ({ signal }): Promise<CatchUp[]> => {\n const url = baseUrl\n ? `${baseUrl}/affiliate_catch_up_actions.json`\n : \"/affiliate_catch_up_actions.json\";\n const response = await fetch(url, {\n headers: {\n \"content-type\": \"application/json\",\n ...getApiHeaders?.(),\n },\n signal,\n });\n\n if (!response.ok) {\n throw new Error(`Failed to fetch catch ups: ${response.status}`);\n }\n\n return response.json();\n },\n enabled: !isPreview,\n ...(isPreview && { placeholderData: PREVIEW_DATA }),\n });\n}\n","import type { ComponentProps } from \"react\";\nimport type React from \"react\";\nimport type {\n BackgroundValue,\n BorderRadiusOptions,\n ColorOptions,\n FontSizeOptions,\n PaddingOptions,\n} from \"@fluid-app/portal-core/types\";\nimport type { WidgetPropertySchema } from \"@fluid-app/portal-core/registries\";\nimport {\n getBorderRadiusField,\n getColorField,\n getFontSizeField,\n getPaddingField,\n} from \"../core/fields\";\nimport { useCatchUps } from \"../hooks/use-catchups\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport { faSpinnerThird, faSparkles } from \"@fortawesome/pro-regular-svg-icons\";\nimport { ErrorState } from \"../components/error-state\";\n\n// Font size mapping for title\nconst fontSizeClasses: Record<FontSizeOptions, string> = {\n \"2xl\": \"text-2xl\",\n xl: \"text-xl\",\n lg: \"text-lg\",\n md: \"text-base\",\n sm: \"text-sm\",\n xs: \"text-xs\",\n};\n\ntype CatchUpWidgetProps = ComponentProps<\"div\"> & {\n // Title settings\n titleEnabled?: boolean;\n titleText?: string;\n titleFontSize?: FontSizeOptions;\n titleColor?: ColorOptions;\n // Design settings\n background?: BackgroundValue;\n textColor?: ColorOptions;\n accentColor?: ColorOptions;\n padding?: PaddingOptions;\n borderRadius?: BorderRadiusOptions;\n // Display settings\n maxItems?: number;\n};\n\nexport function CatchUpWidget({\n // Title settings with defaults\n titleEnabled = true,\n titleText = \"Catch Ups\",\n titleFontSize = \"xl\",\n titleColor = \"foreground\",\n // Design settings with defaults\n background = {\n type: \"solid\",\n color: \"background\",\n },\n textColor = \"foreground\",\n accentColor = \"primary\",\n padding = 4,\n borderRadius = \"md\",\n // Display settings with defaults\n maxItems = 5,\n className,\n ...props\n}: CatchUpWidgetProps): React.JSX.Element {\n const backgroundColor = background.color || \"background\";\n const backgroundImage =\n (background.resource?.image_url || background.resource?.imageUrl) &&\n background.type === \"image\"\n ? `url(${background.resource.image_url || background.resource.imageUrl})`\n : \"none\";\n const { data = [], isLoading, isError } = useCatchUps();\n\n const catchUpsToShow = data.slice(0, maxItems);\n const moreCatchUps = data.length - catchUpsToShow.length;\n\n return (\n <div\n className={`flex flex-col rounded-${borderRadius} bg-${backgroundColor} p-${padding} text-${textColor} ${className || \"\"}`}\n style={{ backgroundImage }}\n {...props}\n >\n {/* Header */}\n <div className=\"flex items-center justify-between\">\n {titleEnabled && (\n <h3\n className={`${fontSizeClasses[titleFontSize]} font-semibold text-${titleColor}`}\n >\n {titleText}\n </h3>\n )}\n {!isLoading && !isError && data.length > 0 && (\n <span className={`text-3xl font-bold text-${accentColor}`}>\n {data.length}\n </span>\n )}\n </div>\n\n {/* Loading state */}\n {isLoading ? (\n <div className=\"flex min-h-[150px] flex-1 items-center justify-center\">\n <FontAwesomeIcon\n icon={faSpinnerThird}\n spin\n className={`h-8 w-8 text-${accentColor}`}\n />\n </div>\n ) : isError ? (\n /* Error state */\n <ErrorState />\n ) : data.length === 0 ? (\n /* Empty state */\n <div className=\"flex min-h-[150px] flex-1 flex-col items-center justify-center gap-2\">\n <FontAwesomeIcon\n icon={faSparkles}\n className={`h-8 w-8 text-${accentColor}`}\n />\n <p className=\"text-center font-semibold\">\n You&apos;re all caught up.\n </p>\n <p className=\"text-sm opacity-60\">See you next time!</p>\n </div>\n ) : (\n /* Default state with catch ups */\n <>\n <div className=\"mt-3 flex-1\">\n {catchUpsToShow.map((catchUp, index: number) => (\n <div\n key={catchUp.id || index}\n className={`py-2 ${index !== catchUpsToShow.length - 1 ? \"border-b border-current/10\" : \"\"}`}\n >\n <p className=\"line-clamp-1 text-sm\">\n {catchUp.suggestion_title}\n </p>\n </div>\n ))}\n </div>\n\n {/* More indicator */}\n {moreCatchUps > 0 && (\n <p className=\"mt-2 text-sm opacity-60\">\n {moreCatchUps} more catch up{moreCatchUps > 1 ? \"s\" : \"\"}\n </p>\n )}\n </>\n )}\n </div>\n );\n}\n\n// Property schema for the widget editor\nexport const catchUpWidgetPropertySchema: WidgetPropertySchema = {\n widgetType: \"CatchUpWidget\",\n displayName: \"Catch Up Widget\",\n tabsConfig: [{ id: \"styling\", label: \"Styling\" }],\n fields: [\n // Styling Tab - Title Group\n {\n key: \"titleEnabled\",\n label: \"Widget Title\",\n type: \"boolean\",\n description: \"Enable the title displayed above the catch ups\",\n defaultValue: true,\n tab: \"styling\",\n group: \"Title\",\n },\n {\n key: \"titleText\",\n label: \"Title\",\n type: \"text\",\n description: \"Title text displayed above the catch ups\",\n defaultValue: \"Catch Ups\",\n tab: \"styling\",\n group: \"Title\",\n requiresKeyToBeTrue: \"titleEnabled\",\n },\n getFontSizeField({\n key: \"titleFontSize\",\n label: \"Title Font Size\",\n description: \"Font size for the widget title\",\n defaultValue: \"xl\",\n tab: \"styling\",\n group: \"Title\",\n requiresKeyToBeTrue: \"titleEnabled\",\n }),\n getColorField({\n key: \"titleColor\",\n label: \"Title Color\",\n description: \"Color for the widget title\",\n defaultValue: \"foreground\",\n tab: \"styling\",\n group: \"Title\",\n requiresKeyToBeTrue: \"titleEnabled\",\n }),\n\n // Styling Tab - Design Group\n {\n type: \"background\",\n key: \"background\",\n label: \"Background\",\n description: \"Background for the container\",\n defaultValue: \"background\",\n tab: \"styling\",\n group: \"Design\",\n },\n getColorField({\n key: \"textColor\",\n label: \"Text Color\",\n description: \"Default text color for catch up items\",\n defaultValue: \"foreground\",\n tab: \"styling\",\n group: \"Design\",\n }),\n getColorField({\n key: \"accentColor\",\n label: \"Accent Color\",\n description: \"Color used for count display and icons\",\n defaultValue: \"primary\",\n tab: \"styling\",\n group: \"Design\",\n }),\n {\n key: \"separator\",\n type: \"separator\",\n label: \"Separator\",\n tab: \"styling\",\n group: \"Design\",\n },\n {\n key: \"maxItems\",\n label: \"Max Items\",\n type: \"number\",\n description: \"Maximum number of catch ups to display\",\n defaultValue: 5,\n min: 1,\n max: 10,\n tab: \"styling\",\n group: \"Design\",\n },\n getPaddingField({\n key: \"padding\",\n label: \"Padding\",\n description: \"Padding around the container\",\n defaultValue: 4,\n tab: \"styling\",\n group: \"Design\",\n }),\n getBorderRadiusField({\n key: \"borderRadius\",\n label: \"Border Radius\",\n description: \"Border radius for the container\",\n defaultValue: \"md\",\n tab: \"styling\",\n group: \"Design\",\n }),\n ],\n} as const satisfies WidgetPropertySchema;\n"],"mappings":";;;;;;;;;;AAEA,MAAa,eAA0B;CACrC;EAAE,IAAI;EAAG,kBAAkB;EAA8C;CACzE;EAAE,IAAI;EAAG,kBAAkB;EAA0C;CACrE;EAAE,IAAI;EAAG,kBAAkB;EAAkD;CAC7E;EAAE,IAAI;EAAG,kBAAkB;EAA2C;CACtE;EAAE,IAAI;EAAG,kBAAkB;EAAiC;CAC7D;;;ACCD,SAAgB,cAAgD;CAC9D,MAAM,EAAE,SAAS,mBAAA,GAAA,4CAAA,sBAAuC;CACxD,MAAM,EAAE,eAAA,GAAA,oDAAA,0BAAuC;AAE/C,SAAA,GAAA,sBAAA,UAAgB;EACd,UAAU;GACR;GACA;GACA,YAAY,YAAY;GACzB;EACD,SAAS,OAAO,EAAE,aAAiC;GACjD,MAAM,MAAM,UACR,GAAG,QAAQ,oCACX;GACJ,MAAM,WAAW,MAAM,MAAM,KAAK;IAChC,SAAS;KACP,gBAAgB;KAChB,GAAG,iBAAiB;KACrB;IACD;IACD,CAAC;AAEF,OAAI,CAAC,SAAS,GACZ,OAAM,IAAI,MAAM,8BAA8B,SAAS,SAAS;AAGlE,UAAO,SAAS,MAA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,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACP,qBAAqB;GACtB,CAAC;uDACY;GACZ,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACP,qBAAqB;GACtB,CAAC;EAGF;GACE,MAAM;GACN,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR;uDACa;GACZ,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR,CAAC;uDACY;GACZ,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR,CAAC;EACF;GACE,KAAK;GACL,MAAM;GACN,OAAO;GACP,KAAK;GACL,OAAO;GACR;EACD;GACE,KAAK;GACL,OAAO;GACP,MAAM;GACN,aAAa;GACb,cAAc;GACd,KAAK;GACL,KAAK;GACL,KAAK;GACL,OAAO;GACR;yDACe;GACd,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR,CAAC;8DACmB;GACnB,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR,CAAC;EACH;CACF"}
@@ -0,0 +1,247 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-wcPFST8Q.mjs";
2
+ import { a as getFontSizeField, c as getPaddingField, i as getColorField, n as getBorderRadiusField } from "./fields-wPOk-SmZ.mjs";
3
+ import { t as ErrorState } from "./error-state-DErSxZwH.mjs";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ import { useQuery } from "@tanstack/react-query";
6
+ import { useDataSourceConfig } from "@fluid-app/portal-core/data-sources/context";
7
+ import { useWidgetPreviewContext } from "@fluid-app/portal-core/data-sources/preview-context";
8
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
9
+ import { faSparkles, faSpinnerThird } from "@fortawesome/pro-regular-svg-icons";
10
+ //#region src/hooks/use-catchups.preview.ts
11
+ const PREVIEW_DATA = [
12
+ {
13
+ id: 1,
14
+ suggestion_title: "Check in with Sarah about her recent order"
15
+ },
16
+ {
17
+ id: 2,
18
+ suggestion_title: "Follow up with Mike on product samples"
19
+ },
20
+ {
21
+ id: 3,
22
+ suggestion_title: "Reconnect with Lisa — last contact 30 days ago"
23
+ },
24
+ {
25
+ id: 4,
26
+ suggestion_title: "Thank Alex for their referral last week"
27
+ },
28
+ {
29
+ id: 5,
30
+ suggestion_title: "Share new catalog with Jordan"
31
+ }
32
+ ];
33
+ //#endregion
34
+ //#region src/hooks/use-catchups.ts
35
+ function useCatchUps() {
36
+ const { baseUrl, getApiHeaders } = useDataSourceConfig();
37
+ const { isPreview } = useWidgetPreviewContext();
38
+ return useQuery({
39
+ queryKey: [
40
+ "portal-widget-use",
41
+ "catchups",
42
+ isPreview ? "preview" : baseUrl
43
+ ],
44
+ queryFn: async ({ signal }) => {
45
+ const url = baseUrl ? `${baseUrl}/affiliate_catch_up_actions.json` : "/affiliate_catch_up_actions.json";
46
+ const response = await fetch(url, {
47
+ headers: {
48
+ "content-type": "application/json",
49
+ ...getApiHeaders?.()
50
+ },
51
+ signal
52
+ });
53
+ if (!response.ok) throw new Error(`Failed to fetch catch ups: ${response.status}`);
54
+ return response.json();
55
+ },
56
+ enabled: !isPreview,
57
+ ...isPreview && { placeholderData: PREVIEW_DATA }
58
+ });
59
+ }
60
+ //#endregion
61
+ //#region src/widgets/CatchUpWidget.tsx
62
+ var CatchUpWidget_exports = /* @__PURE__ */ __exportAll({
63
+ CatchUpWidget: () => CatchUpWidget,
64
+ catchUpWidgetPropertySchema: () => catchUpWidgetPropertySchema
65
+ });
66
+ const fontSizeClasses = {
67
+ "2xl": "text-2xl",
68
+ xl: "text-xl",
69
+ lg: "text-lg",
70
+ md: "text-base",
71
+ sm: "text-sm",
72
+ xs: "text-xs"
73
+ };
74
+ function CatchUpWidget({ titleEnabled = true, titleText = "Catch Ups", titleFontSize = "xl", titleColor = "foreground", background = {
75
+ type: "solid",
76
+ color: "background"
77
+ }, textColor = "foreground", accentColor = "primary", padding = 4, borderRadius = "md", maxItems = 5, className, ...props }) {
78
+ const backgroundColor = background.color || "background";
79
+ const backgroundImage = (background.resource?.image_url || background.resource?.imageUrl) && background.type === "image" ? `url(${background.resource.image_url || background.resource.imageUrl})` : "none";
80
+ const { data = [], isLoading, isError } = useCatchUps();
81
+ const catchUpsToShow = data.slice(0, maxItems);
82
+ const moreCatchUps = data.length - catchUpsToShow.length;
83
+ return /* @__PURE__ */ jsxs("div", {
84
+ className: `flex flex-col rounded-${borderRadius} bg-${backgroundColor} p-${padding} text-${textColor} ${className || ""}`,
85
+ style: { backgroundImage },
86
+ ...props,
87
+ children: [/* @__PURE__ */ jsxs("div", {
88
+ className: "flex items-center justify-between",
89
+ children: [titleEnabled && /* @__PURE__ */ jsx("h3", {
90
+ className: `${fontSizeClasses[titleFontSize]} font-semibold text-${titleColor}`,
91
+ children: titleText
92
+ }), !isLoading && !isError && data.length > 0 && /* @__PURE__ */ jsx("span", {
93
+ className: `text-3xl font-bold text-${accentColor}`,
94
+ children: data.length
95
+ })]
96
+ }), isLoading ? /* @__PURE__ */ jsx("div", {
97
+ className: "flex min-h-[150px] flex-1 items-center justify-center",
98
+ children: /* @__PURE__ */ jsx(FontAwesomeIcon, {
99
+ icon: faSpinnerThird,
100
+ spin: true,
101
+ className: `h-8 w-8 text-${accentColor}`
102
+ })
103
+ }) : isError ? /* @__PURE__ */ jsx(ErrorState, {}) : data.length === 0 ? /* @__PURE__ */ jsxs("div", {
104
+ className: "flex min-h-[150px] flex-1 flex-col items-center justify-center gap-2",
105
+ children: [
106
+ /* @__PURE__ */ jsx(FontAwesomeIcon, {
107
+ icon: faSparkles,
108
+ className: `h-8 w-8 text-${accentColor}`
109
+ }),
110
+ /* @__PURE__ */ jsx("p", {
111
+ className: "text-center font-semibold",
112
+ children: "You're all caught up."
113
+ }),
114
+ /* @__PURE__ */ jsx("p", {
115
+ className: "text-sm opacity-60",
116
+ children: "See you next time!"
117
+ })
118
+ ]
119
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
120
+ className: "mt-3 flex-1",
121
+ children: catchUpsToShow.map((catchUp, index) => /* @__PURE__ */ jsx("div", {
122
+ className: `py-2 ${index !== catchUpsToShow.length - 1 ? "border-b border-current/10" : ""}`,
123
+ children: /* @__PURE__ */ jsx("p", {
124
+ className: "line-clamp-1 text-sm",
125
+ children: catchUp.suggestion_title
126
+ })
127
+ }, catchUp.id || index))
128
+ }), moreCatchUps > 0 && /* @__PURE__ */ jsxs("p", {
129
+ className: "mt-2 text-sm opacity-60",
130
+ children: [
131
+ moreCatchUps,
132
+ " more catch up",
133
+ moreCatchUps > 1 ? "s" : ""
134
+ ]
135
+ })] })]
136
+ });
137
+ }
138
+ const catchUpWidgetPropertySchema = {
139
+ widgetType: "CatchUpWidget",
140
+ displayName: "Catch Up Widget",
141
+ tabsConfig: [{
142
+ id: "styling",
143
+ label: "Styling"
144
+ }],
145
+ fields: [
146
+ {
147
+ key: "titleEnabled",
148
+ label: "Widget Title",
149
+ type: "boolean",
150
+ description: "Enable the title displayed above the catch ups",
151
+ defaultValue: true,
152
+ tab: "styling",
153
+ group: "Title"
154
+ },
155
+ {
156
+ key: "titleText",
157
+ label: "Title",
158
+ type: "text",
159
+ description: "Title text displayed above the catch ups",
160
+ defaultValue: "Catch Ups",
161
+ tab: "styling",
162
+ group: "Title",
163
+ requiresKeyToBeTrue: "titleEnabled"
164
+ },
165
+ getFontSizeField({
166
+ key: "titleFontSize",
167
+ label: "Title Font Size",
168
+ description: "Font size for the widget title",
169
+ defaultValue: "xl",
170
+ tab: "styling",
171
+ group: "Title",
172
+ requiresKeyToBeTrue: "titleEnabled"
173
+ }),
174
+ getColorField({
175
+ key: "titleColor",
176
+ label: "Title Color",
177
+ description: "Color for the widget title",
178
+ defaultValue: "foreground",
179
+ tab: "styling",
180
+ group: "Title",
181
+ requiresKeyToBeTrue: "titleEnabled"
182
+ }),
183
+ {
184
+ type: "background",
185
+ key: "background",
186
+ label: "Background",
187
+ description: "Background for the container",
188
+ defaultValue: "background",
189
+ tab: "styling",
190
+ group: "Design"
191
+ },
192
+ getColorField({
193
+ key: "textColor",
194
+ label: "Text Color",
195
+ description: "Default text color for catch up items",
196
+ defaultValue: "foreground",
197
+ tab: "styling",
198
+ group: "Design"
199
+ }),
200
+ getColorField({
201
+ key: "accentColor",
202
+ label: "Accent Color",
203
+ description: "Color used for count display and icons",
204
+ defaultValue: "primary",
205
+ tab: "styling",
206
+ group: "Design"
207
+ }),
208
+ {
209
+ key: "separator",
210
+ type: "separator",
211
+ label: "Separator",
212
+ tab: "styling",
213
+ group: "Design"
214
+ },
215
+ {
216
+ key: "maxItems",
217
+ label: "Max Items",
218
+ type: "number",
219
+ description: "Maximum number of catch ups to display",
220
+ defaultValue: 5,
221
+ min: 1,
222
+ max: 10,
223
+ tab: "styling",
224
+ group: "Design"
225
+ },
226
+ getPaddingField({
227
+ key: "padding",
228
+ label: "Padding",
229
+ description: "Padding around the container",
230
+ defaultValue: 4,
231
+ tab: "styling",
232
+ group: "Design"
233
+ }),
234
+ getBorderRadiusField({
235
+ key: "borderRadius",
236
+ label: "Border Radius",
237
+ description: "Border radius for the container",
238
+ defaultValue: "md",
239
+ tab: "styling",
240
+ group: "Design"
241
+ })
242
+ ]
243
+ };
244
+ //#endregion
245
+ export { CatchUpWidget_exports as n, catchUpWidgetPropertySchema as r, CatchUpWidget as t };
246
+
247
+ //# sourceMappingURL=CatchUpWidget-vEP5scfy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CatchUpWidget-vEP5scfy.mjs","names":[],"sources":["../src/hooks/use-catchups.preview.ts","../src/hooks/use-catchups.ts","../src/widgets/CatchUpWidget.tsx"],"sourcesContent":["import type { CatchUp } from \"./use-catchups.types\";\n\nexport const PREVIEW_DATA: CatchUp[] = [\n { id: 1, suggestion_title: \"Check in with Sarah about her recent order\" },\n { id: 2, suggestion_title: \"Follow up with Mike on product samples\" },\n { id: 3, suggestion_title: \"Reconnect with Lisa — last contact 30 days ago\" },\n { id: 4, suggestion_title: \"Thank Alex for their referral last week\" },\n { id: 5, suggestion_title: \"Share new catalog with Jordan\" },\n];\n","import { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useDataSourceConfig } from \"@fluid-app/portal-core/data-sources/context\";\nimport { useWidgetPreviewContext } from \"@fluid-app/portal-core/data-sources/preview-context\";\nimport { PREVIEW_DATA } from \"./use-catchups.preview\";\n\nimport type { CatchUp } from \"./use-catchups.types\";\n\nexport type { CatchUp } from \"./use-catchups.types\";\n\nexport function useCatchUps(): UseQueryResult<CatchUp[], Error> {\n const { baseUrl, getApiHeaders } = useDataSourceConfig();\n const { isPreview } = useWidgetPreviewContext();\n\n return useQuery({\n queryKey: [\n \"portal-widget-use\",\n \"catchups\",\n isPreview ? \"preview\" : baseUrl,\n ] as const,\n queryFn: async ({ signal }): Promise<CatchUp[]> => {\n const url = baseUrl\n ? `${baseUrl}/affiliate_catch_up_actions.json`\n : \"/affiliate_catch_up_actions.json\";\n const response = await fetch(url, {\n headers: {\n \"content-type\": \"application/json\",\n ...getApiHeaders?.(),\n },\n signal,\n });\n\n if (!response.ok) {\n throw new Error(`Failed to fetch catch ups: ${response.status}`);\n }\n\n return response.json();\n },\n enabled: !isPreview,\n ...(isPreview && { placeholderData: PREVIEW_DATA }),\n });\n}\n","import type { ComponentProps } from \"react\";\nimport type React from \"react\";\nimport type {\n BackgroundValue,\n BorderRadiusOptions,\n ColorOptions,\n FontSizeOptions,\n PaddingOptions,\n} from \"@fluid-app/portal-core/types\";\nimport type { WidgetPropertySchema } from \"@fluid-app/portal-core/registries\";\nimport {\n getBorderRadiusField,\n getColorField,\n getFontSizeField,\n getPaddingField,\n} from \"../core/fields\";\nimport { useCatchUps } from \"../hooks/use-catchups\";\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\nimport { faSpinnerThird, faSparkles } from \"@fortawesome/pro-regular-svg-icons\";\nimport { ErrorState } from \"../components/error-state\";\n\n// Font size mapping for title\nconst fontSizeClasses: Record<FontSizeOptions, string> = {\n \"2xl\": \"text-2xl\",\n xl: \"text-xl\",\n lg: \"text-lg\",\n md: \"text-base\",\n sm: \"text-sm\",\n xs: \"text-xs\",\n};\n\ntype CatchUpWidgetProps = ComponentProps<\"div\"> & {\n // Title settings\n titleEnabled?: boolean;\n titleText?: string;\n titleFontSize?: FontSizeOptions;\n titleColor?: ColorOptions;\n // Design settings\n background?: BackgroundValue;\n textColor?: ColorOptions;\n accentColor?: ColorOptions;\n padding?: PaddingOptions;\n borderRadius?: BorderRadiusOptions;\n // Display settings\n maxItems?: number;\n};\n\nexport function CatchUpWidget({\n // Title settings with defaults\n titleEnabled = true,\n titleText = \"Catch Ups\",\n titleFontSize = \"xl\",\n titleColor = \"foreground\",\n // Design settings with defaults\n background = {\n type: \"solid\",\n color: \"background\",\n },\n textColor = \"foreground\",\n accentColor = \"primary\",\n padding = 4,\n borderRadius = \"md\",\n // Display settings with defaults\n maxItems = 5,\n className,\n ...props\n}: CatchUpWidgetProps): React.JSX.Element {\n const backgroundColor = background.color || \"background\";\n const backgroundImage =\n (background.resource?.image_url || background.resource?.imageUrl) &&\n background.type === \"image\"\n ? `url(${background.resource.image_url || background.resource.imageUrl})`\n : \"none\";\n const { data = [], isLoading, isError } = useCatchUps();\n\n const catchUpsToShow = data.slice(0, maxItems);\n const moreCatchUps = data.length - catchUpsToShow.length;\n\n return (\n <div\n className={`flex flex-col rounded-${borderRadius} bg-${backgroundColor} p-${padding} text-${textColor} ${className || \"\"}`}\n style={{ backgroundImage }}\n {...props}\n >\n {/* Header */}\n <div className=\"flex items-center justify-between\">\n {titleEnabled && (\n <h3\n className={`${fontSizeClasses[titleFontSize]} font-semibold text-${titleColor}`}\n >\n {titleText}\n </h3>\n )}\n {!isLoading && !isError && data.length > 0 && (\n <span className={`text-3xl font-bold text-${accentColor}`}>\n {data.length}\n </span>\n )}\n </div>\n\n {/* Loading state */}\n {isLoading ? (\n <div className=\"flex min-h-[150px] flex-1 items-center justify-center\">\n <FontAwesomeIcon\n icon={faSpinnerThird}\n spin\n className={`h-8 w-8 text-${accentColor}`}\n />\n </div>\n ) : isError ? (\n /* Error state */\n <ErrorState />\n ) : data.length === 0 ? (\n /* Empty state */\n <div className=\"flex min-h-[150px] flex-1 flex-col items-center justify-center gap-2\">\n <FontAwesomeIcon\n icon={faSparkles}\n className={`h-8 w-8 text-${accentColor}`}\n />\n <p className=\"text-center font-semibold\">\n You&apos;re all caught up.\n </p>\n <p className=\"text-sm opacity-60\">See you next time!</p>\n </div>\n ) : (\n /* Default state with catch ups */\n <>\n <div className=\"mt-3 flex-1\">\n {catchUpsToShow.map((catchUp, index: number) => (\n <div\n key={catchUp.id || index}\n className={`py-2 ${index !== catchUpsToShow.length - 1 ? \"border-b border-current/10\" : \"\"}`}\n >\n <p className=\"line-clamp-1 text-sm\">\n {catchUp.suggestion_title}\n </p>\n </div>\n ))}\n </div>\n\n {/* More indicator */}\n {moreCatchUps > 0 && (\n <p className=\"mt-2 text-sm opacity-60\">\n {moreCatchUps} more catch up{moreCatchUps > 1 ? \"s\" : \"\"}\n </p>\n )}\n </>\n )}\n </div>\n );\n}\n\n// Property schema for the widget editor\nexport const catchUpWidgetPropertySchema: WidgetPropertySchema = {\n widgetType: \"CatchUpWidget\",\n displayName: \"Catch Up Widget\",\n tabsConfig: [{ id: \"styling\", label: \"Styling\" }],\n fields: [\n // Styling Tab - Title Group\n {\n key: \"titleEnabled\",\n label: \"Widget Title\",\n type: \"boolean\",\n description: \"Enable the title displayed above the catch ups\",\n defaultValue: true,\n tab: \"styling\",\n group: \"Title\",\n },\n {\n key: \"titleText\",\n label: \"Title\",\n type: \"text\",\n description: \"Title text displayed above the catch ups\",\n defaultValue: \"Catch Ups\",\n tab: \"styling\",\n group: \"Title\",\n requiresKeyToBeTrue: \"titleEnabled\",\n },\n getFontSizeField({\n key: \"titleFontSize\",\n label: \"Title Font Size\",\n description: \"Font size for the widget title\",\n defaultValue: \"xl\",\n tab: \"styling\",\n group: \"Title\",\n requiresKeyToBeTrue: \"titleEnabled\",\n }),\n getColorField({\n key: \"titleColor\",\n label: \"Title Color\",\n description: \"Color for the widget title\",\n defaultValue: \"foreground\",\n tab: \"styling\",\n group: \"Title\",\n requiresKeyToBeTrue: \"titleEnabled\",\n }),\n\n // Styling Tab - Design Group\n {\n type: \"background\",\n key: \"background\",\n label: \"Background\",\n description: \"Background for the container\",\n defaultValue: \"background\",\n tab: \"styling\",\n group: \"Design\",\n },\n getColorField({\n key: \"textColor\",\n label: \"Text Color\",\n description: \"Default text color for catch up items\",\n defaultValue: \"foreground\",\n tab: \"styling\",\n group: \"Design\",\n }),\n getColorField({\n key: \"accentColor\",\n label: \"Accent Color\",\n description: \"Color used for count display and icons\",\n defaultValue: \"primary\",\n tab: \"styling\",\n group: \"Design\",\n }),\n {\n key: \"separator\",\n type: \"separator\",\n label: \"Separator\",\n tab: \"styling\",\n group: \"Design\",\n },\n {\n key: \"maxItems\",\n label: \"Max Items\",\n type: \"number\",\n description: \"Maximum number of catch ups to display\",\n defaultValue: 5,\n min: 1,\n max: 10,\n tab: \"styling\",\n group: \"Design\",\n },\n getPaddingField({\n key: \"padding\",\n label: \"Padding\",\n description: \"Padding around the container\",\n defaultValue: 4,\n tab: \"styling\",\n group: \"Design\",\n }),\n getBorderRadiusField({\n key: \"borderRadius\",\n label: \"Border Radius\",\n description: \"Border radius for the container\",\n defaultValue: \"md\",\n tab: \"styling\",\n group: \"Design\",\n }),\n ],\n} as const satisfies WidgetPropertySchema;\n"],"mappings":";;;;;;;;;;AAEA,MAAa,eAA0B;CACrC;EAAE,IAAI;EAAG,kBAAkB;EAA8C;CACzE;EAAE,IAAI;EAAG,kBAAkB;EAA0C;CACrE;EAAE,IAAI;EAAG,kBAAkB;EAAkD;CAC7E;EAAE,IAAI;EAAG,kBAAkB;EAA2C;CACtE;E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