@acuteinfo/common-base 1.2.83 → 1.2.85

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 (64) hide show
  1. package/dist/components/common/arrayField/style.d.ts +1 -1
  2. package/dist/components/common/textField/textField.d.ts +3 -3
  3. package/dist/components/common/universal-color-picker/UniversalColorPicker.d.ts +4 -0
  4. package/dist/components/common/universal-color-picker/UniversalColorPicker.types.d.ts +8 -0
  5. package/dist/components/common/universal-color-picker/hooks/useLocalPickerState.d.ts +4 -0
  6. package/dist/components/common/universal-color-picker/index.d.ts +3 -0
  7. package/dist/components/custom-hooks/useDebouncedValue.d.ts +9 -0
  8. package/dist/components/dataTable/columnVisibility.d.ts +1 -2
  9. package/dist/components/dataTable/styledComponents/slider.d.ts +1 -1
  10. package/dist/components/dataTable/tableFilterComponent.d.ts +1 -2
  11. package/dist/components/derived/index.d.ts +1 -0
  12. package/dist/components/derived/refreshIconButton/index.d.ts +2 -0
  13. package/dist/components/derived/refreshIconButton/refreshIconButton.d.ts +9 -0
  14. package/dist/components/styledComponent/button/button.d.ts +1 -0
  15. package/dist/components/styledComponent/input/input.d.ts +1 -1
  16. package/dist/components/styledComponent/inputLabel/inputLabel.d.ts +1 -1
  17. package/dist/components/styledComponent/tab/tab.d.ts +1 -1
  18. package/dist/components/styledComponent/tabs/tabs.d.ts +1 -1
  19. package/dist/components/styledComponent/textfield/textField.d.ts +1 -3
  20. package/dist/components/styledComponent/tooltip/htmlTooltip.d.ts +1 -1
  21. package/dist/components/styledComponent/tooltip/tooltip.d.ts +1 -1
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.js +19 -19
  24. package/dist/index.js.map +1 -1
  25. package/dist/packages/form/index.d.ts +0 -1
  26. package/dist/packages/form/src/atoms.d.ts +49 -16
  27. package/dist/packages/form/src/field.d.ts +2 -1
  28. package/dist/packages/form/src/types.d.ts +6 -0
  29. package/dist/theme/components/ThemeToggleButton.d.ts +9 -0
  30. package/dist/theme/examples/ThemeUsageExample.d.ts +3 -0
  31. package/dist/theme/generateTheme/buildPalette.d.ts +137 -0
  32. package/dist/theme/generateTheme/componentOverrides/appBar.d.ts +14 -0
  33. package/dist/theme/generateTheme/componentOverrides/button.d.ts +4 -0
  34. package/dist/theme/generateTheme/componentOverrides/cssBaseline.d.ts +10 -0
  35. package/dist/theme/generateTheme/componentOverrides/index.d.ts +4 -0
  36. package/dist/theme/generateTheme/componentOverrides/input.d.ts +3 -0
  37. package/dist/theme/generateTheme/componentOverrides/navigation.d.ts +3 -0
  38. package/dist/theme/generateTheme/componentOverrides/surfaces.d.ts +4 -0
  39. package/dist/theme/generateTheme/componentOverrides/tabs.d.ts +3 -0
  40. package/dist/theme/generateTheme/index.d.ts +8 -0
  41. package/dist/theme/generateTheme/resolveColors.d.ts +30 -0
  42. package/dist/theme/generateTheme/types.d.ts +18 -0
  43. package/dist/theme/generators/borderGenerator.d.ts +13 -0
  44. package/dist/theme/generators/gradientGenerator.d.ts +14 -0
  45. package/dist/theme/generators/neutralPaletteGenerator.d.ts +12 -0
  46. package/dist/theme/generators/radiusGenerator.d.ts +12 -0
  47. package/dist/theme/generators/semanticGenerator.d.ts +22 -0
  48. package/dist/theme/generators/shadowGenerator.d.ts +19 -0
  49. package/dist/theme/generators/spacingGenerator.d.ts +23 -0
  50. package/dist/theme/index.d.ts +19 -0
  51. package/dist/theme/legacy/syncLegacyVars.d.ts +2 -0
  52. package/dist/theme/legacy/theme.d.ts +60 -0
  53. package/dist/theme/presets/presets.d.ts +10 -0
  54. package/dist/theme/providers/BaseThemeProvider.d.ts +18 -0
  55. package/dist/theme/providers/ColorModeContext.d.ts +21 -0
  56. package/dist/theme/types/ThemeConfig.d.ts +12 -0
  57. package/dist/theme/types/themeExtensions.d.ts +227 -0
  58. package/dist/theme/utils/accessibility.d.ts +49 -0
  59. package/dist/theme/utils/colorUtils.d.ts +70 -0
  60. package/package.json +4 -3
  61. package/rollup.config.mjs +3 -3
  62. package/dist/components/dataTable/atoms/index.d.ts +0 -11
  63. package/dist/components/layoutReport/hooks/useDebouncedValue.d.ts +0 -12
  64. package/dist/packages/form/src/observer.d.ts +0 -1
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { PaletteMode } from "@mui/material";
3
+ import { LightPaletteTokens } from "../legacy/theme";
4
+ export interface ColorModeContextValue {
5
+ mode: PaletteMode;
6
+ toggleColorMode: () => void;
7
+ setColorMode: (mode: PaletteMode) => void;
8
+ }
9
+ /**
10
+ * Custom hook to safely access the ColorModeContext state.
11
+ */
12
+ export declare const useColorMode: () => ColorModeContextValue;
13
+ export interface ColorModeProviderProps {
14
+ children: React.ReactNode;
15
+ initialTokens?: LightPaletteTokens;
16
+ }
17
+ /**
18
+ * React Context Provider managing mode state ('light' | 'dark') and memoizing
19
+ * the generated MUI theme to avoid theme recalculations on unrelated renders.
20
+ */
21
+ export declare const ColorModeProvider: React.FC<ColorModeProviderProps>;
@@ -0,0 +1,12 @@
1
+ export interface ThemeConfig {
2
+ mode: "light" | "dark";
3
+ primary: string;
4
+ secondary: string;
5
+ background: string;
6
+ text: string;
7
+ success: string;
8
+ error: string;
9
+ warning: string;
10
+ info: string;
11
+ presetId?: string;
12
+ }
@@ -0,0 +1,227 @@
1
+ import "@mui/material/styles";
2
+ declare module "@mui/material/styles" {
3
+ interface Theme {
4
+ customShadows?: any;
5
+ customSpacing?: any;
6
+ surfaces?: any;
7
+ states?: any;
8
+ customTransitions?: any;
9
+ }
10
+ interface ThemeOptions {
11
+ customShadows?: any;
12
+ customSpacing?: any;
13
+ surfaces?: any;
14
+ states?: any;
15
+ customTransitions?: any;
16
+ }
17
+ interface PaletteColor {
18
+ lighter?: string;
19
+ darker?: string;
20
+ }
21
+ interface SimplePaletteColorOptions {
22
+ lighter?: string;
23
+ darker?: string;
24
+ }
25
+ interface Palette {
26
+ surface: {
27
+ page: string;
28
+ card: string;
29
+ elevated: string;
30
+ sidebar: string;
31
+ header: string;
32
+ footer: string;
33
+ input: string;
34
+ tabs: string;
35
+ };
36
+ border: {
37
+ subtle: string;
38
+ default: string;
39
+ strong: string;
40
+ primary: string;
41
+ secondary: string;
42
+ disabled: string;
43
+ error: string;
44
+ success: string;
45
+ warning: string;
46
+ info: string;
47
+ };
48
+ state: {
49
+ hover: string;
50
+ selected: string;
51
+ focus: string;
52
+ pressed: string;
53
+ };
54
+ greyPalette: {
55
+ [key: number]: string;
56
+ };
57
+ shadow: {
58
+ input: string;
59
+ card: string;
60
+ popover: string;
61
+ dialog: string;
62
+ paper: string;
63
+ alert: string;
64
+ default: string;
65
+ tooltip: string;
66
+ button: string;
67
+ table: string;
68
+ form: string;
69
+ box: string;
70
+ grid: string;
71
+ stack: string;
72
+ container: string;
73
+ stepper: string;
74
+ tabs: string;
75
+ };
76
+ radius: {
77
+ xs: string;
78
+ sm: string;
79
+ md: string;
80
+ lg: string;
81
+ xl: string;
82
+ pill: string;
83
+ dialog: string;
84
+ card: string;
85
+ button: string;
86
+ input: string;
87
+ };
88
+ gradient: {
89
+ primary: string;
90
+ secondary: string;
91
+ primaryToSecondary: string;
92
+ subtle: string;
93
+ glow: string;
94
+ button: string;
95
+ buttonHover: string;
96
+ success: string;
97
+ error: string;
98
+ warning: string;
99
+ info: string;
100
+ };
101
+ space: {
102
+ none: string;
103
+ hairline: string;
104
+ xxs: string;
105
+ xs: string;
106
+ sm: string;
107
+ md: string;
108
+ lg: string;
109
+ xl: string;
110
+ xxl: string;
111
+ xxxl: string;
112
+ huge: string;
113
+ appbar: string;
114
+ card: string;
115
+ container: string;
116
+ section: string;
117
+ compact: string;
118
+ relaxed: string;
119
+ };
120
+ transition: {
121
+ fast: string;
122
+ normal: string;
123
+ slow: string;
124
+ };
125
+ }
126
+ interface PaletteOptions {
127
+ surface?: {
128
+ page?: string;
129
+ card?: string;
130
+ elevated?: string;
131
+ sidebar?: string;
132
+ header?: string;
133
+ footer?: string;
134
+ input?: string;
135
+ tabs?: string;
136
+ };
137
+ border?: {
138
+ subtle?: string;
139
+ default?: string;
140
+ strong?: string;
141
+ primary?: string;
142
+ secondary?: string;
143
+ disabled?: string;
144
+ error?: string;
145
+ success?: string;
146
+ warning?: string;
147
+ info?: string;
148
+ };
149
+ state?: {
150
+ hover?: string;
151
+ selected?: string;
152
+ focus?: string;
153
+ pressed?: string;
154
+ };
155
+ greyPalette?: {
156
+ [key: number]: string;
157
+ };
158
+ shadow?: {
159
+ input?: string;
160
+ card?: string;
161
+ popover?: string;
162
+ dialog?: string;
163
+ paper?: string;
164
+ alert?: string;
165
+ default?: string;
166
+ tooltip?: string;
167
+ button?: string;
168
+ table?: string;
169
+ form?: string;
170
+ box?: string;
171
+ grid?: string;
172
+ stack?: string;
173
+ container?: string;
174
+ stepper?: string;
175
+ tabs?: string;
176
+ };
177
+ radius?: {
178
+ xs?: string;
179
+ sm?: string;
180
+ md?: string;
181
+ lg?: string;
182
+ xl?: string;
183
+ pill?: string;
184
+ dialog?: string;
185
+ card?: string;
186
+ button?: string;
187
+ input?: string;
188
+ };
189
+ gradient?: {
190
+ primary?: string;
191
+ secondary?: string;
192
+ primaryToSecondary?: string;
193
+ subtle?: string;
194
+ glow?: string;
195
+ button?: string;
196
+ buttonHover?: string;
197
+ success?: string;
198
+ error?: string;
199
+ warning?: string;
200
+ info?: string;
201
+ };
202
+ space?: {
203
+ none?: string;
204
+ hairline?: string;
205
+ xxs?: string;
206
+ xs?: string;
207
+ sm?: string;
208
+ md?: string;
209
+ lg?: string;
210
+ xl?: string;
211
+ xxl?: string;
212
+ xxxl?: string;
213
+ huge?: string;
214
+ appbar?: string;
215
+ card?: string;
216
+ container?: string;
217
+ section?: string;
218
+ compact?: string;
219
+ relaxed?: string;
220
+ };
221
+ transition?: {
222
+ fast?: string;
223
+ normal?: string;
224
+ slow?: string;
225
+ };
226
+ }
227
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Converts a hex color to its relative luminance.
3
+ * Based on WCAG 2.0 formulas.
4
+ */
5
+ export declare const getLuminance: (hex: string) => number;
6
+ /**
7
+ * Calculates the contrast ratio between two hex colors.
8
+ */
9
+ export declare const getContrastRatio: (foreground: string, background: string) => number;
10
+ /**
11
+ * Ensures the color is a valid 6-character hex. Returns a fallback if invalid.
12
+ */
13
+ export declare const validateHex: (hex: string, fallback?: string) => string;
14
+ /**
15
+ * Automatically calculates a highly readable text color (black or white)
16
+ * based on the background color's luminance.
17
+ */
18
+ export declare const getReadableContrastText: (backgroundHex: string) => string;
19
+ /**
20
+ * Validates and auto-corrects the text color against the background.
21
+ * If the contrast ratio is too low (e.g., < 4.5 for normal text),
22
+ * it returns a highly readable fallback.
23
+ */
24
+ export declare const ensureReadableContrast: (textColor: string, backgroundColor: string, minContrast?: number) => string;
25
+ /**
26
+ * Extracts hex colors from a CSS gradient string.
27
+ */
28
+ export declare const extractGradientColors: (gradientStr: string) => string[];
29
+ /**
30
+ * Calculates whether a gradient background is overall light or dark based on its
31
+ * first color luminance, returning an accessible text color (dark or light).
32
+ */
33
+ export declare const getGradientTextColor: (gradientStr: string, darkTextColor?: string, lightTextColor?: string) => string;
34
+ /**
35
+ * Iteratively adjusts the text color's HSL lightness to meet WCAG contrast
36
+ * requirements against the given background, while preserving the original hue.
37
+ *
38
+ * - Dark Mode: Iteratively lightens text by +2% L per step.
39
+ * - Light Mode: Iteratively darkens text by -2% L per step.
40
+ * - Max Iterations: 20 (~40% lightness delta cap).
41
+ * - Hard Fallback: If ratio is still < minRatio after 20 steps,
42
+ * returns #F8FAFC (dark mode) or #0F172A (light mode) to guarantee compliance.
43
+ *
44
+ * @param textHex – The candidate text hex color to adjust.
45
+ * @param bgHex – The resolved background hex color to contrast against.
46
+ * @param mode – Current theme mode ('light' | 'dark').
47
+ * @param minRatio – Minimum WCAG contrast ratio target (default: 4.5 for AA).
48
+ */
49
+ export declare const ensureIterativeContrast: (textHex: string, bgHex: string, mode: "light" | "dark", minRatio?: number) => string;
@@ -0,0 +1,70 @@
1
+ export type ColorCallback = (error: Error | null, result: string) => void;
2
+ /**
3
+ * Reverses contrast of any color dynamically, maintaining identical format output.
4
+ * Returns "inherit" if color format is invalid or unavailable.
5
+ */
6
+ export declare function reverseColorContrast(colorInput?: string | null, callback?: ColorCallback): string;
7
+ /**
8
+ * Utility to tweak brightness slightly.
9
+ */
10
+ export declare const adjustColor: (color: string, percent: number) => string;
11
+ /**
12
+ * Automatically converts any dynamic light color into a rich,
13
+ * desaturated dark mode equivalent (maintaining the color's hue tint).
14
+ */
15
+ export declare const invertToDarkBg: (color: string) => string;
16
+ /**
17
+ * Deterministically derives a softer, lighter shade of a light mode color
18
+ * for dark mode surfaces to prevent visual vibration and ensure accessibility.
19
+ */
20
+ export declare const lightenColorForDarkMode: (color: string, percent?: number) => string;
21
+ /**
22
+ * Shifts the HSL lightness of a color by an absolute amount.
23
+ * Positive values lighten, negative values darken.
24
+ * Preserves hue and saturation. Clamps result to [0, 100].
25
+ *
26
+ * Unlike `adjustColor` (additive RGB), this operates in perceptual HSL space,
27
+ * ensuring consistent luminance shifts regardless of the input color's brightness.
28
+ */
29
+ export declare const shiftLightness: (hex: string, deltaL: number) => string;
30
+ /**
31
+ * Scales a base reference color into an ultra-light tint for Light Mode (e.g. ~96% lightness)
32
+ * or a deep dark canvas shade for Dark Mode (e.g. ~5% lightness) preserving the original hue.
33
+ */
34
+ export declare const deriveScaledBackground: (baseHex: string, mode: "light" | "dark") => {
35
+ defaultBg: string;
36
+ paperBg: string;
37
+ };
38
+ /**
39
+ * Returns the perceived HSL lightness (0–100) of a hex color.
40
+ * Used for conditional branching in the mode-adaptation pipeline
41
+ * (e.g., "is this background too light for dark mode?").
42
+ */
43
+ export declare const getPerceivedLightness: (hex: string) => number;
44
+ /**
45
+ * Adapts a brand color (primary/secondary) for dark mode surfaces.
46
+ *
47
+ * Lightens the color by `deltaL` (default 30) in HSL space and slightly
48
+ * desaturates it (cap at 85% S) to prevent optical vibration against
49
+ * dark backgrounds while preserving hue identity.
50
+ *
51
+ * Skips adjustment if the color is already light enough (L ≥ 60).
52
+ */
53
+ export declare const adaptBrandColorForDark: (hex: string, deltaL?: number) => string;
54
+ /**
55
+ * Adapts a brand color (primary/secondary) for light mode surfaces.
56
+ *
57
+ * Darkens the color by `deltaL` (default 20) in HSL space to ensure
58
+ * crisp contrast against light backgrounds. Preserves hue and saturation.
59
+ *
60
+ * Skips adjustment if the color is already dark enough (L ≤ 40).
61
+ */
62
+ export declare const adaptBrandColorForLight: (hex: string, deltaL?: number) => string;
63
+ /**
64
+ * Converts any dark color into a light mode background equivalent.
65
+ * This is the inverse of `invertToDarkBg()`.
66
+ *
67
+ * Preserves the original hue tint while expanding lightness to ~96%
68
+ * and capping saturation at 20% for a soft off-white result.
69
+ */
70
+ export declare const adaptToLightBg: (color: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acuteinfo/common-base",
3
- "version": "1.2.83",
3
+ "version": "1.2.85",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "react",
@@ -32,6 +32,8 @@
32
32
  "dayjs": "^1.11.9",
33
33
  "history": "^5.0.0",
34
34
  "i18next": "^23.12.2",
35
+ "jotai": "^2.17.1",
36
+ "jotai-family": "^1.0.1",
35
37
  "js2xmlparser": "^5.0.0",
36
38
  "json-rules-engine": "^5.0.4",
37
39
  "jspdf": "^2.5.1",
@@ -56,7 +58,6 @@
56
58
  "react-to-print": "^2.14.7",
57
59
  "react-virtuoso": "^4.13.0",
58
60
  "react-window": "^1.8.6",
59
- "recoil": "^0.7.7",
60
61
  "regenerator-runtime": "^0.14.1",
61
62
  "typeface-roboto": "^0.0.75",
62
63
  "typescript": "^4.2.2",
@@ -132,4 +133,4 @@
132
133
  "react": "^18.2.0",
133
134
  "react-dom": "^18.2.0"
134
135
  }
135
- }
136
+ }
package/rollup.config.mjs CHANGED
@@ -37,7 +37,6 @@ export default defineConfig({
37
37
  "json-rules-engine",
38
38
  "pako",
39
39
  "xlsx",
40
- "recoil",
41
40
  "react-query",
42
41
  "react-number-format",
43
42
  "react-imask",
@@ -52,8 +51,9 @@ export default defineConfig({
52
51
  "match-sorter",
53
52
  "axios",
54
53
  "@koale/useworker",
55
- "ag-grid-community",
56
- "ag-grid-react",
54
+ /^ag-grid-community/,
55
+ /^ag-grid-react/,
56
+ /^jotai/,
57
57
  ],
58
58
  plugins: [
59
59
  resolve(),
@@ -1,11 +0,0 @@
1
- export interface QueryType {
2
- accessor: string;
3
- condition: string;
4
- value: any[] | any;
5
- }
6
- export interface SubscriptionType {
7
- [key: string]: string[] | string | undefined;
8
- }
9
- export declare const filterAtom: (param: string) => import("recoil").RecoilState<QueryType | null>;
10
- export declare const filtersAtom: (param: string) => import("recoil").RecoilState<QueryType[] | null>;
11
- export declare const subscribeToFilterChange: (param: SubscriptionType) => import("recoil").RecoilValueReadOnly<QueryType[]>;
@@ -1,12 +0,0 @@
1
- /**
2
- * A custom hook that returns a debounced version of the input value.
3
- * The debounced value updates after a specified delay, which is useful
4
- * for scenarios like search inputs where you want to limit the number
5
- * of updates or API calls while the user is typing.
6
- *
7
- * @param {string} value - The input value that you want to debounce.
8
- * @param {number} [delay=500] - The amount of time (in milliseconds) to wait
9
- * before updating the debounced value. Defaults to 500 milliseconds.
10
- * @returns {string} The debounced value that updates after the specified delay.
11
- */
12
- export declare const useDebouncedValue: (value: string, delay?: number) => string;
@@ -1 +0,0 @@
1
- export declare const TimeTravelObserver: () => import("react/jsx-runtime").JSX.Element;