@fluid-app/portal-core 0.1.16

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 (195) hide show
  1. package/dist/chunk-CKQMccvm.cjs +28 -0
  2. package/dist/data-sources/DataAwareWidget.cjs +50 -0
  3. package/dist/data-sources/DataAwareWidget.cjs.map +1 -0
  4. package/dist/data-sources/DataAwareWidget.d.cts +24 -0
  5. package/dist/data-sources/DataAwareWidget.d.cts.map +1 -0
  6. package/dist/data-sources/DataAwareWidget.d.mts +24 -0
  7. package/dist/data-sources/DataAwareWidget.d.mts.map +1 -0
  8. package/dist/data-sources/DataAwareWidget.mjs +48 -0
  9. package/dist/data-sources/DataAwareWidget.mjs.map +1 -0
  10. package/dist/data-sources/ErrorState.cjs +20 -0
  11. package/dist/data-sources/ErrorState.cjs.map +1 -0
  12. package/dist/data-sources/ErrorState.d.cts +7 -0
  13. package/dist/data-sources/ErrorState.d.cts.map +1 -0
  14. package/dist/data-sources/ErrorState.d.mts +7 -0
  15. package/dist/data-sources/ErrorState.d.mts.map +1 -0
  16. package/dist/data-sources/ErrorState.mjs +18 -0
  17. package/dist/data-sources/ErrorState.mjs.map +1 -0
  18. package/dist/data-sources/context.cjs +24 -0
  19. package/dist/data-sources/context.cjs.map +1 -0
  20. package/dist/data-sources/context.d.cts +21 -0
  21. package/dist/data-sources/context.d.cts.map +1 -0
  22. package/dist/data-sources/context.d.mts +21 -0
  23. package/dist/data-sources/context.d.mts.map +1 -0
  24. package/dist/data-sources/context.mjs +21 -0
  25. package/dist/data-sources/context.mjs.map +1 -0
  26. package/dist/data-sources/fetchers/api.cjs +65 -0
  27. package/dist/data-sources/fetchers/api.cjs.map +1 -0
  28. package/dist/data-sources/fetchers/api.d.cts +10 -0
  29. package/dist/data-sources/fetchers/api.d.cts.map +1 -0
  30. package/dist/data-sources/fetchers/api.d.mts +10 -0
  31. package/dist/data-sources/fetchers/api.d.mts.map +1 -0
  32. package/dist/data-sources/fetchers/api.mjs +64 -0
  33. package/dist/data-sources/fetchers/api.mjs.map +1 -0
  34. package/dist/data-sources/fetchers/custom.cjs +108 -0
  35. package/dist/data-sources/fetchers/custom.cjs.map +1 -0
  36. package/dist/data-sources/fetchers/custom.d.cts +17 -0
  37. package/dist/data-sources/fetchers/custom.d.cts.map +1 -0
  38. package/dist/data-sources/fetchers/custom.d.mts +17 -0
  39. package/dist/data-sources/fetchers/custom.d.mts.map +1 -0
  40. package/dist/data-sources/fetchers/custom.mjs +107 -0
  41. package/dist/data-sources/fetchers/custom.mjs.map +1 -0
  42. package/dist/data-sources/fetchers/static.cjs +161 -0
  43. package/dist/data-sources/fetchers/static.cjs.map +1 -0
  44. package/dist/data-sources/fetchers/static.d.cts +40 -0
  45. package/dist/data-sources/fetchers/static.d.cts.map +1 -0
  46. package/dist/data-sources/fetchers/static.d.mts +40 -0
  47. package/dist/data-sources/fetchers/static.d.mts.map +1 -0
  48. package/dist/data-sources/fetchers/static.mjs +158 -0
  49. package/dist/data-sources/fetchers/static.mjs.map +1 -0
  50. package/dist/data-sources/preview-context.cjs +21 -0
  51. package/dist/data-sources/preview-context.cjs.map +1 -0
  52. package/dist/data-sources/preview-context.d.cts +13 -0
  53. package/dist/data-sources/preview-context.d.cts.map +1 -0
  54. package/dist/data-sources/preview-context.d.mts +13 -0
  55. package/dist/data-sources/preview-context.d.mts.map +1 -0
  56. package/dist/data-sources/preview-context.mjs +18 -0
  57. package/dist/data-sources/preview-context.mjs.map +1 -0
  58. package/dist/data-sources/registry-context.cjs +53 -0
  59. package/dist/data-sources/registry-context.cjs.map +1 -0
  60. package/dist/data-sources/registry-context.d.cts +48 -0
  61. package/dist/data-sources/registry-context.d.cts.map +1 -0
  62. package/dist/data-sources/registry-context.d.mts +48 -0
  63. package/dist/data-sources/registry-context.d.mts.map +1 -0
  64. package/dist/data-sources/registry-context.mjs +49 -0
  65. package/dist/data-sources/registry-context.mjs.map +1 -0
  66. package/dist/data-sources/registry.cjs +31 -0
  67. package/dist/data-sources/registry.cjs.map +1 -0
  68. package/dist/data-sources/registry.d.cts +19 -0
  69. package/dist/data-sources/registry.d.cts.map +1 -0
  70. package/dist/data-sources/registry.d.mts +19 -0
  71. package/dist/data-sources/registry.d.mts.map +1 -0
  72. package/dist/data-sources/registry.mjs +29 -0
  73. package/dist/data-sources/registry.mjs.map +1 -0
  74. package/dist/data-sources/transformers.cjs +154 -0
  75. package/dist/data-sources/transformers.cjs.map +1 -0
  76. package/dist/data-sources/transformers.d.cts +10 -0
  77. package/dist/data-sources/transformers.d.cts.map +1 -0
  78. package/dist/data-sources/transformers.d.mts +10 -0
  79. package/dist/data-sources/transformers.d.mts.map +1 -0
  80. package/dist/data-sources/transformers.mjs +153 -0
  81. package/dist/data-sources/transformers.mjs.map +1 -0
  82. package/dist/data-sources/types.cjs +0 -0
  83. package/dist/data-sources/types.d.cts +2 -0
  84. package/dist/data-sources/types.d.mts +2 -0
  85. package/dist/data-sources/types.mjs +1 -0
  86. package/dist/data-sources/use-widget-data.cjs +111 -0
  87. package/dist/data-sources/use-widget-data.cjs.map +1 -0
  88. package/dist/data-sources/use-widget-data.d.cts +17 -0
  89. package/dist/data-sources/use-widget-data.d.cts.map +1 -0
  90. package/dist/data-sources/use-widget-data.d.mts +17 -0
  91. package/dist/data-sources/use-widget-data.d.mts.map +1 -0
  92. package/dist/data-sources/use-widget-data.mjs +109 -0
  93. package/dist/data-sources/use-widget-data.mjs.map +1 -0
  94. package/dist/index-B5cTNde-.d.cts +246 -0
  95. package/dist/index-B5cTNde-.d.cts.map +1 -0
  96. package/dist/index-Cqt2JzkQ.d.mts +246 -0
  97. package/dist/index-Cqt2JzkQ.d.mts.map +1 -0
  98. package/dist/registries/index.cjs +243 -0
  99. package/dist/registries/index.cjs.map +1 -0
  100. package/dist/registries/index.d.cts +338 -0
  101. package/dist/registries/index.d.cts.map +1 -0
  102. package/dist/registries/index.d.mts +338 -0
  103. package/dist/registries/index.d.mts.map +1 -0
  104. package/dist/registries/index.mjs +229 -0
  105. package/dist/registries/index.mjs.map +1 -0
  106. package/dist/shell/AppShellLayout.cjs +49 -0
  107. package/dist/shell/AppShellLayout.cjs.map +1 -0
  108. package/dist/shell/AppShellLayout.d.cts +39 -0
  109. package/dist/shell/AppShellLayout.d.cts.map +1 -0
  110. package/dist/shell/AppShellLayout.d.mts +39 -0
  111. package/dist/shell/AppShellLayout.d.mts.map +1 -0
  112. package/dist/shell/AppShellLayout.mjs +46 -0
  113. package/dist/shell/AppShellLayout.mjs.map +1 -0
  114. package/dist/shell/ScreenHeader.cjs +44 -0
  115. package/dist/shell/ScreenHeader.cjs.map +1 -0
  116. package/dist/shell/ScreenHeader.d.cts +12 -0
  117. package/dist/shell/ScreenHeader.d.cts.map +1 -0
  118. package/dist/shell/ScreenHeader.d.mts +12 -0
  119. package/dist/shell/ScreenHeader.d.mts.map +1 -0
  120. package/dist/shell/ScreenHeader.mjs +42 -0
  121. package/dist/shell/ScreenHeader.mjs.map +1 -0
  122. package/dist/shell/ScreenHeaderContext.cjs +91 -0
  123. package/dist/shell/ScreenHeaderContext.cjs.map +1 -0
  124. package/dist/shell/ScreenHeaderContext.d.cts +35 -0
  125. package/dist/shell/ScreenHeaderContext.d.cts.map +1 -0
  126. package/dist/shell/ScreenHeaderContext.d.mts +35 -0
  127. package/dist/shell/ScreenHeaderContext.d.mts.map +1 -0
  128. package/dist/shell/ScreenHeaderContext.mjs +86 -0
  129. package/dist/shell/ScreenHeaderContext.mjs.map +1 -0
  130. package/dist/shell/ThemeModeContext.cjs +70 -0
  131. package/dist/shell/ThemeModeContext.cjs.map +1 -0
  132. package/dist/shell/ThemeModeContext.d.cts +33 -0
  133. package/dist/shell/ThemeModeContext.d.cts.map +1 -0
  134. package/dist/shell/ThemeModeContext.d.mts +33 -0
  135. package/dist/shell/ThemeModeContext.d.mts.map +1 -0
  136. package/dist/shell/ThemeModeContext.mjs +66 -0
  137. package/dist/shell/ThemeModeContext.mjs.map +1 -0
  138. package/dist/shell/index.cjs +43 -0
  139. package/dist/shell/index.d.cts +7 -0
  140. package/dist/shell/index.d.mts +7 -0
  141. package/dist/shell/index.mjs +7 -0
  142. package/dist/shell/sidebar.cjs +390 -0
  143. package/dist/shell/sidebar.cjs.map +1 -0
  144. package/dist/shell/sidebar.d.cts +85 -0
  145. package/dist/shell/sidebar.d.cts.map +1 -0
  146. package/dist/shell/sidebar.d.mts +85 -0
  147. package/dist/shell/sidebar.d.mts.map +1 -0
  148. package/dist/shell/sidebar.mjs +364 -0
  149. package/dist/shell/sidebar.mjs.map +1 -0
  150. package/dist/shell/use-mobile.cjs +51 -0
  151. package/dist/shell/use-mobile.cjs.map +1 -0
  152. package/dist/shell/use-mobile.d.cts +7 -0
  153. package/dist/shell/use-mobile.d.cts.map +1 -0
  154. package/dist/shell/use-mobile.d.mts +7 -0
  155. package/dist/shell/use-mobile.d.mts.map +1 -0
  156. package/dist/shell/use-mobile.mjs +47 -0
  157. package/dist/shell/use-mobile.mjs.map +1 -0
  158. package/dist/theme/index.cjs +758 -0
  159. package/dist/theme/index.cjs.map +1 -0
  160. package/dist/theme/index.d.cts +131 -0
  161. package/dist/theme/index.d.cts.map +1 -0
  162. package/dist/theme/index.d.mts +131 -0
  163. package/dist/theme/index.d.mts.map +1 -0
  164. package/dist/theme/index.mjs +728 -0
  165. package/dist/theme/index.mjs.map +1 -0
  166. package/dist/types/index.cjs +18 -0
  167. package/dist/types/index.d.cts +4 -0
  168. package/dist/types/index.d.mts +4 -0
  169. package/dist/types/index.mjs +2 -0
  170. package/dist/types-27AHMek-.d.cts +85 -0
  171. package/dist/types-27AHMek-.d.cts.map +1 -0
  172. package/dist/types-BXFX9bXp.cjs +303 -0
  173. package/dist/types-BXFX9bXp.cjs.map +1 -0
  174. package/dist/types-Bjmd7Fdx.mjs +208 -0
  175. package/dist/types-Bjmd7Fdx.mjs.map +1 -0
  176. package/dist/types-C5Zs5V3E.d.mts +155 -0
  177. package/dist/types-C5Zs5V3E.d.mts.map +1 -0
  178. package/dist/types-CeCPKvOv.d.mts +85 -0
  179. package/dist/types-CeCPKvOv.d.mts.map +1 -0
  180. package/dist/types-DrzvahW8.d.cts +155 -0
  181. package/dist/types-DrzvahW8.d.cts.map +1 -0
  182. package/dist/widget-schema-BKZgsNG7.d.mts +119 -0
  183. package/dist/widget-schema-BKZgsNG7.d.mts.map +1 -0
  184. package/dist/widget-schema-BSX2fVhW.d.cts +119 -0
  185. package/dist/widget-schema-BSX2fVhW.d.cts.map +1 -0
  186. package/dist/widget-utils/index.cjs +130 -0
  187. package/dist/widget-utils/index.cjs.map +1 -0
  188. package/dist/widget-utils/index.d.cts +47 -0
  189. package/dist/widget-utils/index.d.cts.map +1 -0
  190. package/dist/widget-utils/index.d.mts +47 -0
  191. package/dist/widget-utils/index.d.mts.map +1 -0
  192. package/dist/widget-utils/index.mjs +119 -0
  193. package/dist/widget-utils/index.mjs.map +1 -0
  194. package/package.json +200 -0
  195. package/src/styles/globals.css +1 -0
