storybook-addon-pseudo-states 10.1.0-alpha.0 → 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.
- package/dist/manager.js +24 -45
- 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
|
|
14
|
-
import {
|
|
15
|
-
import { ButtonIcon
|
|
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
|
-
|
|
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
|
|
25
|
-
|
|
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
|
|
50
|
-
const active = isActive(option);
|
|
23
|
+
const options = pseudoStates.map((option) => {
|
|
51
24
|
return {
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
30
|
+
Select,
|
|
60
31
|
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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.
|
|
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.
|
|
64
|
+
"storybook": "^10.1.0-alpha.10"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|