@guardian/stand 0.0.37 → 0.0.38

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 (63) hide show
  1. package/dist/components/alert-banner/AlertBanner.js +1 -1
  2. package/dist/components/avatar/Avatar.js +1 -1
  3. package/dist/components/button/Button.js +1 -1
  4. package/dist/components/checkbox/Checkbox.js +1 -1
  5. package/dist/components/checkbox/CheckboxGroup.js +1 -1
  6. package/dist/components/date-picker/DatePicker.js +1 -1
  7. package/dist/components/grid/Grid.js +1 -1
  8. package/dist/components/grid/styles.cjs +59 -39
  9. package/dist/components/grid/styles.js +47 -35
  10. package/dist/components/icon/Icon.js +1 -1
  11. package/dist/components/icon-button/IconButton.js +1 -1
  12. package/dist/components/icon-button/styles.js +1 -1
  13. package/dist/components/icon-link-button/IconLinkButton.js +1 -1
  14. package/dist/components/icon-link-button/styles.js +1 -1
  15. package/dist/components/inline-message/InlineMessage.js +1 -1
  16. package/dist/components/intended-audience-signifier/IntendedAudienceSignifier.js +1 -1
  17. package/dist/components/layout/Layout.cjs +49 -84
  18. package/dist/components/layout/Layout.js +27 -76
  19. package/dist/components/layout/styles.cjs +5 -3
  20. package/dist/components/layout/styles.js +5 -4
  21. package/dist/components/link/Link.cjs +5 -5
  22. package/dist/components/link/Link.js +1 -1
  23. package/dist/components/link-button/LinkButton.js +1 -1
  24. package/dist/components/link-button/styles.js +1 -1
  25. package/dist/components/menu/Menu.js +1 -1
  26. package/dist/components/radio-group/RadioGroup.js +1 -1
  27. package/dist/components/select/Select.js +1 -1
  28. package/dist/components/text-area/TextArea.js +1 -1
  29. package/dist/components/text-input/TextInput.js +1 -1
  30. package/dist/components/topbar/TopBar.js +1 -1
  31. package/dist/components/topbar/topBarItem/TopBarItem.js +1 -1
  32. package/dist/components/topbar/topBarNavigation/TopBarNavigation.js +1 -1
  33. package/dist/components/topbar/topBarToolName/TopBarToolName.js +1 -1
  34. package/dist/components/typography/Typography.js +1 -1
  35. package/dist/components/typography/styles.cjs +5 -5
  36. package/dist/index.cjs +2 -0
  37. package/dist/index.js +1 -0
  38. package/dist/layout.cjs +0 -1
  39. package/dist/layout.js +1 -1
  40. package/dist/styleD/build/css/component/grid.css +9 -2
  41. package/dist/styleD/build/css/component/layout.css +4 -4
  42. package/dist/styleD/build/css/semantic/grid.css +15 -0
  43. package/dist/styleD/build/css/semantic/sizing.css +3 -0
  44. package/dist/styleD/build/typescript/component/grid.cjs +15 -2
  45. package/dist/styleD/build/typescript/component/grid.js +15 -2
  46. package/dist/styleD/build/typescript/component/layout.cjs +7 -5
  47. package/dist/styleD/build/typescript/component/layout.js +7 -5
  48. package/dist/styleD/build/typescript/semantic/grid.cjs +21 -0
  49. package/dist/styleD/build/typescript/semantic/grid.js +19 -0
  50. package/dist/styleD/build/typescript/semantic/sizing.cjs +7 -0
  51. package/dist/styleD/build/typescript/semantic/sizing.js +7 -0
  52. package/dist/types/components/grid/sandbox.d.ts +2 -2
  53. package/dist/types/components/layout/Layout.d.ts +11 -19
  54. package/dist/types/components/layout/sandbox.d.ts +1 -1
  55. package/dist/types/components/layout/styles.d.ts +5 -2
  56. package/dist/types/components/layout/types.d.ts +13 -3
  57. package/dist/types/index.d.ts +2 -0
  58. package/dist/types/layout.d.ts +3 -3
  59. package/dist/types/styleD/build/typescript/component/grid.d.ts +15 -2
  60. package/dist/types/styleD/build/typescript/component/layout.d.ts +5 -3
  61. package/dist/types/styleD/build/typescript/semantic/grid.d.ts +21 -0
  62. package/dist/types/styleD/build/typescript/semantic/sizing.d.ts +7 -0
  63. package/package.json +2 -1
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
2
  import { useMemo } from 'react';
