@pega/cosmos-react-core 10.0.0-build.4.3 → 10.0.0-build.4.5

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.
@@ -49,7 +49,15 @@ export type FieldGroupProps = BaseProps & {
49
49
  collapsed?: never;
50
50
  onToggleCollapsed?: never;
51
51
  });
52
- export declare const StyledFieldGroupName: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
52
+ export declare const StyledDescription: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("../HTML").HTMLProps, "ref"> & import("react").RefAttributes<HTMLDivElement> & import("../..").ForwardProps, "ref"> & {
53
+ ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
54
+ }, never>> & string & Omit<ForwardRefForwardPropsComponent<import("../HTML").HTMLProps> & {
55
+ getTestIds: (testIdProp?: import("../..").TestIdProp["testId"]) => import("../..").TestIdsRecord<readonly []>;
56
+ }, keyof import("react").Component<any, {}, any>>;
57
+ export declare const StyledFieldGroupChildren: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
58
+ export declare const StyledFieldGroupName: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("../Text").TextProps, "ref"> & import("react").RefAttributes<HTMLHeadingElement | HTMLSpanElement> & import("../..").ForwardProps, "ref"> & {
59
+ ref?: ((instance: HTMLHeadingElement | HTMLSpanElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLHeadingElement | HTMLSpanElement> | null | undefined;
60
+ }, never>> & string & Omit<ForwardRefForwardPropsComponent<import("../Text").TextProps>, keyof import("react").Component<any, {}, any>>;
53
61
  export declare const StyledFieldHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<(Omit<Omit<Pick<import("../Flex/Flex").BaseFlexProps & BaseProps & import("../..").AsProp & {
54
62
  children?: ReactNode;
55
63
  ref?: Ref<Element>;
@@ -417,15 +425,12 @@ export declare const StyledFieldGroupContent: import("styled-components/dist/typ
417
425
  ref?: import("react").RefObject<Element> | ((instance: Element | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null | undefined;
418
426
  }), import("styled-components/dist/types").BaseObject>> & string & Omit<ForwardRefForwardPropsComponent<import("../Grid").GridProps>, keyof import("react").Component<any, {}, any>>;
419
427
  export declare const StyledFieldGroupLegend: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>, Pick<FieldGroupProps, "collapsed">>> & string;
420
- export declare const StyledFieldGroup: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>, never>> & string;
428
+ export declare const StyledFieldGroup: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>, {
429
+ $hasDescription?: boolean;
430
+ }>> & string;
421
431
  export declare const StyledGroupContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
422
432
  border?: boolean;
423
433
  }>> & string;
424
- export declare const StyledDescription: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("../HTML").HTMLProps, "ref"> & import("react").RefAttributes<HTMLDivElement> & import("../..").ForwardProps, "ref"> & {
425
- ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
426
- }, never>> & string & Omit<ForwardRefForwardPropsComponent<import("../HTML").HTMLProps> & {
427
- getTestIds: (testIdProp?: import("../..").TestIdProp["testId"]) => import("../..").TestIdsRecord<readonly []>;
428
- }, keyof import("react").Component<any, {}, any>>;
429
434
  declare const FieldGroup: ForwardRefForwardPropsComponent<FieldGroupProps>;
430
435
  export default FieldGroup;
431
436
  //# sourceMappingURL=FieldGroup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FieldGroup.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAW7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAI7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,+BAA+B,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK1F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAM7D,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oLAE7B,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oLAAiB,CAAC;AAEtD,eAAO,MAAM,sBAAsB,6QAwBlC,CAAC;AAIF,eAAO,MAAM,gBAAgB;sBAAuC,OAAO;YAa1E,CAAC;AAIF,eAAO,MAAM,oBAAoB;aAAyB,OAAO;YAS/D,CAAC;AAiCH,QAAA,MAAM,UAAU,EAAE,+BAA+B,CAAC,eAAe,CAmG/D,CAAC;AAEH,eAAe,UAAU,CAAC"}
@@ -18,6 +18,18 @@ import { calculateFontSize, omitProps } from '../../styles';
18
18
  import AdditionalInfo from '../AdditionalInfo';
19
19
  registerIcon(caretRightIcon);
20
20
  registerIcon(warnSolidIcon);
21
+ export const StyledDescription = styled(HTML)(({ theme }) => {
22
+ const fontSizes = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);
23
+ return css `
24
+ /* Prevent instruction text from contributing to modal width calculation */
25
+ width: 0;
26
+ min-width: 100%;
27
+ color: rgb(from currentColor r g b / ${theme.base.transparency['transparent-2']});
28
+ font-size: ${fontSizes.xs};
29
+ `;
30
+ });
31
+ StyledDescription.defaultProps = defaultThemeProp;
32
+ export const StyledFieldGroupChildren = styled.div ``;
21
33
  // Styles
22
34
  const StyledExpandButton = styled(Button)(({ theme: { base: { animation } } }) => {
23
35
  const { rtl } = useDirection();
@@ -38,19 +50,14 @@ const StyledErrorIcon = styled(Icon)(({ theme: { base: { palette } } }) => css `
38
50
  color: ${palette.urgent};
39
51
  `);
40
52
  StyledErrorIcon.defaultProps = defaultThemeProp;
41
- export const StyledFieldGroupName = styled.span ``;
53
+ export const StyledFieldGroupName = styled(Text) ``;
42
54
  export const StyledFieldHeader = styled(Flex) `
43
55
  word-break: break-word;
44
56
  `;
45
57
  export const StyledFieldGroupContent = styled(Grid) ``;
46
- export const StyledFieldGroupLegend = styled.legend.withConfig(omitProps('collapsed'))(({ collapsed, theme: { base: { spacing, animation, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger } } } }) => {
58
+ export const StyledFieldGroupLegend = styled.legend.withConfig(omitProps('collapsed'))(({ theme: { base: { animation, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger } } } }) => {
47
59
  return css `
48
60
  width: 100%;
49
- margin-bottom: 0;
50
- ${!collapsed &&
51
- css `
52
- margin-block-end: calc(1.5 * ${spacing});
53
- `}
54
61
  transition: margin-block-end ${animation.speed} ${animation.timing.ease};
55
62
 
56
63
  > ${StyledExpandButton} {
@@ -63,26 +70,27 @@ export const StyledFieldGroupLegend = styled.legend.withConfig(omitProps('collap
63
70
  `;
64
71
  });
65
72
  StyledFieldGroupLegend.defaultProps = defaultThemeProp;
66
- export const StyledFieldGroup = styled.fieldset(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale }, components: { text } } }) => {
67
- const fontSizes = calculateFontSize(fontSize, fontScale);
73
+ export const StyledFieldGroup = styled.fieldset(({ theme, $hasDescription }) => {
68
74
  return css `
69
75
  border: none;
70
76
 
71
- & ${StyledFieldGroupName} {
72
- font-size: ${fontSizes[text.h3['font-size']]};
73
- font-weight: ${text.h3['font-weight']};
74
- }
77
+ ${!$hasDescription &&
78
+ css `
79
+ & > ${StyledFieldGroupLegend}:not(:has([aria-expanded='false'])) {
80
+ margin-block-end: calc(${theme.base.spacing} / 2);
81
+ }
82
+ `}
75
83
  `;
76
84
  });
77
85
  StyledFieldGroup.defaultProps = defaultThemeProp;
78
86
  export const StyledGroupContainer = styled.div(({ theme, border }) => {
79
- const { base: { palette: { 'border-line': borderColor }, spacing, 'border-radius': baseBorderRadius }, components: { 'form-control': { 'border-width': borderWidth } } } = theme;
80
87
  if (!border)
81
88
  return null;
82
89
  return css `
83
- padding: ${spacing};
84
- border-radius: calc(${baseBorderRadius} / 2);
85
- border: ${borderWidth} solid ${borderColor};
90
+ padding: calc(2 * ${theme.base.spacing});
91
+ border-radius: calc(${theme.base['border-radius']} / 2);
92
+ border: ${theme.components['form-control']['border-width']} solid
93
+ ${theme.base.palette['border-line']};
86
94
  `;
87
95
  });
88
96
  StyledGroupContainer.defaultProps = defaultThemeProp;
@@ -90,20 +98,15 @@ StyledGroupContainer.defaultProps = defaultThemeProp;
90
98
  const FieldGroupLegend = ({ name, contextualLabel, children, collapsed, actions, additionalInfo }) => {
91
99
  return (_jsx(StyledFieldGroupLegend, { collapsed: collapsed, children: _jsxs(Flex, { container: { alignItems: 'center', justify: 'between', gap: 0.5 }, children: [_jsxs(Flex, { container: { alignItems: 'center', gap: 0.5 }, as: StyledFieldHeader, children: [children, additionalInfo && (_jsx(AdditionalInfo, { heading: additionalInfo.heading, contextualLabel: contextualLabel || name, children: additionalInfo.content }))] }), actions && _jsx(Actions, { items: actions, contextualLabel: contextualLabel })] }) }));
92
100
  };
93
- export const StyledDescription = styled(HTML) `
94
- /* Prevent instruction text from contributing to modal width calculation */
95
- width: 0;
96
- min-width: 100%;
97
- `;
98
101
  const FieldGroup = forwardRef(function FieldGroup({ children, description, banner, name, contextualLabel, additionalInfo, actions, collapsed, headingTag, onToggleCollapsed, variant, status, ...restProps }, ref) {
99
102
  const t = useI18n();
100
103
  const uid = useUID();
101
- const descAndChildren = (_jsxs(StyledFieldGroupContent, { container: { cols: 'minmax(0, 1fr)', gap: 2 }, children: [banner && _jsx(Banner, { ...banner }), description && (_jsx(StyledDescription, { id: `${uid}-description`, forwardedAs: 'p', content: description })), _jsx("div", { children: children })] }));
102
- return (_jsx(StyledGroupContainer, { border: variant === 'form-group', children: _jsxs(StyledFieldGroup, { "aria-label": contextualLabel || name, "aria-describedby": description ? `${uid}-description` : undefined, as: name ? 'fieldset' : 'div', ...restProps, ref: ref, children: [name && (_jsx(FieldGroupLegend, { collapsed: collapsed, actions: actions, additionalInfo: additionalInfo, name: name, contextualLabel: contextualLabel, children: typeof collapsed === 'boolean' ? (_jsx(StyledExpandButton, { type: 'button', variant: 'text', onClick: () => {
104
+ const descAndChildren = (_jsxs(StyledFieldGroupContent, { container: { cols: 'minmax(0, 1fr)', gap: 0.5 }, children: [banner && _jsx(Banner, { ...banner }), description && (_jsx(StyledDescription, { id: `${uid}-description`, forwardedAs: 'p', content: description })), _jsx(StyledFieldGroupChildren, { children: children })] }));
105
+ return (_jsx(StyledGroupContainer, { border: variant === 'form-group', children: _jsxs(StyledFieldGroup, { "aria-label": contextualLabel || name, "aria-describedby": description ? `${uid}-description` : undefined, as: name ? 'fieldset' : 'div', ...restProps, ref: ref, "$hasDescription": !!description, children: [name && (_jsx(FieldGroupLegend, { collapsed: collapsed, actions: actions, additionalInfo: additionalInfo, name: name, contextualLabel: contextualLabel, children: typeof collapsed === 'boolean' ? (_jsx(StyledExpandButton, { type: 'button', variant: 'text', onClick: () => {
103
106
  onToggleCollapsed?.();
104
107
  }, "aria-expanded": !collapsed, "aria-label": t(collapsed ? 'expand_noun' : 'collapse_noun', [
105
108
  contextualLabel || name
106
- ]), children: _jsxs(Flex, { container: { direction: 'row', alignItems: 'center', gap: 0.5 }, forwardedAs: 'span', children: [_jsx(Icon, { name: 'caret-right' }), status === 'error' ? _jsx(StyledErrorIcon, { name: 'warn-solid' }) : null, headingTag ? (_jsx(Text, { variant: headingTag, children: name })) : (_jsx(StyledFieldGroupName, { children: name }))] }) })) : (_jsxs(_Fragment, { children: [status === 'error' ? _jsx(StyledErrorIcon, { name: 'warn-solid' }) : null, headingTag ? (_jsx(Text, { variant: headingTag, children: name })) : (_jsx(StyledFieldGroupName, { children: name }))] })) })), typeof collapsed === 'boolean' ? (_jsx(ExpandCollapse, { collapsed: collapsed, children: descAndChildren })) : (descAndChildren)] }) }));
109
+ ]), children: _jsxs(Flex, { container: { direction: 'row', alignItems: 'center', gap: 0.5 }, forwardedAs: 'span', children: [_jsx(Icon, { name: 'caret-right' }), status === 'error' ? _jsx(StyledErrorIcon, { name: 'warn-solid' }) : null, headingTag ? (_jsx(Text, { variant: headingTag, children: name })) : (_jsx(StyledFieldGroupName, { variant: 'h3', forwardedAs: 'span', children: name }))] }) })) : (_jsxs(_Fragment, { children: [status === 'error' ? _jsx(StyledErrorIcon, { name: 'warn-solid' }) : null, headingTag ? (_jsx(Text, { variant: headingTag, children: name })) : (_jsx(StyledFieldGroupName, { variant: 'h3', forwardedAs: 'span', children: name }))] })) })), typeof collapsed === 'boolean' ? (_jsx(ExpandCollapse, { collapsed: collapsed, children: descAndChildren })) : (descAndChildren)] }) }));
107
110
  });
108
111
  export default FieldGroup;
109
112
  //# sourceMappingURL=FieldGroup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FieldGroup.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,KAAK,cAAc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;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Text from '../Text';\nimport Button from '../Button';\nimport ExpandCollapse from '../ExpandCollapse';\nimport Flex from '../Flex';\nimport Grid from '../Grid';\nimport HTML from '../HTML';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport Banner from '../Banner';\nimport type { BannerProps } from '../Banner';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport Actions from '../Actions';\nimport type { ActionsProps } from '../Actions';\nimport { defaultThemeProp } from '../../theme';\nimport type { BaseProps, ForwardRefForwardPropsComponent, HeadingTag } from '../../types';\nimport { useDirection, useI18n, useUID } from '../../hooks';\nimport { calculateFontSize, omitProps } from '../../styles';\nimport type { FontSize } from '../../styles';\nimport AdditionalInfo from '../AdditionalInfo';\nimport type { AdditionalInfoProps } from '../AdditionalInfo';\n\nregisterIcon(caretRightIcon);\nregisterIcon(warnSolidIcon);\n\n// Types\nexport type FieldGroupProps = BaseProps & {\n /** The content of the Field Group. */\n children: ReactNode;\n /** A description of the field group to be displayed above the controls. */\n description?: string;\n /** A banner to be displayed above the controls. */\n banner?: BannerProps;\n /** The display and markup variant to apply to the group. */\n variant?: 'form-group';\n /** Indicates validation status for error display in the header. */\n status?: 'error';\n /** A reference to the wrapping element. */\n ref?: Ref<HTMLFieldSetElement>;\n} & (\n | {\n /** The name associated with the Field Group. */\n name: string;\n /** Provides a contextual label for the name. */\n contextualLabel?: string;\n /** Select the heading tag for header */\n headingTag?: HeadingTag;\n /** Provides additional info relevant to the field group. */\n additionalInfo?: {\n heading?: AdditionalInfoProps['heading'];\n content: AdditionalInfoProps['children'];\n };\n /** An array of actions to add to the header. */\n actions?: ActionsProps['items'];\n /**\n * Controls the collapsed state of the field group.\n * Passing undefined will render the field group as non-collapsible.\n * @default false\n */\n collapsed?: boolean;\n /**\n * Called when user clicks the toggle button.\n */\n onToggleCollapsed?: () => void;\n }\n | {\n name?: undefined;\n contextualLabel?: never;\n headingTag?: never;\n additionalInfo?: never;\n actions?: never;\n collapsed?: never;\n onToggleCollapsed?: never;\n }\n );\n\ninterface FieldGroupLegendProps extends Pick<FieldGroupProps, 'collapsed'> {\n name: NonNullable<FieldGroupProps['name']>;\n actions?: ActionsProps['items'];\n children?: ReactNode;\n additionalInfo?: FieldGroupProps['additionalInfo'];\n contextualLabel?: FieldGroupProps['contextualLabel'];\n}\n\n// Styles\nconst StyledExpandButton = styled(Button)(({\n theme: {\n base: { animation }\n }\n}) => {\n const { rtl } = useDirection();\n return css`\n ${StyledIcon} {\n transition: transform ${animation.speed} ${animation.timing.ease};\n }\n &[aria-expanded='true'] ${StyledIcon}:first-child {\n transform: rotate(90deg);\n }\n &[aria-expanded='false'] ${StyledIcon}:first-child {\n transform: rotate(${rtl ? 180 : 0}deg);\n }\n `;\n});\n\nStyledExpandButton.defaultProps = defaultThemeProp;\n\nconst StyledErrorIcon = styled(Icon)(\n ({\n theme: {\n base: { palette }\n }\n }) => css`\n color: ${palette.urgent};\n `\n);\n\nStyledErrorIcon.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroupName = styled.span``;\n\nexport const StyledFieldHeader = styled(Flex)`\n word-break: break-word;\n`;\n\nexport const StyledFieldGroupContent = styled(Grid)``;\n\nexport const StyledFieldGroupLegend = styled.legend.withConfig(omitProps('collapsed'))<\n Pick<FieldGroupProps, 'collapsed'>\n>(\n ({\n collapsed,\n theme: {\n base: {\n spacing,\n animation,\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n }\n }\n }) => {\n return css`\n width: 100%;\n margin-bottom: 0;\n ${!collapsed &&\n css`\n margin-block-end: calc(1.5 * ${spacing});\n `}\n transition: margin-block-end ${animation.speed} ${animation.timing.ease};\n\n > ${StyledExpandButton} {\n min-height: ${hitAreaMouse};\n\n @media (pointer: 'coarse') {\n min-height: ${hitAreaFinger};\n }\n }\n `;\n }\n);\n\nStyledFieldGroupLegend.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroup = styled.fieldset(\n ({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale },\n components: { text }\n }\n }) => {\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n border: none;\n\n & ${StyledFieldGroupName} {\n font-size: ${fontSizes[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n }\n `;\n }\n);\n\nStyledFieldGroup.defaultProps = defaultThemeProp;\n\nexport const StyledGroupContainer = styled.div<{ border?: boolean }>(({ theme, border }) => {\n const {\n base: {\n palette: { 'border-line': borderColor },\n spacing,\n 'border-radius': baseBorderRadius\n },\n components: {\n 'form-control': { 'border-width': borderWidth }\n }\n } = theme;\n if (!border) return null;\n\n return css`\n padding: ${spacing};\n border-radius: calc(${baseBorderRadius} / 2);\n border: ${borderWidth} solid ${borderColor};\n `;\n});\n\nStyledGroupContainer.defaultProps = defaultThemeProp;\n\n// Components\nconst FieldGroupLegend = ({\n name,\n contextualLabel,\n children,\n collapsed,\n actions,\n additionalInfo\n}: FieldGroupLegendProps) => {\n return (\n <StyledFieldGroupLegend collapsed={collapsed}>\n <Flex container={{ alignItems: 'center', justify: 'between', gap: 0.5 }}>\n <Flex container={{ alignItems: 'center', gap: 0.5 }} as={StyledFieldHeader}>\n {children}\n {additionalInfo && (\n <AdditionalInfo\n heading={additionalInfo.heading}\n contextualLabel={contextualLabel || name}\n >\n {additionalInfo.content}\n </AdditionalInfo>\n )}\n </Flex>\n {actions && <Actions items={actions} contextualLabel={contextualLabel} />}\n </Flex>\n </StyledFieldGroupLegend>\n );\n};\n\nexport const StyledDescription = styled(HTML)`\n /* Prevent instruction text from contributing to modal width calculation */\n width: 0;\n min-width: 100%;\n`;\n\nconst FieldGroup: ForwardRefForwardPropsComponent<FieldGroupProps> = forwardRef(function FieldGroup(\n {\n children,\n description,\n banner,\n name,\n contextualLabel,\n additionalInfo,\n actions,\n collapsed,\n headingTag,\n onToggleCollapsed,\n variant,\n status,\n ...restProps\n }: PropsWithoutRef<FieldGroupProps>,\n ref: FieldGroupProps['ref']\n) {\n const t = useI18n();\n const uid = useUID();\n\n const descAndChildren = (\n <StyledFieldGroupContent container={{ cols: 'minmax(0, 1fr)', gap: 2 }}>\n {banner && <Banner {...banner} />}\n {description && (\n <StyledDescription id={`${uid}-description`} forwardedAs='p' content={description} />\n )}\n <div>{children}</div>\n </StyledFieldGroupContent>\n );\n\n return (\n <StyledGroupContainer border={variant === 'form-group'}>\n <StyledFieldGroup\n aria-label={contextualLabel || name}\n aria-describedby={description ? `${uid}-description` : undefined}\n as={name ? 'fieldset' : 'div'}\n {...restProps}\n ref={ref}\n >\n {name && (\n <FieldGroupLegend\n collapsed={collapsed}\n actions={actions}\n additionalInfo={additionalInfo}\n name={name}\n contextualLabel={contextualLabel}\n >\n {typeof collapsed === 'boolean' ? (\n <StyledExpandButton\n type='button'\n variant='text'\n onClick={() => {\n onToggleCollapsed?.();\n }}\n aria-expanded={!collapsed}\n aria-label={t(collapsed ? 'expand_noun' : 'collapse_noun', [\n contextualLabel || name\n ])}\n >\n <Flex\n container={{ direction: 'row', alignItems: 'center', gap: 0.5 }}\n forwardedAs='span'\n >\n <Icon name='caret-right' />\n {status === 'error' ? <StyledErrorIcon name='warn-solid' /> : null}\n {headingTag ? (\n <Text variant={headingTag}>{name}</Text>\n ) : (\n <StyledFieldGroupName>{name}</StyledFieldGroupName>\n )}\n </Flex>\n </StyledExpandButton>\n ) : (\n <>\n {status === 'error' ? <StyledErrorIcon name='warn-solid' /> : null}\n {headingTag ? (\n <Text variant={headingTag}>{name}</Text>\n ) : (\n <StyledFieldGroupName>{name}</StyledFieldGroupName>\n )}\n </>\n )}\n </FieldGroupLegend>\n )}\n\n {typeof collapsed === 'boolean' ? (\n <ExpandCollapse collapsed={collapsed}>{descAndChildren}</ExpandCollapse>\n ) : (\n descAndChildren\n )}\n </StyledFieldGroup>\n </StyledGroupContainer>\n );\n});\n\nexport default FieldGroup;\n"]}
1
+ {"version":3,"file":"FieldGroup.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAG/C,YAAY,CAAC,cAAc,CAAC,CAAC;AAC7B,YAAY,CAAC,aAAa,CAAC,CAAC;AA6D5B,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC1D,MAAM,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW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MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,KAAC,eAAe,IAAC,IAAI,EAAC,YAAY,GAAG,CAAC,CAAC,CAAC,IAAI,EACjE,UAAU,CAAC,CAAC,CAAC,CACZ,KAAC,IAAI,IAAC,OAAO,EAAE,UAAU,YAAG,IAAI,GAAQ,CACzC,CAAC,CAAC,CAAC,CACF,KAAC,oBAAoB,IAAC,OAAO,EAAC,IAAI,EAAC,WAAW,EAAC,MAAM,YAClD,IAAI,GACgB,CACxB,IACI,GACY,CACtB,CAAC,CAAC,CAAC,CACF,8BACG,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,KAAC,eAAe,IAAC,IAAI,EAAC,YAAY,GAAG,CAAC,CAAC,CAAC,IAAI,EACjE,UAAU,CAAC,CAAC,CAAC,CACZ,KAAC,IAAI,IAAC,OAAO,EAAE,UAAU,YAAG,IAAI,GAAQ,CACzC,CAAC,CAAC,CAAC,CACF,KAAC,oBAAoB,IAAC,OAAO,EAAC,IAAI,EAAC,WAAW,EAAC,MAAM,YAClD,IAAI,GACgB,CACxB,IACA,CACJ,GACgB,CACpB,EAEA,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,CAChC,KAAC,cAAc,IAAC,SAAS,EAAE,SAAS,YAAG,eAAe,GAAkB,CACzE,CAAC,CAAC,CAAC,CACF,eAAe,CAChB,IACgB,GACE,CACxB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Text from '../Text';\nimport Button from '../Button';\nimport ExpandCollapse from '../ExpandCollapse';\nimport Flex from '../Flex';\nimport Grid from '../Grid';\nimport HTML from '../HTML';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport Banner from '../Banner';\nimport type { BannerProps } from '../Banner';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport Actions from '../Actions';\nimport type { ActionsProps } from '../Actions';\nimport { defaultThemeProp } from '../../theme';\nimport type { BaseProps, ForwardRefForwardPropsComponent, HeadingTag } from '../../types';\nimport { useDirection, useI18n, useUID } from '../../hooks';\nimport { calculateFontSize, omitProps } from '../../styles';\nimport AdditionalInfo from '../AdditionalInfo';\nimport type { AdditionalInfoProps } from '../AdditionalInfo';\n\nregisterIcon(caretRightIcon);\nregisterIcon(warnSolidIcon);\n\n// Types\nexport type FieldGroupProps = BaseProps & {\n /** The content of the Field Group. */\n children: ReactNode;\n /** A description of the field group to be displayed above the controls. */\n description?: string;\n /** A banner to be displayed above the controls. */\n banner?: BannerProps;\n /** The display and markup variant to apply to the group. */\n variant?: 'form-group';\n /** Indicates validation status for error display in the header. */\n status?: 'error';\n /** A reference to the wrapping element. */\n ref?: Ref<HTMLFieldSetElement>;\n} & (\n | {\n /** The name associated with the Field Group. */\n name: string;\n /** Provides a contextual label for the name. */\n contextualLabel?: string;\n /** Select the heading tag for header */\n headingTag?: HeadingTag;\n /** Provides additional info relevant to the field group. */\n additionalInfo?: {\n heading?: AdditionalInfoProps['heading'];\n content: AdditionalInfoProps['children'];\n };\n /** An array of actions to add to the header. */\n actions?: ActionsProps['items'];\n /**\n * Controls the collapsed state of the field group.\n * Passing undefined will render the field group as non-collapsible.\n * @default false\n */\n collapsed?: boolean;\n /**\n * Called when user clicks the toggle button.\n */\n onToggleCollapsed?: () => void;\n }\n | {\n name?: undefined;\n contextualLabel?: never;\n headingTag?: never;\n additionalInfo?: never;\n actions?: never;\n collapsed?: never;\n onToggleCollapsed?: never;\n }\n );\n\ninterface FieldGroupLegendProps extends Pick<FieldGroupProps, 'collapsed'> {\n name: NonNullable<FieldGroupProps['name']>;\n actions?: ActionsProps['items'];\n children?: ReactNode;\n additionalInfo?: FieldGroupProps['additionalInfo'];\n contextualLabel?: FieldGroupProps['contextualLabel'];\n}\n\nexport const StyledDescription = styled(HTML)(({ theme }) => {\n const fontSizes = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n /* Prevent instruction text from contributing to modal width calculation */\n width: 0;\n min-width: 100%;\n color: rgb(from currentColor r g b / ${theme.base.transparency['transparent-2']});\n font-size: ${fontSizes.xs};\n `;\n});\n\nStyledDescription.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroupChildren = styled.div``;\n\n// Styles\nconst StyledExpandButton = styled(Button)(({\n theme: {\n base: { animation }\n }\n}) => {\n const { rtl } = useDirection();\n return css`\n ${StyledIcon} {\n transition: transform ${animation.speed} ${animation.timing.ease};\n }\n &[aria-expanded='true'] ${StyledIcon}:first-child {\n transform: rotate(90deg);\n }\n &[aria-expanded='false'] ${StyledIcon}:first-child {\n transform: rotate(${rtl ? 180 : 0}deg);\n }\n `;\n});\n\nStyledExpandButton.defaultProps = defaultThemeProp;\n\nconst StyledErrorIcon = styled(Icon)(\n ({\n theme: {\n base: { palette }\n }\n }) => css`\n color: ${palette.urgent};\n `\n);\n\nStyledErrorIcon.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroupName = styled(Text)``;\n\nexport const StyledFieldHeader = styled(Flex)`\n word-break: break-word;\n`;\n\nexport const StyledFieldGroupContent = styled(Grid)``;\n\nexport const StyledFieldGroupLegend = styled.legend.withConfig(omitProps('collapsed'))<\n Pick<FieldGroupProps, 'collapsed'>\n>(\n ({\n theme: {\n base: {\n animation,\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n }\n }\n }) => {\n return css`\n width: 100%;\n transition: margin-block-end ${animation.speed} ${animation.timing.ease};\n\n > ${StyledExpandButton} {\n min-height: ${hitAreaMouse};\n\n @media (pointer: 'coarse') {\n min-height: ${hitAreaFinger};\n }\n }\n `;\n }\n);\n\nStyledFieldGroupLegend.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroup = styled.fieldset<{ $hasDescription?: boolean }>(\n ({ theme, $hasDescription }) => {\n return css`\n border: none;\n\n ${!$hasDescription &&\n css`\n & > ${StyledFieldGroupLegend}:not(:has([aria-expanded='false'])) {\n margin-block-end: calc(${theme.base.spacing} / 2);\n }\n `}\n `;\n }\n);\n\nStyledFieldGroup.defaultProps = defaultThemeProp;\n\nexport const StyledGroupContainer = styled.div<{ border?: boolean }>(({ theme, border }) => {\n if (!border) return null;\n\n return css`\n padding: calc(2 * ${theme.base.spacing});\n border-radius: calc(${theme.base['border-radius']} / 2);\n border: ${theme.components['form-control']['border-width']} solid\n ${theme.base.palette['border-line']};\n `;\n});\n\nStyledGroupContainer.defaultProps = defaultThemeProp;\n\n// Components\nconst FieldGroupLegend = ({\n name,\n contextualLabel,\n children,\n collapsed,\n actions,\n additionalInfo\n}: FieldGroupLegendProps) => {\n return (\n <StyledFieldGroupLegend collapsed={collapsed}>\n <Flex container={{ alignItems: 'center', justify: 'between', gap: 0.5 }}>\n <Flex container={{ alignItems: 'center', gap: 0.5 }} as={StyledFieldHeader}>\n {children}\n {additionalInfo && (\n <AdditionalInfo\n heading={additionalInfo.heading}\n contextualLabel={contextualLabel || name}\n >\n {additionalInfo.content}\n </AdditionalInfo>\n )}\n </Flex>\n {actions && <Actions items={actions} contextualLabel={contextualLabel} />}\n </Flex>\n </StyledFieldGroupLegend>\n );\n};\n\nconst FieldGroup: ForwardRefForwardPropsComponent<FieldGroupProps> = forwardRef(function FieldGroup(\n {\n children,\n description,\n banner,\n name,\n contextualLabel,\n additionalInfo,\n actions,\n collapsed,\n headingTag,\n onToggleCollapsed,\n variant,\n status,\n ...restProps\n }: PropsWithoutRef<FieldGroupProps>,\n ref: FieldGroupProps['ref']\n) {\n const t = useI18n();\n const uid = useUID();\n\n const descAndChildren = (\n <StyledFieldGroupContent container={{ cols: 'minmax(0, 1fr)', gap: 0.5 }}>\n {banner && <Banner {...banner} />}\n {description && (\n <StyledDescription id={`${uid}-description`} forwardedAs='p' content={description} />\n )}\n <StyledFieldGroupChildren>{children}</StyledFieldGroupChildren>\n </StyledFieldGroupContent>\n );\n\n return (\n <StyledGroupContainer border={variant === 'form-group'}>\n <StyledFieldGroup\n aria-label={contextualLabel || name}\n aria-describedby={description ? `${uid}-description` : undefined}\n as={name ? 'fieldset' : 'div'}\n {...restProps}\n ref={ref}\n $hasDescription={!!description}\n >\n {name && (\n <FieldGroupLegend\n collapsed={collapsed}\n actions={actions}\n additionalInfo={additionalInfo}\n name={name}\n contextualLabel={contextualLabel}\n >\n {typeof collapsed === 'boolean' ? (\n <StyledExpandButton\n type='button'\n variant='text'\n onClick={() => {\n onToggleCollapsed?.();\n }}\n aria-expanded={!collapsed}\n aria-label={t(collapsed ? 'expand_noun' : 'collapse_noun', [\n contextualLabel || name\n ])}\n >\n <Flex\n container={{ direction: 'row', alignItems: 'center', gap: 0.5 }}\n forwardedAs='span'\n >\n <Icon name='caret-right' />\n {status === 'error' ? <StyledErrorIcon name='warn-solid' /> : null}\n {headingTag ? (\n <Text variant={headingTag}>{name}</Text>\n ) : (\n <StyledFieldGroupName variant='h3' forwardedAs='span'>\n {name}\n </StyledFieldGroupName>\n )}\n </Flex>\n </StyledExpandButton>\n ) : (\n <>\n {status === 'error' ? <StyledErrorIcon name='warn-solid' /> : null}\n {headingTag ? (\n <Text variant={headingTag}>{name}</Text>\n ) : (\n <StyledFieldGroupName variant='h3' forwardedAs='span'>\n {name}\n </StyledFieldGroupName>\n )}\n </>\n )}\n </FieldGroupLegend>\n )}\n\n {typeof collapsed === 'boolean' ? (\n <ExpandCollapse collapsed={collapsed}>{descAndChildren}</ExpandCollapse>\n ) : (\n descAndChildren\n )}\n </StyledFieldGroup>\n </StyledGroupContainer>\n );\n});\n\nexport default FieldGroup;\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { FC, ReactNode, ComponentType, ReactElement } from 'react';
2
- import type { Action, ExcludeStrict, ForwardProps, OmitStrict, TestIdProp } from '../../types';
2
+ import type { Action, ExcludeStrict, ForwardProps, HeadingTag, OmitStrict, TestIdProp } from '../../types';
3
3
  import type { FlexProps } from '../Flex';
4
4
  import type { FormControlProps } from '../FormControl';
5
5
  import type { LabelProps } from '../Label';
@@ -42,6 +42,11 @@ export interface FormFieldProps extends OmitStrict<FormControlProps, 'placeholde
42
42
  * @default false
43
43
  */
44
44
  labelAfter?: boolean;
45
+ /**
46
+ * Sets the visual variant/styling of the label.
47
+ * @default 'default'
48
+ */
49
+ labelVariant?: 'default' | HeadingTag;
45
50
  /**
46
51
  * Property used to check whether input type is radio to handle styling for RadioCheck
47
52
  * @default false
@@ -73,6 +78,9 @@ export interface FormFieldProps extends OmitStrict<FormControlProps, 'placeholde
73
78
  export declare const StyledFormFieldInfo: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Pick<FormControlProps, "status"> & {
74
79
  infoAbove?: boolean;
75
80
  }>> & string;
81
+ export declare const StyledHeadingLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("../Text").TextProps, "ref"> & import("react").RefAttributes<HTMLHeadingElement | HTMLSpanElement> & ForwardProps, "ref"> & {
82
+ ref?: ((instance: HTMLHeadingElement | HTMLSpanElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLHeadingElement | HTMLSpanElement> | null | undefined;
83
+ }, never>> & string & Omit<import("../..").ForwardRefForwardPropsComponent<import("../Text").TextProps>, keyof import("react").Component<any, {}, any>>;
76
84
  export declare const StyledLabelRow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
77
85
  inline: boolean;
78
86
  }>> & string;
@@ -1 +1 @@
1
- {"version":3,"file":"FormField.d.ts","sourceRoot":"","sources":["../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O;YAwFvB,CAAC;;;;AAoWH,wBAA2D"}
@@ -63,6 +63,7 @@ export const StyledFormFieldInfo = styled.div(({ status, infoAbove, theme }) =>
63
63
  `;
64
64
  });
65
65
  StyledFormFieldInfo.defaultProps = defaultThemeProp;
66
+ export const StyledHeadingLabel = styled(Text) ``;
66
67
  export const StyledLabelRow = styled.div(({ inline }) => {
67
68
  if (inline) {
68
69
  return css `
@@ -96,14 +97,17 @@ export const StyledFormField = styled.div(props => {
96
97
  flex-shrink: 0;
97
98
  }
98
99
 
99
- > ${StyledLabel}, > ${StyledLabelRow}, > ${StyledFlex}:has(> ${StyledLabel}) {
100
+ > :is(${StyledLabel}, ${StyledHeadingLabel}),
101
+ > ${StyledLabelRow}, > ${StyledFlex}:has(> :is(${StyledLabel}, ${StyledHeadingLabel})) {
100
102
  &:not(:empty) {
101
103
  margin-bottom: calc(0.25 * ${spacing});
102
104
  min-height: ${hitAreaCompact};
103
105
  }
104
106
  }
105
107
 
106
- > ${StyledLabel}, > ${StyledLabelRow} > ${StyledLabel}, > ${StyledFlex} > ${StyledLabel} {
108
+ > :is(${StyledLabel}, ${StyledHeadingLabel}),
109
+ > ${StyledLabelRow} > :is(${StyledLabel}, ${StyledHeadingLabel}),
110
+ > ${StyledFlex} > :is(${StyledLabel}, ${StyledHeadingLabel}) {
107
111
  ${required &&
108
112
  css `
109
113
  &::after {
@@ -121,11 +125,11 @@ export const StyledFormField = styled.div(props => {
121
125
  ${asFieldset &&
122
126
  showAdditionalInfo &&
123
127
  css `
124
- > ${StyledFlex} > ${StyledLabel} {
128
+ > ${StyledFlex} > :is(${StyledLabel}, ${StyledHeadingLabel}) {
125
129
  display: block;
126
130
  }
127
131
 
128
- > ${StyledFlex}:has(> ${StyledLabel}) > ${StyledAdditionalInfo} {
132
+ > ${StyledFlex}:has(> :is(${StyledLabel}, ${StyledHeadingLabel})) > ${StyledAdditionalInfo} {
129
133
  align-self: flex-start;
130
134
  }
131
135
  `}
@@ -137,7 +141,7 @@ export const StyledFormField = styled.div(props => {
137
141
  grid-template-rows: auto 1fr;
138
142
  align-items: start;
139
143
 
140
- ${StyledFlex}:has(> ${StyledLabel}), ${StyledFlex}:has(> ${StyledLabelRow}) {
144
+ ${StyledFlex}:has(> :is(${StyledLabel}, ${StyledHeadingLabel})), ${StyledFlex}:has(> ${StyledLabelRow}) {
141
145
  grid-row: span 2;
142
146
  }
143
147
  `}
@@ -163,7 +167,7 @@ const statusIconMap = { error: 'warn-solid', warning: 'diamond-minus', success:
163
167
  const FormField = forwardRef(function FormField(props, ref) {
164
168
  const uid = useUID();
165
169
  const theme = useTheme();
166
- const { testId, children: controlElement, id = uid, as = 'div', label, labelAs: labelAsProp = 'label', labelFor = id, labelId: labelIdProp, labelHidden = false, labelAfter = false, info, status, suppressAnnouncements, isRadioCheck, charLimitDisplay, required = false, disabled = false, readOnly = false, inline = theme.components['form-field'].layout === 'inline', onClear, actions, container, additionalInfo, suggestion, 'aria-describedby': ariaDescribedBy, className, ...restProps } = props;
170
+ const { testId, children: controlElement, id = uid, as = 'div', label, labelAs: labelAsProp = 'label', labelFor = id, labelId: labelIdProp, labelHidden = false, labelAfter = false, labelVariant = 'default', info, status, suppressAnnouncements, isRadioCheck, charLimitDisplay, required = false, disabled = false, readOnly = false, inline = theme.components['form-field'].layout === 'inline', onClear, actions, container, additionalInfo, suggestion, 'aria-describedby': ariaDescribedBy, className, ...restProps } = props;
167
171
  const infoAbove = theme.components['form-field']['helper-text-position'] === 'above';
168
172
  const testIds = useTestIds(testId, getFormFieldTestIds);
169
173
  const asFieldset = as === 'fieldset' || (typeof as !== 'string' && 'target' in as && as.target === 'fieldset');
@@ -178,10 +182,22 @@ const FormField = forwardRef(function FormField(props, ref) {
178
182
  const showAdditionalInfo = !!additionalInfo && !disabled && !labelHidden;
179
183
  const labelInline = inline && !isRadioCheck && !labelHidden;
180
184
  const labelId = asFieldset && !labelIdProp ? `${id}-label` : labelIdProp;
181
- const labelContent = (_jsxs(_Fragment, { children: [_jsx(Label, { "data-testid": testIds.label, id: labelId, as: labelAs, htmlFor: labelAs === 'label' ? labelFor : undefined, labelHidden: labelHidden, onClick: (e) => {
182
- if (readOnly)
183
- e.preventDefault();
184
- }, inline: labelInline, ref: labelRef, children: label }), showAdditionalInfo && labelText && (_jsx(AdditionalInfo, { "data-testid": testIds.additionalInfo, heading: additionalInfo.heading, contextualLabel: labelText, children: additionalInfo.content }))] }));
185
+ const labelContent = (_jsxs(_Fragment, { children: [(() => {
186
+ const baseLabelProps = {
187
+ 'data-testid': testIds.label,
188
+ children: label,
189
+ id: labelId,
190
+ htmlFor: labelAs === 'label' ? labelFor : undefined,
191
+ onClick: (e) => {
192
+ if (readOnly)
193
+ e.preventDefault();
194
+ }
195
+ };
196
+ if (labelVariant === 'default' || labelHidden) {
197
+ return (_jsx(Label, { ...baseLabelProps, as: labelAs, labelHidden: labelHidden, inline: labelInline, ref: labelRef }));
198
+ }
199
+ return (_jsx(StyledHeadingLabel, { ...baseLabelProps, forwardedAs: labelAs, variant: labelVariant, ref: labelRef }));
200
+ })(), showAdditionalInfo && labelText && (_jsx(AdditionalInfo, { "data-testid": testIds.additionalInfo, heading: additionalInfo.heading, contextualLabel: labelText, children: additionalInfo.content }))] }));
185
201
  let labelRow;
186
202
  if (!isRadioCheck && !asFieldset && !labelHidden) {
187
203
  labelRow = (_jsx(Flex, { as: StyledLabelRow, container: { justify: labelInline ? 'start' : 'between', alignItems: 'end' }, item: { alignSelf: labelInline ? 'start' : 'stretch', shrink: labelInline ? 0 : undefined }, inline: labelInline, children: labelContent }));
@@ -1 +1 @@
1
- {"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../src/components/FormField/FormField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE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CAAC,SAAS,sBACvC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,qBAC7D,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACjD,GAAG,EAAE,eAAe,EACpB,SAAS,EAAE,eAAe,CAAC,YAAY,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,aAE9D,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,IAAI,QAAQ,EACvC,CAAC,QAAQ,IAAI,SAAS,IAAI,WAAW,EACrC,OAAO,EACP,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EACrC,CAAC,QAAQ,IAAI,CAAC,SAAS,IAAI,WAAW,EACtC,YAAY,IAAI,OAAO,IAAI,CAC1B,KAAC,iBAAiB,IAChB,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,GAAG,EAAE;oBACZ,OAAO,EAAE,CAAC;gBACZ,CAAC,YAEA,CAAC,CAAC,iBAAiB,CAAC,GACH,CACrB,IACI,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { cloneElement, useEffect, forwardRef, useState, useRef, Children } from 'react';\nimport type { FC, ReactNode, ComponentType, ReactElement, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport AIButton from '../AIButton';\nimport { defaultThemeProp } from '../../theme';\nimport type { Action, ExcludeStrict, ForwardProps, OmitStrict, TestIdProp } from '../../types';\nimport Flex, { StyledFlex } from '../Flex';\nimport type { FlexProps } from '../Flex';\nimport Actions from '../Actions';\nimport type { FormControlProps } from '../FormControl';\nimport { useConsolidatedRef, useI18n, useLiveLog, useTestIds, useTheme, useUID } from '../../hooks';\nimport Label, { StyledLabel } from '../Label';\nimport type { LabelProps } from '../Label';\nimport { calculateFontSize, getReadableStatusColor } from '../../styles';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport { getFocusables, withTestIds, createClassName } from '../../utils';\nimport Button from '../Button';\nimport Text, { StyledText } from '../Text';\nimport Icon, { registerIcon } from '../Icon';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport * as diamondMinusIcon from '../Icon/icons/diamond-minus.icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\nimport * as polarisSolidIcon from '../Icon/icons/polaris-solid.icon';\nimport AdditionalInfo, { StyledAdditionalInfo } from '../AdditionalInfo';\nimport { StyledRadioCheck, StyledRadioCheckInput } from '../RadioCheck/RadioCheck';\n\nimport { getFormFieldTestIds } from './FormField.test-ids';\nimport type { elements } from './FormField.test-ids';\n\nregisterIcon(warnSolidIcon, diamondMinusIcon, checkIcon, polarisSolidIcon);\n\nexport interface FormFieldProps\n extends OmitStrict<FormControlProps, 'placeholder' | 'value' | 'defaultValue'>,\n TestIdProp<typeof elements> {\n /** Pass a single form control component i.e. Input | TextArea | Select | etc.. */\n children: ReactElement | ReactElement[];\n /**\n * An id is required to connect a FormField's wrapping element, control element and info(aria-describedby) live region.\n * A random id will be generated if none is provided.\n * Since MOST FormControls should possess an id(excl. i.e RadioCheckGroup and others) this can be used.\n * The id prop will be used to generate the following:\n * - FormControl <-> Label association via a Label's htmlFor prop.\n * - FormField's wrapping element id {id}-field.\n * - FormField info element id ${id}-info.\n */\n id?: string;\n /**\n * Determines how the wrapping label should be rendered.\n * @default 'label'\n */\n labelAs?: LabelProps['as'];\n /**\n * Overrides the for attribute on the label. If this is not set it will default to the forms id.\n * @default undefined\n */\n labelFor?: LabelProps['htmlFor'];\n /**\n * Sets the id of the label.\n * @default undefined\n */\n labelId?: LabelProps['id'];\n /**\n * Visually hides the label region.\n * @default false\n */\n labelHidden?: boolean;\n /**\n * Visually places the label after the input.\n * @default false\n */\n labelAfter?: boolean;\n /**\n * Property used to check whether input type is radio to handle styling for RadioCheck\n * @default false\n */\n isRadioCheck?: boolean;\n /**\n * Wrapping HTML element tag. Renders as a fieldset for grouped elements i.e. RadioButtons/CheckboxGroup\n * @default 'div'\n */\n as?: 'div' | 'fieldset' | ComponentType<any>;\n /**\n * Layout field elements inline in a row.\n * @default false\n */\n inline?: boolean;\n /** Optionally utilized by Input or Select. */\n actions?: Action[];\n /** Enables Flex container prop pass through. */\n container?: ExcludeStrict<FlexProps['container'], true>;\n /** Character remaining count. Typically used on Textareas only */\n charLimitDisplay?: ReactNode;\n /** Id of additional describing element. */\n 'aria-describedby'?: string;\n /** Callback invoked when the clear button is clicked. If provided will render the clear button. */\n onClear?: () => void;\n /** Suppresses announcements for status changes. */\n suppressAnnouncements?: boolean;\n}\n\nconst StyledStatusIcon = styled(Icon)<{ status: NonNullable<FormFieldProps['status']> }>(({\n theme,\n status\n}) => {\n return css`\n height: 1em;\n width: 1em;\n color: ${getReadableStatusColor(theme, status)};\n vertical-align: baseline;\n `;\n});\n\nStyledStatusIcon.defaultProps = defaultThemeProp;\n\nconst StyledClearButton = styled(Button)(({ theme }) => {\n return css`\n margin-block-start: calc(${theme.base.spacing} / 2);\n align-self: start;\n `;\n});\n\nStyledClearButton.defaultProps = defaultThemeProp;\n\nexport const StyledFormFieldInfo = styled.div<\n Pick<FormControlProps, 'status'> & { infoAbove?: boolean }\n>(({ status, infoAbove, theme }) => {\n const {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing },\n components: { 'form-field': formField }\n } = theme;\n const fontSizes = calculateFontSize(fontSize, fontScale);\n const infoFontSize = fontSizes.xxs;\n\n return css`\n font-size: ${infoFontSize};\n word-break: break-word;\n\n &:not(:empty) {\n ${infoAbove\n ? css`\n margin-block-end: calc(0.25 * ${spacing});\n `\n : css`\n margin-block-start: calc(0.25 * ${spacing});\n `}\n }\n\n ${status &&\n formField[status] &&\n css`\n color: ${getReadableStatusColor(theme, status)};\n `}\n `;\n});\n\nStyledFormFieldInfo.defaultProps = defaultThemeProp;\n\nexport const StyledLabelRow = styled.div<{ inline: boolean }>(({ inline }) => {\n if (inline) {\n return css`\n flex-shrink: 0;\n width: 14ch;\n ${StyledAdditionalInfo} {\n align-self: center;\n }\n `;\n }\n});\n\nexport const StyledFormField = styled.div<\n FormFieldProps & {\n asFieldset: boolean;\n showAdditionalInfo: boolean;\n labelInline?: boolean;\n }\n>(props => {\n const {\n asFieldset,\n showAdditionalInfo,\n disabled,\n required,\n labelInline,\n theme: {\n base: {\n palette: { urgent },\n 'disabled-opacity': disabledOpacity,\n spacing,\n 'hit-area': { 'compact-min': hitAreaCompact }\n }\n }\n } = props;\n\n return css`\n ${disabled &&\n css`\n opacity: ${disabledOpacity};\n -webkit-user-select: none;\n user-select: none;\n `}\n position: relative;\n border: 0;\n\n &:has(${StyledRadioCheckInput}:only-of-type) {\n ${StyledFormFieldInfo} {\n min-width: 100%;\n }\n }\n\n ${StyledFlex}:has(${StyledRadioCheck}) {\n flex-shrink: 0;\n }\n\n > ${StyledLabel}, > ${StyledLabelRow}, > ${StyledFlex}:has(> ${StyledLabel}) {\n &:not(:empty) {\n margin-bottom: calc(0.25 * ${spacing});\n min-height: ${hitAreaCompact};\n }\n }\n\n > ${StyledLabel}, > ${StyledLabelRow} > ${StyledLabel}, > ${StyledFlex} > ${StyledLabel} {\n ${required &&\n css`\n &::after {\n content: ${'\"\\\\00a0*\" / \"\"'};\n color: ${urgent};\n }\n `}\n\n ${disabled &&\n css`\n cursor: not-allowed;\n `}\n }\n\n ${asFieldset &&\n showAdditionalInfo &&\n css`\n > ${StyledFlex} > ${StyledLabel} {\n display: block;\n }\n\n > ${StyledFlex}:has(> ${StyledLabel}) > ${StyledAdditionalInfo} {\n align-self: flex-start;\n }\n `}\n\n ${labelInline &&\n css`\n display: grid;\n grid-template-columns: 14ch 1fr;\n grid-template-rows: auto 1fr;\n align-items: start;\n\n ${StyledFlex}:has(> ${StyledLabel}), ${StyledFlex}:has(> ${StyledLabelRow}) {\n grid-row: span 2;\n }\n `}\n `;\n});\n\nStyledFormField.defaultProps = defaultThemeProp;\n\nconst StyledSuggestionWrapper = styled(Flex)<Pick<FormControlProps, 'status'>>(({\n theme,\n status\n}) => {\n const {\n base: { 'font-size': fontSize, 'font-scale': fontScale },\n components: { 'form-control': formControl }\n } = theme;\n const fontSizes = calculateFontSize(fontSize, fontScale);\n const infoFontSize = fontSizes.xxs;\n\n return css`\n ${StyledText} {\n ${(!status || status === 'pending') &&\n css`\n color: ${formControl['foreground-color']};\n font-size: ${infoFontSize};\n `}\n }\n `;\n});\n\nStyledSuggestionWrapper.defaultProps = defaultThemeProp;\n\nconst statusIconMap = { error: 'warn-solid', warning: 'diamond-minus', success: 'check' };\n\nconst FormField: FC<FormFieldProps & ForwardProps> = forwardRef(function FormField(\n props: PropsWithoutRef<FormFieldProps>,\n ref: Ref<HTMLElement>\n) {\n const uid = useUID();\n const theme = useTheme();\n const {\n testId,\n children: controlElement,\n id = uid,\n as = 'div',\n label,\n labelAs: labelAsProp = 'label',\n labelFor = id,\n labelId: labelIdProp,\n labelHidden = false,\n labelAfter = false,\n info,\n status,\n suppressAnnouncements,\n isRadioCheck,\n charLimitDisplay,\n required = false,\n disabled = false,\n readOnly = false,\n inline = theme.components['form-field'].layout === 'inline',\n onClear,\n actions,\n container,\n additionalInfo,\n suggestion,\n 'aria-describedby': ariaDescribedBy,\n className,\n ...restProps\n } = props;\n\n const infoAbove = theme.components['form-field']['helper-text-position'] === 'above';\n const testIds = useTestIds(testId, getFormFieldTestIds);\n\n const asFieldset =\n as === 'fieldset' || (typeof as !== 'string' && 'target' in as && as.target === 'fieldset');\n const t = useI18n();\n const { announceAssertive } = useLiveLog();\n const labelAs = asFieldset ? 'span' : labelAsProp;\n const hasAutoInputSuggestion = status === 'pending' && !!suggestion && 'onReject' in suggestion;\n const hasSuggestion = hasAutoInputSuggestion || (!!suggestion && 'value' in suggestion);\n const consolidatedRef = useConsolidatedRef(ref);\n const labelRef = useRef<HTMLLabelElement | HTMLLegendElement>(null);\n const [labelText, setLabelText] = useState<string | null>(null);\n\n const showAdditionalInfo = !!additionalInfo && !disabled && !labelHidden;\n const labelInline = inline && !isRadioCheck && !labelHidden;\n const labelId = asFieldset && !labelIdProp ? `${id}-label` : labelIdProp;\n\n const labelContent = (\n <>\n <Label\n data-testid={testIds.label}\n id={labelId}\n as={labelAs}\n htmlFor={labelAs === 'label' ? labelFor : undefined}\n labelHidden={labelHidden}\n onClick={(e: MouseEvent) => {\n if (readOnly) e.preventDefault();\n }}\n inline={labelInline}\n ref={labelRef}\n >\n {label}\n </Label>\n\n {showAdditionalInfo && labelText && (\n <AdditionalInfo\n data-testid={testIds.additionalInfo}\n heading={additionalInfo.heading}\n contextualLabel={labelText}\n >\n {additionalInfo.content}\n </AdditionalInfo>\n )}\n </>\n );\n\n let labelRow: ReactNode;\n if (!isRadioCheck && !asFieldset && !labelHidden) {\n labelRow = (\n <Flex\n as={StyledLabelRow}\n container={{ justify: labelInline ? 'start' : 'between', alignItems: 'end' }}\n item={{ alignSelf: labelInline ? 'start' : 'stretch', shrink: labelInline ? 0 : undefined }}\n inline={labelInline}\n >\n {labelContent}\n </Flex>\n );\n } else if (asFieldset && !labelHidden) {\n labelRow = (\n <Flex\n container={{\n alignItems: 'end',\n justify: showAdditionalInfo && !isRadioCheck ? 'between' : undefined\n }}\n >\n {labelContent}\n </Flex>\n );\n } else {\n labelRow = labelContent;\n }\n\n useEffect(() => {\n setLabelText(labelRef.current?.textContent ?? null);\n }, [label]);\n\n useEffect(() => {\n if (suppressAnnouncements || (status !== 'error' && status !== 'warning')) return;\n\n let message = t(status);\n\n if (typeof info === 'string') message = `${message} ${info}`;\n\n if (labelRef.current?.textContent) message = `${labelRef.current?.textContent} ${message}`;\n\n announceAssertive({ message, type: status });\n }, [status, info]);\n\n // fieldset or single form control element\n let content: FormFieldProps['children'];\n if (asFieldset || Children.count(controlElement) > 1) {\n content = controlElement;\n } else {\n const controlElementAriaDescribedBy = Children.only(controlElement).props[\n 'aria-describedby'\n ] as string | undefined;\n content = cloneElement(controlElement as ReactElement, {\n 'aria-describedby':\n [controlElementAriaDescribedBy, info && !readOnly ? `${id}-info` : undefined]\n .join(' ')\n .trim() || undefined\n });\n }\n\n if (actions) {\n content = (\n <Flex\n container={{ alignItems: 'center', gap: 0.5 }}\n item={{ grow: labelInline ? 1 : undefined }}\n >\n {content}\n <Actions items={actions} menuAt={3} />\n </Flex>\n );\n }\n\n let infoContent = (\n <Flex\n id={`${id}-info`}\n data-testid={testIds.info}\n status={status}\n as={StyledFormFieldInfo}\n container={{ alignItems: 'center', gap: 0.5 }}\n infoAbove={infoAbove}\n >\n {status && status !== 'pending' && (\n <>\n <Flex\n item={{ alignSelf: 'start' }}\n as={StyledStatusIcon}\n status={status}\n name={statusIconMap[status]}\n />\n <VisuallyHiddenText>{`${t(status)} `}</VisuallyHiddenText>\n </>\n )}\n {info}\n </Flex>\n );\n\n if (charLimitDisplay) {\n infoContent = (\n <Flex container={{ justify: infoContent ? 'between' : 'end', gap: 1 }}>\n {infoContent}\n <Flex item={{ shrink: 0 }}>{charLimitDisplay}</Flex>\n </Flex>\n );\n }\n\n if (hasSuggestion) {\n const focusables = getFocusables(consolidatedRef);\n infoContent = (\n <StyledFormFieldInfo\n data-testid={testIds.info}\n status={status}\n id={`${id}-info`}\n infoAbove={infoAbove}\n >\n {'value' in suggestion && (\n <StyledSuggestionWrapper container={{ alignItems: 'center', gap: 0.2 }} status={status}>\n <Icon size='font-size' name='polaris-solid' />{' '}\n <Text>{`${t('suggestion_suggested_value')}:`}</Text>\n <AIButton\n variant='link'\n icon={null}\n data-testid={testIds.suggestionAccept}\n onClick={() => {\n suggestion.onAccept();\n focusables[0]?.focus();\n }}\n label={suggestion.value}\n aria-label={`${t('accept_suggestion_button_a11y')}${labelText ? ` - ${labelText}` : ''}`}\n />\n </StyledSuggestionWrapper>\n )}\n {'onReject' in suggestion &&\n ('previousValue' in suggestion && suggestion.previousValue ? (\n <StyledSuggestionWrapper container={{ alignItems: 'center', gap: 0.2 }} status={status}>\n <Text>{`${t('suggestion_previous_value')}:`}</Text>\n <Button\n variant='link'\n data-testid={testIds.suggestionReject}\n onClick={() => {\n suggestion.onReject();\n focusables[0]?.focus();\n }}\n aria-label={`${t('reject_suggestion_button_a11y')}${labelText ? ` - ${labelText}` : ''}`}\n >\n {suggestion.previousValue}\n </Button>\n </StyledSuggestionWrapper>\n ) : (\n <AIButton\n variant='link'\n icon={null}\n data-testid={testIds.suggestionReject}\n onClick={() => {\n suggestion.onReject();\n focusables[0]?.focus();\n }}\n label={t('suggestion_clear')}\n aria-label={`${t('reject_suggestion_button_a11y')}${labelText ? ` - ${labelText}` : ''}`}\n />\n ))}\n\n <VisuallyHiddenText aria-live='polite'>{t('suggestion_assist')}</VisuallyHiddenText>\n </StyledFormFieldInfo>\n );\n }\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n const target = e.target as HTMLElement;\n if (!target.closest('button')) {\n e.preventDefault();\n suggestion?.onAccept();\n }\n }\n };\n\n const descriptionIds = [];\n if (ariaDescribedBy) descriptionIds.push(ariaDescribedBy);\n if (asFieldset && info) descriptionIds.push(`${id}-info`);\n\n return (\n <Flex\n data-testid={testIds.root}\n {...restProps}\n container={{\n direction: inline && !labelHidden ? 'row' : 'column',\n alignItems: inline && !labelHidden ? 'center' : undefined,\n wrap: isRadioCheck || inline ? 'wrap' : undefined,\n ...container\n }}\n as={StyledFormField}\n asFieldset={asFieldset}\n isRadioCheck={isRadioCheck}\n showAdditionalInfo={showAdditionalInfo}\n id={`${id}-field`}\n forwardedAs={as}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n labelInline={labelInline}\n onKeyDown={hasAutoInputSuggestion ? onKeyDown : undefined}\n aria-describedby={descriptionIds.length ? descriptionIds.join(' ') : undefined}\n aria-labelledby={asFieldset ? labelId : undefined}\n ref={consolidatedRef}\n className={createClassName('form-field', className, { status })}\n >\n {(asFieldset || !labelAfter) && labelRow}\n {!readOnly && infoAbove && infoContent}\n {content}\n {!asFieldset && labelAfter && labelRow}\n {!readOnly && !infoAbove && infoContent}\n {isRadioCheck && onClear && (\n <StyledClearButton\n variant='link'\n onClick={() => {\n onClear();\n }}\n >\n {t('clear_selection')}\n </StyledClearButton>\n )}\n </Flex>\n );\n});\n\nexport default withTestIds(FormField, getFormFieldTestIds);\n"]}
1
+ {"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../src/components/FormField/FormField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUxF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAS/C,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACpG,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,gBAAgB,MAAM,kCAAkC,CAAC;AACrE,OAAO,KAA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Y,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,aAE9D,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,IAAI,QAAQ,EACvC,CAAC,QAAQ,IAAI,SAAS,IAAI,WAAW,EACrC,OAAO,EACP,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EACrC,CAAC,QAAQ,IAAI,CAAC,SAAS,IAAI,WAAW,EACtC,YAAY,IAAI,OAAO,IAAI,CAC1B,KAAC,iBAAiB,IAChB,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,GAAG,EAAE;oBACZ,OAAO,EAAE,CAAC;gBACZ,CAAC,YAEA,CAAC,CAAC,iBAAiB,CAAC,GACH,CACrB,IACI,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { cloneElement, useEffect, forwardRef, useState, useRef, Children } from 'react';\nimport type {\n FC,\n MouseEvent,\n ReactNode,\n ComponentType,\n ReactElement,\n PropsWithoutRef,\n Ref\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport AIButton from '../AIButton';\nimport { defaultThemeProp } from '../../theme';\nimport type {\n Action,\n ExcludeStrict,\n ForwardProps,\n HeadingTag,\n OmitStrict,\n TestIdProp\n} from '../../types';\nimport Flex, { StyledFlex } from '../Flex';\nimport type { FlexProps } from '../Flex';\nimport Actions from '../Actions';\nimport type { FormControlProps } from '../FormControl';\nimport { useConsolidatedRef, useI18n, useLiveLog, useTestIds, useTheme, useUID } from '../../hooks';\nimport Label, { StyledLabel } from '../Label';\nimport type { LabelProps } from '../Label';\nimport { calculateFontSize, getReadableStatusColor } from '../../styles';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport { getFocusables, withTestIds, createClassName } from '../../utils';\nimport Button from '../Button';\nimport Text, { StyledText } from '../Text';\nimport Icon, { registerIcon } from '../Icon';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport * as diamondMinusIcon from '../Icon/icons/diamond-minus.icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\nimport * as polarisSolidIcon from '../Icon/icons/polaris-solid.icon';\nimport AdditionalInfo, { StyledAdditionalInfo } from '../AdditionalInfo';\nimport { StyledRadioCheck, StyledRadioCheckInput } from '../RadioCheck/RadioCheck';\n\nimport { getFormFieldTestIds } from './FormField.test-ids';\nimport type { elements } from './FormField.test-ids';\n\nregisterIcon(warnSolidIcon, diamondMinusIcon, checkIcon, polarisSolidIcon);\n\nexport interface FormFieldProps\n extends OmitStrict<FormControlProps, 'placeholder' | 'value' | 'defaultValue'>,\n TestIdProp<typeof elements> {\n /** Pass a single form control component i.e. Input | TextArea | Select | etc.. */\n children: ReactElement | ReactElement[];\n /**\n * An id is required to connect a FormField's wrapping element, control element and info(aria-describedby) live region.\n * A random id will be generated if none is provided.\n * Since MOST FormControls should possess an id(excl. i.e RadioCheckGroup and others) this can be used.\n * The id prop will be used to generate the following:\n * - FormControl <-> Label association via a Label's htmlFor prop.\n * - FormField's wrapping element id {id}-field.\n * - FormField info element id ${id}-info.\n */\n id?: string;\n /**\n * Determines how the wrapping label should be rendered.\n * @default 'label'\n */\n labelAs?: LabelProps['as'];\n /**\n * Overrides the for attribute on the label. If this is not set it will default to the forms id.\n * @default undefined\n */\n labelFor?: LabelProps['htmlFor'];\n /**\n * Sets the id of the label.\n * @default undefined\n */\n labelId?: LabelProps['id'];\n /**\n * Visually hides the label region.\n * @default false\n */\n labelHidden?: boolean;\n /**\n * Visually places the label after the input.\n * @default false\n */\n labelAfter?: boolean;\n /**\n * Sets the visual variant/styling of the label.\n * @default 'default'\n */\n labelVariant?: 'default' | HeadingTag;\n /**\n * Property used to check whether input type is radio to handle styling for RadioCheck\n * @default false\n */\n isRadioCheck?: boolean;\n /**\n * Wrapping HTML element tag. Renders as a fieldset for grouped elements i.e. RadioButtons/CheckboxGroup\n * @default 'div'\n */\n as?: 'div' | 'fieldset' | ComponentType<any>;\n /**\n * Layout field elements inline in a row.\n * @default false\n */\n inline?: boolean;\n /** Optionally utilized by Input or Select. */\n actions?: Action[];\n /** Enables Flex container prop pass through. */\n container?: ExcludeStrict<FlexProps['container'], true>;\n /** Character remaining count. Typically used on Textareas only */\n charLimitDisplay?: ReactNode;\n /** Id of additional describing element. */\n 'aria-describedby'?: string;\n /** Callback invoked when the clear button is clicked. If provided will render the clear button. */\n onClear?: () => void;\n /** Suppresses announcements for status changes. */\n suppressAnnouncements?: boolean;\n}\n\nconst StyledStatusIcon = styled(Icon)<{ status: NonNullable<FormFieldProps['status']> }>(({\n theme,\n status\n}) => {\n return css`\n height: 1em;\n width: 1em;\n color: ${getReadableStatusColor(theme, status)};\n vertical-align: baseline;\n `;\n});\n\nStyledStatusIcon.defaultProps = defaultThemeProp;\n\nconst StyledClearButton = styled(Button)(({ theme }) => {\n return css`\n margin-block-start: calc(${theme.base.spacing} / 2);\n align-self: start;\n `;\n});\n\nStyledClearButton.defaultProps = defaultThemeProp;\n\nexport const StyledFormFieldInfo = styled.div<\n Pick<FormControlProps, 'status'> & { infoAbove?: boolean }\n>(({ status, infoAbove, theme }) => {\n const {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing },\n components: { 'form-field': formField }\n } = theme;\n const fontSizes = calculateFontSize(fontSize, fontScale);\n const infoFontSize = fontSizes.xxs;\n\n return css`\n font-size: ${infoFontSize};\n word-break: break-word;\n\n &:not(:empty) {\n ${infoAbove\n ? css`\n margin-block-end: calc(0.25 * ${spacing});\n `\n : css`\n margin-block-start: calc(0.25 * ${spacing});\n `}\n }\n\n ${status &&\n formField[status] &&\n css`\n color: ${getReadableStatusColor(theme, status)};\n `}\n `;\n});\n\nStyledFormFieldInfo.defaultProps = defaultThemeProp;\n\nexport const StyledHeadingLabel = styled(Text)``;\n\nexport const StyledLabelRow = styled.div<{ inline: boolean }>(({ inline }) => {\n if (inline) {\n return css`\n flex-shrink: 0;\n width: 14ch;\n ${StyledAdditionalInfo} {\n align-self: center;\n }\n `;\n }\n});\n\nexport const StyledFormField = styled.div<\n FormFieldProps & {\n asFieldset: boolean;\n showAdditionalInfo: boolean;\n labelInline?: boolean;\n }\n>(props => {\n const {\n asFieldset,\n showAdditionalInfo,\n disabled,\n required,\n labelInline,\n theme: {\n base: {\n palette: { urgent },\n 'disabled-opacity': disabledOpacity,\n spacing,\n 'hit-area': { 'compact-min': hitAreaCompact }\n }\n }\n } = props;\n\n return css`\n ${disabled &&\n css`\n opacity: ${disabledOpacity};\n -webkit-user-select: none;\n user-select: none;\n `}\n position: relative;\n border: 0;\n\n &:has(${StyledRadioCheckInput}:only-of-type) {\n ${StyledFormFieldInfo} {\n min-width: 100%;\n }\n }\n\n ${StyledFlex}:has(${StyledRadioCheck}) {\n flex-shrink: 0;\n }\n\n > :is(${StyledLabel}, ${StyledHeadingLabel}),\n > ${StyledLabelRow}, > ${StyledFlex}:has(> :is(${StyledLabel}, ${StyledHeadingLabel})) {\n &:not(:empty) {\n margin-bottom: calc(0.25 * ${spacing});\n min-height: ${hitAreaCompact};\n }\n }\n\n > :is(${StyledLabel}, ${StyledHeadingLabel}),\n > ${StyledLabelRow} > :is(${StyledLabel}, ${StyledHeadingLabel}),\n > ${StyledFlex} > :is(${StyledLabel}, ${StyledHeadingLabel}) {\n ${required &&\n css`\n &::after {\n content: ${'\"\\\\00a0*\" / \"\"'};\n color: ${urgent};\n }\n `}\n\n ${disabled &&\n css`\n cursor: not-allowed;\n `}\n }\n\n ${asFieldset &&\n showAdditionalInfo &&\n css`\n > ${StyledFlex} > :is(${StyledLabel}, ${StyledHeadingLabel}) {\n display: block;\n }\n\n > ${StyledFlex}:has(> :is(${StyledLabel}, ${StyledHeadingLabel})) > ${StyledAdditionalInfo} {\n align-self: flex-start;\n }\n `}\n\n ${labelInline &&\n css`\n display: grid;\n grid-template-columns: 14ch 1fr;\n grid-template-rows: auto 1fr;\n align-items: start;\n\n ${StyledFlex}:has(> :is(${StyledLabel}, ${StyledHeadingLabel})), ${StyledFlex}:has(> ${StyledLabelRow}) {\n grid-row: span 2;\n }\n `}\n `;\n});\n\nStyledFormField.defaultProps = defaultThemeProp;\n\nconst StyledSuggestionWrapper = styled(Flex)<Pick<FormControlProps, 'status'>>(({\n theme,\n status\n}) => {\n const {\n base: { 'font-size': fontSize, 'font-scale': fontScale },\n components: { 'form-control': formControl }\n } = theme;\n const fontSizes = calculateFontSize(fontSize, fontScale);\n const infoFontSize = fontSizes.xxs;\n\n return css`\n ${StyledText} {\n ${(!status || status === 'pending') &&\n css`\n color: ${formControl['foreground-color']};\n font-size: ${infoFontSize};\n `}\n }\n `;\n});\n\nStyledSuggestionWrapper.defaultProps = defaultThemeProp;\n\nconst statusIconMap = { error: 'warn-solid', warning: 'diamond-minus', success: 'check' };\n\nconst FormField: FC<FormFieldProps & ForwardProps> = forwardRef(function FormField(\n props: PropsWithoutRef<FormFieldProps>,\n ref: Ref<HTMLElement>\n) {\n const uid = useUID();\n const theme = useTheme();\n const {\n testId,\n children: controlElement,\n id = uid,\n as = 'div',\n label,\n labelAs: labelAsProp = 'label',\n labelFor = id,\n labelId: labelIdProp,\n labelHidden = false,\n labelAfter = false,\n labelVariant = 'default',\n info,\n status,\n suppressAnnouncements,\n isRadioCheck,\n charLimitDisplay,\n required = false,\n disabled = false,\n readOnly = false,\n inline = theme.components['form-field'].layout === 'inline',\n onClear,\n actions,\n container,\n additionalInfo,\n suggestion,\n 'aria-describedby': ariaDescribedBy,\n className,\n ...restProps\n } = props;\n\n const infoAbove = theme.components['form-field']['helper-text-position'] === 'above';\n const testIds = useTestIds(testId, getFormFieldTestIds);\n\n const asFieldset =\n as === 'fieldset' || (typeof as !== 'string' && 'target' in as && as.target === 'fieldset');\n const t = useI18n();\n const { announceAssertive } = useLiveLog();\n const labelAs = asFieldset ? 'span' : labelAsProp;\n const hasAutoInputSuggestion = status === 'pending' && !!suggestion && 'onReject' in suggestion;\n const hasSuggestion = hasAutoInputSuggestion || (!!suggestion && 'value' in suggestion);\n const consolidatedRef = useConsolidatedRef(ref);\n const labelRef = useRef<HTMLLabelElement | HTMLLegendElement>(null);\n const [labelText, setLabelText] = useState<string | null>(null);\n\n const showAdditionalInfo = !!additionalInfo && !disabled && !labelHidden;\n const labelInline = inline && !isRadioCheck && !labelHidden;\n const labelId = asFieldset && !labelIdProp ? `${id}-label` : labelIdProp;\n\n const labelContent = (\n <>\n {(() => {\n const baseLabelProps = {\n 'data-testid': testIds.label,\n children: label,\n id: labelId,\n htmlFor: labelAs === 'label' ? labelFor : undefined,\n onClick: (e: MouseEvent) => {\n if (readOnly) e.preventDefault();\n }\n };\n\n if (labelVariant === 'default' || labelHidden) {\n return (\n <Label\n {...baseLabelProps}\n as={labelAs}\n labelHidden={labelHidden}\n inline={labelInline}\n ref={labelRef}\n />\n );\n }\n\n return (\n <StyledHeadingLabel\n {...baseLabelProps}\n forwardedAs={labelAs}\n variant={labelVariant}\n ref={labelRef}\n />\n );\n })()}\n\n {showAdditionalInfo && labelText && (\n <AdditionalInfo\n data-testid={testIds.additionalInfo}\n heading={additionalInfo.heading}\n contextualLabel={labelText}\n >\n {additionalInfo.content}\n </AdditionalInfo>\n )}\n </>\n );\n\n let labelRow: ReactNode;\n if (!isRadioCheck && !asFieldset && !labelHidden) {\n labelRow = (\n <Flex\n as={StyledLabelRow}\n container={{ justify: labelInline ? 'start' : 'between', alignItems: 'end' }}\n item={{ alignSelf: labelInline ? 'start' : 'stretch', shrink: labelInline ? 0 : undefined }}\n inline={labelInline}\n >\n {labelContent}\n </Flex>\n );\n } else if (asFieldset && !labelHidden) {\n labelRow = (\n <Flex\n container={{\n alignItems: 'end',\n justify: showAdditionalInfo && !isRadioCheck ? 'between' : undefined\n }}\n >\n {labelContent}\n </Flex>\n );\n } else {\n labelRow = labelContent;\n }\n\n useEffect(() => {\n setLabelText(labelRef.current?.textContent ?? null);\n }, [label]);\n\n useEffect(() => {\n if (suppressAnnouncements || (status !== 'error' && status !== 'warning')) return;\n\n let message = t(status);\n\n if (typeof info === 'string') message = `${message} ${info}`;\n\n if (labelRef.current?.textContent) message = `${labelRef.current?.textContent} ${message}`;\n\n announceAssertive({ message, type: status });\n }, [status, info]);\n\n // fieldset or single form control element\n let content: FormFieldProps['children'];\n if (asFieldset || Children.count(controlElement) > 1) {\n content = controlElement;\n } else {\n const controlElementAriaDescribedBy = Children.only(controlElement).props[\n 'aria-describedby'\n ] as string | undefined;\n content = cloneElement(controlElement as ReactElement, {\n 'aria-describedby':\n [controlElementAriaDescribedBy, info && !readOnly ? `${id}-info` : undefined]\n .join(' ')\n .trim() || undefined\n });\n }\n\n if (actions) {\n content = (\n <Flex\n container={{ alignItems: 'center', gap: 0.5 }}\n item={{ grow: labelInline ? 1 : undefined }}\n >\n {content}\n <Actions items={actions} menuAt={3} />\n </Flex>\n );\n }\n\n let infoContent = (\n <Flex\n id={`${id}-info`}\n data-testid={testIds.info}\n status={status}\n as={StyledFormFieldInfo}\n container={{ alignItems: 'center', gap: 0.5 }}\n infoAbove={infoAbove}\n >\n {status && status !== 'pending' && (\n <>\n <Flex\n item={{ alignSelf: 'start' }}\n as={StyledStatusIcon}\n status={status}\n name={statusIconMap[status]}\n />\n <VisuallyHiddenText>{`${t(status)} `}</VisuallyHiddenText>\n </>\n )}\n {info}\n </Flex>\n );\n\n if (charLimitDisplay) {\n infoContent = (\n <Flex container={{ justify: infoContent ? 'between' : 'end', gap: 1 }}>\n {infoContent}\n <Flex item={{ shrink: 0 }}>{charLimitDisplay}</Flex>\n </Flex>\n );\n }\n\n if (hasSuggestion) {\n const focusables = getFocusables(consolidatedRef);\n infoContent = (\n <StyledFormFieldInfo\n data-testid={testIds.info}\n status={status}\n id={`${id}-info`}\n infoAbove={infoAbove}\n >\n {'value' in suggestion && (\n <StyledSuggestionWrapper container={{ alignItems: 'center', gap: 0.2 }} status={status}>\n <Icon size='font-size' name='polaris-solid' />{' '}\n <Text>{`${t('suggestion_suggested_value')}:`}</Text>\n <AIButton\n variant='link'\n icon={null}\n data-testid={testIds.suggestionAccept}\n onClick={() => {\n suggestion.onAccept();\n focusables[0]?.focus();\n }}\n label={suggestion.value}\n aria-label={`${t('accept_suggestion_button_a11y')}${labelText ? ` - ${labelText}` : ''}`}\n />\n </StyledSuggestionWrapper>\n )}\n {'onReject' in suggestion &&\n ('previousValue' in suggestion && suggestion.previousValue ? (\n <StyledSuggestionWrapper container={{ alignItems: 'center', gap: 0.2 }} status={status}>\n <Text>{`${t('suggestion_previous_value')}:`}</Text>\n <Button\n variant='link'\n data-testid={testIds.suggestionReject}\n onClick={() => {\n suggestion.onReject();\n focusables[0]?.focus();\n }}\n aria-label={`${t('reject_suggestion_button_a11y')}${labelText ? ` - ${labelText}` : ''}`}\n >\n {suggestion.previousValue}\n </Button>\n </StyledSuggestionWrapper>\n ) : (\n <AIButton\n variant='link'\n icon={null}\n data-testid={testIds.suggestionReject}\n onClick={() => {\n suggestion.onReject();\n focusables[0]?.focus();\n }}\n label={t('suggestion_clear')}\n aria-label={`${t('reject_suggestion_button_a11y')}${labelText ? ` - ${labelText}` : ''}`}\n />\n ))}\n\n <VisuallyHiddenText aria-live='polite'>{t('suggestion_assist')}</VisuallyHiddenText>\n </StyledFormFieldInfo>\n );\n }\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n const target = e.target as HTMLElement;\n if (!target.closest('button')) {\n e.preventDefault();\n suggestion?.onAccept();\n }\n }\n };\n\n const descriptionIds = [];\n if (ariaDescribedBy) descriptionIds.push(ariaDescribedBy);\n if (asFieldset && info) descriptionIds.push(`${id}-info`);\n\n return (\n <Flex\n data-testid={testIds.root}\n {...restProps}\n container={{\n direction: inline && !labelHidden ? 'row' : 'column',\n alignItems: inline && !labelHidden ? 'center' : undefined,\n wrap: isRadioCheck || inline ? 'wrap' : undefined,\n ...container\n }}\n as={StyledFormField}\n asFieldset={asFieldset}\n isRadioCheck={isRadioCheck}\n showAdditionalInfo={showAdditionalInfo}\n id={`${id}-field`}\n forwardedAs={as}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n labelInline={labelInline}\n onKeyDown={hasAutoInputSuggestion ? onKeyDown : undefined}\n aria-describedby={descriptionIds.length ? descriptionIds.join(' ') : undefined}\n aria-labelledby={asFieldset ? labelId : undefined}\n ref={consolidatedRef}\n className={createClassName('form-field', className, { status })}\n >\n {(asFieldset || !labelAfter) && labelRow}\n {!readOnly && infoAbove && infoContent}\n {content}\n {!asFieldset && labelAfter && labelRow}\n {!readOnly && !infoAbove && infoContent}\n {isRadioCheck && onClear && (\n <StyledClearButton\n variant='link'\n onClick={() => {\n onClear();\n }}\n >\n {t('clear_selection')}\n </StyledClearButton>\n )}\n </Flex>\n );\n});\n\nexport default withTestIds(FormField, getFormFieldTestIds);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RadioCheckGroup.d.ts","sourceRoot":"","sources":["../../../src/components/RadioCheckGroup/RadioCheckGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,GAAG,EAEH,YAAY,EACZ,WAAW,EAEZ,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAc,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAUrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAMhE,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAC/C,UAAU,EACV,UAAU,CAAC,OAAO,QAAQ,CAAC,GACzB,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,GAAG;IACrC,sDAAsD;IACtD,QAAQ,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;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UAAU,CAAC,CAAC;IACxC;;;OAGG;IACH,MAAM,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IAClC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,+FAA+F;IAC/F,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC;IACnD,8EAA8E;IAC9E,cAAc,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACpD;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,6CAA6C;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACxB,CACJ,CAAC;AAEF,eAAO,MAAM,qBAAqB,+OA8BhC,CAAC;;;;AAwNH,wBAAuE"}
@@ -155,7 +155,7 @@ const RadioCheckGroup = forwardRef(function RadioCheckGroup(props, ref) {
155
155
  });
156
156
  });
157
157
  }, [children, name, disabled, readOnly, variant, onChange]);
