@groupeactual/design-tokens 1.7.10 → 2.0.0-beta.0

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 (108) hide show
  1. package/dist/cjs/index.js +23 -1
  2. package/dist/es/index.d.ts +244 -63
  3. package/dist/es/index.js +23 -1
  4. package/dist/types/helpers/theme.helper.d.ts +5 -0
  5. package/dist/types/index.d.ts +2 -0
  6. package/dist/types/interfaces/theme.interface.d.ts +242 -0
  7. package/dist/types/styled/Accordion.d.ts +4 -0
  8. package/dist/types/styled/Alert.d.ts +4 -0
  9. package/dist/types/styled/Autocomplete.d.ts +4 -0
  10. package/dist/types/styled/Breadcrumbs.d.ts +4 -0
  11. package/dist/types/styled/Button.d.ts +4 -0
  12. package/dist/types/styled/Checkbox.d.ts +4 -0
  13. package/dist/types/styled/Chip.d.ts +4 -0
  14. package/dist/types/styled/Divider.d.ts +4 -0
  15. package/dist/types/styled/FormHelperText.d.ts +4 -0
  16. package/dist/types/styled/FormLabel.d.ts +4 -0
  17. package/dist/types/styled/IconButton.d.ts +4 -0
  18. package/dist/types/styled/InputLabel.d.ts +4 -0
  19. package/dist/types/styled/MenuItem.d.ts +4 -0
  20. package/dist/types/styled/OutlinedInput.d.ts +4 -0
  21. package/dist/types/styled/PaginationItem.d.ts +4 -0
  22. package/dist/types/styled/Radio.d.ts +4 -0
  23. package/dist/types/styled/Select.d.ts +4 -0
  24. package/dist/types/styled/Switch.d.ts +4 -0
  25. package/dist/types/styled/Table.d.ts +4 -0
  26. package/dist/types/styled/TextField.d.ts +4 -0
  27. package/dist/types/styled/Typography.d.ts +4 -0
  28. package/dist/types/theme/theme.d.ts +4 -0
  29. package/package.json +22 -14
  30. package/src/helpers/theme.helper.ts +229 -0
  31. package/src/index.ts +2 -4
  32. package/src/interfaces/theme.interface.ts +270 -0
  33. package/src/styled/Accordion.ts +49 -0
  34. package/src/styled/Alert.ts +83 -0
  35. package/src/styled/Autocomplete.ts +24 -0
  36. package/src/styled/Breadcrumbs.ts +29 -0
  37. package/src/styled/Button.ts +109 -0
  38. package/src/styled/Checkbox.ts +81 -0
  39. package/src/styled/Chip.ts +201 -0
  40. package/src/styled/Divider.ts +24 -0
  41. package/src/styled/FormHelperText.ts +28 -0
  42. package/src/styled/FormLabel.ts +30 -0
  43. package/src/styled/IconButton.ts +161 -0
  44. package/src/styled/InputLabel.ts +30 -0
  45. package/src/styled/MenuItem.ts +73 -0
  46. package/src/styled/OutlinedInput.ts +89 -0
  47. package/src/styled/PaginationItem.ts +72 -0
  48. package/src/styled/Radio.ts +67 -0
  49. package/src/styled/Select.ts +38 -0
  50. package/src/styled/Switch.ts +62 -0
  51. package/src/styled/Table.ts +54 -0
  52. package/src/styled/TextField.ts +105 -0
  53. package/src/styled/Typography.ts +67 -0
  54. package/src/theme/theme.tsx +23 -0
  55. package/src/tokens/tokens.json +667 -6
  56. package/dist/types/src/css/accordionCss.d.ts +0 -3
  57. package/dist/types/src/css/bannerNotificationCss.d.ts +0 -3
  58. package/dist/types/src/css/breadcrumbsCss.d.ts +0 -3
  59. package/dist/types/src/css/buttonCss.d.ts +0 -3
  60. package/dist/types/src/css/chipCss.d.ts +0 -3
  61. package/dist/types/src/css/datatable/datatableCss.d.ts +0 -3
  62. package/dist/types/src/css/form/autoCompleteCss.d.ts +0 -3
  63. package/dist/types/src/css/form/checkboxCss.d.ts +0 -3
  64. package/dist/types/src/css/form/checkboxGroupCss.d.ts +0 -3
  65. package/dist/types/src/css/form/datePickerCss.d.ts +0 -3
  66. package/dist/types/src/css/form/radioCss.d.ts +0 -3
  67. package/dist/types/src/css/form/selectCss.d.ts +0 -3
  68. package/dist/types/src/css/form/snackbarCss.d.ts +0 -3
  69. package/dist/types/src/css/form/textFieldCss.d.ts +0 -3
  70. package/dist/types/src/css/iconButtonCss.d.ts +0 -3
  71. package/dist/types/src/css/index.d.ts +0 -20
  72. package/dist/types/src/css/linkCss.d.ts +0 -3
  73. package/dist/types/src/css/menuItemCss.d.ts +0 -3
  74. package/dist/types/src/css/paginationCss.d.ts +0 -3
  75. package/dist/types/src/css/switchCss.d.ts +0 -3
  76. package/dist/types/src/css/tooltipCss.d.ts +0 -2
  77. package/dist/types/src/helpers/theme.d.ts +0 -4
  78. package/dist/types/src/index.d.ts +0 -4
  79. package/dist/types/src/interfaces/theme.d.ts +0 -16
  80. package/dist/types/src/themes/tokens.d.ts +0 -167
  81. package/dist/types/src/useMaterialThemeTokens.d.ts +0 -6
  82. package/dist/types/src/useThemeTokens.d.ts +0 -6
  83. package/src/css/accordionCss.ts +0 -30
  84. package/src/css/bannerNotificationCss.ts +0 -52
  85. package/src/css/breadcrumbsCss.ts +0 -19
  86. package/src/css/buttonCss.ts +0 -80
  87. package/src/css/chipCss.ts +0 -142
  88. package/src/css/datatable/datatableCss.ts +0 -32
  89. package/src/css/form/autoCompleteCss.ts +0 -340
  90. package/src/css/form/checkboxCss.ts +0 -128
  91. package/src/css/form/checkboxGroupCss.ts +0 -42
  92. package/src/css/form/datePickerCss.ts +0 -117
  93. package/src/css/form/radioCss.ts +0 -102
  94. package/src/css/form/selectCss.ts +0 -233
  95. package/src/css/form/snackbarCss.ts +0 -42
  96. package/src/css/form/textFieldCss.ts +0 -188
  97. package/src/css/iconButtonCss.ts +0 -64
  98. package/src/css/index.ts +0 -20
  99. package/src/css/linkCss.ts +0 -15
  100. package/src/css/menuItemCss.ts +0 -31
  101. package/src/css/paginationCss.ts +0 -59
  102. package/src/css/switchCss.ts +0 -58
  103. package/src/css/tooltipCss.ts +0 -5
  104. package/src/helpers/theme.ts +0 -89
  105. package/src/interfaces/theme.ts +0 -34
  106. package/src/themes/tokens.ts +0 -169
  107. package/src/useMaterialThemeTokens.ts +0 -218
  108. package/src/useThemeTokens.ts +0 -30
