@helsenorge/designsystem-react 15.5.1 → 15.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/lib/CHANGELOG.md +19 -0
  2. package/lib/Checkbox.js +1 -1
  3. package/lib/Checkbox.js.map +1 -1
  4. package/lib/FormGroup.js +9 -2
  5. package/lib/FormGroup.js.map +1 -1
  6. package/lib/FormLayout.js +9 -1
  7. package/lib/FormLayout.js.map +1 -1
  8. package/lib/LazyIcon.js +5 -0
  9. package/lib/LazyIcon.js.map +1 -1
  10. package/lib/Toggle.js +176 -0
  11. package/lib/Toggle.js.map +1 -0
  12. package/lib/components/Close/styles.module.scss +2 -2
  13. package/lib/components/FormGroup/styles.module.scss +15 -3
  14. package/lib/components/FormGroup/styles.module.scss.d.ts +2 -0
  15. package/lib/components/FormLayout/styles.module.scss +9 -1
  16. package/lib/components/FormLayout/styles.module.scss.d.ts +2 -0
  17. package/lib/components/HelpPanel/HelpPanel.d.ts +2 -2
  18. package/lib/components/HelpPanel/index.js +49 -9
  19. package/lib/components/HelpPanel/index.js.map +1 -1
  20. package/lib/components/HelpPanel/styles.module.scss +66 -2
  21. package/lib/components/HelpPanel/styles.module.scss.d.ts +8 -0
  22. package/lib/components/HelpTeaser/HelpTeaser.d.ts +5 -2
  23. package/lib/components/HelpTeaser/index.js +59 -14
  24. package/lib/components/HelpTeaser/index.js.map +1 -1
  25. package/lib/components/HelpTeaser/styles.module.scss +105 -2
  26. package/lib/components/HelpTeaser/styles.module.scss.d.ts +6 -0
  27. package/lib/components/HighlightPanel/index.js +79 -1
  28. package/lib/components/HighlightPanel/index.js.map +1 -0
  29. package/lib/components/Icons/AdditionalIconInformation.d.ts +20 -0
  30. package/lib/components/Icons/AdditionalIconInformation.js +20 -0
  31. package/lib/components/Icons/AdditionalIconInformation.js.map +1 -1
  32. package/lib/components/Icons/ConsentDocument.d.ts +3 -0
  33. package/lib/components/Icons/ConsentDocument.js +53 -0
  34. package/lib/components/Icons/ConsentDocument.js.map +1 -0
  35. package/lib/components/Icons/HealthCarePersonnelSecurity.d.ts +3 -0
  36. package/lib/components/Icons/HealthCarePersonnelSecurity.js +65 -0
  37. package/lib/components/Icons/HealthCarePersonnelSecurity.js.map +1 -0
  38. package/lib/components/Icons/HistoryDocument.d.ts +3 -0
  39. package/lib/components/Icons/HistoryDocument.js +50 -0
  40. package/lib/components/Icons/HistoryDocument.js.map +1 -0
  41. package/lib/components/Icons/IconNames.d.ts +1 -1
  42. package/lib/components/Icons/IconNames.js +5 -0
  43. package/lib/components/Icons/IconNames.js.map +1 -1
  44. package/lib/components/Icons/PersonCommunication.d.ts +3 -0
  45. package/lib/components/Icons/PersonCommunication.js +69 -0
  46. package/lib/components/Icons/PersonCommunication.js.map +1 -0
  47. package/lib/components/Icons/PersonDocument.d.ts +3 -0
  48. package/lib/components/Icons/PersonDocument.js +65 -0
  49. package/lib/components/Icons/PersonDocument.js.map +1 -0
  50. package/lib/components/InfoTeaser/index.js +71 -1
  51. package/lib/components/InfoTeaser/index.js.map +1 -0
  52. package/lib/components/RadioButton/styles.module.scss +6 -6
  53. package/lib/components/Toggle/index.js +1 -175
  54. package/lib/resourceHelper2.js +22 -0
  55. package/lib/resourceHelper2.js.map +1 -0
  56. package/lib/utils/formSpacing.d.ts +3 -0
  57. package/lib/utils/formSpacing.js +16 -0
  58. package/lib/utils/formSpacing.js.map +1 -0
  59. package/package.json +1 -1
  60. package/lib/HighlightPanel.js +0 -80
  61. package/lib/HighlightPanel.js.map +0 -1
  62. package/lib/InfoTeaser.js +0 -89
  63. package/lib/InfoTeaser.js.map +0 -1
  64. package/lib/components/Toggle/index.js.map +0 -1
