carbon-react 111.22.0 → 111.22.1

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.
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare function partialAction(actionName: string): (eventObj?: string | React.SyntheticEvent<Element, Event> | undefined, ...args: string[]) => void;
3
+ export default partialAction;
@@ -0,0 +1,13 @@
1
+ import { action } from "@storybook/addon-actions";
2
+
3
+ function partialAction(actionName) {
4
+ return (eventObj, ...args) => {
5
+ action(actionName)(typeof eventObj === "string" ? {
6
+ view: undefined
7
+ } : { ...eventObj,
8
+ view: undefined
9
+ }, ...args);
10
+ };
11
+ }
12
+
13
+ export default partialAction;
@@ -28,26 +28,20 @@ const Tab = ({
28
28
  const [tabWarnings, setTabWarnings] = useState({});
29
29
  const [tabInfos, setTabInfos] = useState({});
30
30
  const setError = useCallback((childId, error) => {
31
- if (tabErrors[childId] !== error) {
32
- setTabErrors({ ...tabErrors,
33
- [childId]: error
34
- });
35
- }
36
- }, [tabErrors]);
31
+ setTabErrors(state => state[childId] !== error ? { ...state,
32
+ [childId]: error
33
+ } : state);
34
+ }, []);
37
35
  const setWarning = useCallback((childId, warning) => {
38
- if (tabWarnings[childId] !== warning) {
39
- setTabWarnings({ ...tabWarnings,
40
- [childId]: warning
41
- });
42
- }
43
- }, [tabWarnings]);
36
+ setTabWarnings(state => state[childId] !== warning ? { ...state,
37
+ [childId]: warning
38
+ } : state);
39
+ }, []);
44
40
  const setInfo = useCallback((childId, info) => {
45
- if (tabInfos[childId] !== info) {
46
- setTabInfos({ ...tabInfos,
47
- [childId]: info
48
- });
49
- }
50
- }, [tabInfos]);
41
+ setTabInfos(state => state[childId] !== info ? { ...state,
42
+ [childId]: info
43
+ } : state);
44
+ }, []);
51
45
  useEffect(() => {
52
46
  if (updateErrors) {
53
47
  updateErrors(tabId, tabErrors);
@@ -50,26 +50,20 @@ const Tabs = ({
50
50
  const [tabsWarnings, setTabsWarnings] = useState({});
51
51
  const [tabsInfos, setTabsInfos] = useState({});
52
52
  const updateErrors = useCallback((id, error) => {
53
- if (tabsErrors[id] !== error) {
54
- setTabsErrors({ ...tabsErrors,
55
- [id]: error
56
- });
57
- }
58
- }, [tabsErrors]);
53
+ setTabsErrors(state => ({ ...state,
54
+ [id]: error
55
+ }));
56
+ }, []);
59
57
  const updateWarnings = useCallback((id, warning) => {
60
- if (tabsWarnings[id] !== warning) {
61
- setTabsWarnings({ ...tabsWarnings,
62
- [id]: warning
63
- });
64
- }
65
- }, [tabsWarnings]);
58
+ setTabsWarnings(state => ({ ...state,
59
+ [id]: warning
60
+ }));
61
+ }, []);
66
62
  const updateInfos = useCallback((id, info) => {
67
- if (tabsInfos[id] !== info) {
68
- setTabsInfos({ ...tabsInfos,
69
- [id]: info
70
- });
71
- }
72
- }, [tabsInfos]);
63
+ setTabsInfos(state => ({ ...state,
64
+ [id]: info
65
+ }));
66
+ }, []);
73
67
  /** Returns true/false for if the given tab id is selected. */
74
68
 
75
69
  const isTabSelected = useCallback(tabId => tabId === selectedTabIdState, [selectedTabIdState]);
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare function partialAction(actionName: string): (eventObj?: string | React.SyntheticEvent<Element, Event> | undefined, ...args: string[]) => void;
3
+ export default partialAction;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _addonActions = require("@storybook/addon-actions");
9
+
10
+ function partialAction(actionName) {
11
+ return (eventObj, ...args) => {
12
+ (0, _addonActions.action)(actionName)(typeof eventObj === "string" ? {
13
+ view: undefined
14
+ } : { ...eventObj,
15
+ view: undefined
16
+ }, ...args);
17
+ };
18
+ }
19
+
20
+ var _default = partialAction;
21
+ exports.default = _default;
@@ -49,26 +49,20 @@ const Tab = ({
49
49
  const [tabWarnings, setTabWarnings] = (0, _react.useState)({});
50
50
  const [tabInfos, setTabInfos] = (0, _react.useState)({});
51
51
  const setError = (0, _react.useCallback)((childId, error) => {
52
- if (tabErrors[childId] !== error) {
53
- setTabErrors({ ...tabErrors,
54
- [childId]: error
55
- });
56
- }
57
- }, [tabErrors]);
52
+ setTabErrors(state => state[childId] !== error ? { ...state,
53
+ [childId]: error
54
+ } : state);
55
+ }, []);
58
56
  const setWarning = (0, _react.useCallback)((childId, warning) => {
59
- if (tabWarnings[childId] !== warning) {
60
- setTabWarnings({ ...tabWarnings,
61
- [childId]: warning
62
- });
63
- }
64
- }, [tabWarnings]);
57
+ setTabWarnings(state => state[childId] !== warning ? { ...state,
58
+ [childId]: warning
59
+ } : state);
60
+ }, []);
65
61
  const setInfo = (0, _react.useCallback)((childId, info) => {
66
- if (tabInfos[childId] !== info) {
67
- setTabInfos({ ...tabInfos,
68
- [childId]: info
69
- });
70
- }
71
- }, [tabInfos]);
62
+ setTabInfos(state => state[childId] !== info ? { ...state,
63
+ [childId]: info
64
+ } : state);
65
+ }, []);
72
66
  (0, _react.useEffect)(() => {
73
67
  if (updateErrors) {
74
68
  updateErrors(tabId, tabErrors);
@@ -80,26 +80,20 @@ const Tabs = ({
80
80
  const [tabsWarnings, setTabsWarnings] = (0, _react.useState)({});
81
81
  const [tabsInfos, setTabsInfos] = (0, _react.useState)({});
82
82
  const updateErrors = (0, _react.useCallback)((id, error) => {
83
- if (tabsErrors[id] !== error) {
84
- setTabsErrors({ ...tabsErrors,
85
- [id]: error
86
- });
87
- }
88
- }, [tabsErrors]);
83
+ setTabsErrors(state => ({ ...state,
84
+ [id]: error
85
+ }));
86
+ }, []);
89
87
  const updateWarnings = (0, _react.useCallback)((id, warning) => {
90
- if (tabsWarnings[id] !== warning) {
91
- setTabsWarnings({ ...tabsWarnings,
92
- [id]: warning
93
- });
94
- }
95
- }, [tabsWarnings]);
88
+ setTabsWarnings(state => ({ ...state,
89
+ [id]: warning
90
+ }));
91
+ }, []);
96
92
  const updateInfos = (0, _react.useCallback)((id, info) => {
97
- if (tabsInfos[id] !== info) {
98
- setTabsInfos({ ...tabsInfos,
99
- [id]: info
100
- });
101
- }
102
- }, [tabsInfos]);
93
+ setTabsInfos(state => ({ ...state,
94
+ [id]: info
95
+ }));
96
+ }, []);
103
97
  /** Returns true/false for if the given tab id is selected. */
104
98
 
105
99
  const isTabSelected = (0, _react.useCallback)(tabId => tabId === selectedTabIdState, [selectedTabIdState]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "111.22.0",
3
+ "version": "111.22.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",