reshaped 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/bin/cli.js +1 -11
- package/bundle.css +1 -1
- package/bundle.js +10 -10
- package/cli/theming/definitions/base.d.ts +1 -1
- package/cli/theming/definitions/figma.d.ts +1 -1
- package/cli/theming/definitions/reshaped.d.ts +1 -1
- package/cli/theming/definitions/slate.d.ts +1 -1
- package/cli/theming/index.d.ts +4 -4
- package/cli/theming/index.js +7 -107
- package/components/Actionable/Actionable.js +14 -3
- package/components/Actionable/Actionable.module.css +1 -1
- package/components/Autocomplete/tests/Autocomplete.stories.js +27 -1
- package/components/Button/Button.js +2 -0
- package/components/Button/Button.module.css +1 -1
- package/components/Button/Button.types.d.ts +6 -0
- package/components/Button/ButtonGroup.d.ts +4 -0
- package/components/Button/ButtonGroup.js +9 -0
- package/components/Button/tests/Button.stories.d.ts +1 -0
- package/components/Button/tests/Button.stories.js +63 -0
- package/components/DropdownMenu/tests/DropdownMenu.stories.js +1 -0
- package/components/Overlay/Overlay.js +4 -4
- package/components/Tabs/Tabs.d.ts +1 -8
- package/components/Tabs/Tabs.module.css +1 -1
- package/components/Tabs/Tabs.types.d.ts +6 -7
- package/components/Tabs/TabsContext.d.ts +4 -0
- package/components/Tabs/TabsControlled.js +24 -1
- package/components/Tabs/TabsItem.d.ts +1 -8
- package/components/Tabs/TabsItem.js +22 -4
- package/components/Tabs/TabsList.js +30 -32
- package/components/Tabs/tests/Tabs.stories.d.ts +1 -0
- package/components/Tabs/tests/Tabs.stories.js +17 -0
- package/components/Toast/ToastContainer.js +1 -0
- package/components/Toast/ToastProvider.js +4 -0
- package/components/Toast/tests/Toast.stories.js +1 -0
- package/components/_private/Flyout/FlyoutContent.js +4 -2
- package/components/_private/Flyout/tests/Flyout.stories.d.ts +1 -0
- package/components/_private/Flyout/tests/Flyout.stories.js +25 -0
- package/components/_private/Portal/Portal.d.ts +8 -4
- package/components/_private/Portal/Portal.js +23 -11
- package/components/_private/Portal/Portal.types.d.ts +7 -2
- package/components/_private/Portal/index.d.ts +1 -1
- package/components/_private/Portal/index.js +1 -1
- package/components/_private/Portal/tests/Portal.stories.js +11 -12
- package/config/tailwind.d.ts +1 -1
- package/config/tailwind.js +3 -3
- package/hooks/_private/useFlyout.js +16 -13
- package/package.json +36 -28
- package/themes/_generator/tests/themes.stories.d.ts +6 -0
- package/themes/_generator/tests/themes.stories.js +32 -0
- package/{cli/theming → themes/_generator}/tokens/color/color.transforms.d.ts +1 -1
- package/{cli/theming → themes/_generator}/tokens/duration/duration.transforms.d.ts +1 -1
- package/{cli/theming → themes/_generator}/tokens/easing/easing.transforms.d.ts +1 -1
- package/{cli/theming → themes/_generator}/tokens/font/font.transforms.d.ts +1 -1
- package/{cli/theming → themes/_generator}/tokens/fontFamily/fontFamily.transforms.d.ts +1 -1
- package/{cli/theming → themes/_generator}/tokens/fontWeight/fontWeight.transforms.d.ts +1 -1
- package/{cli/theming → themes/_generator}/tokens/shadow/shadow.transforms.d.ts +1 -1
- package/{cli/theming → themes/_generator}/tokens/shadow/shadow.transforms.js +1 -1
- package/{cli/theming → themes/_generator}/tokens/unit/unit.transforms.d.ts +1 -1
- package/{cli/theming → themes/_generator}/tokens/viewport/viewport.transforms.d.ts +1 -1
- package/themes/_generator/transform.d.ts +7 -0
- package/themes/_generator/transform.js +57 -0
- package/{cli/theming → themes/_generator}/types.d.ts +3 -1
- package/{cli/theming → themes/_generator}/utilities/css.js +3 -1
- package/themes/_generator/utilities/generateBackgroundColors.d.ts +4 -0
- package/themes/_generator/utilities/generateBackgroundColors.js +54 -0
- package/themes/_generator/utilities/generateUnits.d.ts +4 -0
- package/themes/_generator/utilities/generateUnits.js +17 -0
- package/{cli/theming → themes/_generator}/utilities/mergeDeep.js +1 -3
- package/{cli/theming → themes/_generator}/utilities/resolveTokenReference.js +1 -3
- package/themes/index.d.ts +3 -0
- package/themes/index.js +5 -0
- package/types/config.d.ts +1 -1
- package/utilities/a11y.js +12 -3
- package/{cli/utilities → utilities}/color.d.ts +1 -1
- package/utilities/dom.d.ts +1 -0
- package/utilities/dom.js +9 -0
- package/cli/utilities/tests/color.test.d.ts +0 -1
- package/cli/utilities/tests/color.test.js +0 -63
- /package/{cli/theming → themes/_generator}/tokens/color/color.transforms.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/color/color.types.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/tokens/color/color.types.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/duration/duration.transforms.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/duration/duration.types.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/tokens/duration/duration.types.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/easing/easing.transforms.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/easing/easing.types.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/tokens/easing/easing.types.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/font/font.transforms.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/font/font.types.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/tokens/font/font.types.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/fontFamily/fontFamily.transforms.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/fontFamily/fontFamily.types.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/tokens/fontFamily/fontFamily.types.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/fontWeight/fontWeight.transforms.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/fontWeight/fontWeight.types.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/tokens/fontWeight/fontWeight.types.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/shadow/shadow.types.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/tokens/shadow/shadow.types.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/transforms.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/tokens/transforms.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/types.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/tokens/types.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/unit/unit.transforms.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/unit/unit.types.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/tokens/unit/unit.types.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/viewport/viewport.transforms.js +0 -0
- /package/{cli/theming → themes/_generator}/tokens/viewport/viewport.types.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/tokens/viewport/viewport.types.js +0 -0
- /package/{cli/theming → themes/_generator}/types.js +0 -0
- /package/{cli/theming → themes/_generator}/utilities/css.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/utilities/mergeDeep.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/utilities/mergeDefinitions.d.ts +0 -0
- /package/{cli/theming → themes/_generator}/utilities/mergeDefinitions.js +0 -0
- /package/{cli/theming → themes/_generator}/utilities/resolveTokenReference.d.ts +0 -0
- /package/{cli/utilities → utilities}/color.js +0 -0
- /package/{cli/utilities → utilities}/string.d.ts +0 -0
- /package/{cli/utilities → utilities}/string.js +0 -0
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "reshaped",
|
3
3
|
"description": "Professionally crafted design system in React & Figma for building products of any scale and complexity",
|
4
|
-
"version": "2.
|
4
|
+
"version": "2.3.0",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
6
6
|
"email": "hello@reshaped.so",
|
7
7
|
"homepage": "https://reshaped.so",
|
@@ -79,53 +79,53 @@
|
|
79
79
|
"defaults and not IE 11"
|
80
80
|
],
|
81
81
|
"devDependencies": {
|
82
|
-
"@size-limit/preset-big-lib": "
|
83
|
-
"@storybook/addon-a11y": "7.
|
84
|
-
"@storybook/react": "7.
|
85
|
-
"@storybook/react-vite": "7.
|
86
|
-
"@testing-library/jest-dom": "
|
82
|
+
"@size-limit/preset-big-lib": "9.0.0",
|
83
|
+
"@storybook/addon-a11y": "7.4.0",
|
84
|
+
"@storybook/react": "7.4.0",
|
85
|
+
"@storybook/react-vite": "7.4.0",
|
86
|
+
"@testing-library/jest-dom": "6.1.3",
|
87
87
|
"@testing-library/react": "14.0.0",
|
88
88
|
"@testing-library/user-event": "14.4.3",
|
89
89
|
"@types/events": "3.0.0",
|
90
|
-
"@types/jest": "29.5.
|
91
|
-
"@types/node": "20.
|
92
|
-
"@types/react": "18.2.
|
90
|
+
"@types/jest": "29.5.4",
|
91
|
+
"@types/node": "20.6.0",
|
92
|
+
"@types/react": "18.2.21",
|
93
93
|
"@types/react-dom": "18.2.7",
|
94
|
-
"@typescript-eslint/eslint-plugin": "6.
|
95
|
-
"@typescript-eslint/parser": "6.
|
94
|
+
"@typescript-eslint/eslint-plugin": "6.6.0",
|
95
|
+
"@typescript-eslint/parser": "6.6.0",
|
96
96
|
"@vitejs/plugin-react": "4.0.4",
|
97
|
-
"chromatic": "
|
98
|
-
"eslint": "8.
|
97
|
+
"chromatic": "7.1.0",
|
98
|
+
"eslint": "8.49.0",
|
99
99
|
"eslint-config-airbnb-typescript": "17.1.0",
|
100
100
|
"eslint-config-prettier": "9.0.0",
|
101
|
-
"eslint-plugin-import": "2.28.
|
101
|
+
"eslint-plugin-import": "2.28.1",
|
102
102
|
"eslint-plugin-jsx-a11y": "6.7.1",
|
103
103
|
"eslint-plugin-prettier": "5.0.0",
|
104
|
-
"eslint-plugin-react": "7.33.
|
104
|
+
"eslint-plugin-react": "7.33.2",
|
105
105
|
"eslint-plugin-react-hooks": "4.6.0",
|
106
106
|
"identity-obj-proxy": "3.0.0",
|
107
|
-
"jest": "29.6.
|
108
|
-
"jest-environment-jsdom": "29.6.
|
107
|
+
"jest": "29.6.4",
|
108
|
+
"jest-environment-jsdom": "29.6.4",
|
109
109
|
"jest-matchmedia-mock": "1.1.0",
|
110
|
-
"lefthook": "1.4.
|
111
|
-
"postcss": "8.4.
|
110
|
+
"lefthook": "1.4.10",
|
111
|
+
"postcss": "8.4.29",
|
112
112
|
"postcss-cli": "10.1.0",
|
113
113
|
"postcss-each": "1.1.0",
|
114
114
|
"postcss-import": "15.1.0",
|
115
115
|
"postcss-nested": "6.0.1",
|
116
|
-
"prettier": "3.0.
|
116
|
+
"prettier": "3.0.3",
|
117
117
|
"react": "18.2.0",
|
118
118
|
"react-dom": "18.2.0",
|
119
|
-
"resolve-tspaths": "0.8.
|
120
|
-
"size-limit": "
|
121
|
-
"storybook": "7.
|
122
|
-
"stylelint": "15.10.
|
119
|
+
"resolve-tspaths": "0.8.15",
|
120
|
+
"size-limit": "9.0.0",
|
121
|
+
"storybook": "7.4.0",
|
122
|
+
"stylelint": "15.10.3",
|
123
123
|
"stylelint-config-prettier": "9.0.5",
|
124
124
|
"stylelint-config-standard": "34.0.0",
|
125
125
|
"ts-jest": "29.1.1",
|
126
|
-
"typescript": "5.
|
127
|
-
"vite": "4.4.
|
128
|
-
"vite-tsconfig-paths": "4.2.
|
126
|
+
"typescript": "5.2.2",
|
127
|
+
"vite": "4.4.9",
|
128
|
+
"vite-tsconfig-paths": "4.2.1"
|
129
129
|
},
|
130
130
|
"peerDependencies": {
|
131
131
|
"postcss": "^8.0.0",
|
@@ -133,12 +133,15 @@
|
|
133
133
|
"react-dom": "^18.0.0"
|
134
134
|
},
|
135
135
|
"dependencies": {
|
136
|
-
"autoprefixer": "10.4.
|
136
|
+
"autoprefixer": "10.4.15",
|
137
137
|
"chalk": "4.1.2",
|
138
138
|
"commander": "11.0.0",
|
139
139
|
"cssnano": "6.0.1",
|
140
140
|
"postcss-custom-media": "8.0.2"
|
141
141
|
},
|
142
|
+
"resolutions": {
|
143
|
+
"jackspeak": "2.1.1"
|
144
|
+
},
|
142
145
|
"size-limit": [
|
143
146
|
{
|
144
147
|
"name": "JS",
|
@@ -149,6 +152,11 @@
|
|
149
152
|
"name": "CSS",
|
150
153
|
"path": "dist/bundle.css",
|
151
154
|
"webpack": false
|
155
|
+
},
|
156
|
+
{
|
157
|
+
"name": "JS Theming engine",
|
158
|
+
"path": "dist/themes/index.js",
|
159
|
+
"webpack": true
|
152
160
|
}
|
153
161
|
],
|
154
162
|
"engines": {
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Example } from "../../../utilities/storybook/index.js";
|
3
|
+
import Button from "../../../components/Button/index.js";
|
4
|
+
import Theme from "../../../components/Theme/index.js";
|
5
|
+
import { getThemeCSS } from "../../index.js";
|
6
|
+
export default { title: "Themes" };
|
7
|
+
const css = getThemeCSS("green", {
|
8
|
+
color: {
|
9
|
+
backgroundPrimary: { hex: "#1abc9c", hexDark: "#16a085" },
|
10
|
+
backgroundPrimaryHighlighted: { hex: "#16a085", hexDark: "#1abc9c" },
|
11
|
+
},
|
12
|
+
});
|
13
|
+
const css2 = getThemeCSS("peach", {
|
14
|
+
color: {
|
15
|
+
backgroundPrimary: { hex: "#ffbe76" },
|
16
|
+
backgroundPrimaryHighlighted: { hex: "#ffbe76" },
|
17
|
+
},
|
18
|
+
});
|
19
|
+
export const behavior = () => (<Example>
|
20
|
+
<Example.Item title="custom runtime theme">
|
21
|
+
<style>{css}</style>
|
22
|
+
<Theme name="green">
|
23
|
+
<Button color="primary">Primary button</Button>
|
24
|
+
</Theme>
|
25
|
+
</Example.Item>
|
26
|
+
<Example.Item title="on colors generation">
|
27
|
+
<style>{css2}</style>
|
28
|
+
<Theme name="peach">
|
29
|
+
<Button color="primary">Primary button</Button>
|
30
|
+
</Theme>
|
31
|
+
</Example.Item>
|
32
|
+
</Example>);
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type * as T from "./types";
|
2
|
+
import type { FullThemeDefinition } from "./tokens/types";
|
3
|
+
declare const transform: (name: string, definition: T.PartialDeep<FullThemeDefinition>, options: T.PrivateOptions) => {
|
4
|
+
variables: string;
|
5
|
+
media: string | undefined;
|
6
|
+
};
|
7
|
+
export default transform;
|
@@ -0,0 +1,57 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
const transforms = __importStar(require("./tokens/transforms"));
|
30
|
+
const css_1 = require("./utilities/css");
|
31
|
+
const generateBackgroundColors_1 = __importDefault(require("./utilities/generateBackgroundColors"));
|
32
|
+
const generateUnits_1 = __importDefault(require("./utilities/generateUnits"));
|
33
|
+
const transform = (name, definition, options) => {
|
34
|
+
const { isPrivate, isFragment, themeOptions } = options;
|
35
|
+
(0, generateBackgroundColors_1.default)(definition, themeOptions);
|
36
|
+
(0, generateUnits_1.default)(definition);
|
37
|
+
const transformedStorage = {
|
38
|
+
variable: [],
|
39
|
+
media: [],
|
40
|
+
};
|
41
|
+
Object.entries(definition).forEach(([tokenType, tokenValues]) => {
|
42
|
+
if (!tokenValues)
|
43
|
+
return;
|
44
|
+
const transform = transforms.css[tokenType];
|
45
|
+
Object.entries(tokenValues).forEach(([tokenName, token]) => {
|
46
|
+
const transformedTokens = transform(tokenName, token, definition);
|
47
|
+
transformedTokens.forEach((transformedToken) => {
|
48
|
+
transformedStorage[transformedToken.type].push(transformedToken);
|
49
|
+
});
|
50
|
+
});
|
51
|
+
});
|
52
|
+
return {
|
53
|
+
variables: (0, css_1.variablesTemplate)(name, transformedStorage.variable),
|
54
|
+
media: isPrivate && !isFragment ? (0, css_1.mediaTemplate)(transformedStorage.media) : undefined,
|
55
|
+
};
|
56
|
+
};
|
57
|
+
exports.default = transform;
|
@@ -5,10 +5,12 @@ export type PartialDeep<T> = T extends Primitive ? Partial<T> : {
|
|
5
5
|
};
|
6
6
|
export type PublicOptions = {
|
7
7
|
isPrivate?: boolean;
|
8
|
-
outputPath: string;
|
9
8
|
themeOptions?: ReshapedConfig["themeOptions"];
|
10
9
|
};
|
11
10
|
export type PrivateOptions = PublicOptions & {
|
12
11
|
isFragment?: boolean;
|
13
12
|
};
|
13
|
+
export type CLIOptions = PrivateOptions & {
|
14
|
+
outputPath: string;
|
15
|
+
};
|
14
16
|
export {};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.mediaTemplate = exports.variablesTemplate = exports.createMedia = exports.createVariable = exports.getVariableName = void 0;
|
4
|
-
const string_1 = require("
|
4
|
+
const string_1 = require("../../../utilities/string");
|
5
5
|
const getVariableName = (tokenName, tokenType) => {
|
6
6
|
const value = ["rs", tokenType && (0, string_1.camelToKebab)(tokenType), (0, string_1.camelToKebab)(tokenName)]
|
7
7
|
.filter(Boolean)
|
@@ -35,6 +35,8 @@ const variablesTemplate = (themeName, tokens) => {
|
|
35
35
|
const selector = type === "root"
|
36
36
|
? `[data-rs-theme="${themeName}"][data-rs-color-mode="light"], [data-rs-theme="${themeName}"][data-rs-color-mode="dark"]`
|
37
37
|
: `[data-rs-theme="${themeName}"][data-rs-color-mode="${type}"]`;
|
38
|
+
if (!tokens.length)
|
39
|
+
return;
|
38
40
|
code += `
|
39
41
|
${selector} {
|
40
42
|
${tokens.map((token) => (0, exports.createVariable)(token)).join("\n")}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import type * as T from "../types";
|
2
|
+
import type { FullThemeDefinition } from "../tokens/types";
|
3
|
+
declare const generateBackgroundColors: (definition: T.PartialDeep<FullThemeDefinition>, themeOptions?: T.PublicOptions["themeOptions"]) => void;
|
4
|
+
export default generateBackgroundColors;
|
@@ -0,0 +1,54 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const color_1 = require("../../../utilities/color");
|
4
|
+
const string_1 = require("../../../utilities/string");
|
5
|
+
const generateBackgroundColors = (definition, themeOptions) => {
|
6
|
+
if (!definition.color)
|
7
|
+
return;
|
8
|
+
Object.keys(definition.color).forEach((tokenName) => {
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
10
|
+
const bgToken = (_a = definition.color) === null || _a === void 0 ? void 0 : _a[tokenName];
|
11
|
+
const generatedForegroundName = `on${(0, string_1.capitalize)(tokenName)}`;
|
12
|
+
const generatedRGBName = `rgb${(0, string_1.capitalize)(tokenName)}`;
|
13
|
+
const generateOnColorsFor = [
|
14
|
+
"backgroundNeutral",
|
15
|
+
"backgroundPrimary",
|
16
|
+
"backgroundCritical",
|
17
|
+
"backgroundPositive",
|
18
|
+
...((themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.generateOnColorsFor) || []),
|
19
|
+
];
|
20
|
+
const needsDynamicForeground = generateOnColorsFor.includes(tokenName);
|
21
|
+
const needsRGB = tokenName.startsWith("background") ||
|
22
|
+
tokenName.endsWith("black") ||
|
23
|
+
tokenName.endsWith("white");
|
24
|
+
if (!bgToken)
|
25
|
+
return;
|
26
|
+
if (needsDynamicForeground) {
|
27
|
+
const hex = (0, color_1.getOnColor)({
|
28
|
+
bgHexColor: bgToken.hex,
|
29
|
+
mode: "light",
|
30
|
+
lightHexColor: (_c = (_b = definition === null || definition === void 0 ? void 0 : definition.color) === null || _b === void 0 ? void 0 : _b.white) === null || _c === void 0 ? void 0 : _c.hex,
|
31
|
+
darkHexColor: (_e = (_d = definition === null || definition === void 0 ? void 0 : definition.color) === null || _d === void 0 ? void 0 : _d.black) === null || _e === void 0 ? void 0 : _e.hex,
|
32
|
+
});
|
33
|
+
const hexDark = (0, color_1.getOnColor)({
|
34
|
+
bgHexColor: bgToken.hexDark || bgToken.hex,
|
35
|
+
mode: "dark",
|
36
|
+
lightHexColor: (_g = (_f = definition === null || definition === void 0 ? void 0 : definition.color) === null || _f === void 0 ? void 0 : _f.white) === null || _g === void 0 ? void 0 : _g.hex,
|
37
|
+
darkHexColor: (_j = (_h = definition === null || definition === void 0 ? void 0 : definition.color) === null || _h === void 0 ? void 0 : _h.black) === null || _j === void 0 ? void 0 : _j.hex,
|
38
|
+
});
|
39
|
+
// eslint-disable-next-line no-param-reassign
|
40
|
+
definition.color[generatedForegroundName] = {
|
41
|
+
hex,
|
42
|
+
hexDark: hex !== hexDark ? hexDark : undefined,
|
43
|
+
};
|
44
|
+
}
|
45
|
+
if (needsRGB) {
|
46
|
+
// eslint-disable-next-line no-param-reassign
|
47
|
+
definition.color[generatedRGBName] = {
|
48
|
+
hex: (0, color_1.hexToRgbString)(bgToken.hex),
|
49
|
+
hexDark: bgToken.hexDark && (0, color_1.hexToRgbString)(bgToken.hexDark),
|
50
|
+
};
|
51
|
+
}
|
52
|
+
});
|
53
|
+
};
|
54
|
+
exports.default = generateBackgroundColors;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const generateUnits = (definition) => {
|
4
|
+
var _a, _b;
|
5
|
+
const baseValue = (_b = (_a = definition.unit) === null || _a === void 0 ? void 0 : _a.base) === null || _b === void 0 ? void 0 : _b.px;
|
6
|
+
// If base value hasn't changed, we don't need to regenerate tokens
|
7
|
+
if (!baseValue)
|
8
|
+
return;
|
9
|
+
for (let i = 1; i <= 10; i += 1) {
|
10
|
+
const generatedName = `x${i}`;
|
11
|
+
// eslint-disable-next-line no-param-reassign
|
12
|
+
definition.unit[generatedName] = {
|
13
|
+
px: baseValue * i,
|
14
|
+
};
|
15
|
+
}
|
16
|
+
};
|
17
|
+
exports.default = generateUnits;
|
@@ -1,5 +1,3 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
1
|
const isObject = (item) => {
|
4
2
|
return item && typeof item === "object" && !Array.isArray(item);
|
5
3
|
};
|
@@ -21,4 +19,4 @@ const mergeDeep = (target, ...sources) => {
|
|
21
19
|
}
|
22
20
|
return mergeDeep(target, ...sources);
|
23
21
|
};
|
24
|
-
|
22
|
+
export default mergeDeep;
|
@@ -1,5 +1,3 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
1
|
const resolveTokenReference = (theme, tokenType, ref) => {
|
4
2
|
const tokenGroup = theme[tokenType];
|
5
3
|
let referencedToken = null;
|
@@ -13,4 +11,4 @@ const resolveTokenReference = (theme, tokenType, ref) => {
|
|
13
11
|
throw new Error(`Referenced token not found for: ${ref}`);
|
14
12
|
return referencedToken;
|
15
13
|
};
|
16
|
-
|
14
|
+
export default resolveTokenReference;
|
package/themes/index.js
ADDED
package/types/config.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { PartialUserThemeDefinition } from "../
|
1
|
+
import { PartialUserThemeDefinition } from "../themes/_generator/tokens/types";
|
2
2
|
export type ReshapedConfig = {
|
3
3
|
themes?: Record<string, PartialUserThemeDefinition>;
|
4
4
|
themeFragments?: Record<string, PartialUserThemeDefinition>;
|
package/utilities/a11y.js
CHANGED
@@ -102,10 +102,19 @@ export const trapFocus = (() => {
|
|
102
102
|
const isSelectionMenu = mode === "selection-menu";
|
103
103
|
const isTabMode = isDialog || isContentMenu;
|
104
104
|
const isArrowsMode = mode === "action-menu" || isSelectionMenu;
|
105
|
+
const focusable = getFocusableElements(root, includeTrigger ? triggerElement : undefined);
|
105
106
|
let chainId;
|
107
|
+
// Re-focus on the first element if content has changed
|
108
|
+
const observer = new MutationObserver(() => {
|
109
|
+
const focusable = getFocusableElements(root, includeTrigger ? triggerElement : undefined);
|
110
|
+
if (!focusable.length)
|
111
|
+
return;
|
112
|
+
focusElement(focusable[0], mode);
|
113
|
+
});
|
106
114
|
const release = (releaseOptions = {}) => {
|
107
115
|
const { withoutFocusReturn } = releaseOptions;
|
108
116
|
chain.removePreviousTill(chainId, (item) => document.body.contains(item.data.trigger));
|
117
|
+
observer.disconnect();
|
109
118
|
if (triggerElement) {
|
110
119
|
triggerElement.focus({ preventScroll: withoutFocusReturn || !isKeyboardMode() });
|
111
120
|
}
|
@@ -159,7 +168,9 @@ export const trapFocus = (() => {
|
|
159
168
|
resetListeners();
|
160
169
|
if (isDialog)
|
161
170
|
srTrap = trapScreenReader(root);
|
162
|
-
|
171
|
+
document.addEventListener("keydown", handleKeyDown);
|
172
|
+
resetListeners = () => document.removeEventListener("keydown", handleKeyDown);
|
173
|
+
observer.observe(root, { childList: true, subtree: true });
|
163
174
|
if (!focusable.length)
|
164
175
|
return null;
|
165
176
|
// Don't add back to the chain if we're traversing back
|
@@ -168,8 +179,6 @@ export const trapFocus = (() => {
|
|
168
179
|
chainId = chain.add({ root, trigger: triggerElement, options });
|
169
180
|
focusElement(focusable[0], mode);
|
170
181
|
}
|
171
|
-
document.addEventListener("keydown", handleKeyDown);
|
172
|
-
resetListeners = () => document.removeEventListener("keydown", handleKeyDown);
|
173
182
|
return release;
|
174
183
|
};
|
175
184
|
})();
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getClosestScrollableParent: (el: HTMLElement | null) => HTMLElement;
|
package/utilities/dom.js
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
export const getClosestScrollableParent = (el) => {
|
2
|
+
const overflowY = el && window.getComputedStyle(el).overflowY;
|
3
|
+
const isScrollable = overflowY === null || overflowY === void 0 ? void 0 : overflowY.includes("scroll");
|
4
|
+
if (el === document.body || !el)
|
5
|
+
return document.body;
|
6
|
+
if (isScrollable && el.scrollHeight > el.clientHeight)
|
7
|
+
return el;
|
8
|
+
return getClosestScrollableParent(el.parentElement);
|
9
|
+
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,63 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const color_1 = require("../color");
|
4
|
-
describe("cli/utilities/color", () => {
|
5
|
-
test("returns white for black background", () => {
|
6
|
-
expect((0, color_1.getOnColor)({ bgHexColor: "#000000", mode: "light" })).toBe("#ffffff");
|
7
|
-
});
|
8
|
-
test("returns white for dark colored background", () => {
|
9
|
-
expect((0, color_1.getOnColor)({ bgHexColor: "#aa0000", mode: "light" })).toBe("#ffffff");
|
10
|
-
});
|
11
|
-
test("returns black for white background", () => {
|
12
|
-
expect((0, color_1.getOnColor)({ bgHexColor: "#ffffff", mode: "light" })).toBe("#000000");
|
13
|
-
});
|
14
|
-
test("returns white for light colored background", () => {
|
15
|
-
expect((0, color_1.getOnColor)({ bgHexColor: "#dedede", mode: "light" })).toBe("#000000");
|
16
|
-
});
|
17
|
-
/**
|
18
|
-
* 8-digit hex
|
19
|
-
*/
|
20
|
-
test("returns black for dark background with alpha: 0", () => {
|
21
|
-
expect((0, color_1.getOnColor)({ bgHexColor: "#00000000", mode: "light" })).toBe("#000000");
|
22
|
-
});
|
23
|
-
test("returns black for light background with alpha: 0", () => {
|
24
|
-
expect((0, color_1.getOnColor)({ bgHexColor: "#ffffff00", mode: "light" })).toBe("#000000");
|
25
|
-
});
|
26
|
-
test("returns black for dark background with alpha: 25%", () => {
|
27
|
-
expect((0, color_1.getOnColor)({ bgHexColor: "#00000040", mode: "light" })).toBe("#000000");
|
28
|
-
});
|
29
|
-
test("returns white for dark background with alpha: 30%", () => {
|
30
|
-
expect((0, color_1.getOnColor)({ bgHexColor: "#0000004D", mode: "light" })).toBe("#ffffff");
|
31
|
-
});
|
32
|
-
/**
|
33
|
-
* Dark mode
|
34
|
-
*/
|
35
|
-
test("returns black for white background in dark mode", () => {
|
36
|
-
expect((0, color_1.getOnColor)({ bgHexColor: "#ffffff", mode: "dark" })).toBe("#000000");
|
37
|
-
});
|
38
|
-
test("returns white for dark background with alpha: 25% in dark mode", () => {
|
39
|
-
expect((0, color_1.getOnColor)({ bgHexColor: "#00000040", mode: "dark" })).toBe("#ffffff");
|
40
|
-
});
|
41
|
-
test("returns white for dark background with alpha: 0 in dark mode", () => {
|
42
|
-
expect((0, color_1.getOnColor)({ bgHexColor: "#00000000", mode: "dark" })).toBe("#ffffff");
|
43
|
-
});
|
44
|
-
/**
|
45
|
-
* Custom resolved color
|
46
|
-
*/
|
47
|
-
test("returns #999 for white background in dark mode", () => {
|
48
|
-
expect((0, color_1.getOnColor)({
|
49
|
-
bgHexColor: "#ffffff",
|
50
|
-
mode: "dark",
|
51
|
-
lightHexColor: "#eeeeee",
|
52
|
-
darkHexColor: "#999999",
|
53
|
-
})).toBe("#999999");
|
54
|
-
});
|
55
|
-
test("returns #eee for black background in dark mode", () => {
|
56
|
-
expect((0, color_1.getOnColor)({
|
57
|
-
bgHexColor: "#000000",
|
58
|
-
mode: "dark",
|
59
|
-
lightHexColor: "#eeeeee",
|
60
|
-
darkHexColor: "#999999",
|
61
|
-
})).toBe("#eeeeee");
|
62
|
-
});
|
63
|
-
});
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|