@aws-amplify/ui-react-native 2.2.12 → 2.2.14
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/dist/theme/createTheme.js +2 -13
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/lib/theme/createTheme.js +7 -19
- package/lib/version.js +1 -1
- package/package.json +4 -5
- package/src/theme/createTheme.ts +13 -18
- package/src/version.ts +1 -1
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import deepExtend from '
|
|
2
|
-
import resolveObject from 'style-dictionary/lib/utils/resolveObject';
|
|
3
|
-
import usesReference from 'style-dictionary/lib/utils/references/usesReference';
|
|
1
|
+
import { deepExtend, resolveObject, usesReference } from '@aws-amplify/ui';
|
|
4
2
|
import { isFunction, setupTokens } from '@aws-amplify/ui';
|
|
5
3
|
import { defaultTheme } from './defaultTheme';
|
|
6
|
-
// This will resolve all references in component themes by either
|
|
7
|
-
// calling the component theme function with the already resolved base tokens
|
|
8
|
-
// OR
|
|
9
|
-
// resolving the component theme object
|
|
10
4
|
const setupComponents = ({ components, tokens, }) => {
|
|
11
5
|
const output = components
|
|
12
6
|
? Object.entries(components).reduce((acc, [key, value]) => ({
|
|
@@ -64,12 +58,7 @@ const setupToken = ({ token, path = [], spaceModifier, }) => {
|
|
|
64
58
|
export const createTheme = (theme, colorMode) => {
|
|
65
59
|
// merge custom `theme` param and `StrictTheme` to get the merged theme.
|
|
66
60
|
// `deepExtend` is a Style Dictionary method that performs a deep merge on n objects.
|
|
67
|
-
const mergedTheme = deepExtend([
|
|
68
|
-
{},
|
|
69
|
-
defaultTheme,
|
|
70
|
-
theme,
|
|
71
|
-
// cast to `StrictTheme` as `deepExtend` returns a generic object
|
|
72
|
-
]);
|
|
61
|
+
const mergedTheme = deepExtend([{}, defaultTheme, theme]);
|
|
73
62
|
let { tokens: mergedTokens } = mergedTheme;
|
|
74
63
|
const { spaceModifier = 1 } = mergedTheme;
|
|
75
64
|
// We need to merge in any applicable overrides because we need to
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.2.
|
|
1
|
+
export declare const VERSION = "2.2.14";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '2.2.
|
|
1
|
+
export const VERSION = '2.2.14';
|
package/lib/theme/createTheme.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createTheme = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const deepExtend_1 = tslib_1.__importDefault(require("style-dictionary/lib/utils/deepExtend"));
|
|
6
|
-
const resolveObject_1 = tslib_1.__importDefault(require("style-dictionary/lib/utils/resolveObject"));
|
|
7
|
-
const usesReference_1 = tslib_1.__importDefault(require("style-dictionary/lib/utils/references/usesReference"));
|
|
8
4
|
const ui_1 = require("@aws-amplify/ui");
|
|
5
|
+
const ui_2 = require("@aws-amplify/ui");
|
|
9
6
|
const defaultTheme_1 = require("./defaultTheme");
|
|
10
|
-
// This will resolve all references in component themes by either
|
|
11
|
-
// calling the component theme function with the already resolved base tokens
|
|
12
|
-
// OR
|
|
13
|
-
// resolving the component theme object
|
|
14
7
|
const setupComponents = ({ components, tokens, }) => {
|
|
15
8
|
const output = components
|
|
16
9
|
? Object.entries(components).reduce((acc, [key, value]) => ({
|
|
17
10
|
...acc,
|
|
18
|
-
[key]: (0,
|
|
11
|
+
[key]: (0, ui_2.isFunction)(value) ? value(tokens) : value,
|
|
19
12
|
}), {})
|
|
20
13
|
: {};
|
|
21
|
-
return (0,
|
|
14
|
+
return (0, ui_1.resolveObject)({
|
|
22
15
|
...tokens,
|
|
23
16
|
components: output,
|
|
24
17
|
}).components;
|
|
@@ -36,7 +29,7 @@ const setupToken = ({ token, path = [], spaceModifier, }) => {
|
|
|
36
29
|
if (typeof value === 'string') {
|
|
37
30
|
// Remove .value from references if there is a reference
|
|
38
31
|
// this needs to come first so we don't get NaNs for references
|
|
39
|
-
if ((0,
|
|
32
|
+
if ((0, ui_1.usesReference)(value)) {
|
|
40
33
|
return value.replace('.value', '');
|
|
41
34
|
}
|
|
42
35
|
if (shouldParseFloatValue(path[0])) {
|
|
@@ -68,12 +61,7 @@ const setupToken = ({ token, path = [], spaceModifier, }) => {
|
|
|
68
61
|
const createTheme = (theme, colorMode) => {
|
|
69
62
|
// merge custom `theme` param and `StrictTheme` to get the merged theme.
|
|
70
63
|
// `deepExtend` is a Style Dictionary method that performs a deep merge on n objects.
|
|
71
|
-
const mergedTheme = (0,
|
|
72
|
-
{},
|
|
73
|
-
defaultTheme_1.defaultTheme,
|
|
74
|
-
theme,
|
|
75
|
-
// cast to `StrictTheme` as `deepExtend` returns a generic object
|
|
76
|
-
]);
|
|
64
|
+
const mergedTheme = (0, ui_1.deepExtend)([{}, defaultTheme_1.defaultTheme, theme]);
|
|
77
65
|
let { tokens: mergedTokens } = mergedTheme;
|
|
78
66
|
const { spaceModifier = 1 } = mergedTheme;
|
|
79
67
|
// We need to merge in any applicable overrides because we need to
|
|
@@ -82,7 +70,7 @@ const createTheme = (theme, colorMode) => {
|
|
|
82
70
|
if (theme?.overrides?.length) {
|
|
83
71
|
theme.overrides.forEach((override) => {
|
|
84
72
|
if (override?.colorMode === colorMode) {
|
|
85
|
-
mergedTokens = (0,
|
|
73
|
+
mergedTokens = (0, ui_1.deepExtend)([
|
|
86
74
|
{},
|
|
87
75
|
mergedTokens,
|
|
88
76
|
override.tokens,
|
|
@@ -94,7 +82,7 @@ const createTheme = (theme, colorMode) => {
|
|
|
94
82
|
// Setup the tokens:
|
|
95
83
|
// - each token will have a raw value
|
|
96
84
|
// - references to tokens (strings wrapped in curly braces) are replaced by raw values
|
|
97
|
-
const tokens = (0,
|
|
85
|
+
const tokens = (0, ui_1.resolveObject)((0, ui_2.setupTokens)({
|
|
98
86
|
tokens: mergedTokens,
|
|
99
87
|
setupToken: ({ token, path }) => {
|
|
100
88
|
return setupToken({ token, path, spaceModifier });
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/ui-react-native",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.14",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -30,10 +30,9 @@
|
|
|
30
30
|
"react-native-safe-area-context": "^4.7.3"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@aws-amplify/ui": "6.6.
|
|
34
|
-
"@aws-amplify/ui-react-core": "3.0.
|
|
35
|
-
"@aws-amplify/ui-react-core-notifications": "2.0.
|
|
36
|
-
"style-dictionary": "3.9.1"
|
|
33
|
+
"@aws-amplify/ui": "6.6.3",
|
|
34
|
+
"@aws-amplify/ui-react-core": "3.0.27",
|
|
35
|
+
"@aws-amplify/ui-react-core-notifications": "2.0.27"
|
|
37
36
|
},
|
|
38
37
|
"peerDependencies": {
|
|
39
38
|
"aws-amplify": "^6.6.0",
|
package/src/theme/createTheme.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import deepExtend from '
|
|
2
|
-
import resolveObject from 'style-dictionary/lib/utils/resolveObject';
|
|
3
|
-
import usesReference from 'style-dictionary/lib/utils/references/usesReference';
|
|
1
|
+
import { deepExtend, resolveObject, usesReference } from '@aws-amplify/ui';
|
|
4
2
|
import { isFunction, setupTokens } from '@aws-amplify/ui';
|
|
5
3
|
import {
|
|
6
4
|
Theme,
|
|
@@ -15,13 +13,15 @@ import { defaultTheme } from './defaultTheme';
|
|
|
15
13
|
// calling the component theme function with the already resolved base tokens
|
|
16
14
|
// OR
|
|
17
15
|
// resolving the component theme object
|
|
16
|
+
interface TokensAndComponents {
|
|
17
|
+
components: Components;
|
|
18
|
+
tokens: StrictTokens;
|
|
19
|
+
}
|
|
20
|
+
|
|
18
21
|
const setupComponents = ({
|
|
19
22
|
components,
|
|
20
23
|
tokens,
|
|
21
|
-
}: {
|
|
22
|
-
components: Components;
|
|
23
|
-
tokens: StrictTokens;
|
|
24
|
-
}) => {
|
|
24
|
+
}: TokensAndComponents): Components => {
|
|
25
25
|
const output = components
|
|
26
26
|
? Object.entries(components).reduce(
|
|
27
27
|
(acc, [key, value]) => ({
|
|
@@ -32,7 +32,7 @@ const setupComponents = ({
|
|
|
32
32
|
)
|
|
33
33
|
: {};
|
|
34
34
|
|
|
35
|
-
return resolveObject({
|
|
35
|
+
return resolveObject<TokensAndComponents>({
|
|
36
36
|
...tokens,
|
|
37
37
|
components: output,
|
|
38
38
|
}).components;
|
|
@@ -103,12 +103,7 @@ export const createTheme = (
|
|
|
103
103
|
): StrictTheme => {
|
|
104
104
|
// merge custom `theme` param and `StrictTheme` to get the merged theme.
|
|
105
105
|
// `deepExtend` is a Style Dictionary method that performs a deep merge on n objects.
|
|
106
|
-
const mergedTheme = deepExtend([
|
|
107
|
-
{},
|
|
108
|
-
defaultTheme,
|
|
109
|
-
theme,
|
|
110
|
-
// cast to `StrictTheme` as `deepExtend` returns a generic object
|
|
111
|
-
]) as StrictTheme;
|
|
106
|
+
const mergedTheme = deepExtend<StrictTheme>([{}, defaultTheme, theme]);
|
|
112
107
|
|
|
113
108
|
let { tokens: mergedTokens } = mergedTheme;
|
|
114
109
|
const { spaceModifier = 1 } = mergedTheme;
|
|
@@ -119,11 +114,11 @@ export const createTheme = (
|
|
|
119
114
|
if (theme?.overrides?.length) {
|
|
120
115
|
theme.overrides.forEach((override) => {
|
|
121
116
|
if (override?.colorMode === colorMode) {
|
|
122
|
-
mergedTokens = deepExtend([
|
|
117
|
+
mergedTokens = deepExtend<StrictTheme['tokens']>([
|
|
123
118
|
{},
|
|
124
119
|
mergedTokens,
|
|
125
120
|
override.tokens,
|
|
126
|
-
])
|
|
121
|
+
]);
|
|
127
122
|
}
|
|
128
123
|
// more overrides in the future could happen here
|
|
129
124
|
});
|
|
@@ -132,13 +127,13 @@ export const createTheme = (
|
|
|
132
127
|
// Setup the tokens:
|
|
133
128
|
// - each token will have a raw value
|
|
134
129
|
// - references to tokens (strings wrapped in curly braces) are replaced by raw values
|
|
135
|
-
const tokens = resolveObject(
|
|
130
|
+
const tokens = resolveObject<StrictTheme['tokens']>(
|
|
136
131
|
setupTokens({
|
|
137
132
|
tokens: mergedTokens,
|
|
138
133
|
setupToken: ({ token, path }) => {
|
|
139
134
|
return setupToken({ token, path, spaceModifier });
|
|
140
135
|
},
|
|
141
|
-
})
|
|
136
|
+
})
|
|
142
137
|
);
|
|
143
138
|
|
|
144
139
|
let components;
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '2.2.
|
|
1
|
+
export const VERSION = '2.2.14';
|