@frontegg/types 4.37.0 → 4.39.2-dashboard
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.
- package/Common.d.ts +3 -0
- package/ContextOptions.d.ts +5 -1
- package/FronteggAppInstance.d.ts +1 -0
- package/FronteggAppOptions.d.ts +4 -4
- package/FronteggMetadata.d.ts +2 -0
- package/Localizations/AdminPortalLocalizations/security.d.ts +4 -0
- package/Localizations/AdminPortalLocalizations/subscriptions.d.ts +23 -0
- package/Localizations/AdminPortalLocalizations/users.d.ts +6 -0
- package/Localizations/LocalizationOverrides.d.ts +1 -0
- package/Localizations/LocalizationType.d.ts +1 -0
- package/Localizations/LoginBoxLocalization/acceptInvitation.d.ts +4 -0
- package/Localizations/LoginBoxLocalization/activateAccount.d.ts +4 -0
- package/Localizations/LoginBoxLocalization/forgetPassword.d.ts +8 -0
- package/Localizations/LoginBoxLocalization/index.d.ts +8 -0
- package/Localizations/LoginBoxLocalization/login.d.ts +28 -0
- package/Localizations/LoginBoxLocalization/resetPassword.d.ts +8 -0
- package/Localizations/LoginBoxLocalization/signup.d.ts +8 -0
- package/Metadata/index.d.ts +1 -1
- package/ThemeOptions/ComponentsOptions.d.ts +63 -0
- package/ThemeOptions/LoginBoxTheme/AcceptInvitationTheme.d.ts +21 -0
- package/ThemeOptions/LoginBoxTheme/ActivateAccountPageTheme.d.ts +52 -0
- package/ThemeOptions/LoginBoxTheme/CustomLoginComponents.d.ts +12 -0
- package/ThemeOptions/LoginBoxTheme/ForgotPasswordTheme.d.ts +46 -0
- package/ThemeOptions/LoginBoxTheme/LoaderTheme.d.ts +7 -0
- package/ThemeOptions/LoginBoxTheme/LoginBoxCommon.d.ts +148 -0
- package/ThemeOptions/LoginBoxTheme/LoginPageTheme.d.ts +119 -0
- package/ThemeOptions/LoginBoxTheme/ResetPasswordTheme.d.ts +48 -0
- package/ThemeOptions/LoginBoxTheme/SignupPageTheme.d.ts +46 -0
- package/ThemeOptions/LoginBoxTheme/SocialLoginsTheme.d.ts +36 -0
- package/ThemeOptions/LoginBoxTheme/index.d.ts +51 -0
- package/ThemeOptions/LoginBoxThemeOptions.d.ts +3 -8
- package/ThemeOptions/helpers.d.ts +0 -0
- package/ThemeOptions/index.d.ts +6 -190
- package/index.js +6 -197
- package/node/index.js +6 -197
- package/package.json +2 -2
package/ThemeOptions/index.d.ts
CHANGED
|
@@ -6,8 +6,10 @@ import { Transitions, TransitionsOptions } from './TransitionsOptions';
|
|
|
6
6
|
import { Breakpoints, BreakpointsOptions } from './BreakpointsOptions';
|
|
7
7
|
import { ComponentsOptions } from './ComponentsOptions';
|
|
8
8
|
import { TypographyOptions, Typography } from './TypographyOptions';
|
|
9
|
-
import { AdminPortalThemeOptions } from './AdminPortalThemeOptions';
|
|
10
|
-
import { LoginBoxThemeOptions } from './
|
|
9
|
+
import { AdminPortalTheme, AdminPortalThemeOptions } from './AdminPortalThemeOptions';
|
|
10
|
+
import { LoginBoxTheme, LoginBoxThemeOptions } from './LoginBoxTheme';
|
|
11
|
+
export * from './LoginBoxTheme';
|
|
12
|
+
export * from './ComponentsOptions';
|
|
11
13
|
export declare type Direction = 'ltr' | 'rtl';
|
|
12
14
|
export interface FronteggThemeOptions {
|
|
13
15
|
palette?: ThemePaletteOptions;
|
|
@@ -21,107 +23,7 @@ export interface FronteggThemeOptions {
|
|
|
21
23
|
typography?: TypographyOptions;
|
|
22
24
|
adminPortal?: AdminPortalThemeOptions;
|
|
23
25
|
loginBox?: LoginBoxThemeOptions;
|
|
24
|
-
navigation?: {
|
|
25
|
-
groupTitleColor?: CSSProperties['color'];
|
|
26
|
-
groupTitleSize?: CSSProperties['fontSize'];
|
|
27
|
-
headerColor?: CSSProperties['color'];
|
|
28
|
-
subHeaderColor?: CSSProperties['color'];
|
|
29
|
-
background?: CSSProperties['background'];
|
|
30
|
-
default: {
|
|
31
|
-
color?: CSSProperties['color'];
|
|
32
|
-
borderColor?: CSSProperties['borderColor'];
|
|
33
|
-
avatarBgColor?: CSSProperties['background'];
|
|
34
|
-
avatarColor?: CSSProperties['color'];
|
|
35
|
-
};
|
|
36
|
-
hover: {
|
|
37
|
-
color?: CSSProperties['color'];
|
|
38
|
-
background?: CSSProperties['background'];
|
|
39
|
-
borderColor?: CSSProperties['borderColor'];
|
|
40
|
-
avatarColor?: CSSProperties['color'];
|
|
41
|
-
avatarBgColor?: CSSProperties['backgroundColor'];
|
|
42
|
-
};
|
|
43
|
-
selected: {
|
|
44
|
-
color?: CSSProperties['color'];
|
|
45
|
-
background?: CSSProperties['background'];
|
|
46
|
-
borderColor?: CSSProperties['borderColor'];
|
|
47
|
-
avatarColor?: CSSProperties['color'];
|
|
48
|
-
avatarBgColor?: CSSProperties['backgroundColor'];
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
dialog?: {
|
|
52
|
-
headerBackground?: CSSProperties['background'];
|
|
53
|
-
headerTextColor?: CSSProperties['color'];
|
|
54
|
-
bodyBackground?: CSSProperties['background'];
|
|
55
|
-
footerBackground?: CSSProperties['background'];
|
|
56
|
-
};
|
|
57
|
-
socialLogins?: {
|
|
58
|
-
rowLayout?: boolean;
|
|
59
|
-
google?: socialLogin;
|
|
60
|
-
github?: socialLogin;
|
|
61
|
-
facebook?: socialLogin;
|
|
62
|
-
microsoft?: socialLogin;
|
|
63
|
-
};
|
|
64
|
-
rightPanel?: {
|
|
65
|
-
headerBackground?: CSSProperties['background'];
|
|
66
|
-
pageBackground?: CSSProperties['background'];
|
|
67
|
-
elementBackground?: CSSProperties['color'];
|
|
68
|
-
profileHeader?: CSSProperties['background'];
|
|
69
|
-
tableHeaderBackground?: CSSProperties['background'];
|
|
70
|
-
tableBodyBackground?: CSSProperties['background'];
|
|
71
|
-
};
|
|
72
|
-
authPage?: {
|
|
73
|
-
loginBox: {
|
|
74
|
-
width?: CSSProperties['width'];
|
|
75
|
-
padding?: CSSProperties['padding'];
|
|
76
|
-
border?: CSSProperties['border'];
|
|
77
|
-
borderRadius?: CSSProperties['borderRadius'];
|
|
78
|
-
boxShadow?: CSSProperties['boxShadow'];
|
|
79
|
-
backgroundCard?: CSSProperties['background'];
|
|
80
|
-
};
|
|
81
|
-
loginSignupSwitch?: {
|
|
82
|
-
color?: CSSProperties['color'];
|
|
83
|
-
fontSize?: CSSProperties['fontSize'];
|
|
84
|
-
fontFamily?: CSSProperties['fontFamily'];
|
|
85
|
-
textAlign?: CSSProperties['textAlign'];
|
|
86
|
-
padding?: CSSProperties['padding'];
|
|
87
|
-
margin?: CSSProperties['margin'];
|
|
88
|
-
link?: {
|
|
89
|
-
color?: CSSProperties['color'];
|
|
90
|
-
decoration?: CSSProperties['textDecoration'];
|
|
91
|
-
fontWeight?: CSSProperties['fontWeight'];
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
inputError: {
|
|
95
|
-
fontFamily?: CSSProperties['fontFamily'];
|
|
96
|
-
fontSize?: CSSProperties['fontSize'];
|
|
97
|
-
fontWeight?: CSSProperties['fontWeight'];
|
|
98
|
-
padding?: CSSProperties['padding'];
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
subHeaderMsg?: {
|
|
102
|
-
color?: CSSProperties['color'];
|
|
103
|
-
fontSize?: CSSProperties['fontSize'];
|
|
104
|
-
fontFamily?: CSSProperties['fontFamily'];
|
|
105
|
-
textAlign?: CSSProperties['textAlign'];
|
|
106
|
-
padding?: CSSProperties['padding'];
|
|
107
|
-
margin?: CSSProperties['margin'];
|
|
108
|
-
textDecoration?: CSSProperties['textDecoration'];
|
|
109
|
-
};
|
|
110
26
|
}
|
|
111
|
-
export declare type socialLogin = {
|
|
112
|
-
background?: CSSProperties['background'];
|
|
113
|
-
default: {
|
|
114
|
-
color?: CSSProperties['color'];
|
|
115
|
-
};
|
|
116
|
-
hover: {
|
|
117
|
-
color?: CSSProperties['color'];
|
|
118
|
-
background?: CSSProperties['background'];
|
|
119
|
-
};
|
|
120
|
-
selected: {
|
|
121
|
-
color?: CSSProperties['color'];
|
|
122
|
-
background?: CSSProperties['background'];
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
27
|
export interface FronteggTheme {
|
|
126
28
|
palette: ThemePalette;
|
|
127
29
|
typographyStyleOptions: CSSProperties;
|
|
@@ -132,94 +34,8 @@ export interface FronteggTheme {
|
|
|
132
34
|
direction: Direction;
|
|
133
35
|
components: ComponentsOptions;
|
|
134
36
|
typography: Typography;
|
|
135
|
-
adminPortal
|
|
136
|
-
loginBox
|
|
137
|
-
navigation: {
|
|
138
|
-
groupTitleColor: CSSProperties['color'];
|
|
139
|
-
groupTitleSize: CSSProperties['fontSize'];
|
|
140
|
-
headerColor: CSSProperties['color'];
|
|
141
|
-
subHeaderColor: CSSProperties['color'];
|
|
142
|
-
background: CSSProperties['background'];
|
|
143
|
-
default: {
|
|
144
|
-
color?: CSSProperties['color'];
|
|
145
|
-
borderColor?: CSSProperties['borderColor'];
|
|
146
|
-
avatarBgColor?: CSSProperties['background'];
|
|
147
|
-
avatarColor?: CSSProperties['color'];
|
|
148
|
-
};
|
|
149
|
-
hover: {
|
|
150
|
-
color?: CSSProperties['color'];
|
|
151
|
-
background?: CSSProperties['background'];
|
|
152
|
-
borderColor?: CSSProperties['borderColor'];
|
|
153
|
-
avatarColor?: CSSProperties['color'];
|
|
154
|
-
avatarBgColor?: CSSProperties['backgroundColor'];
|
|
155
|
-
};
|
|
156
|
-
selected: {
|
|
157
|
-
color?: CSSProperties['color'];
|
|
158
|
-
background?: CSSProperties['background'];
|
|
159
|
-
borderColor?: CSSProperties['borderColor'];
|
|
160
|
-
avatarColor?: CSSProperties['color'];
|
|
161
|
-
avatarBgColor?: CSSProperties['backgroundColor'];
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
dialog: {
|
|
165
|
-
headerBackground?: CSSProperties['background'];
|
|
166
|
-
headerTextColor?: CSSProperties['color'];
|
|
167
|
-
bodyBackground?: CSSProperties['background'];
|
|
168
|
-
footerBackground?: CSSProperties['background'];
|
|
169
|
-
};
|
|
170
|
-
socialLogins: {
|
|
171
|
-
rowLayout?: boolean;
|
|
172
|
-
google?: socialLogin;
|
|
173
|
-
github?: socialLogin;
|
|
174
|
-
facebook?: socialLogin;
|
|
175
|
-
microsoft?: socialLogin;
|
|
176
|
-
};
|
|
177
|
-
rightPanel: {
|
|
178
|
-
headerBackground?: CSSProperties['background'];
|
|
179
|
-
pageBackground?: CSSProperties['background'];
|
|
180
|
-
elementBackground?: CSSProperties['color'];
|
|
181
|
-
profileHeader?: CSSProperties['background'];
|
|
182
|
-
tableHeaderBackground?: CSSProperties['background'];
|
|
183
|
-
tableBodyBackground?: CSSProperties['background'];
|
|
184
|
-
};
|
|
185
|
-
authPage: {
|
|
186
|
-
loginBox: {
|
|
187
|
-
width?: CSSProperties['width'];
|
|
188
|
-
padding?: CSSProperties['padding'];
|
|
189
|
-
border?: CSSProperties['border'];
|
|
190
|
-
borderRadius?: CSSProperties['borderRadius'];
|
|
191
|
-
boxShadow?: CSSProperties['boxShadow'];
|
|
192
|
-
backgroundCard?: CSSProperties['background'];
|
|
193
|
-
};
|
|
194
|
-
loginSignupSwitch?: {
|
|
195
|
-
color?: CSSProperties['color'];
|
|
196
|
-
fontSize?: CSSProperties['fontSize'];
|
|
197
|
-
fontFamily?: CSSProperties['fontFamily'];
|
|
198
|
-
textAlign?: CSSProperties['textAlign'];
|
|
199
|
-
padding?: CSSProperties['padding'];
|
|
200
|
-
margin?: CSSProperties['margin'];
|
|
201
|
-
link?: {
|
|
202
|
-
color?: CSSProperties['color'];
|
|
203
|
-
decoration?: CSSProperties['textDecoration'];
|
|
204
|
-
fontWeight?: CSSProperties['fontWeight'];
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
inputError: {
|
|
208
|
-
fontFamily?: CSSProperties['fontFamily'];
|
|
209
|
-
fontSize?: CSSProperties['fontSize'];
|
|
210
|
-
fontWeight?: CSSProperties['fontWeight'];
|
|
211
|
-
padding?: CSSProperties['padding'];
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
subHeaderMsg: {
|
|
215
|
-
color?: CSSProperties['color'];
|
|
216
|
-
fontSize?: CSSProperties['fontSize'];
|
|
217
|
-
fontFamily?: CSSProperties['fontFamily'];
|
|
218
|
-
textAlign?: CSSProperties['textAlign'];
|
|
219
|
-
padding?: CSSProperties['padding'];
|
|
220
|
-
margin?: CSSProperties['margin'];
|
|
221
|
-
textDecoration?: CSSProperties['textDecoration'];
|
|
222
|
-
};
|
|
37
|
+
adminPortal: AdminPortalTheme;
|
|
38
|
+
loginBox: LoginBoxTheme;
|
|
223
39
|
}
|
|
224
40
|
export declare type BaseThemeOptions = Omit<FronteggThemeOptions, 'adminPortal' | 'loginBox'>;
|
|
225
41
|
export declare type BaseTheme = Omit<FronteggTheme, 'adminPortal' | 'loginBox'>;
|
package/index.js
CHANGED
|
@@ -132,201 +132,9 @@ var cjs = deepmerge_1;
|
|
|
132
132
|
|
|
133
133
|
var deepMerge = cjs;
|
|
134
134
|
|
|
135
|
-
/**
|
|
136
|
-
* Returns a number whose value is limited to the given range.
|
|
137
|
-
* @param {number} value The value to be clamped
|
|
138
|
-
* @param {number} min The lower boundary of the output range
|
|
139
|
-
* @param {number} max The upper boundary of the output range
|
|
140
|
-
* @returns {number} A number in the range [min, max]
|
|
141
|
-
*/
|
|
142
|
-
function clamp(value, min = 0, max = 1) {
|
|
143
|
-
return Math.min(Math.max(min, value), max);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Converts a color from CSS hex format to CSS rgb format.
|
|
147
|
-
* @param {string} color - Hex color, i.e. #nnn or #nnnnnn
|
|
148
|
-
* @returns {string} A CSS rgb color string
|
|
149
|
-
*/
|
|
150
|
-
function hexToRgb(color) {
|
|
151
|
-
color = color.substr(1);
|
|
152
|
-
const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
|
|
153
|
-
let colors = color.match(re);
|
|
154
|
-
if (colors && colors[0].length === 1) {
|
|
155
|
-
colors = colors.map((n) => n + n);
|
|
156
|
-
}
|
|
157
|
-
return colors
|
|
158
|
-
? `rgb${colors.length === 4 ? 'a' : ''}(${colors
|
|
159
|
-
.map((n, index) => {
|
|
160
|
-
return index < 3 ? parseInt(n, 16) : Math.round((parseInt(n, 16) / 255) * 1000) / 1000;
|
|
161
|
-
})
|
|
162
|
-
.join(', ')})`
|
|
163
|
-
: '';
|
|
164
|
-
}
|
|
165
|
-
function intToHex(int) {
|
|
166
|
-
const hex = int.toString(16);
|
|
167
|
-
return hex.length === 1 ? `0${hex}` : hex;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Returns an object with the type and values of a color.
|
|
171
|
-
*
|
|
172
|
-
* Note: Does not support rgb % values.
|
|
173
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
174
|
-
* @returns {object} - A MUI color object: {type: string, values: number[]}
|
|
175
|
-
*/
|
|
176
|
-
function decomposeColor(color) {
|
|
177
|
-
// Idempotent
|
|
178
|
-
if (color.type) {
|
|
179
|
-
return color;
|
|
180
|
-
}
|
|
181
|
-
if (color.charAt(0) === '#') {
|
|
182
|
-
return decomposeColor(hexToRgb(color));
|
|
183
|
-
}
|
|
184
|
-
const marker = color.indexOf('(');
|
|
185
|
-
const type = color.substring(0, marker);
|
|
186
|
-
if (['rgb', 'rgba', 'hsl', 'hsla', 'color'].indexOf(type) === -1) {
|
|
187
|
-
throw new Error('MUI: Unsupported `%s` color.\n' +
|
|
188
|
-
'The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color(). ' + color);
|
|
189
|
-
}
|
|
190
|
-
let values = color.substring(marker + 1, color.length - 1);
|
|
191
|
-
let colorSpace;
|
|
192
|
-
if (type === 'color') {
|
|
193
|
-
values = values.split(' ');
|
|
194
|
-
colorSpace = values.shift();
|
|
195
|
-
if (values.length === 4 && values[3].charAt(0) === '/') {
|
|
196
|
-
values[3] = values[3].substr(1);
|
|
197
|
-
}
|
|
198
|
-
if (['srgb', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec-2020'].indexOf(colorSpace) === -1) {
|
|
199
|
-
throw new Error('MUI: unsupported `%s` color space.\n' +
|
|
200
|
-
'The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.' + colorSpace);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
values = values.split(',');
|
|
205
|
-
}
|
|
206
|
-
values = values.map((value) => parseFloat(value));
|
|
207
|
-
return { type, values, colorSpace };
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Converts a color object with type and values to a string.
|
|
211
|
-
* @param {object} color - Decomposed color
|
|
212
|
-
* @param {string} color.type - One of: 'rgb', 'rgba', 'hsl', 'hsla'
|
|
213
|
-
* @param {array} color.values - [n,n,n] or [n,n,n,n]
|
|
214
|
-
* @returns {string} A CSS color string
|
|
215
|
-
*/
|
|
216
|
-
function recomposeColor(color) {
|
|
217
|
-
const { type, colorSpace } = color;
|
|
218
|
-
let { values } = color;
|
|
219
|
-
if (type.indexOf('rgb') !== -1) {
|
|
220
|
-
// Only convert the first 3 values to int (i.e. not alpha)
|
|
221
|
-
values = values.map((n, i) => (i < 3 ? parseInt(n, 10) : n));
|
|
222
|
-
}
|
|
223
|
-
else if (type.indexOf('hsl') !== -1) {
|
|
224
|
-
values[1] = `${values[1]}%`;
|
|
225
|
-
values[2] = `${values[2]}%`;
|
|
226
|
-
}
|
|
227
|
-
if (type.indexOf('color') !== -1) {
|
|
228
|
-
values = `${colorSpace} ${values.join(' ')}`;
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
values = `${values.join(', ')}`;
|
|
232
|
-
}
|
|
233
|
-
return `${type}(${values})`;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Converts a color from CSS rgb format to CSS hex format.
|
|
237
|
-
* @param {string} color - RGB color, i.e. rgb(n, n, n)
|
|
238
|
-
* @returns {string} A CSS rgb color string, i.e. #nnnnnn
|
|
239
|
-
*/
|
|
240
|
-
function rgbToHex(color) {
|
|
241
|
-
// Idempotent
|
|
242
|
-
if (color.indexOf('#') === 0) {
|
|
243
|
-
return color;
|
|
244
|
-
}
|
|
245
|
-
const { values } = decomposeColor(color);
|
|
246
|
-
return `#${values.map((n, i) => intToHex(i === 3 ? Math.round(255 * n) : n)).join('')}`;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Darkens a color.
|
|
250
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
|
|
251
|
-
* @param {number} coefficient - multiplier in the range 0 - 1
|
|
252
|
-
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
253
|
-
*/
|
|
254
|
-
function darken(color, coefficient) {
|
|
255
|
-
color = decomposeColor(color);
|
|
256
|
-
coefficient = clamp(coefficient);
|
|
257
|
-
if (color.type.indexOf('hsl') !== -1) {
|
|
258
|
-
color.values[2] *= 1 - coefficient;
|
|
259
|
-
}
|
|
260
|
-
else if (color.type.indexOf('rgb') !== -1 || color.type.indexOf('color') !== -1) {
|
|
261
|
-
for (let i = 0; i < 3; i += 1) {
|
|
262
|
-
color.values[i] *= 1 - coefficient;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return recomposeColor(color);
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Lightens a color.
|
|
269
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
|
|
270
|
-
* @param {number} coefficient - multiplier in the range 0 - 1
|
|
271
|
-
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
272
|
-
*/
|
|
273
|
-
function lighten(color, coefficient) {
|
|
274
|
-
color = decomposeColor(color);
|
|
275
|
-
coefficient = clamp(coefficient);
|
|
276
|
-
if (color.type.indexOf('hsl') !== -1) {
|
|
277
|
-
color.values[2] += (100 - color.values[2]) * coefficient;
|
|
278
|
-
}
|
|
279
|
-
else if (color.type.indexOf('rgb') !== -1) {
|
|
280
|
-
for (let i = 0; i < 3; i += 1) {
|
|
281
|
-
color.values[i] += (255 - color.values[i]) * coefficient;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
else if (color.type.indexOf('color') !== -1) {
|
|
285
|
-
for (let i = 0; i < 3; i += 1) {
|
|
286
|
-
color.values[i] += (1 - color.values[i]) * coefficient;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return recomposeColor(color);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const generateMainColorObject = (color) => {
|
|
293
|
-
if (!!color) {
|
|
294
|
-
return {
|
|
295
|
-
main: color,
|
|
296
|
-
light: rgbToHex(lighten(color, 0.4)),
|
|
297
|
-
dark: rgbToHex(darken(color, 0.15)),
|
|
298
|
-
hover: rgbToHex(darken(color, 0.15)),
|
|
299
|
-
active: rgbToHex(darken(color, 0.20)),
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
const generateSubColorObject = (color) => {
|
|
304
|
-
if (!!color) {
|
|
305
|
-
return {
|
|
306
|
-
main: color,
|
|
307
|
-
light: lighten(color, 0.7),
|
|
308
|
-
dark: darken(color, 0.2),
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
const getPalette = (theme, defaultTheme) => {
|
|
313
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
314
|
-
if (!(theme === null || theme === void 0 ? void 0 : theme.palette) || typeof ((_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a.primary) !== 'string') {
|
|
315
|
-
return {};
|
|
316
|
-
}
|
|
317
|
-
return Object.assign(Object.assign({}, defaultTheme), { palette: {
|
|
318
|
-
primary: Object.assign(Object.assign({}, generateMainColorObject((_b = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _b === void 0 ? void 0 : _b.primary)), { contrastText: (_d = (_c = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _c === void 0 ? void 0 : _c.primaryText) !== null && _d !== void 0 ? _d : '#000000' }),
|
|
319
|
-
secondary: Object.assign(Object.assign({}, generateMainColorObject((_e = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _e === void 0 ? void 0 : _e.secondary)), { contrastText: (_g = (_f = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _f === void 0 ? void 0 : _f.secondaryText) !== null && _g !== void 0 ? _g : '#000000' }),
|
|
320
|
-
danger: Object.assign(Object.assign({}, generateMainColorObject((_h = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _h === void 0 ? void 0 : _h.error)), { contrastText: '#FFF' }),
|
|
321
|
-
success: Object.assign(Object.assign({}, generateSubColorObject((_j = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _j === void 0 ? void 0 : _j.success)), { contrastText: '#FFF' }),
|
|
322
|
-
error: Object.assign(Object.assign({}, generateSubColorObject((_k = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _k === void 0 ? void 0 : _k.error)), { contrastText: '#FFF' }),
|
|
323
|
-
warning: Object.assign(Object.assign({}, generateSubColorObject((_l = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _l === void 0 ? void 0 : _l.warning)), { contrastText: '#FFF' }),
|
|
324
|
-
info: Object.assign(Object.assign({}, generateSubColorObject((_m = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _m === void 0 ? void 0 : _m.info)), { contrastText: '#FFF' }),
|
|
325
|
-
} });
|
|
326
|
-
};
|
|
327
|
-
|
|
328
135
|
const defaultMetadata = {
|
|
329
136
|
theme: {},
|
|
137
|
+
themeV2: {},
|
|
330
138
|
navigation: {
|
|
331
139
|
usage: {
|
|
332
140
|
visibility: 'hidden',
|
|
@@ -385,7 +193,7 @@ const defaultMetadata = {
|
|
|
385
193
|
};
|
|
386
194
|
class Metadata {
|
|
387
195
|
constructor() {
|
|
388
|
-
this._theme = defaultMetadata.
|
|
196
|
+
this._theme = defaultMetadata.themeV2;
|
|
389
197
|
this._navigation = defaultMetadata.navigation;
|
|
390
198
|
}
|
|
391
199
|
static getInstance(name = 'default') {
|
|
@@ -408,14 +216,15 @@ class Metadata {
|
|
|
408
216
|
return (_a = this._navigation) !== null && _a !== void 0 ? _a : {};
|
|
409
217
|
}
|
|
410
218
|
set(metadata) {
|
|
411
|
-
var _a, _b, _c;
|
|
219
|
+
var _a, _b, _c, _d;
|
|
412
220
|
try {
|
|
413
221
|
this._navigation = deepMerge.all([(_a = defaultMetadata.navigation) !== null && _a !== void 0 ? _a : {}, (_b = metadata === null || metadata === void 0 ? void 0 : metadata.navigation) !== null && _b !== void 0 ? _b : {}]);
|
|
414
|
-
this._theme = deepMerge.all([(_c = defaultMetadata.
|
|
222
|
+
this._theme = deepMerge.all([(_c = defaultMetadata.themeV2) !== null && _c !== void 0 ? _c : {}, (_d = metadata === null || metadata === void 0 ? void 0 : metadata.themeV2) !== null && _d !== void 0 ? _d : {}]);
|
|
223
|
+
debugger;
|
|
415
224
|
}
|
|
416
225
|
catch (e) {
|
|
417
226
|
this._navigation = defaultMetadata.navigation;
|
|
418
|
-
this._theme = defaultMetadata.
|
|
227
|
+
this._theme = defaultMetadata.themeV2;
|
|
419
228
|
}
|
|
420
229
|
}
|
|
421
230
|
}
|
package/node/index.js
CHANGED
|
@@ -134,201 +134,9 @@ var deepmerge_1 = deepmerge;
|
|
|
134
134
|
|
|
135
135
|
var cjs = deepmerge_1;
|
|
136
136
|
|
|
137
|
-
/**
|
|
138
|
-
* Returns a number whose value is limited to the given range.
|
|
139
|
-
* @param {number} value The value to be clamped
|
|
140
|
-
* @param {number} min The lower boundary of the output range
|
|
141
|
-
* @param {number} max The upper boundary of the output range
|
|
142
|
-
* @returns {number} A number in the range [min, max]
|
|
143
|
-
*/
|
|
144
|
-
function clamp(value, min = 0, max = 1) {
|
|
145
|
-
return Math.min(Math.max(min, value), max);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Converts a color from CSS hex format to CSS rgb format.
|
|
149
|
-
* @param {string} color - Hex color, i.e. #nnn or #nnnnnn
|
|
150
|
-
* @returns {string} A CSS rgb color string
|
|
151
|
-
*/
|
|
152
|
-
function hexToRgb(color) {
|
|
153
|
-
color = color.substr(1);
|
|
154
|
-
const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
|
|
155
|
-
let colors = color.match(re);
|
|
156
|
-
if (colors && colors[0].length === 1) {
|
|
157
|
-
colors = colors.map((n) => n + n);
|
|
158
|
-
}
|
|
159
|
-
return colors
|
|
160
|
-
? `rgb${colors.length === 4 ? 'a' : ''}(${colors
|
|
161
|
-
.map((n, index) => {
|
|
162
|
-
return index < 3 ? parseInt(n, 16) : Math.round((parseInt(n, 16) / 255) * 1000) / 1000;
|
|
163
|
-
})
|
|
164
|
-
.join(', ')})`
|
|
165
|
-
: '';
|
|
166
|
-
}
|
|
167
|
-
function intToHex(int) {
|
|
168
|
-
const hex = int.toString(16);
|
|
169
|
-
return hex.length === 1 ? `0${hex}` : hex;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Returns an object with the type and values of a color.
|
|
173
|
-
*
|
|
174
|
-
* Note: Does not support rgb % values.
|
|
175
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
176
|
-
* @returns {object} - A MUI color object: {type: string, values: number[]}
|
|
177
|
-
*/
|
|
178
|
-
function decomposeColor(color) {
|
|
179
|
-
// Idempotent
|
|
180
|
-
if (color.type) {
|
|
181
|
-
return color;
|
|
182
|
-
}
|
|
183
|
-
if (color.charAt(0) === '#') {
|
|
184
|
-
return decomposeColor(hexToRgb(color));
|
|
185
|
-
}
|
|
186
|
-
const marker = color.indexOf('(');
|
|
187
|
-
const type = color.substring(0, marker);
|
|
188
|
-
if (['rgb', 'rgba', 'hsl', 'hsla', 'color'].indexOf(type) === -1) {
|
|
189
|
-
throw new Error('MUI: Unsupported `%s` color.\n' +
|
|
190
|
-
'The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color(). ' + color);
|
|
191
|
-
}
|
|
192
|
-
let values = color.substring(marker + 1, color.length - 1);
|
|
193
|
-
let colorSpace;
|
|
194
|
-
if (type === 'color') {
|
|
195
|
-
values = values.split(' ');
|
|
196
|
-
colorSpace = values.shift();
|
|
197
|
-
if (values.length === 4 && values[3].charAt(0) === '/') {
|
|
198
|
-
values[3] = values[3].substr(1);
|
|
199
|
-
}
|
|
200
|
-
if (['srgb', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec-2020'].indexOf(colorSpace) === -1) {
|
|
201
|
-
throw new Error('MUI: unsupported `%s` color space.\n' +
|
|
202
|
-
'The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.' + colorSpace);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
values = values.split(',');
|
|
207
|
-
}
|
|
208
|
-
values = values.map((value) => parseFloat(value));
|
|
209
|
-
return { type, values, colorSpace };
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Converts a color object with type and values to a string.
|
|
213
|
-
* @param {object} color - Decomposed color
|
|
214
|
-
* @param {string} color.type - One of: 'rgb', 'rgba', 'hsl', 'hsla'
|
|
215
|
-
* @param {array} color.values - [n,n,n] or [n,n,n,n]
|
|
216
|
-
* @returns {string} A CSS color string
|
|
217
|
-
*/
|
|
218
|
-
function recomposeColor(color) {
|
|
219
|
-
const { type, colorSpace } = color;
|
|
220
|
-
let { values } = color;
|
|
221
|
-
if (type.indexOf('rgb') !== -1) {
|
|
222
|
-
// Only convert the first 3 values to int (i.e. not alpha)
|
|
223
|
-
values = values.map((n, i) => (i < 3 ? parseInt(n, 10) : n));
|
|
224
|
-
}
|
|
225
|
-
else if (type.indexOf('hsl') !== -1) {
|
|
226
|
-
values[1] = `${values[1]}%`;
|
|
227
|
-
values[2] = `${values[2]}%`;
|
|
228
|
-
}
|
|
229
|
-
if (type.indexOf('color') !== -1) {
|
|
230
|
-
values = `${colorSpace} ${values.join(' ')}`;
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
values = `${values.join(', ')}`;
|
|
234
|
-
}
|
|
235
|
-
return `${type}(${values})`;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Converts a color from CSS rgb format to CSS hex format.
|
|
239
|
-
* @param {string} color - RGB color, i.e. rgb(n, n, n)
|
|
240
|
-
* @returns {string} A CSS rgb color string, i.e. #nnnnnn
|
|
241
|
-
*/
|
|
242
|
-
function rgbToHex(color) {
|
|
243
|
-
// Idempotent
|
|
244
|
-
if (color.indexOf('#') === 0) {
|
|
245
|
-
return color;
|
|
246
|
-
}
|
|
247
|
-
const { values } = decomposeColor(color);
|
|
248
|
-
return `#${values.map((n, i) => intToHex(i === 3 ? Math.round(255 * n) : n)).join('')}`;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Darkens a color.
|
|
252
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
|
|
253
|
-
* @param {number} coefficient - multiplier in the range 0 - 1
|
|
254
|
-
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
255
|
-
*/
|
|
256
|
-
function darken(color, coefficient) {
|
|
257
|
-
color = decomposeColor(color);
|
|
258
|
-
coefficient = clamp(coefficient);
|
|
259
|
-
if (color.type.indexOf('hsl') !== -1) {
|
|
260
|
-
color.values[2] *= 1 - coefficient;
|
|
261
|
-
}
|
|
262
|
-
else if (color.type.indexOf('rgb') !== -1 || color.type.indexOf('color') !== -1) {
|
|
263
|
-
for (let i = 0; i < 3; i += 1) {
|
|
264
|
-
color.values[i] *= 1 - coefficient;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return recomposeColor(color);
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Lightens a color.
|
|
271
|
-
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
|
|
272
|
-
* @param {number} coefficient - multiplier in the range 0 - 1
|
|
273
|
-
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
274
|
-
*/
|
|
275
|
-
function lighten(color, coefficient) {
|
|
276
|
-
color = decomposeColor(color);
|
|
277
|
-
coefficient = clamp(coefficient);
|
|
278
|
-
if (color.type.indexOf('hsl') !== -1) {
|
|
279
|
-
color.values[2] += (100 - color.values[2]) * coefficient;
|
|
280
|
-
}
|
|
281
|
-
else if (color.type.indexOf('rgb') !== -1) {
|
|
282
|
-
for (let i = 0; i < 3; i += 1) {
|
|
283
|
-
color.values[i] += (255 - color.values[i]) * coefficient;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
else if (color.type.indexOf('color') !== -1) {
|
|
287
|
-
for (let i = 0; i < 3; i += 1) {
|
|
288
|
-
color.values[i] += (1 - color.values[i]) * coefficient;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return recomposeColor(color);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const generateMainColorObject = (color) => {
|
|
295
|
-
if (!!color) {
|
|
296
|
-
return {
|
|
297
|
-
main: color,
|
|
298
|
-
light: rgbToHex(lighten(color, 0.4)),
|
|
299
|
-
dark: rgbToHex(darken(color, 0.15)),
|
|
300
|
-
hover: rgbToHex(darken(color, 0.15)),
|
|
301
|
-
active: rgbToHex(darken(color, 0.20)),
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
const generateSubColorObject = (color) => {
|
|
306
|
-
if (!!color) {
|
|
307
|
-
return {
|
|
308
|
-
main: color,
|
|
309
|
-
light: lighten(color, 0.7),
|
|
310
|
-
dark: darken(color, 0.2),
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
const getPalette = (theme, defaultTheme) => {
|
|
315
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
316
|
-
if (!(theme === null || theme === void 0 ? void 0 : theme.palette) || typeof ((_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a.primary) !== 'string') {
|
|
317
|
-
return {};
|
|
318
|
-
}
|
|
319
|
-
return Object.assign(Object.assign({}, defaultTheme), { palette: {
|
|
320
|
-
primary: Object.assign(Object.assign({}, generateMainColorObject((_b = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _b === void 0 ? void 0 : _b.primary)), { contrastText: (_d = (_c = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _c === void 0 ? void 0 : _c.primaryText) !== null && _d !== void 0 ? _d : '#000000' }),
|
|
321
|
-
secondary: Object.assign(Object.assign({}, generateMainColorObject((_e = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _e === void 0 ? void 0 : _e.secondary)), { contrastText: (_g = (_f = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _f === void 0 ? void 0 : _f.secondaryText) !== null && _g !== void 0 ? _g : '#000000' }),
|
|
322
|
-
danger: Object.assign(Object.assign({}, generateMainColorObject((_h = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _h === void 0 ? void 0 : _h.error)), { contrastText: '#FFF' }),
|
|
323
|
-
success: Object.assign(Object.assign({}, generateSubColorObject((_j = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _j === void 0 ? void 0 : _j.success)), { contrastText: '#FFF' }),
|
|
324
|
-
error: Object.assign(Object.assign({}, generateSubColorObject((_k = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _k === void 0 ? void 0 : _k.error)), { contrastText: '#FFF' }),
|
|
325
|
-
warning: Object.assign(Object.assign({}, generateSubColorObject((_l = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _l === void 0 ? void 0 : _l.warning)), { contrastText: '#FFF' }),
|
|
326
|
-
info: Object.assign(Object.assign({}, generateSubColorObject((_m = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _m === void 0 ? void 0 : _m.info)), { contrastText: '#FFF' }),
|
|
327
|
-
} });
|
|
328
|
-
};
|
|
329
|
-
|
|
330
137
|
const defaultMetadata = {
|
|
331
138
|
theme: {},
|
|
139
|
+
themeV2: {},
|
|
332
140
|
navigation: {
|
|
333
141
|
usage: {
|
|
334
142
|
visibility: 'hidden',
|
|
@@ -387,7 +195,7 @@ const defaultMetadata = {
|
|
|
387
195
|
};
|
|
388
196
|
class Metadata {
|
|
389
197
|
constructor() {
|
|
390
|
-
this._theme = defaultMetadata.
|
|
198
|
+
this._theme = defaultMetadata.themeV2;
|
|
391
199
|
this._navigation = defaultMetadata.navigation;
|
|
392
200
|
}
|
|
393
201
|
static getInstance(name = 'default') {
|
|
@@ -410,14 +218,15 @@ class Metadata {
|
|
|
410
218
|
return (_a = this._navigation) !== null && _a !== void 0 ? _a : {};
|
|
411
219
|
}
|
|
412
220
|
set(metadata) {
|
|
413
|
-
var _a, _b, _c;
|
|
221
|
+
var _a, _b, _c, _d;
|
|
414
222
|
try {
|
|
415
223
|
this._navigation = cjs.all([(_a = defaultMetadata.navigation) !== null && _a !== void 0 ? _a : {}, (_b = metadata === null || metadata === void 0 ? void 0 : metadata.navigation) !== null && _b !== void 0 ? _b : {}]);
|
|
416
|
-
this._theme = cjs.all([(_c = defaultMetadata.
|
|
224
|
+
this._theme = cjs.all([(_c = defaultMetadata.themeV2) !== null && _c !== void 0 ? _c : {}, (_d = metadata === null || metadata === void 0 ? void 0 : metadata.themeV2) !== null && _d !== void 0 ? _d : {}]);
|
|
225
|
+
debugger;
|
|
417
226
|
}
|
|
418
227
|
catch (e) {
|
|
419
228
|
this._navigation = defaultMetadata.navigation;
|
|
420
|
-
this._theme = defaultMetadata.
|
|
229
|
+
this._theme = defaultMetadata.themeV2;
|
|
421
230
|
}
|
|
422
231
|
}
|
|
423
232
|
}
|