@spectrum-web-components/theme 0.42.3 → 0.42.4
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 +39 -5
- package/spectrum-two/scale-large-core-tokens.d.ts +1 -0
- package/spectrum-two/scale-large-core-tokens.dev.js +6 -0
- package/spectrum-two/scale-large-core-tokens.dev.js.map +7 -0
- package/spectrum-two/scale-large-core-tokens.js +2 -0
- package/spectrum-two/scale-large-core-tokens.js.map +7 -0
- package/spectrum-two/scale-medium-core-tokens.d.ts +1 -0
- package/spectrum-two/scale-medium-core-tokens.dev.js +6 -0
- package/spectrum-two/scale-medium-core-tokens.dev.js.map +7 -0
- package/spectrum-two/scale-medium-core-tokens.js +2 -0
- package/spectrum-two/scale-medium-core-tokens.js.map +7 -0
- package/spectrum-two/theme-dark-core-tokens.d.ts +1 -0
- package/spectrum-two/theme-dark-core-tokens.dev.js +6 -0
- package/spectrum-two/theme-dark-core-tokens.dev.js.map +7 -0
- package/spectrum-two/theme-dark-core-tokens.js +2 -0
- package/spectrum-two/theme-dark-core-tokens.js.map +7 -0
- package/spectrum-two/theme-light-core-tokens.d.ts +1 -0
- package/spectrum-two/theme-light-core-tokens.dev.js +6 -0
- package/spectrum-two/theme-light-core-tokens.dev.js.map +7 -0
- package/spectrum-two/theme-light-core-tokens.js +2 -0
- package/spectrum-two/theme-light-core-tokens.js.map +7 -0
- package/src/Theme.d.ts +4 -4
- package/src/Theme.dev.js +44 -20
- package/src/Theme.dev.js.map +2 -2
- package/src/Theme.js +1 -1
- package/src/Theme.js.map +2 -2
- package/src/express/scale-large-core-tokens.css.dev.js +1 -1
- package/src/express/scale-large-core-tokens.css.dev.js.map +1 -1
- package/src/express/scale-large-core-tokens.css.js +1 -1
- package/src/express/scale-large-core-tokens.css.js.map +1 -1
- package/src/express/scale-large.css.dev.js +1 -1
- package/src/express/scale-large.css.dev.js.map +1 -1
- package/src/express/scale-large.css.js +1 -1
- package/src/express/scale-large.css.js.map +1 -1
- package/src/express/scale-medium-core-tokens.css.dev.js +1 -1
- package/src/express/scale-medium-core-tokens.css.dev.js.map +1 -1
- package/src/express/scale-medium-core-tokens.css.js +1 -1
- package/src/express/scale-medium-core-tokens.css.js.map +1 -1
- package/src/express/scale-medium.css.dev.js +1 -1
- package/src/express/scale-medium.css.dev.js.map +1 -1
- package/src/express/scale-medium.css.js +3 -3
- package/src/express/scale-medium.css.js.map +1 -1
- package/src/express/theme-core-tokens.css.dev.js +1 -1
- package/src/express/theme-core-tokens.css.dev.js.map +1 -1
- package/src/express/theme-core-tokens.css.js +1 -1
- package/src/express/theme-core-tokens.css.js.map +1 -1
- package/src/express/theme.css.dev.js +1 -1
- package/src/express/theme.css.dev.js.map +1 -1
- package/src/express/theme.css.js +1 -1
- package/src/express/theme.css.js.map +1 -1
- package/src/scale-large-core-tokens.css.dev.js +1 -1
- package/src/scale-large-core-tokens.css.dev.js.map +1 -1
- package/src/scale-large-core-tokens.css.js +1 -1
- package/src/scale-large-core-tokens.css.js.map +1 -1
- package/src/scale-large.css.dev.js +1 -1
- package/src/scale-large.css.dev.js.map +1 -1
- package/src/scale-large.css.js +1 -1
- package/src/scale-large.css.js.map +1 -1
- package/src/scale-medium-core-tokens.css.dev.js +1 -1
- package/src/scale-medium-core-tokens.css.dev.js.map +1 -1
- package/src/scale-medium-core-tokens.css.js +1 -1
- package/src/scale-medium-core-tokens.css.js.map +1 -1
- package/src/scale-medium.css.dev.js +1 -1
- package/src/scale-medium.css.dev.js.map +1 -1
- package/src/scale-medium.css.js +3 -3
- package/src/scale-medium.css.js.map +1 -1
- package/src/spectrum-two/core-tokens.d.ts +1 -0
- package/src/spectrum-two/core-tokens.dev.js +5 -0
- package/src/spectrum-two/core-tokens.dev.js.map +7 -0
- package/src/spectrum-two/core-tokens.js +2 -0
- package/src/spectrum-two/core-tokens.js.map +7 -0
- package/src/spectrum-two/core.d.ts +1 -0
- package/src/spectrum-two/core.dev.js +5 -0
- package/src/spectrum-two/core.dev.js.map +7 -0
- package/src/spectrum-two/core.js +2 -0
- package/src/spectrum-two/core.js.map +7 -0
- package/src/spectrum-two/scale-large-core-tokens.css.d.ts +2 -0
- package/src/spectrum-two/scale-large-core-tokens.css.dev.js +7 -0
- package/src/spectrum-two/scale-large-core-tokens.css.dev.js.map +7 -0
- package/src/spectrum-two/scale-large-core-tokens.css.js +4 -0
- package/src/spectrum-two/scale-large-core-tokens.css.js.map +7 -0
- package/src/spectrum-two/scale-medium-core-tokens.css.d.ts +2 -0
- package/src/spectrum-two/scale-medium-core-tokens.css.dev.js +7 -0
- package/src/spectrum-two/scale-medium-core-tokens.css.dev.js.map +7 -0
- package/src/spectrum-two/scale-medium-core-tokens.css.js +4 -0
- package/src/spectrum-two/scale-medium-core-tokens.css.js.map +7 -0
- package/src/spectrum-two/theme-core-tokens.css.d.ts +2 -0
- package/src/spectrum-two/theme-core-tokens.css.dev.js +18 -0
- package/src/spectrum-two/theme-core-tokens.css.dev.js.map +7 -0
- package/src/spectrum-two/theme-core-tokens.css.js +15 -0
- package/src/spectrum-two/theme-core-tokens.css.js.map +7 -0
- package/src/spectrum-two/theme-dark-core-tokens.css.d.ts +2 -0
- package/src/spectrum-two/theme-dark-core-tokens.css.dev.js +7 -0
- package/src/spectrum-two/theme-dark-core-tokens.css.dev.js.map +7 -0
- package/src/spectrum-two/theme-dark-core-tokens.css.js +4 -0
- package/src/spectrum-two/theme-dark-core-tokens.css.js.map +7 -0
- package/src/spectrum-two/theme-light-core-tokens.css.d.ts +2 -0
- package/src/spectrum-two/theme-light-core-tokens.css.dev.js +7 -0
- package/src/spectrum-two/theme-light-core-tokens.css.dev.js.map +7 -0
- package/src/spectrum-two/theme-light-core-tokens.css.js +4 -0
- package/src/spectrum-two/theme-light-core-tokens.css.js.map +7 -0
- package/src/spectrum-two/theme.css.d.ts +2 -0
- package/src/spectrum-two/theme.css.dev.js +18 -0
- package/src/spectrum-two/theme.css.dev.js.map +7 -0
- package/src/spectrum-two/theme.css.js +15 -0
- package/src/spectrum-two/theme.css.js.map +7 -0
- package/src/spectrum-two/themes-core-tokens.d.ts +4 -0
- package/src/spectrum-two/themes-core-tokens.dev.js +6 -0
- package/src/spectrum-two/themes-core-tokens.dev.js.map +7 -0
- package/src/spectrum-two/themes-core-tokens.js +2 -0
- package/src/spectrum-two/themes-core-tokens.js.map +7 -0
- package/src/theme-core-tokens.css.dev.js +1 -1
- package/src/theme-core-tokens.css.dev.js.map +1 -1
- package/src/theme-core-tokens.css.js +1 -1
- package/src/theme-core-tokens.css.js.map +1 -1
- package/src/theme.css.dev.js +1 -1
- package/src/theme.css.dev.js.map +1 -1
- package/src/theme.css.js +1 -1
- package/src/theme.css.js.map +1 -1
- package/src/typography.css.dev.js +1 -1
- package/src/typography.css.dev.js.map +1 -1
- package/src/typography.css.js +1 -1
- package/src/typography.css.js.map +1 -1
- package/test/theme-devmode.test.js +43 -20
- package/test/theme-devmode.test.js.map +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/theme",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -104,6 +104,22 @@
|
|
|
104
104
|
"development": "./express/theme-lightest.dev.js",
|
|
105
105
|
"default": "./express/theme-lightest.js"
|
|
106
106
|
},
|
|
107
|
+
"./spectrum-two/scale-large-core-tokens.js": {
|
|
108
|
+
"development": "./spectrum-two/scale-large-core-tokens.dev.js",
|
|
109
|
+
"default": "./spectrum-two/scale-large-core-tokens.js"
|
|
110
|
+
},
|
|
111
|
+
"./spectrum-two/scale-medium-core-tokens.js": {
|
|
112
|
+
"development": "./spectrum-two/scale-medium-core-tokens.dev.js",
|
|
113
|
+
"default": "./spectrum-two/scale-medium-core-tokens.js"
|
|
114
|
+
},
|
|
115
|
+
"./spectrum-two/theme-dark-core-tokens.js": {
|
|
116
|
+
"development": "./spectrum-two/theme-dark-core-tokens.dev.js",
|
|
117
|
+
"default": "./spectrum-two/theme-dark-core-tokens.js"
|
|
118
|
+
},
|
|
119
|
+
"./spectrum-two/theme-light-core-tokens.js": {
|
|
120
|
+
"development": "./spectrum-two/theme-light-core-tokens.dev.js",
|
|
121
|
+
"default": "./spectrum-two/theme-light-core-tokens.js"
|
|
122
|
+
},
|
|
107
123
|
"./src/express/core-tokens.js": {
|
|
108
124
|
"development": "./src/express/core-tokens.dev.js",
|
|
109
125
|
"default": "./src/express/core-tokens.js"
|
|
@@ -130,6 +146,18 @@
|
|
|
130
146
|
"development": "./src/express/themes.dev.js",
|
|
131
147
|
"default": "./src/express/themes.js"
|
|
132
148
|
},
|
|
149
|
+
"./src/spectrum-two/core-tokens.js": {
|
|
150
|
+
"development": "./src/spectrum-two/core-tokens.dev.js",
|
|
151
|
+
"default": "./src/spectrum-two/core-tokens.js"
|
|
152
|
+
},
|
|
153
|
+
"./src/spectrum-two/core.js": {
|
|
154
|
+
"development": "./src/spectrum-two/core.dev.js",
|
|
155
|
+
"default": "./src/spectrum-two/core.js"
|
|
156
|
+
},
|
|
157
|
+
"./src/spectrum-two/themes-core-tokens.js": {
|
|
158
|
+
"development": "./src/spectrum-two/themes-core-tokens.dev.js",
|
|
159
|
+
"default": "./src/spectrum-two/themes-core-tokens.js"
|
|
160
|
+
},
|
|
133
161
|
"./core.js": {
|
|
134
162
|
"development": "./core.dev.js",
|
|
135
163
|
"default": "./core.js"
|
|
@@ -205,8 +233,8 @@
|
|
|
205
233
|
"lit-html"
|
|
206
234
|
],
|
|
207
235
|
"dependencies": {
|
|
208
|
-
"@spectrum-web-components/base": "^0.42.
|
|
209
|
-
"@spectrum-web-components/styles": "^0.42.
|
|
236
|
+
"@spectrum-web-components/base": "^0.42.4",
|
|
237
|
+
"@spectrum-web-components/styles": "^0.42.4"
|
|
210
238
|
},
|
|
211
239
|
"types": "./src/index.d.ts",
|
|
212
240
|
"customElements": "custom-elements.json",
|
|
@@ -218,6 +246,8 @@
|
|
|
218
246
|
"./core-*.js",
|
|
219
247
|
"./theme-*.js",
|
|
220
248
|
"./scale-*.js",
|
|
249
|
+
"./spectrum-two/theme-*.js",
|
|
250
|
+
"./spectrum-two/scale-*.js",
|
|
221
251
|
"./express/theme-*.js",
|
|
222
252
|
"./express/scale-*.js",
|
|
223
253
|
"./src/themes.js",
|
|
@@ -225,7 +255,11 @@
|
|
|
225
255
|
"./src/express/core.js",
|
|
226
256
|
"./src/express/core-*.js",
|
|
227
257
|
"./src/express/themes.js",
|
|
228
|
-
"./src/express/themes-*.js"
|
|
258
|
+
"./src/express/themes-*.js",
|
|
259
|
+
"./src/spectrum-two/core.js",
|
|
260
|
+
"./src/spectrum-two/core-*.js",
|
|
261
|
+
"./src/spectrum-two/themes.js",
|
|
262
|
+
"./src/spectrum-two/themes-*.js"
|
|
229
263
|
],
|
|
230
|
-
"gitHead": "
|
|
264
|
+
"gitHead": "4924ffd06681ced537edaed873a9ce8b42cf155c"
|
|
231
265
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../src/spectrum-two/core-tokens.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import largeStyles from "../src/spectrum-two/scale-large-core-tokens.css.js";
|
|
3
|
+
import { Theme } from "../src/Theme.dev.js";
|
|
4
|
+
import "../src/spectrum-two/core-tokens.dev.js";
|
|
5
|
+
Theme.registerThemeFragment("large-spectrum-two", "scale", largeStyles);
|
|
6
|
+
//# sourceMappingURL=scale-large-core-tokens.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["scale-large-core-tokens.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport largeStyles from '../src/spectrum-two/scale-large-core-tokens.css.js';\nimport { Theme } from '../src/Theme.dev.js'\nimport '../src/spectrum-two/core-tokens.dev.js'\n\nTheme.registerThemeFragment('large-spectrum-two', 'scale', largeStyles);\n"],
|
|
5
|
+
"mappings": ";AAYA,OAAO,iBAAiB;AACxB,SAAS,aAAa;AACtB,OAAO;AAEP,MAAM,sBAAsB,sBAAsB,SAAS,WAAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["scale-large-core-tokens.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport largeStyles from '../src/spectrum-two/scale-large-core-tokens.css.js';\nimport { Theme } from '../src/Theme.js';\nimport '../src/spectrum-two/core-tokens.js';\n\nTheme.registerThemeFragment('large-spectrum-two', 'scale', largeStyles);\n"],
|
|
5
|
+
"mappings": "aAYA,OAAOA,MAAiB,qDACxB,OAAS,SAAAC,MAAa,kBACtB,MAAO,qCAEPA,EAAM,sBAAsB,qBAAsB,QAASD,CAAW",
|
|
6
|
+
"names": ["largeStyles", "Theme"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../src/spectrum-two/core-tokens.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import mediumStyles from "../src/spectrum-two/scale-medium-core-tokens.css.js";
|
|
3
|
+
import { Theme } from "../src/Theme.dev.js";
|
|
4
|
+
import "../src/spectrum-two/core-tokens.dev.js";
|
|
5
|
+
Theme.registerThemeFragment("medium-spectrum-two", "scale", mediumStyles);
|
|
6
|
+
//# sourceMappingURL=scale-medium-core-tokens.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["scale-medium-core-tokens.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport mediumStyles from '../src/spectrum-two/scale-medium-core-tokens.css.js';\nimport { Theme } from '../src/Theme.dev.js'\nimport '../src/spectrum-two/core-tokens.dev.js'\n\nTheme.registerThemeFragment('medium-spectrum-two', 'scale', mediumStyles);\n"],
|
|
5
|
+
"mappings": ";AAYA,OAAO,kBAAkB;AACzB,SAAS,aAAa;AACtB,OAAO;AAEP,MAAM,sBAAsB,uBAAuB,SAAS,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["scale-medium-core-tokens.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport mediumStyles from '../src/spectrum-two/scale-medium-core-tokens.css.js';\nimport { Theme } from '../src/Theme.js';\nimport '../src/spectrum-two/core-tokens.js';\n\nTheme.registerThemeFragment('medium-spectrum-two', 'scale', mediumStyles);\n"],
|
|
5
|
+
"mappings": "aAYA,OAAOA,MAAkB,sDACzB,OAAS,SAAAC,MAAa,kBACtB,MAAO,qCAEPA,EAAM,sBAAsB,sBAAuB,QAASD,CAAY",
|
|
6
|
+
"names": ["mediumStyles", "Theme"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../src/spectrum-two/core-tokens.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import darkStyles from "../src/spectrum-two/theme-dark-core-tokens.css.js";
|
|
3
|
+
import { Theme } from "../src/Theme.dev.js";
|
|
4
|
+
import "../src/spectrum-two/core-tokens.dev.js";
|
|
5
|
+
Theme.registerThemeFragment("dark-spectrum-two", "color", darkStyles);
|
|
6
|
+
//# sourceMappingURL=theme-dark-core-tokens.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["theme-dark-core-tokens.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport darkStyles from '../src/spectrum-two/theme-dark-core-tokens.css.js';\nimport { Theme } from '../src/Theme.dev.js'\nimport '../src/spectrum-two/core-tokens.dev.js'\n\nTheme.registerThemeFragment('dark-spectrum-two', 'color', darkStyles);\n"],
|
|
5
|
+
"mappings": ";AAYA,OAAO,gBAAgB;AACvB,SAAS,aAAa;AACtB,OAAO;AAEP,MAAM,sBAAsB,qBAAqB,SAAS,UAAU;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["theme-dark-core-tokens.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport darkStyles from '../src/spectrum-two/theme-dark-core-tokens.css.js';\nimport { Theme } from '../src/Theme.js';\nimport '../src/spectrum-two/core-tokens.js';\n\nTheme.registerThemeFragment('dark-spectrum-two', 'color', darkStyles);\n"],
|
|
5
|
+
"mappings": "aAYA,OAAOA,MAAgB,oDACvB,OAAS,SAAAC,MAAa,kBACtB,MAAO,qCAEPA,EAAM,sBAAsB,oBAAqB,QAASD,CAAU",
|
|
6
|
+
"names": ["darkStyles", "Theme"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../src/spectrum-two/core-tokens.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import lightStyles from "../src/spectrum-two/theme-light-core-tokens.css.js";
|
|
3
|
+
import { Theme } from "../src/Theme.dev.js";
|
|
4
|
+
import "../src/spectrum-two/core-tokens.dev.js";
|
|
5
|
+
Theme.registerThemeFragment("light-spectrum-two", "color", lightStyles);
|
|
6
|
+
//# sourceMappingURL=theme-light-core-tokens.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["theme-light-core-tokens.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport lightStyles from '../src/spectrum-two/theme-light-core-tokens.css.js';\nimport { Theme } from '../src/Theme.dev.js'\nimport '../src/spectrum-two/core-tokens.dev.js'\n\nTheme.registerThemeFragment('light-spectrum-two', 'color', lightStyles);\n"],
|
|
5
|
+
"mappings": ";AAYA,OAAO,iBAAiB;AACxB,SAAS,aAAa;AACtB,OAAO;AAEP,MAAM,sBAAsB,sBAAsB,SAAS,WAAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["theme-light-core-tokens.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport lightStyles from '../src/spectrum-two/theme-light-core-tokens.css.js';\nimport { Theme } from '../src/Theme.js';\nimport '../src/spectrum-two/core-tokens.js';\n\nTheme.registerThemeFragment('light-spectrum-two', 'color', lightStyles);\n"],
|
|
5
|
+
"mappings": "aAYA,OAAOA,MAAiB,qDACxB,OAAS,SAAAC,MAAa,kBACtB,MAAO,qCAEPA,EAAM,sBAAsB,qBAAsB,QAASD,CAAW",
|
|
6
|
+
"names": ["lightStyles", "Theme"]
|
|
7
|
+
}
|
package/src/Theme.d.ts
CHANGED
|
@@ -21,10 +21,10 @@ type FragmentMap = Map<string, {
|
|
|
21
21
|
styles: CSSResultGroup;
|
|
22
22
|
}>;
|
|
23
23
|
export type ThemeFragmentMap = Map<FragmentType, FragmentMap>;
|
|
24
|
-
export type Color = 'light' | 'lightest' | 'dark' | 'darkest' | 'light-express' | 'lightest-express' | 'dark-express' | 'darkest-express';
|
|
25
|
-
export type
|
|
26
|
-
export type
|
|
27
|
-
export type
|
|
24
|
+
export type Color = 'light' | 'lightest' | 'dark' | 'darkest' | 'light-express' | 'lightest-express' | 'dark-express' | 'darkest-express' | 'light-spectrum-two' | 'dark-spectrum-two';
|
|
25
|
+
export type ThemeVariant = 'spectrum' | 'express' | 'spectrum-two';
|
|
26
|
+
export type SystemVariant = 'spectrum' | 'express' | 'spectrum-two';
|
|
27
|
+
export type Scale = 'medium' | 'large' | 'medium-express' | 'large-express' | 'medium-spectrum-two' | 'large-spectrum-two';
|
|
28
28
|
type FragmentName = Color | Scale | ThemeVariant | SystemVariant | 'core' | 'app';
|
|
29
29
|
export interface ThemeData {
|
|
30
30
|
color?: Color;
|
package/src/Theme.dev.js
CHANGED
|
@@ -3,8 +3,15 @@ import {
|
|
|
3
3
|
supportsAdoptingStyleSheets
|
|
4
4
|
} from "@spectrum-web-components/base";
|
|
5
5
|
import { version } from "@spectrum-web-components/base/src/version.js";
|
|
6
|
-
const SystemVariantValues = ["spectrum", "express"];
|
|
7
|
-
const ScaleValues = [
|
|
6
|
+
const SystemVariantValues = ["spectrum", "express", "spectrum-two"];
|
|
7
|
+
const ScaleValues = [
|
|
8
|
+
"medium",
|
|
9
|
+
"large",
|
|
10
|
+
"medium-express",
|
|
11
|
+
"large-express",
|
|
12
|
+
"medium-spectrum-two",
|
|
13
|
+
"large-spectrum-two"
|
|
14
|
+
];
|
|
8
15
|
const ColorValues = [
|
|
9
16
|
"light",
|
|
10
17
|
"lightest",
|
|
@@ -13,7 +20,9 @@ const ColorValues = [
|
|
|
13
20
|
"light-express",
|
|
14
21
|
"lightest-express",
|
|
15
22
|
"dark-express",
|
|
16
|
-
"darkest-express"
|
|
23
|
+
"darkest-express",
|
|
24
|
+
"light-spectrum-two",
|
|
25
|
+
"dark-spectrum-two"
|
|
17
26
|
];
|
|
18
27
|
const _Theme = class _Theme extends HTMLElement {
|
|
19
28
|
constructor() {
|
|
@@ -51,8 +60,7 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
51
60
|
];
|
|
52
61
|
}
|
|
53
62
|
set dir(dir) {
|
|
54
|
-
if (dir === this.dir)
|
|
55
|
-
return;
|
|
63
|
+
if (dir === this.dir) return;
|
|
56
64
|
this.setAttribute("dir", dir);
|
|
57
65
|
this._dir = dir;
|
|
58
66
|
const targetDir = dir === "rtl" ? dir : "ltr";
|
|
@@ -81,14 +89,34 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
81
89
|
this._provideContext();
|
|
82
90
|
} else if (attrName === "theme") {
|
|
83
91
|
this.theme = value;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
if (true) {
|
|
93
|
+
window.__swc.warn(
|
|
94
|
+
this,
|
|
95
|
+
'property theme in <sp-theme> has been deprecated. Please use system instead like this <sp-theme system="spectrum"/>',
|
|
96
|
+
"https://opensource.adobe.com/spectrum-web-components/tools/themes/#deprecation",
|
|
97
|
+
{ level: "deprecation" }
|
|
98
|
+
);
|
|
99
|
+
if (value === "spectrum-two") {
|
|
100
|
+
window.__swc.warn(
|
|
101
|
+
this,
|
|
102
|
+
"You are currently using the beta version of Spectrum Two theme. Consumption of this system may be subject to unexpected changes before the 1.0 release of SWC.",
|
|
103
|
+
"https://s2.spectrum.adobe.com/",
|
|
104
|
+
{ level: "high" }
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
90
108
|
} else if (attrName === "system") {
|
|
91
109
|
this.system = value;
|
|
110
|
+
if (true) {
|
|
111
|
+
if (value === "spectrum-two") {
|
|
112
|
+
window.__swc.warn(
|
|
113
|
+
this,
|
|
114
|
+
"You are currently using the beta version of Spectrum Two theme. Consumption of this system may be subject to unexpected changes before the 1.0 release of SWC.",
|
|
115
|
+
"https://s2.spectrum.adobe.com/",
|
|
116
|
+
{ level: "high" }
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
92
120
|
} else if (attrName === "dir") {
|
|
93
121
|
this.dir = value;
|
|
94
122
|
}
|
|
@@ -113,8 +141,7 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
113
141
|
return this._system || name || "";
|
|
114
142
|
}
|
|
115
143
|
set system(newValue) {
|
|
116
|
-
if (newValue === this._system)
|
|
117
|
-
return;
|
|
144
|
+
if (newValue === this._system) return;
|
|
118
145
|
const system = !!newValue && SystemVariantValues.includes(newValue) ? newValue : this.system;
|
|
119
146
|
if (system !== this._system) {
|
|
120
147
|
this._system = system;
|
|
@@ -155,8 +182,7 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
155
182
|
return this._color || name || "";
|
|
156
183
|
}
|
|
157
184
|
set color(newValue) {
|
|
158
|
-
if (newValue === this._color)
|
|
159
|
-
return;
|
|
185
|
+
if (newValue === this._color) return;
|
|
160
186
|
const color = !!newValue && ColorValues.includes(newValue) ? newValue : this.color;
|
|
161
187
|
if (color !== this._color) {
|
|
162
188
|
this._color = color;
|
|
@@ -181,8 +207,7 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
181
207
|
return this._scale || name || "";
|
|
182
208
|
}
|
|
183
209
|
set scale(newValue) {
|
|
184
|
-
if (newValue === this._scale)
|
|
185
|
-
return;
|
|
210
|
+
if (newValue === this._scale) return;
|
|
186
211
|
const scale = !!newValue && ScaleValues.includes(newValue) ? newValue : this.scale;
|
|
187
212
|
if (scale !== this._scale) {
|
|
188
213
|
this._scale = scale;
|
|
@@ -199,7 +224,7 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
199
224
|
..._Theme.themeFragmentsByKind.keys()
|
|
200
225
|
];
|
|
201
226
|
const getStyle = (fragments, name, kind) => {
|
|
202
|
-
const currentStyles = kind && kind !== "theme" && kind !== "system" && this.theme
|
|
227
|
+
const currentStyles = kind && kind !== "theme" && kind !== "system" && this.theme !== "spectrum" && this.system !== "spectrum" ? fragments.get(`${name}-${this.system}`) : fragments.get(name);
|
|
203
228
|
const isAppliedFragment = name === "spectrum" || !kind || this.hasAttribute(kind);
|
|
204
229
|
if (currentStyles && isAppliedFragment) {
|
|
205
230
|
return currentStyles.styles;
|
|
@@ -337,8 +362,7 @@ const _Theme = class _Theme extends HTMLElement {
|
|
|
337
362
|
const fragmentCSS = [];
|
|
338
363
|
for (const [kind, fragments] of _Theme.themeFragmentsByKind) {
|
|
339
364
|
for (const [name, { styles: styles2 }] of fragments) {
|
|
340
|
-
if (name === "default")
|
|
341
|
-
continue;
|
|
365
|
+
if (name === "default") continue;
|
|
342
366
|
let cssText = styles2.cssText;
|
|
343
367
|
if (!_Theme.defaultFragments.has(name)) {
|
|
344
368
|
cssText = cssText.replace(
|
package/src/Theme.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Theme.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResult,\n CSSResultGroup,\n supportsAdoptingStyleSheets,\n} from '@spectrum-web-components/base';\nimport { version } from '@spectrum-web-components/base/src/version.js';\n\ndeclare global {\n interface Window {\n ShadyCSS: {\n nativeShadow: boolean;\n prepareTemplate(\n template: HTMLTemplateElement,\n elementName: string,\n typeExtension?: string\n ): void;\n styleElement(host: HTMLElement): void;\n ScopingShim: {\n prepareAdoptedCssText(\n cssTextArray: string[],\n elementName: string\n ): void;\n };\n };\n }\n}\n\ntype ShadowRootWithAdoptedStyleSheets = HTMLElement['shadowRoot'] & {\n adoptedStyleSheets?: CSSStyleSheet[];\n};\n\ntype FragmentType = 'color' | 'scale' | 'system' | 'theme' | 'core' | 'app';\ntype SettableFragmentTypes = 'color' | 'scale' | 'system' | 'theme';\ntype FragmentMap = Map<string, { name: string; styles: CSSResultGroup }>;\nexport type ThemeFragmentMap = Map<FragmentType, FragmentMap>;\nexport type Color =\n | 'light'\n | 'lightest'\n | 'dark'\n | 'darkest'\n | 'light-express'\n | 'lightest-express'\n | 'dark-express'\n | 'darkest-express';\nexport type Scale = 'medium' | 'large' | 'medium-express' | 'large-express';\nexport type ThemeVariant = 'spectrum' | 'express';\nexport type SystemVariant = 'spectrum' | 'express';\nconst SystemVariantValues = ['spectrum', 'express'];\nconst ScaleValues = ['medium', 'large', 'medium-express', 'large-express'];\nconst ColorValues = [\n 'light',\n 'lightest',\n 'dark',\n 'darkest',\n 'light-express',\n 'lightest-express',\n 'dark-express',\n 'darkest-express',\n];\ntype FragmentName =\n | Color\n | Scale\n | ThemeVariant\n | SystemVariant\n | 'core'\n | 'app';\n\nexport interface ThemeData {\n color?: Color;\n scale?: Scale;\n lang?: string;\n theme?: SystemVariant;\n system?: SystemVariant;\n}\n\ntype ThemeKindProvider = {\n [P in SettableFragmentTypes]:\n | ThemeVariant\n | SystemVariant\n | Color\n | Scale\n | '';\n};\n\nexport interface ProvideLang {\n callback: (lang: string, unsubscribe: () => void) => void;\n}\n\n/**\n * @element sp-theme\n * @attr {string} [lang=\"\"] - The language of the content scoped to this `sp-theme` element, see: <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang\" target=\"_blank\">MDN reference</a>.\n *\n * @slot - Content on which to apply the CSS Custom Properties defined by the current theme configuration\n */\nexport class Theme extends HTMLElement implements ThemeKindProvider {\n private static themeFragmentsByKind: ThemeFragmentMap = new Map();\n private static defaultFragments: Set<FragmentName> = new Set(['spectrum']);\n private static templateElement?: HTMLTemplateElement;\n private static instances: Set<Theme> = new Set();\n static VERSION = version;\n\n static get observedAttributes(): string[] {\n return [\n 'color',\n 'scale',\n 'lang',\n 'dir',\n 'system',\n /* deprecated attributes, but still observing */\n 'theme',\n ];\n }\n\n _dir: 'ltr' | 'rtl' | '' = '';\n\n override set dir(dir: 'ltr' | 'rtl' | '') {\n if (dir === this.dir) return;\n this.setAttribute('dir', dir);\n this._dir = dir;\n const targetDir = dir === 'rtl' ? dir : 'ltr';\n /* c8 ignore next 3 */\n this.trackedChildren.forEach((el) => {\n el.setAttribute('dir', targetDir);\n });\n }\n\n /**\n * Reading direction of the content scoped to this `sp-theme` element.\n * @type {\"ltr\" | \"rtl\" | \"\"}\n * @attr\n */\n override get dir(): 'ltr' | 'rtl' | '' {\n return this._dir;\n }\n\n protected attributeChangedCallback(\n attrName: SettableFragmentTypes | 'lang' | 'dir',\n old: string | null,\n value: string | null\n ): void {\n if (old === value) {\n return;\n }\n if (attrName === 'color') {\n this.color = value as Color;\n } else if (attrName === 'scale') {\n this.scale = value as Scale;\n /* c8 ignore next 3 */\n } else if (attrName === 'lang' && !!value) {\n this.lang = value;\n this._provideContext();\n } else if (attrName === 'theme') {\n this.theme = value as SystemVariant;\n window.__swc.warn(\n this,\n 'property theme in <sp-theme> has been deprecated. Please use system instead like this <sp-theme system=\"spectrum\"/>',\n 'https://opensource.adobe.com/spectrum-web-components/tools/themes/#deprecation',\n { level: 'deprecation' }\n );\n } else if (attrName === 'system') {\n this.system = value as SystemVariant;\n } else if (attrName === 'dir') {\n this.dir = value as 'ltr' | 'rtl' | '';\n }\n }\n\n private requestUpdate(): void {\n /* c8 ignore next 3 */\n if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {\n window.ShadyCSS.styleElement(this);\n } else {\n this.shouldAdoptStyles();\n }\n }\n\n public override shadowRoot!: ShadowRootWithAdoptedStyleSheets;\n\n private _system: SystemVariant | '' = 'spectrum';\n /**\n * The Spectrum system that is applied to the content scoped to this `sp-theme` element.\n *\n * A value is requried.\n * @type {\"spectrum\" | \"express\" }\n * @attr\n */\n get system(): SystemVariant | '' {\n const systemFragments = Theme.themeFragmentsByKind.get('system');\n const { name } =\n (systemFragments && systemFragments.get('default')) || {};\n return this._system || (name as SystemVariant) || '';\n }\n\n set system(newValue: SystemVariant | '') {\n if (newValue === this._system) return;\n const system =\n !!newValue && SystemVariantValues.includes(newValue)\n ? newValue\n : this.system;\n if (system !== this._system) {\n this._system = system;\n this.requestUpdate();\n }\n if (system) {\n this.setAttribute('system', system);\n /* c8 ignore next 3 */\n } else {\n this.removeAttribute('system');\n }\n }\n\n /*\n * @deprecated The `theme` attribute has been deprecated in favor of the `system` attribute.\n */\n get theme(): SystemVariant | '' {\n if (!this.system) {\n this.removeAttribute('system');\n }\n return this.system;\n }\n\n /*\n * @deprecated The `theme` attribute has been deprecated in favor of the `system` attribute.\n */\n set theme(newValue: SystemVariant | '') {\n this.system = newValue;\n this.requestUpdate();\n }\n\n private _color: Color | '' = '';\n\n /**\n * The Spectrum color stops to apply to content scoped by this `sp-theme` element.\n *\n * A value is requried.\n * @type {\"lightest\" | \"light\" | \"dark\" | \"darkest\" | \"\"}\n * @attr\n */\n get color(): Color | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('color');\n const { name } =\n (themeFragments && themeFragments.get('default')) || {};\n return this._color || (name as Color) || '';\n }\n\n set color(newValue: Color | '') {\n if (newValue === this._color) return;\n const color =\n !!newValue && ColorValues.includes(newValue)\n ? newValue\n : this.color;\n if (color !== this._color) {\n this._color = color;\n this.requestUpdate();\n }\n if (color) {\n this.setAttribute('color', color);\n /* c8 ignore next 3 */\n } else {\n this.removeAttribute('color');\n }\n }\n\n private _scale: Scale | '' = '';\n\n /**\n * The Spectrum platform scale to apply to content scoped by this `sp-theme` element.\n *\n * A value is requried.\n * @type {\"medium\" | \"large\" | \"\"}\n * @attr\n */\n get scale(): Scale | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('scale');\n const { name } =\n (themeFragments && themeFragments.get('default')) || {};\n return this._scale || (name as Scale) || '';\n }\n\n set scale(newValue: Scale | '') {\n if (newValue === this._scale) return;\n const scale =\n !!newValue && ScaleValues.includes(newValue)\n ? newValue\n : this.scale;\n if (scale !== this._scale) {\n this._scale = scale;\n this.requestUpdate();\n }\n if (scale) {\n this.setAttribute('scale', scale);\n /* c8 ignore next 3 */\n } else {\n this.removeAttribute('scale');\n }\n }\n\n private get styles(): CSSResultGroup[] {\n const themeKinds: FragmentType[] = [\n ...Theme.themeFragmentsByKind.keys(),\n ];\n const getStyle = (\n fragments: FragmentMap,\n name: FragmentName,\n kind?: FragmentType\n ): CSSResultGroup | undefined => {\n const currentStyles =\n kind &&\n kind !== 'theme' &&\n kind !== 'system' &&\n this.theme === 'express' &&\n this.system === 'express'\n ? fragments.get(`${name}-express`)\n : fragments.get(name);\n // theme=\"spectrum\" is available by default and doesn't need to be applied.\n const isAppliedFragment =\n name === 'spectrum' || !kind || this.hasAttribute(kind);\n if (currentStyles && isAppliedFragment) {\n return currentStyles.styles;\n }\n return;\n };\n const styles = themeKinds.reduce((acc, kind) => {\n const kindFragments = Theme.themeFragmentsByKind.get(\n kind\n ) as FragmentMap;\n let style: CSSResultGroup | undefined;\n if (kind === 'app' || kind === 'core') {\n style = getStyle(kindFragments, kind);\n } else {\n const { [kind]: name } = this;\n style = getStyle(kindFragments, <FragmentName>name, kind);\n }\n if (style) {\n acc.push(style);\n }\n return acc;\n }, [] as CSSResultGroup[]);\n if (window.__swc.DEBUG) {\n const issues: string[] = [];\n const checkForAttribute = (\n name: FragmentType,\n resolvedValue?: string,\n actualValue?: string\n ): void => {\n const systemModifier =\n this.system && this.system !== 'spectrum'\n ? `-${this.system}`\n : '';\n if (!resolvedValue) {\n issues.push(\n `You have not explicitly set the \"${name}\" attribute and there is no default value on which to fallback.`\n );\n } else if (!actualValue) {\n issues.push(\n `You have not explicitly set the \"${name}\" attribute, the default value (\"${resolvedValue}\") is being used as a fallback.`\n );\n } else if (\n !Theme.themeFragmentsByKind\n .get(name)\n ?.get(\n resolvedValue +\n (name === 'system' ? '' : systemModifier)\n )\n ) {\n issues.push(\n `You have set \"${name}='${resolvedValue}'\" but the associated system fragment has not been loaded.`\n );\n }\n };\n\n checkForAttribute('system', this.system, this._system);\n checkForAttribute('color', this.color, this._color);\n checkForAttribute('scale', this.scale, this._scale);\n\n // Check for deprecated attributes\n if (this.hasAttribute('theme')) {\n issues.push(\n `The \"theme\" attribute has been deprecated in favor of \"system\".`\n );\n }\n\n if (issues.length) {\n window.__swc.warn(\n this,\n 'You are leveraging an <sp-theme> element and the following issues may disrupt your theme delivery:',\n 'https://opensource.adobe.com/spectrum-web-components/components/theme/#example',\n {\n issues,\n }\n );\n }\n if (['lightest', 'darkest'].includes(this.color)) {\n window.__swc.warn(\n this,\n `Color lightest and darkest are deprecated and will be removed in a future release`,\n 'https://opensource.adobe.com/spectrum-web-components/tools/themes/#deprecation',\n { level: 'deprecation' }\n );\n }\n }\n return [...styles];\n }\n\n private static get template(): HTMLTemplateElement {\n if (!this.templateElement) {\n this.templateElement = document.createElement('template');\n this.templateElement.innerHTML = '<slot></slot>';\n }\n return this.templateElement;\n }\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n const node = document.importNode(Theme.template.content, true);\n this.shadowRoot.appendChild(node);\n this.shouldAdoptStyles();\n this.addEventListener(\n 'sp-query-theme',\n this.onQueryTheme as EventListener\n );\n this.addEventListener(\n 'sp-language-context',\n this._handleContextPresence as EventListener\n );\n this.updateComplete = this.__createDeferredPromise();\n }\n\n public updateComplete!: Promise<boolean>;\n private __resolve!: (compelted: boolean) => void;\n\n private __createDeferredPromise(): Promise<boolean> {\n return new Promise((resolve) => {\n this.__resolve = resolve;\n });\n }\n\n /* c8 ignore next 12 */\n private onQueryTheme(event: CustomEvent<ThemeData>): void {\n if (event.defaultPrevented) {\n return;\n }\n event.preventDefault();\n const { detail: theme } = event;\n theme.color = this.color || undefined;\n theme.scale = this.scale || undefined;\n theme.lang =\n this.lang || document.documentElement.lang || navigator.language;\n // `theme` is deprecated in favor of `system` but maintaining `theme` as a deprecated path.\n theme.theme = this.system || undefined;\n theme.system = this.system || undefined;\n }\n\n protected connectedCallback(): void {\n this.shouldAdoptStyles();\n // Note, first update/render handles styleElement so we only call this if\n // connected after first update.\n /* c8 ignore next 3 */\n if (window.ShadyCSS !== undefined) {\n window.ShadyCSS.styleElement(this);\n }\n // Add `this` to the instances array.\n Theme.instances.add(this);\n if (!this.hasAttribute('dir')) {\n let dirParent = ((this as HTMLElement).assignedSlot ||\n this.parentNode) as HTMLElement | DocumentFragment | ShadowRoot;\n while (\n dirParent !== document.documentElement &&\n !(dirParent instanceof Theme)\n ) {\n dirParent = ((dirParent as HTMLElement).assignedSlot || // step into the shadow DOM of the parent of a slotted node\n dirParent.parentNode || // DOM Element detected\n (dirParent as ShadowRoot).host) as\n | HTMLElement\n | DocumentFragment\n | ShadowRoot;\n }\n this.dir = dirParent.dir === 'rtl' ? dirParent.dir : 'ltr';\n }\n }\n\n protected disconnectedCallback(): void {\n // Remove `this` to the instances array.\n Theme.instances.delete(this);\n }\n\n public startManagingContentDirection(el: HTMLElement): void {\n this.trackedChildren.add(el);\n }\n\n public stopManagingContentDirection(el: HTMLElement): void {\n this.trackedChildren.delete(el);\n }\n\n private trackedChildren: Set<HTMLElement> = new Set();\n\n private _updateRequested = false;\n\n private async shouldAdoptStyles(): Promise<void> {\n if (!this._updateRequested) {\n this.updateComplete = this.__createDeferredPromise();\n this._updateRequested = true;\n this._updateRequested = await false;\n this.adoptStyles();\n this.__resolve(true);\n }\n }\n\n protected adoptStyles(): void {\n const styles = this.styles; // No test coverage on Edge\n\n // There are three separate cases here based on Shadow DOM support.\n // (1) shadowRoot polyfilled: use ShadyCSS\n // (2) shadowRoot.adoptedStyleSheets available: use it.\n // (3) shadowRoot.adoptedStyleSheets polyfilled: append styles after rendering\n /* c8 ignore next 28 */\n if (\n window.ShadyCSS !== undefined &&\n !window.ShadyCSS.nativeShadow &&\n window.ShadyCSS.ScopingShim\n ) {\n // For browsers using the shim, there seems to be one set of\n // processed styles per template, so it is hard to nest styles. So,\n // for those, we load in all style fragments and then switch using a\n // host selector (e.g. :host([color='dark']))\n const fragmentCSS: string[] = [];\n for (const [kind, fragments] of Theme.themeFragmentsByKind) {\n for (const [name, { styles }] of fragments) {\n if (name === 'default') continue;\n let cssText = (styles as CSSResult).cssText;\n if (!Theme.defaultFragments.has(name as FragmentName)) {\n cssText = cssText.replace(\n ':host',\n `:host([${kind}='${name}'])`\n );\n }\n fragmentCSS.push(cssText);\n }\n }\n window.ShadyCSS.ScopingShim.prepareAdoptedCssText(\n fragmentCSS,\n this.localName\n );\n window.ShadyCSS.prepareTemplate(Theme.template, this.localName);\n } else if (supportsAdoptingStyleSheets) {\n const styleSheets: CSSStyleSheet[] = [];\n for (const style of styles) {\n styleSheets.push(\n (style as CSSResult).styleSheet as CSSStyleSheet\n );\n }\n this.shadowRoot.adoptedStyleSheets = styleSheets;\n /* c8 ignore next 9 */\n } else {\n const styleNodes = this.shadowRoot.querySelectorAll('style');\n styleNodes.forEach((element) => element.remove());\n styles.forEach((s) => {\n const style = document.createElement('style');\n style.textContent = (s as CSSResult).cssText;\n this.shadowRoot.appendChild(style);\n });\n }\n }\n\n static registerThemeFragment(\n name: FragmentName,\n kind: FragmentType,\n styles: CSSResultGroup\n ): void {\n const fragmentMap = Theme.themeFragmentsByKind.get(kind) || new Map();\n if (fragmentMap.size === 0) {\n Theme.themeFragmentsByKind.set(kind, fragmentMap);\n // we're adding our first fragment for this kind, set as default\n fragmentMap.set('default', { name, styles });\n Theme.defaultFragments.add(name);\n }\n fragmentMap.set(name, { name, styles });\n Theme.instances.forEach((instance) => instance.shouldAdoptStyles());\n }\n\n private _contextConsumers = new Map<\n HTMLElement,\n [ProvideLang['callback'], () => void]\n >();\n\n /* c8 ignore next 5 */\n private _provideContext(): void {\n this._contextConsumers.forEach(([callback, unsubscribe]) =>\n callback(this.lang, unsubscribe)\n );\n }\n\n private _handleContextPresence(event: CustomEvent<ProvideLang>): void {\n event.stopPropagation();\n const target = event.composedPath()[0] as HTMLElement;\n /* c8 ignore next 3 */\n if (this._contextConsumers.has(target)) {\n return;\n }\n this._contextConsumers.set(target, [\n event.detail.callback,\n () => this._contextConsumers.delete(target),\n ]);\n const [callback, unsubscribe] =\n this._contextConsumers.get(target) || [];\n if (callback && unsubscribe) {\n callback(\n this.lang ||\n document.documentElement.lang ||\n navigator.language,\n unsubscribe\n );\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";AAYA;AAAA,EAGI;AAAA,OACG;AACP,SAAS,eAAe;
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResult,\n CSSResultGroup,\n supportsAdoptingStyleSheets,\n} from '@spectrum-web-components/base';\nimport { version } from '@spectrum-web-components/base/src/version.js';\n\ndeclare global {\n interface Window {\n ShadyCSS: {\n nativeShadow: boolean;\n prepareTemplate(\n template: HTMLTemplateElement,\n elementName: string,\n typeExtension?: string\n ): void;\n styleElement(host: HTMLElement): void;\n ScopingShim: {\n prepareAdoptedCssText(\n cssTextArray: string[],\n elementName: string\n ): void;\n };\n };\n }\n}\n\ntype ShadowRootWithAdoptedStyleSheets = HTMLElement['shadowRoot'] & {\n adoptedStyleSheets?: CSSStyleSheet[];\n};\n\ntype FragmentType = 'color' | 'scale' | 'system' | 'theme' | 'core' | 'app';\ntype SettableFragmentTypes = 'color' | 'scale' | 'system' | 'theme';\ntype FragmentMap = Map<string, { name: string; styles: CSSResultGroup }>;\nexport type ThemeFragmentMap = Map<FragmentType, FragmentMap>;\nexport type Color =\n | 'light'\n | 'lightest'\n | 'dark'\n | 'darkest'\n | 'light-express'\n | 'lightest-express'\n | 'dark-express'\n | 'darkest-express'\n | 'light-spectrum-two'\n | 'dark-spectrum-two';\nexport type ThemeVariant = 'spectrum' | 'express' | 'spectrum-two';\nexport type SystemVariant = 'spectrum' | 'express' | 'spectrum-two';\nconst SystemVariantValues = ['spectrum', 'express', 'spectrum-two'];\nexport type Scale =\n | 'medium'\n | 'large'\n | 'medium-express'\n | 'large-express'\n | 'medium-spectrum-two'\n | 'large-spectrum-two';\nconst ScaleValues = [\n 'medium',\n 'large',\n 'medium-express',\n 'large-express',\n 'medium-spectrum-two',\n 'large-spectrum-two',\n];\nconst ColorValues = [\n 'light',\n 'lightest',\n 'dark',\n 'darkest',\n 'light-express',\n 'lightest-express',\n 'dark-express',\n 'darkest-express',\n 'light-spectrum-two',\n 'dark-spectrum-two',\n];\ntype FragmentName =\n | Color\n | Scale\n | ThemeVariant\n | SystemVariant\n | 'core'\n | 'app';\n\nexport interface ThemeData {\n color?: Color;\n scale?: Scale;\n lang?: string;\n theme?: SystemVariant;\n system?: SystemVariant;\n}\n\ntype ThemeKindProvider = {\n [P in SettableFragmentTypes]:\n | ThemeVariant\n | SystemVariant\n | Color\n | Scale\n | '';\n};\n\nexport interface ProvideLang {\n callback: (lang: string, unsubscribe: () => void) => void;\n}\n\n/**\n * @element sp-theme\n * @attr {string} [lang=\"\"] - The language of the content scoped to this `sp-theme` element, see: <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang\" target=\"_blank\">MDN reference</a>.\n *\n * @slot - Content on which to apply the CSS Custom Properties defined by the current theme configuration\n */\nexport class Theme extends HTMLElement implements ThemeKindProvider {\n private static themeFragmentsByKind: ThemeFragmentMap = new Map();\n private static defaultFragments: Set<FragmentName> = new Set(['spectrum']);\n private static templateElement?: HTMLTemplateElement;\n private static instances: Set<Theme> = new Set();\n static VERSION = version;\n\n static get observedAttributes(): string[] {\n return [\n 'color',\n 'scale',\n 'lang',\n 'dir',\n 'system',\n /* deprecated attributes, but still observing */\n 'theme',\n ];\n }\n\n _dir: 'ltr' | 'rtl' | '' = '';\n\n override set dir(dir: 'ltr' | 'rtl' | '') {\n if (dir === this.dir) return;\n this.setAttribute('dir', dir);\n this._dir = dir;\n const targetDir = dir === 'rtl' ? dir : 'ltr';\n /* c8 ignore next 3 */\n this.trackedChildren.forEach((el) => {\n el.setAttribute('dir', targetDir);\n });\n }\n\n /**\n * Reading direction of the content scoped to this `sp-theme` element.\n * @type {\"ltr\" | \"rtl\" | \"\"}\n * @attr\n */\n override get dir(): 'ltr' | 'rtl' | '' {\n return this._dir;\n }\n\n protected attributeChangedCallback(\n attrName: SettableFragmentTypes | 'lang' | 'dir',\n old: string | null,\n value: string | null\n ): void {\n if (old === value) {\n return;\n }\n if (attrName === 'color') {\n this.color = value as Color;\n } else if (attrName === 'scale') {\n this.scale = value as Scale;\n /* c8 ignore next 3 */\n } else if (attrName === 'lang' && !!value) {\n this.lang = value;\n this._provideContext();\n } else if (attrName === 'theme') {\n this.theme = value as SystemVariant;\n if (window.__swc.DEBUG) {\n window.__swc.warn(\n this,\n 'property theme in <sp-theme> has been deprecated. Please use system instead like this <sp-theme system=\"spectrum\"/>',\n 'https://opensource.adobe.com/spectrum-web-components/tools/themes/#deprecation',\n { level: 'deprecation' }\n );\n if (value === 'spectrum-two') {\n window.__swc.warn(\n this,\n 'You are currently using the beta version of Spectrum Two theme. Consumption of this system may be subject to unexpected changes before the 1.0 release of SWC.',\n 'https://s2.spectrum.adobe.com/',\n { level: 'high' }\n );\n }\n }\n } else if (attrName === 'system') {\n this.system = value as SystemVariant;\n if (window.__swc.DEBUG) {\n if (value === 'spectrum-two') {\n window.__swc.warn(\n this,\n 'You are currently using the beta version of Spectrum Two theme. Consumption of this system may be subject to unexpected changes before the 1.0 release of SWC.',\n 'https://s2.spectrum.adobe.com/',\n { level: 'high' }\n );\n }\n }\n } else if (attrName === 'dir') {\n this.dir = value as 'ltr' | 'rtl' | '';\n }\n }\n\n private requestUpdate(): void {\n /* c8 ignore next 3 */\n if (window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow) {\n window.ShadyCSS.styleElement(this);\n } else {\n this.shouldAdoptStyles();\n }\n }\n\n public override shadowRoot!: ShadowRootWithAdoptedStyleSheets;\n\n private _system: SystemVariant | '' = 'spectrum';\n /**\n * The Spectrum system that is applied to the content scoped to this `sp-theme` element.\n *\n * A value is requried.\n * @type {\"spectrum\" | \"express\" }\n * @attr\n */\n get system(): SystemVariant | '' {\n const systemFragments = Theme.themeFragmentsByKind.get('system');\n const { name } =\n (systemFragments && systemFragments.get('default')) || {};\n return this._system || (name as SystemVariant) || '';\n }\n\n set system(newValue: SystemVariant | '') {\n if (newValue === this._system) return;\n const system =\n !!newValue && SystemVariantValues.includes(newValue)\n ? newValue\n : this.system;\n if (system !== this._system) {\n this._system = system;\n this.requestUpdate();\n }\n if (system) {\n this.setAttribute('system', system);\n /* c8 ignore next 3 */\n } else {\n this.removeAttribute('system');\n }\n }\n\n /*\n * @deprecated The `theme` attribute has been deprecated in favor of the `system` attribute.\n */\n get theme(): SystemVariant | '' {\n if (!this.system) {\n this.removeAttribute('system');\n }\n return this.system;\n }\n\n /*\n * @deprecated The `theme` attribute has been deprecated in favor of the `system` attribute.\n */\n set theme(newValue: SystemVariant | '') {\n this.system = newValue;\n this.requestUpdate();\n }\n\n private _color: Color | '' = '';\n\n /**\n * The Spectrum color stops to apply to content scoped by this `sp-theme` element.\n *\n * A value is requried.\n * @type {\"lightest\" | \"light\" | \"dark\" | \"darkest\" | \"\"}\n * @attr\n */\n get color(): Color | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('color');\n const { name } =\n (themeFragments && themeFragments.get('default')) || {};\n return this._color || (name as Color) || '';\n }\n\n set color(newValue: Color | '') {\n if (newValue === this._color) return;\n const color =\n !!newValue && ColorValues.includes(newValue)\n ? newValue\n : this.color;\n if (color !== this._color) {\n this._color = color;\n this.requestUpdate();\n }\n if (color) {\n this.setAttribute('color', color);\n /* c8 ignore next 3 */\n } else {\n this.removeAttribute('color');\n }\n }\n\n private _scale: Scale | '' = '';\n\n /**\n * The Spectrum platform scale to apply to content scoped by this `sp-theme` element.\n *\n * A value is requried.\n * @type {\"medium\" | \"large\" | \"\"}\n * @attr\n */\n get scale(): Scale | '' {\n const themeFragments = Theme.themeFragmentsByKind.get('scale');\n const { name } =\n (themeFragments && themeFragments.get('default')) || {};\n return this._scale || (name as Scale) || '';\n }\n\n set scale(newValue: Scale | '') {\n if (newValue === this._scale) return;\n const scale =\n !!newValue && ScaleValues.includes(newValue)\n ? newValue\n : this.scale;\n if (scale !== this._scale) {\n this._scale = scale;\n this.requestUpdate();\n }\n if (scale) {\n this.setAttribute('scale', scale);\n /* c8 ignore next 3 */\n } else {\n this.removeAttribute('scale');\n }\n }\n\n private get styles(): CSSResultGroup[] {\n const themeKinds: FragmentType[] = [\n ...Theme.themeFragmentsByKind.keys(),\n ];\n const getStyle = (\n fragments: FragmentMap,\n name: FragmentName,\n kind?: FragmentType\n ): CSSResultGroup | undefined => {\n const currentStyles =\n kind &&\n kind !== 'theme' &&\n kind !== 'system' &&\n this.theme !== 'spectrum' &&\n this.system !== 'spectrum'\n ? fragments.get(`${name}-${this.system}`)\n : fragments.get(name);\n // theme=\"spectrum\" is available by default and doesn't need to be applied.\n const isAppliedFragment =\n name === 'spectrum' || !kind || this.hasAttribute(kind);\n if (currentStyles && isAppliedFragment) {\n return currentStyles.styles;\n }\n return;\n };\n const styles = themeKinds.reduce((acc, kind) => {\n const kindFragments = Theme.themeFragmentsByKind.get(\n kind\n ) as FragmentMap;\n let style: CSSResultGroup | undefined;\n if (kind === 'app' || kind === 'core') {\n style = getStyle(kindFragments, kind);\n } else {\n const { [kind]: name } = this;\n style = getStyle(kindFragments, <FragmentName>name, kind);\n }\n if (style) {\n acc.push(style);\n }\n return acc;\n }, [] as CSSResultGroup[]);\n if (window.__swc.DEBUG) {\n const issues: string[] = [];\n const checkForAttribute = (\n name: FragmentType,\n resolvedValue?: string,\n actualValue?: string\n ): void => {\n const systemModifier =\n this.system && this.system !== 'spectrum'\n ? `-${this.system}`\n : '';\n if (!resolvedValue) {\n issues.push(\n `You have not explicitly set the \"${name}\" attribute and there is no default value on which to fallback.`\n );\n } else if (!actualValue) {\n issues.push(\n `You have not explicitly set the \"${name}\" attribute, the default value (\"${resolvedValue}\") is being used as a fallback.`\n );\n } else if (\n !Theme.themeFragmentsByKind\n .get(name)\n ?.get(\n resolvedValue +\n (name === 'system' ? '' : systemModifier)\n )\n ) {\n issues.push(\n `You have set \"${name}='${resolvedValue}'\" but the associated system fragment has not been loaded.`\n );\n }\n };\n\n checkForAttribute('system', this.system, this._system);\n checkForAttribute('color', this.color, this._color);\n checkForAttribute('scale', this.scale, this._scale);\n\n // Check for deprecated attributes\n if (this.hasAttribute('theme')) {\n issues.push(\n `The \"theme\" attribute has been deprecated in favor of \"system\".`\n );\n }\n\n if (issues.length) {\n window.__swc.warn(\n this,\n 'You are leveraging an <sp-theme> element and the following issues may disrupt your theme delivery:',\n 'https://opensource.adobe.com/spectrum-web-components/components/theme/#example',\n {\n issues,\n }\n );\n }\n if (['lightest', 'darkest'].includes(this.color)) {\n window.__swc.warn(\n this,\n `Color lightest and darkest are deprecated and will be removed in a future release`,\n 'https://opensource.adobe.com/spectrum-web-components/tools/themes/#deprecation',\n { level: 'deprecation' }\n );\n }\n }\n return [...styles];\n }\n\n private static get template(): HTMLTemplateElement {\n if (!this.templateElement) {\n this.templateElement = document.createElement('template');\n this.templateElement.innerHTML = '<slot></slot>';\n }\n return this.templateElement;\n }\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n const node = document.importNode(Theme.template.content, true);\n this.shadowRoot.appendChild(node);\n this.shouldAdoptStyles();\n this.addEventListener(\n 'sp-query-theme',\n this.onQueryTheme as EventListener\n );\n this.addEventListener(\n 'sp-language-context',\n this._handleContextPresence as EventListener\n );\n this.updateComplete = this.__createDeferredPromise();\n }\n\n public updateComplete!: Promise<boolean>;\n private __resolve!: (compelted: boolean) => void;\n\n private __createDeferredPromise(): Promise<boolean> {\n return new Promise((resolve) => {\n this.__resolve = resolve;\n });\n }\n\n /* c8 ignore next 12 */\n private onQueryTheme(event: CustomEvent<ThemeData>): void {\n if (event.defaultPrevented) {\n return;\n }\n event.preventDefault();\n const { detail: theme } = event;\n theme.color = this.color || undefined;\n theme.scale = this.scale || undefined;\n theme.lang =\n this.lang || document.documentElement.lang || navigator.language;\n // `theme` is deprecated in favor of `system` but maintaining `theme` as a deprecated path.\n theme.theme = this.system || undefined;\n theme.system = this.system || undefined;\n }\n\n protected connectedCallback(): void {\n this.shouldAdoptStyles();\n // Note, first update/render handles styleElement so we only call this if\n // connected after first update.\n /* c8 ignore next 3 */\n if (window.ShadyCSS !== undefined) {\n window.ShadyCSS.styleElement(this);\n }\n // Add `this` to the instances array.\n Theme.instances.add(this);\n if (!this.hasAttribute('dir')) {\n let dirParent = ((this as HTMLElement).assignedSlot ||\n this.parentNode) as HTMLElement | DocumentFragment | ShadowRoot;\n while (\n dirParent !== document.documentElement &&\n !(dirParent instanceof Theme)\n ) {\n dirParent = ((dirParent as HTMLElement).assignedSlot || // step into the shadow DOM of the parent of a slotted node\n dirParent.parentNode || // DOM Element detected\n (dirParent as ShadowRoot).host) as\n | HTMLElement\n | DocumentFragment\n | ShadowRoot;\n }\n this.dir = dirParent.dir === 'rtl' ? dirParent.dir : 'ltr';\n }\n }\n\n protected disconnectedCallback(): void {\n // Remove `this` to the instances array.\n Theme.instances.delete(this);\n }\n\n public startManagingContentDirection(el: HTMLElement): void {\n this.trackedChildren.add(el);\n }\n\n public stopManagingContentDirection(el: HTMLElement): void {\n this.trackedChildren.delete(el);\n }\n\n private trackedChildren: Set<HTMLElement> = new Set();\n\n private _updateRequested = false;\n\n private async shouldAdoptStyles(): Promise<void> {\n if (!this._updateRequested) {\n this.updateComplete = this.__createDeferredPromise();\n this._updateRequested = true;\n this._updateRequested = await false;\n this.adoptStyles();\n this.__resolve(true);\n }\n }\n\n protected adoptStyles(): void {\n const styles = this.styles; // No test coverage on Edge\n\n // There are three separate cases here based on Shadow DOM support.\n // (1) shadowRoot polyfilled: use ShadyCSS\n // (2) shadowRoot.adoptedStyleSheets available: use it.\n // (3) shadowRoot.adoptedStyleSheets polyfilled: append styles after rendering\n /* c8 ignore next 28 */\n if (\n window.ShadyCSS !== undefined &&\n !window.ShadyCSS.nativeShadow &&\n window.ShadyCSS.ScopingShim\n ) {\n // For browsers using the shim, there seems to be one set of\n // processed styles per template, so it is hard to nest styles. So,\n // for those, we load in all style fragments and then switch using a\n // host selector (e.g. :host([color='dark']))\n const fragmentCSS: string[] = [];\n for (const [kind, fragments] of Theme.themeFragmentsByKind) {\n for (const [name, { styles }] of fragments) {\n if (name === 'default') continue;\n let cssText = (styles as CSSResult).cssText;\n if (!Theme.defaultFragments.has(name as FragmentName)) {\n cssText = cssText.replace(\n ':host',\n `:host([${kind}='${name}'])`\n );\n }\n fragmentCSS.push(cssText);\n }\n }\n window.ShadyCSS.ScopingShim.prepareAdoptedCssText(\n fragmentCSS,\n this.localName\n );\n window.ShadyCSS.prepareTemplate(Theme.template, this.localName);\n } else if (supportsAdoptingStyleSheets) {\n const styleSheets: CSSStyleSheet[] = [];\n for (const style of styles) {\n styleSheets.push(\n (style as CSSResult).styleSheet as CSSStyleSheet\n );\n }\n this.shadowRoot.adoptedStyleSheets = styleSheets;\n /* c8 ignore next 9 */\n } else {\n const styleNodes = this.shadowRoot.querySelectorAll('style');\n styleNodes.forEach((element) => element.remove());\n styles.forEach((s) => {\n const style = document.createElement('style');\n style.textContent = (s as CSSResult).cssText;\n this.shadowRoot.appendChild(style);\n });\n }\n }\n\n static registerThemeFragment(\n name: FragmentName,\n kind: FragmentType,\n styles: CSSResultGroup\n ): void {\n const fragmentMap = Theme.themeFragmentsByKind.get(kind) || new Map();\n if (fragmentMap.size === 0) {\n Theme.themeFragmentsByKind.set(kind, fragmentMap);\n // we're adding our first fragment for this kind, set as default\n fragmentMap.set('default', { name, styles });\n Theme.defaultFragments.add(name);\n }\n fragmentMap.set(name, { name, styles });\n Theme.instances.forEach((instance) => instance.shouldAdoptStyles());\n }\n\n private _contextConsumers = new Map<\n HTMLElement,\n [ProvideLang['callback'], () => void]\n >();\n\n /* c8 ignore next 5 */\n private _provideContext(): void {\n this._contextConsumers.forEach(([callback, unsubscribe]) =>\n callback(this.lang, unsubscribe)\n );\n }\n\n private _handleContextPresence(event: CustomEvent<ProvideLang>): void {\n event.stopPropagation();\n const target = event.composedPath()[0] as HTMLElement;\n /* c8 ignore next 3 */\n if (this._contextConsumers.has(target)) {\n return;\n }\n this._contextConsumers.set(target, [\n event.detail.callback,\n () => this._contextConsumers.delete(target),\n ]);\n const [callback, unsubscribe] =\n this._contextConsumers.get(target) || [];\n if (callback && unsubscribe) {\n callback(\n this.lang ||\n document.documentElement.lang ||\n navigator.language,\n unsubscribe\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAYA;AAAA,EAGI;AAAA,OACG;AACP,SAAS,eAAe;AA2CxB,MAAM,sBAAsB,CAAC,YAAY,WAAW,cAA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-
"use strict";import{supportsAdoptingStyleSheets as m}from"@spectrum-web-components/base";import{version as
|
|
1
|
+
"use strict";import{supportsAdoptingStyleSheets as m}from"@spectrum-web-components/base";import{version as h}from"@spectrum-web-components/base/src/version.js";const d=["spectrum","express","spectrum-two"],c=["medium","large","medium-express","large-express","medium-spectrum-two","large-spectrum-two"],p=["light","lightest","dark","darkest","light-express","lightest-express","dark-express","darkest-express","light-spectrum-two","dark-spectrum-two"],r=class r extends HTMLElement{constructor(){super();this._dir="";this._system="spectrum";this._color="";this._scale="";this.trackedChildren=new Set;this._updateRequested=!1;this._contextConsumers=new Map;this.attachShadow({mode:"open"});const e=document.importNode(r.template.content,!0);this.shadowRoot.appendChild(e),this.shouldAdoptStyles(),this.addEventListener("sp-query-theme",this.onQueryTheme),this.addEventListener("sp-language-context",this._handleContextPresence),this.updateComplete=this.__createDeferredPromise()}static get observedAttributes(){return["color","scale","lang","dir","system","theme"]}set dir(e){if(e===this.dir)return;this.setAttribute("dir",e),this._dir=e;const t=e==="rtl"?e:"ltr";this.trackedChildren.forEach(s=>{s.setAttribute("dir",t)})}get dir(){return this._dir}attributeChangedCallback(e,t,s){t!==s&&(e==="color"?this.color=s:e==="scale"?this.scale=s:e==="lang"&&s?(this.lang=s,this._provideContext()):e==="theme"?this.theme=s:e==="system"?this.system=s:e==="dir"&&(this.dir=s))}requestUpdate(){window.ShadyCSS!==void 0&&!window.ShadyCSS.nativeShadow?window.ShadyCSS.styleElement(this):this.shouldAdoptStyles()}get system(){const e=r.themeFragmentsByKind.get("system"),{name:t}=e&&e.get("default")||{};return this._system||t||""}set system(e){if(e===this._system)return;const t=e&&d.includes(e)?e:this.system;t!==this._system&&(this._system=t,this.requestUpdate()),t?this.setAttribute("system",t):this.removeAttribute("system")}get theme(){return this.system||this.removeAttribute("system"),this.system}set theme(e){this.system=e,this.requestUpdate()}get color(){const e=r.themeFragmentsByKind.get("color"),{name:t}=e&&e.get("default")||{};return this._color||t||""}set color(e){if(e===this._color)return;const t=e&&p.includes(e)?e:this.color;t!==this._color&&(this._color=t,this.requestUpdate()),t?this.setAttribute("color",t):this.removeAttribute("color")}get scale(){const e=r.themeFragmentsByKind.get("scale"),{name:t}=e&&e.get("default")||{};return this._scale||t||""}set scale(e){if(e===this._scale)return;const t=e&&c.includes(e)?e:this.scale;t!==this._scale&&(this._scale=t,this.requestUpdate()),t?this.setAttribute("scale",t):this.removeAttribute("scale")}get styles(){const e=[...r.themeFragmentsByKind.keys()],t=(a,i,n)=>{const o=n&&n!=="theme"&&n!=="system"&&this.theme!=="spectrum"&&this.system!=="spectrum"?a.get(`${i}-${this.system}`):a.get(i),l=i==="spectrum"||!n||this.hasAttribute(n);if(o&&l)return o.styles};return[...e.reduce((a,i)=>{const n=r.themeFragmentsByKind.get(i);let o;if(i==="app"||i==="core")o=t(n,i);else{const{[i]:l}=this;o=t(n,l,i)}return o&&a.push(o),a},[])]}static get template(){return this.templateElement||(this.templateElement=document.createElement("template"),this.templateElement.innerHTML="<slot></slot>"),this.templateElement}__createDeferredPromise(){return new Promise(e=>{this.__resolve=e})}onQueryTheme(e){if(e.defaultPrevented)return;e.preventDefault();const{detail:t}=e;t.color=this.color||void 0,t.scale=this.scale||void 0,t.lang=this.lang||document.documentElement.lang||navigator.language,t.theme=this.system||void 0,t.system=this.system||void 0}connectedCallback(){if(this.shouldAdoptStyles(),window.ShadyCSS!==void 0&&window.ShadyCSS.styleElement(this),r.instances.add(this),!this.hasAttribute("dir")){let e=this.assignedSlot||this.parentNode;for(;e!==document.documentElement&&!(e instanceof r);)e=e.assignedSlot||e.parentNode||e.host;this.dir=e.dir==="rtl"?e.dir:"ltr"}}disconnectedCallback(){r.instances.delete(this)}startManagingContentDirection(e){this.trackedChildren.add(e)}stopManagingContentDirection(e){this.trackedChildren.delete(e)}async shouldAdoptStyles(){this._updateRequested||(this.updateComplete=this.__createDeferredPromise(),this._updateRequested=!0,this._updateRequested=await!1,this.adoptStyles(),this.__resolve(!0))}adoptStyles(){const e=this.styles;if(window.ShadyCSS!==void 0&&!window.ShadyCSS.nativeShadow&&window.ShadyCSS.ScopingShim){const t=[];for(const[s,a]of r.themeFragmentsByKind)for(const[i,{styles:n}]of a){if(i==="default")continue;let o=n.cssText;r.defaultFragments.has(i)||(o=o.replace(":host",`:host([${s}='${i}'])`)),t.push(o)}window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t,this.localName),window.ShadyCSS.prepareTemplate(r.template,this.localName)}else if(m){const t=[];for(const s of e)t.push(s.styleSheet);this.shadowRoot.adoptedStyleSheets=t}else this.shadowRoot.querySelectorAll("style").forEach(s=>s.remove()),e.forEach(s=>{const a=document.createElement("style");a.textContent=s.cssText,this.shadowRoot.appendChild(a)})}static registerThemeFragment(e,t,s){const a=r.themeFragmentsByKind.get(t)||new Map;a.size===0&&(r.themeFragmentsByKind.set(t,a),a.set("default",{name:e,styles:s}),r.defaultFragments.add(e)),a.set(e,{name:e,styles:s}),r.instances.forEach(i=>i.shouldAdoptStyles())}_provideContext(){this._contextConsumers.forEach(([e,t])=>e(this.lang,t))}_handleContextPresence(e){e.stopPropagation();const t=e.composedPath()[0];if(this._contextConsumers.has(t))return;this._contextConsumers.set(t,[e.detail.callback,()=>this._contextConsumers.delete(t)]);const[s,a]=this._contextConsumers.get(t)||[];s&&a&&s(this.lang||document.documentElement.lang||navigator.language,a)}};r.themeFragmentsByKind=new Map,r.defaultFragments=new Set(["spectrum"]),r.instances=new Set,r.VERSION=h;export let Theme=r;
|
|
2
2
|
//# sourceMappingURL=Theme.js.map
|