storybook-addon-pseudo-states 1.9.0 → 1.12.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/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- # v1.0.0 (Wed Apr 06 2022)
1
+ # v1.0.0 (Mon May 23 2022)
2
2
 
3
3
  #### 🚀 Enhancement
4
4
 
@@ -7,12 +7,15 @@
7
7
 
8
8
  #### 🐛 Bug Fix
9
9
 
10
+ - fix: Resolve crash for stories that use internal State [#28](https://github.com/chromaui/storybook-addon-pseudo-states/pull/28) (david.maulick@coinbase.com)
10
11
  - Fix CSS selector splitting [#24](https://github.com/chromaui/storybook-addon-pseudo-states/pull/24) ([@ilanus](https://github.com/ilanus) [@ghengeveld](https://github.com/ghengeveld))
11
12
  - Add support for slotted lit elements [#23](https://github.com/chromaui/storybook-addon-pseudo-states/pull/23) ([@ilanus](https://github.com/ilanus))
12
13
  - Setup auto [#7](https://github.com/chromaui/storybook-addon-pseudo-states/pull/7) ([@ghengeveld](https://github.com/ghengeveld))
13
14
 
14
15
  #### ⚠️ Pushed to `main`
15
16
 
17
+ - Use personal access token to be able to push to main ([@ghengeveld](https://github.com/ghengeveld))
18
+ - Use chromatic@next ([@ghengeveld](https://github.com/ghengeveld))
16
19
  - [skip release] Revert back to disabling CustomElement stories ([@ghengeveld](https://github.com/ghengeveld))
17
20
  - Another attempt at dealing with IE ([@ghengeveld](https://github.com/ghengeveld))
18
21
  - Don't disable stories, just ignore IE ([@ghengeveld](https://github.com/ghengeveld))
@@ -24,8 +27,9 @@
24
27
  - Upgrade Storybook ([@ghengeveld](https://github.com/ghengeveld))
25
28
  - Ignore .env file ([@ghengeveld](https://github.com/ghengeveld))
26
29
 
27
- #### Authors: 3
30
+ #### Authors: 4
28
31
 
32
+ - David Maulick ([@dmaulick](https://github.com/dmaulick))
29
33
  - Gert Hengeveld ([@ghengeveld](https://github.com/ghengeveld))
30
34
  - Ilan ([@ilanus](https://github.com/ilanus))
31
35
  - Jeroen Zwartepoorte ([@jpzwarte](https://github.com/jpzwarte))
@@ -97,20 +97,23 @@ _addons.addons.getChannel().on(_coreEvents.STORY_CHANGED, function () {
97
97
  var withPseudoState = function withPseudoState(StoryFn, _ref5) {
98
98
  var viewMode = _ref5.viewMode,
99
99
  parameters = _ref5.parameters,
100
- id = _ref5.id;
100
+ id = _ref5.id,
101
+ globalsArgs = _ref5.globals;
101
102
  var parameter = parameters.pseudo;
103
+ var globals = globalsArgs.pseudo;
102
104
 
103
- var _useGlobals = (0, _addons.useGlobals)(),
104
- _useGlobals2 = _slicedToArray(_useGlobals, 2),
105
- globals = _useGlobals2[0].pseudo,
106
- updateGlobals = _useGlobals2[1]; // Sync parameter to globals, used by the toolbar (only in canvas as this
105
+ var channel = _addons.addons.getChannel(); // Sync parameter to globals, used by the toolbar (only in canvas as this
107
106
  // doesn't make sense for docs because many stories are displayed at once)
108
107
 
109
108
 
110
109
  (0, _addons.useEffect)(function () {
111
- if (parameter !== globals && viewMode === "story") updateGlobals({
112
- pseudo: parameter
113
- });
110
+ if (parameter !== globals && viewMode === "story") {
111
+ channel.emit(_coreEvents.UPDATE_GLOBALS, {
112
+ globals: {
113
+ pseudo: parameter
114
+ }
115
+ });
116
+ }
114
117
  }, [parameter, viewMode]); // Convert selected states to classnames and apply them to the story root element.
115
118
  // Then update each shadow host to redetermine its own pseudo classnames.
116
119
 
@@ -27,8 +27,9 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
27
27
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
28
28
 
29
29
  /* eslint-env browser */
30
- import { addons, useEffect, useGlobals } from "@storybook/addons";
30
+ import { addons, useEffect } from "@storybook/addons";
31
31
  import { DOCS_RENDERED, STORY_CHANGED, STORY_RENDERED } from "@storybook/core-events";
32
+ import { UPDATE_GLOBALS } from '@storybook/core-events';
32
33
  import { PSEUDO_STATES } from "./constants";
33
34
  import { splitSelectors } from "./splitSelectors";
34
35
  var pseudoStates = Object.values(PSEUDO_STATES);
@@ -85,20 +86,21 @@ addons.getChannel().on(STORY_CHANGED, function () {
85
86
  export var withPseudoState = function withPseudoState(StoryFn, _ref5) {
86
87
  var viewMode = _ref5.viewMode,
87
88
  parameters = _ref5.parameters,
88
- id = _ref5.id;
89
+ id = _ref5.id,
90
+ globalsArgs = _ref5.globals;
89
91
  var parameter = parameters.pseudo;
90
-
91
- var _useGlobals = useGlobals(),
92
- _useGlobals2 = _slicedToArray(_useGlobals, 2),
93
- globals = _useGlobals2[0].pseudo,
94
- updateGlobals = _useGlobals2[1]; // Sync parameter to globals, used by the toolbar (only in canvas as this
92
+ var globals = globalsArgs.pseudo;
93
+ var channel = addons.getChannel(); // Sync parameter to globals, used by the toolbar (only in canvas as this
95
94
  // doesn't make sense for docs because many stories are displayed at once)
96
95
 
97
-
98
96
  useEffect(function () {
99
- if (parameter !== globals && viewMode === "story") updateGlobals({
100
- pseudo: parameter
101
- });
97
+ if (parameter !== globals && viewMode === "story") {
98
+ channel.emit(UPDATE_GLOBALS, {
99
+ globals: {
100
+ pseudo: parameter
101
+ }
102
+ });
103
+ }
102
104
  }, [parameter, viewMode]); // Convert selected states to classnames and apply them to the story root element.
103
105
  // Then update each shadow host to redetermine its own pseudo classnames.
104
106
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-addon-pseudo-states",
3
- "version": "1.9.0",
3
+ "version": "1.12.0",
4
4
  "description": "CSS pseudo states for Storybook",
5
5
  "keywords": [
6
6
  "storybook-addons",