158
- return (_jsx(FormField, { testId: testIds, as: StyledRadioCheckGroup, ref: containerRef, name: name, disabled: disabled, required: required, ...restProps, inline: false, suggestion: suggestion, isRadioCheck: true, onClear: onClear,
158
+ return (_jsx(FormField, { testId: testIds, as: StyledRadioCheckGroup, ref: containerRef, name: name, disabled: disabled, required: required, ...restProps, inline: false, suggestion: suggestion, isRadioCheck: true, labelVariant: variant === 'card-grid' ? 'h3' : undefined, onClear: onClear,
159
159
  // Prevents blur when any input within the group is actively focused.
160
160
  onMouseDown: (e) => {
161
161
  restProps.onMouseDown?.(e);
@@ -1 +1 @@
1
- {"version":3,"file":"RadioCheckGroup.js","sourceRoot":"","sources":["../../../src/components/RadioCheckGroup/RadioCheckGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,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,YAAY,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;gBAAE,OAAO;YAEzE,CAAC,CAAC,cAAc,EAAE,CAAC;QACrB,CAAC,YAEA,CAAC,GAAG,EAAE;YACL,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,OAAO,KAAC,UAAU,IAAC,OAAO,EAAC,UAAU,GAAG,CAAC;YAC3C,CAAC;YAED,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,CAC/B,KAAC,cAAc,IACb,GAAG,EAAE,YAAY,EACjB,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,YAEnC,WAAW,GACG,CAClB,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IACH,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE;oBACT,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;oBAC1C,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBAC9B,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAClC,IAAI,EAAE,MAAM;iBACb,YAEA,WAAW,GACP,CACR,CAAC;QACJ,CAAC,CAAC,EAAE,GACM,CACb,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC","sourcesContent":["import { forwardRef, Children, cloneElement, useState, useEffect, useRef, useMemo } from 'react';\nimport type {\n Ref,\n PropsWithoutRef,\n ReactElement,\n ChangeEvent,\n MouseEvent as ReactMouseEvent\n} from 'react';\nimport styled, { css, type DefaultTheme } from 'styled-components';\n\nimport type { RefElement, TestIdProp, WithAttributes } from '../../types';\nimport FormField from '../FormField';\nimport type { FormFieldProps } from '../FormField';\nimport { StyledFormField, StyledFormFieldInfo } from '../FormField/FormField';\nimport type { FormControlProps } from '../FormControl';\nimport type { RadioCheckProps } from '../RadioCheck';\nimport Flex from '../Flex';\nimport { defaultThemeProp } from '../../theme';\nimport { useArrows, useConsolidatedRef, useElement, useTestIds, useUID } from '../../hooks';\nimport {\n StyledImageContainer,\n StyledSelectionCard,\n StyledSelectionCardInline\n} from '../SelectionCard/SelectionCard.styles';\nimport { getActiveElement, withTestIds } from '../../utils';\nimport type { elements } from '../FormField/FormField.test-ids';\nimport { StyledRadioCheck } from '../RadioCheck/RadioCheck';\nimport EmptyState, { StyledEmptyState } from '../EmptyState';\n\nimport { getRadioCheckGroupTestIds } from './RadioCheckGroup.test-ids';\n\nexport type RadioCheckGroupProps = WithAttributes<\n 'fieldset',\n TestIdProp<typeof elements> &\n Pick<FormControlProps, 'suggestion'> & {\n /** Accepts Checkboxes or RadioButtons as children. */\n children?: ReactElement | ReactElement[];\n /**\n * Conveniently pass an onChange handler to the group to be notified when any of the inputs change.\n * Additionally, onChange can be passed to individual children.\n * Both handlers will be called, child followed by group.\n */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /** Callback invoked when the clear button is clicked. If provided will render the clear button. */\n onClear?: FormFieldProps['onClear'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /**\n * Layout field elements inline in a row.\n * @default false\n */\n inline?: FormFieldProps['inline'];\n /** Used to toggle the auto stacking feature of an inlined group.\n * @default true\n */\n autoStack?: boolean;\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /**\n * Controls the styling of the child RadioChecks.\n * @default 'simple'\n */\n variant?: RadioCheckProps['variant'] | 'card-grid';\n /** Pass a heading and content to show additional information on the field. */\n additionalInfo?: FormControlProps['additionalInfo'];\n /**\n * Enables arrow key navigation between options in the group.\n * Disable for checkbox groups where each option is independently selectable.\n * @default true\n */\n arrowNavigation?: boolean;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLElement>;\n }\n>;\n\nexport const StyledRadioCheckGroup = styled.fieldset(({ theme }) => {\n return css`\n container-type: inline-size;\n flex-wrap: nowrap;\n\n &[disabled] {\n > ${StyledFormField} {\n opacity: unset;\n }\n }\n\n ${StyledSelectionCard} {\n max-width: 100%;\n }\n\n ${StyledSelectionCardInline} ${StyledImageContainer} {\n /* To enlarge the image containers to the size of the biggest one */\n min-height: 100%;\n }\n\n ${StyledRadioCheck} > ${StyledFormFieldInfo} {\n display: none;\n }\n\n ${StyledEmptyState} {\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-radius: ${theme.components.card['border-radius']};\n padding: calc(2 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledRadioCheckGroup.defaultProps = defaultThemeProp;\n\nconst getCardGridColumns = (cardWidth: string) => css`\n @container (min-width: calc(2 * ${cardWidth})) {\n grid-template-columns: repeat(2, 1fr);\n }\n\n @container (min-width: calc(3 * ${cardWidth})) {\n grid-template-columns: repeat(3, 1fr);\n }\n\n @container (min-width: calc(4 * ${cardWidth})) {\n grid-template-columns: repeat(4, 1fr);\n }\n`;\n\nconst getCardGridContainerStyles = (theme: DefaultTheme) => {\n const defaultCardWidth = theme.base['content-width'].sm;\n const inlineImageCardWidth = theme.base['content-width'].md;\n return css`\n display: grid;\n gap: ${theme.base.spacing};\n grid-template-columns: 1fr;\n grid-auto-rows: 1fr;\n\n ${getCardGridColumns(defaultCardWidth)}\n\n &:has(${StyledSelectionCardInline}) {\n ${getCardGridColumns(inlineImageCardWidth)}\n }\n `;\n};\n\nconst StyledCardGrid = styled.div<{\n renderInline: boolean;\n autoStack: boolean;\n childCount: number;\n}>(({ theme, renderInline, autoStack, childCount }) => {\n if (!renderInline) {\n return css`\n display: grid;\n gap: ${theme.base.spacing};\n grid-template-columns: minmax(min-content, max-content);\n grid-auto-rows: 1fr;\n `;\n }\n\n return autoStack\n ? getCardGridContainerStyles(theme)\n : css`\n display: grid;\n gap: ${theme.base.spacing};\n grid-template-columns: repeat(${childCount}, 1fr);\n grid-auto-rows: 1fr;\n `;\n});\n\nStyledCardGrid.defaultProps = defaultThemeProp;\n\nconst RadioCheckGroup = forwardRef<\n RefElement<RadioCheckGroupProps>,\n PropsWithoutRef<RadioCheckGroupProps>\n>(function RadioCheckGroup(props, ref) {\n const uid = useUID();\n const {\n testId,\n children,\n name = uid,\n disabled = false,\n required = false,\n onChange,\n readOnly,\n inline = false,\n autoStack = true,\n variant = 'simple',\n arrowNavigation = true,\n onClear,\n suggestion,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getRadioCheckGroupTestIds);\n const [optionsEl, setOptionsEl] = useElement<HTMLDivElement>();\n\n const [renderInline, setRenderInline] = useState(inline);\n const renderInlineRef = useRef(inline);\n const minInlineWidth = useRef(0);\n const containerRef = useConsolidatedRef(ref);\n const skipRef = useRef<HTMLElement>(null);\n\n useArrows(\n arrowNavigation ? containerRef : skipRef,\n {\n selector: '[data-main-focus]',\n cycle: false,\n dir: 'both'\n },\n [children]\n );\n\n useEffect(() => {\n setRenderInline(inline);\n if (inline && optionsEl && optionsEl.lastChild && autoStack) {\n const intersectionObserver = new IntersectionObserver(\n entries => {\n if (entries[0].intersectionRatio < 1) {\n if (entries[0].rootBounds) minInlineWidth.current = entries[0].rootBounds.width + 1;\n renderInlineRef.current = false;\n setRenderInline(false);\n }\n },\n { root: optionsEl, threshold: 1 }\n );\n\n const resizeObserver = new ResizeObserver(entries => {\n if (!renderInlineRef.current && entries[0].contentRect.width > minInlineWidth.current) {\n renderInlineRef.current = true;\n setRenderInline(true);\n }\n });\n\n intersectionObserver.observe(optionsEl.lastChild as Element);\n resizeObserver.observe(optionsEl);\n\n return () => {\n intersectionObserver.disconnect();\n resizeObserver.disconnect();\n };\n }\n }, [optionsEl, inline, autoStack]);\n\n const mapChildren = useMemo(() => {\n if (!children || Children.toArray(children).filter(Boolean).length === 0) return;\n\n return Children.map(children, child => {\n if (!child) return null;\n return cloneElement(child, {\n name,\n status: restProps.status,\n disabled: disabled || child.props.disabled,\n readOnly: readOnly || child.props.readOnly,\n variant: variant === 'card-grid' ? 'card' : variant,\n suppressAnnouncements: true,\n onChange: onChange\n ? (e: ChangeEvent<HTMLInputElement>) => {\n if (!(readOnly || child.props.readOnly)) {\n child.props.onChange?.(e);\n onChange(e);\n }\n }\n : child.props.onChange\n });\n });\n }, [children, name, disabled, readOnly, variant, onChange]);\n\n return (\n <FormField\n testId={testIds}\n as={StyledRadioCheckGroup}\n ref={containerRef}\n name={name}\n disabled={disabled}\n required={required}\n {...restProps}\n inline={false}\n suggestion={suggestion}\n isRadioCheck\n onClear={onClear}\n // Prevents blur when any input within the group is actively focused.\n onMouseDown={(e: ReactMouseEvent<HTMLFieldSetElement>) => {\n restProps.onMouseDown?.(e);\n\n if (!containerRef.current) return;\n\n if (!containerRef.current.contains(getActiveElement())) return;\n\n if (!(e.target instanceof Element) || !e.target.closest('label')) return;\n\n e.preventDefault();\n }}\n >\n {(() => {\n if (!mapChildren) {\n return <EmptyState variant='bordered' />;\n }\n\n return variant === 'card-grid' ? (\n <StyledCardGrid\n ref={setOptionsEl}\n renderInline={renderInline}\n autoStack={autoStack}\n childCount={Children.count(children)}\n >\n {mapChildren}\n </StyledCardGrid>\n ) : (\n <Flex\n ref={setOptionsEl}\n container={{\n direction: renderInline ? 'row' : 'column',\n colGap: renderInline ? 1.5 : 2,\n rowGap: variant === 'card' ? 1 : 0,\n wrap: 'wrap'\n }}\n >\n {mapChildren}\n </Flex>\n );\n })()}\n </FormField>\n );\n});\n\nexport default withTestIds(RadioCheckGroup, getRadioCheckGroupTestIds);\n"]}
1
+ {"version":3,"file":"RadioCheckGroup.js","sourceRoot":"","sources":["../../../src/components/RadioCheckGroup/RadioCheckGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAQjG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAqB,MAAM,mBAAmB,CAAC;AAGnE,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG9E,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AA2DvE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACjE,OAAO,GAAG,CAAA;;;;;UAKF,eAAe;;;;;MAKnB,mBAAmB;;;;MAInB,yBAAyB,IAAI,oBAAoB;;;;;MAKjD,gBAAgB,MAAM,mBAAmB;;;;MAIzC,gBAAgB;gCACU,KAAK,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ACM,CACb,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC","sourcesContent":["import { forwardRef, Children, cloneElement, useState, useEffect, useRef, useMemo } from 'react';\nimport type {\n Ref,\n PropsWithoutRef,\n ReactElement,\n ChangeEvent,\n MouseEvent as ReactMouseEvent\n} from 'react';\nimport styled, { css, type DefaultTheme } from 'styled-components';\n\nimport type { RefElement, TestIdProp, WithAttributes } from '../../types';\nimport FormField from '../FormField';\nimport type { FormFieldProps } from '../FormField';\nimport { StyledFormField, StyledFormFieldInfo } from '../FormField/FormField';\nimport type { FormControlProps } from '../FormControl';\nimport type { RadioCheckProps } from '../RadioCheck';\nimport Flex from '../Flex';\nimport { defaultThemeProp } from '../../theme';\nimport { useArrows, useConsolidatedRef, useElement, useTestIds, useUID } from '../../hooks';\nimport {\n StyledImageContainer,\n StyledSelectionCard,\n StyledSelectionCardInline\n} from '../SelectionCard/SelectionCard.styles';\nimport { getActiveElement, withTestIds } from '../../utils';\nimport type { elements } from '../FormField/FormField.test-ids';\nimport { StyledRadioCheck } from '../RadioCheck/RadioCheck';\nimport EmptyState, { StyledEmptyState } from '../EmptyState';\n\nimport { getRadioCheckGroupTestIds } from './RadioCheckGroup.test-ids';\n\nexport type RadioCheckGroupProps = WithAttributes<\n 'fieldset',\n TestIdProp<typeof elements> &\n Pick<FormControlProps, 'suggestion'> & {\n /** Accepts Checkboxes or RadioButtons as children. */\n children?: ReactElement | ReactElement[];\n /**\n * Conveniently pass an onChange handler to the group to be notified when any of the inputs change.\n * Additionally, onChange can be passed to individual children.\n * Both handlers will be called, child followed by group.\n */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /** Callback invoked when the clear button is clicked. If provided will render the clear button. */\n onClear?: FormFieldProps['onClear'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /**\n * Layout field elements inline in a row.\n * @default false\n */\n inline?: FormFieldProps['inline'];\n /** Used to toggle the auto stacking feature of an inlined group.\n * @default true\n */\n autoStack?: boolean;\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /**\n * Controls the styling of the child RadioChecks.\n * @default 'simple'\n */\n variant?: RadioCheckProps['variant'] | 'card-grid';\n /** Pass a heading and content to show additional information on the field. */\n additionalInfo?: FormControlProps['additionalInfo'];\n /**\n * Enables arrow key navigation between options in the group.\n * Disable for checkbox groups where each option is independently selectable.\n * @default true\n */\n arrowNavigation?: boolean;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLElement>;\n }\n>;\n\nexport const StyledRadioCheckGroup = styled.fieldset(({ theme }) => {\n return css`\n container-type: inline-size;\n flex-wrap: nowrap;\n\n &[disabled] {\n > ${StyledFormField} {\n opacity: unset;\n }\n }\n\n ${StyledSelectionCard} {\n max-width: 100%;\n }\n\n ${StyledSelectionCardInline} ${StyledImageContainer} {\n /* To enlarge the image containers to the size of the biggest one */\n min-height: 100%;\n }\n\n ${StyledRadioCheck} > ${StyledFormFieldInfo} {\n display: none;\n }\n\n ${StyledEmptyState} {\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-radius: ${theme.components.card['border-radius']};\n padding: calc(2 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledRadioCheckGroup.defaultProps = defaultThemeProp;\n\nconst getCardGridColumns = (cardWidth: string) => css`\n @container (min-width: calc(2 * ${cardWidth})) {\n grid-template-columns: repeat(2, 1fr);\n }\n\n @container (min-width: calc(3 * ${cardWidth})) {\n grid-template-columns: repeat(3, 1fr);\n }\n\n @container (min-width: calc(4 * ${cardWidth})) {\n grid-template-columns: repeat(4, 1fr);\n }\n`;\n\nconst getCardGridContainerStyles = (theme: DefaultTheme) => {\n const defaultCardWidth = theme.base['content-width'].sm;\n const inlineImageCardWidth = theme.base['content-width'].md;\n return css`\n display: grid;\n gap: ${theme.base.spacing};\n grid-template-columns: 1fr;\n grid-auto-rows: 1fr;\n\n ${getCardGridColumns(defaultCardWidth)}\n\n &:has(${StyledSelectionCardInline}) {\n ${getCardGridColumns(inlineImageCardWidth)}\n }\n `;\n};\n\nconst StyledCardGrid = styled.div<{\n renderInline: boolean;\n autoStack: boolean;\n childCount: number;\n}>(({ theme, renderInline, autoStack, childCount }) => {\n if (!renderInline) {\n return css`\n display: grid;\n gap: ${theme.base.spacing};\n grid-template-columns: minmax(min-content, max-content);\n grid-auto-rows: 1fr;\n `;\n }\n\n return autoStack\n ? getCardGridContainerStyles(theme)\n : css`\n display: grid;\n gap: ${theme.base.spacing};\n grid-template-columns: repeat(${childCount}, 1fr);\n grid-auto-rows: 1fr;\n `;\n});\n\nStyledCardGrid.defaultProps = defaultThemeProp;\n\nconst RadioCheckGroup = forwardRef<\n RefElement<RadioCheckGroupProps>,\n PropsWithoutRef<RadioCheckGroupProps>\n>(function RadioCheckGroup(props, ref) {\n const uid = useUID();\n const {\n testId,\n children,\n name = uid,\n disabled = false,\n required = false,\n onChange,\n readOnly,\n inline = false,\n autoStack = true,\n variant = 'simple',\n arrowNavigation = true,\n onClear,\n suggestion,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getRadioCheckGroupTestIds);\n const [optionsEl, setOptionsEl] = useElement<HTMLDivElement>();\n\n const [renderInline, setRenderInline] = useState(inline);\n const renderInlineRef = useRef(inline);\n const minInlineWidth = useRef(0);\n const containerRef = useConsolidatedRef(ref);\n const skipRef = useRef<HTMLElement>(null);\n\n useArrows(\n arrowNavigation ? containerRef : skipRef,\n {\n selector: '[data-main-focus]',\n cycle: false,\n dir: 'both'\n },\n [children]\n );\n\n useEffect(() => {\n setRenderInline(inline);\n if (inline && optionsEl && optionsEl.lastChild && autoStack) {\n const intersectionObserver = new IntersectionObserver(\n entries => {\n if (entries[0].intersectionRatio < 1) {\n if (entries[0].rootBounds) minInlineWidth.current = entries[0].rootBounds.width + 1;\n renderInlineRef.current = false;\n setRenderInline(false);\n }\n },\n { root: optionsEl, threshold: 1 }\n );\n\n const resizeObserver = new ResizeObserver(entries => {\n if (!renderInlineRef.current && entries[0].contentRect.width > minInlineWidth.current) {\n renderInlineRef.current = true;\n setRenderInline(true);\n }\n });\n\n intersectionObserver.observe(optionsEl.lastChild as Element);\n resizeObserver.observe(optionsEl);\n\n return () => {\n intersectionObserver.disconnect();\n resizeObserver.disconnect();\n };\n }\n }, [optionsEl, inline, autoStack]);\n\n const mapChildren = useMemo(() => {\n if (!children || Children.toArray(children).filter(Boolean).length === 0) return;\n\n return Children.map(children, child => {\n if (!child) return null;\n return cloneElement(child, {\n name,\n status: restProps.status,\n disabled: disabled || child.props.disabled,\n readOnly: readOnly || child.props.readOnly,\n variant: variant === 'card-grid' ? 'card' : variant,\n suppressAnnouncements: true,\n onChange: onChange\n ? (e: ChangeEvent<HTMLInputElement>) => {\n if (!(readOnly || child.props.readOnly)) {\n child.props.onChange?.(e);\n onChange(e);\n }\n }\n : child.props.onChange\n });\n });\n }, [children, name, disabled, readOnly, variant, onChange]);\n\n return (\n <FormField\n testId={testIds}\n as={StyledRadioCheckGroup}\n ref={containerRef}\n name={name}\n disabled={disabled}\n required={required}\n {...restProps}\n inline={false}\n suggestion={suggestion}\n isRadioCheck\n labelVariant={variant === 'card-grid' ? 'h3' : undefined}\n onClear={onClear}\n // Prevents blur when any input within the group is actively focused.\n onMouseDown={(e: ReactMouseEvent<HTMLFieldSetElement>) => {\n restProps.onMouseDown?.(e);\n\n if (!containerRef.current) return;\n\n if (!containerRef.current.contains(getActiveElement())) return;\n\n if (!(e.target instanceof Element) || !e.target.closest('label')) return;\n\n e.preventDefault();\n }}\n >\n {(() => {\n if (!mapChildren) {\n return <EmptyState variant='bordered' />;\n }\n\n return variant === 'card-grid' ? (\n <StyledCardGrid\n ref={setOptionsEl}\n renderInline={renderInline}\n autoStack={autoStack}\n childCount={Children.count(children)}\n >\n {mapChildren}\n </StyledCardGrid>\n ) : (\n <Flex\n ref={setOptionsEl}\n container={{\n direction: renderInline ? 'row' : 'column',\n colGap: renderInline ? 1.5 : 2,\n rowGap: variant === 'card' ? 1 : 0,\n wrap: 'wrap'\n }}\n >\n {mapChildren}\n </Flex>\n );\n })()}\n </FormField>\n );\n});\n\nexport default withTestIds(RadioCheckGroup, getRadioCheckGroupTestIds);\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { SelectionCardProps } from './SelectionCard.types';
2
- export declare const focusableSelector = "a[href], button, input, textarea, select, details, video[controls], audio[controls]";
2
+ export declare const focusableSelector = "a[href], button, input, textarea, select, details, video[controls], audio[controls], div[role=\"button\"]";
3
3
  declare const _default: import("react").ForwardRefExoticComponent<Omit<SelectionCardProps, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
4
4
  getTestIds: (testIdProp?: import("../..").TestIdProp["testId"]) => import("../..").TestIdsRecord<readonly ["content", "image", "label", "actions"]>;
5
5
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionCard.d.ts","sourceRoot":"","sources":["../../../src/components/SelectionCard/SelectionCard.tsx"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAIV,kBAAkB,EAEnB,MAAM,uBAAuB,CAAC;AAW/B,eAAO,MAAM,iBAAiB,wFACyD,CAAC;;;;AAuSxF,wBAAmE"}
1
+ {"version":3,"file":"SelectionCard.d.ts","sourceRoot":"","sources":["../../../src/components/SelectionCard/SelectionCard.tsx"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAIV,kBAAkB,EAEnB,MAAM,uBAAuB,CAAC;AAW/B,eAAO,MAAM,iBAAiB,8GAC6E,CAAC;;;;AAyS5G,wBAAmE"}
@@ -17,7 +17,7 @@ registerIcon(pictureIcon);
17
17
  const isTileContent = (img) => {
18
18
  return 'foregroundColor' in img;
19
19
  };
20
- export const focusableSelector = 'a[href], button, input, textarea, select, details, video[controls], audio[controls]';
20
+ export const focusableSelector = 'a[href], button, input, textarea, select, details, video[controls], audio[controls], div[role="button"]';
21
21
  const SingleField = ({ id, 'data-testid': testId, truncate, value }) => {
22
22
  const [el, setEl] = useElement(null);
23
23
  return (_jsxs(_Fragment, { children: [_jsx(StyledSingleField, { ref: setEl, id: id, "data-testid": testId, truncate: truncate, children: value }), truncate && el && (_jsx(Tooltip, { target: el, smart: true, children: value }))] }));
@@ -58,13 +58,13 @@ const SelectionCard = forwardRef(function SelectionCard(props, ref) {
58
58
  setHasInteractiveElements(focusables?.length || 0);
59
59
  setFocusOnInput(focusables?.length === 1 && focusables?.[0] instanceof HTMLInputElement);
60
60
  focusables?.forEach(el => el.hasAttribute('data-main-focus')
61
- ? el.removeAttribute('tabindex')
61
+ ? el.setAttribute('tabindex', '0')
62
62
  : el.setAttribute('tabindex', '-1'));
63
63
  }, [additionalInfo, fields, actions]);
64
64
  useFocusTrap(focusOnInput ? null : contentRef, false, [contentRef]);
65
65
  useFocusWithin([focusOnInput ? null : contentRef], focused => contentRef.current
66
66
  ?.querySelectorAll(focusableSelector)
67
- .forEach(el => (focused ? el.removeAttribute('tabindex') : el.setAttribute('tabindex', '-1'))));
67
+ .forEach(el => focused ? el.setAttribute('tabindex', '0') : el.setAttribute('tabindex', '-1')));
68
68
  useEscape(() => containerRef.current?.focus(), focusOnInput ? null : containerRef, [
69
69
  containerRef
70
70
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionCard.js","sourceRoot":"","sources":["../../../src/components/SelectionCard/SelectionCard.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACR,OAAO,EACP,eAAe,EACf,WAAW,EACX,YAAY,EACb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CACJ,CAAC,IACC,EACN,MAAM,IAAI,KAAC,gBAAgB,cAAE,MAAM,GAAoB,IACtC,EACnB,KAAK,EAAE,SAAS,KAAK,YAAY,IAAI,YAAY,IAC7C,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,aAAa,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import {\n forwardRef,\n useEffect,\n useRef,\n useState,\n useMemo,\n useLayoutEffect,\n useCallback,\n cloneElement\n} from 'react';\nimport type { KeyboardEvent, PropsWithoutRef, ReactNode, RefObject } from 'react';\n\nimport { getActiveElement, withTestIds, isValidElement, hasProp } from '../../utils';\nimport Icon, { registerIcon } from '../Icon';\nimport type { RefElement } from '../../types';\nimport {\n useConsolidatedRef,\n useElement,\n useEscape,\n useFocusTrap,\n useFocusWithin,\n useI18n,\n usePrevious,\n useTestIds,\n useUID\n} from '../../hooks';\nimport Grid from '../Grid';\nimport type { GridProps } from '../Grid';\nimport Flex from '../Flex';\nimport FieldValueList from '../FieldValueList';\nimport type { FieldValueListItemProps } from '../FieldValueList';\nimport { StyledImage } from '../Image';\nimport * as pictureIcon from '../Icon/icons/picture.icon';\nimport ShowMoreLess from '../ShowMoreLess';\nimport Tooltip from '../Tooltip';\n\nimport { getSelectionCardTestIds } from './SelectionCard.test-ids';\nimport {\n StyledSelectionCard,\n StyledContentContainer,\n StyledImageContainer,\n StyledSelectionCardInline,\n StyledSelectionCardStacked,\n StyledValueList,\n StyledHeader,\n StyledImageCell,\n StyledContentCell,\n StyledTileContent,\n StyledCardFooter,\n StyledSingleField\n} from './SelectionCard.styles';\nimport type {\n FieldValueItemPropsOmitName,\n ImagePlacement,\n ImageSize,\n SelectionCardProps,\n SelectionCardTile\n} from './SelectionCard.types';\nimport SelectionCardActions from './SelectionCardActions';\n\nregisterIcon(pictureIcon);\n\nconst isTileContent = (\n img: NonNullable<SelectionCardProps['image']>\n): img is SelectionCardTile & { placement?: ImagePlacement; size?: ImageSize } => {\n return 'foregroundColor' in img;\n};\n\nexport const focusableSelector =\n 'a[href], button, input, textarea, select, details, video[controls], audio[controls]';\n\nconst SingleField = ({\n id,\n 'data-testid': testId,\n truncate,\n value\n}: {\n id: string;\n 'data-testid'?: string;\n truncate?: boolean;\n value: ReactNode;\n}) => {\n const [el, setEl] = useElement<HTMLDivElement>(null);\n return (\n <>\n <StyledSingleField ref={setEl} id={id} data-testid={testId} truncate={truncate}>\n {value}\n </StyledSingleField>\n {truncate && el && (\n <Tooltip target={el} smart>\n {value}\n </Tooltip>\n )}\n </>\n );\n};\n\nconst useContentHeight = (\n contentRef: RefObject<HTMLElement>,\n targetRef: RefObject<HTMLElement>\n) => {\n useLayoutEffect(() => {\n if (!contentRef.current || !targetRef.current) return;\n\n const resizeObserver = new ResizeObserver(() => {\n requestAnimationFrame(() => {\n targetRef.current?.style.setProperty(\n '--content-height',\n `${contentRef.current?.scrollHeight}px`\n );\n });\n });\n\n resizeObserver.observe(contentRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }, []);\n};\n\nconst SelectionCard = forwardRef<\n RefElement<SelectionCardProps>,\n PropsWithoutRef<SelectionCardProps>\n>(function SelectionCard(props, ref) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n 'aria-label': label,\n heading,\n disabled = false,\n readOnly,\n image,\n footer,\n fields = [],\n onClick,\n onKeyDown,\n actions,\n additionalInfo,\n ...restProps\n } = props;\n\n const t = useI18n();\n\n const contentRef = useRef<HTMLDivElement>(null);\n const containerRef = useConsolidatedRef(ref);\n\n const [focusOnInput, setFocusOnInput] = useState(false);\n const [hasInteractiveElements, setHasInteractiveElements] = useState(0);\n const [isBrokenImage, setIsBrokenImage] = useState(false);\n const isTile = image !== undefined && isTileContent(image);\n const tile = isTile ? image : undefined;\n const resolvedImageSrc = !isTile ? image?.src : undefined;\n const prevImageSrc = usePrevious(resolvedImageSrc);\n const testIds = useTestIds(testId, getSelectionCardTestIds);\n const contentId = `${id}-content`;\n\n const hasAdditionalContent = fields.length > 0;\n\n useEffect(() => {\n const focusables = containerRef.current?.querySelectorAll(focusableSelector);\n setHasInteractiveElements(focusables?.length || 0);\n setFocusOnInput(focusables?.length === 1 && focusables?.[0] instanceof HTMLInputElement);\n focusables?.forEach(el =>\n el.hasAttribute('data-main-focus')\n ? el.removeAttribute('tabindex')\n : el.setAttribute('tabindex', '-1')\n );\n }, [additionalInfo, fields, actions]);\n\n useFocusTrap(focusOnInput ? null : contentRef, false, [contentRef]);\n\n useFocusWithin([focusOnInput ? null : contentRef], focused =>\n contentRef.current\n ?.querySelectorAll(focusableSelector)\n .forEach(el => (focused ? el.removeAttribute('tabindex') : el.setAttribute('tabindex', '-1')))\n );\n\n useEscape(() => containerRef.current?.focus(), focusOnInput ? null : containerRef, [\n containerRef\n ]);\n\n useContentHeight(contentRef, containerRef);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (\n event.key === 'Enter' &&\n containerRef.current === getActiveElement() &&\n (!focusOnInput || (focusOnInput && hasInteractiveElements > 1))\n ) {\n event.preventDefault();\n contentRef.current?.querySelectorAll<HTMLElement>(focusableSelector)[0]?.focus();\n }\n onKeyDown?.(event);\n },\n [containerRef, contentRef]\n );\n\n const imageContent = useMemo(() => {\n if (!image) return undefined;\n\n const innerContent = tile ? (\n <StyledTileContent\n data-tile-content\n foregroundColor={tile.foregroundColor}\n backgroundColor={tile.backgroundColor}\n size={tile.size}\n >\n {tile.icon ? <Icon name={tile.icon} /> : tile.text || <Icon name='picture' />}\n </StyledTileContent>\n ) : (\n <Flex\n container={{ justify: 'center', alignItems: 'center' }}\n as={StyledImageContainer}\n placement={image.placement}\n size={image.size}\n >\n {(isBrokenImage && resolvedImageSrc === prevImageSrc) || resolvedImageSrc === undefined ? (\n <Icon name='picture' aria-label={t('image_load_error')} />\n ) : (\n <StyledImage\n data-testid={testIds.image}\n {...image}\n onError={() => setIsBrokenImage(true)}\n onLoad={() => setIsBrokenImage(false)}\n />\n )}\n </Flex>\n );\n\n return (\n <Flex\n container={{ justify: 'center', alignItems: 'center' }}\n as={StyledImageCell}\n placement={image.placement}\n size={image.size}\n isTile={isTile}\n style={\n !isTile && image.src && !isBrokenImage ? { '--bg-image': `url(${image.src})` } : undefined\n }\n >\n {innerContent}\n </Flex>\n );\n }, [\n isBrokenImage,\n prevImageSrc,\n image?.placement,\n image?.size,\n tile?.icon,\n tile?.text,\n tile?.foregroundColor,\n tile?.backgroundColor\n ]);\n\n let asProp: GridProps['as'] = StyledSelectionCard;\n if (image) {\n asProp = (image.placement ?? 'inline-start').startsWith('block')\n ? StyledSelectionCardStacked\n : StyledSelectionCardInline;\n }\n\n const isFieldValueListItemProps = (\n item: FieldValueListItemProps | FieldValueItemPropsOmitName\n ): item is FieldValueListItemProps => {\n return hasProp(item, 'name');\n };\n\n return (\n <Grid\n data-testid={testIds.root}\n {...restProps}\n id={id}\n onClick={onClick}\n as={asProp}\n placement={image?.placement}\n size={image?.size}\n container={{ cols: '1fr', rows: 'auto' }}\n disabled={disabled}\n readOnly={readOnly}\n role={hasInteractiveElements ? 'group' : 'article'}\n aria-label={label}\n ref={containerRef}\n data-main-focus={focusOnInput ? undefined : true}\n tabIndex={focusOnInput ? undefined : 0}\n onKeyDown={handleKeyDown}\n >\n {image && image.placement !== 'inline-end' && imageContent}\n {/* element needed to get actual content height of the content container */}\n <StyledContentCell>\n <Flex\n as={StyledContentContainer}\n container={{ direction: 'column', gap: 0.75 }}\n ref={contentRef}\n >\n <Flex as={StyledHeader} container={{ alignItems: 'center', justify: 'between' }}>\n {isValidElement(heading) ? (\n cloneElement(heading, {\n ...{\n tabIndex: focusOnInput ? undefined : -1,\n additionalInfo,\n 'data-main-focus': focusOnInput ? true : undefined,\n 'aria-details': hasAdditionalContent ? contentId : undefined\n }\n })\n ) : (\n <span\n data-testid={testIds.label}\n aria-details={hasAdditionalContent ? contentId : undefined}\n >\n {heading}\n </span>\n )}\n {actions && (\n <SelectionCardActions\n data-testid={testIds.actions}\n actions={actions}\n disabled={disabled}\n contextualLabel={label}\n />\n )}\n </Flex>\n {hasAdditionalContent &&\n (fields.every(field => isFieldValueListItemProps(field)) ? (\n <FieldValueList id={contentId} data-testid={testIds.content} fields={fields} />\n ) : (\n <>\n {fields.length === 1 ? (\n <SingleField\n id={contentId}\n data-testid={testIds.content}\n truncate={fields[0].truncate}\n value={fields[0].value}\n />\n ) : (\n <Flex\n container={{ direction: 'column', gap: 1 }}\n as={StyledValueList}\n id={contentId}\n data-testid={testIds.content}\n >\n {fields.map(field => (\n <li key={field.id}>\n {field.truncate ? (\n <ShowMoreLess lines={3}>{field.value}</ShowMoreLess>\n ) : (\n field.value\n )}\n </li>\n ))}\n </Flex>\n )}\n </>\n ))}\n </Flex>\n {footer && <StyledCardFooter>{footer}</StyledCardFooter>}\n </StyledContentCell>\n {image?.placement === 'inline-end' && imageContent}\n </Grid>\n );\n});\n\nexport default withTestIds(SelectionCard, getSelectionCardTestIds);\n"]}
1
+ {"version":3,"file":"SelectionCard.js","sourceRoot":"","sources":["../../../src/components/SelectionCard/SelectionCard.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACR,OAAO,EACP,eAAe,EACf,WAAW,EACX,YAAY,EACb,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,YAAY,EACZ,cAAc,EACd,OAAO,EACP,WAAW,EACX,UAAU,EACV,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,C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AO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAI,CAChF,CAAC,CAAC,CAAC,CACF,4BACG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CACrB,KAAC,WAAW,IACV,EAAE,EAAE,SAAS,iBACA,OAAO,CAAC,OAAO,EAC5B,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAC5B,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,GACtB,CACH,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,EAC1C,EAAE,EAAE,eAAe,EACnB,EAAE,EAAE,SAAS,iBACA,OAAO,CAAC,OAAO,YAE3B,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CACnB,uBACG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAChB,KAAC,YAAY,IAAC,KAAK,EAAE,CAAC,YAAG,KAAK,CAAC,KAAK,GAAgB,CACrD,CAAC,CAAC,CAAC,CACF,KAAK,CAAC,KAAK,CACZ,IALM,KAAK,CAAC,EAAE,CAMZ,CACN,CAAC,GACG,CACR,GACA,CACJ,CAAC,IACC,EACN,MAAM,IAAI,KAAC,gBAAgB,cAAE,MAAM,GAAoB,IACtC,EACnB,KAAK,EAAE,SAAS,KAAK,YAAY,IAAI,YAAY,IAC7C,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,aAAa,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import {\n forwardRef,\n useEffect,\n useRef,\n useState,\n useMemo,\n useLayoutEffect,\n useCallback,\n cloneElement\n} from 'react';\nimport type { KeyboardEvent, PropsWithoutRef, ReactNode, RefObject } from 'react';\n\nimport { getActiveElement, withTestIds, isValidElement, hasProp } from '../../utils';\nimport Icon, { registerIcon } from '../Icon';\nimport type { RefElement } from '../../types';\nimport {\n useConsolidatedRef,\n useElement,\n useEscape,\n useFocusTrap,\n useFocusWithin,\n useI18n,\n usePrevious,\n useTestIds,\n useUID\n} from '../../hooks';\nimport Grid from '../Grid';\nimport type { GridProps } from '../Grid';\nimport Flex from '../Flex';\nimport FieldValueList from '../FieldValueList';\nimport type { FieldValueListItemProps } from '../FieldValueList';\nimport { StyledImage } from '../Image';\nimport * as pictureIcon from '../Icon/icons/picture.icon';\nimport ShowMoreLess from '../ShowMoreLess';\nimport Tooltip from '../Tooltip';\n\nimport { getSelectionCardTestIds } from './SelectionCard.test-ids';\nimport {\n StyledSelectionCard,\n StyledContentContainer,\n StyledImageContainer,\n StyledSelectionCardInline,\n StyledSelectionCardStacked,\n StyledValueList,\n StyledHeader,\n StyledImageCell,\n StyledContentCell,\n StyledTileContent,\n StyledCardFooter,\n StyledSingleField\n} from './SelectionCard.styles';\nimport type {\n FieldValueItemPropsOmitName,\n ImagePlacement,\n ImageSize,\n SelectionCardProps,\n SelectionCardTile\n} from './SelectionCard.types';\nimport SelectionCardActions from './SelectionCardActions';\n\nregisterIcon(pictureIcon);\n\nconst isTileContent = (\n img: NonNullable<SelectionCardProps['image']>\n): img is SelectionCardTile & { placement?: ImagePlacement; size?: ImageSize } => {\n return 'foregroundColor' in img;\n};\n\nexport const focusableSelector =\n 'a[href], button, input, textarea, select, details, video[controls], audio[controls], div[role=\"button\"]';\n\nconst SingleField = ({\n id,\n 'data-testid': testId,\n truncate,\n value\n}: {\n id: string;\n 'data-testid'?: string;\n truncate?: boolean;\n value: ReactNode;\n}) => {\n const [el, setEl] = useElement<HTMLDivElement>(null);\n return (\n <>\n <StyledSingleField ref={setEl} id={id} data-testid={testId} truncate={truncate}>\n {value}\n </StyledSingleField>\n {truncate && el && (\n <Tooltip target={el} smart>\n {value}\n </Tooltip>\n )}\n </>\n );\n};\n\nconst useContentHeight = (\n contentRef: RefObject<HTMLElement>,\n targetRef: RefObject<HTMLElement>\n) => {\n useLayoutEffect(() => {\n if (!contentRef.current || !targetRef.current) return;\n\n const resizeObserver = new ResizeObserver(() => {\n requestAnimationFrame(() => {\n targetRef.current?.style.setProperty(\n '--content-height',\n `${contentRef.current?.scrollHeight}px`\n );\n });\n });\n\n resizeObserver.observe(contentRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }, []);\n};\n\nconst SelectionCard = forwardRef<\n RefElement<SelectionCardProps>,\n PropsWithoutRef<SelectionCardProps>\n>(function SelectionCard(props, ref) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n 'aria-label': label,\n heading,\n disabled = false,\n readOnly,\n image,\n footer,\n fields = [],\n onClick,\n onKeyDown,\n actions,\n additionalInfo,\n ...restProps\n } = props;\n\n const t = useI18n();\n\n const contentRef = useRef<HTMLDivElement>(null);\n const containerRef = useConsolidatedRef(ref);\n\n const [focusOnInput, setFocusOnInput] = useState(false);\n const [hasInteractiveElements, setHasInteractiveElements] = useState(0);\n const [isBrokenImage, setIsBrokenImage] = useState(false);\n const isTile = image !== undefined && isTileContent(image);\n const tile = isTile ? image : undefined;\n const resolvedImageSrc = !isTile ? image?.src : undefined;\n const prevImageSrc = usePrevious(resolvedImageSrc);\n const testIds = useTestIds(testId, getSelectionCardTestIds);\n const contentId = `${id}-content`;\n\n const hasAdditionalContent = fields.length > 0;\n\n useEffect(() => {\n const focusables = containerRef.current?.querySelectorAll(focusableSelector);\n setHasInteractiveElements(focusables?.length || 0);\n setFocusOnInput(focusables?.length === 1 && focusables?.[0] instanceof HTMLInputElement);\n focusables?.forEach(el =>\n el.hasAttribute('data-main-focus')\n ? el.setAttribute('tabindex', '0')\n : el.setAttribute('tabindex', '-1')\n );\n }, [additionalInfo, fields, actions]);\n\n useFocusTrap(focusOnInput ? null : contentRef, false, [contentRef]);\n\n useFocusWithin([focusOnInput ? null : contentRef], focused =>\n contentRef.current\n ?.querySelectorAll(focusableSelector)\n .forEach(el =>\n focused ? el.setAttribute('tabindex', '0') : el.setAttribute('tabindex', '-1')\n )\n );\n\n useEscape(() => containerRef.current?.focus(), focusOnInput ? null : containerRef, [\n containerRef\n ]);\n\n useContentHeight(contentRef, containerRef);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (\n event.key === 'Enter' &&\n containerRef.current === getActiveElement() &&\n (!focusOnInput || (focusOnInput && hasInteractiveElements > 1))\n ) {\n event.preventDefault();\n contentRef.current?.querySelectorAll<HTMLElement>(focusableSelector)[0]?.focus();\n }\n onKeyDown?.(event);\n },\n [containerRef, contentRef]\n );\n\n const imageContent = useMemo(() => {\n if (!image) return undefined;\n\n const innerContent = tile ? (\n <StyledTileContent\n data-tile-content\n foregroundColor={tile.foregroundColor}\n backgroundColor={tile.backgroundColor}\n size={tile.size}\n >\n {tile.icon ? <Icon name={tile.icon} /> : tile.text || <Icon name='picture' />}\n </StyledTileContent>\n ) : (\n <Flex\n container={{ justify: 'center', alignItems: 'center' }}\n as={StyledImageContainer}\n placement={image.placement}\n size={image.size}\n >\n {(isBrokenImage && resolvedImageSrc === prevImageSrc) || resolvedImageSrc === undefined ? (\n <Icon name='picture' aria-label={t('image_load_error')} />\n ) : (\n <StyledImage\n data-testid={testIds.image}\n {...image}\n onError={() => setIsBrokenImage(true)}\n onLoad={() => setIsBrokenImage(false)}\n />\n )}\n </Flex>\n );\n\n return (\n <Flex\n container={{ justify: 'center', alignItems: 'center' }}\n as={StyledImageCell}\n placement={image.placement}\n size={image.size}\n isTile={isTile}\n style={\n !isTile && image.src && !isBrokenImage ? { '--bg-image': `url(${image.src})` } : undefined\n }\n >\n {innerContent}\n </Flex>\n );\n }, [\n isBrokenImage,\n prevImageSrc,\n image?.placement,\n image?.size,\n tile?.icon,\n tile?.text,\n tile?.foregroundColor,\n tile?.backgroundColor\n ]);\n\n let asProp: GridProps['as'] = StyledSelectionCard;\n if (image) {\n asProp = (image.placement ?? 'inline-start').startsWith('block')\n ? StyledSelectionCardStacked\n : StyledSelectionCardInline;\n }\n\n const isFieldValueListItemProps = (\n item: FieldValueListItemProps | FieldValueItemPropsOmitName\n ): item is FieldValueListItemProps => {\n return hasProp(item, 'name');\n };\n\n return (\n <Grid\n data-testid={testIds.root}\n {...restProps}\n id={id}\n onClick={onClick}\n as={asProp}\n placement={image?.placement}\n size={image?.size}\n container={{ cols: '1fr', rows: 'auto' }}\n disabled={disabled}\n readOnly={readOnly}\n role={hasInteractiveElements ? 'group' : 'article'}\n aria-label={label}\n ref={containerRef}\n data-main-focus={focusOnInput ? undefined : true}\n tabIndex={focusOnInput ? undefined : 0}\n onKeyDown={handleKeyDown}\n >\n {image && image.placement !== 'inline-end' && imageContent}\n {/* element needed to get actual content height of the content container */}\n <StyledContentCell>\n <Flex\n as={StyledContentContainer}\n container={{ direction: 'column', gap: 0.75 }}\n ref={contentRef}\n >\n <Flex as={StyledHeader} container={{ alignItems: 'center', justify: 'between' }}>\n {isValidElement(heading) ? (\n cloneElement(heading, {\n ...{\n tabIndex: focusOnInput ? undefined : -1,\n additionalInfo,\n 'data-main-focus': focusOnInput ? true : undefined,\n 'aria-details': hasAdditionalContent ? contentId : undefined\n }\n })\n ) : (\n <span\n data-testid={testIds.label}\n aria-details={hasAdditionalContent ? contentId : undefined}\n >\n {heading}\n </span>\n )}\n {actions && (\n <SelectionCardActions\n data-testid={testIds.actions}\n actions={actions}\n disabled={disabled}\n contextualLabel={label}\n />\n )}\n </Flex>\n {hasAdditionalContent &&\n (fields.every(field => isFieldValueListItemProps(field)) ? (\n <FieldValueList id={contentId} data-testid={testIds.content} fields={fields} />\n ) : (\n <>\n {fields.length === 1 ? (\n <SingleField\n id={contentId}\n data-testid={testIds.content}\n truncate={fields[0].truncate}\n value={fields[0].value}\n />\n ) : (\n <Flex\n container={{ direction: 'column', gap: 1 }}\n as={StyledValueList}\n id={contentId}\n data-testid={testIds.content}\n >\n {fields.map(field => (\n <li key={field.id}>\n {field.truncate ? (\n <ShowMoreLess lines={3}>{field.value}</ShowMoreLess>\n ) : (\n field.value\n )}\n </li>\n ))}\n </Flex>\n )}\n </>\n ))}\n </Flex>\n {footer && <StyledCardFooter>{footer}</StyledCardFooter>}\n </StyledContentCell>\n {image?.placement === 'inline-end' && imageContent}\n </Grid>\n );\n});\n\nexport default withTestIds(SelectionCard, getSelectionCardTestIds);\n"]}
@@ -1,8 +1,13 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { HeadingTag, OmitStrict } from '../../types';
3
+ import type { MetaListProps } from '../MetaList';
3
4
  import type { SelectionCardProps } from './SelectionCard.types';
4
5
  export interface SelectionCardDisplayProps extends OmitStrict<SelectionCardProps, 'heading' | 'disabled'> {
5
6
  label: NonNullable<ReactNode>;
7
+ /** Metadata items displayed below the heading. */
8
+ subheading?: MetaListProps['items'];
9
+ /** Optional visual displayed before the heading. */
10
+ visual?: ReactNode;
6
11
  /**
7
12
  * Uses specific heading tag for header.
8
13
  * @default h4
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionCardDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/SelectionCard/SelectionCardDisplay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAKtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAIhE,MAAM,WAAW,yBACf,SAAQ,UAAU,CAAC,kBAAkB,EAAE,SAAS,GAAG,UAAU,CAAC;IAC9D,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAC9B;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;;;;AAmCD,wBAA0E"}
1
+ {"version":3,"file":"SelectionCardDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/SelectionCard/SelectionCardDisplay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAKtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAIhE,MAAM,WAAW,yBACf,SAAQ,UAAU,CAAC,kBAAkB,EAAE,SAAS,GAAG,UAAU,CAAC;IAC9D,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAC9B,kDAAkD;IAClD,UAAU,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACpC,oDAAoD;IACpD,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;;;;AA4CD,wBAA0E"}
@@ -2,15 +2,17 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import { useTestIds, useUID } from '../../hooks';
4
4
  import Text from '../Text';
5
+ import SummaryItem from '../SummaryItem';
6
+ import MetaList from '../MetaList';
5
7
  import { withTestIds } from '../../utils';
6
8
  import { getSelectionCardTestIds } from './SelectionCard.test-ids';
7
9
  import SelectionCard from './SelectionCard';
8
10
  const SelectionCardDisplay = forwardRef(function SelectionCardDisplay(props, ref) {
9
11
  const uid = useUID();
10
- const { testId, id = uid, 'aria-label': ariaLabel, label, headingTag = 'h4', ...restProps } = props;
12
+ const { testId, id = uid, 'aria-label': ariaLabel, label, subheading, visual, headingTag = 'h4', ...restProps } = props;
11
13
  const labelId = `${id}-label`;
12
14
  const testIds = useTestIds(testId, getSelectionCardTestIds);
13
- return (_jsx(SelectionCard, { ...restProps, testId: testIds, "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : labelId, heading: _jsx(Text, { variant: headingTag, as: 'span', id: labelId, "data-testid": testIds.label, children: label }), ref: ref }));
15
+ return (_jsx(SelectionCard, { ...restProps, testId: testIds, "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : labelId, heading: _jsx(SummaryItem, { primary: _jsx(Text, { variant: headingTag, as: 'span', id: labelId, "data-testid": testIds.label, children: label }), secondary: subheading?.length ? _jsx(MetaList, { items: subheading }) : undefined, visual: visual, layout: 'stacked' }), ref: ref }));
14
16
  });
15
17
  export default withTestIds(SelectionCardDisplay, getSelectionCardTestIds);
16
18
  //# sourceMappingURL=SelectionCardDisplay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionCardDisplay.js","sourceRoot":"","sources":["../../../src/components/SelectionCard/SelectionCardDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAInC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAY5C,MAAM,oBAAoB,GAAG,UAAU,CAGrC,SAAS,oBAAoB,CAAC,KAAK,EAAE,GAAG;IACxC,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,EACJ,MAAM,EACN,EAAE,GAAG,GAAG,EACR,YAAY,EAAE,SAAS,EACvB,KAAK,EACL,UAAU,GAAG,IAAI,EACjB,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IACV,MAAM,OAAO,GAAG,GAAG,EAAE,QAAQ,CAAC;IAE9B,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IAE5D,OAAO,CACL,KAAC,aAAa,OACR,SAAS,EACb,MAAM,EAAE,OAAO,gBACH,SAAS,qBACJ,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAChD,OAAO,EACL,KAAC,IAAI,IAAC,OAAO,EAAE,UAAU,EAAE,EAAE,EAAC,MAAM,EAAC,EAAE,EAAE,OAAO,iBAAe,OAAO,CAAC,KAAK,YACzE,KAAK,GACD,EAET,GAAG,EAAE,GAAG,GACR,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef, ReactNode } from 'react';\n\nimport type { HeadingTag, OmitStrict, RefElement } from '../../types';\nimport { useTestIds, useUID } from '../../hooks';\nimport Text from '../Text';\nimport { withTestIds } from '../../utils';\n\nimport type { SelectionCardProps } from './SelectionCard.types';\nimport { getSelectionCardTestIds } from './SelectionCard.test-ids';\nimport SelectionCard from './SelectionCard';\n\nexport interface SelectionCardDisplayProps\n extends OmitStrict<SelectionCardProps, 'heading' | 'disabled'> {\n label: NonNullable<ReactNode>;\n /**\n * Uses specific heading tag for header.\n * @default h4\n */\n headingTag?: HeadingTag;\n}\n\nconst SelectionCardDisplay = forwardRef<\n RefElement<SelectionCardDisplayProps>,\n PropsWithoutRef<SelectionCardDisplayProps>\n>(function SelectionCardDisplay(props, ref) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n 'aria-label': ariaLabel,\n label,\n headingTag = 'h4',\n ...restProps\n } = props;\n const labelId = `${id}-label`;\n\n const testIds = useTestIds(testId, getSelectionCardTestIds);\n\n return (\n <SelectionCard\n {...restProps}\n testId={testIds}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabel ? undefined : labelId}\n heading={\n <Text variant={headingTag} as='span' id={labelId} data-testid={testIds.label}>\n {label}\n </Text>\n }\n ref={ref}\n />\n );\n});\n\nexport default withTestIds(SelectionCardDisplay, getSelectionCardTestIds);\n"]}
1
+ {"version":3,"file":"SelectionCardDisplay.js","sourceRoot":"","sources":["../../../src/components/SelectionCard/SelectionCardDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAInC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,M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,eAAe,WAAW,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef, ReactNode } from 'react';\n\nimport type { HeadingTag, OmitStrict, RefElement } from '../../types';\nimport { useTestIds, useUID } from '../../hooks';\nimport Text from '../Text';\nimport SummaryItem from '../SummaryItem';\nimport MetaList from '../MetaList';\nimport type { MetaListProps } from '../MetaList';\nimport { withTestIds } from '../../utils';\n\nimport type { SelectionCardProps } from './SelectionCard.types';\nimport { getSelectionCardTestIds } from './SelectionCard.test-ids';\nimport SelectionCard from './SelectionCard';\n\nexport interface SelectionCardDisplayProps\n extends OmitStrict<SelectionCardProps, 'heading' | 'disabled'> {\n label: NonNullable<ReactNode>;\n /** Metadata items displayed below the heading. */\n subheading?: MetaListProps['items'];\n /** Optional visual displayed before the heading. */\n visual?: ReactNode;\n /**\n * Uses specific heading tag for header.\n * @default h4\n */\n headingTag?: HeadingTag;\n}\n\nconst SelectionCardDisplay = forwardRef<\n RefElement<SelectionCardDisplayProps>,\n PropsWithoutRef<SelectionCardDisplayProps>\n>(function SelectionCardDisplay(props, ref) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n 'aria-label': ariaLabel,\n label,\n subheading,\n visual,\n headingTag = 'h4',\n ...restProps\n } = props;\n const labelId = `${id}-label`;\n\n const testIds = useTestIds(testId, getSelectionCardTestIds);\n\n return (\n <SelectionCard\n {...restProps}\n testId={testIds}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabel ? undefined : labelId}\n heading={\n <SummaryItem\n primary={\n <Text variant={headingTag} as='span' id={labelId} data-testid={testIds.label}>\n {label}\n </Text>\n }\n secondary={subheading?.length ? <MetaList items={subheading} /> : undefined}\n visual={visual}\n layout='stacked'\n />\n }\n ref={ref}\n />\n );\n});\n\nexport default withTestIds(SelectionCardDisplay, getSelectionCardTestIds);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-core",
3
- "version": "10.0.0-build.4.3",
3
+ "version": "10.0.0-build.4.5",
4
4
  "description": "Cosmos is a visual design system and UI component collection. Its goal is to empower application developers in their pursuit to create engaging and rewarding user experiences.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Pegasystems",