@@ -0,0 +1,208 @@
1
+ //#region src/types/widget-schema.ts
2
+ /**
3
+ * Widget type names as a const object.
4
+ * This serves as the single source of truth for widget discriminants.
5
+ * Use `as const` for literal type inference (safety-as-const-deep-readonly rule).
6
+ */
7
+ const WIDGET_TYPE_NAMES = {
8
+ Alert: "AlertWidget",
9
+ Calendar: "CalendarWidget",
10
+ Carousel: "CarouselWidget",
11
+ CatchUp: "CatchUpWidget",
12
+ Chart: "ChartWidget",
13
+ Container: "ContainerWidget",
14
+ Embed: "EmbedWidget",
15
+ Image: "ImageWidget",
16
+ Layout: "LayoutWidget",
17
+ List: "ListWidget",
18
+ MySite: "MySiteWidget",
19
+ Nested: "NestedWidget",
20
+ QuickShare: "QuickShareWidget",
21
+ RecentActivity: "RecentActivityWidget",
22
+ Spacer: "SpacerWidget",
23
+ Table: "TableWidget",
24
+ Text: "TextWidget",
25
+ ToDo: "ToDoWidget",
26
+ Video: "VideoWidget"
27
+ };
28
+ /**
29
+ * Type predicate to check if a string is a known widget type name.
30
+ * Use for runtime validation of widget types.
31
+ *
32
+ * @example
33
+ * if (isWidgetTypeName(widget.type)) {
34
+ * // TypeScript knows widget.type is WidgetTypeName
35
+ * }
36
+ */
37
+ function isWidgetTypeName(type) {
38
+ return Object.values(WIDGET_TYPE_NAMES).includes(type);
39
+ }
40
+ /**
41
+ * Type predicate to check if a widget has a specific type.
42
+ * Enables type-safe widget narrowing without `as` assertions.
43
+ *
44
+ * @example
45
+ * if (isWidgetType(widget, "LayoutWidget")) {
46
+ * // TypeScript knows widget.type === "LayoutWidget"
47
+ * // and widget.props is LayoutWidget props
48
+ * }
49
+ */
50
+ function isWidgetType(widget, typeName) {
51
+ return widget != null && widget.type === typeName;
52
+ }
53
+ /**
54
+ * Helper for exhaustive switch statements on widget types.
55
+ * Use in the default case to ensure all widget types are handled.
56
+ *
57
+ * @example
58
+ * switch (widget.type) {
59
+ * case "AlertWidget": return handleAlert();
60
+ * case "TextWidget": return handleText();
61
+ * // ... all other widget types
62
+ * default: return assertNever(widget.type, "widget type");
63
+ * }
64
+ */
65
+ function assertNever(value, context) {
66
+ const message = context ? `Unexpected ${context}: ${String(value)}` : `Unexpected value: ${String(value)}`;
67
+ throw new Error(message);
68
+ }
69
+ /**
70
+ * Assertion function that throws if value is undefined.
71
+ * Narrows the type to exclude undefined.
72
+ *
73
+ * @example
74
+ * const widget = screen[0];
75
+ * assertDefined(widget, "widget at index 0");
76
+ * // TypeScript knows widget is defined here
77
+ */
78
+ function assertDefined(value, name) {
79
+ if (value == null) throw new Error(name ? `${name} is required` : "Value is required");
80
+ }
81
+ //#endregion
82
+ //#region src/types/field-types.ts
83
+ /**
84
+ * Color options constant - single source of truth for color values.
85
+ * Use COLOR_OPTIONS.primary instead of "primary" for type-safe comparisons.
86
+ */
87
+ const COLOR_OPTIONS = {
88
+ background: "background",
89
+ foreground: "foreground",
90
+ primary: "primary",
91
+ secondary: "secondary",
92
+ accent: "accent",
93
+ muted: "muted",
94
+ destructive: "destructive"
95
+ };
96
+ const FONT_SIZE_OPTIONS = {
97
+ "2xl": "2xl",
98
+ xl: "xl",
99
+ lg: "lg",
100
+ md: "md",
101
+ sm: "sm",
102
+ xs: "xs"
103
+ };
104
+ const BORDER_RADIUS_OPTIONS = {
105
+ none: "none",
106
+ sm: "sm",
107
+ md: "md",
108
+ lg: "lg",
109
+ xl: "xl",
110
+ full: "full"
111
+ };
112
+ /** Padding values - numeric, so we use a tuple for derivation */
113
+ const PADDING_VALUES = [
114
+ 0,
115
+ 2,
116
+ 4,
117
+ 6,
118
+ 8,
119
+ 10
120
+ ];
121
+ const BUTTON_SIZE_OPTIONS = {
122
+ sm: "sm",
123
+ default: "default",
124
+ lg: "lg",
125
+ xl: "xl"
126
+ };
127
+ const GAP_OPTIONS = {
128
+ none: "none",
129
+ xs: "xs",
130
+ sm: "sm",
131
+ md: "md",
132
+ lg: "lg",
133
+ xl: "xl"
134
+ };
135
+ const VERTICAL_ALIGN_OPTIONS = {
136
+ top: "top",
137
+ center: "center",
138
+ bottom: "bottom"
139
+ };
140
+ const HORIZONTAL_ALIGN_OPTIONS = {
141
+ left: "left",
142
+ center: "center",
143
+ right: "right"
144
+ };
145
+ const BACKGROUND_TYPES = {
146
+ solid: "solid",
147
+ image: "image"
148
+ };
149
+ /**
150
+ * Section layout configuration - single source of truth for layout types.
151
+ * SectionLayoutType is derived from these keys to prevent drift.
152
+ */
153
+ const SECTION_LAYOUT_CONFIG = {
154
+ "single-column": {
155
+ columns: 1,
156
+ widths: ["1fr"],
157
+ gridClasses: ""
158
+ },
159
+ "2c-equal": {
160
+ columns: 2,
161
+ widths: ["1fr", "1fr"],
162
+ gridClasses: "@md:grid-cols-2"
163
+ },
164
+ "2c-left-wider": {
165
+ columns: 2,
166
+ widths: ["2fr", "1fr"],
167
+ gridClasses: "@md:grid-cols-[2fr_1fr]"
168
+ },
169
+ "2c-right-wider": {
170
+ columns: 2,
171
+ widths: ["1fr", "2fr"],
172
+ gridClasses: "@md:grid-cols-[1fr_2fr]"
173
+ },
174
+ "2c-left-narrow": {
175
+ columns: 2,
176
+ widths: ["1fr", "3fr"],
177
+ gridClasses: "@md:grid-cols-[1fr_3fr]"
178
+ },
179
+ "2c-right-narrow": {
180
+ columns: 2,
181
+ widths: ["3fr", "1fr"],
182
+ gridClasses: "@md:grid-cols-[3fr_1fr]"
183
+ },
184
+ "3c-equal": {
185
+ columns: 3,
186
+ widths: [
187
+ "1fr",
188
+ "1fr",
189
+ "1fr"
190
+ ],
191
+ gridClasses: "@md:grid-cols-3"
192
+ },
193
+ "3c-middle-wider": {
194
+ columns: 3,
195
+ widths: [
196
+ "1fr",
197
+ "2fr",
198
+ "1fr"
199
+ ],
200
+ gridClasses: "@md:grid-cols-[1fr_2fr_1fr]"
201
+ }
202
+ };
203
+ /** @deprecated Use SECTION_LAYOUT_CONFIG instead */
204
+ const sectionLayoutConfig = SECTION_LAYOUT_CONFIG;
205
+ //#endregion
206
+ export { FONT_SIZE_OPTIONS as a, PADDING_VALUES as c, sectionLayoutConfig as d, WIDGET_TYPE_NAMES as f, isWidgetTypeName as g, isWidgetType as h, COLOR_OPTIONS as i, SECTION_LAYOUT_CONFIG as l, assertNever as m, BORDER_RADIUS_OPTIONS as n, GAP_OPTIONS as o, assertDefined as p, BUTTON_SIZE_OPTIONS as r, HORIZONTAL_ALIGN_OPTIONS as s, BACKGROUND_TYPES as t, VERTICAL_ALIGN_OPTIONS as u };
207
+
208
+ //# sourceMappingURL=types-Bjmd7Fdx.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-Bjmd7Fdx.mjs","names":[],"sources":["../src/types/widget-schema.ts","../src/types/field-types.ts"],"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 readonly \"single-column\": {\n readonly columns: 1;\n readonly widths: readonly [\"1fr\"];\n readonly gridClasses: \"\";\n };\n readonly \"2c-equal\": {\n readonly columns: 2;\n readonly widths: readonly [\"1fr\", \"1fr\"];\n readonly gridClasses: \"@md:grid-cols-2\";\n };\n readonly \"2c-left-wider\": {\n readonly columns: 2;\n readonly widths: readonly [\"2fr\", \"1fr\"];\n readonly gridClasses: \"@md:grid-cols-[2fr_1fr]\";\n };\n readonly \"2c-right-wider\": {\n readonly columns: 2;\n readonly widths: readonly [\"1fr\", \"2fr\"];\n readonly gridClasses: \"@md:grid-cols-[1fr_2fr]\";\n };\n readonly \"2c-left-narrow\": {\n readonly columns: 2;\n readonly widths: readonly [\"1fr\", \"3fr\"];\n readonly gridClasses: \"@md:grid-cols-[1fr_3fr]\";\n };\n readonly \"2c-right-narrow\": {\n readonly columns: 2;\n readonly widths: readonly [\"3fr\", \"1fr\"];\n readonly gridClasses: \"@md:grid-cols-[3fr_1fr]\";\n };\n readonly \"3c-equal\": {\n readonly columns: 3;\n readonly widths: readonly [\"1fr\", \"1fr\", \"1fr\"];\n readonly gridClasses: \"@md:grid-cols-3\";\n };\n readonly \"3c-middle-wider\": {\n readonly columns: 3;\n readonly widths: readonly [\"1fr\", \"2fr\", \"1fr\"];\n readonly gridClasses: \"@md:grid-cols-[1fr_2fr_1fr]\";\n };\n} = {\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: typeof SECTION_LAYOUT_CONFIG =\n SECTION_LAYOUT_CONFIG;\n"],"mappings":";;;;;;AAQA,MAAa,oBAAoB;CAC/B,OAAO;CACP,UAAU;CACV,UAAU;CACV,SAAS;CACT,OAAO;CACP,WAAW;CACX,OAAO;CACP,OAAO;CACP,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,gBAAgB;CAChB,QAAQ;CACR,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACR;;;;;;;;;;AAqED,SAAgB,iBAAiB,MAAsC;AAIrE,QAAO,OAAO,OAAO,kBAAkB,CAAC,SAAS,KAAuB;;;;;;;;;;;;AAa1E,SAAgB,aACd,QACA,UAC+C;AAC/C,QAAO,UAAU,QAAQ,OAAO,SAAS;;;;;;;;;;;;;;AAe3C,SAAgB,YAAY,OAAc,SAAyB;CACjE,MAAM,UAAU,UACZ,cAAc,QAAQ,IAAI,OAAO,MAAM,KACvC,qBAAqB,OAAO,MAAM;AACtC,OAAM,IAAI,MAAM,QAAQ;;;;;;;;;;;AAY1B,SAAgB,cACd,OACA,MACoB;AACpB,KAAI,SAAS,KACX,OAAM,IAAI,MAAM,OAAO,GAAG,KAAK,gBAAgB,oBAAoB;;;;;;;;AChJvE,MAAa,gBAAgB;CAC3B,YAAY;CACZ,YAAY;CACZ,SAAS;CACT,WAAW;CACX,QAAQ;CACR,OAAO;CACP,aAAa;CACd;AAYD,MAAa,oBAAoB;CAC/B,OAAO;CACP,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACL;AAKD,MAAa,wBAAwB;CACnC,MAAM;CACN,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;CACP;;AAMD,MAAa,iBAAiB;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;AAGjD,MAAa,sBAAsB;CACjC,IAAI;CACJ,SAAS;CACT,IAAI;CACJ,IAAI;CACL;AAKD,MAAa,cAAc;CACzB,MAAM;CACN,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACL;AAQD,MAAa,yBAAyB;CACpC,KAAK;CACL,QAAQ;CACR,QAAQ;CACT;AAKD,MAAa,2BAA2B;CACtC,MAAM;CACN,QAAQ;CACR,OAAO;CACR;AAcD,MAAa,mBAAmB;CAC9B,OAAO;CACP,OAAO;CACR;;;;;AAkBD,MAAa,wBAyCT;CACF,iBAAiB;EAAE,SAAS;EAAG,QAAQ,CAAC,MAAM;EAAE,aAAa;EAAI;CACjE,YAAY;EACV,SAAS;EACT,QAAQ,CAAC,OAAO,MAAM;EACtB,aAAa;EACd;CACD,iBAAiB;EACf,SAAS;EACT,QAAQ,CAAC,OAAO,MAAM;EACtB,aAAa;EACd;CACD,kBAAkB;EAChB,SAAS;EACT,QAAQ,CAAC,OAAO,MAAM;EACtB,aAAa;EACd;CACD,kBAAkB;EAChB,SAAS;EACT,QAAQ,CAAC,OAAO,MAAM;EACtB,aAAa;EACd;CACD,mBAAmB;EACjB,SAAS;EACT,QAAQ,CAAC,OAAO,MAAM;EACtB,aAAa;EACd;CACD,YAAY;EACV,SAAS;EACT,QAAQ;GAAC;GAAO;GAAO;GAAM;EAC7B,aAAa;EACd;CACD,mBAAmB;EACjB,SAAS;EACT,QAAQ;GAAC;GAAO;GAAO;GAAM;EAC7B,aAAa;EACd;CACF;;AAgBD,MAAa,sBACX"}
@@ -0,0 +1,155 @@
1
+ //#region src/data-sources/types.d.ts
2
+ type DataSourceType = "api" | "custom" | "static";
3
+ type StaticSourceType = "collections" | "categories" | "tags";
4
+ type ShareableType = "Medium" | "Page" | "EnrollmentPack" | "Library" | "Product";
5
+ interface SelectedItem {
6
+ /** The unique ID of the selected item */
7
+ id: string | number;
8
+ /** The type of shareable content */
9
+ shareableType: ShareableType;
10
+ /** Optional cached data for preview/display purposes in the editor UI */
11
+ cachedData?: {
12
+ title?: string;
13
+ imageUrl?: string;
14
+ kind?: string;
15
+ };
16
+ /** Widget-specific per-item configuration overrides */
17
+ widgetConfig?: Record<string, unknown>;
18
+ }
19
+ interface ApiDataSource {
20
+ type: "api";
21
+ /** API endpoint URL (can include {variable} placeholders, e.g., /api/reps/{rep_id}/items) */
22
+ endpoint: string;
23
+ /** HTTP method (defaults to GET) */
24
+ method?: "GET" | "POST" | "PUT" | "DELETE";
25
+ /** Request headers */
26
+ headers?: Record<string, string>;
27
+ /** Request body for POST/PUT (will be JSON.stringify'd) */
28
+ body?: unknown;
29
+ /**
30
+ * Path to extract from response using dot notation
31
+ * e.g., "data.items" extracts response.data.items
32
+ */
33
+ resultPath?: string;
34
+ /**
35
+ * Which widget props this source populates
36
+ * e.g., ['data'] means the fetched result goes to props.data
37
+ */
38
+ targetProps: string[];
39
+ /**
40
+ * Name of a registered transform function to process the data
41
+ * Transform is applied after resultPath extraction
42
+ */
43
+ transform?: string;
44
+ /** Per-source variables for endpoint template interpolation (e.g., { limit: "10" }) */
45
+ variables?: Record<string, string>;
46
+ /**
47
+ * Auto-refresh interval in milliseconds
48
+ * 0 or undefined = no auto-refresh
49
+ */
50
+ refreshInterval?: number;
51
+ }
52
+ interface CustomDataSource {
53
+ type: "custom";
54
+ /** Array of selected items to fetch */
55
+ selectedItems: SelectedItem[];
56
+ /**
57
+ * Which widget props this source populates
58
+ * e.g., ['slides'] means the fetched results go to props.slides
59
+ */
60
+ targetProps: string[];
61
+ /**
62
+ * Name of a registered transform function to process the data
63
+ * Transform is applied after all items are fetched
64
+ */
65
+ transform?: string;
66
+ /**
67
+ * Auto-refresh interval in milliseconds
68
+ * 0 or undefined = no auto-refresh
69
+ */
70
+ refreshInterval?: number;
71
+ }
72
+ interface StaticDataSource {
73
+ type: "static";
74
+ /** The type of static data (collections, categories, tags) */
75
+ staticType: StaticSourceType;
76
+ /** The selected item ID */
77
+ selectedId: string | number;
78
+ /** Cached data for preview/display in editor UI */
79
+ cachedData?: {
80
+ title?: string;
81
+ imageUrl?: string;
82
+ };
83
+ /**
84
+ * Which widget props this source populates
85
+ */
86
+ targetProps: string[];
87
+ /**
88
+ * Name of a registered transform function to process the data
89
+ */
90
+ transform?: string;
91
+ /**
92
+ * Auto-refresh interval in milliseconds
93
+ * 0 or undefined = no auto-refresh
94
+ */
95
+ refreshInterval?: number;
96
+ }
97
+ type DataSource = ApiDataSource | CustomDataSource | StaticDataSource;
98
+ interface DataSourceConfig {
99
+ /** Array of data sources (usually just one, but supports multiple) */
100
+ sources: DataSource[];
101
+ /** Loading state configuration */
102
+ loading?: {
103
+ /** Show skeleton placeholder while loading (default: true) */showSkeleton?: boolean;
104
+ };
105
+ /** Error handling configuration */
106
+ error?: {
107
+ /** Fallback props to use when fetch fails */fallback?: Record<string, unknown>; /** Number of retry attempts (default: 0) */
108
+ retryCount?: number; /** Delay between retries in ms (default: 1000) */
109
+ retryDelay?: number;
110
+ };
111
+ }
112
+ /** Item returned by static data fetchers */
113
+ interface StaticItem {
114
+ id: string | number;
115
+ title: string;
116
+ imageUrl?: string | undefined;
117
+ }
118
+ /** Context passed to fetchers and transforms */
119
+ interface DataSourceContext {
120
+ /** The widget's unique ID */
121
+ widgetId: string;
122
+ /** The widget type (e.g., "ChartWidget") */
123
+ widgetType: string;
124
+ /** AbortSignal for request cancellation */
125
+ signal: AbortSignal;
126
+ /** Base URL for API calls (e.g., "https://api.fluid.app/api") */
127
+ baseUrl?: string | undefined;
128
+ /** Get API headers function */
129
+ getApiHeaders?: (() => Record<string, string>) | undefined;
130
+ /** Dynamic variables for endpoint path substitution (e.g., { rep_id: "123" }) */
131
+ variables?: Record<string, string> | undefined;
132
+ }
133
+ /** Function signature for data fetchers */
134
+ type DataFetcher<T extends DataSource = DataSource> = (source: T, context: DataSourceContext) => Promise<unknown>;
135
+ /** Function signature for data transforms */
136
+ type DataTransformer = (data: unknown, source?: DataSource, context?: DataSourceContext) => unknown;
137
+ /** The data source registry configuration */
138
+ interface DataSourceRegistry {
139
+ fetchers: Record<DataSourceType, DataFetcher>;
140
+ transformers: Record<string, DataTransformer>;
141
+ }
142
+ /** Result from useWidgetData hook */
143
+ interface WidgetDataResult<T = unknown> {
144
+ /** The resolved data (undefined while loading) */
145
+ data: T | undefined;
146
+ /** True while any source is loading */
147
+ isLoading: boolean;
148
+ /** Error if any source failed */
149
+ error: Error | null;
150
+ /** Manually trigger a refetch */
151
+ refetch: () => void;
152
+ }
153
+ //#endregion
154
+ export { DataSourceConfig as a, DataSourceType as c, ShareableType as d, StaticDataSource as f, WidgetDataResult as h, DataSource as i, DataTransformer as l, StaticSourceType as m, CustomDataSource as n, DataSourceContext as o, StaticItem as p, DataFetcher as r, DataSourceRegistry as s, ApiDataSource as t, SelectedItem as u };
155
+ //# sourceMappingURL=types-C5Zs5V3E.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-C5Zs5V3E.d.mts","names":[],"sources":["../src/data-sources/types.ts"],"mappings":";KACY,cAAA;AAAA,KAGA,gBAAA;AAAA,KAGA,aAAA;AAAA,UAQK,YAAA;EAdL;EAgBV,EAAA;EAbF;EAeE,aAAA,EAAe,aAAA;;EAEf,UAAA;IACE,KAAA;IACA,QAAA;IACA,IAAA;EAAA;EAjBQ;EAoBV,YAAA,GAAe,MAAA;AAAA;AAAA,UAGA,aAAA;EACf,IAAA;EAJe;EAMf,QAAA;;EAEA,MAAA;;EAEA,OAAA,GAAU,MAAA;;EAEV,IAAA;;;;;EAKA,UAAA;EAde;;;;EAmBf,WAAA;;;;;EAKA,SAAA;;EAEA,SAAA,GAAY,MAAA;;;;;EAKZ,eAAA;AAAA;AAAA,UAGe,gBAAA;EACf,IAAA;EAEe;EAAf,aAAA,EAAe,YAAA;;;;;EAKf,WAAA;;;AAaF;;EARE,SAAA;EAWY;;;;EANZ,eAAA;AAAA;AAAA,UAGe,gBAAA;EACf,IAAA;;EAEA,UAAA,EAAY,gBAAA;;EAEZ,UAAA;EAkBA;EAhBA,UAAA;IACE,KAAA;IACA,QAAA;EAAA;;;;EAKF,WAAA;;;;EAIA,SAAA;EAS0D;AAE5D;;;EANE,eAAA;AAAA;AAAA,KAIU,UAAA,GAAa,aAAA,GAAgB,gBAAA,GAAmB,gBAAA;AAAA,UAE3C,gBAAA;;EAEf,OAAA,EAAS,UAAA;;EAET,OAAA;IASE,8DAPA,YAAA;EAAA;EASA;EANF,KAAA;IAWe,6CATb,QAAA,GAAW,MAAA,mBASE;IAPb,UAAA,WASF;IAPE,UAAA;EAAA;AAAA;AAgBJ;AAAA,UAXiB,UAAA;EACf,EAAA;EACA,KAAA;EACA,QAAA;AAAA;;UAQe,iBAAA;;EAEf,QAAA;;EAEA,UAAA;;EAEA,MAAA,EAAQ,WAAA;;EAER,OAAA;;EAEA,aAAA,UAAuB,MAAA;EAEX;EAAZ,SAAA,GAAY,MAAA;AAAA;;KAIF,WAAA,WAAsB,UAAA,GAAa,UAAA,KAC7C,MAAA,EAAQ,CAAA,EACR,OAAA,EAAS,iBAAA,KACN,OAAA;;KAGO,eAAA,IACV,IAAA,WACA,MAAA,GAAS,UAAA,EACT,OAAA,GAAU,iBAAA;;UAIK,kBAAA;EACf,QAAA,EAAU,MAAA,CAAO,cAAA,EAAgB,WAAA;EACjC,YAAA,EAAc,MAAA,SAAe,eAAA;AAAA;;UAId,gBAAA;;EAEf,IAAA,EAAM,CAAA;;EAEN,SAAA;;EAEA,KAAA,EAAO,KAAA;EAtBJ;EAwBH,OAAA;AAAA"}
@@ -0,0 +1,85 @@
1
+ import Color from "colorjs.io";
2
+
3
+ //#region src/theme/types.d.ts
4
+ declare const SEMANTIC_COLOR_NAMES: readonly ["background", "foreground", "primary", "secondary", "accent", "muted", "destructive"];
5
+ type SemanticColorName = (typeof SEMANTIC_COLOR_NAMES)[number];
6
+ declare const SHADE_STEPS: readonly [100, 200, 300, 400, 500, 600, 700, 800, 900];
7
+ type ShadeStep = (typeof SHADE_STEPS)[number];
8
+ declare const FONT_SIZE_KEYS: readonly ["extraSmall", "small", "regular", "large", "extraLarge", "giant"];
9
+ type FontSizeKey = (typeof FONT_SIZE_KEYS)[number];
10
+ declare const FONT_FAMILY_KEYS: readonly ["header", "body"];
11
+ type FontFamilyKey = (typeof FONT_FAMILY_KEYS)[number];
12
+ declare const RADIUS_KEYS: readonly ["small", "medium", "large", "extraLarge"];
13
+ type RadiusKey = (typeof RADIUS_KEYS)[number];
14
+ /** Author-time color input (what the user configures) */
15
+ interface ThemeColorInput {
16
+ base: Color;
17
+ foreground: Color;
18
+ }
19
+ /** Complete theme definition — stored in-memory with Color objects */
20
+ interface ThemeDefinition {
21
+ id: string;
22
+ name: string;
23
+ /** Light mode — always fully specified */
24
+ light: Record<SemanticColorName, ThemeColorInput>;
25
+ /**
26
+ * Dark mode — only user-overridden colors.
27
+ * Missing keys are auto-derived from `light` at resolve time.
28
+ */
29
+ dark: Partial<Record<SemanticColorName, Partial<ThemeColorInput>>>;
30
+ fontSizes: Record<FontSizeKey, string>;
31
+ fontFamilies: Record<FontFamilyKey, string>;
32
+ spacing: string;
33
+ radii: Record<RadiusKey, string>;
34
+ /** When true, theme colors are re-derived from brand guidelines on every load */
35
+ syncWithBrandColors?: boolean;
36
+ }
37
+ /** Resolved semantic color with generated shade ramp */
38
+ interface ResolvedSemanticColor {
39
+ base: Color;
40
+ foreground: Color;
41
+ shades: Record<ShadeStep, Color>;
42
+ }
43
+ /** Complete resolved color set for one mode */
44
+ type ResolvedColorSet = Record<SemanticColorName, ResolvedSemanticColor>;
45
+ /** Fully resolved theme — all colors materialised for both modes */
46
+ interface ResolvedTheme {
47
+ id: string;
48
+ name: string;
49
+ light: ResolvedColorSet;
50
+ dark: ResolvedColorSet;
51
+ fontSizes: ThemeDefinition["fontSizes"];
52
+ fontFamilies: ThemeDefinition["fontFamilies"];
53
+ spacing: string;
54
+ radii: ThemeDefinition["radii"];
55
+ }
56
+ /** Plain OKLCH triplet for JSON serialisation (no Color dependency) */
57
+ interface OklchPlain {
58
+ l: number;
59
+ c: number;
60
+ h: number;
61
+ }
62
+ /** Serialised color pair as stored in the backend payload */
63
+ interface ThemeColorPlain {
64
+ base: OklchPlain;
65
+ foreground: OklchPlain;
66
+ }
67
+ /** Backend payload — plain JSON, no Color objects */
68
+ interface ThemePayload {
69
+ [key: string]: unknown;
70
+ id: string;
71
+ name: string;
72
+ light: Record<SemanticColorName, ThemeColorPlain>;
73
+ dark: Partial<Record<SemanticColorName, {
74
+ base?: OklchPlain;
75
+ foreground?: OklchPlain;
76
+ }>>;
77
+ fontSizes: Record<FontSizeKey, string>;
78
+ fontFamilies: Record<FontFamilyKey, string>;
79
+ spacing: string;
80
+ radii: Record<RadiusKey, string>;
81
+ syncWithBrandColors?: boolean;
82
+ }
83
+ //#endregion
84
+ export { ThemeDefinition as _, OklchPlain as a, ResolvedColorSet as c, SEMANTIC_COLOR_NAMES as d, SHADE_STEPS as f, ThemeColorPlain as g, ThemeColorInput as h, FontSizeKey as i, ResolvedSemanticColor as l, ShadeStep as m, FONT_SIZE_KEYS as n, RADIUS_KEYS as o, SemanticColorName as p, FontFamilyKey as r, RadiusKey as s, FONT_FAMILY_KEYS as t, ResolvedTheme as u, ThemePayload as v };
85
+ //# sourceMappingURL=types-CeCPKvOv.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-CeCPKvOv.d.mts","names":[],"sources":["../src/theme/types.ts"],"mappings":";;;cAGa,oBAAA;AAAA,KASD,iBAAA,WAA4B,oBAAA;AAAA,cAE3B,WAAA;AAAA,KAGD,SAAA,WAAoB,WAAA;AAAA,cAEnB,cAAA;AAAA,KAQD,WAAA,WAAsB,cAAA;AAAA,cAErB,gBAAA;AAAA,KACD,aAAA,WAAwB,gBAAA;AAAA,cAEvB,WAAA;AAAA,KACD,SAAA,WAAoB,WAAA;;UAGf,eAAA;EACf,IAAA,EAAM,KAAA;EACN,UAAA,EAAY,KAAA;AAAA;;UAIG,eAAA;EACf,EAAA;EACA,IAAA;;EAEA,KAAA,EAAO,MAAA,CAAO,iBAAA,EAAmB,eAAA;EA7BH;AAEhC;;;EAgCE,IAAA,EAAM,OAAA,CAAQ,MAAA,CAAO,iBAAA,EAAmB,OAAA,CAAQ,eAAA;EAChD,SAAA,EAAW,MAAA,CAAO,WAAA;EAClB,YAAA,EAAc,MAAA,CAAO,aAAA;EACrB,OAAA;EACA,KAAA,EAAO,MAAA,CAAO,SAAA;EA5BkB;EA8BhC,mBAAA;AAAA;;UAIe,qBAAA;EACf,IAAA,EAAM,KAAA;EACN,UAAA,EAAY,KAAA;EACZ,MAAA,EAAQ,MAAA,CAAO,SAAA,EAAW,KAAA;AAAA;;KAIhB,gBAAA,GAAmB,MAAA,CAAO,iBAAA,EAAmB,qBAAA;;UAGxC,aAAA;EACf,EAAA;EACA,IAAA;EACA,KAAA,EAAO,gBAAA;EACP,IAAA,EAAM,gBAAA;EACN,SAAA,EAAW,eAAA;EACX,YAAA,EAAc,eAAA;EACd,OAAA;EACA,KAAA,EAAO,eAAA;AAAA;AA3CT;AAAA,UA+CiB,UAAA;EACf,CAAA;EACA,CAAA;EACA,CAAA;AAAA;;UAIe,eAAA;EACf,IAAA,EAAM,UAAA;EACN,UAAA,EAAY,UAAA;AAAA;;UAIG,YAAA;EAAA;EAEf,EAAA;EACA,IAAA;EACA,KAAA,EAAO,MAAA,CAAO,iBAAA,EAAmB,eAAA;EACjC,IAAA,EAAM,OAAA,CACJ,MAAA,CAAO,iBAAA;IAAqB,IAAA,GAAO,UAAA;IAAY,UAAA,GAAa,UAAA;EAAA;EAE9D,SAAA,EAAW,MAAA,CAAO,WAAA;EAClB,YAAA,EAAc,MAAA,CAAO,aAAA;EACrB,OAAA;EACA,KAAA,EAAO,MAAA,CAAO,SAAA;EACd,mBAAA;AAAA"}
@@ -0,0 +1,155 @@
1
+ //#region src/data-sources/types.d.ts
2
+ type DataSourceType = "api" | "custom" | "static";
3
+ type StaticSourceType = "collections" | "categories" | "tags";
4
+ type ShareableType = "Medium" | "Page" | "EnrollmentPack" | "Library" | "Product";
5
+ interface SelectedItem {
6
+ /** The unique ID of the selected item */
7
+ id: string | number;
8
+ /** The type of shareable content */
9
+ shareableType: ShareableType;
10
+ /** Optional cached data for preview/display purposes in the editor UI */
11
+ cachedData?: {
12
+ title?: string;
13
+ imageUrl?: string;
14
+ kind?: string;
15
+ };
16
+ /** Widget-specific per-item configuration overrides */
17
+ widgetConfig?: Record<string, unknown>;
18
+ }
19
+ interface ApiDataSource {
20
+ type: "api";
21
+ /** API endpoint URL (can include {variable} placeholders, e.g., /api/reps/{rep_id}/items) */
22
+ endpoint: string;
23
+ /** HTTP method (defaults to GET) */
24
+ method?: "GET" | "POST" | "PUT" | "DELETE";
25
+ /** Request headers */
26
+ headers?: Record<string, string>;
27
+ /** Request body for POST/PUT (will be JSON.stringify'd) */
28
+ body?: unknown;
29
+ /**
30
+ * Path to extract from response using dot notation
31
+ * e.g., "data.items" extracts response.data.items
32
+ */
33
+ resultPath?: string;
34
+ /**
35
+ * Which widget props this source populates
36
+ * e.g., ['data'] means the fetched result goes to props.data
37
+ */
38
+ targetProps: string[];
39
+ /**
40
+ * Name of a registered transform function to process the data
41
+ * Transform is applied after resultPath extraction
42
+ */
43
+ transform?: string;
44
+ /** Per-source variables for endpoint template interpolation (e.g., { limit: "10" }) */
45
+ variables?: Record<string, string>;
46
+ /**
47
+ * Auto-refresh interval in milliseconds
48
+ * 0 or undefined = no auto-refresh
49
+ */
50
+ refreshInterval?: number;
51
+ }
52
+ interface CustomDataSource {
53
+ type: "custom";
54
+ /** Array of selected items to fetch */
55
+ selectedItems: SelectedItem[];
56
+ /**
57
+ * Which widget props this source populates
58
+ * e.g., ['slides'] means the fetched results go to props.slides
59
+ */
60
+ targetProps: string[];
61
+ /**
62
+ * Name of a registered transform function to process the data
63
+ * Transform is applied after all items are fetched
64
+ */
65
+ transform?: string;
66
+ /**
67
+ * Auto-refresh interval in milliseconds
68
+ * 0 or undefined = no auto-refresh
69
+ */
70
+ refreshInterval?: number;
71
+ }
72
+ interface StaticDataSource {
73
+ type: "static";
74
+ /** The type of static data (collections, categories, tags) */
75
+ staticType: StaticSourceType;
76
+ /** The selected item ID */
77
+ selectedId: string | number;
78
+ /** Cached data for preview/display in editor UI */
79
+ cachedData?: {
80
+ title?: string;
81
+ imageUrl?: string;
82
+ };
83
+ /**
84
+ * Which widget props this source populates
85
+ */
86
+ targetProps: string[];
87
+ /**
88
+ * Name of a registered transform function to process the data
89
+ */
90
+ transform?: string;
91
+ /**
92
+ * Auto-refresh interval in milliseconds
93
+ * 0 or undefined = no auto-refresh
94
+ */
95
+ refreshInterval?: number;
96
+ }
97
+ type DataSource = ApiDataSource | CustomDataSource | StaticDataSource;
98
+ interface DataSourceConfig {
99
+ /** Array of data sources (usually just one, but supports multiple) */
100
+ sources: DataSource[];
101
+ /** Loading state configuration */
102
+ loading?: {
103
+ /** Show skeleton placeholder while loading (default: true) */showSkeleton?: boolean;
104
+ };
105
+ /** Error handling configuration */
106
+ error?: {
107
+ /** Fallback props to use when fetch fails */fallback?: Record<string, unknown>; /** Number of retry attempts (default: 0) */
108
+ retryCount?: number; /** Delay between retries in ms (default: 1000) */
109
+ retryDelay?: number;
110
+ };
111
+ }
112
+ /** Item returned by static data fetchers */
113
+ interface StaticItem {
114
+ id: string | number;
115
+ title: string;
116
+ imageUrl?: string | undefined;
117
+ }
118
+ /** Context passed to fetchers and transforms */
119
+ interface DataSourceContext {
120
+ /** The widget's unique ID */
121
+ widgetId: string;
122
+ /** The widget type (e.g., "ChartWidget") */
123
+ widgetType: string;
124
+ /** AbortSignal for request cancellation */
125
+ signal: AbortSignal;
126
+ /** Base URL for API calls (e.g., "https://api.fluid.app/api") */
127
+ baseUrl?: string | undefined;
128
+ /** Get API headers function */
129
+ getApiHeaders?: (() => Record<string, string>) | undefined;
130
+ /** Dynamic variables for endpoint path substitution (e.g., { rep_id: "123" }) */
131
+ variables?: Record<string, string> | undefined;
132
+ }
133
+ /** Function signature for data fetchers */
134
+ type DataFetcher<T extends DataSource = DataSource> = (source: T, context: DataSourceContext) => Promise<unknown>;
135
+ /** Function signature for data transforms */
136
+ type DataTransformer = (data: unknown, source?: DataSource, context?: DataSourceContext) => unknown;
137
+ /** The data source registry configuration */
138
+ interface DataSourceRegistry {
139
+ fetchers: Record<DataSourceType, DataFetcher>;
140
+ transformers: Record<string, DataTransformer>;
141
+ }
142
+ /** Result from useWidgetData hook */
143
+ interface WidgetDataResult<T = unknown> {
144
+ /** The resolved data (undefined while loading) */
145
+ data: T | undefined;
146
+ /** True while any source is loading */
147
+ isLoading: boolean;
148
+ /** Error if any source failed */
149
+ error: Error | null;
150
+ /** Manually trigger a refetch */
151
+ refetch: () => void;
152
+ }
153
+ //#endregion
154
+ export { DataSourceConfig as a, DataSourceType as c, ShareableType as d, StaticDataSource as f, WidgetDataResult as h, DataSource as i, DataTransformer as l, StaticSourceType as m, CustomDataSource as n, DataSourceContext as o, StaticItem as p, DataFetcher as r, DataSourceRegistry as s, ApiDataSource as t, SelectedItem as u };
155
+ //# sourceMappingURL=types-DrzvahW8.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-DrzvahW8.d.cts","names":[],"sources":["../src/data-sources/types.ts"],"mappings":";KACY,cAAA;AAAA,KAGA,gBAAA;AAAA,KAGA,aAAA;AAAA,UAQK,YAAA;EAdL;EAgBV,EAAA;EAbF;EAeE,aAAA,EAAe,aAAA;;EAEf,UAAA;IACE,KAAA;IACA,QAAA;IACA,IAAA;EAAA;EAjBQ;EAoBV,YAAA,GAAe,MAAA;AAAA;AAAA,UAGA,aAAA;EACf,IAAA;EAJe;EAMf,QAAA;;EAEA,MAAA;;EAEA,OAAA,GAAU,MAAA;;EAEV,IAAA;;;;;EAKA,UAAA;EAde;;;;EAmBf,WAAA;;;;;EAKA,SAAA;;EAEA,SAAA,GAAY,MAAA;;;;;EAKZ,eAAA;AAAA;AAAA,UAGe,gBAAA;EACf,IAAA;EAEe;EAAf,aAAA,EAAe,YAAA;;;;;EAKf,WAAA;;;AAaF;;EARE,SAAA;EAWY;;;;EANZ,eAAA;AAAA;AAAA,UAGe,gBAAA;EACf,IAAA;;EAEA,UAAA,EAAY,gBAAA;;EAEZ,UAAA;EAkBA;EAhBA,UAAA;IACE,KAAA;IACA,QAAA;EAAA;;;;EAKF,WAAA;;;;EAIA,SAAA;EAS0D;AAE5D;;;EANE,eAAA;AAAA;AAAA,KAIU,UAAA,GAAa,aAAA,GAAgB,gBAAA,GAAmB,gBAAA;AAAA,UAE3C,gBAAA;;EAEf,OAAA,EAAS,UAAA;;EAET,OAAA;IASE,8DAPA,YAAA;EAAA;EASA;EANF,KAAA;IAWe,6CATb,QAAA,GAAW,MAAA,mBASE;IAPb,UAAA,WASF;IAPE,UAAA;EAAA;AAAA;AAgBJ;AAAA,UAXiB,UAAA;EACf,EAAA;EACA,KAAA;EACA,QAAA;AAAA;;UAQe,iBAAA;;EAEf,QAAA;;EAEA,UAAA;;EAEA,MAAA,EAAQ,WAAA;;EAER,OAAA;;EAEA,aAAA,UAAuB,MAAA;EAEX;EAAZ,SAAA,GAAY,MAAA;AAAA;;KAIF,WAAA,WAAsB,UAAA,GAAa,UAAA,KAC7C,MAAA,EAAQ,CAAA,EACR,OAAA,EAAS,iBAAA,KACN,OAAA;;KAGO,eAAA,IACV,IAAA,WACA,MAAA,GAAS,UAAA,EACT,OAAA,GAAU,iBAAA;;UAIK,kBAAA;EACf,QAAA,EAAU,MAAA,CAAO,cAAA,EAAgB,WAAA;EACjC,YAAA,EAAc,MAAA,SAAe,eAAA;AAAA;;UAId,gBAAA;;EAEf,IAAA,EAAM,CAAA;;EAEN,SAAA;;EAEA,KAAA,EAAO,KAAA;EAtBJ;EAwBH,OAAA;AAAA"}