@guardian/stand 0.0.17 → 0.0.19

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 (66) hide show
  1. package/dist/avatarButton.cjs +7 -0
  2. package/dist/avatarButton.js +1 -0
  3. package/dist/avatarLink.cjs +7 -0
  4. package/dist/avatarLink.js +1 -0
  5. package/dist/components/avatar/styles.cjs +24 -0
  6. package/dist/components/avatar/styles.js +24 -0
  7. package/dist/components/avatar-button/AvatarButton.cjs +14 -0
  8. package/dist/components/avatar-button/AvatarButton.js +12 -0
  9. package/dist/components/avatar-button/styles.cjs +29 -0
  10. package/dist/components/avatar-button/styles.js +26 -0
  11. package/dist/components/avatar-link/AvatarLink.cjs +14 -0
  12. package/dist/components/avatar-link/AvatarLink.js +12 -0
  13. package/dist/components/avatar-link/styles.cjs +24 -0
  14. package/dist/components/avatar-link/styles.js +21 -0
  15. package/dist/components/inline-message/InlineMessage.cjs +56 -0
  16. package/dist/components/inline-message/InlineMessage.js +27 -0
  17. package/dist/components/inline-message/styles.cjs +17 -0
  18. package/dist/components/inline-message/styles.js +14 -0
  19. package/dist/components/select/Select.cjs +67 -0
  20. package/dist/components/select/Select.js +33 -0
  21. package/dist/components/select/styles.cjs +126 -0
  22. package/dist/components/select/styles.js +117 -0
  23. package/dist/index.cjs +4 -0
  24. package/dist/index.js +2 -0
  25. package/dist/inline-message.cjs +9 -0
  26. package/dist/inline-message.js +2 -0
  27. package/dist/select.cjs +9 -0
  28. package/dist/select.js +2 -0
  29. package/dist/styleD/build/css/component/avatar.css +31 -0
  30. package/dist/styleD/build/css/component/inlineMessage.css +17 -0
  31. package/dist/styleD/build/css/component/select.css +57 -0
  32. package/dist/styleD/build/css/semantic/typography.css +38 -0
  33. package/dist/styleD/build/typescript/component/avatar.cjs +95 -12
  34. package/dist/styleD/build/typescript/component/avatar.js +95 -12
  35. package/dist/styleD/build/typescript/component/inlineMessage.cjs +28 -0
  36. package/dist/styleD/build/typescript/component/inlineMessage.js +26 -0
  37. package/dist/styleD/build/typescript/component/select.cjs +88 -0
  38. package/dist/styleD/build/typescript/component/select.js +86 -0
  39. package/dist/styleD/build/typescript/semantic/typography.cjs +50 -0
  40. package/dist/styleD/build/typescript/semantic/typography.js +50 -0
  41. package/dist/types/avatar-button.d.ts +18 -0
  42. package/dist/types/avatar-link.d.ts +18 -0
  43. package/dist/types/components/avatar-button/AvatarButton.d.ts +2 -0
  44. package/dist/types/components/avatar-button/sandbox.d.ts +5 -0
  45. package/dist/types/components/avatar-button/styles.d.ts +6 -0
  46. package/dist/types/components/avatar-button/types.d.ts +3 -0
  47. package/dist/types/components/avatar-link/AvatarLink.d.ts +2 -0
  48. package/dist/types/components/avatar-link/sandbox.d.ts +5 -0
  49. package/dist/types/components/avatar-link/styles.d.ts +6 -0
  50. package/dist/types/components/avatar-link/types.d.ts +3 -0
  51. package/dist/types/components/inline-message/InlineMessage.d.ts +2 -0
  52. package/dist/types/components/inline-message/sandbox.d.ts +5 -0
  53. package/dist/types/components/inline-message/styles.d.ts +8 -0
  54. package/dist/types/components/inline-message/types.d.ts +21 -0
  55. package/dist/types/components/select/Select.d.ts +3 -0
  56. package/dist/types/components/select/sandbox.d.ts +5 -0
  57. package/dist/types/components/select/styles.d.ts +13 -0
  58. package/dist/types/components/select/types.d.ts +21 -0
  59. package/dist/types/index.d.ts +4 -0
  60. package/dist/types/inline-message.d.ts +19 -0
  61. package/dist/types/select.d.ts +20 -0
  62. package/dist/types/styleD/build/typescript/component/avatar.d.ts +83 -0
  63. package/dist/types/styleD/build/typescript/component/inlineMessage.d.ts +28 -0
  64. package/dist/types/styleD/build/typescript/component/select.d.ts +88 -0
  65. package/dist/types/styleD/build/typescript/semantic/typography.d.ts +50 -0
  66. package/package.json +39 -5
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var AvatarButton = require('./components/avatar-button/AvatarButton.cjs');
4
+
5
+
6
+
7
+ exports.AvatarButton = AvatarButton.AvatarButton;
@@ -0,0 +1 @@
1
+ export { AvatarButton } from './components/avatar-button/AvatarButton.js';
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var AvatarLink = require('./components/avatar-link/AvatarLink.cjs');
4
+
5
+
6
+
7
+ exports.AvatarLink = AvatarLink.AvatarLink;
@@ -0,0 +1 @@
1
+ export { AvatarLink } from './components/avatar-link/AvatarLink.js';
@@ -25,6 +25,30 @@ const avatarStyles = (theme, { size, color }) => {
25
25
  user-select: ${theme.shared["user-select"]};
26
26
  color: ${theme.shared.color[color].text};
27
27
  ${typography.convertTypographyToEmotionStringStyle(theme[size].typography)}
28
+
29
+ &[data-avatar-context='interactive']:hover {
30
+ background-color: ${theme.shared.color[color][":hover"].background};
31
+
32
+ :has(> img) {
33
+ background-color: black;
34
+ }
35
+
36
+ img {
37
+ mask-image: linear-gradient(rgb(0 0 0 / 70%), rgb(0 0 0 / 70%));
38
+ }
39
+ }
40
+
41
+ &[data-avatar-context='interactive']:active {
42
+ background-color: ${theme.shared.color[color][":active"].background};
43
+
44
+ :has(> img) {
45
+ background-color: black;
46
+ }
47
+
48
+ img {
49
+ mask-image: linear-gradient(rgb(0 0 0 / 60%), rgb(0 0 0 / 60%));
50
+ }
51
+ }
28
52
  `;
29
53
  };
30
54
 
@@ -23,6 +23,30 @@ const avatarStyles = (theme, { size, color }) => {
23
23
  user-select: ${theme.shared["user-select"]};
24
24
  color: ${theme.shared.color[color].text};
25
25
  ${convertTypographyToEmotionStringStyle(theme[size].typography)}
26
+
27
+ &[data-avatar-context='interactive']:hover {
28
+ background-color: ${theme.shared.color[color][":hover"].background};
29
+
30
+ :has(> img) {
31
+ background-color: black;
32
+ }
33
+
34
+ img {
35
+ mask-image: linear-gradient(rgb(0 0 0 / 70%), rgb(0 0 0 / 70%));
36
+ }
37
+ }
38
+
39
+ &[data-avatar-context='interactive']:active {
40
+ background-color: ${theme.shared.color[color][":active"].background};
41
+
42
+ :has(> img) {
43
+ background-color: black;
44
+ }
45
+
46
+ img {
47
+ mask-image: linear-gradient(rgb(0 0 0 / 60%), rgb(0 0 0 / 60%));
48
+ }
49
+ }
26
50
  `;
27
51
  };
