@tamagui/create-theme 1.5.21 → 1.5.23
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/package.json +3 -3
- package/dist/cjs/colorUtils.js +0 -65
- package/dist/cjs/colorUtils.js.map +0 -7
- package/dist/cjs/createTheme.js +0 -113
- package/dist/cjs/createTheme.js.map +0 -7
- package/dist/cjs/createThemes.js +0 -298
- package/dist/cjs/createThemes.js.map +0 -7
- package/dist/esm/colorUtils.js +0 -40
- package/dist/esm/colorUtils.js.map +0 -7
- package/dist/esm/createTheme.js +0 -85
- package/dist/esm/createTheme.js.map +0 -7
- package/dist/esm/createTheme.mjs +0 -85
- package/dist/esm/createTheme.mjs.map +0 -7
- package/dist/esm/createThemes.js +0 -274
- package/dist/esm/createThemes.js.map +0 -7
- package/types/createTheme.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/create-theme",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.23",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tamagui/web": "^1.5.
|
|
30
|
+
"@tamagui/web": "^1.5.23"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@tamagui/build": "^1.5.
|
|
33
|
+
"@tamagui/build": "^1.5.23"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
package/dist/cjs/colorUtils.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var colorUtils_exports = {};
|
|
20
|
-
__export(colorUtils_exports, {
|
|
21
|
-
hexToRGBA: () => hexToRGBA,
|
|
22
|
-
setColorAlpha: () => setColorAlpha
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(colorUtils_exports);
|
|
25
|
-
var import_core = require("@tamagui/core");
|
|
26
|
-
const hexToRGBA = (hex, alpha = 1) => {
|
|
27
|
-
if (!isValidHex(hex)) {
|
|
28
|
-
throw new Error("Invalid HEX");
|
|
29
|
-
}
|
|
30
|
-
const chunkSize = Math.floor((hex.length - 1) / 3);
|
|
31
|
-
const hexArr = getChunksFromString(hex.slice(1), chunkSize);
|
|
32
|
-
const [r, g, b, a] = (hexArr == null ? void 0 : hexArr.map(convertHexUnitTo256)) ?? [];
|
|
33
|
-
return `rgba(${r}, ${g}, ${b}, ${getAlphaFloat(a, alpha)})`;
|
|
34
|
-
};
|
|
35
|
-
const setColorAlpha = (colorIn, alpha = 1) => {
|
|
36
|
-
const color = `${(0, import_core.getVariableValue)(colorIn)}`;
|
|
37
|
-
if (color.startsWith("hsl(")) {
|
|
38
|
-
return color.replace("hsl", "hsla").replace(")", `, ${alpha})`);
|
|
39
|
-
}
|
|
40
|
-
if (color.startsWith("#")) {
|
|
41
|
-
return hexToRGBA(color, alpha);
|
|
42
|
-
}
|
|
43
|
-
if (color.startsWith("rgb(")) {
|
|
44
|
-
return color.replace("rgb", "rgba").replace(")", `, ${alpha})`);
|
|
45
|
-
}
|
|
46
|
-
return color;
|
|
47
|
-
};
|
|
48
|
-
const isValidHex = (hex) => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
49
|
-
const getChunksFromString = (st, chunkSize = 0) => st.match(new RegExp(`.{${chunkSize}}`, "g"));
|
|
50
|
-
const convertHexUnitTo256 = (hexStr) => parseInt(hexStr.repeat(2 / hexStr.length), 16);
|
|
51
|
-
const getAlphaFloat = (a, alpha = 1) => {
|
|
52
|
-
if (a !== void 0) {
|
|
53
|
-
return a / 255;
|
|
54
|
-
}
|
|
55
|
-
if (typeof alpha !== "number" || alpha < 0 || alpha > 1) {
|
|
56
|
-
return 1;
|
|
57
|
-
}
|
|
58
|
-
return alpha;
|
|
59
|
-
};
|
|
60
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
-
0 && (module.exports = {
|
|
62
|
-
hexToRGBA,
|
|
63
|
-
setColorAlpha
|
|
64
|
-
});
|
|
65
|
-
//# sourceMappingURL=colorUtils.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/colorUtils.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Variable, getVariableValue } from '@tamagui/core'\n\nexport const hexToRGBA = (hex: string, alpha = 1) => {\n if (!isValidHex(hex)) {\n throw new Error('Invalid HEX')\n }\n const chunkSize = Math.floor((hex.length - 1) / 3)\n const hexArr = getChunksFromString(hex.slice(1), chunkSize)\n const [r, g, b, a] = hexArr?.map(convertHexUnitTo256) ?? []\n return `rgba(${r}, ${g}, ${b}, ${getAlphaFloat(a, alpha)})`\n}\n\nexport const setColorAlpha = (colorIn: string | Variable, alpha = 1) => {\n const color = `${getVariableValue(colorIn)}`\n if (color.startsWith('hsl(')) {\n return color.replace('hsl', 'hsla').replace(')', `, ${alpha})`)\n }\n if (color.startsWith('#')) {\n return hexToRGBA(color, alpha)\n }\n if (color.startsWith('rgb(')) {\n return color.replace('rgb', 'rgba').replace(')', `, ${alpha})`)\n }\n return color\n}\n\nconst isValidHex = (hex: string) => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex)\n\nconst getChunksFromString = (st: string, chunkSize = 0) =>\n st.match(new RegExp(`.{${chunkSize}}`, 'g'))\n\nconst convertHexUnitTo256 = (hexStr: string) =>\n parseInt(hexStr.repeat(2 / hexStr.length), 16)\n\nconst getAlphaFloat = (a: any, alpha = 1) => {\n if (a !== undefined) {\n return a / 255\n }\n if (typeof alpha !== 'number' || alpha < 0 || alpha > 1) {\n return 1\n }\n return alpha\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2C;AAEpC,MAAM,YAAY,CAAC,KAAa,QAAQ,MAAM;AACnD,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,UAAM,IAAI,MAAM,aAAa;AAAA,EAC/B;AACA,QAAM,YAAY,KAAK,OAAO,IAAI,SAAS,KAAK,CAAC;AACjD,QAAM,SAAS,oBAAoB,IAAI,MAAM,CAAC,GAAG,SAAS;AAC1D,QAAM,CAAC,GAAG,GAAG,GAAG,CAAC,KAAI,iCAAQ,IAAI,yBAAwB,CAAC;AAC1D,SAAO,QAAQ,MAAM,MAAM,MAAM,cAAc,GAAG,KAAK;AACzD;AAEO,MAAM,gBAAgB,CAAC,SAA4B,QAAQ,MAAM;AACtE,QAAM,QAAQ,OAAG,8BAAiB,OAAO;AACzC,MAAI,MAAM,WAAW,MAAM,GAAG;AAC5B,WAAO,MAAM,QAAQ,OAAO,MAAM,EAAE,QAAQ,KAAK,KAAK,QAAQ;AAAA,EAChE;AACA,MAAI,MAAM,WAAW,GAAG,GAAG;AACzB,WAAO,UAAU,OAAO,KAAK;AAAA,EAC/B;AACA,MAAI,MAAM,WAAW,MAAM,GAAG;AAC5B,WAAO,MAAM,QAAQ,OAAO,MAAM,EAAE,QAAQ,KAAK,KAAK,QAAQ;AAAA,EAChE;AACA,SAAO;AACT;AAEA,MAAM,aAAa,CAAC,QAAgB,6BAA6B,KAAK,GAAG;AAEzE,MAAM,sBAAsB,CAAC,IAAY,YAAY,MACnD,GAAG,MAAM,IAAI,OAAO,KAAK,cAAc,GAAG,CAAC;AAE7C,MAAM,sBAAsB,CAAC,WAC3B,SAAS,OAAO,OAAO,IAAI,OAAO,MAAM,GAAG,EAAE;AAE/C,MAAM,gBAAgB,CAAC,GAAQ,QAAQ,MAAM;AAC3C,MAAI,MAAM,QAAW;AACnB,WAAO,IAAI;AAAA,EACb;AACA,MAAI,OAAO,UAAU,YAAY,QAAQ,KAAK,QAAQ,GAAG;AACvD,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/cjs/createTheme.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var createTheme_exports = {};
|
|
20
|
-
__export(createTheme_exports, {
|
|
21
|
-
addChildren: () => addChildren,
|
|
22
|
-
applyMask: () => applyMask,
|
|
23
|
-
createStrengthenMask: () => createStrengthenMask,
|
|
24
|
-
createTheme: () => createTheme,
|
|
25
|
-
createWeakenMask: () => createWeakenMask
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(createTheme_exports);
|
|
28
|
-
const THEME_INFO = /* @__PURE__ */ new WeakMap();
|
|
29
|
-
function createTheme(palette, definition, options) {
|
|
30
|
-
const theme = {
|
|
31
|
-
...Object.fromEntries(
|
|
32
|
-
Object.entries(definition).map(([key, offset]) => {
|
|
33
|
-
return [key, getValue(palette, offset)];
|
|
34
|
-
})
|
|
35
|
-
),
|
|
36
|
-
...options == null ? void 0 : options.nonInheritedValues
|
|
37
|
-
};
|
|
38
|
-
THEME_INFO.set(theme, { palette, definition, cache: /* @__PURE__ */ new WeakMap() });
|
|
39
|
-
return theme;
|
|
40
|
-
}
|
|
41
|
-
const getValue = (palette, value) => {
|
|
42
|
-
if (typeof value === "string")
|
|
43
|
-
return value;
|
|
44
|
-
const max = palette.length - 1;
|
|
45
|
-
const isPositive = value === 0 ? !isMinusZero(value) : value >= 0;
|
|
46
|
-
const next = isPositive ? value : max + value;
|
|
47
|
-
const index = Math.min(Math.max(0, next), max);
|
|
48
|
-
return palette[index];
|
|
49
|
-
};
|
|
50
|
-
function addChildren(themes, getChildren) {
|
|
51
|
-
const out = { ...themes };
|
|
52
|
-
for (const key in themes) {
|
|
53
|
-
const subThemes = getChildren(key, themes[key]);
|
|
54
|
-
for (const sKey in subThemes) {
|
|
55
|
-
out[`${key}_${sKey}`] = subThemes[sKey];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return out;
|
|
59
|
-
}
|
|
60
|
-
const createWeakenMask = ({
|
|
61
|
-
by = 1,
|
|
62
|
-
max,
|
|
63
|
-
min = 0,
|
|
64
|
-
inverseNegatives
|
|
65
|
-
}) => {
|
|
66
|
-
return (template, { skip }) => {
|
|
67
|
-
const values = Object.entries(template);
|
|
68
|
-
const out = {};
|
|
69
|
-
for (const [key, value] of values) {
|
|
70
|
-
if (typeof value === "string")
|
|
71
|
-
continue;
|
|
72
|
-
if (skip && key in skip) {
|
|
73
|
-
out[key] = value;
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
const isPositive = value === 0 ? !isMinusZero(value) : value >= 0;
|
|
77
|
-
const direction = isPositive ? 1 : -1;
|
|
78
|
-
const invert = inverseNegatives && !isPositive ? -1 : 1;
|
|
79
|
-
const next = value + by * direction * invert;
|
|
80
|
-
const clamped = isPositive ? Math.max(min, Math.min(max, next)) : Math.min(-min, Math.max(-max, next));
|
|
81
|
-
out[key] = clamped;
|
|
82
|
-
}
|
|
83
|
-
return out;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
function isMinusZero(value) {
|
|
87
|
-
return 1 / value === -Infinity;
|
|
88
|
-
}
|
|
89
|
-
const createStrengthenMask = (props) => createWeakenMask({ ...props, inverseNegatives: true });
|
|
90
|
-
function applyMask(theme, mask, options = {}) {
|
|
91
|
-
const info = THEME_INFO.get(theme);
|
|
92
|
-
if (!info) {
|
|
93
|
-
throw new Error(
|
|
94
|
-
process.env.NODE_ENV !== "production" ? `No info found for theme, you must pass the theme created by createThemeFromPalette directly to extendTheme` : `\u274C Err2`
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
if (info.cache.has(mask)) {
|
|
98
|
-
return info.cache.get(mask);
|
|
99
|
-
}
|
|
100
|
-
const template = mask(info.definition, options);
|
|
101
|
-
const next = createTheme(info.palette, template);
|
|
102
|
-
info.cache.set(mask, next);
|
|
103
|
-
return next;
|
|
104
|
-
}
|
|
105
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
-
0 && (module.exports = {
|
|
107
|
-
addChildren,
|
|
108
|
-
applyMask,
|
|
109
|
-
createStrengthenMask,
|
|
110
|
-
createTheme,
|
|
111
|
-
createWeakenMask
|
|
112
|
-
});
|
|
113
|
-
//# sourceMappingURL=createTheme.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/createTheme.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Variable } from '@tamagui/web'\n\nexport type ThemeMask = Record<string, string | number>\nexport type Palette = string[]\nexport type ShiftMaskProps = { by: number; max: number; min?: number }\nexport type MaskOptions = { skip?: Partial<ThemeMask> }\n\ntype GenericTheme = { [key: string]: string | Variable }\ntype CreateMask = <A extends ThemeMask>(template: A, options: MaskOptions) => A\n\nconst THEME_INFO = new WeakMap<\n any,\n { palette: Palette; definition: ThemeMask; cache: WeakMap<any, any> }\n>()\n\nexport function createTheme<\n Definition extends ThemeMask,\n Extras extends Record<string, string> = {}\n>(\n palette: Palette,\n definition: Definition,\n options?: {\n nonInheritedValues?: Extras\n }\n): {\n [key in keyof Definition | keyof Extras]: string\n} {\n const theme = {\n ...(Object.fromEntries(\n Object.entries(definition).map(([key, offset]) => {\n return [key, getValue(palette, offset)]\n })\n ) as any),\n ...options?.nonInheritedValues,\n }\n THEME_INFO.set(theme, { palette, definition, cache: new WeakMap() })\n return theme\n}\n\nconst getValue = (palette: Palette, value: string | number) => {\n if (typeof value === 'string') return value\n const max = palette.length - 1\n const isPositive = value === 0 ? !isMinusZero(value) : value >= 0\n const next = isPositive ? value : max + value\n const index = Math.min(Math.max(0, next), max)\n return palette[index]\n}\n\ntype SubThemeKeys<ParentKeys, ChildKeys> = `${ParentKeys extends string\n ? ParentKeys\n : never}_${ChildKeys extends string ? ChildKeys : never}`\n\nexport function addChildren<\n Theme extends GenericTheme,\n Themes extends { [key: string]: Theme },\n GetChildren extends (name: keyof Themes, theme: Theme) => { [key: string]: Theme }\n>(\n themes: Themes,\n getChildren: GetChildren\n): Themes & {\n [key in SubThemeKeys<keyof Themes, keyof ReturnType<GetChildren>>]: Theme\n} {\n const out = { ...themes }\n for (const key in themes) {\n const subThemes = getChildren(key, themes[key])\n for (const sKey in subThemes) {\n out[`${key}_${sKey}`] = subThemes[sKey] as any\n }\n }\n return out as any\n}\n\nexport const createWeakenMask = ({\n by = 1,\n max,\n min = 0,\n inverseNegatives,\n}: ShiftMaskProps & { inverseNegatives?: boolean }) => {\n return ((template, { skip }) => {\n const values = Object.entries(template) // .filter(Number)\n const out = {}\n for (const [key, value] of values) {\n if (typeof value === 'string') continue\n if (skip && key in skip) {\n out[key] = value\n continue\n }\n const isPositive = value === 0 ? !isMinusZero(value) : value >= 0\n const direction = isPositive ? 1 : -1\n const invert = inverseNegatives && !isPositive ? -1 : 1\n const next = value + by * direction * invert\n const clamped = isPositive\n ? Math.max(min, Math.min(max, next))\n : Math.min(-min, Math.max(-max, next))\n\n out[key] = clamped\n }\n return out as typeof template\n }) as CreateMask\n}\n\nfunction isMinusZero(value) {\n return 1 / value === -Infinity\n}\n\nexport const createStrengthenMask = (props: ShiftMaskProps) =>\n createWeakenMask({ ...props, inverseNegatives: true })\n\nexport function applyMask<Theme extends GenericTheme>(\n theme: Theme,\n mask: CreateMask,\n options: MaskOptions = {}\n): Theme {\n const info = THEME_INFO.get(theme)\n if (!info) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No info found for theme, you must pass the theme created by createThemeFromPalette directly to extendTheme`\n : `\u274C Err2`\n )\n }\n if (info.cache.has(mask)) {\n return info.cache.get(mask)\n }\n\n const template = mask(info.definition, options)\n const next = createTheme(info.palette, template) as Theme\n\n info.cache.set(mask, next)\n\n return next\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,MAAM,aAAa,oBAAI,QAGrB;AAEK,SAAS,Y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AA,MACF;AACA,YAAM,aAAa,UAAU,IAAI,CAAC,YAAY,KAAK,IAAI,SAAS;AAChE,YAAM,YAAY,aAAa,IAAI;AACnC,YAAM,SAAS,oBAAoB,CAAC,aAAa,KAAK;AACtD,YAAM,OAAO,QAAQ,KAAK,YAAY;AACtC,YAAM,UAAU,aACZ,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC,IACjC,KAAK,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC;AAEvC,UAAI,GAAG,IAAI;AAAA,IACb;AACA,WAAO;AAAA,EACT;AACF;AAEA,SAAS,YAAY,OAAO;AAC1B,SAAO,IAAI,UAAU;AACvB;AAEO,MAAM,uBAAuB,CAAC,UACnC,iBAAiB,EAAE,GAAG,OAAO,kBAAkB,KAAK,CAAC;AAEhD,SAAS,UACd,OACA,MACA,UAAuB,CAAC,GACjB;AACP,QAAM,OAAO,WAAW,IAAI,KAAK;AACjC,MAAI,CAAC,MAAM;AACT,UAAM,IAAI;AAAA,MACR,QAAQ,IAAI,aAAa,eACrB,+GACA;AAAA,IACN;AAAA,EACF;AACA,MAAI,KAAK,MAAM,IAAI,IAAI,GAAG;AACxB,WAAO,KAAK,MAAM,IAAI,IAAI;AAAA,EAC5B;AAEA,QAAM,WAAW,KAAK,KAAK,YAAY,OAAO;AAC9C,QAAM,OAAO,YAAY,KAAK,SAAS,QAAQ;AAE/C,OAAK,MAAM,IAAI,MAAM,IAAI;AAEzB,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/cjs/createThemes.js
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var createThemes_exports = {};
|
|
20
|
-
__export(createThemes_exports, {
|
|
21
|
-
createThemes: () => createThemes
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(createThemes_exports);
|
|
24
|
-
var import_core = require("@tamagui/core");
|
|
25
|
-
const createThemes = ({
|
|
26
|
-
activeColor,
|
|
27
|
-
light,
|
|
28
|
-
dark,
|
|
29
|
-
colorsLight,
|
|
30
|
-
colorsDark
|
|
31
|
-
}) => {
|
|
32
|
-
function flatten(obj) {
|
|
33
|
-
const next = {};
|
|
34
|
-
for (const key in obj) {
|
|
35
|
-
Object.assign(next, obj[key]);
|
|
36
|
-
}
|
|
37
|
-
return next;
|
|
38
|
-
}
|
|
39
|
-
const darkColors = flatten(colorsDark);
|
|
40
|
-
const lightColors = flatten(colorsLight);
|
|
41
|
-
const alternates = [1, 2, 3];
|
|
42
|
-
const alts = [1, 2];
|
|
43
|
-
function createThemesFrom(name, getTheme, props) {
|
|
44
|
-
const { shift = 0 } = props;
|
|
45
|
-
const theme = getTheme(0 + shift, props);
|
|
46
|
-
let themeEntries = [[name, theme]];
|
|
47
|
-
const altThemes = alternates.map((alt) => [
|
|
48
|
-
`${name}_alt${alt}`,
|
|
49
|
-
getTheme(alt + shift + 1, props)
|
|
50
|
-
]);
|
|
51
|
-
const altButtonThemes = alternates.map((_, i) => {
|
|
52
|
-
const [bName, bTheme] = [altThemes[i][0], (altThemes[i] || altThemes[i])[1]];
|
|
53
|
-
return [`${bName}_Button`, bTheme];
|
|
54
|
-
});
|
|
55
|
-
const darkerTheme = getTheme(Math.max(0, shift + (props.isLight ? 1 : -1)), props);
|
|
56
|
-
const activeTheme = props.activeTheme || {
|
|
57
|
-
...theme,
|
|
58
|
-
borderColor: props.backgrounds[7],
|
|
59
|
-
background: props.backgrounds[6],
|
|
60
|
-
backgroundHover: props.backgrounds[6],
|
|
61
|
-
backgroundPress: props.backgrounds[6]
|
|
62
|
-
};
|
|
63
|
-
const inverted = altThemes.map(([_name, theme2]) => {
|
|
64
|
-
return {
|
|
65
|
-
...theme2,
|
|
66
|
-
background: theme2.color,
|
|
67
|
-
backgroundHover: theme2.colorHover,
|
|
68
|
-
backgroundFocus: theme2.colorFocus,
|
|
69
|
-
backgroundPress: theme2.colorPress,
|
|
70
|
-
color: theme2.background,
|
|
71
|
-
colorHover: theme2.backgroundHover,
|
|
72
|
-
colorFocus: theme2.backgroundFocus,
|
|
73
|
-
colorPress: theme2.backgroundPress
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
themeEntries = [
|
|
77
|
-
...themeEntries,
|
|
78
|
-
// keep just alts
|
|
79
|
-
...altThemes.slice(0, alts.length),
|
|
80
|
-
...altButtonThemes.slice(0, alts.length),
|
|
81
|
-
[`${name}_Button`, altThemes[1][1]],
|
|
82
|
-
[`${name}_DrawerFrame`, altThemes[2][1]],
|
|
83
|
-
[`${name}_SliderTrack`, altThemes[1][1]],
|
|
84
|
-
[`${name}_SliderTrackActive`, altThemes[2][1]],
|
|
85
|
-
[`${name}_SliderThumb`, inverted[2]],
|
|
86
|
-
[`${name}_Progress`, altThemes[2][1]],
|
|
87
|
-
[`${name}_ProgressIndicator`, inverted[2]],
|
|
88
|
-
[`${name}_Switch`, altThemes[1][1]],
|
|
89
|
-
[`${name}_SwitchThumb`, inverted[2]],
|
|
90
|
-
[`${name}_TooltipArrow`, altThemes[2][1]],
|
|
91
|
-
[`${name}_TooltipContent`, altThemes[2][1]],
|
|
92
|
-
[`${name}_darker`, darkerTheme],
|
|
93
|
-
[`${name}_active`, activeTheme]
|
|
94
|
-
];
|
|
95
|
-
const themes = Object.fromEntries(themeEntries);
|
|
96
|
-
return themes;
|
|
97
|
-
}
|
|
98
|
-
const blanks = [0, 0, 0, 0];
|
|
99
|
-
const themeCreator = (str = 1, {
|
|
100
|
-
backgrounds,
|
|
101
|
-
isLight = true,
|
|
102
|
-
isBase = false,
|
|
103
|
-
colors = [...backgrounds].reverse(),
|
|
104
|
-
borderColors = isLight ? colors : backgrounds,
|
|
105
|
-
backgroundStrong,
|
|
106
|
-
offsets: offsetsProp
|
|
107
|
-
}) => {
|
|
108
|
-
const offsets = {
|
|
109
|
-
borderColor: (offsetsProp == null ? void 0 : offsetsProp.borderColor) ?? (offsetsProp == null ? void 0 : offsetsProp.background) ?? blanks,
|
|
110
|
-
background: (offsetsProp == null ? void 0 : offsetsProp.background) ?? blanks,
|
|
111
|
-
color: (offsetsProp == null ? void 0 : offsetsProp.color) ?? blanks
|
|
112
|
-
};
|
|
113
|
-
const darkColors2 = isLight ? colors : backgrounds;
|
|
114
|
-
const lighterDir = isLight ? -1 : 1;
|
|
115
|
-
const darkerDir = -lighterDir;
|
|
116
|
-
const strongerDir = isLight ? darkerDir : lighterDir;
|
|
117
|
-
const softerDir = -strongerDir;
|
|
118
|
-
const get = (arr, index, name = "background") => {
|
|
119
|
-
return arr[Math.max(0, Math.min(index + (offsets[name][str] || 0), arr.length - 1))];
|
|
120
|
-
};
|
|
121
|
-
const theme = {
|
|
122
|
-
background: get(backgrounds, str),
|
|
123
|
-
backgroundStrong: backgroundStrong || get(backgrounds, str + strongerDir * 2),
|
|
124
|
-
backgroundHover: get(backgrounds, str + lighterDir),
|
|
125
|
-
backgroundPress: get(backgrounds, str + darkerDir),
|
|
126
|
-
backgroundFocus: get(backgrounds, str + darkerDir * 2),
|
|
127
|
-
backgroundTransparent: "hsla(0, 0%, 0%, 0.012)",
|
|
128
|
-
color: get(colors, 0 + str, "color"),
|
|
129
|
-
colorHover: get(colors, 1 + str, "color"),
|
|
130
|
-
colorPress: get(colors, 2 + str, "color"),
|
|
131
|
-
colorFocus: get(colors, 3 + str, "color"),
|
|
132
|
-
shadowColor: isLight ? "hsla(0, 0%, 0%, 0.03)" : "hsla(0, 0%, 0%, 0.2)",
|
|
133
|
-
shadowColorHover: darkColors2[!isLight ? 1 : 8],
|
|
134
|
-
shadowColorPress: darkColors2[!isLight ? 1 : 8],
|
|
135
|
-
shadowColorFocus: darkColors2[!isLight ? 1 : 8],
|
|
136
|
-
borderColor: null,
|
|
137
|
-
borderColorHover: null,
|
|
138
|
-
borderColorPress: null,
|
|
139
|
-
borderColorFocus: null,
|
|
140
|
-
color1: backgrounds[0],
|
|
141
|
-
color2: backgrounds[1],
|
|
142
|
-
color3: backgrounds[2],
|
|
143
|
-
color4: backgrounds[3],
|
|
144
|
-
color5: backgrounds[4],
|
|
145
|
-
color6: backgrounds[5],
|
|
146
|
-
color7: backgrounds[6],
|
|
147
|
-
color8: backgrounds[7],
|
|
148
|
-
color9: backgrounds[8],
|
|
149
|
-
color10: backgrounds[9],
|
|
150
|
-
color11: backgrounds[10],
|
|
151
|
-
color12: backgrounds[11],
|
|
152
|
-
placeholderColor: backgrounds[7]
|
|
153
|
-
};
|
|
154
|
-
if (isBase) {
|
|
155
|
-
Object.assign(theme, {
|
|
156
|
-
borderColor: isLight ? get(colors, 8 - str, "borderColor") : get(backgrounds, 2 + str, "borderColor"),
|
|
157
|
-
borderColorHover: isLight ? get(colors, 6 - str, "borderColor") : get(backgrounds, 3 + str, "borderColor"),
|
|
158
|
-
borderColorPress: isLight ? get(colors, 5 - str, "borderColor") : get(backgrounds, 1 + str, "borderColor"),
|
|
159
|
-
borderColorFocus: isLight ? get(colors, 4 - str, "borderColor") : get(backgrounds, 3 + str, "borderColor")
|
|
160
|
-
});
|
|
161
|
-
} else {
|
|
162
|
-
Object.assign(theme, {
|
|
163
|
-
borderColor: get(borderColors, 1 + strongerDir, "borderColor"),
|
|
164
|
-
borderColorHover: get(borderColors, 2 + strongerDir, "borderColor"),
|
|
165
|
-
borderColorPress: get(borderColors, 3 + strongerDir, "borderColor"),
|
|
166
|
-
borderColorFocus: get(borderColors, 4 + strongerDir, "borderColor")
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
return theme;
|
|
170
|
-
};
|
|
171
|
-
const lightThemes = createThemesFrom("light", themeCreator, {
|
|
172
|
-
backgrounds: light,
|
|
173
|
-
// for now web non-ios style native is...
|
|
174
|
-
backgroundStrong: import_core.isWeb ? "#fefefe" : "#f2f2f2",
|
|
175
|
-
borderColors: light.slice(2),
|
|
176
|
-
isLight: true,
|
|
177
|
-
offsets: {
|
|
178
|
-
background: [2, 2, 2, 2, 2, 2]
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
const darkThemes = createThemesFrom("dark", themeCreator, {
|
|
182
|
-
backgrounds: dark,
|
|
183
|
-
colors: light.slice(2),
|
|
184
|
-
backgroundStrong: "#070707",
|
|
185
|
-
isBase: true,
|
|
186
|
-
isLight: false,
|
|
187
|
-
// shift: 1,
|
|
188
|
-
offsets: {
|
|
189
|
-
color: [0, 4, 5, 5, 5, 5]
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
darkThemes.dark_darker.background = "#030303";
|
|
193
|
-
darkThemes.dark_darker.backgroundStrong = "#000";
|
|
194
|
-
const lightTheme = (0, import_core.createTheme)({
|
|
195
|
-
...lightColors,
|
|
196
|
-
...lightThemes.light
|
|
197
|
-
});
|
|
198
|
-
const darkTheme = (0, import_core.createTheme)({
|
|
199
|
-
...darkColors,
|
|
200
|
-
...darkThemes.dark
|
|
201
|
-
});
|
|
202
|
-
const baseThemes = {
|
|
203
|
-
// light
|
|
204
|
-
...lightThemes,
|
|
205
|
-
light: lightTheme,
|
|
206
|
-
// reserving in types, updating later
|
|
207
|
-
light_active: lightThemes.light,
|
|
208
|
-
light_Card: lightThemes.light,
|
|
209
|
-
light_SliderTrack: lightThemes.light_alt1,
|
|
210
|
-
light_SliderTrackActive: lightThemes.light_alt2,
|
|
211
|
-
light_Switch: lightThemes.light_alt2,
|
|
212
|
-
light_SwitchThumb: lightThemes.light,
|
|
213
|
-
light_DrawerFrame: lightThemes.light_alt1,
|
|
214
|
-
// dark
|
|
215
|
-
...darkThemes,
|
|
216
|
-
dark: darkTheme,
|
|
217
|
-
// reserving in types, updating later
|
|
218
|
-
dark_active: darkThemes.dark,
|
|
219
|
-
dark_Card: darkThemes.dark,
|
|
220
|
-
dark_DrawerFrame: darkThemes.dark_alt1,
|
|
221
|
-
dark_SliderTrack: darkThemes.dark_darker,
|
|
222
|
-
dark_SliderTrackActive: darkThemes.dark_alt2,
|
|
223
|
-
dark_Switch: darkThemes.dark_alt2,
|
|
224
|
-
dark_SwitchThumb: darkThemes.dark_darker,
|
|
225
|
-
dark_Button: darkThemes.dark_alt1
|
|
226
|
-
};
|
|
227
|
-
const darkEntries = Object.entries(darkTheme);
|
|
228
|
-
const lightEntries = Object.entries(lightTheme);
|
|
229
|
-
function findColors(prefix, dark2 = false) {
|
|
230
|
-
return Object.fromEntries(
|
|
231
|
-
(dark2 ? darkEntries : lightEntries).filter(([k]) => k.startsWith(prefix))
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
const colorSchemes = [];
|
|
235
|
-
for (const name in colorsLight) {
|
|
236
|
-
colorSchemes.push({
|
|
237
|
-
name,
|
|
238
|
-
colors: findColors(name),
|
|
239
|
-
darkColors: findColors(name, true)
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
const colorThemeEntries = colorSchemes.flatMap(({ name, colors, darkColors: darkColors2 }) => {
|
|
243
|
-
const [altLightThemes, altDarkThemes] = [
|
|
244
|
-
{ colors: darkColors2, backgrounds: colors },
|
|
245
|
-
{ colors, backgrounds: darkColors2 }
|
|
246
|
-
].map((props, i) => {
|
|
247
|
-
const isLight = i === 0;
|
|
248
|
-
const colorsBase = Object.values(props.colors).slice(2);
|
|
249
|
-
const [backgrounds, colors2] = [
|
|
250
|
-
Object.values(props.backgrounds),
|
|
251
|
-
isLight ? colorsBase : [colorsBase[0], "#ccc", ...colorsBase.slice(1)]
|
|
252
|
-
];
|
|
253
|
-
const scheme = isLight ? "light" : "dark";
|
|
254
|
-
const shift = isLight ? 0 : 1;
|
|
255
|
-
const themeWithAlts = createThemesFrom(name, themeCreator, {
|
|
256
|
-
// @ts-ignore
|
|
257
|
-
colors: colors2,
|
|
258
|
-
// @ts-ignore
|
|
259
|
-
backgrounds,
|
|
260
|
-
// @ts-ignore
|
|
261
|
-
borderColors: backgrounds,
|
|
262
|
-
isLight,
|
|
263
|
-
shift,
|
|
264
|
-
isBase: false,
|
|
265
|
-
offsets: {
|
|
266
|
-
background: isLight ? [2, 2, 2, 2, 2, 2] : null,
|
|
267
|
-
borderColor: isLight ? [2, 2, 2, 3, 2] : null,
|
|
268
|
-
color: isLight ? [0, 0, -1, -2, -3, -3, -4] : [-1, -1, -1, -1, -1, -1]
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
return Object.entries(themeWithAlts).map(([k, v]) => [`${scheme}_${k}`, v]);
|
|
272
|
-
});
|
|
273
|
-
return [...altLightThemes, ...altDarkThemes];
|
|
274
|
-
});
|
|
275
|
-
const colorThemes = Object.fromEntries(colorThemeEntries);
|
|
276
|
-
baseThemes.dark_active = {
|
|
277
|
-
...colorThemes[`dark_${activeColor}_alt2`],
|
|
278
|
-
background: darkColors[`${activeColor}10`],
|
|
279
|
-
backgroundHover: darkColors[`${activeColor}11`],
|
|
280
|
-
backgroundPress: darkColors[`${activeColor}9`],
|
|
281
|
-
backgroundFocus: darkColors[`${activeColor}9`],
|
|
282
|
-
color: darkColors[`${activeColor}12`],
|
|
283
|
-
colorHover: darkColors[`${activeColor}12`],
|
|
284
|
-
colorPress: darkColors[`${activeColor}12`],
|
|
285
|
-
colorFocus: darkColors[`${activeColor}12`]
|
|
286
|
-
};
|
|
287
|
-
baseThemes.light_active = baseThemes.dark_active;
|
|
288
|
-
const allThemes = {
|
|
289
|
-
...baseThemes,
|
|
290
|
-
...colorThemes
|
|
291
|
-
};
|
|
292
|
-
return allThemes;
|
|
293
|
-
};
|
|
294
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
295
|
-
0 && (module.exports = {
|
|
296
|
-
createThemes
|
|
297
|
-
});
|
|
298
|
-
//# sourceMappingURL=createThemes.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/createThemes.ts"],
|
|
4
|
-
"sourcesContent": ["import { Variable, createTheme, isWeb } from '@tamagui/core'\n\n// can make configurable\ntype AltKeys = 1 | 2\ntype AltName<Name extends string, Keys extends string | number> = `${Name}_alt${Keys}`\n\ntype Colors = {\n [key: string]: {\n [key: string]: string\n }\n}\n\ntype GeneratedTheme<ExtraKeys extends string = string> = {\n [Key in ExtraKeys]: Variable<string>\n} & {\n backgroundStrong: Variable<string>\n background: Variable<string>\n backgroundHover: Variable<string>\n backgroundPress: Variable<string>\n backgroundFocus: Variable<string>\n backgroundTransparent: Variable<string>\n color: Variable<string>\n colorHover: Variable<string>\n colorPress: Variable<string>\n colorFocus: Variable<string>\n shadowColor: Variable<string>\n shadowColorHover: Variable<string>\n shadowColorPress: Variable<string>\n shadowColorFocus: Variable<string>\n borderColor: Variable<string>\n borderColorHover: Variable<string>\n borderColorPress: Variable<string>\n borderColorFocus: Variable<string>\n placeholderColor: Variable<string>\n color1: Variable<string>\n color2: Variable<string>\n color3: Variable<string>\n color4: Variable<string>\n color5: Variable<string>\n color6: Variable<string>\n color7: Variable<string>\n color8: Variable<string>\n color9: Variable<string>\n color10: Variable<string>\n color11: Variable<string>\n color12: Variable<string>\n}\n\ntype SubTheme = {\n [key in keyof GeneratedTheme]?: Variable<string> | string\n}\n\ntype GetSubThemes<Name extends string> =\n | `${Name}`\n | `${Name}_alt${AltKeys}`\n | `${Name}_darker`\n | `${Name}_active`\n | `${Name}_Card`\n | `${Name}_SliderTrack`\n | `${Name}_SliderTrackActive`\n | `${Name}_Switch`\n | `${Name}_SwitchThumb`\n | `${Name}_DrawerFrame`\n | `${Name}_Button`\n | `${Name}_SliderThumb`\n | `${Name}_Progress`\n | `${Name}_ProgressIndicator`\n | `${Name}_TooltipArrow`\n | `${Name}_TooltipContent`\n\nexport type GeneratedThemes<ColorsList extends string, BaseColorList extends string> = {\n [key in\n | GetSubThemes<ColorsList extends string ? ColorsList : never>\n | GetSubThemes<`light`>\n | GetSubThemes<`dark`>]: GeneratedTheme<BaseColorList>\n}\n\nexport const createThemes = <ColorsList extends string, BaseColorList extends string>({\n activeColor,\n light,\n dark,\n colorsLight,\n colorsDark,\n}: {\n activeColor: string\n light: string[]\n dark: string[]\n colorsLight: Colors\n colorsDark: Colors\n}): GeneratedThemes<ColorsList, BaseColorList> => {\n function flatten(obj: Colors) {\n const next = {}\n for (const key in obj) {\n Object.assign(next, obj[key])\n }\n return next\n }\n\n const darkColors = flatten(colorsDark)\n const lightColors = flatten(colorsLight)\n\n // spaghetti ahead\n\n type ThemeCreatorProps = {\n shift?: number\n backgrounds: (string | Variable)[]\n backgroundStrong?: string | Variable\n borderColors?: (string | Variable)[]\n colors?: (string | Variable)[]\n activeTheme?: any\n offsets?: {\n color?: number[] | null\n background?: number[] | null\n borderColor?: number[] | null\n }\n isLight?: boolean\n isBase?: boolean\n }\n\n // helpers\n\n const alternates = [1, 2, 3] as const\n const alts = [1, 2] as const\n type ThemeCreator<A = any> = (str: number, props: ThemeCreatorProps) => A\n\n function createThemesFrom<\n Name extends string,\n GetTheme extends ThemeCreator = ThemeCreator\n >(\n name: Name,\n getTheme: GetTheme,\n props: ThemeCreatorProps\n ): {\n [key in GetSubThemes<Name>]: GetTheme extends ThemeCreator<infer Theme>\n ? Theme\n : never\n } {\n const { shift = 0 } = props\n const theme = getTheme(0 + shift, props)\n let themeEntries: any[] = [[name, theme]]\n\n // generate alternates (for use in other themes), but keep just alts\n const altThemes: any[] = alternates.map((alt) => [\n `${name}_alt${alt}`,\n getTheme(alt + shift + 1, props),\n ])\n\n const altButtonThemes: any[] = alternates.map((_, i) => {\n const [bName, bTheme] = [altThemes[i][0], (altThemes[i] || altThemes[i])[1]]\n return [`${bName}_Button` as any, bTheme]\n })\n // add these after alts since we rely on positioning\n const darkerTheme = getTheme(Math.max(0, shift + (props.isLight ? 1 : -1)), props)\n const activeTheme = props.activeTheme || {\n ...theme,\n borderColor: props.backgrounds[7],\n background: props.backgrounds[6],\n backgroundHover: props.backgrounds[6],\n backgroundPress: props.backgrounds[6],\n }\n\n // TODO can be de-duped\n const inverted = altThemes.map(([_name, theme]) => {\n return {\n ...theme,\n background: theme.color,\n backgroundHover: theme.colorHover,\n backgroundFocus: theme.colorFocus,\n backgroundPress: theme.colorPress,\n color: theme.background,\n colorHover: theme.backgroundHover,\n colorFocus: theme.backgroundFocus,\n colorPress: theme.backgroundPress,\n }\n })\n\n themeEntries = [\n ...themeEntries,\n // keep just alts\n ...altThemes.slice(0, alts.length),\n ...altButtonThemes.slice(0, alts.length),\n [`${name}_Button`, altThemes[1][1]],\n [`${name}_DrawerFrame`, altThemes[2][1]],\n [`${name}_SliderTrack`, altThemes[1][1]],\n [`${name}_SliderTrackActive`, altThemes[2][1]],\n [`${name}_SliderThumb`, inverted[2]],\n [`${name}_Progress`, altThemes[2][1]],\n [`${name}_ProgressIndicator`, inverted[2]],\n [`${name}_Switch`, altThemes[1][1]],\n [`${name}_SwitchThumb`, inverted[2]],\n [`${name}_TooltipArrow`, altThemes[2][1]],\n [`${name}_TooltipContent`, altThemes[2][1]],\n [`${name}_darker`, darkerTheme],\n [`${name}_active`, activeTheme],\n ]\n const themes = Object.fromEntries(themeEntries)\n return themes as any\n }\n\n const blanks = [0, 0, 0, 0]\n\n const themeCreator = (\n str = 1,\n {\n backgrounds,\n isLight = true,\n isBase = false,\n colors = [...backgrounds].reverse(),\n borderColors = isLight ? colors : backgrounds,\n backgroundStrong,\n offsets: offsetsProp,\n }: ThemeCreatorProps\n ) => {\n const offsets = {\n borderColor: offsetsProp?.borderColor ?? offsetsProp?.background ?? blanks,\n background: offsetsProp?.background ?? blanks,\n color: offsetsProp?.color ?? blanks,\n }\n const darkColors = isLight ? colors : backgrounds\n const lighterDir = isLight ? -1 : 1\n const darkerDir = -lighterDir\n const strongerDir = isLight ? darkerDir : lighterDir\n const softerDir = -strongerDir\n const get = (arr: any[], index: number, name = 'background') => {\n return arr[Math.max(0, Math.min(index + (offsets[name][str] || 0), arr.length - 1))]\n }\n\n const theme: SubTheme = {\n background: get(backgrounds, str),\n backgroundStrong: backgroundStrong || get(backgrounds, str + strongerDir * 2),\n backgroundHover: get(backgrounds, str + lighterDir),\n backgroundPress: get(backgrounds, str + darkerDir),\n backgroundFocus: get(backgrounds, str + darkerDir * 2),\n backgroundTransparent: 'hsla(0, 0%, 0%, 0.012)',\n color: get(colors, 0 + str, 'color'),\n colorHover: get(colors, 1 + str, 'color'),\n colorPress: get(colors, 2 + str, 'color'),\n colorFocus: get(colors, 3 + str, 'color'),\n shadowColor: isLight ? 'hsla(0, 0%, 0%, 0.03)' : 'hsla(0, 0%, 0%, 0.2)',\n shadowColorHover: darkColors[!isLight ? 1 : 8],\n shadowColorPress: darkColors[!isLight ? 1 : 8],\n shadowColorFocus: darkColors[!isLight ? 1 : 8],\n borderColor: null as any as string | Variable,\n borderColorHover: null as any as string | Variable,\n borderColorPress: null as any as string | Variable,\n borderColorFocus: null as any as string | Variable,\n color1: backgrounds[0],\n color2: backgrounds[1],\n color3: backgrounds[2],\n color4: backgrounds[3],\n color5: backgrounds[4],\n color6: backgrounds[5],\n color7: backgrounds[6],\n color8: backgrounds[7],\n color9: backgrounds[8],\n color10: backgrounds[9],\n color11: backgrounds[10],\n color12: backgrounds[11],\n placeholderColor: backgrounds[7],\n }\n\n if (isBase) {\n Object.assign(theme, {\n borderColor: isLight\n ? get(colors, 8 - str, 'borderColor')\n : get(backgrounds, 2 + str, 'borderColor'),\n borderColorHover: isLight\n ? get(colors, 6 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n borderColorPress: isLight\n ? get(colors, 5 - str, 'borderColor')\n : get(backgrounds, 1 + str, 'borderColor'),\n borderColorFocus: isLight\n ? get(colors, 4 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n })\n } else {\n Object.assign(theme, {\n borderColor: get(borderColors, 1 + strongerDir, 'borderColor'),\n borderColorHover: get(borderColors, 2 + strongerDir, 'borderColor'),\n borderColorPress: get(borderColors, 3 + strongerDir, 'borderColor'),\n borderColorFocus: get(borderColors, 4 + strongerDir, 'borderColor'),\n })\n }\n\n return theme\n }\n\n const lightThemes = createThemesFrom('light', themeCreator, {\n backgrounds: light,\n // for now web non-ios style native is...\n backgroundStrong: isWeb ? '#fefefe' : '#f2f2f2',\n borderColors: light.slice(2),\n isLight: true,\n offsets: {\n background: [2, 2, 2, 2, 2, 2],\n },\n })\n\n const darkThemes = createThemesFrom('dark', themeCreator, {\n backgrounds: dark,\n colors: light.slice(2),\n backgroundStrong: '#070707',\n isBase: true,\n isLight: false,\n // shift: 1,\n offsets: {\n color: [0, 4, 5, 5, 5, 5],\n },\n })\n\n darkThemes.dark_darker.background = '#030303'\n darkThemes.dark_darker.backgroundStrong = '#000'\n\n type LightColorKeys = keyof typeof lightColors\n\n type BaseTheme = {\n [key in LightColorKeys | keyof SubTheme]: Variable<string>\n }\n\n const lightTheme = createTheme({\n ...lightColors,\n ...lightThemes.light,\n }) as BaseTheme\n\n const darkTheme = createTheme({\n ...darkColors,\n ...darkThemes.dark,\n }) as BaseTheme\n\n const baseThemes = {\n // light\n ...lightThemes,\n light: lightTheme,\n // reserving in types, updating later\n light_active: lightThemes.light,\n light_Card: lightThemes.light,\n light_SliderTrack: lightThemes.light_alt1,\n light_SliderTrackActive: lightThemes.light_alt2,\n light_Switch: lightThemes.light_alt2,\n light_SwitchThumb: lightThemes.light,\n light_DrawerFrame: lightThemes.light_alt1,\n\n // dark\n ...darkThemes,\n dark: darkTheme,\n // reserving in types, updating later\n dark_active: darkThemes.dark,\n dark_Card: darkThemes.dark,\n dark_DrawerFrame: darkThemes.dark_alt1,\n dark_SliderTrack: darkThemes.dark_darker,\n dark_SliderTrackActive: darkThemes.dark_alt2,\n dark_Switch: darkThemes.dark_alt2,\n dark_SwitchThumb: darkThemes.dark_darker,\n dark_Button: darkThemes.dark_alt1,\n }\n\n const darkEntries = Object.entries(darkTheme)\n const lightEntries = Object.entries(lightTheme)\n function findColors(prefix: string, dark = false): BaseTheme {\n return Object.fromEntries(\n (dark ? darkEntries : lightEntries).filter(([k]) => k.startsWith(prefix))\n ) as any\n }\n\n const colorSchemes: any[] = []\n\n for (const name in colorsLight) {\n colorSchemes.push({\n name,\n colors: findColors(name),\n darkColors: findColors(name, true),\n })\n }\n\n type ColorThemeNames =\n | ColorsList\n | AltName<`light_${ColorsList extends string ? ColorsList : never}`, AltKeys>\n | AltName<`dark_${ColorsList extends string ? ColorsList : never}`, AltKeys>\n\n const colorThemeEntries = colorSchemes.flatMap(({ name, colors, darkColors }) => {\n const [altLightThemes, altDarkThemes] = [\n { colors: darkColors, backgrounds: colors },\n { colors, backgrounds: darkColors },\n ].map((props, i) => {\n const isLight = i === 0\n const colorsBase = Object.values(props.colors).slice(2)\n const [backgrounds, colors] = [\n Object.values(props.backgrounds),\n isLight ? colorsBase : [colorsBase[0], '#ccc', ...colorsBase.slice(1)],\n ] as const\n\n const scheme = isLight ? 'light' : 'dark'\n const shift = isLight ? 0 : 1\n\n // if (!isLight) {\n // const [_, h, sp, lp] = backgrounds[0].match(/hsl\\(([0-9\\.]+), ([0-9\\.]+)\\%, ([0-9\\.]+)\\%\\)/)!\n // backgrounds.unshift(`hsl(${h}, ${sp}%, ${parseFloat(lp) / 2}%)`)\n // }\n\n const themeWithAlts = createThemesFrom(name, themeCreator, {\n // @ts-ignore\n colors,\n // @ts-ignore\n backgrounds,\n // @ts-ignore\n borderColors: backgrounds,\n isLight,\n shift,\n isBase: false,\n offsets: {\n background: isLight ? [2, 2, 2, 2, 2, 2] : null,\n borderColor: isLight ? [2, 2, 2, 3, 2] : null,\n color: isLight ? [0, 0, -1, -2, -3, -3, -4] : [-1, -1, -1, -1, -1, -1],\n },\n })\n\n return Object.entries(themeWithAlts).map(([k, v]) => [`${scheme}_${k}`, v])\n })\n return [...altLightThemes, ...altDarkThemes]\n })\n\n type TypedColorTheme = typeof lightThemes.light_alt1\n\n const colorThemes: {\n [key in ColorThemeNames]: TypedColorTheme\n } = Object.fromEntries(colorThemeEntries) as any\n\n // add in base _active themes\n baseThemes.dark_active = {\n ...colorThemes[`dark_${activeColor}_alt2`],\n background: darkColors[`${activeColor}10`],\n backgroundHover: darkColors[`${activeColor}11`],\n backgroundPress: darkColors[`${activeColor}9`],\n backgroundFocus: darkColors[`${activeColor}9`],\n color: darkColors[`${activeColor}12`],\n colorHover: darkColors[`${activeColor}12`],\n colorPress: darkColors[`${activeColor}12`],\n colorFocus: darkColors[`${activeColor}12`],\n }\n\n // light active uses light foreground, ios style\n baseThemes.light_active = baseThemes.dark_active\n\n const allThemes = {\n ...baseThemes,\n ...colorThemes,\n } as any\n\n return allThemes\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6C;AA6EtC,MAAM,eAAe,CAA0D;AAAA,EACpF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAMkD;AAChD,WAAS,QAAQ,KAAa;AAC5B,UAAM,OAAO,CAAC;AACd,eAAW,OAAO,KAAK;AACrB,aAAO,OAAO,MAAM,IAAI,GAAG,CAAC;AAAA,IAC9B;AACA,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,QAAQ,UAAU;AACrC,QAAM,cAAc,QAAQ,WAAW;AAsBvC,QAAM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AAI,IAAI,EAAE;AAAA,QACvE;AAAA,MACF,CAAC;AAED,aAAO,OAAO,QAAQ,aAAa,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,UAAU,KAAK,CAAC,CAAC;AAAA,IAC5E,CAAC;AACD,WAAO,CAAC,GAAG,gBAAgB,GAAG,aAAa;AAAA,EAC7C,CAAC;AAID,QAAM,cAEF,OAAO,YAAY,iBAAiB;AAGxC,aAAW,cAAc;AAAA,IACvB,GAAG,YAAY,QAAQ,kBAAkB;AAAA,IACzC,YAAY,WAAW,GAAG,eAAe;AAAA,IACzC,iBAAiB,WAAW,GAAG,eAAe;AAAA,IAC9C,iBAAiB,WAAW,GAAG,cAAc;AAAA,IAC7C,iBAAiB,WAAW,GAAG,cAAc;AAAA,IAC7C,OAAO,WAAW,GAAG,eAAe;AAAA,IACpC,YAAY,WAAW,GAAG,eAAe;AAAA,IACzC,YAAY,WAAW,GAAG,eAAe;AAAA,IACzC,YAAY,WAAW,GAAG,eAAe;AAAA,EAC3C;AAGA,aAAW,eAAe,WAAW;AAErC,QAAM,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AAEA,SAAO;AACT;",
|
|
6
|
-
"names": ["theme", "darkColors", "dark", "colors"]
|
|
7
|
-
}
|
package/dist/esm/colorUtils.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { getVariableValue } from "@tamagui/core";
|
|
2
|
-
const hexToRGBA = (hex, alpha = 1) => {
|
|
3
|
-
if (!isValidHex(hex)) {
|
|
4
|
-
throw new Error("Invalid HEX");
|
|
5
|
-
}
|
|
6
|
-
const chunkSize = Math.floor((hex.length - 1) / 3);
|
|
7
|
-
const hexArr = getChunksFromString(hex.slice(1), chunkSize);
|
|
8
|
-
const [r, g, b, a] = (hexArr == null ? void 0 : hexArr.map(convertHexUnitTo256)) ?? [];
|
|
9
|
-
return `rgba(${r}, ${g}, ${b}, ${getAlphaFloat(a, alpha)})`;
|
|
10
|
-
};
|
|
11
|
-
const setColorAlpha = (colorIn, alpha = 1) => {
|
|
12
|
-
const color = `${getVariableValue(colorIn)}`;
|
|
13
|
-
if (color.startsWith("hsl(")) {
|
|
14
|
-
return color.replace("hsl", "hsla").replace(")", `, ${alpha})`);
|
|
15
|
-
}
|
|
16
|
-
if (color.startsWith("#")) {
|
|
17
|
-
return hexToRGBA(color, alpha);
|
|
18
|
-
}
|
|
19
|
-
if (color.startsWith("rgb(")) {
|
|
20
|
-
return color.replace("rgb", "rgba").replace(")", `, ${alpha})`);
|
|
21
|
-
}
|
|
22
|
-
return color;
|
|
23
|
-
};
|
|
24
|
-
const isValidHex = (hex) => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
25
|
-
const getChunksFromString = (st, chunkSize = 0) => st.match(new RegExp(`.{${chunkSize}}`, "g"));
|
|
26
|
-
const convertHexUnitTo256 = (hexStr) => parseInt(hexStr.repeat(2 / hexStr.length), 16);
|
|
27
|
-
const getAlphaFloat = (a, alpha = 1) => {
|
|
28
|
-
if (a !== void 0) {
|
|
29
|
-
return a / 255;
|
|
30
|
-
}
|
|
31
|
-
if (typeof alpha !== "number" || alpha < 0 || alpha > 1) {
|
|
32
|
-
return 1;
|
|
33
|
-
}
|
|
34
|
-
return alpha;
|
|
35
|
-
};
|
|
36
|
-
export {
|
|
37
|
-
hexToRGBA,
|
|
38
|
-
setColorAlpha
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=colorUtils.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/colorUtils.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Variable, getVariableValue } from '@tamagui/core'\n\nexport const hexToRGBA = (hex: string, alpha = 1) => {\n if (!isValidHex(hex)) {\n throw new Error('Invalid HEX')\n }\n const chunkSize = Math.floor((hex.length - 1) / 3)\n const hexArr = getChunksFromString(hex.slice(1), chunkSize)\n const [r, g, b, a] = hexArr?.map(convertHexUnitTo256) ?? []\n return `rgba(${r}, ${g}, ${b}, ${getAlphaFloat(a, alpha)})`\n}\n\nexport const setColorAlpha = (colorIn: string | Variable, alpha = 1) => {\n const color = `${getVariableValue(colorIn)}`\n if (color.startsWith('hsl(')) {\n return color.replace('hsl', 'hsla').replace(')', `, ${alpha})`)\n }\n if (color.startsWith('#')) {\n return hexToRGBA(color, alpha)\n }\n if (color.startsWith('rgb(')) {\n return color.replace('rgb', 'rgba').replace(')', `, ${alpha})`)\n }\n return color\n}\n\nconst isValidHex = (hex: string) => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex)\n\nconst getChunksFromString = (st: string, chunkSize = 0) =>\n st.match(new RegExp(`.{${chunkSize}}`, 'g'))\n\nconst convertHexUnitTo256 = (hexStr: string) =>\n parseInt(hexStr.repeat(2 / hexStr.length), 16)\n\nconst getAlphaFloat = (a: any, alpha = 1) => {\n if (a !== undefined) {\n return a / 255\n }\n if (typeof alpha !== 'number' || alpha < 0 || alpha > 1) {\n return 1\n }\n return alpha\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAmB,wBAAwB;AAEpC,MAAM,YAAY,CAAC,KAAa,QAAQ,MAAM;AACnD,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,UAAM,IAAI,MAAM,aAAa;AAAA,EAC/B;AACA,QAAM,YAAY,KAAK,OAAO,IAAI,SAAS,KAAK,CAAC;AACjD,QAAM,SAAS,oBAAoB,IAAI,MAAM,CAAC,GAAG,SAAS;AAC1D,QAAM,CAAC,GAAG,GAAG,GAAG,CAAC,KAAI,iCAAQ,IAAI,yBAAwB,CAAC;AAC1D,SAAO,QAAQ,MAAM,MAAM,MAAM,cAAc,GAAG,KAAK;AACzD;AAEO,MAAM,gBAAgB,CAAC,SAA4B,QAAQ,MAAM;AACtE,QAAM,QAAQ,GAAG,iBAAiB,OAAO;AACzC,MAAI,MAAM,WAAW,MAAM,GAAG;AAC5B,WAAO,MAAM,QAAQ,OAAO,MAAM,EAAE,QAAQ,KAAK,KAAK,QAAQ;AAAA,EAChE;AACA,MAAI,MAAM,WAAW,GAAG,GAAG;AACzB,WAAO,UAAU,OAAO,KAAK;AAAA,EAC/B;AACA,MAAI,MAAM,WAAW,MAAM,GAAG;AAC5B,WAAO,MAAM,QAAQ,OAAO,MAAM,EAAE,QAAQ,KAAK,KAAK,QAAQ;AAAA,EAChE;AACA,SAAO;AACT;AAEA,MAAM,aAAa,CAAC,QAAgB,6BAA6B,KAAK,GAAG;AAEzE,MAAM,sBAAsB,CAAC,IAAY,YAAY,MACnD,GAAG,MAAM,IAAI,OAAO,KAAK,cAAc,GAAG,CAAC;AAE7C,MAAM,sBAAsB,CAAC,WAC3B,SAAS,OAAO,OAAO,IAAI,OAAO,MAAM,GAAG,EAAE;AAE/C,MAAM,gBAAgB,CAAC,GAAQ,QAAQ,MAAM;AAC3C,MAAI,MAAM,QAAW;AACnB,WAAO,IAAI;AAAA,EACb;AACA,MAAI,OAAO,UAAU,YAAY,QAAQ,KAAK,QAAQ,GAAG;AACvD,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/createTheme.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
const THEME_INFO = /* @__PURE__ */ new WeakMap();
|
|
2
|
-
function createTheme(palette, definition, options) {
|
|
3
|
-
const theme = {
|
|
4
|
-
...Object.fromEntries(
|
|
5
|
-
Object.entries(definition).map(([key, offset]) => {
|
|
6
|
-
return [key, getValue(palette, offset)];
|
|
7
|
-
})
|
|
8
|
-
),
|
|
9
|
-
...options == null ? void 0 : options.nonInheritedValues
|
|
10
|
-
};
|
|
11
|
-
THEME_INFO.set(theme, { palette, definition, cache: /* @__PURE__ */ new WeakMap() });
|
|
12
|
-
return theme;
|
|
13
|
-
}
|
|
14
|
-
const getValue = (palette, value) => {
|
|
15
|
-
if (typeof value === "string")
|
|
16
|
-
return value;
|
|
17
|
-
const max = palette.length - 1;
|
|
18
|
-
const isPositive = value === 0 ? !isMinusZero(value) : value >= 0;
|
|
19
|
-
const next = isPositive ? value : max + value;
|
|
20
|
-
const index = Math.min(Math.max(0, next), max);
|
|
21
|
-
return palette[index];
|
|
22
|
-
};
|
|
23
|
-
function addChildren(themes, getChildren) {
|
|
24
|
-
const out = { ...themes };
|
|
25
|
-
for (const key in themes) {
|
|
26
|
-
const subThemes = getChildren(key, themes[key]);
|
|
27
|
-
for (const sKey in subThemes) {
|
|
28
|
-
out[`${key}_${sKey}`] = subThemes[sKey];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return out;
|
|
32
|
-
}
|
|
33
|
-
const createWeakenMask = ({
|
|
34
|
-
by = 1,
|
|
35
|
-
max,
|
|
36
|
-
min = 0,
|
|
37
|
-
inverseNegatives
|
|
38
|
-
}) => {
|
|
39
|
-
return (template, { skip }) => {
|
|
40
|
-
const values = Object.entries(template);
|
|
41
|
-
const out = {};
|
|
42
|
-
for (const [key, value] of values) {
|
|
43
|
-
if (typeof value === "string")
|
|
44
|
-
continue;
|
|
45
|
-
if (skip && key in skip) {
|
|
46
|
-
out[key] = value;
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
const isPositive = value === 0 ? !isMinusZero(value) : value >= 0;
|
|
50
|
-
const direction = isPositive ? 1 : -1;
|
|
51
|
-
const invert = inverseNegatives && !isPositive ? -1 : 1;
|
|
52
|
-
const next = value + by * direction * invert;
|
|
53
|
-
const clamped = isPositive ? Math.max(min, Math.min(max, next)) : Math.min(-min, Math.max(-max, next));
|
|
54
|
-
out[key] = clamped;
|
|
55
|
-
}
|
|
56
|
-
return out;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
function isMinusZero(value) {
|
|
60
|
-
return 1 / value === -Infinity;
|
|
61
|
-
}
|
|
62
|
-
const createStrengthenMask = (props) => createWeakenMask({ ...props, inverseNegatives: true });
|
|
63
|
-
function applyMask(theme, mask, options = {}) {
|
|
64
|
-
const info = THEME_INFO.get(theme);
|
|
65
|
-
if (!info) {
|
|
66
|
-
throw new Error(
|
|
67
|
-
process.env.NODE_ENV !== "production" ? `No info found for theme, you must pass the theme created by createThemeFromPalette directly to extendTheme` : `\u274C Err2`
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
if (info.cache.has(mask)) {
|
|
71
|
-
return info.cache.get(mask);
|
|
72
|
-
}
|
|
73
|
-
const template = mask(info.definition, options);
|
|
74
|
-
const next = createTheme(info.palette, template);
|
|
75
|
-
info.cache.set(mask, next);
|
|
76
|
-
return next;
|
|
77
|
-
}
|
|
78
|
-
export {
|
|
79
|
-
addChildren,
|
|
80
|
-
applyMask,
|
|
81
|
-
createStrengthenMask,
|
|
82
|
-
createTheme,
|
|
83
|
-
createWeakenMask
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=createTheme.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/createTheme.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Variable } from '@tamagui/web'\n\nexport type ThemeMask = Record<string, string | number>\nexport type Palette = string[]\nexport type ShiftMaskProps = { by: number; max: number; min?: number }\nexport type MaskOptions = { skip?: Partial<ThemeMask> }\n\ntype GenericTheme = { [key: string]: string | Variable }\ntype CreateMask = <A extends ThemeMask>(template: A, options: MaskOptions) => A\n\nconst THEME_INFO = new WeakMap<\n any,\n { palette: Palette; definition: ThemeMask; cache: WeakMap<any, any> }\n>()\n\nexport function createTheme<\n Definition extends ThemeMask,\n Extras extends Record<string, string> = {}\n>(\n palette: Palette,\n definition: Definition,\n options?: {\n nonInheritedValues?: Extras\n }\n): {\n [key in keyof Definition | keyof Extras]: string\n} {\n const theme = {\n ...(Object.fromEntries(\n Object.entries(definition).map(([key, offset]) => {\n return [key, getValue(palette, offset)]\n })\n ) as any),\n ...options?.nonInheritedValues,\n }\n THEME_INFO.set(theme, { palette, definition, cache: new WeakMap() })\n return theme\n}\n\nconst getValue = (palette: Palette, value: string | number) => {\n if (typeof value === 'string') return value\n const max = palette.length - 1\n const isPositive = value === 0 ? !isMinusZero(value) : value >= 0\n const next = isPositive ? value : max + value\n const index = Math.min(Math.max(0, next), max)\n return palette[index]\n}\n\ntype SubThemeKeys<ParentKeys, ChildKeys> = `${ParentKeys extends string\n ? ParentKeys\n : never}_${ChildKeys extends string ? ChildKeys : never}`\n\nexport function addChildren<\n Theme extends GenericTheme,\n Themes extends { [key: string]: Theme },\n GetChildren extends (name: keyof Themes, theme: Theme) => { [key: string]: Theme }\n>(\n themes: Themes,\n getChildren: GetChildren\n): Themes & {\n [key in SubThemeKeys<keyof Themes, keyof ReturnType<GetChildren>>]: Theme\n} {\n const out = { ...themes }\n for (const key in themes) {\n const subThemes = getChildren(key, themes[key])\n for (const sKey in subThemes) {\n out[`${key}_${sKey}`] = subThemes[sKey] as any\n }\n }\n return out as any\n}\n\nexport const createWeakenMask = ({\n by = 1,\n max,\n min = 0,\n inverseNegatives,\n}: ShiftMaskProps & { inverseNegatives?: boolean }) => {\n return ((template, { skip }) => {\n const values = Object.entries(template) // .filter(Number)\n const out = {}\n for (const [key, value] of values) {\n if (typeof value === 'string') continue\n if (skip && key in skip) {\n out[key] = value\n continue\n }\n const isPositive = value === 0 ? !isMinusZero(value) : value >= 0\n const direction = isPositive ? 1 : -1\n const invert = inverseNegatives && !isPositive ? -1 : 1\n const next = value + by * direction * invert\n const clamped = isPositive\n ? Math.max(min, Math.min(max, next))\n : Math.min(-min, Math.max(-max, next))\n\n out[key] = clamped\n }\n return out as typeof template\n }) as CreateMask\n}\n\nfunction isMinusZero(value) {\n return 1 / value === -Infinity\n}\n\nexport const createStrengthenMask = (props: ShiftMaskProps) =>\n createWeakenMask({ ...props, inverseNegatives: true })\n\nexport function applyMask<Theme extends GenericTheme>(\n theme: Theme,\n mask: CreateMask,\n options: MaskOptions = {}\n): Theme {\n const info = THEME_INFO.get(theme)\n if (!info) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No info found for theme, you must pass the theme created by createThemeFromPalette directly to extendTheme`\n : `\u274C Err2`\n )\n }\n if (info.cache.has(mask)) {\n return info.cache.get(mask)\n }\n\n const template = mask(info.definition, options)\n const next = createTheme(info.palette, template) as Theme\n\n info.cache.set(mask, next)\n\n return next\n}\n"],
|
|
5
|
-
"mappings": "AAUA,MAAM,aAAa,oBAAI,QAGrB;AAEK,SAAS,YAId,SACA,YACA,SAKA;AACA,QAAM,QAAQ;AAAA,IACZ,GAAI,OAAO;AAAA,MACT,OAAO,QAAQ,UAAU,EAAE,IAAI,CAAC,CAAC,KAAK,MAAM,MAAM;AAChD,eAAO,CAAC,KAAK,SAAS,SAAS,MAAM,CAAC;AAAA,MACxC,CAAC;AAAA,IACH;AAAA,IACA,GAAG,mCAAS;AAAA,EACd;AACA,aAAW,IAAI,OAAO,EAAE,SAAS,YAAY,OAAO,oBAAI,QAAQ,EAAE,CAAC;AACnE,SAAO;AACT;AAEA,MAAM,WAAW,CAAC,SAAkB,UAA2B;AAC7D,MAAI,OAAO,UAAU;AAAU,WAAO;AACtC,QAAM,MAAM,QAAQ,SAAS;AAC7B,QAAM,aAAa,UAAU,IAAI,CAAC,YAAY,KAAK,IAAI,SAAS;AAChE,QAAM,OAAO,aAAa,QAAQ,MAAM;AACxC,QAAM,QAAQ,KAAK,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,GAAG;AAC7C,SAAO,QAAQ,KAAK;AACtB;AAMO,SAAS,YAKd,QACA,aAGA;AACA,QAAM,MAAM,EAAE,GAAG,OAAO;AACxB,aAAW,OAAO,QAAQ;AACxB,UAAM,YAAY,YAAY,KAAK,OAAO,GAAG,CAAC;AAC9C,eAAW,QAAQ,WAAW;AAC5B,UAAI,GAAG,OAAO,MAAM,IAAI,UAAU,IAAI;AAAA,IACxC;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,mBAAmB,CAAC;AAAA,EAC/B,KAAK;AAAA,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
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/createTheme.mjs
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
const THEME_INFO = /* @__PURE__ */ new WeakMap();
|
|
2
|
-
function createTheme(palette, definition, options) {
|
|
3
|
-
const theme = {
|
|
4
|
-
...Object.fromEntries(
|
|
5
|
-
Object.entries(definition).map(([key, offset]) => {
|
|
6
|
-
return [key, getValue(palette, offset)];
|
|
7
|
-
})
|
|
8
|
-
),
|
|
9
|
-
...options == null ? void 0 : options.nonInheritedValues
|
|
10
|
-
};
|
|
11
|
-
THEME_INFO.set(theme, { palette, definition, cache: /* @__PURE__ */ new WeakMap() });
|
|
12
|
-
return theme;
|
|
13
|
-
}
|
|
14
|
-
const getValue = (palette, value) => {
|
|
15
|
-
if (typeof value === "string")
|
|
16
|
-
return value;
|
|
17
|
-
const max = palette.length - 1;
|
|
18
|
-
const isPositive = value === 0 ? !isMinusZero(value) : value >= 0;
|
|
19
|
-
const next = isPositive ? value : max + value;
|
|
20
|
-
const index = Math.min(Math.max(0, next), max);
|
|
21
|
-
return palette[index];
|
|
22
|
-
};
|
|
23
|
-
function addChildren(themes, getChildren) {
|
|
24
|
-
const out = { ...themes };
|
|
25
|
-
for (const key in themes) {
|
|
26
|
-
const subThemes = getChildren(key, themes[key]);
|
|
27
|
-
for (const sKey in subThemes) {
|
|
28
|
-
out[`${key}_${sKey}`] = subThemes[sKey];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return out;
|
|
32
|
-
}
|
|
33
|
-
const createWeakenMask = ({
|
|
34
|
-
by = 1,
|
|
35
|
-
max,
|
|
36
|
-
min = 0,
|
|
37
|
-
inverseNegatives
|
|
38
|
-
}) => {
|
|
39
|
-
return (template, { skip }) => {
|
|
40
|
-
const values = Object.entries(template);
|
|
41
|
-
const out = {};
|
|
42
|
-
for (const [key, value] of values) {
|
|
43
|
-
if (typeof value === "string")
|
|
44
|
-
continue;
|
|
45
|
-
if (skip && key in skip) {
|
|
46
|
-
out[key] = value;
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
const isPositive = value === 0 ? !isMinusZero(value) : value >= 0;
|
|
50
|
-
const direction = isPositive ? 1 : -1;
|
|
51
|
-
const invert = inverseNegatives && !isPositive ? -1 : 1;
|
|
52
|
-
const next = value + by * direction * invert;
|
|
53
|
-
const clamped = isPositive ? Math.max(min, Math.min(max, next)) : Math.min(-min, Math.max(-max, next));
|
|
54
|
-
out[key] = clamped;
|
|
55
|
-
}
|
|
56
|
-
return out;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
function isMinusZero(value) {
|
|
60
|
-
return 1 / value === -Infinity;
|
|
61
|
-
}
|
|
62
|
-
const createStrengthenMask = (props) => createWeakenMask({ ...props, inverseNegatives: true });
|
|
63
|
-
function applyMask(theme, mask, options = {}) {
|
|
64
|
-
const info = THEME_INFO.get(theme);
|
|
65
|
-
if (!info) {
|
|
66
|
-
throw new Error(
|
|
67
|
-
process.env.NODE_ENV !== "production" ? `No info found for theme, you must pass the theme created by createThemeFromPalette directly to extendTheme` : `\u274C Err2`
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
if (info.cache.has(mask)) {
|
|
71
|
-
return info.cache.get(mask);
|
|
72
|
-
}
|
|
73
|
-
const template = mask(info.definition, options);
|
|
74
|
-
const next = createTheme(info.palette, template);
|
|
75
|
-
info.cache.set(mask, next);
|
|
76
|
-
return next;
|
|
77
|
-
}
|
|
78
|
-
export {
|
|
79
|
-
addChildren,
|
|
80
|
-
applyMask,
|
|
81
|
-
createStrengthenMask,
|
|
82
|
-
createTheme,
|
|
83
|
-
createWeakenMask
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=createTheme.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/createTheme.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Variable } from '@tamagui/web'\n\nexport type ThemeMask = Record<string, string | number>\nexport type Palette = string[]\nexport type ShiftMaskProps = { by: number; max: number; min?: number }\nexport type MaskOptions = { skip?: Partial<ThemeMask> }\n\ntype GenericTheme = { [key: string]: string | Variable }\ntype CreateMask = <A extends ThemeMask>(template: A, options: MaskOptions) => A\n\nconst THEME_INFO = new WeakMap<\n any,\n { palette: Palette; definition: ThemeMask; cache: WeakMap<any, any> }\n>()\n\nexport function createTheme<\n Definition extends ThemeMask,\n Extras extends Record<string, string> = {}\n>(\n palette: Palette,\n definition: Definition,\n options?: {\n nonInheritedValues?: Extras\n }\n): {\n [key in keyof Definition | keyof Extras]: string\n} {\n const theme = {\n ...(Object.fromEntries(\n Object.entries(definition).map(([key, offset]) => {\n return [key, getValue(palette, offset)]\n })\n ) as any),\n ...options?.nonInheritedValues,\n }\n THEME_INFO.set(theme, { palette, definition, cache: new WeakMap() })\n return theme\n}\n\nconst getValue = (palette: Palette, value: string | number) => {\n if (typeof value === 'string') return value\n const max = palette.length - 1\n const isPositive = value === 0 ? !isMinusZero(value) : value >= 0\n const next = isPositive ? value : max + value\n const index = Math.min(Math.max(0, next), max)\n return palette[index]\n}\n\ntype SubThemeKeys<ParentKeys, ChildKeys> = `${ParentKeys extends string\n ? ParentKeys\n : never}_${ChildKeys extends string ? ChildKeys : never}`\n\nexport function addChildren<\n Theme extends GenericTheme,\n Themes extends { [key: string]: Theme },\n GetChildren extends (name: keyof Themes, theme: Theme) => { [key: string]: Theme }\n>(\n themes: Themes,\n getChildren: GetChildren\n): Themes & {\n [key in SubThemeKeys<keyof Themes, keyof ReturnType<GetChildren>>]: Theme\n} {\n const out = { ...themes }\n for (const key in themes) {\n const subThemes = getChildren(key, themes[key])\n for (const sKey in subThemes) {\n out[`${key}_${sKey}`] = subThemes[sKey] as any\n }\n }\n return out as any\n}\n\nexport const createWeakenMask = ({\n by = 1,\n max,\n min = 0,\n inverseNegatives,\n}: ShiftMaskProps & { inverseNegatives?: boolean }) => {\n return ((template, { skip }) => {\n const values = Object.entries(template) // .filter(Number)\n const out = {}\n for (const [key, value] of values) {\n if (typeof value === 'string') continue\n if (skip && key in skip) {\n out[key] = value\n continue\n }\n const isPositive = value === 0 ? !isMinusZero(value) : value >= 0\n const direction = isPositive ? 1 : -1\n const invert = inverseNegatives && !isPositive ? -1 : 1\n const next = value + by * direction * invert\n const clamped = isPositive\n ? Math.max(min, Math.min(max, next))\n : Math.min(-min, Math.max(-max, next))\n\n out[key] = clamped\n }\n return out as typeof template\n }) as CreateMask\n}\n\nfunction isMinusZero(value) {\n return 1 / value === -Infinity\n}\n\nexport const createStrengthenMask = (props: ShiftMaskProps) =>\n createWeakenMask({ ...props, inverseNegatives: true })\n\nexport function applyMask<Theme extends GenericTheme>(\n theme: Theme,\n mask: CreateMask,\n options: MaskOptions = {}\n): Theme {\n const info = THEME_INFO.get(theme)\n if (!info) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No info found for theme, you must pass the theme created by createThemeFromPalette directly to extendTheme`\n : `\u274C Err2`\n )\n }\n if (info.cache.has(mask)) {\n return info.cache.get(mask)\n }\n\n const template = mask(info.definition, options)\n const next = createTheme(info.palette, template) as Theme\n\n info.cache.set(mask, next)\n\n return next\n}\n"],
|
|
5
|
-
"mappings": "AAUA,MAAM,aAAa,oBAAI,QAGrB;AAEK,SAAS,YAId,SACA,YACA,SAKA;AACA,QAAM,QAAQ;AAAA,IACZ,GAAI,OAAO;AAAA,MACT,OAAO,QAAQ,UAAU,EAAE,IAAI,CAAC,CAAC,KAAK,MAAM,MAAM;AAChD,eAAO,CAAC,KAAK,SAAS,SAAS,MAAM,CAAC;AAAA,MACxC,CAAC;AAAA,IACH;AAAA,IACA,GAAG,mCAAS;AAAA,EACd;AACA,aAAW,IAAI,OAAO,EAAE,SAAS,YAAY,OAAO,oBAAI,QAAQ,EAAE,CAAC;AACnE,SAAO;AACT;AAEA,MAAM,WAAW,CAAC,SAAkB,UAA2B;AAC7D,MAAI,OAAO,UAAU;AAAU,WAAO;AACtC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,IAAI,UAAU;AACvB;AAEO,MAAM,uBAAuB,CAAC,UACnC,iBAAiB,EAAE,GAAG,OAAO,kBAAkB,KAAK,CAAC;AAEhD,SAAS,UACd,OACA,MACA,UAAuB,CAAC,GACjB;AACP,QAAM,OAAO,WAAW,IAAI,KAAK;AACjC,MAAI,CAAC,MAAM;AACT,UAAM,IAAI;AAAA,MACR,QAAQ,IAAI,aAAa,eACrB,+GACA;AAAA,IACN;AAAA,EACF;AACA,MAAI,KAAK,MAAM,IAAI,IAAI,GAAG;AACxB,WAAO,KAAK,MAAM,IAAI,IAAI;AAAA,EAC5B;AAEA,QAAM,WAAW,KAAK,KAAK,YAAY,OAAO;AAC9C,QAAM,OAAO,YAAY,KAAK,SAAS,QAAQ;AAE/C,OAAK,MAAM,IAAI,MAAM,IAAI;AAEzB,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/esm/createThemes.js
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import { createTheme, isWeb } from "@tamagui/core";
|
|
2
|
-
const createThemes = ({
|
|
3
|
-
activeColor,
|
|
4
|
-
light,
|
|
5
|
-
dark,
|
|
6
|
-
colorsLight,
|
|
7
|
-
colorsDark
|
|
8
|
-
}) => {
|
|
9
|
-
function flatten(obj) {
|
|
10
|
-
const next = {};
|
|
11
|
-
for (const key in obj) {
|
|
12
|
-
Object.assign(next, obj[key]);
|
|
13
|
-
}
|
|
14
|
-
return next;
|
|
15
|
-
}
|
|
16
|
-
const darkColors = flatten(colorsDark);
|
|
17
|
-
const lightColors = flatten(colorsLight);
|
|
18
|
-
const alternates = [1, 2, 3];
|
|
19
|
-
const alts = [1, 2];
|
|
20
|
-
function createThemesFrom(name, getTheme, props) {
|
|
21
|
-
const { shift = 0 } = props;
|
|
22
|
-
const theme = getTheme(0 + shift, props);
|
|
23
|
-
let themeEntries = [[name, theme]];
|
|
24
|
-
const altThemes = alternates.map((alt) => [
|
|
25
|
-
`${name}_alt${alt}`,
|
|
26
|
-
getTheme(alt + shift + 1, props)
|
|
27
|
-
]);
|
|
28
|
-
const altButtonThemes = alternates.map((_, i) => {
|
|
29
|
-
const [bName, bTheme] = [altThemes[i][0], (altThemes[i] || altThemes[i])[1]];
|
|
30
|
-
return [`${bName}_Button`, bTheme];
|
|
31
|
-
});
|
|
32
|
-
const darkerTheme = getTheme(Math.max(0, shift + (props.isLight ? 1 : -1)), props);
|
|
33
|
-
const activeTheme = props.activeTheme || {
|
|
34
|
-
...theme,
|
|
35
|
-
borderColor: props.backgrounds[7],
|
|
36
|
-
background: props.backgrounds[6],
|
|
37
|
-
backgroundHover: props.backgrounds[6],
|
|
38
|
-
backgroundPress: props.backgrounds[6]
|
|
39
|
-
};
|
|
40
|
-
const inverted = altThemes.map(([_name, theme2]) => {
|
|
41
|
-
return {
|
|
42
|
-
...theme2,
|
|
43
|
-
background: theme2.color,
|
|
44
|
-
backgroundHover: theme2.colorHover,
|
|
45
|
-
backgroundFocus: theme2.colorFocus,
|
|
46
|
-
backgroundPress: theme2.colorPress,
|
|
47
|
-
color: theme2.background,
|
|
48
|
-
colorHover: theme2.backgroundHover,
|
|
49
|
-
colorFocus: theme2.backgroundFocus,
|
|
50
|
-
colorPress: theme2.backgroundPress
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
themeEntries = [
|
|
54
|
-
...themeEntries,
|
|
55
|
-
// keep just alts
|
|
56
|
-
...altThemes.slice(0, alts.length),
|
|
57
|
-
...altButtonThemes.slice(0, alts.length),
|
|
58
|
-
[`${name}_Button`, altThemes[1][1]],
|
|
59
|
-
[`${name}_DrawerFrame`, altThemes[2][1]],
|
|
60
|
-
[`${name}_SliderTrack`, altThemes[1][1]],
|
|
61
|
-
[`${name}_SliderTrackActive`, altThemes[2][1]],
|
|
62
|
-
[`${name}_SliderThumb`, inverted[2]],
|
|
63
|
-
[`${name}_Progress`, altThemes[2][1]],
|
|
64
|
-
[`${name}_ProgressIndicator`, inverted[2]],
|
|
65
|
-
[`${name}_Switch`, altThemes[1][1]],
|
|
66
|
-
[`${name}_SwitchThumb`, inverted[2]],
|
|
67
|
-
[`${name}_TooltipArrow`, altThemes[2][1]],
|
|
68
|
-
[`${name}_TooltipContent`, altThemes[2][1]],
|
|
69
|
-
[`${name}_darker`, darkerTheme],
|
|
70
|
-
[`${name}_active`, activeTheme]
|
|
71
|
-
];
|
|
72
|
-
const themes = Object.fromEntries(themeEntries);
|
|
73
|
-
return themes;
|
|
74
|
-
}
|
|
75
|
-
const blanks = [0, 0, 0, 0];
|
|
76
|
-
const themeCreator = (str = 1, {
|
|
77
|
-
backgrounds,
|
|
78
|
-
isLight = true,
|
|
79
|
-
isBase = false,
|
|
80
|
-
colors = [...backgrounds].reverse(),
|
|
81
|
-
borderColors = isLight ? colors : backgrounds,
|
|
82
|
-
backgroundStrong,
|
|
83
|
-
offsets: offsetsProp
|
|
84
|
-
}) => {
|
|
85
|
-
const offsets = {
|
|
86
|
-
borderColor: (offsetsProp == null ? void 0 : offsetsProp.borderColor) ?? (offsetsProp == null ? void 0 : offsetsProp.background) ?? blanks,
|
|
87
|
-
background: (offsetsProp == null ? void 0 : offsetsProp.background) ?? blanks,
|
|
88
|
-
color: (offsetsProp == null ? void 0 : offsetsProp.color) ?? blanks
|
|
89
|
-
};
|
|
90
|
-
const darkColors2 = isLight ? colors : backgrounds;
|
|
91
|
-
const lighterDir = isLight ? -1 : 1;
|
|
92
|
-
const darkerDir = -lighterDir;
|
|
93
|
-
const strongerDir = isLight ? darkerDir : lighterDir;
|
|
94
|
-
const softerDir = -strongerDir;
|
|
95
|
-
const get = (arr, index, name = "background") => {
|
|
96
|
-
return arr[Math.max(0, Math.min(index + (offsets[name][str] || 0), arr.length - 1))];
|
|
97
|
-
};
|
|
98
|
-
const theme = {
|
|
99
|
-
background: get(backgrounds, str),
|
|
100
|
-
backgroundStrong: backgroundStrong || get(backgrounds, str + strongerDir * 2),
|
|
101
|
-
backgroundHover: get(backgrounds, str + lighterDir),
|
|
102
|
-
backgroundPress: get(backgrounds, str + darkerDir),
|
|
103
|
-
backgroundFocus: get(backgrounds, str + darkerDir * 2),
|
|
104
|
-
backgroundTransparent: "hsla(0, 0%, 0%, 0.012)",
|
|
105
|
-
color: get(colors, 0 + str, "color"),
|
|
106
|
-
colorHover: get(colors, 1 + str, "color"),
|
|
107
|
-
colorPress: get(colors, 2 + str, "color"),
|
|
108
|
-
colorFocus: get(colors, 3 + str, "color"),
|
|
109
|
-
shadowColor: isLight ? "hsla(0, 0%, 0%, 0.03)" : "hsla(0, 0%, 0%, 0.2)",
|
|
110
|
-
shadowColorHover: darkColors2[!isLight ? 1 : 8],
|
|
111
|
-
shadowColorPress: darkColors2[!isLight ? 1 : 8],
|
|
112
|
-
shadowColorFocus: darkColors2[!isLight ? 1 : 8],
|
|
113
|
-
borderColor: null,
|
|
114
|
-
borderColorHover: null,
|
|
115
|
-
borderColorPress: null,
|
|
116
|
-
borderColorFocus: null,
|
|
117
|
-
color1: backgrounds[0],
|
|
118
|
-
color2: backgrounds[1],
|
|
119
|
-
color3: backgrounds[2],
|
|
120
|
-
color4: backgrounds[3],
|
|
121
|
-
color5: backgrounds[4],
|
|
122
|
-
color6: backgrounds[5],
|
|
123
|
-
color7: backgrounds[6],
|
|
124
|
-
color8: backgrounds[7],
|
|
125
|
-
color9: backgrounds[8],
|
|
126
|
-
color10: backgrounds[9],
|
|
127
|
-
color11: backgrounds[10],
|
|
128
|
-
color12: backgrounds[11],
|
|
129
|
-
placeholderColor: backgrounds[7]
|
|
130
|
-
};
|
|
131
|
-
if (isBase) {
|
|
132
|
-
Object.assign(theme, {
|
|
133
|
-
borderColor: isLight ? get(colors, 8 - str, "borderColor") : get(backgrounds, 2 + str, "borderColor"),
|
|
134
|
-
borderColorHover: isLight ? get(colors, 6 - str, "borderColor") : get(backgrounds, 3 + str, "borderColor"),
|
|
135
|
-
borderColorPress: isLight ? get(colors, 5 - str, "borderColor") : get(backgrounds, 1 + str, "borderColor"),
|
|
136
|
-
borderColorFocus: isLight ? get(colors, 4 - str, "borderColor") : get(backgrounds, 3 + str, "borderColor")
|
|
137
|
-
});
|
|
138
|
-
} else {
|
|
139
|
-
Object.assign(theme, {
|
|
140
|
-
borderColor: get(borderColors, 1 + strongerDir, "borderColor"),
|
|
141
|
-
borderColorHover: get(borderColors, 2 + strongerDir, "borderColor"),
|
|
142
|
-
borderColorPress: get(borderColors, 3 + strongerDir, "borderColor"),
|
|
143
|
-
borderColorFocus: get(borderColors, 4 + strongerDir, "borderColor")
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return theme;
|
|
147
|
-
};
|
|
148
|
-
const lightThemes = createThemesFrom("light", themeCreator, {
|
|
149
|
-
backgrounds: light,
|
|
150
|
-
// for now web non-ios style native is...
|
|
151
|
-
backgroundStrong: isWeb ? "#fefefe" : "#f2f2f2",
|
|
152
|
-
borderColors: light.slice(2),
|
|
153
|
-
isLight: true,
|
|
154
|
-
offsets: {
|
|
155
|
-
background: [2, 2, 2, 2, 2, 2]
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
const darkThemes = createThemesFrom("dark", themeCreator, {
|
|
159
|
-
backgrounds: dark,
|
|
160
|
-
colors: light.slice(2),
|
|
161
|
-
backgroundStrong: "#070707",
|
|
162
|
-
isBase: true,
|
|
163
|
-
isLight: false,
|
|
164
|
-
// shift: 1,
|
|
165
|
-
offsets: {
|
|
166
|
-
color: [0, 4, 5, 5, 5, 5]
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
darkThemes.dark_darker.background = "#030303";
|
|
170
|
-
darkThemes.dark_darker.backgroundStrong = "#000";
|
|
171
|
-
const lightTheme = createTheme({
|
|
172
|
-
...lightColors,
|
|
173
|
-
...lightThemes.light
|
|
174
|
-
});
|
|
175
|
-
const darkTheme = createTheme({
|
|
176
|
-
...darkColors,
|
|
177
|
-
...darkThemes.dark
|
|
178
|
-
});
|
|
179
|
-
const baseThemes = {
|
|
180
|
-
// light
|
|
181
|
-
...lightThemes,
|
|
182
|
-
light: lightTheme,
|
|
183
|
-
// reserving in types, updating later
|
|
184
|
-
light_active: lightThemes.light,
|
|
185
|
-
light_Card: lightThemes.light,
|
|
186
|
-
light_SliderTrack: lightThemes.light_alt1,
|
|
187
|
-
light_SliderTrackActive: lightThemes.light_alt2,
|
|
188
|
-
light_Switch: lightThemes.light_alt2,
|
|
189
|
-
light_SwitchThumb: lightThemes.light,
|
|
190
|
-
light_DrawerFrame: lightThemes.light_alt1,
|
|
191
|
-
// dark
|
|
192
|
-
...darkThemes,
|
|
193
|
-
dark: darkTheme,
|
|
194
|
-
// reserving in types, updating later
|
|
195
|
-
dark_active: darkThemes.dark,
|
|
196
|
-
dark_Card: darkThemes.dark,
|
|
197
|
-
dark_DrawerFrame: darkThemes.dark_alt1,
|
|
198
|
-
dark_SliderTrack: darkThemes.dark_darker,
|
|
199
|
-
dark_SliderTrackActive: darkThemes.dark_alt2,
|
|
200
|
-
dark_Switch: darkThemes.dark_alt2,
|
|
201
|
-
dark_SwitchThumb: darkThemes.dark_darker,
|
|
202
|
-
dark_Button: darkThemes.dark_alt1
|
|
203
|
-
};
|
|
204
|
-
const darkEntries = Object.entries(darkTheme);
|
|
205
|
-
const lightEntries = Object.entries(lightTheme);
|
|
206
|
-
function findColors(prefix, dark2 = false) {
|
|
207
|
-
return Object.fromEntries(
|
|
208
|
-
(dark2 ? darkEntries : lightEntries).filter(([k]) => k.startsWith(prefix))
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
const colorSchemes = [];
|
|
212
|
-
for (const name in colorsLight) {
|
|
213
|
-
colorSchemes.push({
|
|
214
|
-
name,
|
|
215
|
-
colors: findColors(name),
|
|
216
|
-
darkColors: findColors(name, true)
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
const colorThemeEntries = colorSchemes.flatMap(({ name, colors, darkColors: darkColors2 }) => {
|
|
220
|
-
const [altLightThemes, altDarkThemes] = [
|
|
221
|
-
{ colors: darkColors2, backgrounds: colors },
|
|
222
|
-
{ colors, backgrounds: darkColors2 }
|
|
223
|
-
].map((props, i) => {
|
|
224
|
-
const isLight = i === 0;
|
|
225
|
-
const colorsBase = Object.values(props.colors).slice(2);
|
|
226
|
-
const [backgrounds, colors2] = [
|
|
227
|
-
Object.values(props.backgrounds),
|
|
228
|
-
isLight ? colorsBase : [colorsBase[0], "#ccc", ...colorsBase.slice(1)]
|
|
229
|
-
];
|
|
230
|
-
const scheme = isLight ? "light" : "dark";
|
|
231
|
-
const shift = isLight ? 0 : 1;
|
|
232
|
-
const themeWithAlts = createThemesFrom(name, themeCreator, {
|
|
233
|
-
// @ts-ignore
|
|
234
|
-
colors: colors2,
|
|
235
|
-
// @ts-ignore
|
|
236
|
-
backgrounds,
|
|
237
|
-
// @ts-ignore
|
|
238
|
-
borderColors: backgrounds,
|
|
239
|
-
isLight,
|
|
240
|
-
shift,
|
|
241
|
-
isBase: false,
|
|
242
|
-
offsets: {
|
|
243
|
-
background: isLight ? [2, 2, 2, 2, 2, 2] : null,
|
|
244
|
-
borderColor: isLight ? [2, 2, 2, 3, 2] : null,
|
|
245
|
-
color: isLight ? [0, 0, -1, -2, -3, -3, -4] : [-1, -1, -1, -1, -1, -1]
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
return Object.entries(themeWithAlts).map(([k, v]) => [`${scheme}_${k}`, v]);
|
|
249
|
-
});
|
|
250
|
-
return [...altLightThemes, ...altDarkThemes];
|
|
251
|
-
});
|
|
252
|
-
const colorThemes = Object.fromEntries(colorThemeEntries);
|
|
253
|
-
baseThemes.dark_active = {
|
|
254
|
-
...colorThemes[`dark_${activeColor}_alt2`],
|
|
255
|
-
background: darkColors[`${activeColor}10`],
|
|
256
|
-
backgroundHover: darkColors[`${activeColor}11`],
|
|
257
|
-
backgroundPress: darkColors[`${activeColor}9`],
|
|
258
|
-
backgroundFocus: darkColors[`${activeColor}9`],
|
|
259
|
-
color: darkColors[`${activeColor}12`],
|
|
260
|
-
colorHover: darkColors[`${activeColor}12`],
|
|
261
|
-
colorPress: darkColors[`${activeColor}12`],
|
|
262
|
-
colorFocus: darkColors[`${activeColor}12`]
|
|
263
|
-
};
|
|
264
|
-
baseThemes.light_active = baseThemes.dark_active;
|
|
265
|
-
const allThemes = {
|
|
266
|
-
...baseThemes,
|
|
267
|
-
...colorThemes
|
|
268
|
-
};
|
|
269
|
-
return allThemes;
|
|
270
|
-
};
|
|
271
|
-
export {
|
|
272
|
-
createThemes
|
|
273
|
-
};
|
|
274
|
-
//# sourceMappingURL=createThemes.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/createThemes.ts"],
|
|
4
|
-
"sourcesContent": ["import { Variable, createTheme, isWeb } from '@tamagui/core'\n\n// can make configurable\ntype AltKeys = 1 | 2\ntype AltName<Name extends string, Keys extends string | number> = `${Name}_alt${Keys}`\n\ntype Colors = {\n [key: string]: {\n [key: string]: string\n }\n}\n\ntype GeneratedTheme<ExtraKeys extends string = string> = {\n [Key in ExtraKeys]: Variable<string>\n} & {\n backgroundStrong: Variable<string>\n background: Variable<string>\n backgroundHover: Variable<string>\n backgroundPress: Variable<string>\n backgroundFocus: Variable<string>\n backgroundTransparent: Variable<string>\n color: Variable<string>\n colorHover: Variable<string>\n colorPress: Variable<string>\n colorFocus: Variable<string>\n shadowColor: Variable<string>\n shadowColorHover: Variable<string>\n shadowColorPress: Variable<string>\n shadowColorFocus: Variable<string>\n borderColor: Variable<string>\n borderColorHover: Variable<string>\n borderColorPress: Variable<string>\n borderColorFocus: Variable<string>\n placeholderColor: Variable<string>\n color1: Variable<string>\n color2: Variable<string>\n color3: Variable<string>\n color4: Variable<string>\n color5: Variable<string>\n color6: Variable<string>\n color7: Variable<string>\n color8: Variable<string>\n color9: Variable<string>\n color10: Variable<string>\n color11: Variable<string>\n color12: Variable<string>\n}\n\ntype SubTheme = {\n [key in keyof GeneratedTheme]?: Variable<string> | string\n}\n\ntype GetSubThemes<Name extends string> =\n | `${Name}`\n | `${Name}_alt${AltKeys}`\n | `${Name}_darker`\n | `${Name}_active`\n | `${Name}_Card`\n | `${Name}_SliderTrack`\n | `${Name}_SliderTrackActive`\n | `${Name}_Switch`\n | `${Name}_SwitchThumb`\n | `${Name}_DrawerFrame`\n | `${Name}_Button`\n | `${Name}_SliderThumb`\n | `${Name}_Progress`\n | `${Name}_ProgressIndicator`\n | `${Name}_TooltipArrow`\n | `${Name}_TooltipContent`\n\nexport type GeneratedThemes<ColorsList extends string, BaseColorList extends string> = {\n [key in\n | GetSubThemes<ColorsList extends string ? ColorsList : never>\n | GetSubThemes<`light`>\n | GetSubThemes<`dark`>]: GeneratedTheme<BaseColorList>\n}\n\nexport const createThemes = <ColorsList extends string, BaseColorList extends string>({\n activeColor,\n light,\n dark,\n colorsLight,\n colorsDark,\n}: {\n activeColor: string\n light: string[]\n dark: string[]\n colorsLight: Colors\n colorsDark: Colors\n}): GeneratedThemes<ColorsList, BaseColorList> => {\n function flatten(obj: Colors) {\n const next = {}\n for (const key in obj) {\n Object.assign(next, obj[key])\n }\n return next\n }\n\n const darkColors = flatten(colorsDark)\n const lightColors = flatten(colorsLight)\n\n // spaghetti ahead\n\n type ThemeCreatorProps = {\n shift?: number\n backgrounds: (string | Variable)[]\n backgroundStrong?: string | Variable\n borderColors?: (string | Variable)[]\n colors?: (string | Variable)[]\n activeTheme?: any\n offsets?: {\n color?: number[] | null\n background?: number[] | null\n borderColor?: number[] | null\n }\n isLight?: boolean\n isBase?: boolean\n }\n\n // helpers\n\n const alternates = [1, 2, 3] as const\n const alts = [1, 2] as const\n type ThemeCreator<A = any> = (str: number, props: ThemeCreatorProps) => A\n\n function createThemesFrom<\n Name extends string,\n GetTheme extends ThemeCreator = ThemeCreator\n >(\n name: Name,\n getTheme: GetTheme,\n props: ThemeCreatorProps\n ): {\n [key in GetSubThemes<Name>]: GetTheme extends ThemeCreator<infer Theme>\n ? Theme\n : never\n } {\n const { shift = 0 } = props\n const theme = getTheme(0 + shift, props)\n let themeEntries: any[] = [[name, theme]]\n\n // generate alternates (for use in other themes), but keep just alts\n const altThemes: any[] = alternates.map((alt) => [\n `${name}_alt${alt}`,\n getTheme(alt + shift + 1, props),\n ])\n\n const altButtonThemes: any[] = alternates.map((_, i) => {\n const [bName, bTheme] = [altThemes[i][0], (altThemes[i] || altThemes[i])[1]]\n return [`${bName}_Button` as any, bTheme]\n })\n // add these after alts since we rely on positioning\n const darkerTheme = getTheme(Math.max(0, shift + (props.isLight ? 1 : -1)), props)\n const activeTheme = props.activeTheme || {\n ...theme,\n borderColor: props.backgrounds[7],\n background: props.backgrounds[6],\n backgroundHover: props.backgrounds[6],\n backgroundPress: props.backgrounds[6],\n }\n\n // TODO can be de-duped\n const inverted = altThemes.map(([_name, theme]) => {\n return {\n ...theme,\n background: theme.color,\n backgroundHover: theme.colorHover,\n backgroundFocus: theme.colorFocus,\n backgroundPress: theme.colorPress,\n color: theme.background,\n colorHover: theme.backgroundHover,\n colorFocus: theme.backgroundFocus,\n colorPress: theme.backgroundPress,\n }\n })\n\n themeEntries = [\n ...themeEntries,\n // keep just alts\n ...altThemes.slice(0, alts.length),\n ...altButtonThemes.slice(0, alts.length),\n [`${name}_Button`, altThemes[1][1]],\n [`${name}_DrawerFrame`, altThemes[2][1]],\n [`${name}_SliderTrack`, altThemes[1][1]],\n [`${name}_SliderTrackActive`, altThemes[2][1]],\n [`${name}_SliderThumb`, inverted[2]],\n [`${name}_Progress`, altThemes[2][1]],\n [`${name}_ProgressIndicator`, inverted[2]],\n [`${name}_Switch`, altThemes[1][1]],\n [`${name}_SwitchThumb`, inverted[2]],\n [`${name}_TooltipArrow`, altThemes[2][1]],\n [`${name}_TooltipContent`, altThemes[2][1]],\n [`${name}_darker`, darkerTheme],\n [`${name}_active`, activeTheme],\n ]\n const themes = Object.fromEntries(themeEntries)\n return themes as any\n }\n\n const blanks = [0, 0, 0, 0]\n\n const themeCreator = (\n str = 1,\n {\n backgrounds,\n isLight = true,\n isBase = false,\n colors = [...backgrounds].reverse(),\n borderColors = isLight ? colors : backgrounds,\n backgroundStrong,\n offsets: offsetsProp,\n }: ThemeCreatorProps\n ) => {\n const offsets = {\n borderColor: offsetsProp?.borderColor ?? offsetsProp?.background ?? blanks,\n background: offsetsProp?.background ?? blanks,\n color: offsetsProp?.color ?? blanks,\n }\n const darkColors = isLight ? colors : backgrounds\n const lighterDir = isLight ? -1 : 1\n const darkerDir = -lighterDir\n const strongerDir = isLight ? darkerDir : lighterDir\n const softerDir = -strongerDir\n const get = (arr: any[], index: number, name = 'background') => {\n return arr[Math.max(0, Math.min(index + (offsets[name][str] || 0), arr.length - 1))]\n }\n\n const theme: SubTheme = {\n background: get(backgrounds, str),\n backgroundStrong: backgroundStrong || get(backgrounds, str + strongerDir * 2),\n backgroundHover: get(backgrounds, str + lighterDir),\n backgroundPress: get(backgrounds, str + darkerDir),\n backgroundFocus: get(backgrounds, str + darkerDir * 2),\n backgroundTransparent: 'hsla(0, 0%, 0%, 0.012)',\n color: get(colors, 0 + str, 'color'),\n colorHover: get(colors, 1 + str, 'color'),\n colorPress: get(colors, 2 + str, 'color'),\n colorFocus: get(colors, 3 + str, 'color'),\n shadowColor: isLight ? 'hsla(0, 0%, 0%, 0.03)' : 'hsla(0, 0%, 0%, 0.2)',\n shadowColorHover: darkColors[!isLight ? 1 : 8],\n shadowColorPress: darkColors[!isLight ? 1 : 8],\n shadowColorFocus: darkColors[!isLight ? 1 : 8],\n borderColor: null as any as string | Variable,\n borderColorHover: null as any as string | Variable,\n borderColorPress: null as any as string | Variable,\n borderColorFocus: null as any as string | Variable,\n color1: backgrounds[0],\n color2: backgrounds[1],\n color3: backgrounds[2],\n color4: backgrounds[3],\n color5: backgrounds[4],\n color6: backgrounds[5],\n color7: backgrounds[6],\n color8: backgrounds[7],\n color9: backgrounds[8],\n color10: backgrounds[9],\n color11: backgrounds[10],\n color12: backgrounds[11],\n placeholderColor: backgrounds[7],\n }\n\n if (isBase) {\n Object.assign(theme, {\n borderColor: isLight\n ? get(colors, 8 - str, 'borderColor')\n : get(backgrounds, 2 + str, 'borderColor'),\n borderColorHover: isLight\n ? get(colors, 6 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n borderColorPress: isLight\n ? get(colors, 5 - str, 'borderColor')\n : get(backgrounds, 1 + str, 'borderColor'),\n borderColorFocus: isLight\n ? get(colors, 4 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n })\n } else {\n Object.assign(theme, {\n borderColor: get(borderColors, 1 + strongerDir, 'borderColor'),\n borderColorHover: get(borderColors, 2 + strongerDir, 'borderColor'),\n borderColorPress: get(borderColors, 3 + strongerDir, 'borderColor'),\n borderColorFocus: get(borderColors, 4 + strongerDir, 'borderColor'),\n })\n }\n\n return theme\n }\n\n const lightThemes = createThemesFrom('light', themeCreator, {\n backgrounds: light,\n // for now web non-ios style native is...\n backgroundStrong: isWeb ? '#fefefe' : '#f2f2f2',\n borderColors: light.slice(2),\n isLight: true,\n offsets: {\n background: [2, 2, 2, 2, 2, 2],\n },\n })\n\n const darkThemes = createThemesFrom('dark', themeCreator, {\n backgrounds: dark,\n colors: light.slice(2),\n backgroundStrong: '#070707',\n isBase: true,\n isLight: false,\n // shift: 1,\n offsets: {\n color: [0, 4, 5, 5, 5, 5],\n },\n })\n\n darkThemes.dark_darker.background = '#030303'\n darkThemes.dark_darker.backgroundStrong = '#000'\n\n type LightColorKeys = keyof typeof lightColors\n\n type BaseTheme = {\n [key in LightColorKeys | keyof SubTheme]: Variable<string>\n }\n\n const lightTheme = createTheme({\n ...lightColors,\n ...lightThemes.light,\n }) as BaseTheme\n\n const darkTheme = createTheme({\n ...darkColors,\n ...darkThemes.dark,\n }) as BaseTheme\n\n const baseThemes = {\n // light\n ...lightThemes,\n light: lightTheme,\n // reserving in types, updating later\n light_active: lightThemes.light,\n light_Card: lightThemes.light,\n light_SliderTrack: lightThemes.light_alt1,\n light_SliderTrackActive: lightThemes.light_alt2,\n light_Switch: lightThemes.light_alt2,\n light_SwitchThumb: lightThemes.light,\n light_DrawerFrame: lightThemes.light_alt1,\n\n // dark\n ...darkThemes,\n dark: darkTheme,\n // reserving in types, updating later\n dark_active: darkThemes.dark,\n dark_Card: darkThemes.dark,\n dark_DrawerFrame: darkThemes.dark_alt1,\n dark_SliderTrack: darkThemes.dark_darker,\n dark_SliderTrackActive: darkThemes.dark_alt2,\n dark_Switch: darkThemes.dark_alt2,\n dark_SwitchThumb: darkThemes.dark_darker,\n dark_Button: darkThemes.dark_alt1,\n }\n\n const darkEntries = Object.entries(darkTheme)\n const lightEntries = Object.entries(lightTheme)\n function findColors(prefix: string, dark = false): BaseTheme {\n return Object.fromEntries(\n (dark ? darkEntries : lightEntries).filter(([k]) => k.startsWith(prefix))\n ) as any\n }\n\n const colorSchemes: any[] = []\n\n for (const name in colorsLight) {\n colorSchemes.push({\n name,\n colors: findColors(name),\n darkColors: findColors(name, true),\n })\n }\n\n type ColorThemeNames =\n | ColorsList\n | AltName<`light_${ColorsList extends string ? ColorsList : never}`, AltKeys>\n | AltName<`dark_${ColorsList extends string ? ColorsList : never}`, AltKeys>\n\n const colorThemeEntries = colorSchemes.flatMap(({ name, colors, darkColors }) => {\n const [altLightThemes, altDarkThemes] = [\n { colors: darkColors, backgrounds: colors },\n { colors, backgrounds: darkColors },\n ].map((props, i) => {\n const isLight = i === 0\n const colorsBase = Object.values(props.colors).slice(2)\n const [backgrounds, colors] = [\n Object.values(props.backgrounds),\n isLight ? colorsBase : [colorsBase[0], '#ccc', ...colorsBase.slice(1)],\n ] as const\n\n const scheme = isLight ? 'light' : 'dark'\n const shift = isLight ? 0 : 1\n\n // if (!isLight) {\n // const [_, h, sp, lp] = backgrounds[0].match(/hsl\\(([0-9\\.]+), ([0-9\\.]+)\\%, ([0-9\\.]+)\\%\\)/)!\n // backgrounds.unshift(`hsl(${h}, ${sp}%, ${parseFloat(lp) / 2}%)`)\n // }\n\n const themeWithAlts = createThemesFrom(name, themeCreator, {\n // @ts-ignore\n colors,\n // @ts-ignore\n backgrounds,\n // @ts-ignore\n borderColors: backgrounds,\n isLight,\n shift,\n isBase: false,\n offsets: {\n background: isLight ? [2, 2, 2, 2, 2, 2] : null,\n borderColor: isLight ? [2, 2, 2, 3, 2] : null,\n color: isLight ? [0, 0, -1, -2, -3, -3, -4] : [-1, -1, -1, -1, -1, -1],\n },\n })\n\n return Object.entries(themeWithAlts).map(([k, v]) => [`${scheme}_${k}`, v])\n })\n return [...altLightThemes, ...altDarkThemes]\n })\n\n type TypedColorTheme = typeof lightThemes.light_alt1\n\n const colorThemes: {\n [key in ColorThemeNames]: TypedColorTheme\n } = Object.fromEntries(colorThemeEntries) as any\n\n // add in base _active themes\n baseThemes.dark_active = {\n ...colorThemes[`dark_${activeColor}_alt2`],\n background: darkColors[`${activeColor}10`],\n backgroundHover: darkColors[`${activeColor}11`],\n backgroundPress: darkColors[`${activeColor}9`],\n backgroundFocus: darkColors[`${activeColor}9`],\n color: darkColors[`${activeColor}12`],\n colorHover: darkColors[`${activeColor}12`],\n colorPress: darkColors[`${activeColor}12`],\n colorFocus: darkColors[`${activeColor}12`],\n }\n\n // light active uses light foreground, ios style\n baseThemes.light_active = baseThemes.dark_active\n\n const allThemes = {\n ...baseThemes,\n ...colorThemes,\n } as any\n\n return allThemes\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAmB,aAAa,aAAa;AA6EtC,MAAM,eAAe,CAA0D;AAAA,EACpF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAMkD;AAChD,WAAS,QAAQ,KAAa;AAC5B,UAAM,OAAO,CAAC;AACd,eAAW,OAAO,KAAK;AACrB,aAAO,OAAO,MAAM,IAAI,GAAG,CAAC;AAAA,IAC9B;AACA,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,QAAQ,UAAU;AACrC,QAAM,cAAc,QAAQ,WAAW;AAsBvC,QAAM,aAAa,CAAC,GAAG,GAAG,CAAC;AAC3B,QAAM,OAAO,C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