@@ -0,0 +1,242 @@
1
+ import { ColorPartial } from '@mui/material/styles/createPalette';
2
+ export type Theme = 'Interne' | 'Externe';
3
+ export interface ThemeValue {
4
+ value: string;
5
+ type: string;
6
+ }
7
+ export type DefaultColors = {
8
+ [key: string]: ThemeValue;
9
+ };
10
+ export interface ThemeStructure {
11
+ 'DFLib-Variables/Interne'?: TokenStructure;
12
+ 'DFLib-Variables/Interne/defaultColors'?: CustomColors;
13
+ 'DFLib-Variables/Externe'?: TokenStructure;
14
+ }
15
+ export interface PaletteColors {
16
+ primary: ColorCategory;
17
+ secondary: ColorCategory;
18
+ error: ColorCategory;
19
+ warning: ColorCategory;
20
+ success: ColorCategory;
21
+ infos: ColorCategory;
22
+ text: TextColors;
23
+ background: Background;
24
+ border: Border;
25
+ action: {
26
+ hoverOpacity: ThemeValue;
27
+ };
28
+ }
29
+ export interface TokenStructure {
30
+ palette?: PaletteColors;
31
+ Typography?: TypographyTokens;
32
+ spacing?: SpacingTokens;
33
+ radius?: RadiusTokens;
34
+ }
35
+ export interface TextDefaultColors {
36
+ greyDark?: ThemeValue;
37
+ }
38
+ export interface BackgroundDefaultColors {
39
+ white?: ThemeValue;
40
+ greyXLight?: ThemeValue;
41
+ greyXDarkBgModal?: ThemeValue;
42
+ blueHoverEquivalence?: ThemeValue;
43
+ blueHoverOpacity12?: ThemeValue;
44
+ }
45
+ export interface BorderDefaultColors {
46
+ greyLightDefaultBorder?: ThemeValue;
47
+ }
48
+ export interface NotificationDefaultColors {
49
+ blueInfo?: ThemeValue;
50
+ greenSuccess?: ThemeValue;
51
+ orangeWarning?: ThemeValue;
52
+ redError?: ThemeValue;
53
+ }
54
+ export interface SecondaryDefaultColors {
55
+ blueDark?: ThemeValue;
56
+ blueMedium?: ThemeValue;
57
+ blueLight?: ThemeValue;
58
+ greenDark?: ThemeValue;
59
+ greenMedium?: ThemeValue;
60
+ green?: ThemeValue;
61
+ greenLight?: ThemeValue;
62
+ brown?: ThemeValue;
63
+ brownLight?: ThemeValue;
64
+ orangeLight?: ThemeValue;
65
+ yellow?: ThemeValue;
66
+ purpleDark?: ThemeValue;
67
+ purple?: ThemeValue;
68
+ pink?: ThemeValue;
69
+ pinkLight?: ThemeValue;
70
+ }
71
+ export interface CustomColors {
72
+ redActual?: ThemeValue;
73
+ blueClickable?: ThemeValue;
74
+ blueHoverClickable?: ThemeValue;
75
+ blueHoverOpacity12?: ThemeValue;
76
+ greyMediumInactive?: ThemeValue;
77
+ greyXDark?: ThemeValue;
78
+ textColors: TextDefaultColors;
79
+ backgroundColors: BackgroundDefaultColors;
80
+ borderColors: BorderDefaultColors;
81
+ notificationColors: NotificationDefaultColors;
82
+ secondaryColors: SecondaryDefaultColors;
83
+ }
84
+ export interface ColorCategory {
85
+ main?: ThemeValue;
86
+ mainChannel?: ThemeValue;
87
+ light?: ThemeValue;
88
+ 'light 2'?: ThemeValue;
89
+ 'light 3'?: ThemeValue;
90
+ lightChannel?: ThemeValue;
91
+ dark?: ThemeValue;
92
+ 'dark 2'?: ThemeValue;
93
+ 'dark 3'?: ThemeValue;
94
+ darkChannel?: ThemeValue;
95
+ 'secondary contrast text'?: ThemeValue;
96
+ 'primary contrast text'?: ThemeValue;
97
+ }
98
+ export interface TextColors {
99
+ primary: ThemeValue;
100
+ secondary: ThemeValue;
101
+ disabled: ThemeValue;
102
+ dark: ThemeValue;
103
+ }
104
+ export interface Background {
105
+ default: ThemeValue;
106
+ grey: ThemeValue;
107
+ }
108
+ export interface Border {
109
+ default: ThemeValue;
110
+ grey: ThemeValue;
111
+ }
112
+ export interface TypographyToken {
113
+ fontFamily: {
114
+ value: string;
115
+ type: string;
116
+ };
117
+ fontSize: {
118
+ value: string;
119
+ type: string;
120
+ };
121
+ LineHeight: {
122
+ value: string;
123
+ type: string;
124
+ };
125
+ fontWeight: {
126
+ value: string;
127
+ type: string;
128
+ };
129
+ }
130
+ export interface TypographyTokens {
131
+ h1: TypographyToken;
132
+ h2: TypographyToken;
133
+ h3: TypographyToken;
134
+ h4: TypographyToken;
135
+ h5: TypographyToken;
136
+ h6: TypographyToken;
137
+ subtitle1: TypographyToken;
138
+ subtitle2: TypographyToken;
139
+ body1: TypographyToken;
140
+ body2: TypographyToken;
141
+ button: TypographyToken;
142
+ caption: TypographyToken;
143
+ }
144
+ export interface SpacingTokens {
145
+ xxs: ThemeValue;
146
+ xs: ThemeValue;
147
+ sm: ThemeValue;
148
+ md: ThemeValue;
149
+ lg: ThemeValue;
150
+ xl: ThemeValue;
151
+ xxl: ThemeValue;
152
+ }
153
+ export interface RadiusTokens {
154
+ small: ThemeValue;
155
+ medium: ThemeValue;
156
+ large: ThemeValue;
157
+ xLarge: ThemeValue;
158
+ }
159
+ export type PaletteColorOptions = BasicPaletteColorOptions | ColorPartial;
160
+ export interface BasicPaletteColorOptions {
161
+ light?: string;
162
+ lightChannel?: string;
163
+ light2?: string;
164
+ light3?: string;
165
+ main: string;
166
+ mainChannel?: string;
167
+ dark?: string;
168
+ darkChannel?: string;
169
+ dark2?: string;
170
+ dark3?: string;
171
+ contrastText?: string;
172
+ }
173
+ export interface TextPaletteColorOptions {
174
+ secondary?: string;
175
+ primary?: string;
176
+ dark?: string;
177
+ disabled?: string;
178
+ }
179
+ export interface BackgroundPaletteColorOptions {
180
+ default?: string;
181
+ paper?: string;
182
+ grey?: string;
183
+ }
184
+ export interface BorderPaletteColorOptions {
185
+ default?: string;
186
+ grey?: string;
187
+ }
188
+ export interface PaletteDefaultColors {
189
+ redActual?: string;
190
+ blueClickable?: string;
191
+ blueHoverClickable?: string;
192
+ greyMediumInactive?: string;
193
+ greyXDark?: string;
194
+ greyDark?: string;
195
+ white?: string;
196
+ greyXLight?: string;
197
+ greyXDarkBgModal?: string;
198
+ blueHoverEquivalence?: string;
199
+ blueHoverOpacity12?: string;
200
+ greyLightDefaultBorder?: string;
201
+ blueInfo?: string;
202
+ greenSuccess?: string;
203
+ orangeWarning?: string;
204
+ redError?: string;
205
+ blueDark?: string;
206
+ blueMedium?: string;
207
+ blueLight?: string;
208
+ greenDark?: string;
209
+ greenMedium?: string;
210
+ green?: string;
211
+ greenLight?: string;
212
+ brown?: string;
213
+ brownLight?: string;
214
+ orangeLight?: string;
215
+ yellow?: string;
216
+ purpleDark?: string;
217
+ purple?: string;
218
+ pink?: string;
219
+ pinkLight?: string;
220
+ }
221
+ export interface PaletteDS extends PaletteDefaultColors {
222
+ primary?: BasicPaletteColorOptions;
223
+ secondary?: BasicPaletteColorOptions;
224
+ error?: BasicPaletteColorOptions;
225
+ warning?: BasicPaletteColorOptions;
226
+ success?: BasicPaletteColorOptions;
227
+ info?: BasicPaletteColorOptions;
228
+ text?: TextPaletteColorOptions;
229
+ border?: BorderPaletteColorOptions;
230
+ }
231
+ export interface MuiTokens {
232
+ palette: any;
233
+ typography: any;
234
+ }
235
+ export type SpacingArgument = number | string;
236
+ export interface Spacing {
237
+ (): string;
238
+ (_value: SpacingArgument): string;
239
+ (_topBottom: SpacingArgument, _rightLeft: SpacingArgument): string;
240
+ (_top: SpacingArgument, _rightLeft: SpacingArgument, _bottom: SpacingArgument): string;
241
+ (_top: SpacingArgument, _right: SpacingArgument, _bottom: SpacingArgument, _left: SpacingArgument): string;
242
+ }
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const Accordion: (spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default Accordion;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const Alert: (spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default Alert;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const Autocomplete: (_spacing: Spacing, _tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default Autocomplete;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const Breadcrumbs: (spacing: Spacing, _tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default Breadcrumbs;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const Button: (_spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default Button;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const Checkbox: (spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default Checkbox;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const Chip: (spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default Chip;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const Divider: (_spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default Divider;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const FormHelperText: (_spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default FormHelperText;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const FormLabel: (_spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default FormLabel;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const IconButton: (spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default IconButton;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const InputLabel: (spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default InputLabel;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const MenuItem: (spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default MenuItem;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const OutlinedInput: (spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default OutlinedInput;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const PaginationItem: (_spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default PaginationItem;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const Radio: (spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default Radio;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const Select: (spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default Select;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const Switch: (_spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default Switch;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const Table: (spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default Table;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { CustomColors, Spacing, TokenStructure } from '@/interfaces/theme.interface';
3
+ declare const TextField: (spacing: Spacing, tokens: TokenStructure & CustomColors) => Components<unknown>;
4
+ export default TextField;
@@ -0,0 +1,4 @@
1
+ import { Components } from '@mui/material';
2
+ import { Spacing } from '@/interfaces/theme.interface';
3
+ declare const Typography: (_spacing: Spacing) => Components<unknown>;
4
+ export default Typography;
@@ -0,0 +1,4 @@
1
+ import { PaletteMode, ThemeOptions } from '@mui/material';
2
+ import { Theme } from '@/interfaces/theme.interface';
3
+ declare const theme: (themeName: Theme, mode?: PaletteMode) => ThemeOptions;
4
+ export default theme;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groupeactual/design-tokens",
3
- "version": "1.7.10",
3
+ "version": "2.0.0-beta.0",
4
4
  "type": "module",
5
5
  "description": "A simple library to manage design tokens",
6
6
  "main": "dist/cjs/index.js",
@@ -11,29 +11,37 @@
11
11
  "src"
12
12
  ],
13
13
  "devDependencies": {
14
- "prettier": "^3.4.1",
15
- "eslint": "^9.16.0",
16
- "eslint-config-prettier": "^9.1.0",
14
+ "eslint": "^9.24.0",
15
+ "eslint-config-prettier": "^10.1.2",
17
16
  "eslint-plugin-import": "^2.31.0",
18
- "eslint-plugin-jest": "^28.9.0",
17
+ "eslint-plugin-jest": "^28.11.0",
19
18
  "eslint-plugin-jsx-a11y": "^6.10.2",
20
- "eslint-plugin-n": "^17.14.0",
21
- "eslint-plugin-prettier": "^5.2.1",
19
+ "eslint-plugin-n": "^17.17.0",
20
+ "eslint-plugin-prettier": "^5.2.6",
22
21
  "eslint-plugin-promise": "^7.2.1",
23
- "eslint-plugin-react": "^7.37.2",
24
- "eslint-plugin-react-hooks": "^5.0.0",
25
- "sass": "^1.81.0",
26
- "sass-loader": "^16.0.3",
27
- "style-dictionary": "^4.2.0",
22
+ "eslint-plugin-react": "^7.37.5",
23
+ "eslint-plugin-react-hooks": "^5.2.0",
24
+ "prettier": "^3.5.3",
25
+ "sass": "^1.86.3",
26
+ "sass-loader": "^16.0.5",
28
27
  "style-loader": "^4.0.0",
29
28
  "token-transformer": "^0.0.33",
30
- "tslib": "^2.8.1"
29
+ "tslib": "^2.8.1",
30
+ "typescript": "5.7.3"
31
+ },
32
+ "dependencies": {
33
+ "@mui/material": "7.0.2",
34
+ "@mui/system": "7.0.2",
35
+ "@emotion/react": "^11.14.0",
36
+ "@emotion/styled": "^11.14.0"
31
37
  },
32
38
  "scripts": {
33
39
  "build": "rollup -c",
34
40
  "build:watch": "rollup --bundleConfigAsCjs -c -w",
35
41
  "dev": "npm run build:watch",
36
42
  "eslint": "eslint --config \"eslint.config.js\" --color \".\" --max-warnings=0",
37
- "lint": "npm run eslint"
43
+ "lint": "npm run eslint",
44
+ "prettier:check": "prettier --check .",
45
+ "prettier:format": "prettier --write ."
38
46
  }
39
47
  }
@@ -0,0 +1,229 @@
1
+ import { PaletteMode, ThemeOptions, createTheme } from '@mui/material';
2
+
3
+ import {
4
+ BackgroundDefaultColors,
5
+ BasicPaletteColorOptions,
6
+ BorderDefaultColors,
7
+ ColorCategory,
8
+ CustomColors,
9
+ DefaultColors,
10
+ NotificationDefaultColors,
11
+ PaletteDefaultColors,
12
+ SecondaryDefaultColors,
13
+ TextDefaultColors,
14
+ Theme,
15
+ ThemeStructure,
16
+ ThemeValue,
17
+ TokenStructure,
18
+ TypographyToken,
19
+ } from '@/interfaces/theme.interface';
20
+ import Accordion from '@/styled/Accordion';
21
+ import Alert from '@/styled/Alert';
22
+ import Autocomplete from '@/styled/Autocomplete';
23
+ import Breadcrumbs from '@/styled/Breadcrumbs';
24
+ import Button from '@/styled/Button';
25
+ import Checkbox from '@/styled/Checkbox';
26
+ import Chip from '@/styled/Chip';
27
+ import Divider from '@/styled/Divider';
28
+ import FormHelperText from '@/styled/FormHelperText';
29
+ import FormLabel from '@/styled/FormLabel';
30
+ import IconButton from '@/styled/IconButton';
31
+ import InputLabel from '@/styled/InputLabel';
32
+ import MenuItem from '@/styled/MenuItem';
33
+ import OutlinedInput from '@/styled/OutlinedInput';
34
+ import PaginationItem from '@/styled/PaginationItem';
35
+ import Radio from '@/styled/Radio';
36
+ import Select from '@/styled/Select';
37
+ import Switch from '@/styled/Switch';
38
+ import Table from '@/styled/Table';
39
+ import TextField from '@/styled/TextField';
40
+ import Typography from '@/styled/Typography';
41
+
42
+ const convertPaletteColor = (
43
+ colorCategory: ColorCategory,
44
+ ): BasicPaletteColorOptions => {
45
+ return {
46
+ main: colorCategory.main?.value || '',
47
+ mainChannel: colorCategory.mainChannel?.value || '',
48
+ light: colorCategory.light?.value,
49
+ light2: colorCategory['light 2']?.value || '',
50
+ light3: colorCategory['light 3']?.value || '',
51
+ lightChannel: colorCategory.lightChannel?.value || '',
52
+ dark: colorCategory.dark?.value || '',
53
+ dark2: colorCategory['dark 2']?.value || '',
54
+ dark3: colorCategory['dark 3']?.value || '',
55
+ darkChannel: colorCategory.darkChannel?.value || '',
56
+ contrastText:
57
+ colorCategory['primary contrast text']?.value ||
58
+ colorCategory['secondary contrast text']?.value ||
59
+ '#ffffff',
60
+ };
61
+ };
62
+
63
+ const convertTypographyVariant = (variant: TypographyToken | undefined) => {
64
+ return {
65
+ fontFamily: variant?.fontFamily.value,
66
+ fontSize: variant?.fontSize.value,
67
+ lineHeight: variant?.LineHeight.value,
68
+ fontWeight: Number(variant?.fontWeight.value),
69
+ };
70
+ };
71
+
72
+ export function isColor(colorValue: DefaultColors | ThemeValue): boolean {
73
+ if (colorValue?.value && colorValue?.type) {
74
+ return true;
75
+ }
76
+
77
+ return false;
78
+ }
79
+
80
+ const convertCustomColors = (
81
+ colors:
82
+ | CustomColors
83
+ | TextDefaultColors
84
+ | BackgroundDefaultColors
85
+ | BorderDefaultColors
86
+ | NotificationDefaultColors
87
+ | SecondaryDefaultColors,
88
+ ) => {
89
+ return Object.keys(colors).reduce((acc, key) => {
90
+ const colorValue = colors[key];
91
+
92
+ if (isColor(colorValue)) {
93
+ if (colorValue?.value) {
94
+ acc[key] = colorValue.value;
95
+ }
96
+ }
97
+
98
+ return acc;
99
+ }, {} as PaletteDefaultColors);
100
+ };
101
+
102
+ const getTheme = (
103
+ themeName: Theme,
104
+ mode: PaletteMode,
105
+ themesTokens: ThemeStructure,
106
+ ): ThemeOptions => {
107
+ const basicTokens: TokenStructure | undefined =
108
+ themesTokens[`DFLib-Variables/${themeName}`];
109
+ const customColors: CustomColors | undefined =
110
+ themesTokens[`DFLib-Variables/${themeName}/defaultColors`];
111
+
112
+ if (!basicTokens || !customColors) {
113
+ throw new Error(`Theme ${themeName} not found`);
114
+ }
115
+
116
+ const tokens: TokenStructure & CustomColors = {
117
+ ...basicTokens,
118
+ ...customColors,
119
+ };
120
+
121
+ const { spacing } = createTheme({
122
+ spacing: (factor: number) =>
123
+ `${factor * Number(tokens.spacing?.xxs.value)}px`,
124
+ });
125
+
126
+ // * TODO mainChannel, lightChannel, darkChannel get first 5 char "136cac" and convert to rgba color but without rgba function (ex: 105 15 105)
127
+
128
+ return {
129
+ palette: {
130
+ mode: mode,
131
+ primary: tokens.palette
132
+ ? convertPaletteColor(tokens.palette.primary)
133
+ : {},
134
+ secondary: tokens.palette
135
+ ? convertPaletteColor(tokens.palette.secondary)
136
+ : {},
137
+ error: tokens.palette ? convertPaletteColor(tokens.palette.error) : {},
138
+ warning: tokens.palette
139
+ ? convertPaletteColor(tokens.palette.warning)
140
+ : {},
141
+ success: tokens.palette
142
+ ? convertPaletteColor(tokens.palette.success)
143
+ : {},
144
+ info: tokens.palette ? convertPaletteColor(tokens.palette.infos) : {},
145
+ text: tokens.palette
146
+ ? {
147
+ primary: tokens.palette.text.primary.value,
148
+ secondary: tokens.palette.text.secondary.value,
149
+ dark: tokens.palette.text.dark.value,
150
+ disabled: tokens.palette.text.disabled.value,
151
+ }
152
+ : {},
153
+ background: tokens.palette
154
+ ? {
155
+ default: tokens.palette.background.default.value,
156
+ paper: tokens.palette.background.default.value,
157
+ grey: tokens.palette.background.grey.value,
158
+ }
159
+ : {},
160
+ divider: tokens.palette ? tokens.palette.border.default.value : '',
161
+ border: tokens.palette
162
+ ? {
163
+ default: tokens.palette.background.default.value,
164
+ grey: tokens.palette.background.grey.value,
165
+ }
166
+ : {},
167
+ action: tokens.palette
168
+ ? {
169
+ disabled: tokens.backgroundColors.white?.value,
170
+ disabledBackground: tokens.palette.text?.disabled.value,
171
+ disabledOpacity: 1,
172
+ hover: tokens.backgroundColors?.blueHoverEquivalence?.value,
173
+ hoverOpacity: Number(tokens.palette.action.hoverOpacity.value),
174
+ }
175
+ : {},
176
+ ...convertCustomColors(customColors),
177
+ ...convertCustomColors(customColors.textColors),
178
+ ...convertCustomColors(customColors.backgroundColors),
179
+ ...convertCustomColors(customColors.borderColors),
180
+ ...convertCustomColors(customColors.notificationColors),
181
+ ...convertCustomColors(customColors.secondaryColors),
182
+ },
183
+ typography: {
184
+ fontFamily: tokens.Typography?.body1?.fontFamily?.value || '',
185
+ h1: convertTypographyVariant(tokens?.Typography?.h1),
186
+ h2: convertTypographyVariant(tokens?.Typography?.h2),
187
+ h3: convertTypographyVariant(tokens?.Typography?.h3),
188
+ h4: convertTypographyVariant(tokens?.Typography?.h4),
189
+ h5: convertTypographyVariant(tokens?.Typography?.h5),
190
+ h6: convertTypographyVariant(tokens?.Typography?.h6),
191
+ subtitle1: convertTypographyVariant(tokens?.Typography?.subtitle1),
192
+ subtitle2: convertTypographyVariant(tokens?.Typography?.subtitle2),
193
+ body1: convertTypographyVariant(tokens?.Typography?.body1),
194
+ body2: convertTypographyVariant(tokens?.Typography?.body2),
195
+ button: convertTypographyVariant(tokens?.Typography?.button),
196
+ caption: convertTypographyVariant(tokens?.Typography?.caption),
197
+ },
198
+ shape: {
199
+ borderRadius: Number(tokens.radius?.small.value),
200
+ },
201
+ spacing: (factor: number) =>
202
+ `${factor * Number(tokens.spacing?.xxs.value)}px`,
203
+ components: {
204
+ ...Typography(spacing),
205
+ ...FormHelperText(spacing, tokens),
206
+ ...FormLabel(spacing, tokens),
207
+ ...Button(spacing, tokens),
208
+ ...IconButton(spacing, tokens),
209
+ ...Checkbox(spacing, tokens),
210
+ ...Radio(spacing, tokens),
211
+ ...MenuItem(spacing, tokens),
212
+ ...Accordion(spacing, tokens),
213
+ ...Breadcrumbs(spacing, tokens),
214
+ ...Chip(spacing, tokens),
215
+ ...InputLabel(spacing, tokens),
216
+ ...OutlinedInput(spacing, tokens),
217
+ ...Autocomplete(spacing, tokens),
218
+ ...Switch(spacing, tokens),
219
+ ...Select(spacing, tokens),
220
+ ...TextField(spacing, tokens),
221
+ ...Table(spacing, tokens),
222
+ ...Alert(spacing, tokens),
223
+ ...PaginationItem(spacing, tokens),
224
+ ...Divider(spacing, tokens),
225
+ },
226
+ };
227
+ };
228
+
229
+ export default getTheme;
package/src/index.ts CHANGED
@@ -1,4 +1,2 @@
1
- export { default as useThemeTokens } from './useThemeTokens';
2
- export { default as useMaterialThemeTokens } from './useMaterialThemeTokens';
3
- export * from './interfaces/theme';
4
- export * from './css';
1
+ export { default as theme } from './theme/theme';
2
+ export * from './interfaces/theme.interface';