storybook-addon-pseudo-states 10.1.0-alpha.1 → 10.1.0-alpha.10

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.
Files changed (2) hide show
  1. package/dist/manager.js +24 -45
  2. package/package.json +2 -2
package/dist/manager.js CHANGED
@@ -10,60 +10,39 @@ import {
10
10
  import { addons, types } from "storybook/manager-api";
11
11
 
12
12
  // src/manager/PseudoStateTool.tsx
13
- import React, { useCallback } from "react";
14
- import { Form, IconButton, TooltipLinkList, WithTooltip } from "storybook/internal/components";
15
- import { ButtonIcon, RefreshIcon } from "@storybook/icons";
13
+ import React from "react";
14
+ import { Select } from "storybook/internal/components";
15
+ import { ButtonIcon } from "@storybook/icons";
16
16
  import { useGlobals } from "storybook/manager-api";
17
- import { color, styled } from "storybook/theming";
18
- var LinkTitle = styled.span(({ active }) => ({
19
- color: active ? color.secondary : "inherit"
20
- }));
21
- var options = Object.keys(PSEUDO_STATES).sort();
17
+ var pseudoStates = Object.keys(PSEUDO_STATES).sort();
22
18
  var PseudoStateTool = /* @__PURE__ */ __name(() => {
23
19
  const [globals, updateGlobals] = useGlobals();
24
- const pseudo = globals[PARAM_KEY];
25
- const isActive = useCallback(
26
- (option) => {
27
- if (!pseudo) {
28
- return false;
29
- }
30
- return pseudo[option] === true;
31
- },
32
- [pseudo]
33
- );
34
- const hasActive = options.some(isActive);
35
- const reset = {
36
- id: "reset",
37
- title: "Reset pseudo states",
38
- icon: React.createElement(RefreshIcon, { style: { opacity: hasActive ? 1 : 0.7 } }),
39
- disabled: !hasActive,
40
- onClick: /* @__PURE__ */ __name(() => updateGlobals({ [PARAM_KEY]: {} }), "onClick")
41
- };
42
- const toggleOption = useCallback(
43
- (option) => () => {
44
- const { [option]: value, ...rest } = pseudo;
45
- updateGlobals({ [PARAM_KEY]: value === true ? rest : { ...rest, [option]: true } });
46
- },
47
- [pseudo, updateGlobals]
20
+ const defaultOptions = Object.keys(globals[PARAM_KEY] || {}).filter(
21
+ (key) => pseudoStates.includes(key)
48
22
  );
49
- const links = options.map((option) => {
50
- const active = isActive(option);
23
+ const options = pseudoStates.map((option) => {
51
24
  return {
52
- id: option,
53
- title: React.createElement(LinkTitle, { active }, ":", PSEUDO_STATES[option]),
54
- input: React.createElement(Form.Checkbox, { checked: active, onChange: toggleOption(option) }),
55
- active
25
+ title: `:${PSEUDO_STATES[option]}`,
26
+ value: option
56
27
  };
57
28
  });
58
29
  return React.createElement(
59
- WithTooltip,
30
+ Select,
60
31
  {
61
- placement: "top",
62
- trigger: "click",
63
- closeOnOutsideClick: true,
64
- tooltip: React.createElement(TooltipLinkList, { links: [[reset], links] })
65
- },
66
- React.createElement(IconButton, { key: "pseudo-states", title: "Select CSS pseudo states", active: hasActive }, React.createElement(ButtonIcon, null))
32
+ resetLabel: "Reset pseudo states",
33
+ onReset: () => updateGlobals({ [PARAM_KEY]: {} }),
34
+ icon: React.createElement(ButtonIcon, null),
35
+ ariaLabel: "CSS pseudo states",
36
+ tooltip: "Apply CSS pseudo states",
37
+ defaultOptions,
38
+ options,
39
+ multiSelect: true,
40
+ onChange: (selected) => {
41
+ updateGlobals({
42
+ [PARAM_KEY]: selected.reduce((acc, curr) => ({ ...acc, [curr]: true }), {})
43
+ });
44
+ }
45
+ }
67
46
  );
68
47
  }, "PseudoStateTool");
69
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-addon-pseudo-states",
3
- "version": "10.1.0-alpha.1",
3
+ "version": "10.1.0-alpha.10",
4
4
  "description": "Storybook Pseudo-states addon: Manipulate CSS pseudo states",
5
5
  "keywords": [
6
6
  "storybook",
@@ -61,7 +61,7 @@
61
61
  "typescript": "^5.8.3"
62
62
  },
63
63
  "peerDependencies": {
64
- "storybook": "^10.1.0-alpha.1"
64
+ "storybook": "^10.1.0-alpha.10"
65
65
  },
66
66
  "publishConfig": {
67
67
  "access": "public"