3
3
  import { mergeDeep } from '../../util/mergeDeep.js';
4
- import { alertBannerContentStyles, alertBannerStyles, defaultAlertBannerTheme } from './styles.js';
4
+ import { defaultAlertBannerTheme, alertBannerContentStyles, alertBannerStyles } from './styles.js';
5
5
  import { Icon } from '../icon/Icon.js';
6
6
  import { IconButton } from '../icon-button/IconButton.js';
7
7
 
@@ -1,7 +1,7 @@
1
1
  import { jsx, Fragment } from '@emotion/react/jsx-runtime';
2
2
  import { useState } from 'react';
3
3
  import { mergeDeep } from '../../util/mergeDeep.js';
4
- import { avatarImageStyles, avatarStyles, defaultAvatarTheme } from './styles.js';
4
+ import { defaultAvatarTheme, avatarImageStyles, avatarStyles } from './styles.js';
5
5
  import { avatarColors } from './types.js';
6
6
 
7
7
  const getColorFromString = (input) => {
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
2
2
  import { Button as Button$1, composeRenderProps } from 'react-aria-components';
3
3
  import { mergeDeep } from '../../util/mergeDeep.js';
4
4
  import { Icon } from '../icon/Icon.js';
5
- import { buttonStyles, defaultButtonTheme } from './styles.js';
5
+ import { defaultButtonTheme, buttonStyles } from './styles.js';
6
6
 
7
7
  function Button({ variant = "primary", size = "md", theme = {}, cssOverrides, icon, ...props }) {
8
8
  const mergedTheme = mergeDeep(defaultButtonTheme, theme);
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx, Fragment } from '@emotion/react/jsx-runtime';
2
2
  import { Checkbox as Checkbox$1 } from 'react-aria-components';
3
3
  import { mergeDeep } from '../../util/mergeDeep.js';
4
- import { checkboxLabelStyles, checkboxStyles, defaultCheckboxTheme } from './styles.js';
4
+ import { defaultCheckboxTheme, checkboxLabelStyles, checkboxStyles } from './styles.js';
5
5
 
6
6
  function Checkbox({ children, size = "md", isIndeterminate = false, theme = {}, cssOverrides, ...props }) {
7
7
  const mergedTheme = mergeDeep(defaultCheckboxTheme, theme);
@@ -4,7 +4,7 @@ import { CheckboxGroup as CheckboxGroup$1 } from 'react-aria-components';
4
4
  import { mergeDeep } from '../../util/mergeDeep.js';
5
5
  import { FormInputContainer } from '../form/Form.js';
6
6
  import { Checkbox } from './Checkbox.js';
7
- import { checkboxGroupStyles, defaultCheckboxTheme } from './styles.js';
7
+ import { defaultCheckboxTheme, checkboxGroupStyles } from './styles.js';
8
8
 
9
9
  function CheckboxGroup({ size = "md", theme = {}, ...props }) {
10
10
  const mergedTheme = mergeDeep(defaultCheckboxTheme, {
@@ -4,7 +4,7 @@ import { DatePicker as DatePicker$1, Group, I18nProvider, Button, Popover, DateI
4
4
  import { mergeDeep } from '../../util/mergeDeep.js';
5
5
  import { FormInputContainer } from '../form/Form.js';
6
6
  import { Icon } from '../icon/Icon.js';
7
- import { dateSegmentStyles, datePickerStyles, datePickerPopoverStyles, defaultDatePickerTheme, calendarHeaderStyles, calendarCellStyles, calendarGridStyles } from './styles.js';
7
+ import { defaultDatePickerTheme, dateSegmentStyles, datePickerStyles, datePickerPopoverStyles, calendarHeaderStyles, calendarCellStyles, calendarGridStyles } from './styles.js';
8
8
 
9
9
  const MONTHS = [
10
10
  "January",
@@ -1,6 +1,6 @@
1
1
  import { jsx } from '@emotion/react/jsx-runtime';
2
2
  import { mergeDeep } from '../../util/mergeDeep.js';
3
- import { gridStyles, itemStyles, defaultGridTheme } from './styles.js';
3
+ import { defaultGridTheme, gridStyles, itemStyles } from './styles.js';
4
4
 
5
5
  function Grid({ children, theme = {}, cssOverrides, as: Component = "div", ...props }) {
6
6
  const mergedTheme = mergeDeep(defaultGridTheme, theme);
@@ -8,9 +8,9 @@ const defaultGridTheme = grid.componentGrid;
8
8
  const isResponsiveGridSize = (size) => typeof size === "object";
9
9
  const isResponsiveOffset = (offset) => typeof offset === "object";
10
10
  const clampToColumns = (value, columns) => Math.max(0, Math.min(value, columns));
11
- const numericOffsetMargin = (offset, theme) => `calc(((100% - (${theme.shared.columns} - 1) * ${theme.shared.gap}) * ${offset} / ${theme.shared.columns}) + ${offset} * ${theme.shared.gap})`;
12
- const numericSizeWidth = (size, theme) => `calc(((100% - (${theme.shared.columns} - 1) * ${theme.shared.gap}) * ${size} / ${theme.shared.columns}) + (${size} - 1) * ${theme.shared.gap})`;
13
- const fixedSizeStyles = (size, theme) => {
11
+ const numericOffsetMargin = (offset, columns, gap) => `calc(((100% - (${columns} - 1) * ${gap}) * ${offset} / ${columns}) + ${offset} * ${gap})`;
12
+ const numericSizeWidth = (size, columns, gap) => `calc(((100% - (${columns} - 1) * ${gap}) * ${size} / ${columns}) + (${size} - 1) * ${gap})`;
13
+ const fixedSizeStyles = (size, theme, breakpoint) => {
14
14
  if (size === "grow") {
15
15
  return react.css`
16
16
  flex-basis: 0;
@@ -27,59 +27,53 @@ const fixedSizeStyles = (size, theme) => {
27
27
  max-width: none;
28
28
  `;
29
29
  }
30
- const clampedSize = clampToColumns(size, theme.shared.columns);
31
- const width = numericSizeWidth(clampedSize, theme);
30
+ const width = numericSizeWidth(
31
+ clampToColumns(size, theme[breakpoint].columns),
32
+ theme[breakpoint].columns,
33
+ theme[breakpoint].gap
34
+ );
32
35
  return react.css`
33
- flex-basis: ${width};
34
36
  flex-grow: 0;
37
+ flex-basis: ${width};
35
38
  width: ${width};
36
39
  max-width: ${width};
37
40
  `;
38
41
  };
39
- const fixedOffsetStyles = (offset, theme) => {
42
+ const fixedOffsetStyles = (offset, theme, breakpoint) => {
43
+ if (typeof offset === "undefined") {
44
+ return react.css``;
45
+ }
40
46
  if (offset === "auto") {
41
47
  return react.css`
42
48
  margin-left: auto;
43
49
  `;
44
50
  }
45
- const clampedOffset = clampToColumns(offset, theme.shared.columns);
46
51
  return react.css`
47
- margin-left: ${numericOffsetMargin(clampedOffset, theme)};
52
+ margin-left: ${numericOffsetMargin(
53
+ clampToColumns(offset, theme[breakpoint].columns),
54
+ theme[breakpoint].columns,
55
+ theme[breakpoint].gap
56
+ )};
48
57
  `;
49
58
  };
50
- const offsetStyles = (offset, theme) => {
51
- if (typeof offset === "undefined") {
52
- return react.css``;
53
- }
59
+ const offsetStyles = (offset, theme, breakpoint) => {
54
60
  if (!isResponsiveOffset(offset)) {
55
- return fixedOffsetStyles(offset, theme);
61
+ return fixedOffsetStyles(offset, theme, breakpoint);
56
62
  }
57
- return react.css`
58
- ${Object.entries(offset).map(
59
- ([breakpoint, breakpointOffset]) => react.css`
60
- ${mq.from[breakpoint]} {
61
- ${fixedOffsetStyles(breakpointOffset, theme)}
62
- }
63
- `
64
- )}
65
- `;
63
+ return fixedOffsetStyles(offset[breakpoint], theme, breakpoint);
66
64
  };
67
- const sizeStyles = (size, theme) => {
65
+ const sizeStyles = (size, theme, breakpoint) => {
68
66
  if (typeof size === "undefined") {
69
- return fixedSizeStyles(theme.shared.columns, theme);
67
+ size = theme[breakpoint].columns;
70
68
  }
71
69
  if (!isResponsiveGridSize(size)) {
72
- return fixedSizeStyles(size, theme);
70
+ return fixedSizeStyles(size, theme, breakpoint);
73
71
  }
74
- return react.css`
75
- ${Object.entries(size).map(
76
- ([breakpoint, breakpointSize]) => react.css`
77
- ${mq.from[breakpoint]} {
78
- ${fixedSizeStyles(breakpointSize, theme)}
79
- }
80
- `
81
- )}
82
- `;
72
+ return fixedSizeStyles(
73
+ size[breakpoint] ?? theme[breakpoint].columns,
74
+ theme,
75
+ breakpoint
76
+ );
83
77
  };
84
78
  const gridStyles = (theme) => {
85
79
  return react.css`
@@ -87,17 +81,43 @@ const gridStyles = (theme) => {
87
81
  width: ${theme.shared.width};
88
82
  flex-direction: ${theme.shared.direction};
89
83
  flex-wrap: ${theme.shared.wrap};
90
- padding: 0 ${theme.shared.gap};
91
- gap: ${theme.shared.gap};
92
84
  justify-content: ${theme.shared.justifyContent};
93
85
  align-items: ${theme.shared.alignItems};
86
+
87
+ ${mq.from.sm} {
88
+ gap: ${theme.sm.gap};
89
+ padding: 0 ${theme.sm.padding};
90
+ }
91
+
92
+ ${mq.from.md} {
93
+ gap: ${theme.md.gap};
94
+ padding: 0 ${theme.md.padding};
95
+ }
96
+
97
+ ${mq.from.lg} {
98
+ gap: ${theme.lg.gap};
99
+ padding: 0 ${theme.lg.padding};
100
+ }
94
101
  `;
95
102
  };
96
103
  const itemStyles = (theme, { size, offset }) => {
97
104
  return react.css`
98
105
  min-width: 0;
99
- ${sizeStyles(size, theme)}
100
- ${offsetStyles(offset, theme)}
106
+
107
+ ${mq.from.sm} {
108
+ ${sizeStyles(size, theme, "sm")}
109
+ ${offsetStyles(offset, theme, "sm")}
110
+ }
111
+
112
+ ${mq.from.md} {
113
+ ${sizeStyles(size, theme, "md")}
114
+ ${offsetStyles(offset, theme, "md")}
115
+ }
116
+
117
+ ${mq.from.lg} {
118
+ ${sizeStyles(size, theme, "lg")}
119
+ ${offsetStyles(offset, theme, "lg")}
120
+ }
101
121
  `;
102
122
  };
103
123
 
@@ -6,9 +6,9 @@ const defaultGridTheme = componentGrid;
6
6
  const isResponsiveGridSize = (size) => typeof size === "object";
7
7
  const isResponsiveOffset = (offset) => typeof offset === "object";
8
8
  const clampToColumns = (value, columns) => Math.max(0, Math.min(value, columns));
9
- const numericOffsetMargin = (offset, theme) => `calc(((100% - (${theme.shared.columns} - 1) * ${theme.shared.gap}) * ${offset} / ${theme.shared.columns}) + ${offset} * ${theme.shared.gap})`;
10
- const numericSizeWidth = (size, theme) => `calc(((100% - (${theme.shared.columns} - 1) * ${theme.shared.gap}) * ${size} / ${theme.shared.columns}) + (${size} - 1) * ${theme.shared.gap})`;
11
- const fixedSizeStyles = (size, theme) => {
9
+ const numericOffsetMargin = (offset, columns, gap) => `calc(((100% - (${columns} - 1) * ${gap}) * ${offset} / ${columns}) + ${offset} * ${gap})`;
10
+ const numericSizeWidth = (size, columns, gap) => `calc(((100% - (${columns} - 1) * ${gap}) * ${size} / ${columns}) + (${size} - 1) * ${gap})`;
11
+ const fixedSizeStyles = (size, theme, breakpoint) => {
12
12
  if (size === "grow") {
13
13
  return css`
14
14
  flex-basis: 0;
@@ -25,55 +25,41 @@ const fixedSizeStyles = (size, theme) => {
25
25
  max-width: none;
26
26
  `;
27
27
  }
28
- const clampedSize = clampToColumns(size, theme.shared.columns);
29
- const width = numericSizeWidth(clampedSize, theme);
28
+ const width = numericSizeWidth(clampToColumns(size, theme[breakpoint].columns), theme[breakpoint].columns, theme[breakpoint].gap);
30
29
  return css`
31
- flex-basis: ${width};
32
30
  flex-grow: 0;
31
+ flex-basis: ${width};
33
32
  width: ${width};
34
33
  max-width: ${width};
35
34
  `;
36
35
  };
37
- const fixedOffsetStyles = (offset, theme) => {
36
+ const fixedOffsetStyles = (offset, theme, breakpoint) => {
37
+ if (typeof offset === "undefined") {
38
+ return css``;
39
+ }
38
40
  if (offset === "auto") {
39
41
  return css`
40
42
  margin-left: auto;
41
43
  `;
42
44
  }
43
- const clampedOffset = clampToColumns(offset, theme.shared.columns);
44
45
  return css`
45
- margin-left: ${numericOffsetMargin(clampedOffset, theme)};
46
+ margin-left: ${numericOffsetMargin(clampToColumns(offset, theme[breakpoint].columns), theme[breakpoint].columns, theme[breakpoint].gap)};
46
47
  `;
47
48
  };
48
- const offsetStyles = (offset, theme) => {
49
- if (typeof offset === "undefined") {
50
- return css``;
51
- }
49
+ const offsetStyles = (offset, theme, breakpoint) => {
52
50
  if (!isResponsiveOffset(offset)) {
53
- return fixedOffsetStyles(offset, theme);
51
+ return fixedOffsetStyles(offset, theme, breakpoint);
54
52
  }
55
- return css`
56
- ${Object.entries(offset).map(([breakpoint, breakpointOffset]) => css`
57
- ${from[breakpoint]} {
58
- ${fixedOffsetStyles(breakpointOffset, theme)}
59
- }
60
- `)}
61
- `;
53
+ return fixedOffsetStyles(offset[breakpoint], theme, breakpoint);
62
54
  };
63
- const sizeStyles = (size, theme) => {
55
+ const sizeStyles = (size, theme, breakpoint) => {
64
56
  if (typeof size === "undefined") {
65
- return fixedSizeStyles(theme.shared.columns, theme);
57
+ size = theme[breakpoint].columns;
66
58
  }
67
59
  if (!isResponsiveGridSize(size)) {
68
- return fixedSizeStyles(size, theme);
60
+ return fixedSizeStyles(size, theme, breakpoint);
69
61
  }
70
- return css`
71
- ${Object.entries(size).map(([breakpoint, breakpointSize]) => css`
72
- ${from[breakpoint]} {
73
- ${fixedSizeStyles(breakpointSize, theme)}
74
- }
75
- `)}
76
- `;
62
+ return fixedSizeStyles(size[breakpoint] ?? theme[breakpoint].columns, theme, breakpoint);
77
63
  };
78
64
  const gridStyles = (theme) => {
79
65
  return css`
@@ -81,17 +67,43 @@ const gridStyles = (theme) => {
81
67
  width: ${theme.shared.width};
82
68
  flex-direction: ${theme.shared.direction};
83
69
  flex-wrap: ${theme.shared.wrap};
84
- padding: 0 ${theme.shared.gap};
85
- gap: ${theme.shared.gap};
86
70
  justify-content: ${theme.shared.justifyContent};
87
71
  align-items: ${theme.shared.alignItems};
72
+
73
+ ${from.sm} {
74
+ gap: ${theme.sm.gap};
75
+ padding: 0 ${theme.sm.padding};
76
+ }
77
+
78
+ ${from.md} {
79
+ gap: ${theme.md.gap};
80
+ padding: 0 ${theme.md.padding};
81
+ }
82
+
83
+ ${from.lg} {
84
+ gap: ${theme.lg.gap};
85
+ padding: 0 ${theme.lg.padding};
86
+ }
88
87
  `;
89
88
  };
90
89
  const itemStyles = (theme, { size, offset }) => {
91
90
  return css`
92
91
  min-width: 0;
93
- ${sizeStyles(size, theme)}
94
- ${offsetStyles(offset, theme)}
92
+
93
+ ${from.sm} {
94
+ ${sizeStyles(size, theme, "sm")}
95
+ ${offsetStyles(offset, theme, "sm")}
96
+ }
97
+
98
+ ${from.md} {
99
+ ${sizeStyles(size, theme, "md")}
100
+ ${offsetStyles(offset, theme, "md")}
101
+ }
102
+
103
+ ${from.lg} {
104
+ ${sizeStyles(size, theme, "lg")}
105
+ ${offsetStyles(offset, theme, "lg")}
106
+ }
95
107
  `;
96
108
  };
97
109
 
@@ -1,6 +1,6 @@
1
1
  import { jsx } from '@emotion/react/jsx-runtime';
2
2
  import { mergeDeep } from '../../util/mergeDeep.js';
3
- import { iconStyles, defaultIconTheme } from './styles.js';
3
+ import { defaultIconTheme, iconStyles } from './styles.js';
4
4
 
5
5
  function Icon({ children, size = "md", fill, alt, symbol, theme = {}, cssOverrides, className }) {
6
6
  const mergedTheme = mergeDeep(defaultIconTheme, theme);
@@ -3,7 +3,7 @@ import { useRef, useEffect } from 'react';
3
3
  import { Button, composeRenderProps } from 'react-aria-components';
4
4
  import { mergeDeep } from '../../util/mergeDeep.js';
5
5
  import { Icon } from '../icon/Icon.js';
6
- import { iconButtonStyles, defaultIconButtonTheme } from './styles.js';
6
+ import { defaultIconButtonTheme, iconButtonStyles } from './styles.js';
7
7
 
8
8
  function IconButton({ variant = "primary", size = "md", symbol, ariaLabel, theme = {}, cssOverrides, ...props }) {
9
9
  const mergedTheme = mergeDeep(defaultIconButtonTheme, theme);
@@ -1,4 +1,4 @@
1
- import { buttonStyles, defaultButtonTheme } from '../button/styles.js';
1
+ import { defaultButtonTheme, buttonStyles } from '../button/styles.js';
2
2
 
3
3
  const defaultIconButtonTheme = defaultButtonTheme;
4
4
  const iconButtonStyles = buttonStyles;
@@ -3,7 +3,7 @@ import { useRef, useEffect } from 'react';
3
3
  import { Link, composeRenderProps } from 'react-aria-components';
4
4
  import { mergeDeep } from '../../util/mergeDeep.js';
5
5
  import { Icon } from '../icon/Icon.js';
6
- import { iconLinkButtonStyles, defaultIconLinkButtonTheme } from './styles.js';
6
+ import { defaultIconLinkButtonTheme, iconLinkButtonStyles } from './styles.js';
7
7
 
8
8
  function IconLinkButton({ variant = "primary", size = "md", symbol, ariaLabel, theme = {}, cssOverrides, ...props }) {
9
9
  const mergedTheme = mergeDeep(defaultIconLinkButtonTheme, theme);
@@ -1,4 +1,4 @@
1
- import { buttonStyles, defaultButtonTheme } from '../button/styles.js';
1
+ import { defaultButtonTheme, buttonStyles } from '../button/styles.js';
2
2
 
3
3
  const defaultIconLinkButtonTheme = defaultButtonTheme;
4
4
  const iconLinkButtonStyles = buttonStyles;
@@ -3,7 +3,7 @@ import { useMemo } from 'react';
3
3
  import { mergeDeep } from '../../util/mergeDeep.js';
4
4
  import { Icon } from '../icon/Icon.js';
5
5
  import { Typography } from '../typography/Typography.js';
6
- import { inlineMessageIconStyles, inlineMessageStyles, defaultInlineMessageTheme } from './styles.js';
6
+ import { defaultInlineMessageTheme, inlineMessageIconStyles, inlineMessageStyles } from './styles.js';
7
7
 
8
8
  function InlineMessage({ children, level, hideIcon = false, icon, theme = {}, cssOverrides, className, ...props }) {
9
9
  const mergedTheme = mergeDeep(defaultInlineMessageTheme, theme);
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from '@emotion/react/jsx-runtime';
2
2
  import { mergeDeep } from '../../util/mergeDeep.js';
3
3
  import { DoubleChevronRightSvg, globeIcon, auFlag, usFlag, ukFlag } from './FlagIcons.js';
4
- import { intendedAudienceSignifierStyles, intendedAudienceSignifierIconStyles, intendedAudienceSignifierChevronIconStyles, defaultIntendedAudienceSignifierTheme } from './styles.js';
4
+ import { defaultIntendedAudienceSignifierTheme, intendedAudienceSignifierStyles, intendedAudienceSignifierIconStyles, intendedAudienceSignifierChevronIconStyles } from './styles.js';
5
5
 
6
6
  const sourceIcons = {
7
7
  UK: ukFlag,
@@ -1,15 +1,27 @@
1
1
  'use strict';
2
2
 
3
3
  var jsxRuntime = require('@emotion/react/jsx-runtime');
4
- var react = require('@emotion/react');
5
- var React = require('react');
6
4
  var mergeDeep = require('../../util/mergeDeep.cjs');
7
- var AlertBanner = require('../alert-banner/AlertBanner.cjs');
8
- var Grid = require('../grid/Grid.cjs');
9
- var TopBar = require('../topbar/TopBar.cjs');
10
5
  var styles = require('./styles.cjs');
11
6
 
12
- function Sidebar({
7
+ const LayoutAlertBanner = ({
8
+ as: Component = "aside",
9
+ children,
10
+ cssOverrides,
11
+ ...props
12
+ }) => {
13
+ return /* @__PURE__ */ jsxRuntime.jsx(Component, { css: [styles.alertBannerLayoutStyles(), cssOverrides], ...props, children });
14
+ };
15
+ const LayoutTopBar = ({
16
+ as: Component = "nav",
17
+ children,
18
+ cssOverrides,
19
+ ...props
20
+ }) => {
21
+ return /* @__PURE__ */ jsxRuntime.jsx(Component, { css: [styles.topBarLayoutStyles(), cssOverrides], ...props, children });
22
+ };
23
+ function LayoutSidebar({
24
+ as: Component = "aside",
13
25
  children,
14
26
  layoutSmBreakpoint = "hidden",
15
27
  theme = {},
@@ -18,97 +30,50 @@ function Sidebar({
18
30
  }) {
19
31
  const mergedTheme = mergeDeep.mergeDeep(styles.defaultSidebarTheme, theme);
20
32
  return /* @__PURE__ */ jsxRuntime.jsx(
21
- "aside",
33
+ Component,
22
34
  {
23
- css: [styles.sidebarStyles(mergedTheme, { layoutSmBreakpoint }), cssOverrides],
35
+ css: [
36
+ styles.sidebarLayoutStyles(),
37
+ styles.sidebarStyles(mergedTheme, { layoutSmBreakpoint }),
38
+ cssOverrides
39
+ ],
24
40
  ...props,
25
41
  children
26
42
  }
27
43
  );
28
44
  }
29
- function Layout({
45
+ function LayoutMain({
46
+ as: Component = "main",
30
47
  children,
31
48
  fluid = true,
32
49
  theme = {},
33
50
  cssOverrides,
34
51
  ...props
35
52
  }) {
36
- const mergedTheme = mergeDeep.mergeDeep(styles.defaultLayoutTheme, theme);
37
- let alertBanner = null;
38
- let topBar = null;
39
- let sidebar = null;
40
- let main = null;
41
- React.Children.forEach(children, (child) => {
42
- if (!React.isValidElement(child)) {
43
- return;
44
- }
45
- if (child.type === AlertBanner.AlertBanner) {
46
- const alertBannerChild = child;
47
- const alertBannerCssOverrides = Array.isArray(
48
- alertBannerChild.props.cssOverrides
49
- ) ? alertBannerChild.props.cssOverrides : alertBannerChild.props.cssOverrides ? [alertBannerChild.props.cssOverrides] : [];
50
- alertBanner ?? (alertBanner = React.cloneElement(alertBannerChild, {
51
- cssOverrides: [styles.alertBannerLayoutStyles(), ...alertBannerCssOverrides]
52
- }));
53
- return;
54
- }
55
- if (child.type === TopBar.TopBar) {
56
- const topBarChild = child;
57
- const topBarCssOverrides = Array.isArray(topBarChild.props.cssOverrides) ? topBarChild.props.cssOverrides : topBarChild.props.cssOverrides ? [topBarChild.props.cssOverrides] : [];
58
- topBar ?? (topBar = React.cloneElement(topBarChild, {
59
- cssOverrides: [styles.topBarLayoutStyles(), ...topBarCssOverrides]
60
- }));
61
- return;
62
- }
63
- if (child.type === Sidebar) {
64
- const sidebarChild = child;
65
- const sidebarCssOverrides = Array.isArray(sidebarChild.props.cssOverrides) ? sidebarChild.props.cssOverrides : sidebarChild.props.cssOverrides ? [sidebarChild.props.cssOverrides] : [];
66
- sidebar ?? (sidebar = React.cloneElement(sidebarChild, {
67
- cssOverrides: [styles.sidebarLayoutStyles(), ...sidebarCssOverrides]
68
- }));
69
- return;
70
- }
71
- if (child.type === Grid.Grid) {
72
- const gridChild = child;
73
- const gridCssOverrides = Array.isArray(gridChild.props.cssOverrides) ? gridChild.props.cssOverrides : gridChild.props.cssOverrides ? [gridChild.props.cssOverrides] : [];
74
- main ?? (main = React.cloneElement(gridChild, {
75
- as: "main",
76
- cssOverrides: [
77
- styles.mainLayoutStyles(mergedTheme, { fluid }),
78
- ...gridCssOverrides
79
- ]
80
- }));
81
- return;
82
- }
83
- if (!main) {
84
- const childWithProps = child;
85
- if ("cssOverrides" in childWithProps.props) {
86
- const childCssOverrides = Array.isArray(
87
- childWithProps.props.cssOverrides
88
- ) ? childWithProps.props.cssOverrides : [childWithProps.props.cssOverrides ?? react.css``];
89
- main ?? (main = React.cloneElement(childWithProps, {
90
- cssOverrides: [
91
- styles.mainLayoutStyles(mergedTheme, { fluid }),
92
- ...childCssOverrides
93
- ]
94
- }));
95
- } else {
96
- main ?? (main = React.cloneElement(childWithProps, {
97
- css: [
98
- styles.mainLayoutStyles(mergedTheme, { fluid }),
99
- childWithProps.props.css
100
- ]
101
- }));
102
- }
53
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultMainTheme, theme);
54
+ return /* @__PURE__ */ jsxRuntime.jsx(
55
+ Component,
56
+ {
57
+ css: [styles.mainLayoutStyles(mergedTheme, { fluid }), cssOverrides],
58
+ ...props,
59
+ children
103
60
  }
104
- });
105
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { css: [styles.layoutStyles(mergedTheme), cssOverrides], ...props, children: [
106
- alertBanner,
107
- topBar,
108
- sidebar,
109
- main
110
- ] });
61
+ );
62
+ }
63
+ function LayoutRoot({
64
+ children,
65
+ theme = {},
66
+ cssOverrides,
67
+ ...props
68
+ }) {
69
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultLayoutTheme, theme);
70
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { css: [styles.layoutStyles(mergedTheme), cssOverrides], ...props, children });
111
71
  }
72
+ const Layout = Object.assign(LayoutRoot, {
73
+ AlertBanner: LayoutAlertBanner,
74
+ TopBar: LayoutTopBar,
75
+ Sidebar: LayoutSidebar,
76
+ Main: LayoutMain
77
+ });
112
78
 
113
79
  exports.Layout = Layout;
114
- exports.Sidebar = Sidebar;