@kaizen/components 1.74.3 → 1.75.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.
Files changed (32) hide show
  1. package/bin/codemod.sh +1 -0
  2. package/codemods/README.md +6 -0
  3. package/codemods/migrateGuidanceBlockActionsToActionsSlot/index.ts +21 -0
  4. package/codemods/migrateGuidanceBlockActionsToActionsSlot/migrateGuidanceBlockActionsToActionsSlot.spec.ts +122 -0
  5. package/codemods/migrateGuidanceBlockActionsToActionsSlot/migrateGuidanceBlockActionsToActionsSlot.ts +102 -0
  6. package/codemods/migrateGuidanceBlockActionsToActionsSlot/transformActionsToActionsSlot.spec.ts +196 -0
  7. package/codemods/migrateGuidanceBlockActionsToActionsSlot/transformActionsToActionsSlot.ts +71 -0
  8. package/codemods/utils/createProp.ts +1 -1
  9. package/codemods/utils/index.ts +1 -0
  10. package/codemods/utils/transformV1ButtonPropsToButtonOrLinkButton.spec.tsx +199 -0
  11. package/codemods/utils/transformV1ButtonPropsToButtonOrLinkButton.ts +195 -0
  12. package/dist/cjs/GuidanceBlock/GuidanceBlock.cjs +49 -84
  13. package/dist/cjs/GuidanceBlock/GuidanceBlock.module.css.cjs +0 -2
  14. package/dist/esm/GuidanceBlock/GuidanceBlock.mjs +50 -84
  15. package/dist/esm/GuidanceBlock/GuidanceBlock.module.css.mjs +0 -2
  16. package/dist/styles.css +1117 -1126
  17. package/dist/types/GuidanceBlock/GuidanceBlock.d.ts +8 -4
  18. package/package.json +4 -5
  19. package/src/GuidanceBlock/GuidanceBlock.module.css +0 -9
  20. package/src/GuidanceBlock/GuidanceBlock.tsx +48 -87
  21. package/src/GuidanceBlock/_docs/GuidanceBlock--migration-guide.mdx +77 -0
  22. package/src/GuidanceBlock/_docs/GuidanceBlock.mdx +35 -6
  23. package/src/GuidanceBlock/_docs/GuidanceBlock.stickersheet.stories.tsx +60 -27
  24. package/src/GuidanceBlock/_docs/GuidanceBlock.stories.tsx +205 -4
  25. package/src/Notification/InlineNotification/_docs/InlineNotification.stories.tsx +1 -0
  26. package/src/Workflow/_docs/ProgressStepper.stickersheet.stories.tsx +1 -1
  27. package/src/Workflow/_docs/ProgressStepper.stories.tsx +1 -1
  28. package/src/Workflow/_docs/Workflow.stories.tsx +1 -1
  29. package/src/Workflow/_docs/WorkflowFooter.stories.tsx +1 -1
  30. package/src/Workflow/_docs/WorkflowHeader.stories.tsx +1 -1
  31. package/src/__next__/Button/_docs/Button--migration-guide.mdx +3 -3
  32. package/src/__next__/Tag/Tag/_docs/Tag.stories.tsx +10 -0
@@ -1,14 +1,14 @@
1
1
  import { __rest, __assign } from 'tslib';
2
- import React, { useState, useEffect } from 'react';
2
+ import React, { useState } from 'react';
3
3
  import classnames from 'classnames';
4
- import Media from 'react-media';
5
4
  import { Button } from '../Button/Button/Button.mjs';
6
5
  import '../Button/IconButton/IconButton.mjs';
7
6
  import { Heading } from '../Heading/Heading.mjs';
8
7
  import { Text } from '../Text/Text.mjs';
9
8
  import { Tooltip } from '../Tooltip/Tooltip.mjs';
10
- import { Icon } from '../__next__/Icon/Icon.mjs';
9
+ import { useMediaQueries } from '../utils/useMediaQueries.mjs';
11
10
  import styles from './GuidanceBlock.module.css.mjs';