28
52
 
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
4
+ var reactAriaComponents = require('react-aria-components');
5
+ var mergeDeep = require('../../util/mergeDeep.cjs');
6
+ var Avatar = require('../avatar/Avatar.cjs');
7
+ var styles = require('./styles.cjs');
8
+
9
+ function AvatarButton(props) {
10
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultAvatarButtonTheme, props.theme ?? {});
11
+ return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Button, { css: styles.avatarButtonStyles(mergedTheme), ...props, children: /* @__PURE__ */ jsxRuntime.jsx(Avatar.Avatar, { ...props, "data-avatar-context": "interactive" }) });
12
+ }
13
+
14
+ exports.AvatarButton = AvatarButton;
@@ -0,0 +1,12 @@
1
+ import { jsx } from '@emotion/react/jsx-runtime';
2
+ import { Button } from 'react-aria-components';
3
+ import { mergeDeep } from '../../util/mergeDeep.js';
4
+ import { Avatar } from '../avatar/Avatar.js';
5
+ import { defaultAvatarButtonTheme, avatarButtonStyles } from './styles.js';
6
+
7
+ function AvatarButton(props) {
8
+ const mergedTheme = mergeDeep(defaultAvatarButtonTheme, props.theme ?? {});
9
+ return jsx(Button, { css: avatarButtonStyles(mergedTheme), ...props, children: jsx(Avatar, { ...props, "data-avatar-context": "interactive" }) });
10
+ }
11
+
12
+ export { AvatarButton };
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ var react = require('@emotion/react');
4
+ var styles = require('../avatar/styles.cjs');
5
+
6
+ const defaultAvatarButtonTheme = styles.defaultAvatarTheme;
7
+ const avatarButtonStyles = (theme) => {
8
+ return react.css`
9
+ display: ${theme.shared.display};
10
+ width: ${theme.shared.link.width};
11
+ background: ${theme.shared.button.background};
12
+ border: ${theme.shared.button.border};
13
+ padding: ${theme.shared.button.padding};
14
+ cursor: ${theme.shared.button.cursor};
15
+ &[data-focus-visible],
16
+ &:focus-visible {
17
+ outline: ${theme.shared.link[":focus-visible"].outline};
18
+ outline-offset: ${theme.shared.link[":focus-visible"]["outline-offset"]};
19
+ border-radius: ${theme.shared["border-radius"]};
20
+ }
21
+ &[data-disabled],
22
+ &:disabled {
23
+ cursor: ${theme.shared.button[":disabled"].cursor};
24
+ }
25
+ `;
26
+ };
27
+
28
+ exports.avatarButtonStyles = avatarButtonStyles;
29
+ exports.defaultAvatarButtonTheme = defaultAvatarButtonTheme;
@@ -0,0 +1,26 @@
1
+ import { css } from '@emotion/react';
2
+ import { defaultAvatarTheme } from '../avatar/styles.js';
3
+
4
+ const defaultAvatarButtonTheme = defaultAvatarTheme;
5
+ const avatarButtonStyles = (theme) => {
6
+ return css`
7
+ display: ${theme.shared.display};
8
+ width: ${theme.shared.link.width};
9
+ background: ${theme.shared.button.background};
10
+ border: ${theme.shared.button.border};
11
+ padding: ${theme.shared.button.padding};
12
+ cursor: ${theme.shared.button.cursor};
13
+ &[data-focus-visible],
14
+ &:focus-visible {
15
+ outline: ${theme.shared.link[":focus-visible"].outline};
16
+ outline-offset: ${theme.shared.link[":focus-visible"]["outline-offset"]};
17
+ border-radius: ${theme.shared["border-radius"]};
18
+ }
19
+ &[data-disabled],
20
+ &:disabled {
21
+ cursor: ${theme.shared.button[":disabled"].cursor};
22
+ }
23
+ `;
24
+ };
25
+
26
+ export { avatarButtonStyles, defaultAvatarButtonTheme };
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
4
+ var reactAriaComponents = require('react-aria-components');
5
+ var mergeDeep = require('../../util/mergeDeep.cjs');
6
+ var Avatar = require('../avatar/Avatar.cjs');
7
+ var styles = require('./styles.cjs');
8
+
9
+ function AvatarLink(props) {
10
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultAvatarLinkTheme, props.theme ?? {});
11
+ return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Link, { css: styles.avatarLinkStyles(mergedTheme), ...props, children: /* @__PURE__ */ jsxRuntime.jsx(Avatar.Avatar, { ...props, "data-avatar-context": "interactive" }) });
12
+ }
13
+
14
+ exports.AvatarLink = AvatarLink;
@@ -0,0 +1,12 @@
1
+ import { jsx } from '@emotion/react/jsx-runtime';
2
+ import { Link } from 'react-aria-components';
3
+ import { mergeDeep } from '../../util/mergeDeep.js';
4
+ import { Avatar } from '../avatar/Avatar.js';
5
+ import { defaultAvatarLinkTheme, avatarLinkStyles } from './styles.js';
6
+
7
+ function AvatarLink(props) {
8
+ const mergedTheme = mergeDeep(defaultAvatarLinkTheme, props.theme ?? {});
9
+ return jsx(Link, { css: avatarLinkStyles(mergedTheme), ...props, children: jsx(Avatar, { ...props, "data-avatar-context": "interactive" }) });
10
+ }
11
+
12
+ export { AvatarLink };
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var react = require('@emotion/react');
4
+ var styles = require('../avatar/styles.cjs');
5
+
6
+ const defaultAvatarLinkTheme = styles.defaultAvatarTheme;
7
+ const avatarLinkStyles = (theme) => {
8
+ return react.css`
9
+ display: ${theme.shared.display};
10
+ width: ${theme.shared.link.width};
11
+
12
+ &[data-focus-visible],
13
+ &:focus-visible {
14
+ outline: ${theme.shared.link[":focus-visible"].outline};
15
+ outline-offset: ${theme.shared.link[":focus-visible"]["outline-offset"]};
16
+ border-radius: ${theme.shared["border-radius"]};
17
+ }
18
+
19
+ text-decoration: ${theme.shared.link["text-decoration"]};
20
+ `;
21
+ };
22
+
23
+ exports.avatarLinkStyles = avatarLinkStyles;
24
+ exports.defaultAvatarLinkTheme = defaultAvatarLinkTheme;
@@ -0,0 +1,21 @@
1
+ import { css } from '@emotion/react';
2
+ import { defaultAvatarTheme } from '../avatar/styles.js';
3
+
4
+ const defaultAvatarLinkTheme = defaultAvatarTheme;
5
+ const avatarLinkStyles = (theme) => {
6
+ return css`
7
+ display: ${theme.shared.display};
8
+ width: ${theme.shared.link.width};
9
+
10
+ &[data-focus-visible],
11
+ &:focus-visible {
12
+ outline: ${theme.shared.link[":focus-visible"].outline};
13
+ outline-offset: ${theme.shared.link[":focus-visible"]["outline-offset"]};
14
+ border-radius: ${theme.shared["border-radius"]};
15
+ }
16
+
17
+ text-decoration: ${theme.shared.link["text-decoration"]};
18
+ `;
19
+ };
20
+
21
+ export { avatarLinkStyles, defaultAvatarLinkTheme };
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
4
+ var React = require('react');
5
+ var mergeDeep = require('../../util/mergeDeep.cjs');
6
+ var Icon = require('../icon/Icon.cjs');
7
+ var Typography = require('../typography/Typography.cjs');
8
+ var styles = require('./styles.cjs');
9
+
10
+ function InlineMessage({
11
+ children,
12
+ level,
13
+ hideIcon = false,
14
+ icon,
15
+ theme = {},
16
+ cssOverrides,
17
+ className,
18
+ ...props
19
+ }) {
20
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultInlineMessageTheme, theme);
21
+ const determinedIcon = React.useMemo(() => {
22
+ if (icon) {
23
+ return icon;
24
+ }
25
+ switch (level) {
26
+ case "error":
27
+ return "warning";
28
+ case "success":
29
+ return "check_circle";
30
+ case "information":
31
+ default:
32
+ return "info";
33
+ }
34
+ }, [icon, level]);
35
+ return /* @__PURE__ */ jsxRuntime.jsxs(
36
+ "div",
37
+ {
38
+ css: [styles.inlineMessageStyles(mergedTheme, { level }), cssOverrides],
39
+ className,
40
+ ...props,
41
+ children: [
42
+ !hideIcon && /* @__PURE__ */ jsxRuntime.jsx(Icon.Icon, { fill: mergedTheme[level].color, size: "md", children: determinedIcon }),
43
+ /* @__PURE__ */ jsxRuntime.jsx(
44
+ Typography.Typography,
45
+ {
46
+ variant: "help-text-form-md",
47
+ theme: { color: mergedTheme[level].color },
48
+ children
49
+ }
50
+ )
51
+ ]
52
+ }
53
+ );
54
+ }
55
+
56
+ exports.InlineMessage = InlineMessage;
@@ -0,0 +1,27 @@
1
+ import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
+ import { useMemo } from 'react';
3
+ import { mergeDeep } from '../../util/mergeDeep.js';
4
+ import { Icon } from '../icon/Icon.js';
5
+ import { Typography } from '../typography/Typography.js';
6
+ import { inlineMessageStyles, defaultInlineMessageTheme } from './styles.js';
7
+
8
+ function InlineMessage({ children, level, hideIcon = false, icon, theme = {}, cssOverrides, className, ...props }) {
9
+ const mergedTheme = mergeDeep(defaultInlineMessageTheme, theme);
10
+ const determinedIcon = useMemo(() => {
11
+ if (icon) {
12
+ return icon;
13
+ }
14
+ switch (level) {
15
+ case "error":
16
+ return "warning";
17
+ case "success":
18
+ return "check_circle";
19
+ case "information":
20
+ default:
21
+ return "info";
22
+ }
23
+ }, [icon, level]);
24
+ return jsxs("div", { css: [inlineMessageStyles(mergedTheme, { level }), cssOverrides], className, ...props, children: [!hideIcon && jsx(Icon, { fill: mergedTheme[level].color, size: "md", children: determinedIcon }), jsx(Typography, { variant: "help-text-form-md", theme: { color: mergedTheme[level].color }, children })] });
25
+ }
26
+
27
+ export { InlineMessage };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var react = require('@emotion/react');
4
+ var inlineMessage = require('../../styleD/build/typescript/component/inlineMessage.cjs');
5
+
6
+ const defaultInlineMessageTheme = inlineMessage.componentInlineMessage;
7
+ const inlineMessageStyles = (theme, { level }) => {
8
+ return react.css`
9
+ display: ${theme.shared.display};
10
+ align-items: ${theme.shared["align-items"]};
11
+ gap: ${theme.shared.gap};
12
+ color: ${theme[level].color};
13
+ `;
14
+ };
15
+
16
+ exports.defaultInlineMessageTheme = defaultInlineMessageTheme;
17
+ exports.inlineMessageStyles = inlineMessageStyles;
@@ -0,0 +1,14 @@
1
+ import { css } from '@emotion/react';
2
+ import { componentInlineMessage } from '../../styleD/build/typescript/component/inlineMessage.js';
3
+
4
+ const defaultInlineMessageTheme = componentInlineMessage;
5
+ const inlineMessageStyles = (theme, { level }) => {
6
+ return css`
7
+ display: ${theme.shared.display};
8
+ align-items: ${theme.shared["align-items"]};
9
+ gap: ${theme.shared.gap};
10
+ color: ${theme[level].color};
11
+ `;
12
+ };
13
+
14
+ export { defaultInlineMessageTheme, inlineMessageStyles };
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
4
+ var React = require('react');
5
+ var reactAriaComponents = require('react-aria-components');
6
+ var mergeDeep = require('../../util/mergeDeep.cjs');
7
+ var Icon = require('../icon/Icon.cjs');
8
+ var InlineMessage = require('../inline-message/InlineMessage.cjs');
9
+ var styles = require('./styles.cjs');
10
+
11
+ function Option({ children, theme = {} }) {
12
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultSelectTheme, theme);
13
+ return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.ListBoxItem, { css: styles.listBoxItemStyles(mergedTheme), children });
14
+ }
15
+ function ListBox({ children, theme = {} }) {
16
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultSelectTheme, theme);
17
+ const items = [];
18
+ React.Children.forEach(children, (child, i) => {
19
+ if (!React.isValidElement(child)) {
20
+ return;
21
+ }
22
+ if (child.type === Option) {
23
+ items.push(
24
+ React.cloneElement(child, {
25
+ key: `${child.key}-${i}`
26
+ })
27
+ );
28
+ }
29
+ });
30
+ return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.ListBox, { css: styles.listBoxStyles(mergedTheme), children: items });
31
+ }
32
+ function Select({
33
+ children,
34
+ label,
35
+ contextualHelpText,
36
+ theme = {},
37
+ cssOverrides,
38
+ className,
39
+ isInvalid,
40
+ errorMessage,
41
+ ...props
42
+ }) {
43
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultSelectTheme, theme);
44
+ return /* @__PURE__ */ jsxRuntime.jsxs(
45
+ reactAriaComponents.Select,
46
+ {
47
+ css: [styles.selectStyles(mergedTheme), cssOverrides],
48
+ className,
49
+ isInvalid,
50
+ ...props,
51
+ children: [
52
+ label && /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Label, { css: styles.labelStyles(mergedTheme), children: label }),
53
+ " ",
54
+ contextualHelpText && /* @__PURE__ */ jsxRuntime.jsx("div", { css: styles.helpTextStyles(mergedTheme), children: contextualHelpText }),
55
+ /* @__PURE__ */ jsxRuntime.jsxs(reactAriaComponents.Button, { css: styles.buttonStyles(mergedTheme, isInvalid), children: [
56
+ /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.SelectValue, {}),
57
+ /* @__PURE__ */ jsxRuntime.jsx(Icon.Icon, { symbol: "keyboard_arrow_down", size: "lg" })
58
+ ] }),
59
+ /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.FieldError, { children: /* @__PURE__ */ jsxRuntime.jsx(InlineMessage.InlineMessage, { level: "error", children: errorMessage }) }),
60
+ /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Popover, { css: styles.popoverStyles(mergedTheme), children: /* @__PURE__ */ jsxRuntime.jsx(ListBox, { children }) })
61
+ ]
62
+ }
63
+ );
64
+ }
65
+
66
+ exports.Option = Option;
67
+ exports.Select = Select;
@@ -0,0 +1,33 @@
1
+ import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
+ import React from 'react';
3
+ import { Select as Select$1, Label, Button, SelectValue, FieldError, Popover, ListBox as ListBox$1, ListBoxItem } from 'react-aria-components';
4
+ import { mergeDeep } from '../../util/mergeDeep.js';
5
+ import { Icon } from '../icon/Icon.js';
6
+ import { InlineMessage } from '../inline-message/InlineMessage.js';
7
+ import { labelStyles, helpTextStyles, buttonStyles, popoverStyles, selectStyles, defaultSelectTheme, listBoxStyles, listBoxItemStyles } from './styles.js';
8
+
9
+ function Option({ children, theme = {} }) {
10
+ const mergedTheme = mergeDeep(defaultSelectTheme, theme);
11
+ return jsx(ListBoxItem, { css: listBoxItemStyles(mergedTheme), children });
12
+ }
13
+ function ListBox({ children, theme = {} }) {
14
+ const mergedTheme = mergeDeep(defaultSelectTheme, theme);
15
+ const items = [];
16
+ React.Children.forEach(children, (child, i) => {
17
+ if (!React.isValidElement(child)) {
18
+ return;
19
+ }
20
+ if (child.type === Option) {
21
+ items.push(React.cloneElement(child, {
22
+ key: `${child.key}-${i}`
23
+ }));
24
+ }
25
+ });
26
+ return jsx(ListBox$1, { css: listBoxStyles(mergedTheme), children: items });
27
+ }
28
+ function Select({ children, label, contextualHelpText, theme = {}, cssOverrides, className, isInvalid, errorMessage, ...props }) {
29
+ const mergedTheme = mergeDeep(defaultSelectTheme, theme);
30
+ return jsxs(Select$1, { css: [selectStyles(mergedTheme), cssOverrides], className, isInvalid, ...props, children: [label && jsx(Label, { css: labelStyles(mergedTheme), children: label }), " ", contextualHelpText && jsx("div", { css: helpTextStyles(mergedTheme), children: contextualHelpText }), jsxs(Button, { css: buttonStyles(mergedTheme, isInvalid), children: [jsx(SelectValue, {}), jsx(Icon, { symbol: "keyboard_arrow_down", size: "lg" })] }), jsx(FieldError, { children: jsx(InlineMessage, { level: "error", children: errorMessage }) }), jsx(Popover, { css: popoverStyles(mergedTheme), children: jsx(ListBox, { children }) })] });
31
+ }
32
+
33
+ export { Option, Select };
@@ -0,0 +1,126 @@
1
+ 'use strict';
2
+
3
+ var react = require('@emotion/react');
4
+ var select = require('../../styleD/build/typescript/component/select.cjs');
5
+ var typography = require('../../styleD/utils/semantic/typography.cjs');
6
+
7
+ const defaultSelectTheme = select.componentSelect;
8
+ const selectStyles = (theme) => {
9
+ return react.css`
10
+ display: ${theme.shared.display};
11
+ flex-direction: ${theme.shared.flexDirection};
12
+ gap: ${theme.shared.gap};
13
+
14
+ max-width: ${theme.shared.maxWidth};
15
+ width: ${theme.shared.width};
16
+ `;
17
+ };
18
+ const popoverStyles = (theme) => {
19
+ return react.css`
20
+ max-width: ${theme.shared.maxWidth};
21
+ width: ${theme.shared.width};
22
+ `;
23
+ };
24
+ const listBoxItemStyles = (theme) => {
25
+ return react.css`
26
+ padding-left: ${theme.option.paddingLeft};
27
+ padding-right: ${theme.option.paddingRight};
28
+ padding-top: ${theme.option.paddingTop};
29
+ padding-bottom: ${theme.option.paddingBottom};
30
+
31
+ &[data-hovered] {
32
+ outline: ${theme.shared.hover.outline};
33
+ }
34
+
35
+ /* Hovering adds data-focused and the item stays focused after hovering away */
36
+ &[data-focused] {
37
+ background-color: ${theme.shared.hover.backgroundColor};
38
+ }
39
+
40
+ /* Override default browser focus behaviour */
41
+ :focus-visible {
42
+ outline: none;
43
+ }
44
+
45
+ &[data-focus-visible] {
46
+ outline: ${theme.option.focused.outline};
47
+ outline-offset: ${theme.option.focused["outline-offset"]};
48
+ background-color: ${theme.option.focused.backgroundColor};
49
+ }
50
+
51
+ /* Must be last to take precedence */
52
+ &[data-pressed] {
53
+ background-color: ${theme.shared.pressed.backgroundColor};
54
+ }
55
+ `;
56
+ };
57
+ const listBoxStyles = (theme) => {
58
+ return react.css`
59
+ ${typography.convertTypographyToEmotionStringStyle(theme.listBox.typography)}
60
+ background-color: ${theme.listBox.backgroundColor};
61
+ border: ${theme.listBox.border};
62
+ box-shadow: ${theme.listBox.shadow};
63
+ max-width: ${theme.shared.maxWidth};
64
+ width: ${theme.shared.width};
65
+ outline: none;
66
+ `;
67
+ };
68
+ const labelStyles = (theme) => {
69
+ return react.css`
70
+ color: ${theme.label.color};
71
+ ${typography.convertTypographyToEmotionStringStyle(theme.label.typography)};
72
+ `;
73
+ };
74
+ const helpTextStyles = (theme) => {
75
+ return react.css`
76
+ color: ${theme.helpText.color};
77
+ ${typography.convertTypographyToEmotionStringStyle(theme.helpText.typography)}
78
+ `;
79
+ };
80
+ const buttonStyles = (theme, isInvalid) => {
81
+ return react.css`
82
+ display: ${theme.button.display};
83
+ justify-content: ${theme.button.justifyContent};
84
+ align-items: ${theme.button.alignItems};
85
+ background-color: ${theme.button.backgroundColor};
86
+ border: ${theme.button.border};
87
+ border-radius: ${theme.button.borderRadius};
88
+ height: ${theme.button.height};
89
+ padding-left: ${theme.button.paddingLeft};
90
+ padding-right: ${theme.button.paddingRight};
91
+ margin-top: ${theme.button.marginTop};
92
+ ${typography.convertTypographyToEmotionStringStyle(theme.button.typography)}
93
+ color: ${theme.button.color};
94
+
95
+ &[data-hovered] {
96
+ background-color: ${theme.shared.hover.backgroundColor};
97
+ }
98
+
99
+ &[data-pressed] {
100
+ background-color: ${theme.shared.pressed.backgroundColor};
101
+ }
102
+
103
+ &[data-focus-visible] {
104
+ outline: ${theme.button.focused.outline};
105
+ outline-offset: ${theme.button.focused["outline-offset"]};
106
+ }
107
+
108
+ &[data-disabled] {
109
+ cursor: ${theme.button.disabled.cursor};
110
+ background-color: ${theme.button.disabled.backgroundColor};
111
+ color: ${theme.button.disabled.color};
112
+ border: ${theme.button.disabled.border};
113
+ }
114
+
115
+ ${isInvalid ? `border: ${theme.button.error.border};` : ``}
116
+ `;
117
+ };
118
+
119
+ exports.buttonStyles = buttonStyles;
120
+ exports.defaultSelectTheme = defaultSelectTheme;
121
+ exports.helpTextStyles = helpTextStyles;
122
+ exports.labelStyles = labelStyles;
123
+ exports.listBoxItemStyles = listBoxItemStyles;
124
+ exports.listBoxStyles = listBoxStyles;
125
+ exports.popoverStyles = popoverStyles;
126
+ exports.selectStyles = selectStyles;