@carbon/storybook-addon-theme 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Panel.js CHANGED
@@ -1,24 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Panel = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _managerApi = require("@storybook/manager-api");
9
+ var _components = require("@storybook/components");
10
+ var _constants = require("./constants");
11
+ var _PanelContent = require("./components/PanelContent");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
13
  /**
2
14
  * Copyright IBM Corp. 2023, 2023
3
15
  *
4
16
  * This source code is licensed under the Apache-2.0 license found in the
5
17
  * LICENSE file in the root directory of this source tree.
6
18
  */
7
- import React from 'react';
8
- import { useGlobals } from '@storybook/manager-api';
9
- import { AddonPanel } from '@storybook/components';
10
- import { PARAM_KEY } from './constants';
11
- import { PanelContent } from './components/PanelContent';
12
- export const Panel = props => {
13
- const [globals, updateGlobals] = useGlobals();
14
- const globalCarbonTheme = globals[PARAM_KEY];
15
- return /*#__PURE__*/React.createElement(AddonPanel, props, /*#__PURE__*/React.createElement(PanelContent, {
19
+
20
+ const Panel = props => {
21
+ const [globals, updateGlobals] = (0, _managerApi.useGlobals)();
22
+ const globalCarbonTheme = globals[_constants.PARAM_KEY];
23
+ return /*#__PURE__*/_react.default.createElement(_components.AddonPanel, props, /*#__PURE__*/_react.default.createElement(_PanelContent.PanelContent, {
16
24
  theme: globalCarbonTheme,
17
25
  onChange: value => {
18
26
  updateGlobals({
19
- [PARAM_KEY]: value
27
+ [_constants.PARAM_KEY]: value
20
28
  });
21
29
  }
22
30
  }));
23
31
  };
32
+ exports.Panel = Panel;
24
33
  //# sourceMappingURL=Panel.js.map
package/dist/Panel.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Panel.js","names":["React","useGlobals","AddonPanel","PARAM_KEY","PanelContent","Panel","props","globals","updateGlobals","globalCarbonTheme","createElement","theme","onChange","value"],"sources":["../src/Panel.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport React from 'react';\nimport { useGlobals } from '@storybook/manager-api';\n\nimport { AddonPanel } from '@storybook/components';\nimport { PARAM_KEY } from './constants';\nimport { PanelContent } from './components/PanelContent';\n\nexport const Panel = (props) => {\n const [globals, updateGlobals] = useGlobals();\n const globalCarbonTheme = globals[PARAM_KEY];\n\n return (\n <AddonPanel {...props}>\n <PanelContent\n theme={globalCarbonTheme}\n onChange={(value) => {\n updateGlobals({ [PARAM_KEY]: value });\n }}\n />\n </AddonPanel>\n );\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,YAAY,QAAQ,2BAA2B;AAExD,OAAO,MAAMC,KAAK,GAAIC,KAAK,IAAK;EAC9B,MAAM,CAACC,OAAO,EAAEC,aAAa,CAAC,GAAGP,UAAU,CAAC,CAAC;EAC7C,MAAMQ,iBAAiB,GAAGF,OAAO,CAACJ,SAAS,CAAC;EAE5C,oBACEH,KAAA,CAAAU,aAAA,CAACR,UAAU,EAAKI,KAAK,eACnBN,KAAA,CAAAU,aAAA,CAACN,YAAY;IACXO,KAAK,EAAEF,iBAAkB;IACzBG,QAAQ,EAAGC,KAAK,IAAK;MACnBL,aAAa,CAAC;QAAE,CAACL,SAAS,GAAGU;MAAM,CAAC,CAAC;IACvC;EAAE,CACH,CACS,CAAC;AAEjB,CAAC"}
1
+ {"version":3,"file":"Panel.js","names":["_react","_interopRequireDefault","require","_managerApi","_components","_constants","_PanelContent","obj","__esModule","default","Panel","props","globals","updateGlobals","useGlobals","globalCarbonTheme","PARAM_KEY","createElement","AddonPanel","PanelContent","theme","onChange","value","exports"],"sources":["../src/Panel.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport React from 'react';\nimport { useGlobals } from '@storybook/manager-api';\n\nimport { AddonPanel } from '@storybook/components';\nimport { PARAM_KEY } from './constants';\nimport { PanelContent } from './components/PanelContent';\n\nexport const Panel = (props) => {\n const [globals, updateGlobals] = useGlobals();\n const globalCarbonTheme = globals[PARAM_KEY];\n\n return (\n <AddonPanel {...props}>\n <PanelContent\n theme={globalCarbonTheme}\n onChange={(value) => {\n updateGlobals({ [PARAM_KEY]: value });\n }}\n />\n </AddonPanel>\n );\n};\n"],"mappings":";;;;;;AAMA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAAyD,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAXzD;AACA;AACA;AACA;AACA;AACA;;AAQO,MAAMG,KAAK,GAAIC,KAAK,IAAK;EAC9B,MAAM,CAACC,OAAO,EAAEC,aAAa,CAAC,GAAG,IAAAC,sBAAU,EAAC,CAAC;EAC7C,MAAMC,iBAAiB,GAAGH,OAAO,CAACI,oBAAS,CAAC;EAE5C,oBACEhB,MAAA,CAAAS,OAAA,CAAAQ,aAAA,CAACb,WAAA,CAAAc,UAAU,EAAKP,KAAK,eACnBX,MAAA,CAAAS,OAAA,CAAAQ,aAAA,CAACX,aAAA,CAAAa,YAAY;IACXC,KAAK,EAAEL,iBAAkB;IACzBM,QAAQ,EAAGC,KAAK,IAAK;MACnBT,aAAa,CAAC;QAAE,CAACG,oBAAS,GAAGM;MAAM,CAAC,CAAC;IACvC;EAAE,CACH,CACS,CAAC;AAEjB,CAAC;AAACC,OAAA,CAAAb,KAAA,GAAAA,KAAA"}
@@ -1,34 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PanelContent = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _components = require("@storybook/components");
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _constants = require("../constants");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
12
  /**
2
13
  * Copyright IBM Corp. 2023, 2023
3
14
  *
4
15
  * This source code is licensed under the Apache-2.0 license found in the
5
16
  * LICENSE file in the root directory of this source tree.
6
17
  */
7
- import React from 'react';
8
- import { Form } from '@storybook/components';
9
- import PropTypes from 'prop-types';
10
- import { CARBON_THEMES } from '../constants';
11
- export const PanelContent = ({
18
+
19
+ const PanelContent = ({
12
20
  theme,
13
21
  onChange
14
22
  }) => {
15
- const themes = Object.values(CARBON_THEMES);
16
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(Form.Field, {
23
+ const themes = Object.values(_constants.CARBON_THEMES);
24
+ return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_components.Form, null, /*#__PURE__*/_react.default.createElement(_components.Form.Field, {
17
25
  label: "Select Carbon theme:"
18
- }, /*#__PURE__*/React.createElement(Form.Select, {
26
+ }, /*#__PURE__*/_react.default.createElement(_components.Form.Select, {
19
27
  name: "carbon-theme",
20
28
  value: theme,
21
29
  onChange: ev => {
22
30
  onChange && onChange(ev.target.value);
23
31
  },
24
32
  size: "flex"
25
- }, themes.map(option => /*#__PURE__*/React.createElement("option", {
33
+ }, themes.map(option => /*#__PURE__*/_react.default.createElement("option", {
26
34
  key: option,
27
35
  value: option
28
36
  }, option))))));
29
37
  };
38
+ exports.PanelContent = PanelContent;
30
39
  PanelContent.propTypes = {
31
- onChange: PropTypes.func,
32
- theme: PropTypes.string
40
+ onChange: _propTypes.default.func,
41
+ theme: _propTypes.default.string
33
42
  };
34
43
  //# sourceMappingURL=PanelContent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PanelContent.js","names":["React","Form","PropTypes","CARBON_THEMES","PanelContent","theme","onChange","themes","Object","values","createElement","Field","label","Select","name","value","ev","target","size","map","option","key","propTypes","func","string"],"sources":["../../src/components/PanelContent.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport React from 'react';\nimport { Form } from '@storybook/components';\nimport PropTypes from 'prop-types';\nimport { CARBON_THEMES } from '../constants';\n\nexport const PanelContent = ({ theme, onChange }) => {\n const themes = Object.values(CARBON_THEMES);\n\n return (\n <div>\n <Form>\n <Form.Field label=\"Select Carbon theme:\">\n <Form.Select\n name=\"carbon-theme\"\n value={theme}\n onChange={(ev) => {\n onChange && onChange(ev.target.value);\n }}\n size=\"flex\"\n >\n {themes.map((option) => (\n <option key={option} value={option}>\n {option}\n </option>\n ))}\n </Form.Select>\n </Form.Field>\n </Form>\n </div>\n );\n};\n\nPanelContent.propTypes = {\n onChange: PropTypes.func,\n theme: PropTypes.string,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,aAAa,QAAQ,cAAc;AAE5C,OAAO,MAAMC,YAAY,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAS,CAAC,KAAK;EACnD,MAAMC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAACN,aAAa,CAAC;EAE3C,oBACEH,KAAA,CAAAU,aAAA,2BACEV,KAAA,CAAAU,aAAA,CAACT,IAAI,qBACHD,KAAA,CAAAU,aAAA,CAACT,IAAI,CAACU,KAAK;IAACC,KAAK,EAAC;EAAsB,gBACtCZ,KAAA,CAAAU,aAAA,CAACT,IAAI,CAACY,MAAM;IACVC,IAAI,EAAC,cAAc;IACnBC,KAAK,EAAEV,KAAM;IACbC,QAAQ,EAAGU,EAAE,IAAK;MAChBV,QAAQ,IAAIA,QAAQ,CAACU,EAAE,CAACC,MAAM,CAACF,KAAK,CAAC;IACvC,CAAE;IACFG,IAAI,EAAC;EAAM,GAEVX,MAAM,CAACY,GAAG,CAAEC,MAAM,iBACjBpB,KAAA,CAAAU,aAAA;IAAQW,GAAG,EAAED,MAAO;IAACL,KAAK,EAAEK;EAAO,GAChCA,MACK,CACT,CACU,CACH,CACR,CACH,CAAC;AAEV,CAAC;AAEDhB,YAAY,CAACkB,SAAS,GAAG;EACvBhB,QAAQ,EAAEJ,SAAS,CAACqB,IAAI;EACxBlB,KAAK,EAAEH,SAAS,CAACsB;AACnB,CAAC"}
1
+ {"version":3,"file":"PanelContent.js","names":["_react","_interopRequireDefault","require","_components","_propTypes","_constants","obj","__esModule","default","PanelContent","theme","onChange","themes","Object","values","CARBON_THEMES","createElement","Form","Field","label","Select","name","value","ev","target","size","map","option","key","exports","propTypes","PropTypes","func","string"],"sources":["../../src/components/PanelContent.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport React from 'react';\nimport { Form } from '@storybook/components';\nimport PropTypes from 'prop-types';\nimport { CARBON_THEMES } from '../constants';\n\nexport const PanelContent = ({ theme, onChange }) => {\n const themes = Object.values(CARBON_THEMES);\n\n return (\n <div>\n <Form>\n <Form.Field label=\"Select Carbon theme:\">\n <Form.Select\n name=\"carbon-theme\"\n value={theme}\n onChange={(ev) => {\n onChange && onChange(ev.target.value);\n }}\n size=\"flex\"\n >\n {themes.map((option) => (\n <option key={option} value={option}>\n {option}\n </option>\n ))}\n </Form.Select>\n </Form.Field>\n </Form>\n </div>\n );\n};\n\nPanelContent.propTypes = {\n onChange: PropTypes.func,\n theme: PropTypes.string,\n};\n"],"mappings":";;;;;;AAMA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAA6C,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAT7C;AACA;AACA;AACA;AACA;AACA;;AAMO,MAAMG,YAAY,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAS,CAAC,KAAK;EACnD,MAAMC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAACC,wBAAa,CAAC;EAE3C,oBACEf,MAAA,CAAAQ,OAAA,CAAAQ,aAAA,2BACEhB,MAAA,CAAAQ,OAAA,CAAAQ,aAAA,CAACb,WAAA,CAAAc,IAAI,qBACHjB,MAAA,CAAAQ,OAAA,CAAAQ,aAAA,CAACb,WAAA,CAAAc,IAAI,CAACC,KAAK;IAACC,KAAK,EAAC;EAAsB,gBACtCnB,MAAA,CAAAQ,OAAA,CAAAQ,aAAA,CAACb,WAAA,CAAAc,IAAI,CAACG,MAAM;IACVC,IAAI,EAAC,cAAc;IACnBC,KAAK,EAAEZ,KAAM;IACbC,QAAQ,EAAGY,EAAE,IAAK;MAChBZ,QAAQ,IAAIA,QAAQ,CAACY,EAAE,CAACC,MAAM,CAACF,KAAK,CAAC;IACvC,CAAE;IACFG,IAAI,EAAC;EAAM,GAEVb,MAAM,CAACc,GAAG,CAAEC,MAAM,iBACjB3B,MAAA,CAAAQ,OAAA,CAAAQ,aAAA;IAAQY,GAAG,EAAED,MAAO;IAACL,KAAK,EAAEK;EAAO,GAChCA,MACK,CACT,CACU,CACH,CACR,CACH,CAAC;AAEV,CAAC;AAACE,OAAA,CAAApB,YAAA,GAAAA,YAAA;AAEFA,YAAY,CAACqB,SAAS,GAAG;EACvBnB,QAAQ,EAAEoB,kBAAS,CAACC,IAAI;EACxBtB,KAAK,EAAEqB,kBAAS,CAACE;AACnB,CAAC"}
package/dist/constants.js CHANGED
@@ -1,17 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TOOL_ID = exports.PARAM_KEY = exports.PANEL_ID = exports.CARBON_THEMES = exports.ADDON_ID = void 0;
1
7
  /**
2
8
  * Copyright IBM Corp. 2023, 2023
3
9
  *
4
10
  * This source code is licensed under the Apache-2.0 license found in the
5
11
  * LICENSE file in the root directory of this source tree.
6
12
  */
7
- export const ADDON_ID = '@carbon/theme';
8
- export const PANEL_ID = `${ADDON_ID}/panel`;
9
- export const TOOL_ID = `${ADDON_ID}/tool`;
10
- export const PARAM_KEY = 'carbonTheme';
11
- export const CARBON_THEMES = {
13
+ const ADDON_ID = '@carbon/theme';
14
+ exports.ADDON_ID = ADDON_ID;
15
+ const PANEL_ID = `${ADDON_ID}/panel`;
16
+ exports.PANEL_ID = PANEL_ID;
17
+ const TOOL_ID = `${ADDON_ID}/tool`;
18
+ exports.TOOL_ID = TOOL_ID;
19
+ const PARAM_KEY = 'carbonTheme';
20
+ exports.PARAM_KEY = PARAM_KEY;
21
+ const CARBON_THEMES = {
12
22
  white: 'white',
13
23
  g10: 'g10',
14
24
  g90: 'g90',
15
25
  g100: 'g100'
16
26
  };
27
+ exports.CARBON_THEMES = CARBON_THEMES;
17
28
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["ADDON_ID","PANEL_ID","TOOL_ID","PARAM_KEY","CARBON_THEMES","white","g10","g90","g100"],"sources":["../src/constants.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nexport const ADDON_ID = '@carbon/theme';\nexport const PANEL_ID = `${ADDON_ID}/panel`;\nexport const TOOL_ID = `${ADDON_ID}/tool`;\nexport const PARAM_KEY = 'carbonTheme';\nexport const CARBON_THEMES = {\n white: 'white',\n g10: 'g10',\n g90: 'g90',\n g100: 'g100',\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAAG,eAAe;AACvC,OAAO,MAAMC,QAAQ,GAAI,GAAED,QAAS,QAAO;AAC3C,OAAO,MAAME,OAAO,GAAI,GAAEF,QAAS,OAAM;AACzC,OAAO,MAAMG,SAAS,GAAG,aAAa;AACtC,OAAO,MAAMC,aAAa,GAAG;EAC3BC,KAAK,EAAE,OAAO;EACdC,GAAG,EAAE,KAAK;EACVC,GAAG,EAAE,KAAK;EACVC,IAAI,EAAE;AACR,CAAC"}
1
+ {"version":3,"file":"constants.js","names":["ADDON_ID","exports","PANEL_ID","TOOL_ID","PARAM_KEY","CARBON_THEMES","white","g10","g90","g100"],"sources":["../src/constants.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nexport const ADDON_ID = '@carbon/theme';\nexport const PANEL_ID = `${ADDON_ID}/panel`;\nexport const TOOL_ID = `${ADDON_ID}/tool`;\nexport const PARAM_KEY = 'carbonTheme';\nexport const CARBON_THEMES = {\n white: 'white',\n g10: 'g10',\n g90: 'g90',\n g100: 'g100',\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAG,eAAe;AAACC,OAAA,CAAAD,QAAA,GAAAA,QAAA;AACjC,MAAME,QAAQ,GAAI,GAAEF,QAAS,QAAO;AAACC,OAAA,CAAAC,QAAA,GAAAA,QAAA;AACrC,MAAMC,OAAO,GAAI,GAAEH,QAAS,OAAM;AAACC,OAAA,CAAAE,OAAA,GAAAA,OAAA;AACnC,MAAMC,SAAS,GAAG,aAAa;AAACH,OAAA,CAAAG,SAAA,GAAAA,SAAA;AAChC,MAAMC,aAAa,GAAG;EAC3BC,KAAK,EAAE,OAAO;EACdC,GAAG,EAAE,KAAK;EACVC,GAAG,EAAE,KAAK;EACVC,IAAI,EAAE;AACR,CAAC;AAACR,OAAA,CAAAI,aAAA,GAAAA,aAAA"}
@@ -1,21 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withCarbonTheme = void 0;
7
+ var _previewApi = require("@storybook/preview-api");
8
+ var _constants = require("../constants");
1
9
  /**
2
10
  * Copyright IBM Corp. 2023, 2023
3
11
  *
4
12
  * This source code is licensed under the Apache-2.0 license found in the
5
13
  * LICENSE file in the root directory of this source tree.
6
14
  */
7
- import { useEffect } from '@storybook/preview-api';
8
- import { PARAM_KEY } from '../constants';
9
- export const withCarbonTheme = (StoryFn, context) => {
15
+
16
+ const withCarbonTheme = (StoryFn, context) => {
10
17
  const {
11
18
  globals,
12
19
  parameters
13
20
  } = context;
14
- const globalCarbonTheme = globals[PARAM_KEY];
15
- const storyCarbonTheme = parameters[PARAM_KEY];
21
+ const globalCarbonTheme = globals[_constants.PARAM_KEY];
22
+ const storyCarbonTheme = parameters[_constants.PARAM_KEY];
16
23
 
17
24
  // eslint-disable-next-line react-hooks/rules-of-hooks
18
- useEffect(() => {
25
+ (0, _previewApi.useEffect)(() => {
19
26
  const selector = context.viewMode === 'docs' ? `.sbdocs-preview .docs-story` : '.sb-show-main';
20
27
  const rootElements = document.querySelectorAll(selector);
21
28
  rootElements.forEach(rootElement => {
@@ -24,4 +31,5 @@ export const withCarbonTheme = (StoryFn, context) => {
24
31
  }, [context.id, context.viewMode, globalCarbonTheme, storyCarbonTheme]);
25
32
  return StoryFn();
26
33
  };
34
+ exports.withCarbonTheme = withCarbonTheme;
27
35
  //# sourceMappingURL=withCarbonTheme.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withCarbonTheme.js","names":["useEffect","PARAM_KEY","withCarbonTheme","StoryFn","context","globals","parameters","globalCarbonTheme","storyCarbonTheme","selector","viewMode","rootElements","document","querySelectorAll","forEach","rootElement","setAttribute","id"],"sources":["../../src/decorators/withCarbonTheme.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { useEffect } from '@storybook/preview-api';\nimport { PARAM_KEY } from '../constants';\n\nexport const withCarbonTheme = (StoryFn, context) => {\n const { globals, parameters } = context;\n\n const globalCarbonTheme = globals[PARAM_KEY];\n const storyCarbonTheme = parameters[PARAM_KEY];\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n const selector =\n context.viewMode === 'docs'\n ? `.sbdocs-preview .docs-story`\n : '.sb-show-main';\n\n const rootElements = document.querySelectorAll(selector);\n rootElements.forEach((rootElement) => {\n rootElement.setAttribute(\n 'storybook-carbon-theme',\n globalCarbonTheme ?? storyCarbonTheme\n );\n });\n }, [context.id, context.viewMode, globalCarbonTheme, storyCarbonTheme]);\n\n return StoryFn();\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,wBAAwB;AAClD,SAASC,SAAS,QAAQ,cAAc;AAExC,OAAO,MAAMC,eAAe,GAAGA,CAACC,OAAO,EAAEC,OAAO,KAAK;EACnD,MAAM;IAAEC,OAAO;IAAEC;EAAW,CAAC,GAAGF,OAAO;EAEvC,MAAMG,iBAAiB,GAAGF,OAAO,CAACJ,SAAS,CAAC;EAC5C,MAAMO,gBAAgB,GAAGF,UAAU,CAACL,SAAS,CAAC;;EAE9C;EACAD,SAAS,CAAC,MAAM;IACd,MAAMS,QAAQ,GACZL,OAAO,CAACM,QAAQ,KAAK,MAAM,GACtB,6BAA4B,GAC7B,eAAe;IAErB,MAAMC,YAAY,GAAGC,QAAQ,CAACC,gBAAgB,CAACJ,QAAQ,CAAC;IACxDE,YAAY,CAACG,OAAO,CAAEC,WAAW,IAAK;MACpCA,WAAW,CAACC,YAAY,CACtB,wBAAwB,EACxBT,iBAAiB,IAAIC,gBACvB,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,EAAE,CAACJ,OAAO,CAACa,EAAE,EAAEb,OAAO,CAACM,QAAQ,EAAEH,iBAAiB,EAAEC,gBAAgB,CAAC,CAAC;EAEvE,OAAOL,OAAO,CAAC,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"withCarbonTheme.js","names":["_previewApi","require","_constants","withCarbonTheme","StoryFn","context","globals","parameters","globalCarbonTheme","PARAM_KEY","storyCarbonTheme","useEffect","selector","viewMode","rootElements","document","querySelectorAll","forEach","rootElement","setAttribute","id","exports"],"sources":["../../src/decorators/withCarbonTheme.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { useEffect } from '@storybook/preview-api';\nimport { PARAM_KEY } from '../constants';\n\nexport const withCarbonTheme = (StoryFn, context) => {\n const { globals, parameters } = context;\n\n const globalCarbonTheme = globals[PARAM_KEY];\n const storyCarbonTheme = parameters[PARAM_KEY];\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n const selector =\n context.viewMode === 'docs'\n ? `.sbdocs-preview .docs-story`\n : '.sb-show-main';\n\n const rootElements = document.querySelectorAll(selector);\n rootElements.forEach((rootElement) => {\n rootElement.setAttribute(\n 'storybook-carbon-theme',\n globalCarbonTheme ?? storyCarbonTheme\n );\n });\n }, [context.id, context.viewMode, globalCarbonTheme, storyCarbonTheme]);\n\n return StoryFn();\n};\n"],"mappings":";;;;;;AAMA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAPA;AACA;AACA;AACA;AACA;AACA;;AAIO,MAAME,eAAe,GAAGA,CAACC,OAAO,EAAEC,OAAO,KAAK;EACnD,MAAM;IAAEC,OAAO;IAAEC;EAAW,CAAC,GAAGF,OAAO;EAEvC,MAAMG,iBAAiB,GAAGF,OAAO,CAACG,oBAAS,CAAC;EAC5C,MAAMC,gBAAgB,GAAGH,UAAU,CAACE,oBAAS,CAAC;;EAE9C;EACA,IAAAE,qBAAS,EAAC,MAAM;IACd,MAAMC,QAAQ,GACZP,OAAO,CAACQ,QAAQ,KAAK,MAAM,GACtB,6BAA4B,GAC7B,eAAe;IAErB,MAAMC,YAAY,GAAGC,QAAQ,CAACC,gBAAgB,CAACJ,QAAQ,CAAC;IACxDE,YAAY,CAACG,OAAO,CAAEC,WAAW,IAAK;MACpCA,WAAW,CAACC,YAAY,CACtB,wBAAwB,EACxBX,iBAAiB,IAAIE,gBACvB,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,EAAE,CAACL,OAAO,CAACe,EAAE,EAAEf,OAAO,CAACQ,QAAQ,EAAEL,iBAAiB,EAAEE,gBAAgB,CAAC,CAAC;EAEvE,OAAON,OAAO,CAAC,CAAC;AAClB,CAAC;AAACiB,OAAA,CAAAlB,eAAA,GAAAA,eAAA"}
package/dist/manager.js CHANGED
@@ -1,18 +1,21 @@
1
+ "use strict";
2
+
3
+ var _managerApi = require("@storybook/manager-api");
4
+ var _Panel = require("./Panel");
1
5
  /**
2
6
  * Copyright IBM Corp. 2023, 2023
3
7
  *
4
8
  * This source code is licensed under the Apache-2.0 license found in the
5
9
  * LICENSE file in the root directory of this source tree.
6
10
  */
7
- import { addons, types } from '@storybook/manager-api';
8
- import { Panel } from './Panel';
11
+
9
12
  const ADDON_ID = 'carbonTheme';
10
13
  const PANEL_ID = `${ADDON_ID}/panel`;
11
- addons.register(ADDON_ID, () => {
12
- addons.add(PANEL_ID, {
13
- type: types.PANEL,
14
+ _managerApi.addons.register(ADDON_ID, () => {
15
+ _managerApi.addons.add(PANEL_ID, {
16
+ type: _managerApi.types.PANEL,
14
17
  title: 'Carbon Theme',
15
- render: Panel
18
+ render: _Panel.Panel
16
19
  });
17
20
  });
18
21
  //# sourceMappingURL=manager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"manager.js","names":["addons","types","Panel","ADDON_ID","PANEL_ID","register","add","type","PANEL","title","render"],"sources":["../src/manager.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { addons, types } from '@storybook/manager-api';\n\nimport { Panel } from './Panel';\n\nconst ADDON_ID = 'carbonTheme';\nconst PANEL_ID = `${ADDON_ID}/panel`;\n\naddons.register(ADDON_ID, () => {\n addons.add(PANEL_ID, {\n type: types.PANEL,\n title: 'Carbon Theme',\n render: Panel,\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,KAAK,QAAQ,wBAAwB;AAEtD,SAASC,KAAK,QAAQ,SAAS;AAE/B,MAAMC,QAAQ,GAAG,aAAa;AAC9B,MAAMC,QAAQ,GAAI,GAAED,QAAS,QAAO;AAEpCH,MAAM,CAACK,QAAQ,CAACF,QAAQ,EAAE,MAAM;EAC9BH,MAAM,CAACM,GAAG,CAACF,QAAQ,EAAE;IACnBG,IAAI,EAAEN,KAAK,CAACO,KAAK;IACjBC,KAAK,EAAE,cAAc;IACrBC,MAAM,EAAER;EACV,CAAC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"manager.js","names":["_managerApi","require","_Panel","ADDON_ID","PANEL_ID","addons","register","add","type","types","PANEL","title","render","Panel"],"sources":["../src/manager.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { addons, types } from '@storybook/manager-api';\n\nimport { Panel } from './Panel';\n\nconst ADDON_ID = 'carbonTheme';\nconst PANEL_ID = `${ADDON_ID}/panel`;\n\naddons.register(ADDON_ID, () => {\n addons.add(PANEL_ID, {\n type: types.PANEL,\n title: 'Carbon Theme',\n render: Panel,\n });\n});\n"],"mappings":";;AAMA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;;AAKA,MAAME,QAAQ,GAAG,aAAa;AAC9B,MAAMC,QAAQ,GAAI,GAAED,QAAS,QAAO;AAEpCE,kBAAM,CAACC,QAAQ,CAACH,QAAQ,EAAE,MAAM;EAC9BE,kBAAM,CAACE,GAAG,CAACH,QAAQ,EAAE;IACnBI,IAAI,EAAEC,iBAAK,CAACC,KAAK;IACjBC,KAAK,EAAE,cAAc;IACrBC,MAAM,EAAEC;EACV,CAAC,CAAC;AACJ,CAAC,CAAC"}
package/dist/preset.js CHANGED
@@ -1,3 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
1
7
  /**
2
8
  * Copyright IBM Corp. 2023, 2023
3
9
  *
@@ -7,8 +13,8 @@
7
13
  function managerEntries(entry = []) {
8
14
  return [...entry, require.resolve('./manager')]; //👈 Addon implementation
9
15
  }
10
-
11
- export default {
16
+ var _default = {
12
17
  managerEntries
13
18
  };
19
+ exports.default = _default;
14
20
  //# sourceMappingURL=preset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preset.js","names":["managerEntries","entry","require","resolve"],"sources":["../src/preset.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nfunction managerEntries(entry = []) {\n return [...entry, require.resolve('./manager')]; //👈 Addon implementation\n}\n\nexport default { managerEntries };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,cAAcA,CAACC,KAAK,GAAG,EAAE,EAAE;EAClC,OAAO,CAAC,GAAGA,KAAK,EAAEC,OAAO,CAACC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AACnD;;AAEA,eAAe;EAAEH;AAAe,CAAC"}
1
+ {"version":3,"file":"preset.js","names":["managerEntries","entry","require","resolve","_default","exports","default"],"sources":["../src/preset.js"],"sourcesContent":["/**\n * Copyright IBM Corp. 2023, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\nfunction managerEntries(entry = []) {\n return [...entry, require.resolve('./manager')]; //👈 Addon implementation\n}\n\nexport default { managerEntries };\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,cAAcA,CAACC,KAAK,GAAG,EAAE,EAAE;EAClC,OAAO,CAAC,GAAGA,KAAK,EAAEC,OAAO,CAACC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AACnD;AAAC,IAAAC,QAAA,GAEc;EAAEJ;AAAe,CAAC;AAAAK,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/storybook-addon-theme",
3
3
  "description": "Carbon theme switcher for Storybook",
4
- "version": "2.0.4",
4
+ "version": "2.0.5",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/react.js",
7
7
  "repository": {
@@ -60,5 +60,5 @@
60
60
  "npm-run-all": "^4.1.5",
61
61
  "rimraf": "^5.0.1"
62
62
  },
63
- "gitHead": "d16309a4cb6cc8d75c12335695015fc272752f36"
63
+ "gitHead": "3379b9af8e581eb50ec510e8a81248b4ec6d439d"
64
64
  }