11
+ import { Icon } from '../__next__/Icon/Icon.mjs';
12
12
  var WithTooltip = function (_a) {
13
13
  var tooltipProps = _a.tooltipProps,
14
14
  children = _a.children;
@@ -20,40 +20,32 @@ var WithTooltip = function (_a) {
20
20
  */
21
21
  const GuidanceBlock = /*#__PURE__*/function () {
22
22
  const GuidanceBlock = function (_a) {
23
- var _b, _c, _d, _e;
24
- var _f = _a.layout,
25
- layout = _f === void 0 ? 'default' : _f,
26
- _g = _a.variant,
27
- variant = _g === void 0 ? 'default' : _g,
28
- _h = _a.withActionButtonArrow,
29
- withActionButtonArrow = _h === void 0 ? true : _h,
30
- _j = _a.noMaxWidth,
31
- noMaxWidth = _j === void 0 ? false : _j,
32
- _k = _a.illustrationType,
33
- illustrationType = _k === void 0 ? 'spot' : _k,
34
- _l = _a.smallScreenTextAlignment,
35
- smallScreenTextAlignment = _l === void 0 ? 'center' : _l,
23
+ var _b, _c, _d, _e, _f;
24
+ var _g = _a.layout,
25
+ layout = _g === void 0 ? 'default' : _g,
26
+ _h = _a.variant,
27
+ variant = _h === void 0 ? 'default' : _h,
28
+ _j = _a.withActionButtonArrow,
29
+ withActionButtonArrow = _j === void 0 ? true : _j,
30
+ _k = _a.noMaxWidth,
31
+ noMaxWidth = _k === void 0 ? false : _k,
32
+ _l = _a.illustrationType,
33
+ illustrationType = _l === void 0 ? 'spot' : _l,
34
+ _m = _a.smallScreenTextAlignment,
35
+ smallScreenTextAlignment = _m === void 0 ? 'center' : _m,
36
36
  actions = _a.actions,
37
37
  illustration = _a.illustration,
38
38
  secondaryDismiss = _a.secondaryDismiss,
39
- restProps = __rest(_a, ["layout", "variant", "withActionButtonArrow", "noMaxWidth", "illustrationType", "smallScreenTextAlignment", "actions", "illustration", "secondaryDismiss"]);
40
- var _m = useState(false),
41
- hidden = _m[0],
42
- setHidden = _m[1];
39
+ actionsSlot = _a.actionsSlot,
40
+ restProps = __rest(_a, ["layout", "variant", "withActionButtonArrow", "noMaxWidth", "illustrationType", "smallScreenTextAlignment", "actions", "illustration", "secondaryDismiss", "actionsSlot"]);
43
41
  var _o = useState(false),
44
- removed = _o[0],
45
- setRemoved = _o[1];
46
- var _p = useState(''),
47
- mediaQueryLayout = _p[0],
48
- setMediaQueryLayout = _p[1];
42
+ hidden = _o[0],
43
+ setHidden = _o[1];
44
+ var _p = useState(false),
45
+ removed = _p[0],
46
+ setRemoved = _p[1];
47
+ var queries = useMediaQueries().queries;
49
48
  var containerRef = /*#__PURE__*/React.createRef();
50
- useEffect(function () {
51
- if (layout === 'inline' || layout === 'stacked') {
52
- containerQuery();
53
- }
54
- // @todo: Fix if possible - avoiding breaking in eslint upgrade
55
- // eslint-disable-next-line react-hooks/exhaustive-deps
56
- }, []);
57
49
  var handleDismissBanner = function () {
58
50
  var _a;
59
51
  setHidden(true);
@@ -65,21 +57,6 @@ const GuidanceBlock = /*#__PURE__*/function () {
65
57
  setRemoved(true);
66
58
  }
67
59
  };
68
- var containerQuery = function () {
69
- var resizeObserver = new ResizeObserver(function (entries) {
70
- if (entries.length === 1) {
71
- handleMediaQueryLayout(entries[0].contentRect.width);
72
- }
73
- });
74
- resizeObserver.observe(containerRef.current);
75
- };
76
- var handleMediaQueryLayout = function (width) {
77
- if (width <= 320) {
78
- setMediaQueryLayout('centerContent');
79
- } else {
80
- setMediaQueryLayout('');
81
- }
82
- };
83
60
  var marginTop = function () {
84
61
  if (hidden && containerRef.current) {
85
62
  return -containerRef.current.clientHeight + 'px';
@@ -89,9 +66,8 @@ const GuidanceBlock = /*#__PURE__*/function () {
89
66
  if (removed) {
90
67
  return /*#__PURE__*/React.createElement(React.Fragment, null);
91
68
  }
92
- var componentIsMobile = mediaQueryLayout.includes('centerContent');
93
69
  return /*#__PURE__*/React.createElement("div", {
94
- className: classnames(styles.banner, variant && styles[variant], layout && styles[layout], hidden && styles.hidden, mediaQueryLayout === 'centerContent' && styles.centerContent, noMaxWidth && styles.noMaxWidth, illustrationType === 'scene' && styles.hasSceneIllustration, smallScreenTextAlignment === 'left' && styles.smallScreenTextAlignment),
70
+ className: classnames(styles.banner, variant && styles[variant], layout && styles[layout], hidden && styles.hidden, queries.isSmall && styles.centerContent, noMaxWidth && styles.noMaxWidth, illustrationType === 'scene' && styles.hasSceneIllustration, smallScreenTextAlignment === 'left' && styles.smallScreenTextAlignment),
95
71
  style: {
96
72
  marginTop: marginTop()
97
73
  },
@@ -115,41 +91,31 @@ const GuidanceBlock = /*#__PURE__*/function () {
115
91
  }, (_d = restProps === null || restProps === void 0 ? void 0 : restProps.text) === null || _d === void 0 ? void 0 : _d.title)), /*#__PURE__*/React.createElement(Text, {
116
92
  tag: "p",
117
93
  variant: "body"
118
- }, (_e = restProps === null || restProps === void 0 ? void 0 : restProps.text) === null || _e === void 0 ? void 0 : _e.description)))), (actions === null || actions === void 0 ? void 0 : actions.primary) && (/*#__PURE__*/React.createElement(Media, {
119
- query: "(max-width: 767px)"
120
- }, function (isMobile) {
121
- var _a;
122
- return /*#__PURE__*/React.createElement("div", {
123
- className: classnames({
124
- noRightMargin: isMobile || componentIsMobile,
125
- rightMargin: !(isMobile || componentIsMobile) && layout === 'default'
126
- })
127
- }, /*#__PURE__*/React.createElement("div", {
128
- className: classnames(styles.buttonContainer, (actions === null || actions === void 0 ? void 0 : actions.secondary) && styles.secondaryAction)
129
- }, /*#__PURE__*/React.createElement(WithTooltip, {
130
- tooltipProps: actions.primary.tooltip
131
- }, /*#__PURE__*/React.createElement(Button, __assign({
132
- icon: withActionButtonArrow ? (/*#__PURE__*/React.createElement(Icon, {
133
- name: "arrow_forward",
134
- isPresentational: true,
135
- shouldMirrorInRTL: true
136
- })) : undefined,
137
- iconPosition: "end"
138
- }, actions.primary, {
139
- fullWidth: isMobile || componentIsMobile
140
- }))), (actions === null || actions === void 0 ? void 0 : actions.secondary) && (/*#__PURE__*/React.createElement(WithTooltip, {
141
- tooltipProps: actions.secondary.tooltip
142
- }, /*#__PURE__*/React.createElement("div", {
143
- className: styles.secondaryAction
144
- }, /*#__PURE__*/React.createElement(Button, __assign({
145
- secondary: true
146
- }, actions.secondary, {
147
- onClick: secondaryDismiss ? function () {
148
- return handleDismissBanner();
149
- } : (_a = actions === null || actions === void 0 ? void 0 : actions.secondary) === null || _a === void 0 ? void 0 : _a.onClick,
150
- fullWidth: isMobile || componentIsMobile
151
- })))))));
152
- }))));
94
+ }, (_e = restProps === null || restProps === void 0 ? void 0 : restProps.text) === null || _e === void 0 ? void 0 : _e.description)))), (actions === null || actions === void 0 ? void 0 : actions.primary) || actionsSlot ? (/*#__PURE__*/React.createElement("div", {
95
+ className: styles.buttonContainer
96
+ }, (actions === null || actions === void 0 ? void 0 : actions.primary) && (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(WithTooltip, {
97
+ tooltipProps: actions.primary.tooltip
98
+ }, /*#__PURE__*/React.createElement(Button, __assign({
99
+ icon: withActionButtonArrow ? (/*#__PURE__*/React.createElement(Icon, {
100
+ name: "arrow_forward",
101
+ isPresentational: true,
102
+ shouldMirrorInRTL: true
103
+ })) : undefined,
104
+ iconPosition: "end"
105
+ }, actions.primary, {
106
+ fullWidth: queries.isSmall
107
+ }))), (actions === null || actions === void 0 ? void 0 : actions.secondary) && (/*#__PURE__*/React.createElement(WithTooltip, {
108
+ tooltipProps: actions.secondary.tooltip
109
+ }, /*#__PURE__*/React.createElement("div", {
110
+ className: styles.secondaryAction
111
+ }, /*#__PURE__*/React.createElement(Button, __assign({
112
+ secondary: true
113
+ }, actions.secondary, {
114
+ onClick: secondaryDismiss ? function () {
115
+ return handleDismissBanner();
116
+ } : (_f = actions === null || actions === void 0 ? void 0 : actions.secondary) === null || _f === void 0 ? void 0 : _f.onClick,
117
+ fullWidth: queries.isSmall
118
+ }))))))), !actions && actionsSlot && actionsSlot)) : null));
153
119
  };
154
120
  GuidanceBlock.displayName = 'GuidanceBlock';
155
121
  return GuidanceBlock;
@@ -1,6 +1,4 @@
1
1
  var styles = {
2
- "rightMargin": "GuidanceBlock-module_rightMargin__T6JO2",
3
- "noRightMargin": "GuidanceBlock-module_noRightMargin__MczwN",
4
2
  "banner": "GuidanceBlock-module_banner__7FT39",
5
3
  "noMaxWidth": "GuidanceBlock-module_noMaxWidth__UCCUk",
6
4
  "illustrationWrapper": "GuidanceBlock-module_illustrationWrapper__tK4Xr",