@kaizen/components 1.74.3 → 1.75.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.
Files changed (27) 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 +1 -2
  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/__next__/Button/_docs/Button--migration-guide.mdx +3 -3
  27. package/src/__next__/Tag/Tag/_docs/Tag.stories.tsx +10 -0
@@ -0,0 +1,199 @@
1
+ import ts from 'typescript'
2
+ import { parseJsx } from '../__tests__/utils'
3
+ import { transformV1ButtonPropsToButtonOrLinkButton } from './transformV1ButtonPropsToButtonOrLinkButton'
4
+ import { printAst } from './'
5
+
6
+ const mockedTransformer =
7
+ () =>
8
+ (context: ts.TransformationContext) =>
9
+ (rootNode: ts.Node): ts.Node => {
10
+ const visit = (node: ts.Node): ts.Node => {
11
+ if (ts.isJsxSelfClosingElement(node)) {
12
+ const primaryAction = node.attributes.properties.find((prop) => {
13
+ return prop?.name?.getText() === 'primaryAction'
14
+ }) as ts.JsxAttribute
15
+
16
+ if (primaryAction) {
17
+ const primaryActionInitializer =
18
+ primaryAction?.initializer?.getChildren()[1] as ts.ObjectLiteralExpression
19
+ const ButtonOrLinkComponent =
20
+ transformV1ButtonPropsToButtonOrLinkButton(primaryActionInitializer)
21
+ const newAttr = ts.factory.createJsxAttribute(
22
+ ts.factory.createIdentifier('primaryAction'),
23
+ ts.factory.createJsxExpression(undefined, ButtonOrLinkComponent.component),
24
+ )
25
+
26
+ return ts.factory.createJsxSelfClosingElement(
27
+ ts.factory.createIdentifier('DummyComponent'),
28
+ undefined,
29
+ ts.factory.createJsxAttributes([newAttr]),
30
+ )
31
+ }
32
+ }
33
+ return ts.visitEachChild(node, visit, context)
34
+ }
35
+ return ts.visitNode(rootNode, visit)
36
+ }
37
+
38
+ const transformInput = (sourceFile: ts.SourceFile): string => {
39
+ const result = ts.transform(sourceFile, [mockedTransformer()])
40
+ const transformedSource = result.transformed[0] as ts.SourceFile
41
+ return printAst(transformedSource)
42
+ }
43
+
44
+ describe('transformV1ButtonPropsToButtonOrLinkButton()', () => {
45
+ it('transforms V1 button-like props into a Button/next component', () => {
46
+ const inputAst = parseJsx(`<DummyComponent primaryAction={{
47
+ label: 'Learn more',
48
+ onClick: () => console.log("hello world")
49
+ destructive: true,
50
+ disabled: false,
51
+ reversed: true,
52
+ size: 'small',
53
+ working: true,
54
+ workingLabel: 'Loading...',
55
+ workingLabelHidden: true,
56
+ disableTabFocusAndIUnderstandTheAccessibilityImplications: true,
57
+ 'data-automation-id': 'some-id',
58
+ classNameOverride: styles.buttonClass,
59
+ }} />`)
60
+
61
+ const outputAst = parseJsx(
62
+ `<DummyComponent primaryAction={<Button onPress={() => console.log("hello world")} isDisabled={false} isReversed size="medium" isPending pendingLabel='Loading...' hasHiddenPendingLabel data-testid='some-id' className={styles.buttonClass} variant="secondary">Learn more</Button>} />`,
63
+ )
64
+
65
+ expect(transformInput(inputAst)).toBe(printAst(outputAst))
66
+ })
67
+ it('transforms V1 link-like props into a LinkButton component', () => {
68
+ const inputAst = parseJsx(`<DummyComponent primaryAction={{
69
+ label: 'Learn more',
70
+ href: 'https://www.example.com',
71
+ destructive: true,
72
+ disabled: false,
73
+ reversed: true,
74
+ newTabAndIUnderstandTheAccessibilityImplications: true,
75
+ size: 'small',
76
+ working: true,
77
+ workingLabel: 'Loading...',
78
+ workingLabelHidden: true,
79
+ disableTabFocusAndIUnderstandTheAccessibilityImplications: true,
80
+ }} />`)
81
+
82
+ const outputAst = parseJsx(
83
+ `<DummyComponent primaryAction={<LinkButton href='https://www.example.com' isDisabled={false} isReversed target="_blank" rel="noopener noreferrer" size="medium" isPending pendingLabel='Loading...' hasHiddenPendingLabel variant="secondary">Learn more</LinkButton>} />`,
84
+ )
85
+
86
+ expect(transformInput(inputAst)).toBe(printAst(outputAst))
87
+ })
88
+ it('transforms component render props into a LinkButton component and keeps the component render props', () => {
89
+ const inputAst = parseJsx(`<DummyComponent primaryAction={{
90
+ label: 'Learn more',
91
+ href: 'https://www.example.com',
92
+ destructive: true,
93
+ disabled: false,
94
+ reversed: true,
95
+ newTabAndIUnderstandTheAccessibilityImplications: true,
96
+ size: 'small',
97
+ working: true,
98
+ workingLabel: 'Loading...',
99
+ workingLabelHidden: true,
100
+ disableTabFocusAndIUnderstandTheAccessibilityImplications: true,
101
+ component: ({ children }) => <span>{children}</span>,
102
+ }} />`)
103
+
104
+ const outputAst = parseJsx(
105
+ `<DummyComponent primaryAction={<LinkButton href='https://www.example.com' isDisabled={false} isReversed target="_blank" rel="noopener noreferrer" size="medium" isPending pendingLabel='Loading...' hasHiddenPendingLabel component={({ children }) => <span>{children}</span>} variant="secondary">Learn more</LinkButton>}/>`,
106
+ )
107
+
108
+ expect(transformInput(inputAst)).toBe(printAst(outputAst))
109
+ })
110
+ it('will create a large button if the size is undefined', () => {
111
+ const inputAst = parseJsx(`<DummyComponent primaryAction={{
112
+ label: 'Learn more',
113
+ onClick: () => console.log("hello world")
114
+ }}/>`)
115
+
116
+ const outputAst = parseJsx(
117
+ `<DummyComponent primaryAction={<Button onPress={() => console.log("hello world")} variant="secondary" size="large">Learn more</Button>}}
118
+ />`,
119
+ )
120
+
121
+ expect(transformInput(inputAst)).toBe(printAst(outputAst))
122
+ })
123
+
124
+ // This will allow for type feedback to the consumer
125
+ it('passes tooltip and badge props into the created element', () => {
126
+ const inputAst = parseJsx(`<DummyComponent primaryAction={{
127
+ label: 'Learn more',
128
+ onClick: () => console.log("hello world")
129
+ size: 'small',
130
+ classNameOverride: styles.buttonClass,
131
+ tooltip: { text: 'Opens in a new tab', mood: 'cautionary' },
132
+ badge: { text: 'New' },
133
+ }}/>`)
134
+
135
+ const outputAst = parseJsx(
136
+ `<DummyComponent primaryAction={<Button onPress={() => console.log("hello world")} size="medium" className={styles.buttonClass} tooltip={{ text: 'Opens in a new tab', mood: 'cautionary' }} badge={{ text: 'New' }} variant="secondary">Learn more</Button>}}
137
+ />`,
138
+ )
139
+
140
+ expect(transformInput(inputAst)).toBe(printAst(outputAst))
141
+ })
142
+ it('passes all data and native attributes into the created element', () => {
143
+ const inputAst = parseJsx(`<DummyComponent primaryAction={{
144
+ label: 'Learn more',
145
+ onClick: () => console.log("hello world")
146
+ size: 'small',
147
+ classNameOverride: styles.buttonClass,
148
+ 'data-random-attribute': 'some-id',
149
+ "aria-label": "some label",
150
+ form: 'form-id',
151
+ }}/>`)
152
+
153
+ const outputAst = parseJsx(
154
+ `<DummyComponent primaryAction={<Button onPress={() => console.log("hello world")} size="medium" className={styles.buttonClass} data-random-attribute='some-id' aria-label="some label" form='form-id' variant="secondary">Learn more</Button>}}
155
+ />`,
156
+ )
157
+
158
+ expect(transformInput(inputAst)).toBe(printAst(outputAst))
159
+ })
160
+
161
+ it('transforms shorthand properties as expressions', () => {
162
+ const inputAst = parseJsx(`<DummyComponent primaryAction={{
163
+ label,
164
+ onClick: () => console.log("hello world")
165
+ size: 'small',
166
+ classNameOverride: styles.buttonClass,
167
+ badge: { text: 'New' },
168
+ 'data-random-attribute': 'some-id',
169
+ "aria-label": "some label",
170
+ form: 'form-id',
171
+ }}/>`)
172
+
173
+ const outputAst = parseJsx(
174
+ `<DummyComponent primaryAction={<Button onPress={() => console.log("hello world")} size="medium" className={styles.buttonClass} badge={{ text: 'New' }} data-random-attribute='some-id' aria-label="some label" form='form-id' variant="secondary">{label}</Button>}}
175
+ />`,
176
+ )
177
+
178
+ expect(transformInput(inputAst)).toBe(printAst(outputAst))
179
+ })
180
+ it('transforms expressions correctly as children', () => {
181
+ const inputAst = parseJsx(`
182
+ <DummyComponent primaryAction={{
183
+ label: intl.formatMessage({ id: "label.id", defaultMessage: "Label", { variableVal }),
184
+ onClick: () => console.log("hello world")
185
+ href: url,
186
+ size: buttonSize,
187
+ classNameOverride: styles.buttonClass,
188
+ badge: { text: 'New' },
189
+ 'data-random-attribute': 'some-id',
190
+ form: 'form-id',
191
+ }}/>`)
192
+
193
+ const outputAst = parseJsx(
194
+ `<DummyComponent primaryAction={<LinkButton onPress={() => console.log("hello world")} href={url} size={buttonSize} className={styles.buttonClass} badge={{ text: 'New' }} data-random-attribute='some-id' form='form-id' variant="secondary">{intl.formatMessage({ id: "label.id", defaultMessage: "Label", { variableVal })}</LinkButton>}}
195
+ />`,
196
+ )
197
+ expect(transformInput(inputAst)).toBe(printAst(outputAst))
198
+ })
199
+ })
@@ -0,0 +1,195 @@
1
+ import ts from 'typescript'
2
+
3
+ import {
4
+ createJsxElementWithChildren,
5
+ createProp,
6
+ createStringProp,
7
+ getPropValueText,
8
+ } from '../utils'
9
+
10
+ /**
11
+ * A function that transforms button v1 prop values into a Button/next JSX component
12
+ * @returns
13
+ * - `ts.JsxAttribute` if the prop should be transformed
14
+ * - `null` if the prop should be removed
15
+ * - `undefined` if the prop should be kept as is
16
+ */
17
+ export const transformButtonProp = (
18
+ propName: string,
19
+ propValue: ts.JsxAttributeValue | undefined,
20
+ ): ts.JsxAttribute | null | undefined => {
21
+ const sanitizedPropName = propName.replace(/'/g, '')
22
+ const sanitizedPropValue =
23
+ propValue?.kind === ts.SyntaxKind.StringLiteral
24
+ ? propValue
25
+ : ts.factory.createJsxExpression(undefined, propValue)
26
+
27
+ switch (sanitizedPropName) {
28
+ case 'onClick':
29
+ return createProp('onPress', sanitizedPropValue)
30
+ case 'reversed':
31
+ return createProp('isReversed', sanitizedPropValue)
32
+ case 'classNameOverride':
33
+ return createProp('className', sanitizedPropValue)
34
+ case 'data-automation-id':
35
+ return createProp('data-testid', sanitizedPropValue)
36
+ case 'fullWidth':
37
+ return createProp('isFullWidth', sanitizedPropValue)
38
+ case 'working':
39
+ return createProp('isPending', sanitizedPropValue)
40
+ case 'workingLabel':
41
+ return createProp('pendingLabel', sanitizedPropValue)
42
+ case 'workingLabelHidden':
43
+ return createProp('hasHiddenPendingLabel', sanitizedPropValue)
44
+ case 'onMouseDown':
45
+ return createProp('onPressStart', sanitizedPropValue)
46
+ case 'disableTabFocusAndIUnderstandTheAccessibilityImplications':
47
+ return null
48
+ case 'newTabAndIUnderstandTheAccessibilityImplications':
49
+ return null
50
+ case 'disabled':
51
+ return createProp('isDisabled', sanitizedPropValue)
52
+ case 'secondaryDismiss':
53
+ return null
54
+ case 'icon': {
55
+ return createProp('icon', sanitizedPropValue)
56
+ }
57
+ case 'size': {
58
+ const oldValue = propValue && (getPropValueText(propValue) as 'small' | 'regular')
59
+ const buttonSizeMap = {
60
+ small: 'medium',
61
+ regular: 'large',
62
+ }
63
+
64
+ return oldValue ? createStringProp('size', buttonSizeMap[oldValue]) : undefined
65
+ }
66
+ case 'primary':
67
+ return createStringProp('variant', 'primary')
68
+ case 'secondary':
69
+ return createStringProp('variant', 'tertiary')
70
+ case 'destructive':
71
+ return null
72
+ default:
73
+ return undefined
74
+ }
75
+ }
76
+
77
+ type TransformButtonProp = {
78
+ import: string
79
+ component: ts.JsxSelfClosingElement | ts.JsxElement
80
+ }
81
+
82
+ /** A utility to transform V1 Button props into a Button or LinkButton with the import JSX element */
83
+ export const transformV1ButtonPropsToButtonOrLinkButton = (
84
+ buttonProps: ts.ObjectLiteralExpression,
85
+ /** optional override for the variant type if needed, ie: primary or secondary actions*/
86
+ variantOverride?: string,
87
+ ): TransformButtonProp => {
88
+ let childrenValue: ts.JsxAttributeValue | undefined
89
+ let hasSizeProp = false
90
+ let hasVariant = false
91
+ let hasLinkAttr = false
92
+
93
+ const newProps = buttonProps.properties.reduce<ts.JsxAttributeLike[]>((acc, currentProp) => {
94
+ const propName = currentProp?.name?.getText()
95
+ const propValue = ts.isPropertyAssignment(currentProp) ? currentProp.initializer : undefined
96
+
97
+ if (propName) {
98
+ if (propName === 'label') {
99
+ if (ts.isShorthandPropertyAssignment(currentProp)) {
100
+ childrenValue = ts.factory.createJsxExpression(
101
+ undefined,
102
+ ts.factory.createIdentifier(propName),
103
+ )
104
+ return acc
105
+ }
106
+ if (propValue && propValue?.kind !== ts.SyntaxKind.StringLiteral) {
107
+ childrenValue = ts.factory.createJsxExpression(undefined, propValue)
108
+ return acc
109
+ }
110
+ childrenValue = propValue as ts.JsxAttributeValue
111
+ return acc
112
+ }
113
+
114
+ if (propName === 'newTabAndIUnderstandTheAccessibilityImplications') {
115
+ return [
116
+ ...acc,
117
+ createStringProp('target', '_blank'),
118
+ createStringProp('rel', 'noopener noreferrer'),
119
+ ]
120
+ }
121
+
122
+ if (propName === 'primary' || propName === 'secondary' || variantOverride) {
123
+ hasVariant = true
124
+ }
125
+
126
+ if (propName === 'size') {
127
+ hasSizeProp = true
128
+ }
129
+
130
+ if (propName === 'href') {
131
+ hasLinkAttr = true
132
+ if (propValue && propValue?.kind !== ts.SyntaxKind.StringLiteral) {
133
+ return [...acc, createProp('href', ts.factory.createJsxExpression(undefined, propValue))]
134
+ }
135
+ return [...acc, createProp('href', propValue as ts.StringLiteral)]
136
+ }
137
+
138
+ if (propName === 'component') {
139
+ hasLinkAttr = true
140
+ return [
141
+ ...acc,
142
+ createProp(
143
+ 'component',
144
+ ts.factory.createJsxExpression(undefined, propValue) as ts.JsxExpression,
145
+ ),
146
+ ]
147
+ }
148
+
149
+ const newProp = transformButtonProp(propName, propValue as ts.JsxAttributeValue)
150
+
151
+ if (newProp === null) return acc
152
+
153
+ if (newProp === undefined) {
154
+ const sanitizedPropName = propName.replace(/'|"/g, '')
155
+ const sanitizedPropValue: ts.JsxAttributeValue =
156
+ propValue?.kind === ts.SyntaxKind.StringLiteral
157
+ ? (propValue as ts.StringLiteral)
158
+ : (ts.factory.createJsxExpression(undefined, propValue) as ts.JsxExpression)
159
+ const otherAttr = ts.factory.createJsxAttribute(
160
+ ts.factory.createIdentifier(sanitizedPropName),
161
+ sanitizedPropValue,
162
+ )
163
+ acc.push(otherAttr)
164
+ return acc
165
+ }
166
+
167
+ if (newProp) {
168
+ return [...acc, newProp]
169
+ }
170
+ }
171
+
172
+ return acc
173
+ }, [])
174
+
175
+ if (!hasVariant) {
176
+ newProps.push(createStringProp('variant', 'secondary'))
177
+ }
178
+
179
+ if (variantOverride) {
180
+ newProps.push(createStringProp('variant', variantOverride))
181
+ }
182
+
183
+ if (!hasSizeProp) {
184
+ newProps.push(createStringProp('size', 'large'))
185
+ }
186
+
187
+ return {
188
+ import: hasLinkAttr ? 'LinkButton' : 'Button',
189
+ component: createJsxElementWithChildren(
190
+ hasLinkAttr ? 'LinkButton' : 'Button',
191
+ newProps,
192
+ childrenValue,
193
+ ),
194
+ }
195
+ }
@@ -3,14 +3,14 @@
3
3
  var tslib = require('tslib');
4
4
  var React = require('react');
5
5
  var classnames = require('classnames');
6
- var Media = require('react-media');
7
6
  var Button = require('../Button/Button/Button.cjs');
8
7
  require('../Button/IconButton/IconButton.cjs');
9
8
  var Heading = require('../Heading/Heading.cjs');
10
9
  var Text = require('../Text/Text.cjs');
11
10
  var Tooltip = require('../Tooltip/Tooltip.cjs');
12
- var Icon = require('../__next__/Icon/Icon.cjs');
11
+ var useMediaQueries = require('../utils/useMediaQueries.cjs');
13
12
  var GuidanceBlock_module = require('./GuidanceBlock.module.css.cjs');
13
+ var Icon = require('../__next__/Icon/Icon.cjs');
14
14
  function _interopDefault(e) {
15
15
  return e && e.__esModule ? e : {
16
16
  default: e
@@ -18,7 +18,6 @@ function _interopDefault(e) {
18
18
  }
19
19
  var React__default = /*#__PURE__*/_interopDefault(React);
20
20
  var classnames__default = /*#__PURE__*/_interopDefault(classnames);
21
- var Media__default = /*#__PURE__*/_interopDefault(Media);
22
21
  var WithTooltip = function (_a) {
23
22
  var tooltipProps = _a.tooltipProps,
24
23
  children = _a.children;
@@ -29,40 +28,32 @@ var WithTooltip = function (_a) {
29
28
  * {@link https://cultureamp.design/?path=/docs/components-guidanceblock--docs Storybook}
30
29
  */
31
30
  var GuidanceBlock = function (_a) {
32
- var _b, _c, _d, _e;
33
- var _f = _a.layout,
34
- layout = _f === void 0 ? 'default' : _f,
35
- _g = _a.variant,
36
- variant = _g === void 0 ? 'default' : _g,
37
- _h = _a.withActionButtonArrow,
38
- withActionButtonArrow = _h === void 0 ? true : _h,
39
- _j = _a.noMaxWidth,
40
- noMaxWidth = _j === void 0 ? false : _j,
41
- _k = _a.illustrationType,
42
- illustrationType = _k === void 0 ? 'spot' : _k,
43
- _l = _a.smallScreenTextAlignment,
44
- smallScreenTextAlignment = _l === void 0 ? 'center' : _l,
31
+ var _b, _c, _d, _e, _f;
32
+ var _g = _a.layout,
33
+ layout = _g === void 0 ? 'default' : _g,
34
+ _h = _a.variant,
35
+ variant = _h === void 0 ? 'default' : _h,
36
+ _j = _a.withActionButtonArrow,
37
+ withActionButtonArrow = _j === void 0 ? true : _j,
38
+ _k = _a.noMaxWidth,
39
+ noMaxWidth = _k === void 0 ? false : _k,
40
+ _l = _a.illustrationType,
41
+ illustrationType = _l === void 0 ? 'spot' : _l,
42
+ _m = _a.smallScreenTextAlignment,
43
+ smallScreenTextAlignment = _m === void 0 ? 'center' : _m,
45
44
  actions = _a.actions,
46
45
  illustration = _a.illustration,
47
46
  secondaryDismiss = _a.secondaryDismiss,
48
- restProps = tslib.__rest(_a, ["layout", "variant", "withActionButtonArrow", "noMaxWidth", "illustrationType", "smallScreenTextAlignment", "actions", "illustration", "secondaryDismiss"]);
49
- var _m = React.useState(false),
50
- hidden = _m[0],
51
- setHidden = _m[1];
47
+ actionsSlot = _a.actionsSlot,
48
+ restProps = tslib.__rest(_a, ["layout", "variant", "withActionButtonArrow", "noMaxWidth", "illustrationType", "smallScreenTextAlignment", "actions", "illustration", "secondaryDismiss", "actionsSlot"]);
52
49
  var _o = React.useState(false),
53
- removed = _o[0],
54
- setRemoved = _o[1];
55
- var _p = React.useState(''),
56
- mediaQueryLayout = _p[0],
57
- setMediaQueryLayout = _p[1];
50
+ hidden = _o[0],
51
+ setHidden = _o[1];
52
+ var _p = React.useState(false),
53
+ removed = _p[0],
54
+ setRemoved = _p[1];
55
+ var queries = useMediaQueries.useMediaQueries().queries;
58
56
  var containerRef = React__default.default.createRef();
59
- React.useEffect(function () {
60
- if (layout === 'inline' || layout === 'stacked') {
61
- containerQuery();
62
- }
63
- // @todo: Fix if possible - avoiding breaking in eslint upgrade
64
- // eslint-disable-next-line react-hooks/exhaustive-deps
65
- }, []);
66
57
  var handleDismissBanner = function () {
67
58
  var _a;
68
59
  setHidden(true);
@@ -74,21 +65,6 @@ var GuidanceBlock = function (_a) {
74
65
  setRemoved(true);
75
66
  }
76
67
  };
77
- var containerQuery = function () {
78
- var resizeObserver = new ResizeObserver(function (entries) {
79
- if (entries.length === 1) {
80
- handleMediaQueryLayout(entries[0].contentRect.width);
81
- }
82
- });
83
- resizeObserver.observe(containerRef.current);
84
- };
85
- var handleMediaQueryLayout = function (width) {
86
- if (width <= 320) {
87
- setMediaQueryLayout('centerContent');
88
- } else {
89
- setMediaQueryLayout('');
90
- }
91
- };
92
68
  var marginTop = function () {
93
69
  if (hidden && containerRef.current) {
94
70
  return -containerRef.current.clientHeight + 'px';
@@ -98,9 +74,8 @@ var GuidanceBlock = function (_a) {
98
74
  if (removed) {
99
75
  return React__default.default.createElement(React__default.default.Fragment, null);
100
76
  }
101
- var componentIsMobile = mediaQueryLayout.includes('centerContent');
102
77
  return React__default.default.createElement("div", {
103
- className: classnames__default.default(GuidanceBlock_module.banner, variant && GuidanceBlock_module[variant], layout && GuidanceBlock_module[layout], hidden && GuidanceBlock_module.hidden, mediaQueryLayout === 'centerContent' && GuidanceBlock_module.centerContent, noMaxWidth && GuidanceBlock_module.noMaxWidth, illustrationType === 'scene' && GuidanceBlock_module.hasSceneIllustration, smallScreenTextAlignment === 'left' && GuidanceBlock_module.smallScreenTextAlignment),
78
+ className: classnames__default.default(GuidanceBlock_module.banner, variant && GuidanceBlock_module[variant], layout && GuidanceBlock_module[layout], hidden && GuidanceBlock_module.hidden, queries.isSmall && GuidanceBlock_module.centerContent, noMaxWidth && GuidanceBlock_module.noMaxWidth, illustrationType === 'scene' && GuidanceBlock_module.hasSceneIllustration, smallScreenTextAlignment === 'left' && GuidanceBlock_module.smallScreenTextAlignment),
104
79
  style: {
105
80
  marginTop: marginTop()
106
81
  },
@@ -124,41 +99,31 @@ var GuidanceBlock = function (_a) {
124
99
  }, (_d = restProps === null || restProps === void 0 ? void 0 : restProps.text) === null || _d === void 0 ? void 0 : _d.title)), React__default.default.createElement(Text.Text, {
125
100
  tag: "p",
126
101
  variant: "body"
127
- }, (_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) && React__default.default.createElement(Media__default.default, {
128
- query: "(max-width: 767px)"
129
- }, function (isMobile) {
130
- var _a;
131
- return React__default.default.createElement("div", {
132
- className: classnames__default.default({
133
- noRightMargin: isMobile || componentIsMobile,
134
- rightMargin: !(isMobile || componentIsMobile) && layout === 'default'
135
- })
136
- }, React__default.default.createElement("div", {
137
- className: classnames__default.default(GuidanceBlock_module.buttonContainer, (actions === null || actions === void 0 ? void 0 : actions.secondary) && GuidanceBlock_module.secondaryAction)
138
- }, React__default.default.createElement(WithTooltip, {
139
- tooltipProps: actions.primary.tooltip
140
- }, React__default.default.createElement(Button.Button, tslib.__assign({
141
- icon: withActionButtonArrow ? React__default.default.createElement(Icon.Icon, {
142
- name: "arrow_forward",
143
- isPresentational: true,
144
- shouldMirrorInRTL: true
145
- }) : undefined,
146
- iconPosition: "end"
147
- }, actions.primary, {
148
- fullWidth: isMobile || componentIsMobile
149
- }))), (actions === null || actions === void 0 ? void 0 : actions.secondary) && React__default.default.createElement(WithTooltip, {
150
- tooltipProps: actions.secondary.tooltip
151
- }, React__default.default.createElement("div", {
152
- className: GuidanceBlock_module.secondaryAction
153
- }, React__default.default.createElement(Button.Button, tslib.__assign({
154
- secondary: true
155
- }, actions.secondary, {
156
- onClick: secondaryDismiss ? function () {
157
- return handleDismissBanner();
158
- } : (_a = actions === null || actions === void 0 ? void 0 : actions.secondary) === null || _a === void 0 ? void 0 : _a.onClick,
159
- fullWidth: isMobile || componentIsMobile
160
- }))))));
161
- })));
102
+ }, (_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 ? React__default.default.createElement("div", {
103
+ className: GuidanceBlock_module.buttonContainer
104
+ }, (actions === null || actions === void 0 ? void 0 : actions.primary) && React__default.default.createElement(React__default.default.Fragment, null, React__default.default.createElement(WithTooltip, {
105
+ tooltipProps: actions.primary.tooltip
106
+ }, React__default.default.createElement(Button.Button, tslib.__assign({
107
+ icon: withActionButtonArrow ? React__default.default.createElement(Icon.Icon, {
108
+ name: "arrow_forward",
109
+ isPresentational: true,
110
+ shouldMirrorInRTL: true
111
+ }) : undefined,
112
+ iconPosition: "end"
113
+ }, actions.primary, {
114
+ fullWidth: queries.isSmall
115
+ }))), (actions === null || actions === void 0 ? void 0 : actions.secondary) && React__default.default.createElement(WithTooltip, {
116
+ tooltipProps: actions.secondary.tooltip
117
+ }, React__default.default.createElement("div", {
118
+ className: GuidanceBlock_module.secondaryAction
119
+ }, React__default.default.createElement(Button.Button, tslib.__assign({
120
+ secondary: true
121
+ }, actions.secondary, {
122
+ onClick: secondaryDismiss ? function () {
123
+ return handleDismissBanner();
124
+ } : (_f = actions === null || actions === void 0 ? void 0 : actions.secondary) === null || _f === void 0 ? void 0 : _f.onClick,
125
+ fullWidth: queries.isSmall
126
+ }))))), !actions && actionsSlot && actionsSlot) : null));
162
127
  };
163
128
  GuidanceBlock.displayName = 'GuidanceBlock';
164
129
  exports.GuidanceBlock = GuidanceBlock;
@@ -1,8 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var styles = {
4
- "rightMargin": "GuidanceBlock-module_rightMargin__T6JO2",
5
- "noRightMargin": "GuidanceBlock-module_noRightMargin__MczwN",
6
4
  "banner": "GuidanceBlock-module_banner__7FT39",
7
5
  "noMaxWidth": "GuidanceBlock-module_noMaxWidth__UCCUk",
8
6
  "illustrationWrapper": "GuidanceBlock-module_illustrationWrapper__tK4Xr",