package/lib/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## [15.7.0](https://github.com/helsenorge/designsystem/compare/v15.6.0...v15.7.0) (2026-08-19)
2
+
3
+ ### Features
4
+
5
+ * ikoner for innstillinger ([86e28d9](https://github.com/helsenorge/designsystem/commit/86e28d950a40b9dd72fa63cbac8e09ad5ff79dd2)), closes [#383478](https://github.com/helsenorge/designsystem/issues/383478)
6
+
7
+ ## [15.6.0](https://github.com/helsenorge/designsystem/compare/v15.5.1...v15.6.0) (2026-08-18)
8
+
9
+ ### Features
10
+
11
+ * **helppanel:** ny variant subdued og spacing endringer ([ab758f9](https://github.com/helsenorge/designsystem/commit/ab758f9b0fe6cb6b5df4a1fd9e46a5b17095afef)), closes [#381355](https://github.com/helsenorge/designsystem/issues/381355)
12
+ * **helpteaser:** ny prop variant med subdued valg ([83ffba6](https://github.com/helsenorge/designsystem/commit/83ffba63fb1e0c67c84d9de416ca88b98dbcd9b1)), closes [#381365](https://github.com/helsenorge/designsystem/issues/381365)
13
+
14
+ ### Bug Fixes
15
+
16
+ * formgroup og formlayout spacing fikses ([31ea3ff](https://github.com/helsenorge/designsystem/commit/31ea3ff9e6250ae41cb59d1fae94452e5cbce5f7)), closes [#374103](https://github.com/helsenorge/designsystem/issues/374103)
17
+ * **close:** fokus outline 4px ([b51d0dd](https://github.com/helsenorge/designsystem/commit/b51d0ddb149ff7103dfe1d2f6a09ce80c00f723f)), closes [#379795](https://github.com/helsenorge/designsystem/issues/379795)
18
+ * **helppanel:** styling settes på riktig breakpoint ([103a337](https://github.com/helsenorge/designsystem/commit/103a337a36d5df5ebe4a5963328a060ff1e4ac5c)), closes [#381355](https://github.com/helsenorge/designsystem/issues/381355)
19
+
1
20
  ## [15.5.1](https://github.com/helsenorge/designsystem/compare/v15.5.0...v15.5.1) (2026-08-11)
2
21
 
3
22
  ### Bug Fixes
package/lib/Checkbox.js CHANGED
@@ -47,7 +47,7 @@ var Checkbox = (props) => {
47
47
  });
48
48
  if (checked !== checkedControlledState && typeof checked !== "undefined") {
49
49
  setCheckedControlledState(checked);
50
- if (typeof checked !== "undefined") setIsChecked(checked);
50
+ setIsChecked(checked);
51
51
  }
52
52
  const onChangeHandler = (e) => {
53
53
  if (onChange) onChange(e);
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","names":[],"sources":["../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport CheckboxMarker from './CheckboxMarker/CheckboxMarker';\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { getLabelText, renderLabelAsParent } from '../Label/utils';\n\nimport checkboxStyles from './styles.module.scss';\n\nexport interface CheckboxProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the checkbox - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** input id of the checkbox */\n inputId?: string;\n /** Changes the visuals of the checkbox */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the checkbox */\n size?: keyof typeof FormSize;\n /** Activates Error style for the checkbox - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref that is passed to the component */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nexport const Checkbox: React.FC<CheckboxProps> = props => {\n const {\n className,\n checked = false,\n disabled,\n label,\n inputId = uuid(),\n onColor = FormOnColor.onwhite,\n name = inputId,\n size,\n errorText,\n error = !!errorText,\n errorTextId: errorTextIdProp,\n errorWrapperClassName,\n value = getLabelText(label),\n testId,\n required,\n onChange,\n ref,\n } = props;\n\n const [checkedControlledState, setCheckedControlledState] = useState(checked);\n const [isChecked, setIsChecked] = useState(checked);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n const onWhite = onColor === FormOnColor.onwhite;\n const onGrey = onColor === FormOnColor.ongrey;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const onInvalid = error || onColor === FormOnColor.oninvalid;\n const onDark = onColor === FormOnColor.ondark;\n const large = size === FormSize.large;\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n\n const checkboxWrapperClasses = classNames(checkboxStyles['checkbox-wrapper'], {\n [checkboxStyles['checkbox-wrapper--large']]: large,\n });\n const checkboxLabelClasses = classNames(checkboxStyles['checkbox-label'], {\n [checkboxStyles['checkbox-label--disabled']]: disabled,\n [checkboxStyles['checkbox-label--on-dark']]: onDark,\n [checkboxStyles['checkbox-label--large']]: large,\n [checkboxStyles['checkbox-label__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__large--focus']]: large && isFocused,\n [checkboxStyles['checkbox-label__large--on-white']]: large && onWhite,\n [checkboxStyles['checkbox-label__large--on-grey']]: large && onGrey,\n [checkboxStyles['checkbox-label__large--on-blueberry']]: large && onBlueberry,\n [checkboxStyles['checkbox-label__large--on-invalid']]: large && onInvalid,\n [checkboxStyles['checkbox-label__large--disabled']]: large && disabled,\n });\n const checkboxClasses = classNames(checkboxStyles.checkbox, className);\n const labelTextClasses = classNames(checkboxStyles['checkbox-label__text'], {\n [checkboxStyles['checkbox-label__text__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__text__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox-label__text--on-dark']]: onDark,\n [checkboxStyles['checkbox-label__text--disabled']]: disabled,\n });\n\n if (checked !== checkedControlledState && typeof checked !== 'undefined') {\n setCheckedControlledState(checked);\n\n if (typeof checked !== 'undefined') {\n setIsChecked(checked);\n }\n }\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>): void => {\n if (onChange) {\n onChange(e);\n }\n\n setIsChecked(!isChecked);\n };\n\n const getLabelContent = (): React.ReactNode => {\n return (\n <>\n <span className={checkboxStyles['checkbox__marker-wrapper']}>\n <input\n id={inputId}\n name={name}\n className={checkboxClasses}\n type=\"checkbox\"\n checked={isChecked}\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n aria-invalid={error}\n required={required}\n onChange={onChangeHandler}\n />\n <CheckboxMarker checked={isChecked} disabled={disabled} error={error} onColor={onColor} size={size} />\n </span>\n </>\n );\n };\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Checkbox} className={checkboxWrapperClasses}>\n {renderLabelAsParent({\n label: label,\n children: getLabelContent(),\n inputId: inputId,\n onColor: onColor as FormOnColor,\n labelClassName: checkboxLabelClasses,\n labelTextClassName: labelTextClasses,\n sublabelWrapperClassName: checkboxStyles['checkbox-sublabel-wrapper'],\n large: large,\n afterLabelChildrenClassName: checkboxStyles['checkbox-afterlabelchildren-wrapper'],\n })}\n </div>\n </ErrorWrapper>\n );\n};\n\nexport default Checkbox;\n"],"mappings":";;;;;;;;;;;;;;AA+CA,IAAa,YAAoC,UAAS;CACxD,MAAM,EACJ,WACA,UAAU,OACV,UACA,OACA,UAAU,KAAK,GACf,UAAU,YAAY,SACtB,OAAO,SACP,MACA,WACA,QAAQ,CAAC,CAAC,WACV,aAAa,iBACb,uBACA,QAAQ,aAAa,KAAK,GAC1B,QACA,UACA,UACA,QACE;CAEJ,MAAM,CAAC,wBAAwB,6BAA6B,SAAS,OAAO;CAC5E,MAAM,CAAC,WAAW,gBAAgB,SAAS,OAAO;CAClD,MAAM,cAAc,kBAAkB,eAAe;CACrD,MAAM,UAAU,YAAY,YAAY;CACxC,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,cAAc,YAAY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vD,gBAAc;IACJ;IACV,UAAU;GACX,CAAA,GACD,oBAAC,gBAAD;IAAgB,SAAS;IAAqB;IAAiB;IAAgB;IAAe;GAAO,CAAA,CACjG;EACN,CAAA,EAAA,CAAA;CAEN;CAEA,OACE,oBAAC,sBAAD;EAAc,WAAW;EAAkC;EAAwB;EACjF,UAAA,oBAAC,OAAD;GAAK,eAAa;GAAQ,oBAAkB,YAAY;GAAU,WAAW;GAC1E,UAAA,oBAAoB;IACZ;IACP,UAAU,gBAAgB;IACjB;IACA;IACT,gBAAgB;IAChB,oBAAoB;IACpB,0BAA0B,eAAe;IAClC;IACP,6BAA6B,eAAe;GAC9C,CAAC;EACE,CAAA;CACO,CAAA;AAElB"}
1
+ {"version":3,"file":"Checkbox.js","names":[],"sources":["../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport CheckboxMarker from './CheckboxMarker/CheckboxMarker';\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { getLabelText, renderLabelAsParent } from '../Label/utils';\n\nimport checkboxStyles from './styles.module.scss';\n\nexport interface CheckboxProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the checkbox - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** input id of the checkbox */\n inputId?: string;\n /** Changes the visuals of the checkbox */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the checkbox */\n size?: keyof typeof FormSize;\n /** Activates Error style for the checkbox - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref that is passed to the component */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nexport const Checkbox: React.FC<CheckboxProps> = props => {\n const {\n className,\n checked = false,\n disabled,\n label,\n inputId = uuid(),\n onColor = FormOnColor.onwhite,\n name = inputId,\n size,\n errorText,\n error = !!errorText,\n errorTextId: errorTextIdProp,\n errorWrapperClassName,\n value = getLabelText(label),\n testId,\n required,\n onChange,\n ref,\n } = props;\n\n const [checkedControlledState, setCheckedControlledState] = useState(checked);\n const [isChecked, setIsChecked] = useState(checked);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n const onWhite = onColor === FormOnColor.onwhite;\n const onGrey = onColor === FormOnColor.ongrey;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const onInvalid = error || onColor === FormOnColor.oninvalid;\n const onDark = onColor === FormOnColor.ondark;\n const large = size === FormSize.large;\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n\n const checkboxWrapperClasses = classNames(checkboxStyles['checkbox-wrapper'], {\n [checkboxStyles['checkbox-wrapper--large']]: large,\n });\n const checkboxLabelClasses = classNames(checkboxStyles['checkbox-label'], {\n [checkboxStyles['checkbox-label--disabled']]: disabled,\n [checkboxStyles['checkbox-label--on-dark']]: onDark,\n [checkboxStyles['checkbox-label--large']]: large,\n [checkboxStyles['checkbox-label__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__large--focus']]: large && isFocused,\n [checkboxStyles['checkbox-label__large--on-white']]: large && onWhite,\n [checkboxStyles['checkbox-label__large--on-grey']]: large && onGrey,\n [checkboxStyles['checkbox-label__large--on-blueberry']]: large && onBlueberry,\n [checkboxStyles['checkbox-label__large--on-invalid']]: large && onInvalid,\n [checkboxStyles['checkbox-label__large--disabled']]: large && disabled,\n });\n const checkboxClasses = classNames(checkboxStyles.checkbox, className);\n const labelTextClasses = classNames(checkboxStyles['checkbox-label__text'], {\n [checkboxStyles['checkbox-label__text__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__text__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox-label__text--on-dark']]: onDark,\n [checkboxStyles['checkbox-label__text--disabled']]: disabled,\n });\n\n if (checked !== checkedControlledState && typeof checked !== 'undefined') {\n setCheckedControlledState(checked);\n setIsChecked(checked);\n }\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>): void => {\n if (onChange) {\n onChange(e);\n }\n\n setIsChecked(!isChecked);\n };\n\n const getLabelContent = (): React.ReactNode => {\n return (\n <>\n <span className={checkboxStyles['checkbox__marker-wrapper']}>\n <input\n id={inputId}\n name={name}\n className={checkboxClasses}\n type=\"checkbox\"\n checked={isChecked}\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n aria-invalid={error}\n required={required}\n onChange={onChangeHandler}\n />\n <CheckboxMarker checked={isChecked} disabled={disabled} error={error} onColor={onColor} size={size} />\n </span>\n </>\n );\n };\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Checkbox} className={checkboxWrapperClasses}>\n {renderLabelAsParent({\n label: label,\n children: getLabelContent(),\n inputId: inputId,\n onColor: onColor as FormOnColor,\n labelClassName: checkboxLabelClasses,\n labelTextClassName: labelTextClasses,\n sublabelWrapperClassName: checkboxStyles['checkbox-sublabel-wrapper'],\n large: large,\n afterLabelChildrenClassName: checkboxStyles['checkbox-afterlabelchildren-wrapper'],\n })}\n </div>\n </ErrorWrapper>\n );\n};\n\nexport default Checkbox;\n"],"mappings":";;;;;;;;;;;;;;AA+CA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I,YAAY,0BAA0B,OAAO,YAAY,aAAa;EACxE,0BAA0B,OAAO;EACjC,aAAa,OAAO;CACtB;CAEA,MAAM,mBAAmB,MAAiD;EACxE,IAAI,UACF,SAAS,CAAC;EAGZ,aAAa,CAAC,SAAS;CACzB;CAEA,MAAM,wBAAyC;EAC7C,OACE,oBAAA,UAAA,EAAA,UACE,qBAAC,QAAD;GAAM,WAAW,eAAe;GAAhC,UAAA,CACE,oBAAC,SAAD;IACE,IAAI;IACE;IACN,WAAW;IACX,MAAK;IACL,SAAS;IACC;IACH;IACP,KAAK;IACL,oBAAkB,mBAAmB,OAAO,WAAW;IACvD,gBAAc;IACJ;IACV,UAAU;GACX,CAAA,GACD,oBAAC,gBAAD;IAAgB,SAAS;IAAqB;IAAiB;IAAgB;IAAe;GAAO,CAAA,CACjG;EACN,CAAA,EAAA,CAAA;CAEN;CAEA,OACE,oBAAC,sBAAD;EAAc,WAAW;EAAkC;EAAwB;EACjF,UAAA,oBAAC,OAAD;GAAK,eAAa;GAAQ,oBAAkB,YAAY;GAAU,WAAW;GAC1E,UAAA,oBAAoB;IACZ;IACP,UAAU,gBAAgB;IACjB;IACA;IACT,gBAAgB;IAChB,oBAAoB;IACpB,0BAA0B,eAAe;IAClC;IACP,6BAA6B,eAAe;GAC9C,CAAC;EACE,CAAA;CACO,CAAA;AAElB"}
package/lib/FormGroup.js CHANGED
@@ -6,9 +6,10 @@ import { t as FormFieldTag_default } from "./FormFieldTag.js";
6
6
  import { t as Checkbox } from "./Checkbox.js";
7
7
  import Title_default from "./components/Title/index.js";
8
8
  import { t as Select_default } from "./Select.js";
9
+ import { t as RadioButton } from "./RadioButton.js";
10
+ import { hasSublabel, isCompactComponent } from "./utils/formSpacing.js";
9
11
  import { t as FormLayout_default } from "./FormLayout.js";
10
12
  import { t as Input } from "./Input.js";
11
- import { t as RadioButton } from "./RadioButton.js";
12
13
  import { t as Slider_default } from "./Slider.js";
13
14
  import { t as Textarea_default } from "./Textarea.js";
14
15
  import classNames from "classnames";
@@ -26,7 +27,13 @@ var FormGroup = (props) => {
26
27
  const titleClasses = classNames({ [formGroupStyles["form-group-wrapper__title--on-dark"]]: onDark && !error });
27
28
  const CustomTagForLegend = legendHtmlMarkup;
28
29
  const legendClasses = classNames(formGroupStyles["field-set__legend"], { [formGroupStyles["field-set__legend--on-dark"]]: onDark && !error }, legendClassName);
29
- const fieldsetClasses = classNames(formGroupStyles["field-set"], fieldsetClassName);
30
+ const childArray = React.Children.toArray(props.children);
31
+ const hasOnlyCompactComponents = childArray.length > 0 && childArray.every(isCompactComponent);
32
+ const hasCompactSublabel = hasOnlyCompactComponents && childArray.some(hasSublabel);
33
+ const fieldsetClasses = classNames(formGroupStyles["field-set"], {
34
+ [formGroupStyles["field-set--compact-gap"]]: hasOnlyCompactComponents && !hasCompactSublabel,
35
+ [formGroupStyles["field-set--compact-sublabel-gap"]]: hasCompactSublabel
36
+ }, fieldsetClassName);
30
37
  const mapFormComponent = (child, index) => {
31
38
  if (isComponent(child, FormLayout_default)) return React.cloneElement(child, {
32
39
  size,
@@ -1 +1 @@
1
- {"version":3,"file":"FormGroup.js","names":[],"sources":["../src/components/FormGroup/FormGroup.tsx"],"sourcesContent":["import React, { useId, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { CheckboxProps } from '../Checkbox/Checkbox';\nimport type { FormFieldTagProps } from '../FormFieldTag';\nimport type { FormLayoutProps } from '../FormLayout';\nimport type { InputProps } from '../Input/Input';\nimport type { RadioButtonProps } from '../RadioButton/RadioButton';\nimport type { SelectProps } from '../Select';\nimport type { SliderProps } from '../Slider';\nimport type { TextareaProps } from '../Textarea';\n\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { isComponent } from '../../utils/component';\nimport Checkbox from '../Checkbox/Checkbox';\nimport ErrorWrapper from '../ErrorWrapper';\nimport FormFieldTag from '../FormFieldTag';\nimport FormLayout from '../FormLayout';\nimport Input from '../Input/Input';\nimport RadioButton from '../RadioButton/RadioButton';\nimport Select from '../Select';\nimport Slider from '../Slider';\nimport Textarea from '../Textarea';\nimport Title, { type TitleTags } from '../Title';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport type FormGroupTags = 'fieldset' | 'div';\n\nexport interface FormGroupProps {\n /** Can be used as a replacement text for legend in cases where the group title already exists externally */\n ariaLabelledBy?: string;\n /** title for the the fieldset */\n title?: string;\n /** text placed in the legend tag of the fieldset */\n legend?: string;\n /** id for the legend tag */\n legendId?: string;\n /** Items in the FormGroup component */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds custom classes to the errorWrapper. */\n errorWrapperClassName?: string;\n /** Adds custom classes to the fieldset element. */\n fieldsetClassName?: string;\n /** Sets a tag that describes whether the form group is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the legend element. */\n legendClassName?: string;\n /** Changes the visuals of the formgroup */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Error message */\n error?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the data-testid attribute for the error-wrapper. */\n errorWrapperTestId?: string;\n /** Unique name for the child input element */\n name?: string;\n /** Unique name for the fieldset */\n fieldsetName?: string;\n /** Sets div instead of fieldset tag */\n htmlMarkup?: FormGroupTags;\n /** Markup for legend if formgroup htmlMarkup is div*/\n legendHtmlMarkup?: TitleTags;\n /** Markup for title */\n titleHtmlMarkup?: TitleTags;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n /** Ref passed to the error message element */\n errorMessageRef?: React.Ref<HTMLDivElement | null>;\n}\n\nexport const FormGroup: React.FC<FormGroupProps> = (props: FormGroupProps) => {\n const {\n ariaLabelledBy,\n className,\n errorTextId: errorTextIdProp,\n fieldsetClassName,\n formFieldTag,\n legendClassName,\n legendId,\n onColor = FormOnColor.onwhite,\n size = FormSize.medium,\n error,\n name,\n htmlMarkup = 'fieldset',\n renderError = true,\n errorWrapperClassName,\n errorWrapperTestId,\n errorMessageRef,\n legendHtmlMarkup = 'h5',\n titleHtmlMarkup = 'h4',\n } = props;\n const radioGroupId = useId();\n const [checkedRadioId, setCheckedRadioId] = useState<string>();\n const errorTextId = useIdWithFallback(errorTextIdProp);\n const onDark = onColor === FormOnColor.ondark;\n const formGroupWrapperClasses = classNames(formGroupStyles['form-group-wrapper'], className);\n const titleClasses = classNames({\n [formGroupStyles['form-group-wrapper__title--on-dark']]: onDark && !error,\n });\n\n const CustomTagForLegend = legendHtmlMarkup;\n\n const legendClasses = classNames(\n formGroupStyles['field-set__legend'],\n {\n [formGroupStyles['field-set__legend--on-dark']]: onDark && !error,\n },\n legendClassName\n );\n\n const fieldsetClasses = classNames(formGroupStyles['field-set'], fieldsetClassName);\n\n const mapFormComponent = (child: React.ReactNode, index: number): React.ReactNode => {\n if (isComponent<FormLayoutProps>(child, FormLayout)) {\n return React.cloneElement(child, {\n size,\n mapHelper: mapFormComponent,\n });\n } else if (isComponent<FormGroupProps>(child, FormGroup)) {\n return React.cloneElement(child, {\n onColor,\n size,\n error,\n renderError: false,\n errorTextId: errorTextId,\n });\n } else if (isComponent<CheckboxProps>(child, Checkbox)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n size,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<RadioButtonProps>(child, RadioButton)) {\n const radioId = typeof child.props.inputId === 'undefined' ? radioGroupId + index : child.props.inputId;\n const groupChecked =\n child.props.checked !== undefined ? child.props.checked : checkedRadioId !== undefined ? checkedRadioId === radioId : undefined;\n return React.cloneElement(child, {\n inputId: radioId,\n name: name ?? child.props.name,\n onColor,\n size,\n checked: groupChecked,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n setCheckedRadioId(event.target.id);\n if (child.props.onChange) child.props.onChange(event);\n },\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<InputProps>(child, Input)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n size,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<TextareaProps>(child, Textarea)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<SelectProps>(child, Select)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<SliderProps>(child, Slider)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n error: !!error,\n errorTextId: errorTextId,\n });\n }\n return child;\n };\n\n const formGroupContent = (): React.ReactNode => {\n return (\n <div>\n {htmlMarkup === 'div' && (\n <div className={fieldsetClasses}>\n {props.legend && (\n <>\n <CustomTagForLegend id={legendId} className={legendClasses}>\n {props.legend}\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n </CustomTagForLegend>\n </>\n )}\n {React.Children.map(props.children, mapFormComponent)}\n </div>\n )}\n {htmlMarkup === 'fieldset' && (\n <fieldset aria-labelledby={ariaLabelledBy} name={props.fieldsetName} className={fieldsetClasses}>\n {props.legend && (\n <>\n <legend id={legendId} className={legendClasses}>\n {props.legend}\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n </legend>\n </>\n )}\n {React.Children.map(props.children, mapFormComponent)}\n </fieldset>\n )}\n </div>\n );\n };\n\n return (\n <div data-testid={props.testId} data-analyticsid={AnalyticsId.FormGroup} className={formGroupWrapperClasses}>\n {props.title && (\n <Title\n className={titleClasses}\n htmlMarkup={titleHtmlMarkup}\n appearance={'title4'}\n margin={{ marginTop: 0, marginBottom: error ? 1 : 2 }}\n >\n {props.title}\n </Title>\n )}\n <ErrorWrapper\n className={errorWrapperClassName}\n errorText={error}\n testId={errorWrapperTestId}\n errorTextId={errorTextId}\n errorMessageRef={errorMessageRef}\n renderError={renderError}\n >\n {formGroupContent()}\n </ErrorWrapper>\n </div>\n );\n};\n\nFormGroup.displayName = 'FormGroup';\n\nexport default FormGroup;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgFA,IAAa,aAAuC,UAA0B;CAC5E,MAAM,EACJ,gBACA,WACA,aAAa,iBACb,mBACA,cACA,iBACA,UACA,UAAU,YAAY,SACtB,OAAO,SAAS,QAChB,OACA,MACA,aAAa,YACb,cAAc,MACd,uBACA,oBACA,iBACA,mBAAmB,MACnB,kBAAkB,SAChB;CACJ,MAAM,eAAe,MAAM;CAC3B,MAAM,CAAC,gBAAgB,qBAAqB,SAAiB;CAC7D,MAAM,cAAc,kBAAkB,eAAe;CACrD,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,0BAA0B,WAAW,gBAAgB,uBAAuB,SAAS;CAC3F,MAAM,eAAe,WAAW,GAC7B,gBAAgB,wCAAwC,UAAU,CAAC,MACtE,CAAC;CAED,MAAM,qBAAqB;CAE3B,MAAM,gBAAgB,WACpB,gBAAgB,sBAChB,GACG,gBAAgB,gCAAgC,UAAU,CAAC,MAC9D,GACA,eACF;CAEA,MAAM,kBAAkB,WAAW,gBAAgB,cAAc,iBAAiB;CAElF,MAAM,oBAAoB,OAAwB,UAAmC;EACnF,IAAI,YAA6B,OAAO,kBAAU,GAChD,OAAO,MAAM,aAAa,OAAO;GAC/B;GACA,WAAW;EACb,CAAC;OACI,IAAI,YAA4B,OAAO,SAAS,GACrD,OAAO,MAAM,aAAa,OAAO;GAC/B;GACA;GACA;GACA,aAAa;GACA;EACf,CAAC;OACI,IAAI,YAA2B,OAAO,QAAQ,GACnD,OAAO,MAAM,aAAa,OAAO;GAC/B,MAAM,QAAQ,MAAM,MAAM;GAC1B;GACA;GACA,OAAO,CAAC,CAAC;GACI;EACf,CAAC;OACI,IAAI,YAA8B,OAAO,WAAW,GAAG;GAC5D,MAAM,UAAU,OAAO,MAAM,MAAM,YAAY,cAAc,eAAe,QAAQ,MAAM,MAAM;GA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AAA,GAEH,MAAM,SAAS,IAAI,MAAM,UAAU,gBAAgB,CACjD;EAEN,CAAA,GAAA,eAAe,cACd,qBAAC,YAAD;GAAU,mBAAiB;GAAgB,MAAM,MAAM;GAAc,WAAW;GAAhF,UAAA,CACG,MAAM,UACL,oBAAA,UAAA,EAAA,UACE,qBAAC,UAAD;IAAQ,IAAI;IAAU,WAAW;IAAjC,UAAA,CACG,MAAM,QACN,gBAAgB,YAA+B,cAAc,oBAAY,KAAK,MAAM,aAAa,YAAY,CACxG;GACR,CAAA,EAAA,CAAA,GAEH,MAAM,SAAS,IAAI,MAAM,UAAU,gBAAgB,CAC5C;EAET,CAAA,CAAA,EAAA,CAAA;CAET;CAEA,OACE,qBAAC,OAAD;EAAK,eAAa,MAAM;EAAQ,oBAAkB,YAAY;EAAW,WAAW;EAApF,UAAA,CACG,MAAM,SACL,oBAAC,eAAD;GACE,WAAW;GACX,YAAY;GACZ,YAAY;GACZ,QAAQ;IAAE,WAAW;IAAG,cAAc,QAAQ,IAAI;GAAE;GAEnD,UAAA,MAAM;EACF,CAAA,GAET,oBAAC,sBAAD;GACE,WAAW;GACX,WAAW;GACX,QAAQ;GACK;GACI;GACJ;GAEZ,UAAA,iBAAiB;EACN,CAAA,CACX;;AAET;AAEA,UAAU,cAAc"}
1
+ {"version":3,"file":"FormGroup.js","names":[],"sources":["../src/components/FormGroup/FormGroup.tsx"],"sourcesContent":["import React, { useId, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { CheckboxProps } from '../Checkbox/Checkbox';\nimport type { FormFieldTagProps } from '../FormFieldTag';\nimport type { FormLayoutProps } from '../FormLayout';\nimport type { InputProps } from '../Input/Input';\nimport type { RadioButtonProps } from '../RadioButton/RadioButton';\nimport type { SelectProps } from '../Select';\nimport type { SliderProps } from '../Slider';\nimport type { TextareaProps } from '../Textarea';\n\nimport { AnalyticsId, FormOnColor, FormSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { isComponent } from '../../utils/component';\nimport { hasSublabel, isCompactComponent } from '../../utils/formSpacing';\nimport Checkbox from '../Checkbox/Checkbox';\nimport ErrorWrapper from '../ErrorWrapper';\nimport FormFieldTag from '../FormFieldTag';\nimport FormLayout from '../FormLayout';\nimport Input from '../Input/Input';\nimport RadioButton from '../RadioButton/RadioButton';\nimport Select from '../Select';\nimport Slider from '../Slider';\nimport Textarea from '../Textarea';\nimport Title, { type TitleTags } from '../Title';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport type FormGroupTags = 'fieldset' | 'div';\n\nexport interface FormGroupProps {\n /** Can be used as a replacement text for legend in cases where the group title already exists externally */\n ariaLabelledBy?: string;\n /** title for the the fieldset */\n title?: string;\n /** text placed in the legend tag of the fieldset */\n legend?: string;\n /** id for the legend tag */\n legendId?: string;\n /** Items in the FormGroup component */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds custom classes to the errorWrapper. */\n errorWrapperClassName?: string;\n /** Adds custom classes to the fieldset element. */\n fieldsetClassName?: string;\n /** Sets a tag that describes whether the form group is required or optional */\n formFieldTag?: React.ReactNode;\n /** Adds custom classes to the legend element. */\n legendClassName?: string;\n /** Changes the visuals of the formgroup */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Error message */\n error?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the data-testid attribute for the error-wrapper. */\n errorWrapperTestId?: string;\n /** Unique name for the child input element */\n name?: string;\n /** Unique name for the fieldset */\n fieldsetName?: string;\n /** Sets div instead of fieldset tag */\n htmlMarkup?: FormGroupTags;\n /** Markup for legend if formgroup htmlMarkup is div*/\n legendHtmlMarkup?: TitleTags;\n /** Markup for title */\n titleHtmlMarkup?: TitleTags;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n /** Ref passed to the error message element */\n errorMessageRef?: React.Ref<HTMLDivElement | null>;\n}\n\nexport const FormGroup: React.FC<FormGroupProps> = (props: FormGroupProps) => {\n const {\n ariaLabelledBy,\n className,\n errorTextId: errorTextIdProp,\n fieldsetClassName,\n formFieldTag,\n legendClassName,\n legendId,\n onColor = FormOnColor.onwhite,\n size = FormSize.medium,\n error,\n name,\n htmlMarkup = 'fieldset',\n renderError = true,\n errorWrapperClassName,\n errorWrapperTestId,\n errorMessageRef,\n legendHtmlMarkup = 'h5',\n titleHtmlMarkup = 'h4',\n } = props;\n const radioGroupId = useId();\n const [checkedRadioId, setCheckedRadioId] = useState<string>();\n const errorTextId = useIdWithFallback(errorTextIdProp);\n const onDark = onColor === FormOnColor.ondark;\n const formGroupWrapperClasses = classNames(formGroupStyles['form-group-wrapper'], className);\n const titleClasses = classNames({\n [formGroupStyles['form-group-wrapper__title--on-dark']]: onDark && !error,\n });\n\n const CustomTagForLegend = legendHtmlMarkup;\n\n const legendClasses = classNames(\n formGroupStyles['field-set__legend'],\n {\n [formGroupStyles['field-set__legend--on-dark']]: onDark && !error,\n },\n legendClassName\n );\n\n const childArray = React.Children.toArray(props.children);\n const hasOnlyCompactComponents = childArray.length > 0 && childArray.every(isCompactComponent);\n const hasCompactSublabel = hasOnlyCompactComponents && childArray.some(hasSublabel);\n const fieldsetClasses = classNames(\n formGroupStyles['field-set'],\n {\n [formGroupStyles['field-set--compact-gap']]: hasOnlyCompactComponents && !hasCompactSublabel,\n [formGroupStyles['field-set--compact-sublabel-gap']]: hasCompactSublabel,\n },\n fieldsetClassName\n );\n\n const mapFormComponent = (child: React.ReactNode, index: number): React.ReactNode => {\n if (isComponent<FormLayoutProps>(child, FormLayout)) {\n return React.cloneElement(child, {\n size,\n mapHelper: mapFormComponent,\n });\n } else if (isComponent<FormGroupProps>(child, FormGroup)) {\n return React.cloneElement(child, {\n onColor,\n size,\n error,\n renderError: false,\n errorTextId: errorTextId,\n });\n } else if (isComponent<CheckboxProps>(child, Checkbox)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n size,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<RadioButtonProps>(child, RadioButton)) {\n const radioId = typeof child.props.inputId === 'undefined' ? radioGroupId + index : child.props.inputId;\n const groupChecked =\n child.props.checked !== undefined ? child.props.checked : checkedRadioId !== undefined ? checkedRadioId === radioId : undefined;\n return React.cloneElement(child, {\n inputId: radioId,\n name: name ?? child.props.name,\n onColor,\n size,\n checked: groupChecked,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n setCheckedRadioId(event.target.id);\n if (child.props.onChange) child.props.onChange(event);\n },\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<InputProps>(child, Input)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n size,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<TextareaProps>(child, Textarea)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<SelectProps>(child, Select)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n onColor,\n error: !!error,\n errorTextId: errorTextId,\n });\n } else if (isComponent<SliderProps>(child, Slider)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n error: !!error,\n errorTextId: errorTextId,\n });\n }\n return child;\n };\n\n const formGroupContent = (): React.ReactNode => {\n return (\n <div>\n {htmlMarkup === 'div' && (\n <div className={fieldsetClasses}>\n {props.legend && (\n <>\n <CustomTagForLegend id={legendId} className={legendClasses}>\n {props.legend}\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n </CustomTagForLegend>\n </>\n )}\n {React.Children.map(props.children, mapFormComponent)}\n </div>\n )}\n {htmlMarkup === 'fieldset' && (\n <fieldset aria-labelledby={ariaLabelledBy} name={props.fieldsetName} className={fieldsetClasses}>\n {props.legend && (\n <>\n <legend id={legendId} className={legendClasses}>\n {props.legend}\n {formFieldTag && isComponent<FormFieldTagProps>(formFieldTag, FormFieldTag) && React.cloneElement(formFieldTag)}\n </legend>\n </>\n )}\n {React.Children.map(props.children, mapFormComponent)}\n </fieldset>\n )}\n </div>\n );\n };\n\n return (\n <div data-testid={props.testId} data-analyticsid={AnalyticsId.FormGroup} className={formGroupWrapperClasses}>\n {props.title && (\n <Title\n className={titleClasses}\n htmlMarkup={titleHtmlMarkup}\n appearance={'title4'}\n margin={{ marginTop: 0, marginBottom: error ? 1 : 2 }}\n >\n {props.title}\n </Title>\n )}\n <ErrorWrapper\n className={errorWrapperClassName}\n errorText={error}\n testId={errorWrapperTestId}\n errorTextId={errorTextId}\n errorMessageRef={errorMessageRef}\n renderError={renderError}\n >\n {formGroupContent()}\n </ErrorWrapper>\n </div>\n );\n};\n\nFormGroup.displayName = 'FormGroup';\n\nexport default FormGroup;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiFA,IAAa,aAAuC,UAA0B;CAC5E,MAAM,EACJ,gBACA,WACA,aAAa,iBACb,mBACA,cACA,iBACA,UACA,UAAU,YAAY,SACtB,OAAO,SAAS,QAChB,OACA,MACA,aAAa,YACb,cAAc,MACd,uBACA,oBACA,iBACA,mBAAmB,MACnB,kBAAkB,SAChB;CACJ,MAAM,eAAe,MAAM;CAC3B,MAAM,CAAC,gBAAgB,qBAAqB,SAAiB;CAC7D,MAAM,cAAc,kBAAkB,eAAe;CACrD,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,0BAA0B,WAAW,gBAAgB,uBAAuB,SAAS;CAC3F,MAAM,eAAe,WAAW,GAC7B,gBAAgB,wCAAwC,UAAU,CAAC,MACtE,CAAC;CAED,MAAM,qBAAqB;CAE3B,MAAM,gBAAgB,WACpB,gBAAgB,sBAChB,GACG,gBAAgB,gCAAgC,UAAU,CAAC,MAC9D,GACA,eACF;CAEA,MAAM,aAAa,MAAM,SAAS,QAAQ,MAAM,QAAQ;CACxD,MAAM,2BAA2B,WAAW,SAAS,KAAK,WAAW,MAAM,kBAAkB;CAC7F,MAAM,qBAAqB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WAAW;IAAG,cAAc,QAAQ,IAAI;GAAE;GAEnD,UAAA,MAAM;EACF,CAAA,GAET,oBAAC,sBAAD;GACE,WAAW;GACX,WAAW;GACX,QAAQ;GACK;GACI;GACJ;GAEZ,UAAA,iBAAiB;EACN,CAAA,CACX;;AAET;AAEA,UAAU,cAAc"}
package/lib/FormLayout.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AnalyticsId, FormSize } from "./constants.js";
2
+ import { hasSublabel, isCompactComponent } from "./utils/formSpacing.js";
2
3
  import classNames from "classnames";
3
4
  import React from "react";
4
5
  import { jsx } from "react/jsx-runtime";
@@ -17,7 +18,14 @@ var FormLayoutColumns = /* @__PURE__ */ function(FormLayoutColumns) {
17
18
  var FormLayout = (props) => {
18
19
  const { maxColumns: columns = FormLayoutColumns.one, colMinWidth = 300, size, className, mapHelper, ref } = props;
19
20
  const cssVariable = { "--min-col-width": `${colMinWidth}px` };
20
- const formLayoutContainerClasses = classNames(formGroupStyles["form-layout-container"], { [formGroupStyles["form-layout-container--large"]]: size === FormSize.large }, className);
21
+ const childArray = React.Children.toArray(props.children);
22
+ const hasOnlyCompactComponents = childArray.length > 0 && childArray.every(isCompactComponent);
23
+ const hasCompactSublabel = hasOnlyCompactComponents && childArray.some(hasSublabel);
24
+ const formLayoutContainerClasses = classNames(formGroupStyles["form-layout-container"], {
25
+ [formGroupStyles["form-layout-container--compact-gap"]]: hasOnlyCompactComponents && !hasCompactSublabel,
26
+ [formGroupStyles["form-layout-container--compact-sublabel-gap"]]: hasCompactSublabel,
27
+ [formGroupStyles["form-layout-container--large"]]: size === FormSize.large
28
+ }, className);
21
29
  const formLayoutChildClasses = classNames(formGroupStyles["form-layout-child"], {
22
30
  [formGroupStyles["form-layout-child--two"]]: columns === FormLayoutColumns.two,
23
31
  [formGroupStyles["form-layout-child--three"]]: columns === FormLayoutColumns.three,
@@ -1 +1 @@
1
- {"version":3,"file":"FormLayout.js","names":[],"sources":["../src/components/FormLayout/constants.ts","../src/components/FormLayout/FormLayout.tsx","../src/components/FormLayout/index.ts"],"sourcesContent":["export enum FormLayoutColumns {\n one = 'one',\n two = 'two',\n three = 'three',\n four = 'four',\n five = 'five',\n}\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { FormLayoutColumns } from './constants';\nimport { AnalyticsId, FormSize } from '../../constants';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport interface FormLayoutProps {\n /** The max number of columns that will exist if space is available */\n maxColumns?: keyof typeof FormLayoutColumns;\n /** Sets the minimum width for the columns in pixels - this determines how many will fit on a row */\n colMinWidth?: number;\n /** Items in the FormLayout component */\n children?: React.ReactNode;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Function that helps map the form children */\n mapHelper?: (child: React.ReactNode, index: number) => React.ReactNode;\n /** Ref passed to the root div */\n ref?: React.Ref<HTMLDivElement | null>;\n}\n\nexport const FormLayout: React.FC<FormLayoutProps> = (props: FormLayoutProps) => {\n const { maxColumns: columns = FormLayoutColumns.one, colMinWidth = 300, size, className, mapHelper, ref } = props;\n\n const cssVariable = { '--min-col-width': `${colMinWidth}px` } as React.CSSProperties;\n const formLayoutContainerClasses = classNames(\n formGroupStyles['form-layout-container'],\n {\n [formGroupStyles['form-layout-container--large']]: size === FormSize.large,\n },\n className\n );\n const formLayoutChildClasses = classNames(formGroupStyles['form-layout-child'], {\n [formGroupStyles['form-layout-child--two']]: columns === FormLayoutColumns.two,\n [formGroupStyles['form-layout-child--three']]: columns === FormLayoutColumns.three,\n [formGroupStyles['form-layout-child--four']]: columns === FormLayoutColumns.four,\n [formGroupStyles['form-layout-child--five']]: columns === FormLayoutColumns.five,\n });\n\n return (\n <div\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.FormLayout}\n style={cssVariable}\n className={formLayoutContainerClasses}\n ref={ref}\n >\n {React.Children.map(props.children, (child: React.ReactNode, index: number) => {\n return <div className={formLayoutChildClasses}>{mapHelper ? mapHelper(child, index) : child}</div>;\n })}\n </div>\n );\n};\n\nFormLayout.displayName = 'FormLayout';\n\nexport default FormLayout;\n","import FormLayout from './FormLayout';\nexport { FormLayoutColumns } from './constants';\nexport * from './FormLayout';\nexport default FormLayout;\n"],"mappings":";;;;;;AAAA,IAAY,oBAAL,yBAAA,mBAAA;CACL,kBAAA,SAAA;CACA,kBAAA,SAAA;CACA,kBAAA,WAAA;CACA,kBAAA,UAAA;CACA,kBAAA,UAAA;;AACF,EAAA,CAAA,CAAA;;;ACsBA,IAAa,cAAyC,UAA2B;CAC/E,MAAM,EAAE,YAAY,UAAU,kBAAkB,KAAK,cAAc,KAAK,MAAM,WAAW,WAAW,QAAQ;CAE5G,MAAM,cAAc,EAAE,mBAAmB,GAAG,YAAY,IAAI;CAC5D,MAAM,6BAA6B,WACjC,gBAAgB,0BAChB,GACG,gBAAgB,kCAAkC,SAAS,SAAS,MACvE,GACA,SACF;CACA,MAAM,yBAAyB,WAAW,gBAAgB,sBAAsB;GAC7E,gBAAgB,4BAA4B,YAAY,kBAAkB;GAC1E,gBAAgB,8BAA8B,YAAY,kBAAkB;GAC5E,gBAAgB,6BAA6B,YAAY,kBAAkB;GAC3E,gBAAgB,6BAA6B,YAAY,kBAAkB;CAC9E,CAAC;CAED,OACE,oBAAC,OAAD;EACE,eAAa,MAAM;EACnB,oBAAkB,YAAY;EAC9B,OAAO;EACP,WAAW;EACN;EAEJ,UAAA,MAAM,SAAS,IAAI,MAAM,WAAW,OAAwB,UAAkB;GAC7E,OAAO,oBAAC,OAAD;IAAK,WAAW;IAAyB,UAAA,YAAY,UAAU,OAAO,KAAK,IAAI;GAAW,CAAA;EACnG,CAAC;CACE,CAAA;AAET;AAEA,WAAW,cAAc;;;AC1DzB,IAAA,qBAAe"}
1
+ {"version":3,"file":"FormLayout.js","names":[],"sources":["../src/components/FormLayout/constants.ts","../src/components/FormLayout/FormLayout.tsx","../src/components/FormLayout/index.ts"],"sourcesContent":["export enum FormLayoutColumns {\n one = 'one',\n two = 'two',\n three = 'three',\n four = 'four',\n five = 'five',\n}\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { FormLayoutColumns } from './constants';\nimport { AnalyticsId, FormSize } from '../../constants';\nimport { hasSublabel, isCompactComponent } from '../../utils/formSpacing';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport interface FormLayoutProps {\n /** The max number of columns that will exist if space is available */\n maxColumns?: keyof typeof FormLayoutColumns;\n /** Sets the minimum width for the columns in pixels - this determines how many will fit on a row */\n colMinWidth?: number;\n /** Items in the FormLayout component */\n children?: React.ReactNode;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Function that helps map the form children */\n mapHelper?: (child: React.ReactNode, index: number) => React.ReactNode;\n /** Ref passed to the root div */\n ref?: React.Ref<HTMLDivElement | null>;\n}\n\nexport const FormLayout: React.FC<FormLayoutProps> = (props: FormLayoutProps) => {\n const { maxColumns: columns = FormLayoutColumns.one, colMinWidth = 300, size, className, mapHelper, ref } = props;\n\n const cssVariable = { '--min-col-width': `${colMinWidth}px` } as React.CSSProperties;\n const childArray = React.Children.toArray(props.children);\n const hasOnlyCompactComponents = childArray.length > 0 && childArray.every(isCompactComponent);\n const hasCompactSublabel = hasOnlyCompactComponents && childArray.some(hasSublabel);\n const formLayoutContainerClasses = classNames(\n formGroupStyles['form-layout-container'],\n {\n [formGroupStyles['form-layout-container--compact-gap']]: hasOnlyCompactComponents && !hasCompactSublabel,\n [formGroupStyles['form-layout-container--compact-sublabel-gap']]: hasCompactSublabel,\n [formGroupStyles['form-layout-container--large']]: size === FormSize.large,\n },\n className\n );\n const formLayoutChildClasses = classNames(formGroupStyles['form-layout-child'], {\n [formGroupStyles['form-layout-child--two']]: columns === FormLayoutColumns.two,\n [formGroupStyles['form-layout-child--three']]: columns === FormLayoutColumns.three,\n [formGroupStyles['form-layout-child--four']]: columns === FormLayoutColumns.four,\n [formGroupStyles['form-layout-child--five']]: columns === FormLayoutColumns.five,\n });\n\n return (\n <div\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.FormLayout}\n style={cssVariable}\n className={formLayoutContainerClasses}\n ref={ref}\n >\n {React.Children.map(props.children, (child: React.ReactNode, index: number) => {\n return <div className={formLayoutChildClasses}>{mapHelper ? mapHelper(child, index) : child}</div>;\n })}\n </div>\n );\n};\n\nFormLayout.displayName = 'FormLayout';\n\nexport default FormLayout;\n","import FormLayout from './FormLayout';\nexport { FormLayoutColumns } from './constants';\nexport * from './FormLayout';\nexport default FormLayout;\n"],"mappings":";;;;;;;AAAA,IAAY,oBAAL,yBAAA,mBAAA;CACL,kBAAA,SAAA;CACA,kBAAA,SAAA;CACA,kBAAA,WAAA;CACA,kBAAA,UAAA;CACA,kBAAA,UAAA;;AACF,EAAA,CAAA,CAAA;;;ACuBA,IAAa,cAAyC,UAA2B;CAC/E,MAAM,EAAE,YAAY,UAAU,kBAAkB,KAAK,cAAc,KAAK,MAAM,WAAW,WAAW,QAAQ;CAE5G,MAAM,cAAc,EAAE,mBAAmB,GAAG,YAAY,IAAI;CAC5D,MAAM,aAAa,MAAM,SAAS,QAAQ,MAAM,QAAQ;CACxD,MAAM,2BAA2B,WAAW,SAAS,KAAK,WAAW,MAAM,kBAAkB;CAC7F,MAAM,qBAAqB,4BAA4B,WAAW,KAAK,WAAW;CAClF,MAAM,6BAA6B,WACjC,gBAAgB,0BAChB;GACG,gBAAgB,wCAAwC,4BAA4B,CAAC;GACrF,gBAAgB,iDAAiD;GACjE,gBAAgB,kCAAkC,SAAS,SAAS;CACvE,GACA,SACF;CACA,MAAM,yBAAyB,WAAW,gBAAgB,sBAAsB;GAC7E,gBAAgB,4BAA4B,YAAY,kBAAkB;GAC1E,gBAAgB,8BAA8B,YAAY,kBAAkB;GAC5E,gBAAgB,6BAA6B,YAAY,kBAAkB;GAC3E,gBAAgB,6BAA6B,YAAY,kBAAkB;CAC9E,CAAC;CAED,OACE,oBAAC,OAAD;EACE,eAAa,MAAM;EACnB,oBAAkB,YAAY;EAC9B,OAAO;EACP,WAAW;EACN;EAEJ,UAAA,MAAM,SAAS,IAAI,MAAM,WAAW,OAAwB,UAAkB;GAC7E,OAAO,oBAAC,OAAD;IAAK,WAAW;IAAyB,UAAA,YAAY,UAAU,OAAO,KAAK,IAAI;GAAW,CAAA;EACnG,CAAC;CACE,CAAA;AAET;AAEA,WAAW,cAAc;;;AChEzB,IAAA,qBAAe"}
package/lib/LazyIcon.js CHANGED
@@ -67,6 +67,7 @@ var LazyIcon = ({ iconName, size = IconSize.Small, ...rest }) => {
67
67
  "../Icons/ChildPlaying.tsx": () => import("./components/Icons/ChildPlaying.js"),
68
68
  "../Icons/Cigarette.tsx": () => import("./components/Icons/Cigarette.js"),
69
69
  "../Icons/Coins.tsx": () => import("./components/Icons/Coins.js"),
70
+ "../Icons/ConsentDocument.tsx": () => import("./components/Icons/ConsentDocument.js"),
70
71
  "../Icons/Contacts.tsx": () => import("./components/Icons/Contacts.js"),
71
72
  "../Icons/Copy.tsx": () => import("./components/Icons/Copy.js"),
72
73
  "../Icons/CoronaCertificate.tsx": () => import("./components/Icons/CoronaCertificate.js"),
@@ -160,6 +161,7 @@ var LazyIcon = ({ iconName, size = IconSize.Small, ...rest }) => {
160
161
  "../Icons/HandWaving.tsx": () => import("./components/Icons/HandWaving.js"),
161
162
  "../Icons/HandWithDisease.tsx": () => import("./components/Icons/HandWithDisease.js"),
162
163
  "../Icons/HandsAndHeart.tsx": () => import("./components/Icons/HandsAndHeart.js"),
164
+ "../Icons/HealthCarePersonnelSecurity.tsx": () => import("./components/Icons/HealthCarePersonnelSecurity.js"),
163
165
  "../Icons/HealthClinic.tsx": () => import("./components/Icons/HealthClinic.js"),
164
166
  "../Icons/HealthMeasurements.tsx": () => import("./components/Icons/HealthMeasurements.js"),
165
167
  "../Icons/HealthWarning.tsx": () => import("./components/Icons/HealthWarning.js"),
@@ -174,6 +176,7 @@ var LazyIcon = ({ iconName, size = IconSize.Small, ...rest }) => {
174
176
  "../Icons/Hiker.tsx": () => import("./components/Icons/Hiker.js"),
175
177
  "../Icons/Hipprosthesis.tsx": () => import("./components/Icons/Hipprosthesis.js"),
176
178
  "../Icons/History.tsx": () => import("./components/Icons/History.js"),
179
+ "../Icons/HistoryDocument.tsx": () => import("./components/Icons/HistoryDocument.js"),
177
180
  "../Icons/HivAndAids.tsx": () => import("./components/Icons/HivAndAids.js"),
178
181
  "../Icons/Home.tsx": () => import("./components/Icons/Home.js"),
179
182
  "../Icons/HomeFill.tsx": () => import("./components/Icons/HomeFill.js"),
@@ -242,6 +245,8 @@ var LazyIcon = ({ iconName, size = IconSize.Small, ...rest }) => {
242
245
  "../Icons/Person.tsx": () => import("./components/Icons/Person.js"),
243
246
  "../Icons/PersonAndPatient.tsx": () => import("./components/Icons/PersonAndPatient.js"),
244
247
  "../Icons/PersonCancel.tsx": () => import("./components/Icons/PersonCancel.js"),
248
+ "../Icons/PersonCommunication.tsx": () => import("./components/Icons/PersonCommunication.js"),
249
+ "../Icons/PersonDocument.tsx": () => import("./components/Icons/PersonDocument.js"),
245
250
  "../Icons/PersonInXRayMachine.tsx": () => import("./components/Icons/PersonInXRayMachine.js"),
246
251
  "../Icons/PersonOverweight.tsx": () => import("./components/Icons/PersonOverweight.js"),
247
252
  "../Icons/PersonRelaxing.tsx": () => import("./components/Icons/PersonRelaxing.js"),
@@ -1 +1 @@
1
- {"version":3,"file":"LazyIcon.js","names":[],"sources":["../src/components/LazyIcon/LazyIcon.tsx","../src/components/LazyIcon/utils.ts","../src/components/LazyIcon/index.ts"],"sourcesContent":["import { lazy, Suspense, useMemo } from 'react';\n\nimport type { BaseIconProps, SvgIcon } from '../Icon';\nimport type { IconName } from '../Icons/IconNames';\n\nimport ErrorBoundary from './ErrorBoundary';\nimport { useIsServerSide } from '../../hooks/useIsServerSide';\nimport Icon, { IconSize } from '../Icon';\n\nexport interface LazyIconProps extends BaseIconProps {\n // Navnet på ikonet som skal vises. Tilsvarer filnavnet til ikonet i Icons-mappen\n iconName: IconName;\n}\n\nexport const LazyIcon: React.FC<LazyIconProps> = ({ iconName, size = IconSize.Small, ...rest }) => {\n const lazyLoadIcon = (iconName: IconName): React.LazyExoticComponent<SvgIcon> => lazy<SvgIcon>(() => import(`../Icons/${iconName}.tsx`));\n\n const icon = useMemo(() => lazyLoadIcon(iconName), [iconName]);\n const isServerSide = useIsServerSide();\n\n if (isServerSide) {\n return null;\n }\n\n const fallback = (\n <svg\n data-testid={'fallback'}\n role={'presentation'}\n focusable={false}\n aria-hidden={true}\n viewBox=\"0 0 48 48\"\n style={{ minWidth: size, minHeight: size }}\n width={size}\n height={size}\n />\n );\n\n return (\n <ErrorBoundary fallback={fallback} reset={iconName}>\n <Suspense fallback={fallback}>\n <Icon svgIcon={icon} size={size} {...rest} />\n </Suspense>\n </ErrorBoundary>\n );\n};\n\nexport default LazyIcon;\n","/** @deprecated Use the useIsServerSide hook instead */\nexport const isServerSide = (): boolean => typeof document === 'undefined';\n","import LazyIcon from './LazyIcon';\nexport * from './LazyIcon';\nexport * from './utils';\nexport default LazyIcon;\n"],"mappings":";;;;;;;AAcA,IAAa,YAAqC,EAAE,UAAU,OAAO,SAAS,OAAO,GAAG,WAAW;CACjG,MAAM,gBAAgB,aAA2D,WAAoB,wCAAA,uBAAA,OAAA;EAAA,uCAAA,OAAA;EAAA,sCAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,oCAAA,OAAA;EAAA,sCAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,8BAAA,OAAA;EAAA,4BAAA,OAAA;EAAA,8BAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,gCAAA,OAAA;EAAA,gCAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,8BAAA,OAAA;EAAA,mCAAA,OAAA;EAAA,wCAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,0BAAA,OAAA;EAAA,6BAAA,OAAA;EAAA,0CAAA,O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AAA;EAAA,8BAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,uCAAA,OAAA;EAAA,6BAAA,OAAA;EAAA,mCAAA,OAAA;EAAA,mCAAA,OAAA;EAAA,wBAAA,OAAA;EAAA,+BAAA,OAAA;EAAA,8BAAA,OAAA;EAAA,8BAAA,OAAA;EAAA,2BAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,kCAAA,OAAA;CAAA,CAAA,GAAA,YAAA,SAAA,OAAA,CAAA,CAAkC;CAEvI,MAAM,OAAO,cAAc,aAAa,QAAQ,GAAG,CAAC,QAAQ,CAAC;CAG7D,IAFqB,gBAEjB,GACF,OAAO;CAGT,MAAM,WACJ,oBAAC,OAAD;EACE,eAAa;EACb,MAAM;EACN,WAAW;EACX,eAAa;EACb,SAAQ;EACR,OAAO;GAAE,UAAU;GAAM,WAAW;EAAK;EACzC,OAAO;EACP,QAAQ;CACT,CAAA;CAGH,OACE,oBAAC,eAAD;EAAyB;EAAU,OAAO;EACxC,UAAA,oBAAC,UAAD;GAAoB;GAClB,UAAA,oBAAC,cAAD;IAAM,SAAS;IAAY;IAAM,GAAI;GAAO,CAAA;EACpC,CAAA;CACG,CAAA;AAEnB;;;;AC3CA,IAAa,qBAA8B,OAAO,aAAa;;;ACE/D,IAAA,mBAAe"}
1
+ {"version":3,"file":"LazyIcon.js","names":[],"sources":["../src/components/LazyIcon/LazyIcon.tsx","../src/components/LazyIcon/utils.ts","../src/components/LazyIcon/index.ts"],"sourcesContent":["import { lazy, Suspense, useMemo } from 'react';\n\nimport type { BaseIconProps, SvgIcon } from '../Icon';\nimport type { IconName } from '../Icons/IconNames';\n\nimport ErrorBoundary from './ErrorBoundary';\nimport { useIsServerSide } from '../../hooks/useIsServerSide';\nimport Icon, { IconSize } from '../Icon';\n\nexport interface LazyIconProps extends BaseIconProps {\n // Navnet på ikonet som skal vises. Tilsvarer filnavnet til ikonet i Icons-mappen\n iconName: IconName;\n}\n\nexport const LazyIcon: React.FC<LazyIconProps> = ({ iconName, size = IconSize.Small, ...rest }) => {\n const lazyLoadIcon = (iconName: IconName): React.LazyExoticComponent<SvgIcon> => lazy<SvgIcon>(() => import(`../Icons/${iconName}.tsx`));\n\n const icon = useMemo(() => lazyLoadIcon(iconName), [iconName]);\n const isServerSide = useIsServerSide();\n\n if (isServerSide) {\n return null;\n }\n\n const fallback = (\n <svg\n data-testid={'fallback'}\n role={'presentation'}\n focusable={false}\n aria-hidden={true}\n viewBox=\"0 0 48 48\"\n style={{ minWidth: size, minHeight: size }}\n width={size}\n height={size}\n />\n );\n\n return (\n <ErrorBoundary fallback={fallback} reset={iconName}>\n <Suspense fallback={fallback}>\n <Icon svgIcon={icon} size={size} {...rest} />\n </Suspense>\n </ErrorBoundary>\n );\n};\n\nexport default LazyIcon;\n","/** @deprecated Use the useIsServerSide hook instead */\nexport const isServerSide = (): boolean => typeof document === 'undefined';\n","import LazyIcon from './LazyIcon';\nexport * from './LazyIcon';\nexport * from './utils';\nexport default LazyIcon;\n"],"mappings":";;;;;;;AAcA,IAAa,YAAqC,EAAE,UAAU,OAAO,SAAS,OAAO,GAAG,WAAW;CACjG,MAAM,gBAAgB,aAA2D,WAAoB,wCAAA,uBAAA,OAAA;EAAA,uCAAA,OAAA;EAAA,sCAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,oCAAA,OAAA;EAAA,sCAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,8BAAA,OAAA;EAAA,4BAAA,OAAA;EAAA,8BAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,gCAAA,OAAA;EAAA,gCAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,8BAAA,OAAA;EAAA,mCAAA,OAAA;EAAA,wCAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,0BAAA,OAAA;EAAA,6BAAA,OAAA;EAAA,0CAAA,OAAA;EAAA,2BAAA,OAAA;EAAA,8BAAA,OAAA;EAAA,mCAAA,OAAA;EAAA,2BAAA,OAAA;EAAA,2BAAA,OAAA;EAAA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,8BAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,uCAAA,OAAA;EAAA,6BAAA,OAAA;EAAA,mCAAA,OAAA;EAAA,mCAAA,OAAA;EAAA,wBAAA,OAAA;EAAA,+BAAA,OAAA;EAAA,8BAAA,OAAA;EAAA,8BAAA,OAAA;EAAA,2BAAA,OAAA;EAAA,iCAAA,OAAA;EAAA,kCAAA,OAAA;CAAA,CAAA,GAAA,YAAA,SAAA,OAAA,CAAA,CAAkC;CAEvI,MAAM,OAAO,cAAc,aAAa,QAAQ,GAAG,CAAC,QAAQ,CAAC;CAG7D,IAFqB,gBAEjB,GACF,OAAO;CAGT,MAAM,WACJ,oBAAC,OAAD;EACE,eAAa;EACb,MAAM;EACN,WAAW;EACX,eAAa;EACb,SAAQ;EACR,OAAO;GAAE,UAAU;GAAM,WAAW;EAAK;EACzC,OAAO;EACP,QAAQ;CACT,CAAA;CAGH,OACE,oBAAC,eAAD;EAAyB;EAAU,OAAO;EACxC,UAAA,oBAAC,UAAD;GAAoB;GAClB,UAAA,oBAAC,cAAD;IAAM,SAAS;IAAY;IAAM,GAAI;GAAO,CAAA;EACpC,CAAA;CACG,CAAA;AAEnB;;;;AC3CA,IAAa,qBAA8B,OAAO,aAAa;;;ACE/D,IAAA,mBAAe"}
package/lib/Toggle.js ADDED
@@ -0,0 +1,176 @@
1
+ import { AnalyticsId } from "./constants.js";
2
+ import { usePseudoClasses } from "./hooks/usePseudoClasses.js";
3
+ import classNames from "classnames";
4
+ import React, { useEffect, useId, useState } from "react";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { useAnimate } from "motion/react";
7
+ import styles from "./components/Toggle/styles.module.scss";
8
+ //#region src/components/Toggle/constants.ts
9
+ var TogglePosition = /* @__PURE__ */ function(TogglePosition) {
10
+ TogglePosition["left"] = "left";
11
+ TogglePosition["right"] = "right";
12
+ return TogglePosition;
13
+ }({});
14
+ var ToggleOnColor = /* @__PURE__ */ function(ToggleOnColor) {
15
+ ToggleOnColor["onwhite"] = "onwhite";
16
+ ToggleOnColor["onneutral"] = "onneutral";
17
+ ToggleOnColor["onblueberry"] = "onblueberry";
18
+ return ToggleOnColor;
19
+ }({});
20
+ //#endregion
21
+ //#region src/components/Toggle/Toggle.tsx
22
+ var Toggle = ({ checked = false, disabled, label, onChange, onColor = ToggleOnColor.onwhite, statusText, subLabel, togglePosition = TogglePosition.left, testId }) => {
23
+ const [checkedControlledState, setCheckedControlledState] = useState(checked);
24
+ const [checkedState, setCheckedState] = useState(checked);
25
+ const [showToggleAnimation, setShowToggleAnimation] = useState(false);
26
+ const [scope, animate] = useAnimate();
27
+ const baseId = useId();
28
+ const toggleId = "toggle-" + baseId;
29
+ const inputId = "input-" + baseId;
30
+ const labelId = "label-" + baseId;
31
+ const subLabelId = "sublabel-" + baseId;
32
+ const toggleRef = React.useRef(null);
33
+ const toggleDotRef = React.useRef(null);
34
+ const { refObject, isHovered, isActive } = usePseudoClasses(scope);
35
+ const showHoveredStyling = isHovered && !showToggleAnimation;
36
+ const isOnWhite = onColor === ToggleOnColor.onwhite;
37
+ const animationDuration = disabled ? 0 : .2;
38
+ const dotBackgroundColor = disabled ? "var(--color-disabled-graphics)" : checkedState ? "var(--color-action-graphics-ondark)" : "var(--core-color-neutral-700)";
39
+ if (checked !== checkedControlledState && typeof checked !== "undefined") {
40
+ setCheckedControlledState(checked);
41
+ setCheckedState(checked);
42
+ }
43
+ const getBackgroundColor = () => {
44
+ if (disabled) return "transparent";
45
+ else if (checkedState && isActive) return "var(--core-color-blueberry-800)";
46
+ else if (checkedState) return showHoveredStyling ? "var(--color-action-graphics-onlight-hover)" : "var(--color-action-graphics-onlight)";
47
+ else if (isOnWhite && isActive) return "var(--core-color-neutral-400)";
48
+ else if (isOnWhite) return showHoveredStyling ? "var(--core-color-neutral-200)" : "var(--core-color-neutral-50)";
49
+ else if (isActive) return "var(--core-color-neutral-200)";
50
+ else return showHoveredStyling ? "var(--core-color-neutral-50)" : "var(--core-color-white)";
51
+ };
52
+ useEffect(() => {
53
+ if (showToggleAnimation) {
54
+ const timer = setTimeout(() => setShowToggleAnimation(false), 300);
55
+ return () => clearTimeout(timer);
56
+ }
57
+ }, [showToggleAnimation]);
58
+ useEffect(() => {
59
+ if (!toggleRef.current || !toggleDotRef.current) return;
60
+ animate(toggleRef.current, { background: getBackgroundColor() }, {
61
+ duration: animationDuration,
62
+ ease: "easeInOut"
63
+ });
64
+ animate(toggleDotRef.current, { background: dotBackgroundColor }, {
65
+ duration: animationDuration,
66
+ ease: "easeInOut"
67
+ });
68
+ animate(toggleDotRef.current, { x: checkedState ? 16 : 0 }, {
69
+ duration: animationDuration,
70
+ ease: "easeInOut"
71
+ });
72
+ animate("svg", { opacity: checkedState ? 1 : 0 }, {
73
+ duration: animationDuration,
74
+ ease: "easeInOut"
75
+ });
76
+ }, [
77
+ checkedState,
78
+ showHoveredStyling,
79
+ isActive,
80
+ disabled
81
+ ]);
82
+ const handleChange = (event) => {
83
+ setCheckedState(event.target.checked);
84
+ setShowToggleAnimation(true);
85
+ onChange?.(event);
86
+ };
87
+ const toggleContainerClassNames = classNames(styles["toggle-container"], {
88
+ [styles["toggle-container--position-right"]]: togglePosition === TogglePosition.right,
89
+ [styles["toggle-container--with-status"]]: statusText !== void 0 && statusText !== null,
90
+ [styles["toggle-container--disabled"]]: disabled
91
+ });
92
+ const subLabelClassNames = classNames(styles["toggle-container__sublabel"]);
93
+ const statusTextClassNames = classNames(styles["toggle-container__status"], { [styles["toggle-container__status--checked"]]: checkedState });
94
+ const toggleClassNames = classNames(styles["toggle-container__toggle"], {
95
+ [styles["toggle-container__toggle--ignore-hover"]]: showToggleAnimation,
96
+ [styles["toggle-container__toggle--on-white"]]: onColor === ToggleOnColor.onwhite
97
+ });
98
+ const toggleDotClassNames = classNames(styles["toggle-container__toggle__dot"], { [styles["toggle-container__toggle__dot--ignore-hover"]]: showToggleAnimation });
99
+ const renderToggle = () => /* @__PURE__ */ jsxs("div", {
100
+ className: styles["toggle-container__outer-toggle"],
101
+ children: [/* @__PURE__ */ jsxs("label", {
102
+ ref: refObject,
103
+ className: styles["toggle-container__toggle-group"],
104
+ children: [/* @__PURE__ */ jsx("input", {
105
+ disabled,
106
+ id: inputId,
107
+ type: "checkbox",
108
+ checked: checkedState,
109
+ onChange: handleChange,
110
+ className: styles["toggle-container__input"],
111
+ "aria-label": label.map((l) => l.text).join(" "),
112
+ "aria-describedby": [subLabel ? subLabelId : null, statusText ? toggleId + "-status" : null].filter(Boolean).join(" ") || void 0,
113
+ role: "switch"
114
+ }), /* @__PURE__ */ jsx("span", {
115
+ id: toggleId,
116
+ ref: toggleRef,
117
+ className: toggleClassNames,
118
+ "aria-hidden": "true",
119
+ children: /* @__PURE__ */ jsx("span", {
120
+ ref: toggleDotRef,
121
+ className: toggleDotClassNames,
122
+ "aria-hidden": "true",
123
+ children: /* @__PURE__ */ jsx("svg", {
124
+ width: "12",
125
+ height: "12",
126
+ viewBox: "0 0 12 12",
127
+ fill: "none",
128
+ xmlns: "http://www.w3.org/2000/svg",
129
+ className: styles["toggle-container__toggle__dot__icon"],
130
+ children: /* @__PURE__ */ jsx("path", {
131
+ d: "M11 2.65247L4.69877 9.34741L1 5.41836",
132
+ strokeWidth: "2.2"
133
+ })
134
+ })
135
+ })
136
+ })]
137
+ }), statusText && /* @__PURE__ */ jsx("span", {
138
+ className: statusTextClassNames,
139
+ id: toggleId + "-status",
140
+ children: checkedState ? statusText.checked : statusText.unchecked
141
+ })]
142
+ });
143
+ const renderLabelText = () => {
144
+ return /* @__PURE__ */ jsxs("div", {
145
+ className: styles["toggle-container__outer-label"],
146
+ children: [/* @__PURE__ */ jsx("span", {
147
+ id: labelId,
148
+ className: styles["toggle-container__label"],
149
+ children: label.map((labelText) => {
150
+ const labelClassNames = classNames({ [styles["toggle-container__label__text--subdued"]]: labelText.type === "subdued" });
151
+ return /* @__PURE__ */ jsx("span", {
152
+ className: labelClassNames,
153
+ children: labelText.text
154
+ }, labelId + labelText.text);
155
+ })
156
+ }), subLabel && /* @__PURE__ */ jsx("div", {
157
+ id: subLabelId,
158
+ className: subLabelClassNames,
159
+ children: subLabel
160
+ })]
161
+ });
162
+ };
163
+ return /* @__PURE__ */ jsxs("div", {
164
+ className: toggleContainerClassNames,
165
+ "data-testid": testId,
166
+ "data-analyticsid": AnalyticsId.Toggle,
167
+ children: [togglePosition === TogglePosition.left && /* @__PURE__ */ jsxs(Fragment, { children: [renderToggle(), renderLabelText()] }), togglePosition === TogglePosition.right && /* @__PURE__ */ jsxs(Fragment, { children: [renderLabelText(), renderToggle()] })]
168
+ });
169
+ };
170
+ //#endregion
171
+ //#region src/components/Toggle/index.ts
172
+ var Toggle_default = Toggle;
173
+ //#endregion
174
+ export { ToggleOnColor as n, TogglePosition as r, Toggle_default as t };
175
+
176
+ //# sourceMappingURL=Toggle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toggle.js","names":[],"sources":["../src/components/Toggle/constants.ts","../src/components/Toggle/Toggle.tsx","../src/components/Toggle/index.ts"],"sourcesContent":["export enum TogglePosition {\n left = 'left',\n right = 'right',\n}\n\nexport enum ToggleOnColor {\n onwhite = 'onwhite',\n onneutral = 'onneutral',\n onblueberry = 'onblueberry',\n}\n","import React, { useState, useEffect, useId } from 'react';\n\nimport classNames from 'classnames';\nimport { useAnimate } from 'motion/react';\n\nimport { ToggleOnColor, TogglePosition } from './constants';\nimport { AnalyticsId } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\n\nimport styles from './styles.module.scss';\n\nimport '../../scss/supernova/styles/colors.css';\n\nexport type LabelText = {\n text: string;\n type?: 'subdued' | 'normal';\n};\n\nexport type StatusTextType = {\n checked: string;\n unchecked: string;\n};\n\nexport interface ToggleProps extends Pick<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'disabled'> {\n /** Determines if the Toggle is checked */\n checked?: boolean;\n /** Sets the label of the Toggle */\n label: LabelText[];\n /** Defines the color of the toggle */\n onColor?: keyof typeof ToggleOnColor;\n /** A text that is shown under the Toggle switch */\n statusText?: StatusTextType;\n /** Sets the sublabel of the Toggle */\n subLabel?: string;\n /** Sets the position of the toggle relative to the label */\n togglePosition?: keyof typeof TogglePosition;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst Toggle: React.FC<ToggleProps> = ({\n checked = false,\n disabled,\n label,\n onChange,\n onColor = ToggleOnColor.onwhite,\n statusText,\n subLabel,\n togglePosition = TogglePosition.left,\n testId,\n}: ToggleProps) => {\n const [checkedControlledState, setCheckedControlledState] = useState(checked);\n const [checkedState, setCheckedState] = useState(checked);\n const [showToggleAnimation, setShowToggleAnimation] = useState(false);\n const [scope, animate] = useAnimate();\n const baseId = useId();\n const toggleId = 'toggle-' + baseId;\n const inputId = 'input-' + baseId;\n const labelId = 'label-' + baseId;\n const subLabelId = 'sublabel-' + baseId;\n const toggleRef = React.useRef<HTMLSpanElement>(null);\n const toggleDotRef = React.useRef<HTMLSpanElement>(null);\n const { refObject, isHovered, isActive } = usePseudoClasses<HTMLLabelElement>(scope);\n const showHoveredStyling = isHovered && !showToggleAnimation;\n const isOnWhite = onColor === ToggleOnColor.onwhite;\n const animationDuration = disabled ? 0 : 0.2;\n const dotBackgroundColor = disabled\n ? 'var(--color-disabled-graphics)'\n : checkedState\n ? 'var(--color-action-graphics-ondark)'\n : 'var(--core-color-neutral-700)';\n\n if (checked !== checkedControlledState && typeof checked !== 'undefined') {\n setCheckedControlledState(checked);\n setCheckedState(checked);\n }\n\n const getBackgroundColor = (): string => {\n if (disabled) {\n return 'transparent';\n } else if (checkedState && isActive) {\n return 'var(--core-color-blueberry-800)';\n } else if (checkedState) {\n return showHoveredStyling ? 'var(--color-action-graphics-onlight-hover)' : 'var(--color-action-graphics-onlight)';\n } else if (isOnWhite && isActive) {\n return 'var(--core-color-neutral-400)';\n } else if (isOnWhite) {\n return showHoveredStyling ? 'var(--core-color-neutral-200)' : 'var(--core-color-neutral-50)';\n } else if (isActive) {\n return 'var(--core-color-neutral-200)';\n } else {\n return showHoveredStyling ? 'var(--core-color-neutral-50)' : 'var(--core-color-white)';\n }\n };\n\n useEffect(() => {\n if (showToggleAnimation) {\n const timer = setTimeout(() => setShowToggleAnimation(false), 300);\n return (): void => clearTimeout(timer);\n }\n }, [showToggleAnimation]);\n\n useEffect(() => {\n if (!toggleRef.current || !toggleDotRef.current) return;\n animate(toggleRef.current, { background: getBackgroundColor() }, { duration: animationDuration, ease: 'easeInOut' });\n animate(\n toggleDotRef.current,\n {\n background: dotBackgroundColor,\n },\n { duration: animationDuration, ease: 'easeInOut' }\n );\n animate(toggleDotRef.current, { x: checkedState ? 16 : 0 }, { duration: animationDuration, ease: 'easeInOut' });\n animate('svg', { opacity: checkedState ? 1 : 0 }, { duration: animationDuration, ease: 'easeInOut' });\n }, [checkedState, showHoveredStyling, isActive, disabled]);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n setCheckedState(event.target.checked);\n setShowToggleAnimation(true);\n onChange?.(event);\n };\n\n const toggleContainerClassNames = classNames(styles['toggle-container'], {\n [styles['toggle-container--position-right']]: togglePosition === TogglePosition.right,\n [styles['toggle-container--with-status']]: statusText !== undefined && statusText !== null,\n [styles['toggle-container--disabled']]: disabled,\n });\n\n const subLabelClassNames = classNames(styles['toggle-container__sublabel']);\n\n const statusTextClassNames = classNames(styles['toggle-container__status'], {\n [styles['toggle-container__status--checked']]: checkedState,\n });\n\n const toggleClassNames = classNames(styles['toggle-container__toggle'], {\n [styles['toggle-container__toggle--ignore-hover']]: showToggleAnimation,\n [styles['toggle-container__toggle--on-white']]: onColor === ToggleOnColor.onwhite,\n });\n\n const toggleDotClassNames = classNames(styles['toggle-container__toggle__dot'], {\n [styles['toggle-container__toggle__dot--ignore-hover']]: showToggleAnimation,\n });\n\n const renderToggle = (): React.ReactElement => (\n <div className={styles['toggle-container__outer-toggle']}>\n <label ref={refObject} className={styles['toggle-container__toggle-group']}>\n <input\n disabled={disabled}\n id={inputId}\n type=\"checkbox\"\n checked={checkedState}\n onChange={handleChange}\n className={styles['toggle-container__input']}\n aria-label={label.map(l => l.text).join(' ')}\n aria-describedby={[subLabel ? subLabelId : null, statusText ? toggleId + '-status' : null].filter(Boolean).join(' ') || undefined}\n role=\"switch\"\n />\n <span id={toggleId} ref={toggleRef} className={toggleClassNames} aria-hidden=\"true\">\n <span ref={toggleDotRef} className={toggleDotClassNames} aria-hidden=\"true\">\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 12 12\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={styles['toggle-container__toggle__dot__icon']}\n >\n <path d=\"M11 2.65247L4.69877 9.34741L1 5.41836\" strokeWidth=\"2.2\" />\n </svg>\n </span>\n </span>\n </label>\n {statusText && (\n <span className={statusTextClassNames} id={toggleId + '-status'}>\n {checkedState ? statusText.checked : statusText.unchecked}\n </span>\n )}\n </div>\n );\n\n const renderLabelText = (): React.ReactElement => {\n return (\n <div className={styles['toggle-container__outer-label']}>\n <span id={labelId} className={styles['toggle-container__label']}>\n {label.map(labelText => {\n const labelClassNames = classNames({\n [styles['toggle-container__label__text--subdued']]: labelText.type === 'subdued',\n });\n\n return (\n <span key={labelId + labelText.text} className={labelClassNames}>\n {labelText.text}\n </span>\n );\n })}\n </span>\n {subLabel && (\n <div id={subLabelId} className={subLabelClassNames}>\n {subLabel}\n </div>\n )}\n </div>\n );\n };\n\n return (\n <div className={toggleContainerClassNames} data-testid={testId} data-analyticsid={AnalyticsId.Toggle}>\n {togglePosition === TogglePosition.left && (\n <>\n {renderToggle()}\n {renderLabelText()}\n </>\n )}\n {togglePosition === TogglePosition.right && (\n <>\n {renderLabelText()}\n {renderToggle()}\n </>\n )}\n </div>\n );\n};\n\nexport default Toggle;\n","import Toggle from './Toggle';\nexport { TogglePosition, ToggleOnColor } from './constants';\nexport * from './Toggle';\nexport default Toggle;\n"],"mappings":";;;;;;;;AAAA,IAAY,iBAAL,yBAAA,gBAAA;CACL,eAAA,UAAA;CACA,eAAA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A9F,UAAA,CACG,mBAAmB,eAAe,QACjC,qBAAA,UAAA,EAAA,UAAA,CACG,aAAa,GACb,gBAAgB,CACjB,EAAA,CAAA,GAEH,mBAAmB,eAAe,SACjC,qBAAA,UAAA,EAAA,UAAA,CACG,gBAAgB,GAChB,aAAa,CACd,EAAA,CAAA,CAED;;AAET;;;AC1NA,IAAA,iBAAe"}
@@ -54,7 +54,7 @@ $mobile-outer-size: 2.75rem;
54
54
  }
55
55
 
56
56
  :focus-visible > & {
57
- outline: 3px solid var(--color-action-border-onlight-focus);
57
+ outline: 4px solid var(--color-action-border-onlight-focus);
58
58
  border-radius: 0;
59
59
  border: 0;
60
60
  }
@@ -69,7 +69,7 @@ $mobile-outer-size: 2.75rem;
69
69
  }
70
70
 
71
71
  :focus-visible > & {
72
- outline: 3px solid var(--color-action-border-onlight-focus);
72
+ outline: 4px solid var(--color-action-border-onlight-focus);
73
73
  border-radius: 0;
74
74
  border: 0;
75
75
  }
@@ -1,7 +1,7 @@
1
- @use '../../scss/spacers' as spacers;
2
1
  @use '../../scss/palette' as palette;
3
2
  @use '../../scss/font-mixins' as fonts;
4
3
  @use '../../scss/breakpoints' as breakpoints;
4
+ @import '../../scss/supernova/styles/spacers';
5
5
 
6
6
  .form-group-wrapper {
7
7
  &__title {
@@ -21,14 +21,22 @@
21
21
  margin: 0;
22
22
  display: flex;
23
23
  flex-flow: column;
24
- gap: spacers.getSpacer(s);
24
+ gap: var(--core-space-s);
25
25
 
26
26
  > div {
27
27
  padding-bottom: 0;
28
28
  }
29
29
 
30
+ &--compact-gap {
31
+ gap: 0;
32
+ }
33
+
34
+ &--compact-sublabel-gap {
35
+ gap: var(--core-space-2xs);
36
+ }
37
+
30
38
  &__legend {
31
- margin-bottom: spacers.getSpacer(m);
39
+ margin-bottom: var(--core-space-s);
32
40
  margin-top: 0;
33
41
  display: flex;
34
42
  flex-flow: column;
@@ -40,4 +48,8 @@
40
48
  color: palette.$white;
41
49
  }
42
50
  }
51
+
52
+ &--compact-sublabel-gap &__legend {
53
+ margin-bottom: var(--core-space-m);
54
+ }
43
55
  }
@@ -2,6 +2,8 @@ export type Styles = {
2
2
  'field-set': string;
3
3
  'field-set__legend': string;
4
4
  'field-set__legend--on-dark': string;
5
+ 'field-set--compact-gap': string;
6
+ 'field-set--compact-sublabel-gap': string;
5
7
  'form-group-wrapper': string;
6
8
  'form-group-wrapper__title--on-dark': string;
7
9
  };
@@ -6,7 +6,15 @@
6
6
 
7
7
  display: flex;
8
8
  flex-wrap: wrap;
9
- gap: spacers.getSpacer(s) var(--column-gap);
9
+ column-gap: var(--column-gap);
10
+
11
+ &--compact-gap {
12
+ row-gap: 0;
13
+ }
14
+
15
+ &--compact-sublabel-gap {
16
+ row-gap: var(--core-space-2xs);
17
+ }
10
18
 
11
19
  &--large {
12
20
  row-gap: spacers.getSpacer(2xs);
@@ -5,6 +5,8 @@ export type Styles = {
5
5
  'form-layout-child--three': string;
6
6
  'form-layout-child--two': string;
7
7
  'form-layout-container': string;
8
+ 'form-layout-container--compact-gap': string;
9
+ 'form-layout-container--compact-sublabel-gap': string;
8
10
  'form-layout-container--large': string;
9
11
  };
10
12
 
@@ -1,6 +1,6 @@
1
- export type HelpPanelVariants = 'normal' | 'compact';
1
+ export type HelpPanelVariants = 'normal' | 'compact' | 'subdued';
2
2
  export interface HelpPanelProps {
3
- /** What's in the box? */
3
+ /** The content of the component */
4
4
  children: React.ReactNode;
5
5
  /** If set the compact styling will be used */
6
6
  variant?: HelpPanelVariants;