wjec-one 4.0.21 → 4.1.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.
package/theme/index.d.ts CHANGED
@@ -1,87 +1,435 @@
1
- /// <reference types="react" />
2
- import * as _emotion_utils from '@emotion/utils';
3
- import * as React from 'react';
4
- import { Dispatch } from 'react';
5
- import { Record } from 'immutable';
1
+ import * as react from 'react';
2
+ import { Dispatch, FC, PropsWithChildren } from 'react';
3
+ import { Implements, DeepPartial, ObjectLeaves, ColorPalette as ColorPalette$1, ColorPaletteEduqas } from 'wjec-one';
4
+ import * as _emotion_core from '@emotion/core';
6
5
 
7
- type ColorPalette = {
8
- border: string;
9
- entryLevel: string;
10
- errorBackground: string;
11
- error: string;
12
- errorDark: string;
13
- errorDarker: string;
14
- font: string;
15
- fontLight: string;
16
- gceALevel: string;
17
- gceASLevel: string;
18
- gcse: string;
19
- highlight: string;
20
- neutral: string;
21
- neutralDark: string;
22
- neutralLight: string;
23
- offBlack: string;
24
- offWhite: string;
25
- otherQualifications: string;
26
- primary: string;
27
- primaryDark: string;
28
- primaryDarkActive: string;
29
- primaryLight: string;
30
- primaryLightActive: string;
31
- primaryLightest: string;
32
- secondary: string;
33
- secondaryDark: string;
34
- secondaryDarkActive: string;
35
- secondaryLight: string;
36
- secondaryLightActive: string;
37
- success: string;
38
- successBackground: string;
39
- successDark: string;
40
- successDarker: string;
41
- tertiary: string;
42
- vQAward: string;
43
- warningBackground: string;
44
- warning: string;
45
- warningDark: string;
46
- welshBaccAdvanced: string;
47
- welshBaccFoundation: string;
48
- welshBaccNational: string;
49
- welshBaccKS4: string;
50
- };
6
+ declare const wjec: Readonly<{
7
+ readonly basicBlack: "#000000";
8
+ readonly basicBlack50: "#000000";
9
+ readonly basicNearlyWhite: "#fafcfc";
10
+ readonly basicWhite: "#ffffff";
11
+ readonly basicWhite50: "#ffffff";
12
+ readonly error: "#d22d2d";
13
+ readonly errorDark: "#931f1f";
14
+ readonly errorDarker: "#691616";
15
+ readonly errorDarkest: "#3f0d0d";
16
+ readonly errorLight: "#db5757";
17
+ readonly errorLighter: "#f2bfbf";
18
+ readonly errorLightest: "#fbebeb";
19
+ readonly highlight: "#e57300";
20
+ readonly highlightDark: "#b25900";
21
+ readonly highlightDarker: "#663300";
22
+ readonly highlightDarkest: "#331a00";
23
+ readonly highlightLight: "#f8a653";
24
+ readonly highlightLighter: "#fcd9b5";
25
+ readonly highlightLightest: "#fef2e6";
26
+ readonly neutral: "#819198";
27
+ readonly neutralDark: "#68787f";
28
+ readonly neutralDarker: "#4b585d";
29
+ readonly neutralDarker2: "#22282a";
30
+ readonly neutralDarkest: "#171b1c";
31
+ readonly neutralLight: "#9daaaf";
32
+ readonly neutralLighter: "#b9c2c6";
33
+ readonly neutralLighter2: "#d5dbdd";
34
+ readonly neutralLighter3: "#f1f3f4";
35
+ readonly neutralLightest: "#fafcfc";
36
+ readonly primary: "#007db2";
37
+ readonly primaryDark: "#005980";
38
+ readonly primaryDarker: "#004766";
39
+ readonly primaryDarkest: "#00354d";
40
+ readonly primaryLight: "#80d9ff";
41
+ readonly primaryLighter: "#b2e8ff";
42
+ readonly primaryLightest: "#e5f7ff";
43
+ readonly qualificationMurkyGreenLight: "#acc081";
44
+ readonly qualificationMurkyGreenMid: "#81994d";
45
+ readonly qualificationOrangeLight: "#f8a653";
46
+ readonly qualificationPinkLight: "#ffc0cb";
47
+ readonly qualificationPinkMid: "#ff8fa2";
48
+ readonly qualificationPlum: "#b858f4";
49
+ readonly qualificationTeal: "#4d9995";
50
+ readonly qualificationTealishBlueLight: "#aeb6dc";
51
+ readonly qualificationTealishBlueMid: "#5f6fba";
52
+ readonly qualificationYellowLight: "#f9e186";
53
+ readonly secondary: "#247d8f";
54
+ readonly secondaryDark: "#1a5966";
55
+ readonly secondaryDarker: "#135e6d";
56
+ readonly secondaryDarkest: "#0f363d";
57
+ readonly secondaryLight: "#70c9db";
58
+ readonly secondaryLighter: "#c2e8f0";
59
+ readonly secondaryLightest: "#ebf7fa";
60
+ readonly secondaryLightest2: "#f7fcfd";
61
+ readonly success: "#357e38";
62
+ readonly successDark: "#265a26";
63
+ readonly successDarker: "#1e481e";
64
+ readonly successLight: "#5dbb5d";
65
+ readonly successLighter: "#aad4aa";
66
+ readonly successLightest: "#ecf7ec";
67
+ readonly tertiary: "#f4c924";
68
+ readonly tertiaryDark: "#aa8909";
69
+ readonly tertiaryDarker: "#796206";
70
+ readonly tertiaryDarkest: "#493b04";
71
+ readonly tertiaryLight: "#f6d555";
72
+ readonly tertiaryLighter: "#f9e186";
73
+ readonly tertiaryLightest: "#fef9e7";
74
+ readonly warning: "#e57300";
75
+ readonly warningDark: "#b25900";
76
+ readonly warningDarker: "#663300";
77
+ readonly warningDarkest: "#331a00";
78
+ readonly warningLight: "#ff8c1a";
79
+ readonly warningLighter: "#fcd9b5";
80
+ readonly warningLightest: "#fef2e6";
81
+ }>;
82
+ declare const eduqas: Readonly<{
83
+ readonly primary: "#F1511B";
84
+ readonly primaryDark: "#BF3608";
85
+ readonly primaryLight: "#FDB8A1";
86
+ readonly basicBlack: "#000000";
87
+ readonly basicBlack50: "#000000";
88
+ readonly basicNearlyWhite: "#fafcfc";
89
+ readonly basicWhite: "#ffffff";
90
+ readonly basicWhite50: "#ffffff";
91
+ readonly error: "#d22d2d";
92
+ readonly errorDark: "#931f1f";
93
+ readonly errorDarker: "#691616";
94
+ readonly errorDarkest: "#3f0d0d";
95
+ readonly errorLight: "#db5757";
96
+ readonly errorLighter: "#f2bfbf";
97
+ readonly errorLightest: "#fbebeb";
98
+ readonly highlight: "#e57300";
99
+ readonly highlightDark: "#b25900";
100
+ readonly highlightDarker: "#663300";
101
+ readonly highlightDarkest: "#331a00";
102
+ readonly highlightLight: "#f8a653";
103
+ readonly highlightLighter: "#fcd9b5";
104
+ readonly highlightLightest: "#fef2e6";
105
+ readonly neutral: "#819198";
106
+ readonly neutralDark: "#68787f";
107
+ readonly neutralDarker: "#4b585d";
108
+ readonly neutralDarker2: "#22282a";
109
+ readonly neutralDarkest: "#171b1c";
110
+ readonly neutralLight: "#9daaaf";
111
+ readonly neutralLighter: "#b9c2c6";
112
+ readonly neutralLighter2: "#d5dbdd";
113
+ readonly neutralLighter3: "#f1f3f4";
114
+ readonly neutralLightest: "#fafcfc";
115
+ readonly primaryDarker: "#004766";
116
+ readonly primaryDarkest: "#00354d";
117
+ readonly primaryLighter: "#b2e8ff";
118
+ readonly primaryLightest: "#e5f7ff";
119
+ readonly qualificationMurkyGreenLight: "#acc081";
120
+ readonly qualificationMurkyGreenMid: "#81994d";
121
+ readonly qualificationOrangeLight: "#f8a653";
122
+ readonly qualificationPinkLight: "#ffc0cb";
123
+ readonly qualificationPinkMid: "#ff8fa2";
124
+ readonly qualificationPlum: "#b858f4";
125
+ readonly qualificationTeal: "#4d9995";
126
+ readonly qualificationTealishBlueLight: "#aeb6dc";
127
+ readonly qualificationTealishBlueMid: "#5f6fba";
128
+ readonly qualificationYellowLight: "#f9e186";
129
+ readonly secondary: "#247d8f";
130
+ readonly secondaryDark: "#1a5966";
131
+ readonly secondaryDarker: "#135e6d";
132
+ readonly secondaryDarkest: "#0f363d";
133
+ readonly secondaryLight: "#70c9db";
134
+ readonly secondaryLighter: "#c2e8f0";
135
+ readonly secondaryLightest: "#ebf7fa";
136
+ readonly secondaryLightest2: "#f7fcfd";
137
+ readonly success: "#357e38";
138
+ readonly successDark: "#265a26";
139
+ readonly successDarker: "#1e481e";
140
+ readonly successLight: "#5dbb5d";
141
+ readonly successLighter: "#aad4aa";
142
+ readonly successLightest: "#ecf7ec";
143
+ readonly tertiary: "#f4c924";
144
+ readonly tertiaryDark: "#aa8909";
145
+ readonly tertiaryDarker: "#796206";
146
+ readonly tertiaryDarkest: "#493b04";
147
+ readonly tertiaryLight: "#f6d555";
148
+ readonly tertiaryLighter: "#f9e186";
149
+ readonly tertiaryLightest: "#fef9e7";
150
+ readonly warning: "#e57300";
151
+ readonly warningDark: "#b25900";
152
+ readonly warningDarker: "#663300";
153
+ readonly warningDarkest: "#331a00";
154
+ readonly warningLight: "#ff8c1a";
155
+ readonly warningLighter: "#fcd9b5";
156
+ readonly warningLightest: "#fef2e6";
157
+ }>;
51
158
 
