@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 CHANGED
@@ -1,78 +1,84 @@
1
1
  "use strict";
2
- import { html, render } from "@spectrum-web-components/base";
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
- .docs-story sp-story-decorator::part(container) {
10
+ sp-story-decorator::part(container) {
10
11
  min-height: auto;
11
12
  position: relative;
12
13
  }
13
- .docs-story sp-story-decorator::part(controls) {
14
+ sp-story-decorator::part(controls) {
14
15
  position: absolute;
15
16
  }
16
17
  </style>
17
18
  `;
18
- export const swcThemeDecoratorWithConfig = ({ bundled } = { bundled: true }) => (story, context) => {
19
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
20
- if (!bundled) {
21
- requestAnimationFrame(() => {
22
- document.documentElement.setAttribute("lang", "en");
23
- const decorator = document.querySelector(
24
- "sp-story-decorator"
25
- );
26
- render(story(), decorator);
27
- });
28
- }
29
- let hideNavStyles;
30
- if (((_a = context == null ? void 0 : context.globals) == null ? void 0 : _a.system) || ((_b = context == null ? void 0 : context.globals) == null ? void 0 : _b.color) || ((_c = context == null ? void 0 : context.globals) == null ? void 0 : _c.scale) || ((_d = context == null ? void 0 : context.globals) == null ? void 0 : _d.textDirection) || ((_e = context == null ? void 0 : context.globals) == null ? void 0 : _e.reduceMotion)) {
31
- hideNavStyles = html`
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 (context.globals.color) {
44
- window.__swc_hack_knobs__.defaultColor = context.globals.color;
34
+ if (color) {
35
+ window.__swc_hack_knobs__.defaultColor = color;
45
36
  }
46
- if (context.globals.scale) {
47
- window.__swc_hack_knobs__.defaultScale = context.globals.scale;
37
+ if (scale) {
38
+ window.__swc_hack_knobs__.defaultScale = scale;
48
39
  }
49
- if (context.globals.textDirection) {
50
- window.__swc_hack_knobs__.defaultDirection = context.globals.textDirection;
51
- if (document.documentElement.dir !== context.globals.textDirection) {
52
- document.documentElement.dir = context.globals.textDirection;
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 (context.globals.reduceMotion !== void 0) {
56
- window.__swc_hack_knobs__.defaultReduceMotion = context.globals.reduceMotion;
46
+ if (reduceMotion !== void 0) {
47
+ window.__swc_hack_knobs__.defaultReduceMotion = reduceMotion;
57
48
  }
58
- if (context.globals.lang) {
59
- window.__swc_hack_knobs__.defaultLocale = context.globals.lang;
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
- ${themeStyles} ${hideNavStyles}
64
- <sp-story-decorator
65
- role="main"
66
- system=${(_f = context == null ? void 0 : context.globals) == null ? void 0 : _f.system}
67
- color=${(_g = context == null ? void 0 : context.globals) == null ? void 0 : _g.color}
68
- scale=${(_h = context == null ? void 0 : context.globals) == null ? void 0 : _h.scale}
69
- lang=${(_i = context == null ? void 0 : context.globals) == null ? void 0 : _i.lang}
70
- .direction=${(_j = context == null ? void 0 : context.globals) == null ? void 0 : _j.textDirection}
71
- ?reduce-motion=${(_k = context == null ? void 0 : context.globals) == null ? void 0 : _k.reduceMotion}
72
- >
73
- ${bundled ? story() : html``}
74
- </sp-story-decorator>
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
@@ -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, render, TemplateResult } from '@spectrum-web-components/base';\nimport './sp-story-decorator.dev.js'\nimport { Parameters, Renderer, StoryContext } from '@storybook/csf';\n\nexport const themeStyles = html`\n <style>\n #root {\n padding: 0;\n }\n .docs-story sp-story-decorator::part(container) {\n min-height: auto;\n position: relative;\n }\n .docs-story sp-story-decorator::part(controls) {\n position: absolute;\n }\n </style>\n`;\n\nexport const swcThemeDecoratorWithConfig =\n ({ bundled } = { bundled: true }) =>\n (\n story: () => TemplateResult,\n context: StoryContext<Renderer, Parameters>\n ) => {\n if (!bundled) {\n requestAnimationFrame(() => {\n document.documentElement.setAttribute('lang', 'en');\n const decorator = document.querySelector(\n 'sp-story-decorator'\n ) as HTMLElement;\n render(story(), decorator);\n });\n }\n\n let hideNavStyles;\n // If the global settings exist, hide the bottom toolbar\n if (\n context?.globals?.system ||\n context?.globals?.color ||\n context?.globals?.scale ||\n context?.globals?.textDirection ||\n context?.globals?.reduceMotion\n ) {\n hideNavStyles = html`\n <style>\n sp-story-decorator::part(controls) {\n display: none;\n }\n </style>\n `;\n }\n\n // Update window.__swc_hack_knobs__ values with current context globals\n if (context?.globals) {\n if (context.globals.system) {\n window.__swc_hack_knobs__.defaultSystemVariant =\n context.globals.system;\n }\n if (context.globals.color) {\n window.__swc_hack_knobs__.defaultColor = context.globals.color;\n }\n if (context.globals.scale) {\n window.__swc_hack_knobs__.defaultScale = context.globals.scale;\n }\n if (context.globals.textDirection) {\n window.__swc_hack_knobs__.defaultDirection =\n context.globals.textDirection;\n if (\n document.documentElement.dir !==\n context.globals.textDirection\n ) {\n document.documentElement.dir =\n context.globals.textDirection;\n }\n }\n if (context.globals.reduceMotion !== undefined) {\n window.__swc_hack_knobs__.defaultReduceMotion =\n context.globals.reduceMotion;\n }\n if (context.globals.lang) {\n window.__swc_hack_knobs__.defaultLocale = context.globals.lang;\n }\n }\n\n return html`\n ${themeStyles} ${hideNavStyles}\n <sp-story-decorator\n role=\"main\"\n system=${context?.globals?.system}\n color=${context?.globals?.color}\n scale=${context?.globals?.scale}\n lang=${context?.globals?.lang}\n .direction=${context?.globals?.textDirection}\n ?reduce-motion=${context?.globals?.reduceMotion}\n >\n ${bundled ? story() : html``}\n </sp-story-decorator>\n `;\n };\n\nexport const swcThemeDecorator = swcThemeDecoratorWithConfig();\n"],
5
- "mappings": ";AAYA,SAAS,MAAM,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aAAO,mBAAmB,gBAAgB,QAAQ,QAAQ;AAAA,IAC9D;AAAA,EACJ;AAEA,SAAO;AAAA,cACD,WAAW,IAAI,aAAa;AAAA;AAAA;AAAA,0BAGjB,wCAAS,YAAT,mBAAkB,MAAM;AAAA,yBACzB,wCAAS,YAAT,mBAAkB,KAAK;AAAA,yBACvB,wCAAS,YAAT,mBAAkB,KAAK;AAAA,wBACxB,wCAAS,YAAT,mBAAkB,IAAI;AAAA,8BAChB,wCAAS,YAAT,mBAAkB,aAAa;AAAA,kCAC3B,wCAAS,YAAT,mBAAkB,YAAY;AAAA;AAAA,kBAE7C,UAAU,MAAM,IAAI,MAAM;AAAA;AAAA;AAGxC;AAEG,aAAM,oBAAoB,4BAA4B;",
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 s,render as h}from"@spectrum-web-components/base";import"./sp-story-decorator.js";export const themeStyles=s`
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
- .docs-story sp-story-decorator::part(container) {
6
+ sp-story-decorator::part(container) {
7
7
  min-height: auto;
8
8
  position: relative;
9
9
  }
10
- .docs-story sp-story-decorator::part(controls) {
10
+ sp-story-decorator::part(controls) {
11
11
  position: absolute;
12
12
  }
13
13
  </style>
14
- `,swcThemeDecoratorWithConfig=({bundled:r}={bundled:!0})=>(a,l)=>{var i,e,d,_,m,b,g,u,y,p,f;r||requestAnimationFrame(()=>{document.documentElement.setAttribute("lang","en");const w=document.querySelector("sp-story-decorator");h(a(),w)});let o;return((i=l==null?void 0:l.globals)!=null&&i.system||(e=l==null?void 0:l.globals)!=null&&e.color||(d=l==null?void 0:l.globals)!=null&&d.scale||(_=l==null?void 0:l.globals)!=null&&_.textDirection||(m=l==null?void 0:l.globals)!=null&&m.reduceMotion)&&(o=s`
15
- <style>
16
- sp-story-decorator::part(controls) {
17
- display: none;
18
- }
19
- </style>
20
- `),l!=null&&l.globals&&(l.globals.system&&(window.__swc_hack_knobs__.defaultSystemVariant=l.globals.system),l.globals.color&&(window.__swc_hack_knobs__.defaultColor=l.globals.color),l.globals.scale&&(window.__swc_hack_knobs__.defaultScale=l.globals.scale),l.globals.textDirection&&(window.__swc_hack_knobs__.defaultDirection=l.globals.textDirection,document.documentElement.dir!==l.globals.textDirection&&(document.documentElement.dir=l.globals.textDirection)),l.globals.reduceMotion!==void 0&&(window.__swc_hack_knobs__.defaultReduceMotion=l.globals.reduceMotion),l.globals.lang&&(window.__swc_hack_knobs__.defaultLocale=l.globals.lang)),s`
21
- ${themeStyles} ${o}
22
- <sp-story-decorator
23
- role="main"
24
- system=${(b=l==null?void 0:l.globals)==null?void 0:b.system}
25
- color=${(g=l==null?void 0:l.globals)==null?void 0:g.color}
26
- scale=${(u=l==null?void 0:l.globals)==null?void 0:u.scale}
27
- lang=${(y=l==null?void 0:l.globals)==null?void 0:y.lang}
28
- .direction=${(p=l==null?void 0:l.globals)==null?void 0:p.textDirection}
29
- ?reduce-motion=${(f=l==null?void 0:l.globals)==null?void 0:f.reduceMotion}
30
- >
31
- ${r?a():s``}
32
- </sp-story-decorator>
33
- `},swcThemeDecorator=swcThemeDecoratorWithConfig();
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, render, TemplateResult } from '@spectrum-web-components/base';\nimport './sp-story-decorator.js';\nimport { Parameters, Renderer, StoryContext } from '@storybook/csf';\n\nexport const themeStyles = html`\n <style>\n #root {\n padding: 0;\n }\n .docs-story sp-story-decorator::part(container) {\n min-height: auto;\n position: relative;\n }\n .docs-story sp-story-decorator::part(controls) {\n position: absolute;\n }\n </style>\n`;\n\nexport const swcThemeDecoratorWithConfig =\n ({ bundled } = { bundled: true }) =>\n (\n story: () => TemplateResult,\n context: StoryContext<Renderer, Parameters>\n ) => {\n if (!bundled) {\n requestAnimationFrame(() => {\n document.documentElement.setAttribute('lang', 'en');\n const decorator = document.querySelector(\n 'sp-story-decorator'\n ) as HTMLElement;\n render(story(), decorator);\n });\n }\n\n let hideNavStyles;\n // If the global settings exist, hide the bottom toolbar\n if (\n context?.globals?.system ||\n context?.globals?.color ||\n context?.globals?.scale ||\n context?.globals?.textDirection ||\n context?.globals?.reduceMotion\n ) {\n hideNavStyles = html`\n <style>\n sp-story-decorator::part(controls) {\n display: none;\n }\n </style>\n `;\n }\n\n // Update window.__swc_hack_knobs__ values with current context globals\n if (context?.globals) {\n if (context.globals.system) {\n window.__swc_hack_knobs__.defaultSystemVariant =\n context.globals.system;\n }\n if (context.globals.color) {\n window.__swc_hack_knobs__.defaultColor = context.globals.color;\n }\n if (context.globals.scale) {\n window.__swc_hack_knobs__.defaultScale = context.globals.scale;\n }\n if (context.globals.textDirection) {\n window.__swc_hack_knobs__.defaultDirection =\n context.globals.textDirection;\n if (\n document.documentElement.dir !==\n context.globals.textDirection\n ) {\n document.documentElement.dir =\n context.globals.textDirection;\n }\n }\n if (context.globals.reduceMotion !== undefined) {\n window.__swc_hack_knobs__.defaultReduceMotion =\n context.globals.reduceMotion;\n }\n if (context.globals.lang) {\n window.__swc_hack_knobs__.defaultLocale = context.globals.lang;\n }\n }\n\n return html`\n ${themeStyles} ${hideNavStyles}\n <sp-story-decorator\n role=\"main\"\n system=${context?.globals?.system}\n color=${context?.globals?.color}\n scale=${context?.globals?.scale}\n lang=${context?.globals?.lang}\n .direction=${context?.globals?.textDirection}\n ?reduce-motion=${context?.globals?.reduceMotion}\n >\n ${bundled ? story() : html``}\n </sp-story-decorator>\n `;\n };\n\nexport const swcThemeDecorator = swcThemeDecoratorWithConfig();\n"],
5
- "mappings": "aAYA,OAAS,QAAAA,EAAM,UAAAC,MAA8B,gCAC7C,MAAO,0BAGA,aAAM,Y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B,OAAO,mBAAmB,cAAgBA,EAAQ,QAAQ,OAI3DJ;AAAA,cACD,WAAW,IAAIiB,CAAa;AAAA;AAAA;AAAA,0BAGjBP,EAAAN,GAAA,YAAAA,EAAS,UAAT,YAAAM,EAAkB,MAAM;AAAA,yBACzBC,EAAAP,GAAA,YAAAA,EAAS,UAAT,YAAAO,EAAkB,KAAK;AAAA,yBACvBC,EAAAR,GAAA,YAAAA,EAAS,UAAT,YAAAQ,EAAkB,KAAK;AAAA,wBACxBC,EAAAT,GAAA,YAAAA,EAAS,UAAT,YAAAS,EAAkB,IAAI;AAAA,8BAChBC,EAAAV,GAAA,YAAAA,EAAS,UAAT,YAAAU,EAAkB,aAAa;AAAA,kCAC3BC,EAAAX,GAAA,YAAAA,EAAS,UAAT,YAAAW,EAAkB,YAAY;AAAA;AAAA,kBAE7Cb,EAAUC,EAAM,EAAIH,GAAM;AAAA;AAAA,SAGxC,EAES,kBAAoB,4BAA4B",
6
- "names": ["html", "render", "bundled", "story", "context", "_a", "_b", "_c", "_d", "_e", "_f", "_g", "_h", "_i", "_j", "_k", "decorator", "hideNavStyles"]
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-beta.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-beta.0",
73
- "@spectrum-web-components/field-label": "1.6.0-beta.0",
74
- "@spectrum-web-components/menu": "1.6.0-beta.0",
75
- "@spectrum-web-components/overlay": "1.6.0-beta.0",
76
- "@spectrum-web-components/picker": "1.6.0-beta.0",
77
- "@spectrum-web-components/reactive-controllers": "1.6.0-beta.0",
78
- "@spectrum-web-components/switch": "1.6.0-beta.0",
79
- "@spectrum-web-components/theme": "1.6.0-beta.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",