@pega/cosmos-react-core 3.0.0-dev.24.0 → 3.0.0-dev.27.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 (108) hide show
  1. package/lib/components/Actions/Actions.d.ts +5 -0
  2. package/lib/components/Actions/Actions.d.ts.map +1 -1
  3. package/lib/components/Actions/Actions.js +2 -2
  4. package/lib/components/Actions/Actions.js.map +1 -1
  5. package/lib/components/AdditionalInfo/AdditionalInfo.d.ts.map +1 -1
  6. package/lib/components/AdditionalInfo/AdditionalInfo.js.map +1 -1
  7. package/lib/components/AdditionalInfo/index.d.ts +1 -2
  8. package/lib/components/AdditionalInfo/index.d.ts.map +1 -1
  9. package/lib/components/AdditionalInfo/index.js +1 -1
  10. package/lib/components/AdditionalInfo/index.js.map +1 -1
  11. package/lib/components/AppShell/AppHeader.d.ts.map +1 -1
  12. package/lib/components/AppShell/AppHeader.js +7 -7
  13. package/lib/components/AppShell/AppHeader.js.map +1 -1
  14. package/lib/components/AppShell/AppShell.d.ts.map +1 -1
  15. package/lib/components/AppShell/AppShell.js +8 -2
  16. package/lib/components/AppShell/AppShell.js.map +1 -1
  17. package/lib/components/AppShell/AppShell.styles.js +1 -1
  18. package/lib/components/AppShell/AppShell.styles.js.map +1 -1
  19. package/lib/components/AppShell/NavigationList.d.ts.map +1 -1
  20. package/lib/components/AppShell/NavigationList.js +1 -1
  21. package/lib/components/AppShell/NavigationList.js.map +1 -1
  22. package/lib/components/AppShell/index.d.ts +0 -1
  23. package/lib/components/AppShell/index.d.ts.map +1 -1
  24. package/lib/components/AppShell/index.js +0 -1
  25. package/lib/components/AppShell/index.js.map +1 -1
  26. package/lib/components/Badges/Keyboard.d.ts.map +1 -1
  27. package/lib/components/Badges/Keyboard.js +3 -1
  28. package/lib/components/Badges/Keyboard.js.map +1 -1
  29. package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
  30. package/lib/components/ComboBox/ComboBox.js +5 -2
  31. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  32. package/lib/components/ComboBox/ComboBox.types.d.ts +5 -1
  33. package/lib/components/ComboBox/ComboBox.types.d.ts.map +1 -1
  34. package/lib/components/ComboBox/ComboBox.types.js.map +1 -1
  35. package/lib/components/Dialog/Dialog.d.ts.map +1 -1
  36. package/lib/components/Dialog/Dialog.js +2 -2
  37. package/lib/components/Dialog/Dialog.js.map +1 -1
  38. package/lib/components/FieldGroup/FieldGroup.d.ts +7 -0
  39. package/lib/components/FieldGroup/FieldGroup.d.ts.map +1 -1
  40. package/lib/components/FieldGroup/FieldGroup.js +29 -28
  41. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  42. package/lib/components/FormControl/FormControl.d.ts +3 -2
  43. package/lib/components/FormControl/FormControl.d.ts.map +1 -1
  44. package/lib/components/FormControl/FormControl.js.map +1 -1
  45. package/lib/components/HTML/HTML.d.ts.map +1 -1
  46. package/lib/components/HTML/HTML.js +1 -0
  47. package/lib/components/HTML/HTML.js.map +1 -1
  48. package/lib/components/Link/Link.d.ts.map +1 -1
  49. package/lib/components/Link/Link.js +38 -24
  50. package/lib/components/Link/Link.js.map +1 -1
  51. package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
  52. package/lib/components/ListToolbar/ListToolbar.js +49 -56
  53. package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
  54. package/lib/components/ListToolbar/ListToolbar.styles.d.ts +1 -0
  55. package/lib/components/ListToolbar/ListToolbar.styles.d.ts.map +1 -1
  56. package/lib/components/ListToolbar/ListToolbar.styles.js +36 -2
  57. package/lib/components/ListToolbar/ListToolbar.styles.js.map +1 -1
  58. package/lib/components/ListToolbar/ListToolbar.types.d.ts +17 -10
  59. package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -1
  60. package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -1
  61. package/lib/components/Menu/MenuItem.d.ts.map +1 -1
  62. package/lib/components/Menu/MenuItem.js +1 -3
  63. package/lib/components/Menu/MenuItem.js.map +1 -1
  64. package/lib/components/Menu/NavItemsList.d.ts +2 -2
  65. package/lib/components/Menu/NavItemsList.d.ts.map +1 -1
  66. package/lib/components/Menu/NavItemsList.js +9 -9
  67. package/lib/components/Menu/NavItemsList.js.map +1 -1
  68. package/lib/components/MultiStepForm/FormProgress.styles.d.ts.map +1 -1
  69. package/lib/components/MultiStepForm/FormProgress.styles.js +1 -0
  70. package/lib/components/MultiStepForm/FormProgress.styles.js.map +1 -1
  71. package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
  72. package/lib/components/SearchInput/SearchInput.js +26 -6
  73. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  74. package/lib/components/SkipLinks/SkipLinks.d.ts +15 -0
  75. package/lib/components/SkipLinks/SkipLinks.d.ts.map +1 -0
  76. package/lib/components/{AppShell/SkipNavigation.js → SkipLinks/SkipLinks.js} +23 -19
  77. package/lib/components/SkipLinks/SkipLinks.js.map +1 -0
  78. package/lib/components/SkipLinks/index.d.ts +4 -0
  79. package/lib/components/SkipLinks/index.d.ts.map +1 -0
  80. package/lib/components/SkipLinks/index.js +3 -0
  81. package/lib/components/SkipLinks/index.js.map +1 -0
  82. package/lib/components/Tree/StandardTree.d.ts.map +1 -1
  83. package/lib/components/Tree/StandardTree.js +27 -13
  84. package/lib/components/Tree/StandardTree.js.map +1 -1
  85. package/lib/components/Tree/StandardTree.styles.js +3 -3
  86. package/lib/components/Tree/StandardTree.styles.js.map +1 -1
  87. package/lib/components/Tree/StandardTree.types.d.ts +1 -0
  88. package/lib/components/Tree/StandardTree.types.d.ts.map +1 -1
  89. package/lib/components/Tree/StandardTree.types.js.map +1 -1
  90. package/lib/hooks/useFocusWithin.d.ts.map +1 -1
  91. package/lib/hooks/useFocusWithin.js +0 -8
  92. package/lib/hooks/useFocusWithin.js.map +1 -1
  93. package/lib/hooks/useI18n.d.ts +9 -3
  94. package/lib/hooks/useI18n.d.ts.map +1 -1
  95. package/lib/i18n/default.d.ts +9 -3
  96. package/lib/i18n/default.d.ts.map +1 -1
  97. package/lib/i18n/default.js +9 -3
  98. package/lib/i18n/default.js.map +1 -1
  99. package/lib/i18n/i18n.d.ts +9 -3
  100. package/lib/i18n/i18n.d.ts.map +1 -1
  101. package/lib/index.d.ts +2 -0
  102. package/lib/index.d.ts.map +1 -1
  103. package/lib/index.js +2 -0
  104. package/lib/index.js.map +1 -1
  105. package/package.json +1 -1
  106. package/lib/components/AppShell/SkipNavigation.d.ts +0 -4
  107. package/lib/components/AppShell/SkipNavigation.d.ts.map +0 -1
  108. package/lib/components/AppShell/SkipNavigation.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FieldGroup.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAsD,MAAM,OAAO,CAAC;AACjG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,OAAyB,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAE3D,YAAY,CAAC,cAAc,CAAC,CAAC;AA+B7B,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,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EF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, useState, FunctionComponent, PropsWithoutRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Button, { StyledButton } from '../Button';\nimport ExpandCollapse from '../ExpandCollapse';\nimport Flex, { StyledFlex } from '../Flex';\nimport HTML from '../HTML';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport Actions, { ActionsProps } from '../Actions';\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { useDirection, useI18n, useUID } from '../../hooks';\nimport { calculateFontSize, FontSize } from '../../styles';\n\nregisterIcon(caretRightIcon);\n\nexport interface FieldGroupProps extends 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 /**\n * If true, the Field Group will be able to collapse the content of its children by clicking on the name.\n * @default false\n */\n collapsible?: boolean;\n /**\n * If true, the Field Group will be collapsed on the first render.\n * @default false\n */\n defaultCollapsed?: boolean;\n /** The name associated with the Field Group. */\n name?: string;\n /** An array of actions to add to the header. */\n actions?: ActionsProps['items'];\n /** A reference to the wrapping element. */\n ref?: Ref<HTMLFieldSetElement>;\n}\n\ninterface FieldGroupLegendProps {\n open: boolean;\n actions?: ActionsProps['items'];\n children?: ReactNode;\n}\n\nexport const StyledFieldGroupLegend = styled.legend<{ open: boolean }>(\n ({\n open,\n theme: {\n base: {\n spacing,\n animation,\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n }\n }\n }) => {\n const { rtl } = useDirection();\n return css`\n width: 100%;\n margin-bottom: 0;\n ${open &&\n css`\n margin-block-end: calc(1.5 * ${spacing});\n `}\n transition: margin-block-end ${animation.speed} ${animation.timing.ease};\n\n button ${StyledIcon} {\n transition: transform ${animation.speed} ${animation.timing.ease};\n }\n\n button[aria-expanded='true'] ${StyledIcon} {\n transform: rotate(90deg);\n }\n button[aria-expanded='false'] ${StyledIcon} {\n transform: rotate(${rtl ? 180 : 0}deg);\n }\n\n > ${StyledFlex} ${StyledButton} {\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 ${StyledFieldGroupLegend} ${StyledButton} {\n font-weight: inherit;\n }\n\n & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n }\n\n & & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n }\n\n & & & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n }\n\n & & & & ${StyledFieldGroupLegend} {\n font-size: ${fontSizes[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n }\n `;\n }\n);\n\nStyledFieldGroup.defaultProps = defaultThemeProp;\n\nconst FieldGroupLegend: FunctionComponent<FieldGroupLegendProps> = ({\n children,\n open,\n actions,\n ...restProps\n}) => {\n return (\n <StyledFieldGroupLegend open={open} {...restProps}>\n <Flex container={{ alignItems: 'center', justify: 'between' }}>\n {children}\n {actions && <Actions items={actions} />}\n </Flex>\n </StyledFieldGroupLegend>\n );\n};\n\nconst FieldGroup: FunctionComponent<FieldGroupProps & ForwardProps> = forwardRef(\n (\n {\n children,\n description,\n name,\n actions,\n collapsible = false,\n defaultCollapsed = false,\n ...restProps\n }: PropsWithoutRef<FieldGroupProps>,\n ref: FieldGroupProps['ref']\n ) => {\n const [open, setOpen] = useState(!defaultCollapsed);\n const t = useI18n();\n const uid = useUID();\n\n const descAndChildren = (\n <Flex container={{ direction: 'column', gap: 3 }}>\n {description && <HTML id={`${uid}-description`} as='p' content={description} />}\n <div>{children}</div>\n </Flex>\n );\n\n return (\n <StyledFieldGroup\n aria-label={name}\n aria-describedby={description ? `${uid}-description` : undefined}\n {...restProps}\n ref={ref}\n >\n {name && (\n <FieldGroupLegend open={open} actions={actions}>\n {collapsible ? (\n <Button\n type='button'\n variant='text'\n onClick={() => {\n setOpen(cur => !cur);\n }}\n aria-expanded={open ? 'true' : 'false'}\n aria-label={t(open ? 'collapse_noun' : 'expand_noun', [name])}\n >\n <Flex\n container={{ direction: 'row', alignItems: 'center', gap: 0.5 }}\n forwardedAs='span'\n >\n <Icon name='caret-right' />\n <span>{name}</span>\n </Flex>\n </Button>\n ) : (\n <span>{name}</span>\n )}\n </FieldGroupLegend>\n )}\n {collapsible ? (\n <ExpandCollapse collapsed={!open}>{descAndChildren}</ExpandCollapse>\n ) : (\n descAndChildren\n )}\n </StyledFieldGroup>\n );\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,QAAQ,EAAsD,MAAM,OAAO,CAAC;AACjG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,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,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,OAAyB,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAA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C,CACb,KAAC,kBAAkB,IACjB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,GAAG,EAAE;wBACZ,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;oBACvB,CAAC,mBACc,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,gBAC1B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,YAE7D,MAAC,IAAI,IACH,SAAS,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,EAC/D,WAAW,EAAC,MAAM,aAElB,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,GAAG,EAC3B,KAAC,oBAAoB,cAAE,IAAI,GAAwB,IAC9C,GACY,CACtB,CAAC,CAAC,CAAC,CACF,KAAC,oBAAoB,cAAE,IAAI,GAAwB,CACpD,GACgB,CACpB,EACA,WAAW,CAAC,CAAC,CAAC,CACb,KAAC,cAAc,IAAC,SAAS,EAAE,CAAC,IAAI,YAAG,eAAe,GAAkB,CACrE,CAAC,CAAC,CAAC,CACF,eAAe,CAChB,IACgB,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, useState, FunctionComponent, PropsWithoutRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Button from '../Button';\nimport ExpandCollapse from '../ExpandCollapse';\nimport Flex from '../Flex';\nimport HTML from '../HTML';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport Actions, { ActionsProps } from '../Actions';\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { useDirection, useI18n, useUID } from '../../hooks';\nimport { calculateFontSize, FontSize } from '../../styles';\nimport AdditionalInfo, { AdditionalInfoProps } from '../AdditionalInfo';\n\nregisterIcon(caretRightIcon);\n\nexport interface FieldGroupProps extends 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 /**\n * If true, the Field Group will be able to collapse the content of its children by clicking on the name.\n * @default false\n */\n collapsible?: boolean;\n /**\n * If true, the Field Group will be collapsed on the first render.\n * @default false\n */\n defaultCollapsed?: boolean;\n /** The name associated with the Field Group. */\n name?: string;\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 /** A reference to the wrapping element. */\n ref?: Ref<HTMLFieldSetElement>;\n}\n\ninterface FieldGroupLegendProps {\n open: boolean;\n actions?: ActionsProps['items'];\n children?: ReactNode;\n additionalInfo?: FieldGroupProps['additionalInfo'];\n}\n\nconst StyledExpandButton = styled(Button)(\n ({\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} {\n transform: rotate(90deg);\n }\n &[aria-expanded='false'] ${StyledIcon} {\n transform: rotate(${rtl ? 180 : 0}deg);\n }\n `;\n }\n);\n\nStyledExpandButton.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroupName = styled.span``;\n\nexport const StyledFieldGroupLegend = styled.legend<{ open: boolean }>(\n ({\n open,\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 ${open &&\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 & & ${StyledFieldGroupName} {\n font-size: ${fontSizes[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n }\n\n & & & ${StyledFieldGroupName} {\n font-size: ${fontSizes[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n }\n\n & & & & ${StyledFieldGroupName} {\n font-size: ${fontSizes[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n }\n `;\n }\n);\n\nStyledFieldGroup.defaultProps = defaultThemeProp;\n\nconst FieldGroupLegend: FunctionComponent<FieldGroupLegendProps> = ({\n children,\n open,\n actions,\n additionalInfo,\n ...restProps\n}) => {\n return (\n <StyledFieldGroupLegend open={open} {...restProps}>\n <Flex container={{ alignItems: 'center', justify: 'between', gap: 0.5 }}>\n <Flex container={{ alignItems: 'center', gap: 0.5 }}>\n {children}\n {additionalInfo && (\n <AdditionalInfo heading={additionalInfo.heading}>\n {additionalInfo.content}\n </AdditionalInfo>\n )}\n </Flex>\n {actions && <Actions items={actions} />}\n </Flex>\n </StyledFieldGroupLegend>\n );\n};\n\nconst FieldGroup: FunctionComponent<FieldGroupProps & ForwardProps> = forwardRef(\n (\n {\n children,\n description,\n name,\n additionalInfo,\n actions,\n collapsible = false,\n defaultCollapsed = false,\n ...restProps\n }: PropsWithoutRef<FieldGroupProps>,\n ref: FieldGroupProps['ref']\n ) => {\n const [open, setOpen] = useState(!defaultCollapsed);\n const t = useI18n();\n const uid = useUID();\n\n const descAndChildren = (\n <Flex container={{ direction: 'column', gap: 3 }}>\n {description && <HTML id={`${uid}-description`} as='p' content={description} />}\n <div>{children}</div>\n </Flex>\n );\n\n return (\n <StyledFieldGroup\n aria-label={name}\n aria-describedby={description ? `${uid}-description` : undefined}\n {...restProps}\n ref={ref}\n >\n {name && (\n <FieldGroupLegend open={open} actions={actions} additionalInfo={additionalInfo}>\n {collapsible ? (\n <StyledExpandButton\n type='button'\n variant='text'\n onClick={() => {\n setOpen(cur => !cur);\n }}\n aria-expanded={open ? 'true' : 'false'}\n aria-label={t(open ? 'collapse_noun' : 'expand_noun', [name])}\n >\n <Flex\n container={{ direction: 'row', alignItems: 'center', gap: 0.5 }}\n forwardedAs='span'\n >\n <Icon name='caret-right' />\n <StyledFieldGroupName>{name}</StyledFieldGroupName>\n </Flex>\n </StyledExpandButton>\n ) : (\n <StyledFieldGroupName>{name}</StyledFieldGroupName>\n )}\n </FieldGroupLegend>\n )}\n {collapsible ? (\n <ExpandCollapse collapsed={!open}>{descAndChildren}</ExpandCollapse>\n ) : (\n descAndChildren\n )}\n </StyledFieldGroup>\n );\n }\n);\n\nexport default FieldGroup;\n"]}
@@ -1,5 +1,6 @@
1
1
  import { FunctionComponent, ReactNode } from 'react';
2
2
  import { BaseProps, ForwardProps } from '../../types';
3
+ import { AdditionalInfoProps } from '../AdditionalInfo';
3
4
  export interface FormControlProps extends BaseProps {
4
5
  /**
5
6
  * Sets DOM id for the control and associates label element via 'for' attribute.
@@ -20,8 +21,8 @@ export interface FormControlProps extends BaseProps {
20
21
  placeholder?: string;
21
22
  /** Button when clicked will show additional information on a field */
22
23
  additionalInfo?: {
23
- heading: string;
24
- content: string;
24
+ heading: AdditionalInfoProps['heading'];
25
+ content: AdditionalInfoProps['children'];
25
26
  };
26
27
  /**
27
28
  * Creates a controlled input and sets the value. Requires an onChange handler to update value.
@@ -1 +1 @@
1
- {"version":3,"file":"FormControl.d.ts","sourceRoot":"","sources":["../../../src/components/FormControl/FormControl.tsx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Y,CAInE,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"FormControl.js","sourceRoot":"","sources":["../../../src/components/FormControl/FormControl.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA8CjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAGzC,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,eAAe,EAAE,UAAU,EAC3B,WAAW,EAAE,YAAY,EACzB,YAAY,EAAE,aAAa,EAC3B,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAC5B,OAAO,EACR,EACD,UAAU,EAAE,EACV,YAAY,EAAE,SAAS,EACvB,cAAc,EAAE,EACd,kBAAkB,EAAE,UAAU,EAC9B,kBAAkB,EAAE,UAAU,EAC9B,cAAc,EAAE,GAAG,EACnB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,WAAW,EAC3B,QAAQ,EAAE,EAAE,cAAc,EAAE,gBAAgB,EAAE,EAC9C,QAAQ,EAAE,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,EACpE,WAAW,EAAE,EACX,cAAc,EAAE,mBAAmB,EACnC,kBAAkB,EAAE,uBAAuB,EAC5C,EACD,YAAY,EAAE,EACZ,cAAc,EAAE,mBAAmB,EACnC,kBAAkB,EAAE,uBAAuB,EAC5C,EACF,EACF,EACF,EACD,MAAM,EACN,aAAa,EACd,EAAE,EAAE;IACH,MAAM,QAAQ,GAAG,iBAAiB,CAAC,YAAY,EAAE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wardRef, FunctionComponent, PropsWithoutRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix, rgba } from 'polished';\n\nimport { BaseProps, ForwardProps, PropsWithDefaults } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\n\nexport interface FormControlProps extends BaseProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: string;\n /** Set visual state based on a validation state. */\n status?: 'success' | 'warning' | 'error' | 'pending';\n /** Pass a string or a fragment with an Icon and string. */\n label?: ReactNode;\n /** Visually hides the label region. */\n labelHidden?: boolean;\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: ReactNode;\n /** Indicate if the field is required. The browser defaults to false. */\n required?: boolean;\n /** Placeholder text. The browser defaults to an empty string. */\n placeholder?: string;\n /** Button when clicked will show additional information on a field */\n additionalInfo?: {\n heading: string;\n content: string;\n };\n /**\n * Creates a controlled input and sets the value. Requires an onChange handler to update value.\n * value + onChange is the recommended method per React team.\n */\n value?: string;\n /**\n * If you wish to use an [uncontrolled input](https://reactjs.org/docs/uncontrolled-components.html), pass a defaultValue prop and a ref to access the input's native value prop or by other DOM ref means.\n */\n defaultValue?: string;\n /** Disable the control. The browser defaults to false. */\n disabled?: boolean;\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: boolean;\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: string;\n /** Callback fired when AI suggestion is accepted/rejected */\n onResolveSuggestion?: (accepted: boolean) => void;\n}\n\ntype FormControlPropsWithDefaults = PropsWithDefaults<FormControlProps>;\n\nexport const StyledFormControl = styled.div<\n FormControlPropsWithDefaults & { hasSuggestion?: boolean }\n>(\n ({\n theme: {\n base: {\n 'border-radius': baseRadius,\n 'font-size': baseFontSize,\n 'font-scale': baseFontScale,\n animation: { speed, timing },\n palette\n },\n components: {\n 'form-field': formField,\n 'form-control': {\n 'foreground-color': foreground,\n 'background-color': background,\n 'border-color': brd,\n 'border-radius': radius,\n 'border-width': borderWidth,\n ':hover': { 'border-color': hoverBorderColor },\n ':focus': { 'border-color': focusBorderColor, 'box-shadow': shadow },\n ':disabled': {\n 'border-color': disabledBorderColor,\n 'background-color': disabledBackgroundColor\n },\n ':read-only': {\n 'border-color': readOnlyBorderColor,\n 'background-color': readOnlyBackgroundColor\n }\n }\n }\n },\n status,\n hasSuggestion\n }) => {\n const fontSize = calculateFontSize(baseFontSize, baseFontScale);\n const borderColor = status && formField[status] ? formField[status]['status-color'] : brd;\n const backgroundColor =\n hasSuggestion && status\n ? mix(0.1, formField[status]['status-color'], palette['primary-background'])\n : background;\n\n return css`\n color: ${foreground};\n background-color: ${backgroundColor};\n border-radius: calc(${baseRadius} * ${radius});\n border-color: ${borderColor};\n border-width: ${borderWidth};\n border-style: solid;\n transition: all ${timing.ease} ${speed};\n &,\n & > select {\n outline: none;\n }\n\n &:disabled,\n &[disabled] {\n background-color: ${disabledBackgroundColor};\n border-color: ${disabledBorderColor};\n cursor: not-allowed;\n }\n\n &:focus:not([disabled]) {\n border-color: ${focusBorderColor};\n box-shadow: ${shadow};\n ${hasSuggestion &&\n css`\n background-color: ${background};\n `}\n }\n\n &:focus-within:not([disabled]) {\n ${hasSuggestion &&\n css`\n background-color: ${background};\n `}\n }\n\n &:hover:not([readonly]):not([disabled]):not(:focus, :focus-within) {\n ${!status &&\n css`\n border-color: ${hoverBorderColor};\n `}\n ${hasSuggestion &&\n css`\n background-color: ${background};\n box-shadow: 0 0 0 0.125rem ${rgba(borderColor, 0.2)};\n `}\n }\n\n ${hasSuggestion &&\n css`\n border-end-end-radius: 0;\n `}\n\n &[readonly] {\n background-color: ${readOnlyBackgroundColor};\n border-color: ${readOnlyBorderColor};\n }\n\n @media (pointer: coarse) {\n /* stylelint-disable-next-line unit-allowed-list */\n font-size: max(${fontSize.s}, 16px);\n }\n `;\n }\n);\n\nStyledFormControl.defaultProps = defaultThemeProp;\n\nconst FormControl: FunctionComponent<FormControlProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<FormControlProps>, ref: Ref<HTMLDivElement>) => {\n return <StyledFormControl ref={ref} {...props} />;\n }\n);\n\nexport default FormControl;\n"]}
1
+ {"version":3,"file":"FormControl.js","sourceRoot":"","sources":["../../../src/components/FormControl/FormControl.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA+CjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAGzC,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,eAAe,EAAE,UAAU,EAC3B,WAAW,EAAE,YAAY,EACzB,YAAY,EAAE,aAAa,EAC3B,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAC5B,OAAO,EACR,EACD,UAAU,EAAE,EACV,YAAY,EAAE,SAAS,EACvB,cAAc,EAAE,EACd,kBAAkB,EAAE,UAAU,EAC9B,kBAAkB,EAAE,UAAU,EAC9B,cAAc,EAAE,GAAG,EACnB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,WAAW,EAC3B,QAAQ,EAAE,EAAE,cAAc,EAAE,gBAAgB,EAAE,EAC9C,QAAQ,EAAE,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,EACpE,WAAW,EAAE,EACX,cAAc,EAAE,mBAAmB,EACnC,kBAAkB,EAAE,uBAAuB,EAC5C,EACD,YAAY,EAAE,EACZ,cAAc,EAAE,mBAAmB,EACnC,kBAAkB,EAAE,uBAAuB,EAC5C,EACF,E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EAAE,GAAG,KAAM,KAAK,GAAI,CAAC;AACpD,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix, rgba } from 'polished';\n\nimport { BaseProps, ForwardProps, PropsWithDefaults } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\nimport { AdditionalInfoProps } from '../AdditionalInfo';\n\nexport interface FormControlProps extends BaseProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: string;\n /** Set visual state based on a validation state. */\n status?: 'success' | 'warning' | 'error' | 'pending';\n /** Pass a string or a fragment with an Icon and string. */\n label?: ReactNode;\n /** Visually hides the label region. */\n labelHidden?: boolean;\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: ReactNode;\n /** Indicate if the field is required. The browser defaults to false. */\n required?: boolean;\n /** Placeholder text. The browser defaults to an empty string. */\n placeholder?: string;\n /** Button when clicked will show additional information on a field */\n additionalInfo?: {\n heading: AdditionalInfoProps['heading'];\n content: AdditionalInfoProps['children'];\n };\n /**\n * Creates a controlled input and sets the value. Requires an onChange handler to update value.\n * value + onChange is the recommended method per React team.\n */\n value?: string;\n /**\n * If you wish to use an [uncontrolled input](https://reactjs.org/docs/uncontrolled-components.html), pass a defaultValue prop and a ref to access the input's native value prop or by other DOM ref means.\n */\n defaultValue?: string;\n /** Disable the control. The browser defaults to false. */\n disabled?: boolean;\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: boolean;\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: string;\n /** Callback fired when AI suggestion is accepted/rejected */\n onResolveSuggestion?: (accepted: boolean) => void;\n}\n\ntype FormControlPropsWithDefaults = PropsWithDefaults<FormControlProps>;\n\nexport const StyledFormControl = styled.div<\n FormControlPropsWithDefaults & { hasSuggestion?: boolean }\n>(\n ({\n theme: {\n base: {\n 'border-radius': baseRadius,\n 'font-size': baseFontSize,\n 'font-scale': baseFontScale,\n animation: { speed, timing },\n palette\n },\n components: {\n 'form-field': formField,\n 'form-control': {\n 'foreground-color': foreground,\n 'background-color': background,\n 'border-color': brd,\n 'border-radius': radius,\n 'border-width': borderWidth,\n ':hover': { 'border-color': hoverBorderColor },\n ':focus': { 'border-color': focusBorderColor, 'box-shadow': shadow },\n ':disabled': {\n 'border-color': disabledBorderColor,\n 'background-color': disabledBackgroundColor\n },\n ':read-only': {\n 'border-color': readOnlyBorderColor,\n 'background-color': readOnlyBackgroundColor\n }\n }\n }\n },\n status,\n hasSuggestion\n }) => {\n const fontSize = calculateFontSize(baseFontSize, baseFontScale);\n const borderColor = status && formField[status] ? formField[status]['status-color'] : brd;\n const backgroundColor =\n hasSuggestion && status\n ? mix(0.1, formField[status]['status-color'], palette['primary-background'])\n : background;\n\n return css`\n color: ${foreground};\n background-color: ${backgroundColor};\n border-radius: calc(${baseRadius} * ${radius});\n border-color: ${borderColor};\n border-width: ${borderWidth};\n border-style: solid;\n transition: all ${timing.ease} ${speed};\n &,\n & > select {\n outline: none;\n }\n\n &:disabled,\n &[disabled] {\n background-color: ${disabledBackgroundColor};\n border-color: ${disabledBorderColor};\n cursor: not-allowed;\n }\n\n &:focus:not([disabled]) {\n border-color: ${focusBorderColor};\n box-shadow: ${shadow};\n ${hasSuggestion &&\n css`\n background-color: ${background};\n `}\n }\n\n &:focus-within:not([disabled]) {\n ${hasSuggestion &&\n css`\n background-color: ${background};\n `}\n }\n\n &:hover:not([readonly]):not([disabled]):not(:focus, :focus-within) {\n ${!status &&\n css`\n border-color: ${hoverBorderColor};\n `}\n ${hasSuggestion &&\n css`\n background-color: ${background};\n box-shadow: 0 0 0 0.125rem ${rgba(borderColor, 0.2)};\n `}\n }\n\n ${hasSuggestion &&\n css`\n border-end-end-radius: 0;\n `}\n\n &[readonly] {\n background-color: ${readOnlyBackgroundColor};\n border-color: ${readOnlyBorderColor};\n }\n\n @media (pointer: coarse) {\n /* stylelint-disable-next-line unit-allowed-list */\n font-size: max(${fontSize.s}, 16px);\n }\n `;\n }\n);\n\nStyledFormControl.defaultProps = defaultThemeProp;\n\nconst FormControl: FunctionComponent<FormControlProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<FormControlProps>, ref: Ref<HTMLDivElement>) => {\n return <StyledFormControl ref={ref} {...props} />;\n }\n);\n\nexport default FormControl;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"HTML.d.ts","sourceRoot":"","sources":["../../../src/components/HTML/HTML.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,GAAG,EAIJ,MAAM,OAAO,CAAC;AACf,OAAe,EAAO,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAM9D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGtE,MAAM,WAAW,SAAU,SAAQ,SAAS,EAAE,cAAc;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,UAAU,wDA2CtB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,YAAY,2DA2BjD,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,YAAY,WAwDhD,CAAC;AAEF,eAAO,MAAM,UAAU,6EAmBrB,CAAC;AAIH,QAAA,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,GAAG,YAAY,CA4BrD,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"HTML.d.ts","sourceRoot":"","sources":["../../../src/components/HTML/HTML.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,GAAG,EAIJ,MAAM,OAAO,CAAC;AACf,OAAe,EAAO,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAM9D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGtE,MAAM,WAAW,SAAU,SAAQ,SAAS,EAAE,cAAc;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,UAAU,wDA2CtB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,YAAY,2DA2BjD,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,YAAY,WAwDhD,CAAC;AAEF,eAAO,MAAM,UAAU,6EAmBrB,CAAC;AAIH,QAAA,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,GAAG,YAAY,CA6BrD,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -171,6 +171,7 @@ const HTML = forwardRef(({ content, ...restProps }, ref) => {
171
171
  node.removeAttribute('target');
172
172
  }
173
173
  }
174
+ node.removeAttribute('class');
174
175
  });