52
- declare const _default: ColorPalette;
159
+ declare const colors_d_eduqas: typeof eduqas;
160
+ declare const colors_d_wjec: typeof wjec;
161
+ declare namespace colors_d {
162
+ export {
163
+ colors_d_eduqas as eduqas,
164
+ colors_d_wjec as wjec,
165
+ };
166
+ }
53
167
 
54
- type ThemeState$1 = {
55
- brand: 'eduqas' | 'wjec';
56
- colorPalette: typeof _default;
168
+ type ColorPalette = {
169
+ basicBlack: string;
170
+ basicBlack50: string;
171
+ basicNearlyWhite: string;
172
+ basicWhite: string;
173
+ basicWhite50: string;
174
+ errorDark: string;
175
+ errorDarker: string;
176
+ errorDarkest: string;
177
+ error: string;
178
+ errorLight: string;
179
+ errorLighter: string;
180
+ errorLightest: string;
181
+ highlightDark: string;
182
+ highlightDarker: string;
183
+ highlightDarkest: string;
184
+ highlight: string;
185
+ highlightLight: string;
186
+ highlightLighter: string;
187
+ highlightLightest: string;
188
+ neutralDark: string;
189
+ neutralDarker: string;
190
+ neutralDarker2: string;
191
+ neutralDarkest: string;
192
+ neutral: string;
193
+ neutralLight: string;
194
+ neutralLighter: string;
195
+ neutralLighter2: string;
196
+ neutralLighter3: string;
197
+ neutralLightest: string;
198
+ primaryDark: string;
199
+ primaryDarker: string;
200
+ primaryDarkest: string;
201
+ primary: string;
202
+ primaryLight: string;
203
+ primaryLighter: string;
204
+ primaryLightest: string;
205
+ qualificationMurkyGreenLight: string;
206
+ qualificationMurkyGreenMid: string;
207
+ qualificationOrangeLight: string;
208
+ qualificationPinkLight: string;
209
+ qualificationPinkMid: string;
210
+ qualificationPlum: string;
211
+ qualificationTeal: string;
212
+ qualificationTealishBlueLight: string;
213
+ qualificationTealishBlueMid: string;
214
+ qualificationYellowLight: string;
215
+ secondaryDark: string;
216
+ secondaryDarker: string;
217
+ secondaryDarkest: string;
218
+ secondary: string;
219
+ secondaryLight: string;
220
+ secondaryLighter: string;
221
+ secondaryLightest: string;
222
+ secondaryLightest2: string;
223
+ successDark: string;
224
+ successDarker: string;
225
+ success: string;
226
+ successLight: string;
227
+ successLighter: string;
228
+ successLightest: string;
229
+ tertiaryDark: string;
230
+ tertiaryDarker: string;
231
+ tertiaryDarkest: string;
232
+ tertiary: string;
233
+ tertiaryLight: string;
234
+ tertiaryLighter: string;
235
+ tertiaryLightest: string;
236
+ warningDark: string;
237
+ warningDarker: string;
238
+ warningDarkest: string;
239
+ warning: string;
240
+ warningLight: string;
241
+ warningLighter: string;
242
+ warningLightest: string;
57
243
  };
58
-
59
- type Action = AsyncAction | SimpleAction;
60
- type AsyncAction = (dispatch: Dispatch<Action>, state: DestructurableRecord<any>) => void | Promise<void>;
61
- type ContextHook<T> = <R extends any, U extends {
62
- [key: string]: (state: T) => R;
63
- }>(selectors?: U) => [
64
- DestructurableRecord<T & {
65
- [K in keyof U]: ReturnType<U[K]>;
66
- }>,
67
- Dispatch<Action>
68
- ];
69
- type DestructurableRecord<T extends {}> = Record<T> & {
70
- [K in keyof T]: T[K];
71
- };
72
- type SimpleAction = {
73
- payload?: any;
74
- type: string;
244
+ type ThemeCategory = {
245
+ [category: string]: keyof ColorPalette | ThemeCategory;
246
+ };
247
+ type ThemeColorMapping = Implements<ThemeCategory, {
248
+ controls: {
249
+ borders: {
250
+ default: keyof ColorPalette;
251
+ defaultDarker: keyof ColorPalette;
252
+ defaultHover: keyof ColorPalette;
253
+ defaultLight: keyof ColorPalette;
254
+ disabled: keyof ColorPalette;
255
+ error: keyof ColorPalette;
256
+ primary: keyof ColorPalette;
257
+ primaryHover: keyof ColorPalette;
258
+ secondary: keyof ColorPalette;
259
+ secondaryHover: keyof ColorPalette;
260
+ success: keyof ColorPalette;
261
+ warning: keyof ColorPalette;
262
+ white: keyof ColorPalette;
263
+ };
264
+ container: {
265
+ background: keyof ColorPalette;
266
+ backgroundLightgrey: keyof ColorPalette;
267
+ boldGreen: keyof ColorPalette;
268
+ boldRed: keyof ColorPalette;
269
+ boldYellow: keyof ColorPalette;
270
+ border: keyof ColorPalette;
271
+ error: keyof ColorPalette;
272
+ primary: keyof ColorPalette;
273
+ success: keyof ColorPalette;
274
+ warning: keyof ColorPalette;
275
+ };
276
+ interaction: {
277
+ default: keyof ColorPalette;
278
+ defaultActive: keyof ColorPalette;
279
+ defaultHover: keyof ColorPalette;
280
+ disabled: keyof ColorPalette;
281
+ error: keyof ColorPalette;
282
+ errorActive: keyof ColorPalette;
283
+ errorHover: keyof ColorPalette;
284
+ errorSecondary: keyof ColorPalette;
285
+ errorSecondaryActive: keyof ColorPalette;
286
+ errorSecondaryHover: keyof ColorPalette;
287
+ primary: keyof ColorPalette;
288
+ primaryActive: keyof ColorPalette;
289
+ primaryHover: keyof ColorPalette;
290
+ primaryLightBackground: keyof ColorPalette;
291
+ secondary: keyof ColorPalette;
292
+ secondaryActive: keyof ColorPalette;
293
+ secondaryHover: keyof ColorPalette;
294
+ success: keyof ColorPalette;
295
+ successActive: keyof ColorPalette;
296
+ successHover: keyof ColorPalette;
297
+ successLightBackground: keyof ColorPalette;
298
+ tertiary: keyof ColorPalette;
299
+ tertiaryActive: keyof ColorPalette;
300
+ tertiaryHover: keyof ColorPalette;
301
+ textDark: keyof ColorPalette;
302
+ textDisabled: keyof ColorPalette;
303
+ textLight: keyof ColorPalette;
304
+ textSecondaryDark: keyof ColorPalette;
305
+ textSecondaryLight: keyof ColorPalette;
306
+ warning: keyof ColorPalette;
307
+ warningActive: keyof ColorPalette;
308
+ warningHover: keyof ColorPalette;
309
+ };
310
+ userInput: {
311
+ background: {
312
+ default: keyof ColorPalette;
313
+ defaultHover: keyof ColorPalette;
314
+ defaultShadow: keyof ColorPalette;
315
+ error: keyof ColorPalette;
316
+ primary: keyof ColorPalette;
317
+ primaryHover: keyof ColorPalette;
318
+ secondary: keyof ColorPalette;
319
+ secondaryHover: keyof ColorPalette;
320
+ success: keyof ColorPalette;
321
+ warning: keyof ColorPalette;
322
+ };
323
+ icon: {
324
+ default: keyof ColorPalette;
325
+ defaultLight: keyof ColorPalette;
326
+ disabled: keyof ColorPalette;
327
+ error: keyof ColorPalette;
328
+ primary: keyof ColorPalette;
329
+ primaryDark: keyof ColorPalette;
330
+ primaryLight: keyof ColorPalette;
331
+ secondary: keyof ColorPalette;
332
+ secondaryDark: keyof ColorPalette;
333
+ secondaryLight: keyof ColorPalette;
334
+ success: keyof ColorPalette;
335
+ warning: keyof ColorPalette;
336
+ };
337
+ message: {
338
+ default: keyof ColorPalette;
339
+ error: keyof ColorPalette;
340
+ success: keyof ColorPalette;
341
+ warning: keyof ColorPalette;
342
+ };
343
+ text: {
344
+ default: keyof ColorPalette;
345
+ defaultLighter: keyof ColorPalette;
346
+ disabled: keyof ColorPalette;
347
+ label: keyof ColorPalette;
348
+ placeholder: keyof ColorPalette;
349
+ };
350
+ };
351
+ };
352
+ foundational: {
353
+ background: keyof ColorPalette;
354
+ border: keyof ColorPalette;
355
+ eduqas: keyof ColorPalette;
356
+ neutral: keyof ColorPalette;
357
+ primary: keyof ColorPalette;
358
+ secondary: keyof ColorPalette;
359
+ tertiary: keyof ColorPalette;
360
+ white: keyof ColorPalette;
361
+ wjec: keyof ColorPalette;
362
+ };
363
+ qualifications: {
364
+ entrylevel: keyof ColorPalette;
365
+ gcealevel: keyof ColorPalette;
366
+ gceaslevel: keyof ColorPalette;
367
+ gcse: keyof ColorPalette;
368
+ otherquals: keyof ColorPalette;
369
+ vqaward: keyof ColorPalette;
370
+ wbqadvanced: keyof ColorPalette;
371
+ wbqfoundation: keyof ColorPalette;
372
+ wbqkeystage4: keyof ColorPalette;
373
+ wbqnational: keyof ColorPalette;
374
+ };
375
+ text: {
376
+ body: {
377
+ accent: keyof ColorPalette;
378
+ default: keyof ColorPalette;
379
+ disabled: keyof ColorPalette;
380
+ highlight: keyof ColorPalette;
381
+ link: keyof ColorPalette;
382
+ linkHoverBackground: keyof ColorPalette;
383
+ };
384
+ heading: {
385
+ large: keyof ColorPalette;
386
+ medium: keyof ColorPalette;
387
+ primary: keyof ColorPalette;
388
+ secondary: keyof ColorPalette;
389
+ };
390
+ };
391
+ }>;
392
+ type ThemeConfig = {
393
+ colorMapping?: DeepPartial<ThemeColorMapping>;
394
+ colorPalette: ColorPalette;
395
+ name: string;
75
396
  };
397
+ interface ThemeRegister {
398
+ legacyEduqas: ThemeConfig;
399
+ eduqas: ThemeConfig;
400
+ legacyWjec: ThemeConfig;
401
+ wjec: ThemeConfig;
402
+ }
403
+ type Theme = {
404
+ colorPalette: ColorPalette;
405
+ name: string;
406
+ themeColors: ThemeColorMapping;
407
+ };
408
+
409
+ declare const cssVar: (path: keyof ColorPalette | ObjectLeaves<ThemeColorMapping>) => `var(--${string})`;
410
+ declare const getCssColorVariableName: (path: keyof ColorPalette | ObjectLeaves<ThemeColorMapping>) => `--${string}`;
411
+ declare const registerThemes: (newThemeConfigs: {
412
+ [theme: string]: ThemeConfig;
413
+ }) => void;
76
414
 
77
- type ThemeState = ThemeState$1;
415
+ type ThemeState = {
416
+ brand: 'eduqas' | 'wjec';
417
+ colorPalette: typeof ColorPalette$1 | typeof ColorPaletteEduqas;
418
+ };
419
+ type ThemeStylesType = (_emotion_core.SerializedStyles extends undefined ? 0 : 1) extends 1 ? _emotion_core.SerializedStyles : react.CSSProperties;
420
+ declare const selectBrand: (brand: "eduqas" | "wjec") => void;
421
+ declare const useWjecOneTheme: () => [ThemeState, Dispatch<any>];
422
+ declare const useWjecOneThemeStyles: <S extends {
423
+ [key: string]: ThemeStylesType;
424
+ }>(styles: S | ((theme: ThemeState) => S)) => S;
78
425
 
79
- declare const selectBrand: (payload?: "eduqas" | "wjec") => SimpleAction;
80
- declare const themeContext: React.Context<[DestructurableRecord<ThemeState$1>, React.Dispatch<Action>]>;
81
- declare const WjecOneThemeProvider: React.FC<React.PropsWithChildren<Pick<ThemeState$1, "brand">>>;
82
- declare const useWjecOneTheme: ContextHook<ThemeState$1>;
83
- declare const useWjecOneThemeStyles: <S extends {
84
- [key: string]: _emotion_utils.SerializedStyles;
85
- }>(styles: S | ((theme: ThemeState$1) => S)) => S;
426
+ declare const getTheme: (theme?: keyof ThemeRegister) => Readonly<Theme>;
427
+ declare const setTheme: (themeOrSetter: keyof ThemeRegister | ((currentTheme: keyof ThemeRegister) => keyof ThemeRegister)) => void;
428
+ type ThemeProviderProps = PropsWithChildren<{
429
+ defaultTheme?: keyof ThemeRegister;
430
+ }>;
431
+ declare const ThemeProvider: FC<ThemeProviderProps>;
432
+ declare const useTheme: (theme?: keyof ThemeRegister) => Readonly<Theme>;
433
+ declare const useThemeColor: <T extends string>(color: T | keyof ColorPalette) => string;
86
434
 
87
- export { ThemeState, WjecOneThemeProvider, selectBrand, themeContext, useWjecOneTheme, useWjecOneThemeStyles };
435
+ export { ColorPalette, Theme, ThemeColorMapping, ThemeConfig, ThemeProvider, ThemeRegister, ThemeState, colors_d as colors, cssVar, getCssColorVariableName, getTheme, registerThemes, selectBrand, setTheme, useTheme, useThemeColor, useWjecOneTheme, useWjecOneThemeStyles };
package/theme/index.js CHANGED
@@ -1 +1 @@
1
- import{createSimpleAction as r,createContext as e}from"wjec-one/store";import{isCallableFunction as t}from"wjec-one/utils";import{useMemo as n}from"react";function o(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function a(r,e,t){return(e=function(r){var e=function(r,e){if("object"!=typeof r||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==typeof e?e:e+""}(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function i(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function c(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?i(Object(t),!0).forEach((function(e){a(r,e,t[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}))}return r}function u(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,c=[],u=!0,l=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=a.call(t)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(r){l=!0,o=r}finally{try{if(!u&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(r,e)||function(r,e){if(r){if("string"==typeof r)return o(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(r,e):void 0}}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var l=r("SELECT_BRAND"),f=Object.freeze({border:"#BCCBD1",entryLevel:"#6B994D",error:"#D32F2F",errorBackground:"#FBEBEB",errorDark:"#A82424",errorDarker:"#661616",font:"#2E3638",fontLight:"#606A6C",gceALevel:"#516FA2",gceASLevel:"#4D9995",gcse:"#81994D",highlight:"#FFEDC1",neutral:"#F1F3F4",neutralDark:"#2D3538",neutralLight:"#56666C",offBlack:"#001B26",offWhite:"#FAFCFC",otherQualifications:"#A55395",secondary:"#47BAD1",secondaryDark:"#1F6B7A",secondaryDarkActive:"#103840",secondaryLight:"#C0E8F0",secondaryLightActive:"#96CBD6",success:"#43A047",successBackground:"#EDF6ED",successDark:"#3C9040",successDarker:"#2A662D",tertiary:"#FFEDC1",vQAward:"#D86C8B",warning:"#F57C00",warningBackground:"#FEF2E6",warningDark:"#EF6C00",welshBaccAdvanced:"#6E81DC",welshBaccFoundation:"#BF8660",welshBaccNational:"#B4C160",welshBaccKS4:"#B25A6C"}),s=Object.freeze(c(c({},f),{},{primary:"#007DB2",primaryDark:"#00628C",primaryDarkActive:"#004766",primaryLight:"#E5F8FF",primaryLightActive:"#CCF1FF",primaryLightest:"#E5F7FF"})),y=Object.freeze(c(c({},f),{},{primary:"#F1511B",primaryDark:"#BF3608",primaryDarkActive:"#BF3608",primaryLight:"#FDB8A1",primaryLightActive:"#FDB8A1"})),m=function(r,e){var t=e.payload;return"SELECT_BRAND"===e.type?r.merge({brand:t,colorPalette:"wjec"===t?s:y}):r},p={brand:"wjec",colorPalette:s},b=function(){var r=e(m,p,(function(r,e){var t=r.brand,n=e.colorPalette;return{colorPalette:"eduqas"===t?y:n}})),o=r.context,a=r.hook,i=r.provider;return{selectBrand:l,themeContext:o,WjecOneThemeProvider:i,useWjecOneTheme:a,useWjecOneThemeStyles:function(r){var e=u(a(),1)[0];return n((function(){return t(r)?r(e):r}),[e.brand])}}}(),h=b.selectBrand,v=b.themeContext,d=b.WjecOneThemeProvider,g=b.useWjecOneTheme,F=b.useWjecOneThemeStyles;export{d as WjecOneThemeProvider,h as selectBrand,v as themeContext,g as useWjecOneTheme,F as useWjecOneThemeStyles};
1
+ import{useMemo as e,createContext as r,useState as a,createElement as t,useContext as i}from"react";import{ColorPaletteEduqas as n,ColorPalette as c,useIsMounted as s}from"wjec-one";import{deepFreeze as o,deepMerge as l,noop as d}from"wjec-one/utils";const h={selectedTheme:"wjec",themes:{legacyEduqas:void 0,eduqas:void 0,legacyWjec:void 0,wjec:void 0}},u=e=>h[e],g=e=>{Object.entries(e).forEach(([e,r])=>{h[e]=r})},f=Object.freeze({basicBlack:"#000000",basicBlack50:"#000000",basicNearlyWhite:"#fafcfc",basicWhite:"#ffffff",basicWhite50:"#ffffff",error:"#d22d2d",errorDark:"#931f1f",errorDarker:"#691616",errorDarkest:"#3f0d0d",errorLight:"#db5757",errorLighter:"#f2bfbf",errorLightest:"#fbebeb",highlight:"#e57300",highlightDark:"#b25900",highlightDarker:"#663300",highlightDarkest:"#331a00",highlightLight:"#f8a653",highlightLighter:"#fcd9b5",highlightLightest:"#fef2e6",neutral:"#819198",neutralDark:"#68787f",neutralDarker:"#4b585d",neutralDarker2:"#22282a",neutralDarkest:"#171b1c",neutralLight:"#9daaaf",neutralLighter:"#b9c2c6",neutralLighter2:"#d5dbdd",neutralLighter3:"#f1f3f4",neutralLightest:"#fafcfc",primary:"#007db2",primaryDark:"#005980",primaryDarker:"#004766",primaryDarkest:"#00354d",primaryLight:"#80d9ff",primaryLighter:"#b2e8ff",primaryLightest:"#e5f7ff",qualificationMurkyGreenLight:"#acc081",qualificationMurkyGreenMid:"#81994d",qualificationOrangeLight:"#f8a653",qualificationPinkLight:"#ffc0cb",qualificationPinkMid:"#ff8fa2",qualificationPlum:"#b858f4",qualificationTeal:"#4d9995",qualificationTealishBlueLight:"#aeb6dc",qualificationTealishBlueMid:"#5f6fba",qualificationYellowLight:"#f9e186",secondary:"#247d8f",secondaryDark:"#1a5966",secondaryDarker:"#135e6d",secondaryDarkest:"#0f363d",secondaryLight:"#70c9db",secondaryLighter:"#c2e8f0",secondaryLightest:"#ebf7fa",secondaryLightest2:"#f7fcfd",success:"#357e38",successDark:"#265a26",successDarker:"#1e481e",successLight:"#5dbb5d",successLighter:"#aad4aa",successLightest:"#ecf7ec",tertiary:"#f4c924",tertiaryDark:"#aa8909",tertiaryDarker:"#796206",tertiaryDarkest:"#493b04",tertiaryLight:"#f6d555",tertiaryLighter:"#f9e186",tertiaryLightest:"#fef9e7",warning:"#e57300",warningDark:"#b25900",warningDarker:"#663300",warningDarkest:"#331a00",warningLight:"#ff8c1a",warningLighter:"#fcd9b5",warningLightest:"#fef2e6"}),y=Object.freeze({...f,primary:"#F1511B",primaryDark:"#BF3608",primaryLight:"#FDB8A1"});var L=Object.freeze({__proto__:null,eduqas:y,wjec:f});const m=Object.freeze({controls:{borders:{default:"neutralLight",defaultDarker:"neutralDark",defaultHover:"neutral",defaultLight:"neutralLighter2",disabled:"neutralLight",error:"error",primary:"primary",primaryHover:"primaryDark",secondary:"secondary",secondaryHover:"secondaryDark",success:"success",warning:"warning",white:"basicWhite"},container:{background:"basicWhite",backgroundLightgrey:"neutralLighter3",boldGreen:"successLighter",boldRed:"errorLighter",boldYellow:"tertiaryLighter",border:"neutralLighter2",error:"errorLightest",primary:"primaryLightest",success:"successLightest",warning:"warningLightest"},interaction:{default:"neutralLighter2",defaultActive:"neutralDark",defaultHover:"neutralLight",disabled:"neutralLighter3",error:"error",errorActive:"errorDarker",errorHover:"errorDark",errorSecondary:"errorLightest",errorSecondaryActive:"errorLight",errorSecondaryHover:"errorLighter",primary:"primary",primaryActive:"primaryDarker",primaryHover:"primaryDark",primaryLightBackground:"primaryLightest",secondary:"secondaryLightest",secondaryActive:"secondaryLight",secondaryHover:"secondaryLighter",success:"success",successActive:"successDarker",successHover:"successDark",successLightBackground:"successLightest",tertiary:"tertiary",tertiaryActive:"tertiaryDarker",tertiaryHover:"tertiaryDark",textDark:"neutralDarker2",textDisabled:"neutralLighter",textLight:"neutralLightest",textSecondaryDark:"secondaryDarker",textSecondaryLight:"secondaryLightest",warning:"warning",warningActive:"warningDarker",warningHover:"warningDark"},userInput:{background:{default:"basicWhite",defaultHover:"neutralLighter3",defaultShadow:"neutralLighter2",error:"errorLightest",primary:"primaryLightest",primaryHover:"primaryLighter",secondary:"secondaryLightest",secondaryHover:"secondaryLighter",success:"successLightest",warning:"warningLightest"},icon:{default:"neutralDark",defaultLight:"neutralLighter3",disabled:"neutralLighter",error:"error",primary:"primary",primaryDark:"primaryDark",primaryLight:"primaryLighter",secondary:"secondary",secondaryDark:"secondaryDark",secondaryLight:"secondaryLighter",success:"success",warning:"warning"},message:{default:"neutralDarker",error:"errorDark",success:"successDark",warning:"warningDark"},text:{default:"neutralDarker2",defaultLighter:"neutralLightest",disabled:"neutral",label:"neutralDarker",placeholder:"neutral"}}},foundational:{background:"neutralLighter3",border:"neutralLighter",eduqas:"warning",neutral:"neutral",primary:"primary",secondary:"secondary",tertiary:"tertiary",white:"basicWhite",wjec:"primary"},qualifications:{entrylevel:"qualificationMurkyGreenLight",gcealevel:"qualificationTealishBlueMid",gceaslevel:"qualificationTeal",gcse:"qualificationMurkyGreenMid",otherquals:"qualificationPlum",vqaward:"qualificationPinkMid",wbqadvanced:"qualificationTealishBlueLight",wbqfoundation:"qualificationOrangeLight",wbqkeystage4:"qualificationPinkLight",wbqnational:"qualificationYellowLight"},text:{body:{accent:"warningDark",default:"neutralDarker2",disabled:"neutral",highlight:"primaryDark",link:"primary",linkHoverBackground:"primaryLighter"},heading:{large:"primaryDarkest",medium:"neutralDarker2",primary:"primary",secondary:"secondary"}}}),k=({colorMapping:e={},...r})=>o({...r,themeColors:l(m,e)}),b=e=>`var(${p(e)})`,p=e=>`--${e.replaceAll(".","_").replaceAll(/[A-Z]/g,e=>`-${e.toLocaleLowerCase()}`)}`,D=e=>{const r=u("themes"),a=Object.fromEntries(Object.entries(e).map(([e,r])=>[e,k(r)]));g({themes:{...r,...a}})};let w,q;const v=()=>{const e=u("selectedTheme"),r=u("themes"),a=r[e].colorPalette,t=Object.keys(a).map(e=>`${p(e)}: ${a[e]};`),i=(e,r)=>{const a=[];return Object.entries(e).forEach(([e,t])=>{const n=`${r}.${e}`;if("string"==typeof t){const e=p(n);a.push(`${e}: ${b(t)};`)}else"object"==typeof t&&a.push(...i(t,n).flat())}),a},n=Object.entries(r[e].themeColors).map(([e,r])=>i(r,e)).flat();w.setAttribute("data-wjec-one-color-palette",e),q.setAttribute("data-wjec-one-theme-colors",e),w.innerHTML=`\n :root {\n ${t.join("\n")}\n }\n `,q.innerHTML=`\n :root {\n ${n.join("\n")}\n }\n `},j=e=>M(e),T=()=>{E();const e=u("selectedTheme").toLocaleLowerCase().includes("eduqas")?"eduqas":"wjec";return[{brand:e,colorPalette:"eduqas"===e?n:c},(...e)=>d()]},H=r=>{const[a]=T();return e(()=>"function"==typeof r?r(a):r,[a])};((e={})=>{D(e),w=document.createElement("style"),q=document.createElement("style"),document.head.appendChild(w),document.head.appendChild(q),v()})({legacyEduqas:{colorPalette:n,name:"Eduqas 4.0"},eduqas:{colorPalette:y,name:"Eduqas 5.0"},legacyWjec:{colorPalette:c,name:"WJEC 4.0"},wjec:{colorPalette:f,name:"WJEC 5.0"}});const A=(e=u("selectedTheme"))=>u("themes")[e],O=r(u("themes")[u("selectedTheme")]);let P;const M=e=>{const r="function"==typeof e?e(u("selectedTheme")):e;g({selectedTheme:r}),v(),P?.(r)},B=({children:e,defaultTheme:r="wjec"})=>{const i=s(),[n,c]=a(r);return i.current||r===u("selectedTheme")||M(r),P=c,t(O.Provider,{value:A(n)},e)},E=(e=u("selectedTheme"))=>{const r=i(O);return e!==u("selectedTheme")?u("themes")[e]:r},W=e=>{const{colorPalette:r}=E();return Object.hasOwn(r,e)?r[e]:e};export{B as ThemeProvider,L as colors,b as cssVar,p as getCssColorVariableName,A as getTheme,D as registerThemes,j as selectBrand,M as setTheme,E as useTheme,W as useThemeColor,T as useWjecOneTheme,H as useWjecOneThemeStyles};