@spectrum-web-components/story-decorator 1.6.0-beta.0 → 1.6.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/decorator.dev.js +60 -54
- package/decorator.dev.js.map +2 -2
- package/decorator.js +32 -23
- package/decorator.js.map +3 -3
- package/package.json +12 -9
package/decorator.dev.js
CHANGED
|
@@ -1,78 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import { html
|
|
2
|
+
import { html } from "@spectrum-web-components/base";
|
|
3
|
+
import { useEffect } from "@storybook/preview-api";
|
|
3
4
|
import "./sp-story-decorator.dev.js";
|
|
4
5
|
export const themeStyles = html`
|
|
5
6
|
<style>
|
|
6
7
|
#root {
|
|
7
8
|
padding: 0;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
sp-story-decorator::part(container) {
|
|
10
11
|
min-height: auto;
|
|
11
12
|
position: relative;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
sp-story-decorator::part(controls) {
|
|
14
15
|
position: absolute;
|
|
15
16
|
}
|
|
16
17
|
</style>
|
|
17
18
|
`;
|
|
18
|
-
export const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<style>
|
|
33
|
-
sp-story-decorator::part(controls) {
|
|
34
|
-
display: none;
|
|
35
|
-
}
|
|
36
|
-
</style>
|
|
37
|
-
`;
|
|
38
|
-
}
|
|
39
|
-
if (context == null ? void 0 : context.globals) {
|
|
40
|
-
if (context.globals.system) {
|
|
41
|
-
window.__swc_hack_knobs__.defaultSystemVariant = context.globals.system;
|
|
19
|
+
export const swcThemeDecorator = (story, context) => {
|
|
20
|
+
const {
|
|
21
|
+
globals: {
|
|
22
|
+
system,
|
|
23
|
+
color,
|
|
24
|
+
scale,
|
|
25
|
+
textDirection,
|
|
26
|
+
reduceMotion,
|
|
27
|
+
lang
|
|
28
|
+
} = {}
|
|
29
|
+
} = context;
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (system) {
|
|
32
|
+
window.__swc_hack_knobs__.defaultSystemVariant = system;
|
|
42
33
|
}
|
|
43
|
-
if (
|
|
44
|
-
window.__swc_hack_knobs__.defaultColor =
|
|
34
|
+
if (color) {
|
|
35
|
+
window.__swc_hack_knobs__.defaultColor = color;
|
|
45
36
|
}
|
|
46
|
-
if (
|
|
47
|
-
window.__swc_hack_knobs__.defaultScale =
|
|
37
|
+
if (scale) {
|
|
38
|
+
window.__swc_hack_knobs__.defaultScale = scale;
|
|
48
39
|
}
|
|
49
|
-
if (
|
|
50
|
-
window.__swc_hack_knobs__.defaultDirection =
|
|
51
|
-
if (document.documentElement.dir !==
|
|
52
|
-
document.documentElement.dir =
|
|
40
|
+
if (textDirection) {
|
|
41
|
+
window.__swc_hack_knobs__.defaultDirection = textDirection;
|
|
42
|
+
if (document.documentElement.dir !== textDirection) {
|
|
43
|
+
document.documentElement.dir = textDirection;
|
|
53
44
|
}
|
|
54
45
|
}
|
|
55
|
-
if (
|
|
56
|
-
window.__swc_hack_knobs__.defaultReduceMotion =
|
|
46
|
+
if (reduceMotion !== void 0) {
|
|
47
|
+
window.__swc_hack_knobs__.defaultReduceMotion = reduceMotion;
|
|
57
48
|
}
|
|
58
|
-
if (
|
|
59
|
-
window.__swc_hack_knobs__.defaultLocale =
|
|
49
|
+
if (lang) {
|
|
50
|
+
window.__swc_hack_knobs__.defaultLocale = lang;
|
|
60
51
|
}
|
|
61
|
-
}
|
|
52
|
+
}, [system, color, scale, textDirection, reduceMotion, lang]);
|
|
53
|
+
const hasAnySetting = system || color || scale || textDirection || reduceMotion;
|
|
62
54
|
return html`
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
<style>
|
|
56
|
+
#root {
|
|
57
|
+
padding: 0;
|
|
58
|
+
}
|
|
59
|
+
sp-story-decorator::part(container) {
|
|
60
|
+
min-height: auto;
|
|
61
|
+
position: relative;
|
|
62
|
+
}
|
|
63
|
+
sp-story-decorator::part(controls) {
|
|
64
|
+
position: absolute;
|
|
65
|
+
}
|
|
66
|
+
${hasAnySetting ? `sp-story-decorator::part(controls) {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
` : ""}
|
|
70
|
+
</style>
|
|
71
|
+
<sp-story-decorator
|
|
72
|
+
role="main"
|
|
73
|
+
system=${system}
|
|
74
|
+
color=${color}
|
|
75
|
+
scale=${scale}
|
|
76
|
+
lang=${lang}
|
|
77
|
+
.direction=${textDirection}
|
|
78
|
+
?reduce-motion=${reduceMotion}
|
|
79
|
+
>
|
|
80
|
+
${story({}, context)}
|
|
81
|
+
</sp-story-decorator>
|
|
82
|
+
`;
|
|
76
83
|
};
|
|
77
|
-
export const swcThemeDecorator = swcThemeDecoratorWithConfig();
|
|
78
84
|
//# sourceMappingURL=decorator.dev.js.map
|
package/decorator.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["decorator.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 { html
|
|
5
|
-
"mappings": ";AAYA,SAAS,
|
|
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 { html } from '@spectrum-web-components/base';\nimport { useEffect } from '@storybook/preview-api';\nimport './sp-story-decorator.dev.js'\nimport type { StoryContext, StoryFn } from '@storybook/web-components';\n\nexport const themeStyles = html`\n <style>\n #root {\n padding: 0;\n }\n sp-story-decorator::part(container) {\n min-height: auto;\n position: relative;\n }\n sp-story-decorator::part(controls) {\n position: absolute;\n }\n </style>\n`;\n\n/**\n * Global properties added to each component; determines what stylesheets are loaded\n **/\nexport const swcThemeDecorator = (story: StoryFn, context: StoryContext) => {\n const {\n globals: {\n system,\n color,\n scale,\n textDirection,\n reduceMotion,\n lang,\n } = {},\n } = context;\n\n useEffect(() => {\n // Update window.__swc_hack_knobs__ values with current context globals\n if (system) {\n window.__swc_hack_knobs__.defaultSystemVariant = system;\n }\n if (color) {\n window.__swc_hack_knobs__.defaultColor = color;\n }\n if (scale) {\n window.__swc_hack_knobs__.defaultScale = scale;\n }\n if (textDirection) {\n window.__swc_hack_knobs__.defaultDirection = textDirection;\n if (document.documentElement.dir !== textDirection) {\n document.documentElement.dir = textDirection;\n }\n }\n if (reduceMotion !== undefined) {\n window.__swc_hack_knobs__.defaultReduceMotion = reduceMotion;\n }\n if (lang) {\n window.__swc_hack_knobs__.defaultLocale = lang;\n }\n }, [system, color, scale, textDirection, reduceMotion, lang]);\n\n const hasAnySetting =\n system || color || scale || textDirection || reduceMotion;\n\n return html`\n <style>\n #root {\n padding: 0;\n }\n sp-story-decorator::part(container) {\n min-height: auto;\n position: relative;\n }\n sp-story-decorator::part(controls) {\n position: absolute;\n }\n ${hasAnySetting\n ? `sp-story-decorator::part(controls) {\n display: none;\n }\n `\n : ''}\n </style>\n <sp-story-decorator\n role=\"main\"\n system=${system}\n color=${color}\n scale=${scale}\n lang=${lang}\n .direction=${textDirection}\n ?reduce-motion=${reduceMotion}\n >\n ${story({}, context)}\n </sp-story-decorator>\n `;\n};\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,OAAO;AAGA,aAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBpB,aAAM,oBAAoB,CAAC,OAAgB,YAA0B;AACxE,QAAM;AAAA,IACF,SAAS;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACJ,IAAI,CAAC;AAAA,EACT,IAAI;AAEJ,YAAU,MAAM;AAEZ,QAAI,QAAQ;AACR,aAAO,mBAAmB,uBAAuB;AAAA,IACrD;AACA,QAAI,OAAO;AACP,aAAO,mBAAmB,eAAe;AAAA,IAC7C;AACA,QAAI,OAAO;AACP,aAAO,mBAAmB,eAAe;AAAA,IAC7C;AACA,QAAI,eAAe;AACf,aAAO,mBAAmB,mBAAmB;AAC7C,UAAI,SAAS,gBAAgB,QAAQ,eAAe;AAChD,iBAAS,gBAAgB,MAAM;AAAA,MACnC;AAAA,IACJ;AACA,QAAI,iBAAiB,QAAW;AAC5B,aAAO,mBAAmB,sBAAsB;AAAA,IACpD;AACA,QAAI,MAAM;AACN,aAAO,mBAAmB,gBAAgB;AAAA,IAC9C;AAAA,EACJ,GAAG,CAAC,QAAQ,OAAO,OAAO,eAAe,cAAc,IAAI,CAAC;AAE5D,QAAM,gBACF,UAAU,SAAS,SAAS,iBAAiB;AAEjD,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAYG,gBACI;AAAA;AAAA;AAAA,YAIA,EAAE;AAAA;AAAA;AAAA;AAAA,qBAIC,MAAM;AAAA,oBACP,KAAK;AAAA,oBACL,KAAK;AAAA,mBACN,IAAI;AAAA,yBACE,aAAa;AAAA,6BACT,YAAY;AAAA;AAAA,cAE3B,MAAM,CAAC,GAAG,OAAO,CAAC;AAAA;AAAA;AAGhC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/decorator.js
CHANGED
|
@@ -1,34 +1,43 @@
|
|
|
1
|
-
"use strict";import{html as
|
|
1
|
+
"use strict";import{html as a}from"@spectrum-web-components/base";import{useEffect as d}from"@storybook/preview-api";import"./sp-story-decorator.js";export const themeStyles=a`
|
|
2
2
|
<style>
|
|
3
3
|
#root {
|
|
4
4
|
padding: 0;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
sp-story-decorator::part(container) {
|
|
7
7
|
min-height: auto;
|
|
8
8
|
position: relative;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
sp-story-decorator::part(controls) {
|
|
11
11
|
position: absolute;
|
|
12
12
|
}
|
|
13
13
|
</style>
|
|
14
|
-
`,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
14
|
+
`,swcThemeDecorator=(c,i)=>{const{globals:{system:t,color:e,scale:r,textDirection:o,reduceMotion:n,lang:s}={}}=i;return d(()=>{t&&(window.__swc_hack_knobs__.defaultSystemVariant=t),e&&(window.__swc_hack_knobs__.defaultColor=e),r&&(window.__swc_hack_knobs__.defaultScale=r),o&&(window.__swc_hack_knobs__.defaultDirection=o,document.documentElement.dir!==o&&(document.documentElement.dir=o)),n!==void 0&&(window.__swc_hack_knobs__.defaultReduceMotion=n),s&&(window.__swc_hack_knobs__.defaultLocale=s)},[t,e,r,o,n,s]),a`
|
|
15
|
+
<style>
|
|
16
|
+
#root {
|
|
17
|
+
padding: 0;
|
|
18
|
+
}
|
|
19
|
+
sp-story-decorator::part(container) {
|
|
20
|
+
min-height: auto;
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
sp-story-decorator::part(controls) {
|
|
24
|
+
position: absolute;
|
|
25
|
+
}
|
|
26
|
+
${t||e||r||o||n?`sp-story-decorator::part(controls) {
|
|
27
|
+
display: none;
|
|
28
|
+
}
|
|
29
|
+
`:""}
|
|
30
|
+
</style>
|
|
31
|
+
<sp-story-decorator
|
|
32
|
+
role="main"
|
|
33
|
+
system=${t}
|
|
34
|
+
color=${e}
|
|
35
|
+
scale=${r}
|
|
36
|
+
lang=${s}
|
|
37
|
+
.direction=${o}
|
|
38
|
+
?reduce-motion=${n}
|
|
39
|
+
>
|
|
40
|
+
${c({},i)}
|
|
41
|
+
</sp-story-decorator>
|
|
42
|
+
`};
|
|
34
43
|
//# sourceMappingURL=decorator.js.map
|
package/decorator.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["decorator.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 { html
|
|
5
|
-
"mappings": "aAYA,OAAS,QAAAA,
|
|
6
|
-
"names": ["html", "
|
|
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 { html } from '@spectrum-web-components/base';\nimport { useEffect } from '@storybook/preview-api';\nimport './sp-story-decorator.js';\nimport type { StoryContext, StoryFn } from '@storybook/web-components';\n\nexport const themeStyles = html`\n <style>\n #root {\n padding: 0;\n }\n sp-story-decorator::part(container) {\n min-height: auto;\n position: relative;\n }\n sp-story-decorator::part(controls) {\n position: absolute;\n }\n </style>\n`;\n\n/**\n * Global properties added to each component; determines what stylesheets are loaded\n **/\nexport const swcThemeDecorator = (story: StoryFn, context: StoryContext) => {\n const {\n globals: {\n system,\n color,\n scale,\n textDirection,\n reduceMotion,\n lang,\n } = {},\n } = context;\n\n useEffect(() => {\n // Update window.__swc_hack_knobs__ values with current context globals\n if (system) {\n window.__swc_hack_knobs__.defaultSystemVariant = system;\n }\n if (color) {\n window.__swc_hack_knobs__.defaultColor = color;\n }\n if (scale) {\n window.__swc_hack_knobs__.defaultScale = scale;\n }\n if (textDirection) {\n window.__swc_hack_knobs__.defaultDirection = textDirection;\n if (document.documentElement.dir !== textDirection) {\n document.documentElement.dir = textDirection;\n }\n }\n if (reduceMotion !== undefined) {\n window.__swc_hack_knobs__.defaultReduceMotion = reduceMotion;\n }\n if (lang) {\n window.__swc_hack_knobs__.defaultLocale = lang;\n }\n }, [system, color, scale, textDirection, reduceMotion, lang]);\n\n const hasAnySetting =\n system || color || scale || textDirection || reduceMotion;\n\n return html`\n <style>\n #root {\n padding: 0;\n }\n sp-story-decorator::part(container) {\n min-height: auto;\n position: relative;\n }\n sp-story-decorator::part(controls) {\n position: absolute;\n }\n ${hasAnySetting\n ? `sp-story-decorator::part(controls) {\n display: none;\n }\n `\n : ''}\n </style>\n <sp-story-decorator\n role=\"main\"\n system=${system}\n color=${color}\n scale=${scale}\n lang=${lang}\n .direction=${textDirection}\n ?reduce-motion=${reduceMotion}\n >\n ${story({}, context)}\n </sp-story-decorator>\n `;\n};\n"],
|
|
5
|
+
"mappings": "aAYA,OAAS,QAAAA,MAAY,gCACrB,OAAS,aAAAC,MAAiB,yBAC1B,MAAO,0BAGA,aAAM,YAAcD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBd,kBAAoB,CAACE,EAAgBC,IAA0B,CACxE,KAAM,CACF,QAAS,CACL,OAAAC,EACA,MAAAC,EACA,MAAAC,EACA,cAAAC,EACA,aAAAC,EACA,KAAAC,CACJ,EAAI,CAAC,CACT,EAAIN,EAEJ,OAAAF,EAAU,IAAM,CAERG,IACA,OAAO,mBAAmB,qBAAuBA,GAEjDC,IACA,OAAO,mBAAmB,aAAeA,GAEzCC,IACA,OAAO,mBAAmB,aAAeA,GAEzCC,IACA,OAAO,mBAAmB,iBAAmBA,EACzC,SAAS,gBAAgB,MAAQA,IACjC,SAAS,gBAAgB,IAAMA,IAGnCC,IAAiB,SACjB,OAAO,mBAAmB,oBAAsBA,GAEhDC,IACA,OAAO,mBAAmB,cAAgBA,EAElD,EAAG,CAACL,EAAQC,EAAOC,EAAOC,EAAeC,EAAcC,CAAI,CAAC,EAKrDT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAFHI,GAAUC,GAASC,GAASC,GAAiBC,EAenC;AAAA;AAAA;AAAA,UAIA,EAAE;AAAA;AAAA;AAAA;AAAA,qBAICJ,CAAM;AAAA,oBACPC,CAAK;AAAA,oBACLC,CAAK;AAAA,mBACNG,CAAI;AAAA,yBACEF,CAAa;AAAA,6BACTC,CAAY;AAAA;AAAA,cAE3BN,EAAM,CAAC,EAAGC,CAAO,CAAC;AAAA;AAAA,KAGhC",
|
|
6
|
+
"names": ["html", "useEffect", "story", "context", "system", "color", "scale", "textDirection", "reduceMotion", "lang"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/story-decorator",
|
|
3
|
-
"version": "1.6.0
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -69,14 +69,17 @@
|
|
|
69
69
|
"lit-html"
|
|
70
70
|
],
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@spectrum-web-components/base": "1.6.0
|
|
73
|
-
"@spectrum-web-components/field-label": "1.6.0
|
|
74
|
-
"@spectrum-web-components/menu": "1.6.0
|
|
75
|
-
"@spectrum-web-components/overlay": "1.6.0
|
|
76
|
-
"@spectrum-web-components/picker": "1.6.0
|
|
77
|
-
"@spectrum-web-components/reactive-controllers": "1.6.0
|
|
78
|
-
"@spectrum-web-components/switch": "1.6.0
|
|
79
|
-
"@spectrum-web-components/theme": "1.6.0
|
|
72
|
+
"@spectrum-web-components/base": "1.6.0",
|
|
73
|
+
"@spectrum-web-components/field-label": "1.6.0",
|
|
74
|
+
"@spectrum-web-components/menu": "1.6.0",
|
|
75
|
+
"@spectrum-web-components/overlay": "1.6.0",
|
|
76
|
+
"@spectrum-web-components/picker": "1.6.0",
|
|
77
|
+
"@spectrum-web-components/reactive-controllers": "1.6.0",
|
|
78
|
+
"@spectrum-web-components/switch": "1.6.0",
|
|
79
|
+
"@spectrum-web-components/theme": "1.6.0"
|
|
80
|
+
},
|
|
81
|
+
"peerDependencies": {
|
|
82
|
+
"@storybook/preview-api": ">=8"
|
|
80
83
|
},
|
|
81
84
|
"types": "./src/index.d.ts",
|
|
82
85
|
"customElements": "custom-elements.json",
|