175
176
  setMounted(true);
176
177
  }, []);
@@ -1 +1 @@
1
- {"version":3,"file":"HTML.js","sourceRoot":"","sources":["../../../src/components/HTML/HTML.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAIV,QAAQ,EACR,SAAS,EACT,OAAO,EACR,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAgB,MAAM,mBAAmB,CAAC;AAC9D,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C5B,CAAC;AAEF,MAAM,CAAC,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AAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACvC,IAAI,IAAI,CAAC,OAAO,KAAK,GAAG,IAAI,IAAI,EAAE;gBAChC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;gBACpF,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE;oBACzC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;oBACtC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;iBACtC;qBAAM;oBACL,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;iBAChC;aACF;QACH,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,aAAa,CAAC,CAAC,CAAC,CACrB,KAAC,UAAU,IAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,GAAG,KAAM,SAAS,GAAI,CAC5F,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useState,\n useEffect,\n useMemo\n} from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\nimport dompurify from 'dompurify';\n\nimport { StyledPopover } from '../Popover';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize, FontSize } from '../../styles';\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { sameOrigin } from '../../utils';\n\nexport interface HTMLProps extends BaseProps, NoChildrenProp {\n content: string;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const listStyles = css`\n ul,\n ol {\n padding-inline-start: 2.5rem;\n }\n\n li {\n margin: 0.5rem 0;\n }\n\n ul li {\n ul {\n margin-inline-start: 1rem;\n list-style-type: circle;\n }\n\n ul ul {\n margin-inline-start: 2rem;\n list-style-type: square;\n }\n\n ul ul ul {\n margin-inline-start: 3rem;\n list-style-type: disc;\n }\n }\n\n ol li {\n ol {\n margin-inline-start: 1rem;\n list-style-type: lower-alpha;\n }\n\n ol ol {\n margin-inline-start: 2rem;\n list-style-type: lower-roman;\n }\n\n ol ol ol {\n margin-inline-start: 3rem;\n list-style-type: decimal;\n }\n }\n`;\n\nexport const getTableStyles = (theme: DefaultTheme) => css`\n border-collapse: collapse;\n\n td {\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n min-width: 6.25rem;\n }\n\n tr:first-child {\n td:first-child {\n border-top-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-top-right-radius: 0.125rem;\n }\n }\n\n tr:last-child {\n td:first-child {\n border-bottom-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-bottom-right-radius: 0.125rem;\n }\n }\n`;\n\nexport const getHtmlStyles = (theme: DefaultTheme) => {\n const {\n base: { 'font-size': baseFontSize, 'font-scale': baseFontScale, palette },\n components: { text }\n } = theme;\n const fontSize = calculateFontSize(baseFontSize, baseFontScale);\n return `\n ${listStyles}\n table {\n ${getTableStyles(theme)}\n }\n img {\n max-width: 100%;\n height: auto;\n border-radius: 0.25rem;\n }\n a {\n color: ${palette.interactive};\n }\n pre {\n white-space: break-spaces;\n }\n p {\n min-height: ${fontSize[text.primary['font-size'] as FontSize]};\n }\n h1 {\n font-size: ${fontSize[text.h1['font-size'] as FontSize]};\n font-weight: ${text.h1['font-weight']};\n min-height: ${fontSize[text.h1['font-size'] as FontSize]};\n }\n h2 {\n font-size: ${fontSize[text.h2['font-size'] as FontSize]};\n font-weight: ${text.h2['font-weight']};\n min-height: ${fontSize[text.h2['font-size'] as FontSize]};\n }\n h3 {\n font-size: ${fontSize[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n min-height: ${fontSize[text.h3['font-size'] as FontSize]};\n }\n h4 {\n font-size: ${fontSize[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n min-height: ${fontSize[text.h4['font-size'] as FontSize]};\n }\n h5 {\n font-size: ${fontSize[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n min-height: ${fontSize[text.h5['font-size'] as FontSize]};\n }\n h6 {\n font-size: ${fontSize[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n min-height: ${fontSize[text.h6['font-size'] as FontSize]};\n }\n `;\n};\n\nexport const StyledHTML = styled.div(({ theme }) => {\n return css`\n width: 100%;\n overflow-x: auto;\n ${getHtmlStyles(theme)}\n\n ${StyledPopover} ul {\n ul {\n padding-inline-start: 0;\n }\n ol {\n padding-inline-start: 0;\n }\n }\n\n ${StyledPopover} li {\n margin: 0;\n }\n `;\n});\n\nStyledHTML.defaultProps = defaultThemeProp;\n\nconst HTML: FunctionComponent<HTMLProps & ForwardProps> = forwardRef(\n ({ content, ...restProps }: PropsWithoutRef<HTMLProps>, ref: HTMLProps['ref']) => {\n const [mounted, setMounted] = useState(false);\n const sanitizedHtml = useMemo(() => {\n return mounted ? dompurify.sanitize(content) : '';\n }, [content, mounted]);\n\n useEffect(() => {\n dompurify.addHook('uponSanitizeAttribute', node => {\n const href = node.getAttribute('href');\n if (node.tagName === 'A' && href) {\n const fullURL = new URL(/^[a-z][a-z0-9.+-]*:/i.test(href) ? href : `https:${href}`);\n if (!sameOrigin(window.location, fullURL)) {\n node.setAttribute('target', '_blank');\n node.setAttribute('rel', 'noopener');\n } else {\n node.removeAttribute('target');\n }\n }\n });\n\n setMounted(true);\n }, []);\n\n return sanitizedHtml ? (\n <StyledHTML dangerouslySetInnerHTML={{ __html: sanitizedHtml }} ref={ref} {...restProps} />\n ) : null;\n }\n);\n\nexport default HTML;\n"]}
1
+ {"version":3,"file":"HTML.js","sourceRoot":"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AAO,aAAa,CAAC,CAAC,CAAC,CACrB,KAAC,UAAU,IAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,GAAG,KAAM,SAAS,GAAI,CAC5F,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useState,\n useEffect,\n useMemo\n} from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\nimport dompurify from 'dompurify';\n\nimport { StyledPopover } from '../Popover';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize, FontSize } from '../../styles';\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { sameOrigin } from '../../utils';\n\nexport interface HTMLProps extends BaseProps, NoChildrenProp {\n content: string;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const listStyles = css`\n ul,\n ol {\n padding-inline-start: 2.5rem;\n }\n\n li {\n margin: 0.5rem 0;\n }\n\n ul li {\n ul {\n margin-inline-start: 1rem;\n list-style-type: circle;\n }\n\n ul ul {\n margin-inline-start: 2rem;\n list-style-type: square;\n }\n\n ul ul ul {\n margin-inline-start: 3rem;\n list-style-type: disc;\n }\n }\n\n ol li {\n ol {\n margin-inline-start: 1rem;\n list-style-type: lower-alpha;\n }\n\n ol ol {\n margin-inline-start: 2rem;\n list-style-type: lower-roman;\n }\n\n ol ol ol {\n margin-inline-start: 3rem;\n list-style-type: decimal;\n }\n }\n`;\n\nexport const getTableStyles = (theme: DefaultTheme) => css`\n border-collapse: collapse;\n\n td {\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n min-width: 6.25rem;\n }\n\n tr:first-child {\n td:first-child {\n border-top-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-top-right-radius: 0.125rem;\n }\n }\n\n tr:last-child {\n td:first-child {\n border-bottom-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-bottom-right-radius: 0.125rem;\n }\n }\n`;\n\nexport const getHtmlStyles = (theme: DefaultTheme) => {\n const {\n base: { 'font-size': baseFontSize, 'font-scale': baseFontScale, palette },\n components: { text }\n } = theme;\n const fontSize = calculateFontSize(baseFontSize, baseFontScale);\n return `\n ${listStyles}\n table {\n ${getTableStyles(theme)}\n }\n img {\n max-width: 100%;\n height: auto;\n border-radius: 0.25rem;\n }\n a {\n color: ${palette.interactive};\n }\n pre {\n white-space: break-spaces;\n }\n p {\n min-height: ${fontSize[text.primary['font-size'] as FontSize]};\n }\n h1 {\n font-size: ${fontSize[text.h1['font-size'] as FontSize]};\n font-weight: ${text.h1['font-weight']};\n min-height: ${fontSize[text.h1['font-size'] as FontSize]};\n }\n h2 {\n font-size: ${fontSize[text.h2['font-size'] as FontSize]};\n font-weight: ${text.h2['font-weight']};\n min-height: ${fontSize[text.h2['font-size'] as FontSize]};\n }\n h3 {\n font-size: ${fontSize[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n min-height: ${fontSize[text.h3['font-size'] as FontSize]};\n }\n h4 {\n font-size: ${fontSize[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n min-height: ${fontSize[text.h4['font-size'] as FontSize]};\n }\n h5 {\n font-size: ${fontSize[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n min-height: ${fontSize[text.h5['font-size'] as FontSize]};\n }\n h6 {\n font-size: ${fontSize[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n min-height: ${fontSize[text.h6['font-size'] as FontSize]};\n }\n `;\n};\n\nexport const StyledHTML = styled.div(({ theme }) => {\n return css`\n width: 100%;\n overflow-x: auto;\n ${getHtmlStyles(theme)}\n\n ${StyledPopover} ul {\n ul {\n padding-inline-start: 0;\n }\n ol {\n padding-inline-start: 0;\n }\n }\n\n ${StyledPopover} li {\n margin: 0;\n }\n `;\n});\n\nStyledHTML.defaultProps = defaultThemeProp;\n\nconst HTML: FunctionComponent<HTMLProps & ForwardProps> = forwardRef(\n ({ content, ...restProps }: PropsWithoutRef<HTMLProps>, ref: HTMLProps['ref']) => {\n const [mounted, setMounted] = useState(false);\n const sanitizedHtml = useMemo(() => {\n return mounted ? dompurify.sanitize(content) : '';\n }, [content, mounted]);\n\n useEffect(() => {\n dompurify.addHook('uponSanitizeAttribute', node => {\n const href = node.getAttribute('href');\n if (node.tagName === 'A' && href) {\n const fullURL = new URL(/^[a-z][a-z0-9.+-]*:/i.test(href) ? href : `https:${href}`);\n if (!sameOrigin(window.location, fullURL)) {\n node.setAttribute('target', '_blank');\n node.setAttribute('rel', 'noopener');\n } else {\n node.removeAttribute('target');\n }\n }\n node.removeAttribute('class');\n });\n\n setMounted(true);\n }, []);\n\n return sanitizedHtml ? (\n <StyledHTML dangerouslySetInnerHTML={{ __html: sanitizedHtml }} ref={ref} {...restProps} />\n ) : null;\n }\n);\n\nexport default HTML;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../src/components/Link/Link.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,iBAAiB,EACjB,GAAG,EAMJ,MAAM,OAAO,CAAC;AAIf,OAAe,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAOtD,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C,oCAAoC;IACpC,QAAQ,EAAE,SAAS,CAAC;IACpB,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACjC;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,mFAAmF;IACnF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iFAAiF;IACjF,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE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AED,eAAO,MAAM,iBAAiB,yGAK7B,CAAC;AAIF,eAAO,MAAM,oBAAoB,oLA6D/B,CAAC;AAIH,eAAO,MAAM,UAAU,iJAAmB,CAAC;AAI3C,QAAA,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,GAAG,YAAY,CA4FrD,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -6,13 +6,18 @@ import Button from '../Button';
6
6
  import Popover from '../Popover';
7
7
  import BareButton from '../Button/BareButton';
8
8
  import { defaultThemeProp } from '../../theme';
9
- import { useBreakpoint, useConsolidatedRef, useI18n, useUID, useModalContext } from '../../hooks';
9
+ import { useBreakpoint, useConsolidatedRef, useI18n, useUID, useModalContext, useOS } from '../../hooks';
10
10
  import { tryCatch } from '../../utils';
11
11
  import { calculateFontSize } from '../../styles';
12
12
  import AppShellContext from '../AppShell/AppShellContext';
13
- export const StyledLinkPopover = styled.div `
14
- background-color: ${props => props.theme.components.tooltip['background-color']};
15
- `;
13
+ import { Keyboard } from '../Badges';
14
+ import Text, { StyledText } from '../Text';
15
+ import { StyledKeyboard } from '../Badges/Keyboard';
16
+ import Flex from '../Flex';
17
+ export const StyledLinkPopover = styled.div(({ theme }) => css `
18
+ background-color: ${theme.components.tooltip['background-color']};
19
+ padding: ${theme.base.spacing};
20
+ `);
16
21
  StyledLinkPopover.defaultProps = defaultThemeProp;
17
22
  export const StyledLinkPopoverBtn = styled(BareButton)(({ theme }) => {
18
23
  const contrastColor = tryCatch(() => readableColor(theme.base.palette.interactive));
@@ -22,12 +27,12 @@ export const StyledLinkPopoverBtn = styled(BareButton)(({ theme }) => {
22
27
  display: inline-flex;
23
28
  align-items: center;
24
29
  z-index: 1;
25
- padding: 0 ${theme.base.spacing};
26
30
  min-height: 1.5rem;
27
31
  line-height: 1;
28
32
  color: ${contrastColor};
29
33
  font-size: ${fontSize.xs};
30
34
  text-decoration: none;
35
+ width: 100%;
31
36
 
32
37
  /* FIXME: Button selector specificity... */
33
38
  & + & {
@@ -46,13 +51,33 @@ export const StyledLinkPopoverBtn = styled(BareButton)(({ theme }) => {
46
51
 
47
52
  &:hover,
48
53
  &:active {
49
- text-decoration: underline;
54
+ ${StyledText} span {
55
+ text-decoration: underline;
56
+ }
50
57
  }
51
58
 
52
59
  &:focus {
53
60
  box-shadow: inset 0 0 0 0.0625rem ${theme.base.palette.light},
54
61
  0 0 0.125rem 0.0625rem ${theme.base.palette.interactive};
55
62
  }
63
+
64
+ ${StyledText} {
65
+ display: flex;
66
+ justify-content: space-between;
67
+ align-items: center;
68
+ width: 100%;
69
+ }
70
+
71
+ ${StyledKeyboard} {
72
+ color: ${theme.base.palette.light};
73
+ background-color: ${theme.base.colors.gray.dark};
74
+ border-color: ${theme.base.colors.gray.medium};
75
+ inset-block-start: unset;
76
+
77
+ &:first-of-type {
78
+ margin-inline: ${theme.base.spacing};
79
+ }
80
+ }
56
81
  `;
57
82
  });
58
83
  StyledLinkPopoverBtn.defaultProps = defaultThemeProp;
@@ -65,9 +90,9 @@ const Link = forwardRef(({ href, variant = 'link', previewable, onPreview, ...re
65
90
  const linkRef = useConsolidatedRef(ref);
66
91
  const [popover, setPopover] = useState(false);
67
92
  const previewBtnRef = useRef(null);
68
- const openInTabBtnRef = useRef(null);
69
93
  const isSmallOrAbove = useBreakpoint('sm');
70
94
  const t = useI18n();
95
+ const { macintosh } = useOS();
71
96
  const openPopover = () => {
72
97
  if (isSmallOrAbove)
73
98
  setPopover(true);
@@ -75,22 +100,6 @@ const Link = forwardRef(({ href, variant = 'link', previewable, onPreview, ...re
75
100
  const closePopover = () => {
76
101
  setPopover(false);
77
102
  };
78
- const onKeyUp = (event) => {
79
- if (event.keyCode === 27) {
80
- closePopover();
81
- }
82
- if (event.keyCode === 38 || event.keyCode === 40) {
83
- previewBtnRef?.current?.focus();
84
- }
85
- if (event.keyCode === 37 || event.keyCode === 39) {
86
- if (previewBtnRef.current === document.activeElement) {
87
- openInTabBtnRef?.current?.focus();
88
- }
89
- else {
90
- previewBtnRef?.current?.focus();
91
- }
92
- }
93
- };
94
103
  const onEnterLink = () => {
95
104
  if (previewable)
96
105
  openPopover();
@@ -99,7 +108,12 @@ const Link = forwardRef(({ href, variant = 'link', previewable, onPreview, ...re
99
108
  previewTriggerRef.current = linkRef.current;
100
109
  onPreview?.({ href });
101
110
  };
102
- return (_jsxs(_Fragment, { children: [_jsx(StyledLink, { href: href, variant: variant, ref: linkRef, ...restProps, onMouseEnter: onEnterLink, onMouseLeave: closePopover, onFocus: onEnterLink, onKeyUp: onKeyUp, onBlur: closePopover, "aria-describedby": previewable ? `${uid}-preview-instructions` : undefined }), _jsxs(Popover, { show: popover, groupId: 'link_preview', showDelay: 'short', hideDelay: 'short', placement: 'bottom', target: linkRef.current, onMouseEnter: openPopover, onMouseLeave: closePopover, as: StyledLinkPopover, arrow: true, children: [!inModal && (_jsx(StyledLinkPopoverBtn, { preview: true, type: 'button', ref: previewBtnRef, onClick: onPreviewClick, tabIndex: '-1', onFocus: openPopover, onBlur: closePopover, onKeyUp: onKeyUp, children: t('preview') })), _jsx(StyledLinkPopoverBtn, { forwardedAs: 'a', href: href, ref: openInTabBtnRef, target: '_blank', rel: 'noreferrer', tabIndex: '-1', onFocus: openPopover, onBlur: closePopover, onKeyUp: onKeyUp, children: t('link_open_in_tab_text') })] }), previewable && (_jsx("span", { id: `${uid}-preview-instructions`, hidden: true, children: t('preview_link_arrow_navigation') }))] }));
111
+ const onKeyUp = (e) => {
112
+ if (e.getModifierState('Alt') && e.code === 'KeyP') {
113
+ onPreviewClick();
114
+ }
115
+ };
116
+ return (_jsxs(_Fragment, { children: [_jsx(StyledLink, { href: href, variant: variant, ref: linkRef, ...restProps, onMouseEnter: onEnterLink, onMouseLeave: closePopover, onFocus: onEnterLink, onBlur: closePopover, onKeyUp: onKeyUp, "aria-describedby": previewable ? `${uid}-preview-instructions` : undefined }), !inModal && (_jsx(Popover, { show: popover, groupId: 'link_preview', showDelay: 'short', hideDelay: 'short', placement: 'bottom', target: linkRef.current, onMouseEnter: openPopover, onMouseLeave: closePopover, as: StyledLinkPopover, arrow: true, children: _jsx(StyledLinkPopoverBtn, { preview: true, type: 'button', ref: previewBtnRef, onClick: onPreviewClick, tabIndex: '-1', children: _jsxs(Text, { children: [_jsx("span", { children: t('preview') }), _jsxs(Flex, { container: { inline: true, justify: 'end' }, children: [_jsx(Keyboard, { keyName: 'Alt' }), _jsx(Keyboard, { keyName: 'P' })] })] }) }) })), previewable && (_jsx("span", { id: `${uid}-preview-instructions`, hidden: true, children: t('preview_link_instruction', [macintosh ? 'option' : 'alt']) }))] }));
103
117
  });
104
118
  export default Link;
105
119
  //# sourceMappingURL=Link.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../../src/components/Link/Link.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,QAAQ,EACR,MAAM,EAEN,UAAU,EACX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,MAAuB,MAAM,WAAW,CAAC;AAChD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,eAAe,MAAM,6BAA6B,CAAC;AA2B1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;sBACrB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,k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,EAAE,OAAO,YAEf,CAAC,CAAC,uBAAuB,CAAC,GACN,IACf,EAET,WAAW,IAAI,CACd,eAAM,EAAE,EAAE,GAAG,GAAG,uBAAuB,EAAE,MAAM,kBAC5C,CAAC,CAAC,+BAA+B,CAAC,GAC9B,CACR,IACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n forwardRef,\n ReactNode,\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n useState,\n useRef,\n KeyboardEvent,\n useContext\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor } from 'polished';\n\nimport Button, { ButtonProps } from '../Button';\nimport Popover from '../Popover';\nimport BareButton from '../Button/BareButton';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { useBreakpoint, useConsolidatedRef, useI18n, useUID, useModalContext } from '../../hooks';\nimport { tryCatch } from '../../utils';\nimport { calculateFontSize } from '../../styles';\nimport AppShellContext from '../AppShell/AppShellContext';\n\nexport interface LinkProps extends BaseProps {\n /** Text or content for the Link. */\n children: ReactNode;\n /** URL or DOM id to navigate to. */\n href: string;\n /**\n * Controls the styling of the Link.\n * @default \"link\"\n */\n variant?: ButtonProps['variant'];\n /**\n * Set the Icon prop to `true` if you're using just an Icon in your Link. Make sure to pass an Icon as children if `true`.\n * @default false\n */\n icon?: ButtonProps['icon'];\n /** Determines if the Link should render a popover when focused or hovered over. */\n previewable?: boolean;\n /** Callback function that is run when the preview popover is interacted with. */\n onPreview?: (e: { href: string }) => void;\n /** Specifies where to open the link href. */\n target?: string;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLAnchorElement>;\n}\n\nexport const StyledLinkPopover = styled.div`\n background-color: ${props => props.theme.components.tooltip['background-color']};\n`;\n\nStyledLinkPopover.defaultProps = defaultThemeProp;\n\nexport const StyledLinkPopoverBtn = styled(BareButton)(({ theme }) => {\n const contrastColor = tryCatch(() => readableColor(theme.base.palette.interactive));\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n position: relative;\n display: inline-flex;\n align-items: center;\n z-index: 1;\n padding: 0 ${theme.base.spacing};\n min-height: 1.5rem;\n line-height: 1;\n color: ${contrastColor};\n font-size: ${fontSize.xs};\n text-decoration: none;\n\n /* FIXME: Button selector specificity... */\n & + & {\n margin: 0;\n }\n\n & + &::before {\n content: '';\n position: absolute;\n inset-inline-start: 0;\n inset-block: 0;\n width: 1px; /* stylelint-disable-line unit-allowed-list */\n background-color: ${contrastColor};\n opacity: ${theme.base.transparency['transparent-3']};\n }\n\n &:hover,\n &:active {\n text-decoration: underline;\n }\n\n &:focus {\n box-shadow: inset 0 0 0 0.0625rem ${theme.base.palette.light},\n 0 0 0.125rem 0.0625rem ${theme.base.palette.interactive};\n }\n `;\n});\n\nStyledLinkPopoverBtn.defaultProps = defaultThemeProp;\n\nexport const StyledLink = styled(Button)``;\n\nStyledLink.defaultProps = defaultThemeProp;\n\nconst Link: FunctionComponent<LinkProps & ForwardProps> = forwardRef(\n (\n { href, variant = 'link', previewable, onPreview, ...restProps }: PropsWithoutRef<LinkProps>,\n ref: LinkProps['ref']\n ) => {\n const { initialized: inModal } = useModalContext();\n const { previewTriggerRef } = useContext(AppShellContext);\n const uid = useUID();\n const linkRef = useConsolidatedRef(ref);\n const [popover, setPopover] = useState(false);\n const previewBtnRef = useRef<HTMLButtonElement>(null);\n const openInTabBtnRef = useRef<HTMLAnchorElement>(null);\n const isSmallOrAbove = useBreakpoint('sm');\n const t = useI18n();\n\n const openPopover = () => {\n if (isSmallOrAbove) setPopover(true);\n };\n\n const closePopover = () => {\n setPopover(false);\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (event.keyCode === 27) {\n closePopover();\n }\n\n if (event.keyCode === 38 || event.keyCode === 40) {\n previewBtnRef?.current?.focus();\n }\n\n if (event.keyCode === 37 || event.keyCode === 39) {\n if (previewBtnRef.current === document.activeElement) {\n openInTabBtnRef?.current?.focus();\n } else {\n previewBtnRef?.current?.focus();\n }\n }\n };\n\n const onEnterLink = () => {\n if (previewable) openPopover();\n };\n\n const onPreviewClick = () => {\n previewTriggerRef.current = linkRef.current;\n onPreview?.({ href });\n };\n\n return (\n <>\n <StyledLink\n href={href}\n variant={variant}\n ref={linkRef as any}\n {...restProps}\n onMouseEnter={onEnterLink}\n onMouseLeave={closePopover}\n onFocus={onEnterLink}\n onKeyUp={onKeyUp}\n onBlur={closePopover}\n aria-describedby={previewable ? `${uid}-preview-instructions` : undefined}\n />\n\n <Popover\n show={popover}\n groupId='link_preview'\n showDelay='short'\n hideDelay='short'\n placement='bottom'\n target={linkRef.current}\n onMouseEnter={openPopover}\n onMouseLeave={closePopover}\n as={StyledLinkPopover}\n arrow\n >\n {!inModal && (\n <StyledLinkPopoverBtn\n preview\n type='button'\n ref={previewBtnRef}\n onClick={onPreviewClick}\n tabIndex='-1'\n onFocus={openPopover}\n onBlur={closePopover}\n onKeyUp={onKeyUp}\n >\n {t('preview')}\n </StyledLinkPopoverBtn>\n )}\n <StyledLinkPopoverBtn\n forwardedAs='a'\n href={href}\n ref={openInTabBtnRef}\n target='_blank'\n rel='noreferrer'\n tabIndex='-1'\n onFocus={openPopover}\n onBlur={closePopover}\n onKeyUp={onKeyUp}\n >\n {t('link_open_in_tab_text')}\n </StyledLinkPopoverBtn>\n </Popover>\n\n {previewable && (\n <span id={`${uid}-preview-instructions`} hidden>\n {t('preview_link_arrow_navigation')}\n </span>\n )}\n </>\n );\n }\n);\n\nexport default Link;\n"]}
1
+ {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../../src/components/Link/Link.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,QAAQ,EACR,MAAM,EAEN,UAAU,EACX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,M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,EACtB,SAAS,EAAC,OAAO,EACjB,SAAS,EAAC,OAAO,EACjB,SAAS,EAAC,QAAQ,EAClB,MAAM,EAAE,OAAO,CAAC,OAAO,EACvB,YAAY,EAAE,WAAW,EACzB,YAAY,EAAE,YAAY,EAC1B,EAAE,EAAE,iBAAiB,EACrB,KAAK,kBAEL,KAAC,oBAAoB,IACnB,OAAO,QACP,IAAI,EAAC,QAAQ,EACb,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAC,IAAI,YAEb,MAAC,IAAI,eACH,yBAAO,CAAC,CAAC,SAAS,CAAC,GAAQ,EAC3B,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,aAC/C,KAAC,QAAQ,IAAC,OAAO,EAAC,KAAK,GAAG,EAC1B,KAAC,QAAQ,IAAC,OAAO,EAAC,GAAG,GAAG,IACnB,IACF,GACc,GACf,CACX,EAEA,WAAW,IAAI,CACd,eAAM,EAAE,EAAE,GAAG,GAAG,uBAAuB,EAAE,MAAM,kBAC5C,CAAC,CAAC,0BAA0B,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GACzD,CACR,IACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n forwardRef,\n ReactNode,\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n useState,\n useRef,\n KeyboardEvent,\n useContext\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor } from 'polished';\n\nimport Button, { ButtonProps } from '../Button';\nimport Popover from '../Popover';\nimport BareButton from '../Button/BareButton';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport {\n useBreakpoint,\n useConsolidatedRef,\n useI18n,\n useUID,\n useModalContext,\n useOS\n} from '../../hooks';\nimport { tryCatch } from '../../utils';\nimport { calculateFontSize } from '../../styles';\nimport AppShellContext from '../AppShell/AppShellContext';\nimport { Keyboard } from '../Badges';\nimport Text, { StyledText } from '../Text';\nimport { StyledKeyboard } from '../Badges/Keyboard';\nimport Flex from '../Flex';\n\nexport interface LinkProps extends BaseProps {\n /** Text or content for the Link. */\n children: ReactNode;\n /** URL or DOM id to navigate to. */\n href: string;\n /**\n * Controls the styling of the Link.\n * @default \"link\"\n */\n variant?: ButtonProps['variant'];\n /**\n * Set the Icon prop to `true` if you're using just an Icon in your Link. Make sure to pass an Icon as children if `true`.\n * @default false\n */\n icon?: ButtonProps['icon'];\n /** Determines if the Link should render a popover when focused or hovered over. */\n previewable?: boolean;\n /** Callback function that is run when the preview popover is interacted with. */\n onPreview?: (e: { href: string }) => void;\n /** Specifies where to open the link href. */\n target?: string;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLAnchorElement>;\n}\n\nexport const StyledLinkPopover = styled.div(\n ({ theme }) => css`\n background-color: ${theme.components.tooltip['background-color']};\n padding: ${theme.base.spacing};\n `\n);\n\nStyledLinkPopover.defaultProps = defaultThemeProp;\n\nexport const StyledLinkPopoverBtn = styled(BareButton)(({ theme }) => {\n const contrastColor = tryCatch(() => readableColor(theme.base.palette.interactive));\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n position: relative;\n display: inline-flex;\n align-items: center;\n z-index: 1;\n min-height: 1.5rem;\n line-height: 1;\n color: ${contrastColor};\n font-size: ${fontSize.xs};\n text-decoration: none;\n width: 100%;\n\n /* FIXME: Button selector specificity... */\n & + & {\n margin: 0;\n }\n\n & + &::before {\n content: '';\n position: absolute;\n inset-inline-start: 0;\n inset-block: 0;\n width: 1px; /* stylelint-disable-line unit-allowed-list */\n background-color: ${contrastColor};\n opacity: ${theme.base.transparency['transparent-3']};\n }\n\n &:hover,\n &:active {\n ${StyledText} span {\n text-decoration: underline;\n }\n }\n\n &:focus {\n box-shadow: inset 0 0 0 0.0625rem ${theme.base.palette.light},\n 0 0 0.125rem 0.0625rem ${theme.base.palette.interactive};\n }\n\n ${StyledText} {\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n }\n\n ${StyledKeyboard} {\n color: ${theme.base.palette.light};\n background-color: ${theme.base.colors.gray.dark};\n border-color: ${theme.base.colors.gray.medium};\n inset-block-start: unset;\n\n &:first-of-type {\n margin-inline: ${theme.base.spacing};\n }\n }\n `;\n});\n\nStyledLinkPopoverBtn.defaultProps = defaultThemeProp;\n\nexport const StyledLink = styled(Button)``;\n\nStyledLink.defaultProps = defaultThemeProp;\n\nconst Link: FunctionComponent<LinkProps & ForwardProps> = forwardRef(\n (\n { href, variant = 'link', previewable, onPreview, ...restProps }: PropsWithoutRef<LinkProps>,\n ref: LinkProps['ref']\n ) => {\n const { initialized: inModal } = useModalContext();\n const { previewTriggerRef } = useContext(AppShellContext);\n const uid = useUID();\n const linkRef = useConsolidatedRef(ref);\n const [popover, setPopover] = useState(false);\n const previewBtnRef = useRef<HTMLButtonElement>(null);\n const isSmallOrAbove = useBreakpoint('sm');\n const t = useI18n();\n const { macintosh } = useOS();\n\n const openPopover = () => {\n if (isSmallOrAbove) setPopover(true);\n };\n\n const closePopover = () => {\n setPopover(false);\n };\n\n const onEnterLink = () => {\n if (previewable) openPopover();\n };\n\n const onPreviewClick = () => {\n previewTriggerRef.current = linkRef.current;\n onPreview?.({ href });\n };\n\n const onKeyUp = (e: KeyboardEvent) => {\n if (e.getModifierState('Alt') && e.code === 'KeyP') {\n onPreviewClick();\n }\n };\n\n return (\n <>\n <StyledLink\n href={href}\n variant={variant}\n ref={linkRef as any}\n {...restProps}\n onMouseEnter={onEnterLink}\n onMouseLeave={closePopover}\n onFocus={onEnterLink}\n onBlur={closePopover}\n onKeyUp={onKeyUp}\n aria-describedby={previewable ? `${uid}-preview-instructions` : undefined}\n />\n\n {!inModal && (\n <Popover\n show={popover}\n groupId='link_preview'\n showDelay='short'\n hideDelay='short'\n placement='bottom'\n target={linkRef.current}\n onMouseEnter={openPopover}\n onMouseLeave={closePopover}\n as={StyledLinkPopover}\n arrow\n >\n <StyledLinkPopoverBtn\n preview\n type='button'\n ref={previewBtnRef}\n onClick={onPreviewClick}\n tabIndex='-1'\n >\n <Text>\n <span>{t('preview')}</span>\n <Flex container={{ inline: true, justify: 'end' }}>\n <Keyboard keyName='Alt' />\n <Keyboard keyName='P' />\n </Flex>\n </Text>\n </StyledLinkPopoverBtn>\n </Popover>\n )}\n\n {previewable && (\n <span id={`${uid}-preview-instructions`} hidden>\n {t('preview_link_instruction', [macintosh ? 'option' : 'alt'])}\n </span>\n )}\n </>\n );\n }\n);\n\nexport default Link;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ListToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAQlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAAU,YAAY,EAAE,MAAM,aAAa,CAAC;AAgBnD,OAAO,EACL,gBAAgB,EAKjB,MAAM,qBAAqB,CAAC;AAiH7B,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAgQnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"ListToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAOlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAAU,YAAY,EAAE,MAAM,aAAa,CAAC;AAqBnD,OAAO,EACL,gBAAgB,EAIjB,MAAM,qBAAqB,CAAC;AA2F7B,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAqRnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { forwardRef, useCallback, useEffect, useMemo, useState } from 'react';
2
+ import { forwardRef, useCallback, useMemo, useRef, useState } from 'react';
3
3
  import Actions from '../Actions';
4
4
  import Text from '../Text';
5
5
  import Button from '../Button';
@@ -16,7 +16,7 @@ import { hasProp } from '../../utils';
16
16
  import MenuButton from '../MenuButton';
17
17
  import { Count } from '../Badges';
18
18
  import PresetMenuPopover from './PresetMenuPopover';
19
- import { StyledViewSelector, StyledSearchForm, StyledListToolbar } from './ListToolbar.styles';
19
+ import { StyledViewSelector, StyledSearchForm, StyledListToolbar, StyledHeadingText } from './ListToolbar.styles';
20
20
  import QueryOptionPopover from './QueryOptionPopover';
21
21
  registerIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);
22
22
  const CountMeta = ({ count }) => {
@@ -27,7 +27,7 @@ const CountMeta = ({ count }) => {
27
27
  }), count.total !== undefined && count.selected !== undefined && ' ', count.selected !== undefined &&
28
28
  `(${t('selected_count', [count.selected], { count: count.selected })})`] }));
29
29
  };
30
- const QueryOptionButton = ({ id, queryOptionProps, iconOnly, setCurrentQueryOption }) => {
30
+ const QueryOptionButton = ({ id, queryOptionProps, iconOnly, onClick }) => {
31
31
  const t = useI18n();
32
32
  let i18nKey;
33
33
  let icon;
@@ -39,39 +39,17 @@ const QueryOptionButton = ({ id, queryOptionProps, iconOnly, setCurrentQueryOpti
39
39
  i18nKey = 'sort';
40
40
  icon = 'arrow-up-down';
41
41
  }
42
- else if (id === 'group') {
42
+ else {
43
43
  i18nKey = 'group';
44
44
  icon = 'row';
45
45
  }
46
46
  const text = t(i18nKey);
47
47
  const variant = iconOnly ? 'simple' : 'text';
48
- useEffect(() => {
49
- if (!queryOptionProps || !hasProp(queryOptionProps, 'renderer')) {
50
- return;
51
- }
52
- setCurrentQueryOption(cur => {
53
- if (!cur)
54
- return null;
55
- if (cur.id === id) {
56
- return {
57
- ...cur,
58
- props: queryOptionProps
59
- };
60
- }
61
- return cur;
62
- });
63
- }, [queryOptionProps, setCurrentQueryOption, id]);
64
48
  if (hasProp(queryOptionProps, 'renderer')) {
65
- return (_jsx("div", { children: _jsx(Button, { variant: variant, icon: iconOnly, label: iconOnly ? text : undefined, onClick: (e) => {
66
- setCurrentQueryOption({
67
- id,
68
- props: queryOptionProps,
69
- popoverTarget: e.currentTarget
70
- });
71
- }, children: _jsxs(Flex, { container: { inline: true, alignItems: 'center', gap: 1 }, as: 'span', children: [_jsx(Icon, { name: icon }), !iconOnly && text, !iconOnly && queryOptionProps.count && _jsx(Count, { children: queryOptionProps.count })] }) }) }));
49
+ return (_jsx("div", { children: _jsx(Button, { variant: variant, icon: iconOnly, label: iconOnly ? text : undefined, onClick: onClick, children: _jsxs(Flex, { container: { inline: true, alignItems: 'center', gap: 1 }, as: 'span', children: [_jsx(Icon, { name: icon }), !iconOnly && text, !iconOnly && queryOptionProps.count && _jsx(Count, { children: queryOptionProps.count })] }) }) }));
72
50
  }
73
51
  if (hasProp(queryOptionProps, 'items')) {
74
- return (_jsx("div", { children: _jsx(MenuButton, { variant: variant, text: text, icon: icon, iconOnly: iconOnly, count: queryOptionProps.count, menu: {
52
+ return (_jsx("div", { children: _jsx(MenuButton, { variant: variant, text: text, icon: icon, iconOnly: iconOnly, count: queryOptionProps.count, onClick: onClick, menu: {
75
53
  mode: queryOptionProps.mode,
76
54
  items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),
77
55
  onItemClick: queryOptionProps.onItemClick
@@ -79,33 +57,48 @@ const QueryOptionButton = ({ id, queryOptionProps, iconOnly, setCurrentQueryOpti
79
57
  }
80
58
  return null;
81
59
  };
82
- const ListToolbar = forwardRef(({ heading, onCreateNew, search, count, additionalActions, filter, sort, group, actions, actionsButtonRef, condensed }, ref) => {
60
+ const ListToolbar = forwardRef(({ heading, formControlProps, createNew, search, count, additionalActions, filter, sort, group, actions, actionsButtonRef, condensed }, ref) => {
83
61
  const t = useI18n();
84
62
  const isSmallOrAbove = useBreakpoint('sm');
85
63
  const isMediumOrAbove = useBreakpoint('md');
86
64
  const consolidatedActionsButtonRef = useConsolidatedRef(actionsButtonRef);
87
- const [queryOptionDialogState, setQueryOptionDialogState] = useState(null);
65
+ const [currentQueryOptionId, setCurrentQueryOptionId] = useState(null);
66
+ const queryOptionPopoverTarget = useRef();
88
67
  const [actionsQueryOptionPreset, setActionsQueryOptionPreset] = useState();
89
68
  const [optionPresetMenuOpen, setOptionPresetMenuOpen] = useState(false);
90
69
  const createNewButton = useMemo(() => {
91
- if (!onCreateNew)
70
+ if (!createNew?.onClick)
92
71
  return null;
93
- const text = t('create_new');
94
- return (_jsx(Button, { variant: isSmallOrAbove ? 'secondary' : 'simple', icon: !isSmallOrAbove, label: isSmallOrAbove ? undefined : text, onClick: onCreateNew, children: isSmallOrAbove ? _jsx("span", { children: text }) : _jsx(Icon, { name: 'plus' }) }));
95
- }, [t, onCreateNew, isSmallOrAbove]);
96
- const filterButton = filter && (_jsx(QueryOptionButton, { id: 'filter', queryOptionProps: filter, iconOnly: !isMediumOrAbove, setCurrentQueryOption: setQueryOptionDialogState }));
97
- const sortButton = sort && (_jsx(QueryOptionButton, { id: 'sort', queryOptionProps: sort, iconOnly: !isMediumOrAbove, setCurrentQueryOption: setQueryOptionDialogState }));
98
- const groupButton = group && (_jsx(QueryOptionButton, { id: 'group', queryOptionProps: group, iconOnly: !isMediumOrAbove, setCurrentQueryOption: setQueryOptionDialogState }));
99
- const onQueryOptionCancel = useCallback(() => {
100
- if (queryOptionDialogState?.props.onCancel() === false)
101
- return;
102
- setQueryOptionDialogState(null);
103
- }, [queryOptionDialogState]);
104
- const onQueryOptionSubmit = useCallback(() => {
105
- if (queryOptionDialogState?.props.onSubmit() === false)
106
- return;
107
- setQueryOptionDialogState(null);
108
- }, [queryOptionDialogState]);
72
+ const text = createNew.label ?? t('create_new');
73
+ return (_jsx(Button, { variant: isSmallOrAbove ? 'secondary' : 'simple', icon: !isSmallOrAbove, label: isSmallOrAbove ? undefined : text, "aria-label": text, onClick: createNew.onClick, children: isSmallOrAbove ? text : _jsx(Icon, { name: 'plus' }) }));
74
+ }, [t, createNew, isSmallOrAbove]);
75
+ const filterButton = filter && (_jsx(QueryOptionButton, { id: 'filter', queryOptionProps: filter, iconOnly: !isMediumOrAbove, onClick: e => {
76
+ setCurrentQueryOptionId('filter');
77
+ queryOptionPopoverTarget.current = e.currentTarget;
78
+ } }));
79
+ const sortButton = sort && (_jsx(QueryOptionButton, { id: 'sort', queryOptionProps: sort, iconOnly: !isMediumOrAbove, onClick: e => {
80
+ setCurrentQueryOptionId('sort');
81
+ queryOptionPopoverTarget.current = e.currentTarget;
82
+ } }));
83
+ const groupButton = group && (_jsx(QueryOptionButton, { id: 'group', queryOptionProps: group, iconOnly: !isMediumOrAbove, onClick: e => {
84
+ setCurrentQueryOptionId('group');
85
+ queryOptionPopoverTarget.current = e.currentTarget;
86
+ } }));
87
+ let queryOptionPopover = null;
88
+ if (currentQueryOptionId) {
89
+ const queryOptionProps = { filter, sort, group }[currentQueryOptionId];
90
+ if (queryOptionProps && hasProp(queryOptionProps, 'renderer')) {
91
+ queryOptionPopover = (_jsx(QueryOptionPopover, { target: queryOptionPopoverTarget.current, heading: t(`${currentQueryOptionId}_by`), onCancel: () => {
92
+ if (queryOptionProps.onCancel() === false)
93
+ return;
94
+ setCurrentQueryOptionId(null);
95
+ }, onSubmit: () => {
96
+ if (queryOptionProps.onSubmit() === false)
97
+ return;
98
+ setCurrentQueryOptionId(null);
99
+ }, children: _jsx(queryOptionProps.renderer, {}) }));
100
+ }
101
+ }
109
102
  const getQueryOptionAction = useCallback((id, icon, queryOptionProps) => {
110
103
  return {
111
104
  text: t(id),
@@ -114,11 +107,8 @@ const ListToolbar = forwardRef(({ heading, onCreateNew, search, count, additiona
114
107
  count: queryOptionProps.count,
115
108
  onClick: () => {
116
109
  if (hasProp(queryOptionProps, 'renderer')) {
117
- setQueryOptionDialogState({
118
- id,
119
- popoverTarget: consolidatedActionsButtonRef.current,
120
- props: queryOptionProps
121
- });
110
+ setCurrentQueryOptionId(id);
111
+ queryOptionPopoverTarget.current = consolidatedActionsButtonRef.current ?? undefined;
122
112
  }
123
113
  if (hasProp(queryOptionProps, 'items')) {
124
114
  setActionsQueryOptionPreset({
@@ -156,17 +146,20 @@ const ListToolbar = forwardRef(({ heading, onCreateNew, search, count, additiona
156
146
  return (_jsxs(Flex, { as: StyledListToolbar, container: { direction: 'column', gap: 2 }, item: { grow: 1 }, ref: ref, role: 'toolbar', children: [(heading ||
157
147
  createNewButton ||
158
148
  (condensed && (count || additionalActions || search || basicModeActions))) && (_jsxs(Flex, { container: { alignItems: 'start', justify: 'between', gap: 2 }, children: [_jsxs(Flex, { container: { alignItems: 'center', gap: 2, wrap: 'wrap' }, children: [heading &&
159
- (typeof heading === 'string' ? (_jsx(Text, { variant: 'h3', children: heading })) : (_jsx(StyledViewSelector, { variant: 'text', text: heading.views.find(view => view.selected)?.text ?? heading.views[0].text, menu: {
149
+ (typeof heading === 'string' ? (_jsx(StyledHeadingText, { variant: 'h3', required: formControlProps?.required, children: heading })) : (_jsx(StyledViewSelector, { variant: 'text', text: heading.views.find(view => view.selected)?.text ?? heading.views[0].text, menu: {
160
150
  mode: 'single-select',
161
- items: heading.views.map(view => ({ ...view, primary: view.text })),
151
+ items: heading.views.map(view => ({
152
+ ...view,
153
+ primary: `${view.text}${view.id === heading.defaultId ? ` (${t('default')})` : ''}${view.id === heading.appDefaultId ? ` (${t('app_default')})` : ''}`
154
+ })),
162
155
  onItemClick: heading.onViewSelect
163
- } }))), isSmallOrAbove && condensed && (_jsxs(_Fragment, { children: [count && _jsx(CountMeta, { count: count }), additionalActions] }))] }), _jsxs(Flex, { container: { alignItems: 'center', gap: 2 }, children: [search && condensed && isSmallOrAbove && _jsx(SearchInput, { ...search }), createNewButton, condensed && basicModeActions && (_jsx("span", { children: _jsx(Actions, { items: basicModeActions.map(({ icon, ...restProps }) => ({
156
+ }, required: formControlProps?.required }))), isSmallOrAbove && condensed && (_jsxs(_Fragment, { children: [count && _jsx(CountMeta, { count: count }), additionalActions] }))] }), _jsxs(Flex, { container: { alignItems: 'center', gap: 2 }, children: [search && condensed && isSmallOrAbove && _jsx(SearchInput, { ...search }), createNewButton, condensed && basicModeActions && (_jsx("span", { children: _jsx(Actions, { items: basicModeActions.map(({ icon, ...restProps }) => ({
164
157
  visual: icon ? _jsx(Icon, { name: icon }) : undefined,
165
158
  ...restProps
166
159
  })), menuAt: 1, ref: consolidatedActionsButtonRef }) }))] })] })), (!condensed || !isSmallOrAbove) && (_jsxs(Flex, { container: { alignItems: 'start', justify: 'between', gap: 2 }, children: [_jsxs(Flex, { as: StyledSearchForm, container: { alignItems: 'center', wrap: 'wrap', gap: 2 }, item: { grow: 1 }, children: [search && _jsx(SearchInput, { ...search }), isSmallOrAbove && !condensed && (_jsxs(_Fragment, { children: [count && _jsx(CountMeta, { count: count }), additionalActions] }))] }), !condensed && (filterButton || sortButton || groupButton || actions) && (_jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, md: { container: { gap: 2 } }, children: [_jsxs(_Fragment, { children: [filterButton, sortButton, groupButton] }), actions && (_jsx(Actions, { items: actions.map(({ icon, ...restProps }) => ({
167
160
  visual: icon ? _jsx(Icon, { name: icon }) : undefined,
168
161
  ...restProps
169
- })), menuAt: 1, ref: consolidatedActionsButtonRef }))] }))] })), !isSmallOrAbove && (count || additionalActions) && (_jsxs(Flex, { container: { alignItems: 'center', wrap: 'wrap', gap: 2 }, children: [count && _jsx(CountMeta, { count: count }), additionalActions] })), queryOptionDialogState && (_jsx(QueryOptionPopover, { target: queryOptionDialogState.popoverTarget, heading: t(`${queryOptionDialogState.id}_by`), onCancel: onQueryOptionCancel, onSubmit: onQueryOptionSubmit, children: _jsx(queryOptionDialogState.props.renderer, {}) })), condensed && (_jsx(PresetMenuPopover, { buttonRef: consolidatedActionsButtonRef, heading: actionsQueryOptionPreset?.heading, menu: actionsQueryOptionPreset?.menu, isOpen: optionPresetMenuOpen, onClose: () => setOptionPresetMenuOpen(false) }))] }));
162
+ })), menuAt: 1, ref: consolidatedActionsButtonRef }))] }))] })), !isSmallOrAbove && (count || additionalActions) && (_jsxs(Flex, { container: { alignItems: 'center', wrap: 'wrap', gap: 2 }, children: [count && _jsx(CountMeta, { count: count }), additionalActions] })), queryOptionPopover, condensed && (_jsx(PresetMenuPopover, { buttonRef: consolidatedActionsButtonRef, heading: actionsQueryOptionPreset?.heading, menu: actionsQueryOptionPreset?.menu, isOpen: optionPresetMenuOpen, onClose: () => setOptionPresetMenuOpen(false) }))] }));
170
163
  });
171
164
  export default ListToolbar;
172
165
  //# sourceMappingURL=ListToolbar.js.map