@temboplus/frontend-react-core 0.1.3-beta.1 → 0.1.3-beta.2

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.
@@ -0,0 +1,398 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { ConfigProvider } from 'antd';
4
+ import { buildColorPalette, } from './colors.js';
5
+ import { buildUIConstants, } from './constants.js';
6
+ /**
7
+ * Internal React context carrying the active Tembo theme
8
+ */
9
+ const TemboThemeContext = React.createContext({
10
+ colors: buildColorPalette(),
11
+ constants: buildUIConstants(),
12
+ });
13
+ /**
14
+ * Build Ant Design theme configuration from Tembo tokens
15
+ * Maps semantic Tembo color palette and constants to Ant Design's token system
16
+ *
17
+ * @param palette - Complete Tembo color palette
18
+ * @param constants - Complete Tembo UI constants
19
+ * @param overrides - Optional raw Ant Design theme overrides
20
+ * @returns Ant Design ThemeConfig
21
+ */
22
+ const buildAntDThemeConfig = (palette, constants, overrides) => {
23
+ var _a, _b;
24
+ const baseTokens = {
25
+ // Primary colors
26
+ colorPrimary: palette.primary.main,
27
+ colorPrimaryHover: palette.primary.hover,
28
+ colorPrimaryActive: palette.primary.active,
29
+ colorPrimaryBorder: palette.primary.main,
30
+ // Text colors
31
+ colorText: palette.text.primary,
32
+ colorTextSecondary: palette.text.secondary,
33
+ colorTextTertiary: palette.text.tertiary,
34
+ colorTextQuaternary: palette.text.quaternary,
35
+ colorTextDisabled: palette.text.disabled,
36
+ // Background colors
37
+ colorBgBase: palette.surface.background,
38
+ colorBgContainer: palette.surface.main,
39
+ colorBgElevated: palette.surface.elevated,
40
+ colorBgLayout: palette.surface.background,
41
+ colorBgSpotlight: palette.surface.hover,
42
+ // Border colors
43
+ colorBorder: palette.border.main,
44
+ colorBorderSecondary: palette.border.light,
45
+ colorSplit: palette.border.divider,
46
+ // Success colors
47
+ colorSuccess: palette.success.main,
48
+ colorSuccessBg: palette.success.bg,
49
+ colorSuccessBorder: palette.success.border,
50
+ colorSuccessText: palette.success.text,
51
+ // Error colors
52
+ colorError: palette.error.main,
53
+ colorErrorBg: palette.error.bg,
54
+ colorErrorBorder: palette.error.border,
55
+ colorErrorText: palette.error.text,
56
+ // Warning colors
57
+ colorWarning: palette.warning.main,
58
+ colorWarningBg: palette.warning.bg,
59
+ colorWarningBorder: palette.warning.border,
60
+ colorWarningText: palette.warning.text,
61
+ // Info colors
62
+ colorInfo: palette.info.main,
63
+ colorInfoBg: palette.info.bg,
64
+ colorInfoBorder: palette.info.border,
65
+ colorInfoText: palette.info.text,
66
+ // Link colors
67
+ colorLink: palette.utility.link,
68
+ colorLinkHover: palette.utility.linkHover,
69
+ colorLinkActive: palette.utility.linkActive,
70
+ // Border radius
71
+ borderRadius: constants.radius.base,
72
+ borderRadiusLG: constants.radius.lg,
73
+ borderRadiusSM: constants.radius.sm,
74
+ borderRadiusXS: 6,
75
+ // Shadows
76
+ boxShadow: constants.shadow.base,
77
+ boxShadowSecondary: constants.shadow.card,
78
+ boxShadowTertiary: constants.shadow.elevated,
79
+ // Typography
80
+ fontFamily: constants.typography.fontFamily,
81
+ fontSize: constants.typography.fontSize.base,
82
+ fontSizeHeading1: 38,
83
+ fontSizeHeading2: 30,
84
+ fontSizeHeading3: 24,
85
+ fontSizeHeading4: 20,
86
+ fontSizeHeading5: constants.typography.fontSize.lg,
87
+ fontWeightStrong: constants.typography.fontWeight.medium,
88
+ lineHeight: constants.typography.lineHeight.base,
89
+ lineHeightHeading1: 1.21,
90
+ lineHeightHeading2: 1.27,
91
+ lineHeightHeading3: 1.33,
92
+ lineHeightHeading4: 1.4,
93
+ lineHeightHeading5: 1.5,
94
+ };
95
+ const baseTheme = {
96
+ token: baseTokens,
97
+ components: {
98
+ Button: {
99
+ colorPrimary: palette.components.button.primary.bg,
100
+ colorPrimaryHover: palette.components.button.primary.hover,
101
+ colorPrimaryActive: palette.action.active,
102
+ colorPrimaryBorder: palette.components.button.primary.bg,
103
+ primaryColor: palette.components.button.primary.text,
104
+ colorBorder: palette.components.button.default.border,
105
+ colorBgContainer: palette.components.button.default.bg,
106
+ colorText: palette.components.button.default.text,
107
+ defaultBg: palette.components.button.default.bg,
108
+ defaultBorderColor: palette.components.button.default.border,
109
+ defaultColor: palette.components.button.default.text,
110
+ primaryShadow: 'none',
111
+ defaultShadow: 'none',
112
+ dangerShadow: 'none',
113
+ fontWeight: constants.typography.fontWeight.medium,
114
+ controlHeight: 32,
115
+ paddingContentHorizontal: constants.spacing.lg,
116
+ borderRadius: constants.radius.button,
117
+ borderRadiusLG: constants.radius.button,
118
+ borderRadiusSM: constants.radius.sm + 8,
119
+ },
120
+ Input: {
121
+ colorBgContainer: palette.components.input.bg,
122
+ colorBorder: palette.components.input.border,
123
+ hoverBorderColor: palette.components.input.borderHover,
124
+ activeBorderColor: palette.components.input.borderFocus,
125
+ colorPrimaryHover: palette.components.input.borderFocus,
126
+ colorTextPlaceholder: palette.components.input.placeholder,
127
+ borderRadius: constants.radius.input,
128
+ borderRadiusLG: constants.radius.base,
129
+ borderRadiusSM: constants.radius.sm,
130
+ },
131
+ Select: {
132
+ colorBgContainer: palette.components.input.bg,
133
+ colorBorder: palette.components.input.border,
134
+ colorTextPlaceholder: palette.components.input.placeholder,
135
+ colorPrimaryHover: palette.action.main,
136
+ hoverBorderColor: palette.components.input.borderHover,
137
+ activeBorderColor: palette.components.input.borderFocus,
138
+ optionSelectedBg: palette.action.main,
139
+ optionSelectedColor: palette.action.contrast,
140
+ optionActiveBg: palette.surface.hover,
141
+ colorBgElevated: palette.utility.white,
142
+ controlItemBgHover: palette.surface.hover,
143
+ boxShadowSecondary: constants.shadow.elevated,
144
+ borderRadius: constants.radius.input,
145
+ borderRadiusLG: constants.radius.base,
146
+ borderRadiusSM: constants.radius.sm,
147
+ },
148
+ Checkbox: {
149
+ colorPrimary: palette.action.main,
150
+ colorPrimaryHover: palette.action.hover,
151
+ colorBorder: palette.border.strong,
152
+ borderRadiusSM: 6,
153
+ },
154
+ Radio: {
155
+ colorPrimary: palette.action.main,
156
+ colorPrimaryHover: palette.action.hover,
157
+ colorBorder: palette.border.strong,
158
+ },
159
+ Switch: {
160
+ colorPrimary: palette.action.main,
161
+ colorPrimaryHover: palette.action.hover,
162
+ colorTextQuaternary: palette.text.quaternary,
163
+ },
164
+ Form: {
165
+ labelColor: palette.text.primary,
166
+ labelRequiredMarkColor: palette.error.main,
167
+ labelFontSize: constants.typography.fontSize.base,
168
+ itemMarginBottom: constants.spacing.lg,
169
+ },
170
+ DatePicker: {
171
+ colorBgContainer: palette.components.input.bg,
172
+ colorBorder: palette.components.input.border,
173
+ hoverBorderColor: palette.components.input.borderHover,
174
+ activeBorderColor: palette.components.input.borderFocus,
175
+ colorPrimary: palette.action.main,
176
+ borderRadius: constants.radius.input,
177
+ },
178
+ InputNumber: {
179
+ borderRadius: constants.radius.input,
180
+ },
181
+ Table: {
182
+ colorBgContainer: palette.components.table.bg,
183
+ headerBg: palette.components.table.headerBg,
184
+ headerColor: palette.components.table.headerText,
185
+ borderColor: palette.components.table.border,
186
+ headerSplitColor: palette.components.table.border,
187
+ rowHoverBg: palette.components.table.rowHover,
188
+ rowSelectedBg: palette.action.light,
189
+ rowSelectedHoverBg: palette.action.lighter,
190
+ colorText: palette.text.primary,
191
+ colorTextHeading: palette.text.primary,
192
+ borderRadius: constants.radius.base,
193
+ borderRadiusLG: constants.radius.lg,
194
+ },
195
+ Card: {
196
+ colorBgContainer: palette.surface.main,
197
+ colorBorder: palette.border.main,
198
+ colorBorderSecondary: palette.border.light,
199
+ boxShadowTertiary: constants.shadow.card,
200
+ borderRadius: constants.radius.card,
201
+ borderRadiusLG: constants.radius.lg + 4,
202
+ },
203
+ Statistic: {
204
+ contentFontSize: 24,
205
+ colorTextHeading: palette.text.primary,
206
+ },
207
+ Descriptions: {
208
+ labelBg: palette.surface.hover,
209
+ colorTextSecondary: palette.text.secondary,
210
+ itemPaddingBottom: constants.spacing.md,
211
+ },
212
+ Badge: {
213
+ colorError: palette.error.main,
214
+ colorSuccess: palette.success.main,
215
+ colorInfo: palette.info.main,
216
+ colorInfoBg: palette.info.bg,
217
+ borderRadiusSM: constants.radius.input,
218
+ },
219
+ Tag: {
220
+ colorBorder: palette.border.main,
221
+ defaultBg: palette.surface.hover,
222
+ borderRadiusSM: constants.radius.sm,
223
+ },
224
+ Timeline: {
225
+ dotBg: palette.surface.main,
226
+ tailColor: palette.border.main,
227
+ },
228
+ Alert: {
229
+ colorSuccessBg: palette.success.bg,
230
+ colorSuccessBorder: palette.success.border,
231
+ colorErrorBg: palette.error.bg,
232
+ colorErrorBorder: palette.error.border,
233
+ colorWarningBg: palette.warning.bg,
234
+ colorWarningBorder: palette.warning.border,
235
+ colorInfoBg: palette.info.bg,
236
+ colorInfoBorder: palette.info.border,
237
+ borderRadiusLG: constants.radius.base,
238
+ },
239
+ Modal: {
240
+ contentBg: palette.surface.elevated,
241
+ headerBg: palette.surface.elevated,
242
+ colorBgMask: 'rgba(0, 0, 0, 0.45)',
243
+ borderRadiusLG: constants.radius.lg,
244
+ },
245
+ Drawer: {
246
+ colorBgElevated: palette.surface.elevated,
247
+ colorBgMask: 'rgba(0, 0, 0, 0.45)',
248
+ borderRadiusLG: constants.radius.lg,
249
+ },
250
+ Notification: {
251
+ colorBgElevated: palette.utility.white,
252
+ borderRadiusLG: constants.radius.base,
253
+ },
254
+ Message: {
255
+ contentBg: palette.utility.white,
256
+ borderRadiusLG: constants.radius.base,
257
+ },
258
+ Spin: {
259
+ colorPrimary: palette.primary.main,
260
+ },
261
+ Progress: {
262
+ colorSuccess: palette.success.main,
263
+ colorError: palette.error.main,
264
+ defaultColor: palette.primary.main,
265
+ borderRadius: 100,
266
+ },
267
+ Skeleton: {
268
+ colorFill: palette.neutral[200],
269
+ colorFillContent: palette.neutral[100],
270
+ borderRadiusSM: constants.radius.sm,
271
+ },
272
+ Menu: {
273
+ itemBg: 'transparent',
274
+ itemColor: palette.text.primary,
275
+ itemHoverBg: palette.surface.hover,
276
+ itemSelectedBg: palette.action.lighter,
277
+ itemSelectedColor: palette.action.main,
278
+ itemActiveBg: palette.action.lighter,
279
+ subMenuItemBg: 'transparent',
280
+ darkItemBg: palette.components.sidebar.bg,
281
+ darkSubMenuItemBg: palette.components.sidebar.bg,
282
+ darkItemColor: palette.components.sidebar.text,
283
+ darkItemHoverBg: palette.components.sidebar.hover,
284
+ darkItemSelectedBg: palette.components.sidebar.selected,
285
+ darkItemSelectedColor: palette.primary.contrast,
286
+ borderRadius: constants.radius.input,
287
+ borderRadiusLG: constants.radius.base,
288
+ },
289
+ Breadcrumb: {
290
+ linkColor: palette.utility.link,
291
+ linkHoverColor: palette.utility.linkHover,
292
+ itemColor: palette.text.secondary,
293
+ lastItemColor: palette.text.primary,
294
+ separatorColor: palette.text.tertiary,
295
+ borderRadiusSM: 6,
296
+ },
297
+ Pagination: {
298
+ colorPrimary: palette.primary.main,
299
+ colorPrimaryHover: palette.primary.hover,
300
+ itemActiveBg: palette.primary.main,
301
+ borderRadius: constants.radius.sm,
302
+ },
303
+ Steps: {
304
+ colorPrimary: palette.action.main,
305
+ colorText: palette.text.secondary,
306
+ colorTextDescription: palette.text.tertiary,
307
+ borderRadiusSM: 100,
308
+ },
309
+ Tabs: {
310
+ colorPrimary: palette.action.main,
311
+ colorBorderSecondary: palette.border.main,
312
+ itemColor: palette.text.secondary,
313
+ itemHoverColor: palette.action.hover,
314
+ itemSelectedColor: palette.action.main,
315
+ inkBarColor: palette.action.main,
316
+ borderRadiusSM: constants.radius.sm,
317
+ },
318
+ Layout: {
319
+ colorBgBody: palette.surface.background,
320
+ colorBgHeader: palette.utility.white,
321
+ colorBgTrigger: palette.components.sidebar.bg,
322
+ siderBg: palette.components.sidebar.bg,
323
+ headerBg: palette.utility.white,
324
+ borderRadiusLG: 0,
325
+ },
326
+ Divider: {
327
+ colorSplit: palette.border.divider,
328
+ },
329
+ Typography: {
330
+ colorText: palette.text.primary,
331
+ colorTextSecondary: palette.text.secondary,
332
+ colorTextDescription: palette.text.tertiary,
333
+ },
334
+ Tooltip: {
335
+ colorBgSpotlight: palette.neutral[900],
336
+ colorTextLightSolid: palette.utility.white,
337
+ borderRadius: constants.radius.sm,
338
+ },
339
+ Popover: {
340
+ colorBgElevated: palette.utility.white,
341
+ borderRadiusLG: constants.radius.base,
342
+ },
343
+ Dropdown: {
344
+ boxShadowSecondary: constants.shadow.dropdown,
345
+ },
346
+ Calendar: {
347
+ colorBgContainer: palette.utility.white,
348
+ colorPrimary: palette.action.main,
349
+ borderRadiusLG: constants.radius.base,
350
+ },
351
+ },
352
+ };
353
+ if (!overrides)
354
+ return baseTheme;
355
+ return Object.assign(Object.assign({}, baseTheme), { token: Object.assign(Object.assign({}, baseTheme.token), ((_a = overrides.token) !== null && _a !== void 0 ? _a : {})), components: Object.assign(Object.assign({}, baseTheme.components), ((_b = overrides.components) !== null && _b !== void 0 ? _b : {})) });
356
+ };
357
+ /**
358
+ * TemboThemeProvider
359
+ *
360
+ * Wraps your application to provide theming through React context and Ant Design's ConfigProvider.
361
+ * Merges default colors/constants with host overrides and configures Ant Design components.
362
+ *
363
+ * All child components can access theme values via the useTemboTheme() hook.
364
+ */
365
+ export const TemboThemeProvider = ({ children, colors, constants, themeOverrides, }) => {
366
+ const palette = React.useMemo(() => buildColorPalette(colors), [colors]);
367
+ const uiConstants = React.useMemo(() => buildUIConstants(constants), [constants]);
368
+ const theme = React.useMemo(() => buildAntDThemeConfig(palette, uiConstants, themeOverrides), [palette, uiConstants, themeOverrides]);
369
+ const contextValue = React.useMemo(() => ({
370
+ colors: palette,
371
+ constants: uiConstants,
372
+ }), [palette, uiConstants]);
373
+ return (_jsx(TemboThemeContext.Provider, { value: contextValue, children: _jsx(ConfigProvider, { theme: theme, children: children }) }));
374
+ };
375
+ /**
376
+ * Hook to access the active Tembo theme
377
+ *
378
+ * Returns the merged color palette and UI constants with any host overrides applied.
379
+ * Components should always use this hook instead of importing defaults directly.
380
+ *
381
+ * @returns Theme context containing colors and constants
382
+ *
383
+ * @example
384
+ * function MyComponent() {
385
+ * const { colors, constants } = useTemboTheme();
386
+ *
387
+ * return (
388
+ * <div style={{
389
+ * color: colors.text.primary,
390
+ * padding: constants.spacing.md,
391
+ * borderRadius: constants.radius.base
392
+ * }}>
393
+ * Themed content
394
+ * </div>
395
+ * );
396
+ * }
397
+ */
398
+ export const useTemboTheme = () => React.useContext(TemboThemeContext);
@@ -0,0 +1 @@
1
+ export * from "../features/input-validation";
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@temboplus/frontend-react-core",
3
- "version": "0.1.3-beta.1",
3
+ "version": "0.1.3-beta.2",
4
4
  "repository": "https://github.com/TemboPlus-Frontend/temboplus-frontend-react-core",
5
5
  "author": "Okello Gerald",
6
6
  "license": "ISC",
7
7
  "description": "A React UI library for TemboPlus applications, providing reusable components, validators, and utilities for building consistent react applications across the platform.",
8
8
  "scripts": {
9
- "build": "rollup -c rollup.config.js --configTsconfig tsconfig.json",
9
+ "build:types": "tsc --project tsconfig.json",
10
+ "build:js": "rollup -c rollup.config.js --configTsconfig tsconfig.json",
11
+ "build:fix-dts": "node ./scripts/fix-dts.js",
12
+ "build": "npm run build:types && npm run build:js && npm run build:fix-dts",
10
13
  "prepare": "npm run build",
11
14
  "dev": "npm run build -- --watch",
12
15
  "test": "vitest",