@draftbit/theme 50.6.2-8430ca.2 → 50.6.2-98b4e5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/DefaultTheme.js +1 -1
- package/lib/commonjs/Provider.js +1 -1
- package/lib/commonjs/createTheme.js +1 -1
- package/lib/commonjs/createThemeValuesProxy.js +1 -1
- package/lib/commonjs/types.js +1 -0
- package/lib/commonjs/validators.js +1 -1
- package/lib/typescript/src/DefaultTheme.js +38 -38
- package/lib/typescript/src/DefaultTheme.js.map +1 -1
- package/lib/typescript/src/Provider.js +10 -1
- package/lib/typescript/src/Provider.js.map +1 -1
- package/lib/typescript/src/createTheme.d.ts +13 -1
- package/lib/typescript/src/createTheme.js +17 -6
- package/lib/typescript/src/createTheme.js.map +1 -1
- package/lib/typescript/src/createThemeValuesProxy.js +34 -22
- package/lib/typescript/src/createThemeValuesProxy.js.map +1 -1
- package/lib/typescript/src/types.d.ts +30 -2
- package/lib/typescript/src/validators.d.ts +3 -1
- package/lib/typescript/src/validators.js +10 -45
- package/lib/typescript/src/validators.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -3
- package/src/DefaultTheme.js +38 -38
- package/src/DefaultTheme.js.map +1 -1
- package/src/DefaultTheme.ts +38 -38
- package/src/Provider.js +10 -1
- package/src/Provider.js.map +1 -1
- package/src/Provider.tsx +10 -1
- package/src/createTheme.js +17 -6
- package/src/createTheme.js.map +1 -1
- package/src/createTheme.ts +19 -12
- package/src/createThemeValuesProxy.js +34 -22
- package/src/createThemeValuesProxy.js.map +1 -1
- package/src/createThemeValuesProxy.ts +49 -31
- package/src/types.ts +33 -2
- package/src/validators.js +10 -45
- package/src/validators.js.map +1 -1
- package/src/validators.ts +12 -49
package/src/validators.js
CHANGED
|
@@ -1,52 +1,17 @@
|
|
|
1
1
|
export function validatePalettes(palettes) {
|
|
2
|
-
|
|
3
|
-
if (typeof key !== "string") {
|
|
4
|
-
throw new Error(`Invalid palettes object, ${key} is not a string`);
|
|
5
|
-
}
|
|
6
|
-
for (const [innerKey, value] of Object.entries(palettes[key])) {
|
|
7
|
-
if (typeof innerKey !== "string") {
|
|
8
|
-
throw new Error(`Invalid palette color key, ${innerKey} is not a string`);
|
|
9
|
-
}
|
|
10
|
-
if (typeof value !== "string") {
|
|
11
|
-
throw new Error(`Invalid palette color value, ${value} is not a string`);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
2
|
+
palettes;
|
|
15
3
|
}
|
|
16
4
|
export function validateBreakpoints(breakpoints) {
|
|
17
|
-
|
|
18
|
-
if (typeof key !== "string") {
|
|
19
|
-
throw new Error(`Invalid breakpoint key, ${key} is not a string`);
|
|
20
|
-
}
|
|
21
|
-
if (typeof value !== "number") {
|
|
22
|
-
throw new Error(`Invalid breakpoint value, ${value} is not a number`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
5
|
+
breakpoints;
|
|
25
6
|
}
|
|
26
7
|
export function validateTheme(theme) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (value === undefined || value === null) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
else if (typeof value === "object") {
|
|
39
|
-
validateThemeValues(value);
|
|
40
|
-
}
|
|
41
|
-
else if (typeof value !== "string" && typeof value !== "number") {
|
|
42
|
-
throw new Error(`Invalid theme value, ${value} is not a string, number, or object`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
validateThemeValues(theme.colors.branding);
|
|
47
|
-
validateThemeValues(theme.colors.text);
|
|
48
|
-
validateThemeValues(theme.colors.foreground);
|
|
49
|
-
validateThemeValues(theme.colors.background);
|
|
50
|
-
validateThemeValues(theme.colors.border);
|
|
8
|
+
theme;
|
|
9
|
+
}
|
|
10
|
+
export function isTextStyleObject(value) {
|
|
11
|
+
value;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
export function asThemeValuesObject(value) {
|
|
15
|
+
return value;
|
|
51
16
|
}
|
|
52
17
|
//# sourceMappingURL=validators.js.map
|
package/src/validators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["validators.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,QAAuB;IACtD,
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["validators.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,QAAuB;IACtD,QAAQ,CAAC;AACX,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,WAAwB;IAC1D,WAAW,CAAC;AACd,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAY;IACxC,KAAK,CAAC;AACR,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAU;IAC1C,KAAK,CAAC;IACN,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAU;IAC5C,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/src/validators.ts
CHANGED
|
@@ -1,59 +1,22 @@
|
|
|
1
1
|
import { ColorPalettes, Breakpoints, Theme, ThemeValues } from "./types";
|
|
2
2
|
|
|
3
3
|
export function validatePalettes(palettes: ColorPalettes) {
|
|
4
|
-
|
|
5
|
-
if (typeof key !== "string") {
|
|
6
|
-
throw new Error(`Invalid palettes object, ${key} is not a string`);
|
|
7
|
-
}
|
|
8
|
-
for (const [innerKey, value] of Object.entries(palettes[key])) {
|
|
9
|
-
if (typeof innerKey !== "string") {
|
|
10
|
-
throw new Error(
|
|
11
|
-
`Invalid palette color key, ${innerKey} is not a string`
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
if (typeof value !== "string") {
|
|
15
|
-
throw new Error(
|
|
16
|
-
`Invalid palette color value, ${value} is not a string`
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
4
|
+
palettes;
|
|
21
5
|
}
|
|
22
6
|
|
|
23
7
|
export function validateBreakpoints(breakpoints: Breakpoints) {
|
|
24
|
-
|
|
25
|
-
if (typeof key !== "string") {
|
|
26
|
-
throw new Error(`Invalid breakpoint key, ${key} is not a string`);
|
|
27
|
-
}
|
|
28
|
-
if (typeof value !== "number") {
|
|
29
|
-
throw new Error(`Invalid breakpoint value, ${value} is not a number`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
8
|
+
breakpoints;
|
|
32
9
|
}
|
|
33
10
|
|
|
34
11
|
export function validateTheme(theme: Theme) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} else if (typeof value === "object") {
|
|
46
|
-
validateThemeValues(value);
|
|
47
|
-
} else if (typeof value !== "string" && typeof value !== "number") {
|
|
48
|
-
throw new Error(
|
|
49
|
-
`Invalid theme value, ${value} is not a string, number, or object`
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
validateThemeValues(theme.colors.branding);
|
|
55
|
-
validateThemeValues(theme.colors.text);
|
|
56
|
-
validateThemeValues(theme.colors.foreground);
|
|
57
|
-
validateThemeValues(theme.colors.background);
|
|
58
|
-
validateThemeValues(theme.colors.border);
|
|
12
|
+
theme;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function isTextStyleObject(value: any): boolean {
|
|
16
|
+
value;
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function asThemeValuesObject(value: any): ThemeValues | null {
|
|
21
|
+
return value;
|
|
59
22
|
}
|