@pega/cosmos-react-core 7.0.0-build.22.3 → 7.0.0-build.22.30

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 (173) hide show
  1. package/lib/components/AIButton/AIButton.d.ts +30 -2
  2. package/lib/components/AIButton/AIButton.d.ts.map +1 -1
  3. package/lib/components/AIButton/AIButton.js +4 -3
  4. package/lib/components/AIButton/AIButton.js.map +1 -1
  5. package/lib/components/AppShell/AppHeader.d.ts.map +1 -1
  6. package/lib/components/AppShell/AppHeader.js +4 -6
  7. package/lib/components/AppShell/AppHeader.js.map +1 -1
  8. package/lib/components/AppShell/AppHeader.styles.d.ts.map +1 -1
  9. package/lib/components/AppShell/AppHeader.styles.js +6 -2
  10. package/lib/components/AppShell/AppHeader.styles.js.map +1 -1
  11. package/lib/components/AppShell/AppShell.d.ts.map +1 -1
  12. package/lib/components/AppShell/AppShell.js +2 -1
  13. package/lib/components/AppShell/AppShell.js.map +1 -1
  14. package/lib/components/AppShell/AppShell.styles.d.ts +3 -0
  15. package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
  16. package/lib/components/AppShell/AppShell.styles.js +12 -0
  17. package/lib/components/AppShell/AppShell.styles.js.map +1 -1
  18. package/lib/components/AppShell/AppShell.types.d.ts +4 -0
  19. package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
  20. package/lib/components/AppShell/AppShell.types.js.map +1 -1
  21. package/lib/components/AppShell/NavigationList.d.ts.map +1 -1
  22. package/lib/components/AppShell/NavigationList.js +3 -3
  23. package/lib/components/AppShell/NavigationList.js.map +1 -1
  24. package/lib/components/AppShell/NavigationListItemWrapper.d.ts.map +1 -1
  25. package/lib/components/AppShell/NavigationListItemWrapper.js +1 -0
  26. package/lib/components/AppShell/NavigationListItemWrapper.js.map +1 -1
  27. package/lib/components/Banner/Banner.d.ts.map +1 -1
  28. package/lib/components/Banner/Banner.js +1 -1
  29. package/lib/components/Banner/Banner.js.map +1 -1
  30. package/lib/components/Button/Button.d.ts.map +1 -1
  31. package/lib/components/Button/Button.js +67 -35
  32. package/lib/components/Button/Button.js.map +1 -1
  33. package/lib/components/Card/Card.d.ts.map +1 -1
  34. package/lib/components/Card/Card.js +8 -0
  35. package/lib/components/Card/Card.js.map +1 -1
  36. package/lib/components/ColorPicker/ColorPicker.js +1 -1
  37. package/lib/components/ColorPicker/ColorPicker.js.map +1 -1
  38. package/lib/components/ComboBox/ComboBox.styles.d.ts.map +1 -1
  39. package/lib/components/ComboBox/ComboBox.styles.js +4 -0
  40. package/lib/components/ComboBox/ComboBox.styles.js.map +1 -1
  41. package/lib/components/Configuration/Configuration.d.ts +1 -0
  42. package/lib/components/Configuration/Configuration.d.ts.map +1 -1
  43. package/lib/components/Configuration/Configuration.js +58 -30
  44. package/lib/components/Configuration/Configuration.js.map +1 -1
  45. package/lib/components/Configuration/connected-watcher.d.ts +17 -0
  46. package/lib/components/Configuration/connected-watcher.d.ts.map +1 -0
  47. package/lib/components/Configuration/connected-watcher.js +13 -0
  48. package/lib/components/Configuration/connected-watcher.js.map +1 -0
  49. package/lib/components/DateTime/Input/MonthInput.d.ts.map +1 -1
  50. package/lib/components/DateTime/Input/MonthInput.js +21 -10
  51. package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
  52. package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
  53. package/lib/components/DateTime/Picker/DatePicker.js +5 -32
  54. package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
  55. package/lib/components/DateTime/Picker/utils.d.ts +9 -0
  56. package/lib/components/DateTime/Picker/utils.d.ts.map +1 -1
  57. package/lib/components/DateTime/Picker/utils.js +16 -0
  58. package/lib/components/DateTime/Picker/utils.js.map +1 -1
  59. package/lib/components/File/CompactList.js +1 -1
  60. package/lib/components/File/CompactList.js.map +1 -1
  61. package/lib/components/File/FileDisplayList.d.ts +2 -1
  62. package/lib/components/File/FileDisplayList.d.ts.map +1 -1
  63. package/lib/components/File/FileDisplayList.js +3 -2
  64. package/lib/components/File/FileDisplayList.js.map +1 -1
  65. package/lib/components/File/FileInput.d.ts +30 -6
  66. package/lib/components/File/FileInput.d.ts.map +1 -1
  67. package/lib/components/File/FileInput.js +135 -96
  68. package/lib/components/File/FileInput.js.map +1 -1
  69. package/lib/components/File/FileInput.styles.d.ts +24 -0
  70. package/lib/components/File/FileInput.styles.d.ts.map +1 -0
  71. package/lib/components/File/FileInput.styles.js +154 -0
  72. package/lib/components/File/FileInput.styles.js.map +1 -0
  73. package/lib/components/File/FileItem.d.ts +3 -0
  74. package/lib/components/File/FileItem.d.ts.map +1 -1
  75. package/lib/components/File/FileItem.js +3 -4
  76. package/lib/components/File/FileItem.js.map +1 -1
  77. package/lib/components/File/FileList.d.ts +6 -3
  78. package/lib/components/File/FileList.d.ts.map +1 -1
  79. package/lib/components/File/FileList.js +25 -7
  80. package/lib/components/File/FileList.js.map +1 -1
  81. package/lib/components/Fullscreen/Fullscreen.d.ts +18 -0
  82. package/lib/components/Fullscreen/Fullscreen.d.ts.map +1 -0
  83. package/lib/components/Fullscreen/Fullscreen.js +51 -0
  84. package/lib/components/Fullscreen/Fullscreen.js.map +1 -0
  85. package/lib/components/Fullscreen/Fullscreen.test-ids.d.ts +2 -0
  86. package/lib/components/Fullscreen/Fullscreen.test-ids.d.ts.map +1 -0
  87. package/lib/components/Fullscreen/Fullscreen.test-ids.js +3 -0
  88. package/lib/components/Fullscreen/Fullscreen.test-ids.js.map +1 -0
  89. package/lib/components/Fullscreen/FullscreenButton.d.ts +6 -0
  90. package/lib/components/Fullscreen/FullscreenButton.d.ts.map +1 -0
  91. package/lib/components/Fullscreen/FullscreenButton.js +33 -0
  92. package/lib/components/Fullscreen/FullscreenButton.js.map +1 -0
  93. package/lib/components/Fullscreen/index.d.ts +4 -0
  94. package/lib/components/Fullscreen/index.d.ts.map +1 -0
  95. package/lib/components/Fullscreen/index.js +4 -0
  96. package/lib/components/Fullscreen/index.js.map +1 -0
  97. package/lib/components/Icon/streamline-icons/dock.icon.d.ts +5 -0
  98. package/lib/components/Icon/streamline-icons/dock.icon.d.ts.map +1 -0
  99. package/lib/components/Icon/streamline-icons/dock.icon.js +7 -0
  100. package/lib/components/Icon/streamline-icons/dock.icon.js.map +1 -0
  101. package/lib/components/Icon/streamline-icons/undock.icon.d.ts +5 -0
  102. package/lib/components/Icon/streamline-icons/undock.icon.d.ts.map +1 -0
  103. package/lib/components/Icon/streamline-icons/undock.icon.js +7 -0
  104. package/lib/components/Icon/streamline-icons/undock.icon.js.map +1 -0
  105. package/lib/components/Icon/streamlineIconNames.d.ts +1 -1
  106. package/lib/components/Icon/streamlineIconNames.d.ts.map +1 -1
  107. package/lib/components/Icon/streamlineIconNames.js +2 -0
  108. package/lib/components/Icon/streamlineIconNames.js.map +1 -1
  109. package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
  110. package/lib/components/ListToolbar/ListToolbar.js +3 -2
  111. package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
  112. package/lib/components/Location/Location.types.d.ts +1 -0
  113. package/lib/components/Location/Location.types.d.ts.map +1 -1
  114. package/lib/components/Location/Location.types.js.map +1 -1
  115. package/lib/components/Location/LocationView.d.ts.map +1 -1
  116. package/lib/components/Location/LocationView.js +31 -7
  117. package/lib/components/Location/LocationView.js.map +1 -1
  118. package/lib/components/Location/utils.d.ts.map +1 -1
  119. package/lib/components/Location/utils.js +23 -21
  120. package/lib/components/Location/utils.js.map +1 -1
  121. package/lib/components/Modal/ModalManager.d.ts.map +1 -1
  122. package/lib/components/Modal/ModalManager.js +5 -1
  123. package/lib/components/Modal/ModalManager.js.map +1 -1
  124. package/lib/components/PageTemplates/PageTemplates.d.ts +1 -0
  125. package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -1
  126. package/lib/components/PageTemplates/PageTemplates.js +82 -29
  127. package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
  128. package/lib/components/Popover/modifiers.js +4 -4
  129. package/lib/components/Popover/modifiers.js.map +1 -1
  130. package/lib/components/Tabs/Tab.d.ts.map +1 -1
  131. package/lib/components/Tabs/Tab.js +4 -0
  132. package/lib/components/Tabs/Tab.js.map +1 -1
  133. package/lib/components/Toaster/Toaster.d.ts +1 -1
  134. package/lib/components/Toaster/Toaster.d.ts.map +1 -1
  135. package/lib/components/Toaster/Toaster.js +79 -19
  136. package/lib/components/Toaster/Toaster.js.map +1 -1
  137. package/lib/components/Toaster/Toaster.types.d.ts +17 -4
  138. package/lib/components/Toaster/Toaster.types.d.ts.map +1 -1
  139. package/lib/components/Toaster/Toaster.types.js.map +1 -1
  140. package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
  141. package/lib/components/Tooltip/Tooltip.js +3 -1
  142. package/lib/components/Tooltip/Tooltip.js.map +1 -1
  143. package/lib/hooks/useArrows.d.ts.map +1 -1
  144. package/lib/hooks/useArrows.js +3 -1
  145. package/lib/hooks/useArrows.js.map +1 -1
  146. package/lib/hooks/useI18n.d.ts +27 -0
  147. package/lib/hooks/useI18n.d.ts.map +1 -1
  148. package/lib/hooks/useScrollToggle.d.ts.map +1 -1
  149. package/lib/hooks/useScrollToggle.js +1 -0
  150. package/lib/hooks/useScrollToggle.js.map +1 -1
  151. package/lib/i18n/default.d.ts +27 -0
  152. package/lib/i18n/default.d.ts.map +1 -1
  153. package/lib/i18n/default.js +31 -1
  154. package/lib/i18n/default.js.map +1 -1
  155. package/lib/i18n/i18n.d.ts +27 -0
  156. package/lib/i18n/i18n.d.ts.map +1 -1
  157. package/lib/index.d.ts +2 -0
  158. package/lib/index.d.ts.map +1 -1
  159. package/lib/index.js +2 -0
  160. package/lib/index.js.map +1 -1
  161. package/lib/theme/theme.d.ts +6 -0
  162. package/lib/theme/theme.d.ts.map +1 -1
  163. package/lib/theme/themeDefinition.json +5 -1
  164. package/lib/theme/themeOverrides.schema.json +3 -0
  165. package/lib/utils/index.d.ts +1 -0
  166. package/lib/utils/index.d.ts.map +1 -1
  167. package/lib/utils/index.js +1 -0
  168. package/lib/utils/index.js.map +1 -1
  169. package/lib/utils/isPositionWithinRect.d.ts +12 -0
  170. package/lib/utils/isPositionWithinRect.d.ts.map +1 -0
  171. package/lib/utils/isPositionWithinRect.js +11 -0
  172. package/lib/utils/isPositionWithinRect.js.map +1 -0
  173. package/package.json +7 -4
@@ -1 +1 @@
1
- {"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../src/components/Banner/Banner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAU/C,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,iBAAiB,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,oBAAoB,MAAM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mBACQ,OAAO,CAAC,OAAO,EAC5B,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,gBACP,CAAC,CAAC,kCAAkC,CAAC,EACjD,OAAO,EAAC,QAAQ,EAChB,IAAI,kBAEJ,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,CACV,GACI,IACF,EACP,KAAC,cAAc,IAAC,SAAS,EAAE,SAAS,YAClC,KAAC,uBAAuB,IAAC,KAAK,EAAE,gBAAgB,GAAI,GACrC,IACG,CACvB,IACI,CACR,CAAC;AACJ,CAAC,CAAC,EACF,gBAAgB,CACjB,CAAC","sourcesContent":["import { useState, forwardRef, useMemo, useImperativeHandle } from 'react';\nimport type { PropsWithoutRef, Ref, MouseEventHandler, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\nimport { getContrast } from 'polished';\n\nimport { defaultThemeProp } from '../../theme';\nimport type {\n ForwardProps,\n HeadingTag,\n NoChildrenProp,\n OmitStrict,\n RefElement,\n TestIdProp,\n WithAttributes\n} from '../../types';\nimport Button, { StyledButton } from '../Button';\nimport { focusHeadingOrContainer, tryCatch, withTestIds } from '../../utils';\nimport { useConsolidatedRef, useDirection, useI18n, useTestIds } from '../../hooks';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Grid from '../Grid';\nimport ExpandCollapse from '../ExpandCollapse';\nimport { Count } from '../Badges';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport * as flagWaveSolidIcon from '../Icon/icons/flag-wave-solid.icon';\nimport * as informationSolidIcon from '../Icon/icons/information-solid.icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport { UnorderedList } from '../List';\nimport { readableColor } from '../../styles';\n\nimport { getBannerTestIds } from './Banner.test-ids';\n\nregisterIcon(\n timesIcon,\n caretRightIcon,\n warnSolidIcon,\n flagWaveSolidIcon,\n informationSolidIcon,\n checkIcon\n);\n\nexport interface BannerHandleValue {\n /** Used to apply focus to the banner via an imperative handle. */\n focus: () => void;\n}\n\nexport interface BannerMessage {\n label: string;\n description?: string;\n action?: {\n text: string;\n onClick?: MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>;\n href?: string;\n };\n items?: (BannerMessage | string)[];\n}\n\nexport type BannerProps = WithAttributes<\n 'div',\n TestIdProp &\n NoChildrenProp & {\n /** Controls the styling of the Banner. */ variant: 'urgent' | 'warning' | 'success' | 'info';\n /**\n * The heading tag to render the provided heading as. This is agnostic to the styling of the heading.\n * @default 'h2'\n */\n headingTag?: HeadingTag;\n /** Pass one or more descriptive messages to inform the user. */\n messages: (string | BannerMessage)[];\n /** Callback when user explicitly dismisses the Banner. */\n onDismiss?: MouseEventHandler;\n /** Ref that can be used to access the imperative handle. */\n handle?: Ref<BannerHandleValue>;\n }\n>;\n\nexport const StyledBanner = styled.div<{ headingTag: BannerProps['headingTag'] }>(\n ({ headingTag, theme }) => {\n return css`\n border-radius: ${theme.components.card['border-radius']};\n min-inline-size: 100%;\n inline-size: 0;\n\n &:has(${headingTag}:focus) {\n box-shadow: ${theme.base.shadow.focus};\n }\n `;\n }\n);\n\nStyledBanner.defaultProps = defaultThemeProp;\n\nexport const StyledBannerStatus = styled.div<Pick<BannerProps, 'variant'>>(({ variant, theme }) => {\n const { background } = theme.components.banner[variant];\n const color = tryCatch(() =>\n getContrast(background, theme.base.palette['primary-background']) >= 3\n ? theme.base.palette['primary-background']\n : readableColor(background)\n );\n\n return css`\n background-color: ${background};\n color: ${color};\n border-start-start-radius: inherit;\n border-end-start-radius: inherit;\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-inline-end: none;\n font-size: 1.25rem;\n `;\n});\n\nStyledBannerStatus.defaultProps = defaultThemeProp;\n\nexport const StyledBannerHeader = styled.div(({ theme }) => {\n const { rtl } = useDirection();\n\n return css`\n min-height: 2.125rem;\n\n ${StyledButton}[aria-expanded] {\n ${StyledIcon} {\n transition: rotate ${theme.base.animation.speed} ${theme.base.animation.timing.ease};\n }\n\n &[aria-expanded='true'] ${StyledIcon} {\n rotate: 90deg;\n }\n\n &[aria-expanded='false'] ${StyledIcon} {\n rotate: ${rtl ? 180 : 0}deg;\n }\n }\n `;\n});\n\nStyledBannerHeader.defaultProps = defaultThemeProp;\n\nexport const StyledBannerContent = styled.div<{ expandable?: boolean }>(({ expandable, theme }) => {\n return css`\n background: ${theme.components.card.background};\n padding-block: calc(0.5 * ${theme.base.spacing});\n padding-inline-start: calc(${expandable ? 0.5 : 2} * ${theme.base.spacing});\n padding-inline-end: calc(0.5 * ${theme.base.spacing});\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-inline-start: none;\n border-start-end-radius: inherit;\n border-end-end-radius: inherit;\n `;\n});\n\nStyledBannerContent.defaultProps = defaultThemeProp;\n\nexport const StyledBannerMessageList = styled(UnorderedList)(\n ({ theme }) => css`\n padding-block-end: calc(0.5 * ${theme.base.spacing});\n padding-inline-start: calc(5 * ${theme.base.spacing});\n padding-inline-end: calc(2 * ${theme.base.spacing});\n `\n);\n\nStyledBannerMessageList.defaultProps = defaultThemeProp;\n\nexport const StyledBannerMessage = styled.span`\n overflow-wrap: break-word;\n list-style: none;\n`;\n\nStyledBannerMessage.defaultProps = defaultThemeProp;\n\nconst BannerMessageItem = forwardRef<\n HTMLLIElement,\n TestIdProp & OmitStrict<BannerMessage, 'items'> & ForwardProps\n>(function BannerMessageItem({ testId, label, description, action, ...restProps }, ref) {\n const testIds = useTestIds(testId, getBannerTestIds);\n\n return (\n <StyledBannerMessage {...restProps} ref={ref}>\n <span data-testid={testIds.messageLabel}>{label}</span>\n {description && (\n <>\n {' '}\n <Text data-testid={testIds.messageDescription} variant='secondary'>\n {description}\n </Text>\n </>\n )}\n {action && (\n <>\n {' '}\n <Text variant='secondary'>\n <Button\n data-testid={testIds.messageAction}\n variant='link'\n href={action.href}\n onClick={action.onClick}\n {...action}\n >\n {action.text}\n </Button>\n </Text>\n </>\n )}\n </StyledBannerMessage>\n );\n});\n\nconst prepareMessages = (\n messages: (string | BannerMessage)[],\n testId: TestIdProp['testId']\n): [messages: ReactNode[], count: number] => {\n let count = 0;\n\n return [\n messages.flatMap(msg => {\n count += 1;\n\n if (typeof msg === 'string') {\n return [<BannerMessageItem label={msg} />];\n }\n\n if (msg.items) {\n const { items, ...restMsg } = msg;\n const [subMessages, subCount] = prepareMessages(items, testId);\n count += subCount;\n return [<BannerMessageItem {...restMsg} testId={testId} />, subMessages];\n }\n\n return [<BannerMessageItem {...msg} testId={testId} />];\n }),\n count\n ];\n};\n\nexport default withTestIds(\n forwardRef<RefElement<BannerProps>, PropsWithoutRef<BannerProps>>(function Banner(\n { testId, variant, headingTag = 'h2', messages, onDismiss, handle, ...restProps },\n ref\n ) {\n const testIds = useTestIds(testId, getBannerTestIds);\n const [messagesToRender, count] = useMemo(() => prepareMessages(messages, testId), [messages]);\n const t = useI18n();\n const [collapsed, setCollapsed] = useState(count > 2);\n\n const bannerRef = useConsolidatedRef(ref);\n\n let role: string;\n let icon: string;\n let heading: string;\n let ariaLive: string;\n\n switch (variant) {\n case 'urgent':\n heading = t('error');\n icon = 'warn-solid';\n role = 'alert';\n ariaLive = 'assertive';\n break;\n case 'warning':\n heading = t('warning');\n icon = 'flag-wave-solid';\n role = 'alert';\n ariaLive = 'assertive';\n break;\n case 'success':\n heading = t('success');\n icon = 'check';\n role = 'none';\n ariaLive = 'polite';\n break;\n case 'info':\n default:\n heading = t('information');\n icon = 'information-solid';\n role = 'none';\n ariaLive = 'polite';\n break;\n }\n\n useImperativeHandle(\n handle,\n () => ({\n focus: () => {\n // Empty timeout ensures that the banner will take focus after any other programmatic focus events\n setTimeout(() => {\n if (bannerRef.current) {\n focusHeadingOrContainer(bannerRef.current, heading);\n }\n });\n }\n }),\n []\n );\n\n return (\n <Grid\n data-testid={testIds.root}\n {...restProps}\n as={StyledBanner}\n container={{ cols: '2rem minmax(0, 1fr)' }}\n role={role}\n aria-live={ariaLive}\n headingTag={headingTag}\n ref={bannerRef}\n >\n <Flex\n as={StyledBannerStatus}\n container={{ justify: 'center', alignItems: 'start', pad: [1.5, 0] }}\n variant={variant}\n >\n <Icon name={icon} />\n </Flex>\n {count === 1 ? (\n <Flex container={{ alignItems: 'start' }} as={StyledBannerContent}>\n <VisuallyHiddenText as={headingTag}>{`${heading} ${count}`}</VisuallyHiddenText>\n <Flex item={{ alignSelf: 'center', grow: 1 }} as='ul'>\n {typeof messages[0] === 'string' ? (\n <BannerMessageItem testId={testId} label={messages[0]} as='li' />\n ) : (\n <BannerMessageItem {...messages[0]} testId={testId} as='li' />\n )}\n </Flex>\n {onDismiss && (\n <Button\n data-testid={testIds.dismiss}\n onClick={onDismiss}\n label={t('dismiss')}\n aria-label={t('banner_dismiss_button_label_a11y')}\n variant='simple'\n icon\n >\n <Icon name='times' />\n </Button>\n )}\n </Flex>\n ) : (\n <StyledBannerContent expandable>\n <Grid\n as={StyledBannerHeader}\n container={{ cols: 'auto 1fr auto', areas: '\"toggle heading dismiss\"', gap: 0.5 }}\n >\n <Grid\n data-testid={testIds.heading}\n container={{ cols: 'min-content min-content', gap: 0.5, alignItems: 'center' }}\n item={{ area: 'heading', alignSelf: 'center' }}\n as={Text}\n forwardedAs={headingTag}\n variant='h2'\n >\n {heading} <Count>{count}</Count>\n </Grid>\n <Grid item={{ area: 'toggle', alignSelf: 'center' }}>\n <Button\n data-testid={testIds.expandCollapse}\n onClick={() => {\n setCollapsed(cur => !cur);\n }}\n label={t(collapsed ? 'expand' : 'collapse')}\n aria-expanded={collapsed ? 'false' : 'true'}\n variant='simple'\n icon\n >\n <Icon name='caret-right' />\n </Button>\n </Grid>\n <Grid item={{ area: 'dismiss', alignSelf: 'center' }}>\n {onDismiss && (\n <Button\n data-testid={testIds.dismiss}\n onClick={onDismiss}\n label={t('dismiss')}\n aria-label={t('banner_dismiss_button_label_a11y')}\n variant='simple'\n icon\n >\n <Icon name='times' />\n </Button>\n )}\n </Grid>\n </Grid>\n <ExpandCollapse collapsed={collapsed}>\n <StyledBannerMessageList items={messagesToRender} />\n </ExpandCollapse>\n </StyledBannerContent>\n )}\n </Grid>\n );\n }),\n getBannerTestIds\n);\n"]}
1
+ {"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../src/components/Banner/Banner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAU/C,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,iBAAiB,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK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C,IAAI,IAAC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,YACjD,SAAS,IAAI,CACZ,KAAC,MAAM,mBACQ,OAAO,CAAC,OAAO,EAC5B,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,gBACP,CAAC,CAAC,kCAAkC,CAAC,EACjD,OAAO,EAAC,QAAQ,EAChB,IAAI,kBAEJ,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,CACV,GACI,IACF,EACP,KAAC,cAAc,IAAC,SAAS,EAAE,SAAS,YAClC,KAAC,uBAAuB,IAAC,KAAK,EAAE,gBAAgB,GAAI,GACrC,IACG,CACvB,IACI,CACR,CAAC;AACJ,CAAC,CAAC,EACF,gBAAgB,CACjB,CAAC","sourcesContent":["import { useState, forwardRef, useMemo, useImperativeHandle } from 'react';\nimport type { PropsWithoutRef, Ref, MouseEventHandler, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\nimport { getContrast } from 'polished';\n\nimport { defaultThemeProp } from '../../theme';\nimport type {\n ForwardProps,\n HeadingTag,\n NoChildrenProp,\n OmitStrict,\n RefElement,\n TestIdProp,\n WithAttributes\n} from '../../types';\nimport Button, { StyledButton } from '../Button';\nimport { focusHeadingOrContainer, tryCatch, withTestIds } from '../../utils';\nimport { useConsolidatedRef, useDirection, useI18n, useTestIds } from '../../hooks';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Grid from '../Grid';\nimport ExpandCollapse from '../ExpandCollapse';\nimport { Count } from '../Badges';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport * as flagWaveSolidIcon from '../Icon/icons/flag-wave-solid.icon';\nimport * as informationSolidIcon from '../Icon/icons/information-solid.icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport { UnorderedList } from '../List';\nimport { readableColor } from '../../styles';\n\nimport { getBannerTestIds } from './Banner.test-ids';\n\nregisterIcon(\n timesIcon,\n caretRightIcon,\n warnSolidIcon,\n flagWaveSolidIcon,\n informationSolidIcon,\n checkIcon\n);\n\nexport interface BannerHandleValue {\n /** Used to apply focus to the banner via an imperative handle. */\n focus: () => void;\n}\n\nexport interface BannerMessage {\n label: string;\n description?: string;\n action?: {\n text: string;\n onClick?: MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>;\n href?: string;\n };\n items?: (BannerMessage | string)[];\n}\n\nexport type BannerProps = WithAttributes<\n 'div',\n TestIdProp &\n NoChildrenProp & {\n /** Controls the styling of the Banner. */ variant: 'urgent' | 'warning' | 'success' | 'info';\n /**\n * The heading tag to render the provided heading as. This is agnostic to the styling of the heading.\n * @default 'h2'\n */\n headingTag?: HeadingTag;\n /** Pass one or more descriptive messages to inform the user. */\n messages: (string | BannerMessage)[];\n /** Callback when user explicitly dismisses the Banner. */\n onDismiss?: MouseEventHandler;\n /** Ref that can be used to access the imperative handle. */\n handle?: Ref<BannerHandleValue>;\n }\n>;\n\nexport const StyledBanner = styled.div<{ headingTag: BannerProps['headingTag'] }>(\n ({ headingTag, theme }) => {\n return css`\n border-radius: ${theme.components.card['border-radius']};\n min-inline-size: 100%;\n inline-size: 0;\n\n &:has(${headingTag}:focus) {\n box-shadow: ${theme.base.shadow.focus};\n }\n `;\n }\n);\n\nStyledBanner.defaultProps = defaultThemeProp;\n\nexport const StyledBannerStatus = styled.div<Pick<BannerProps, 'variant'>>(({ variant, theme }) => {\n const { background } = theme.components.banner[variant];\n const color = tryCatch(() =>\n getContrast(background, theme.base.palette['primary-background']) >= 3\n ? theme.base.palette['primary-background']\n : readableColor(background)\n );\n\n return css`\n background-color: ${background};\n color: ${color};\n border-start-start-radius: inherit;\n border-end-start-radius: inherit;\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-inline-end: none;\n font-size: 1.25rem;\n `;\n});\n\nStyledBannerStatus.defaultProps = defaultThemeProp;\n\nexport const StyledBannerHeader = styled.div(({ theme }) => {\n const { rtl } = useDirection();\n\n return css`\n min-height: 2.125rem;\n\n ${StyledButton}[aria-expanded] {\n ${StyledIcon} {\n transition: rotate ${theme.base.animation.speed} ${theme.base.animation.timing.ease};\n }\n\n &[aria-expanded='true'] ${StyledIcon} {\n rotate: 90deg;\n }\n\n &[aria-expanded='false'] ${StyledIcon} {\n rotate: ${rtl ? 180 : 0}deg;\n }\n }\n `;\n});\n\nStyledBannerHeader.defaultProps = defaultThemeProp;\n\nexport const StyledBannerContent = styled.div<{ expandable?: boolean }>(({ expandable, theme }) => {\n return css`\n background: ${theme.components.card.background};\n padding-block: calc(0.5 * ${theme.base.spacing});\n padding-inline-start: calc(${expandable ? 0.5 : 2} * ${theme.base.spacing});\n padding-inline-end: calc(0.5 * ${theme.base.spacing});\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-inline-start: none;\n border-start-end-radius: inherit;\n border-end-end-radius: inherit;\n `;\n});\n\nStyledBannerContent.defaultProps = defaultThemeProp;\n\nexport const StyledBannerMessageList = styled(UnorderedList)(\n ({ theme }) => css`\n padding-block-end: calc(0.5 * ${theme.base.spacing});\n padding-inline-start: calc(5 * ${theme.base.spacing});\n padding-inline-end: calc(2 * ${theme.base.spacing});\n `\n);\n\nStyledBannerMessageList.defaultProps = defaultThemeProp;\n\nexport const StyledBannerMessage = styled.span`\n overflow-wrap: break-word;\n list-style: none;\n`;\n\nStyledBannerMessage.defaultProps = defaultThemeProp;\n\nconst BannerMessageItem = forwardRef<\n HTMLLIElement,\n TestIdProp & OmitStrict<BannerMessage, 'items'> & ForwardProps\n>(function BannerMessageItem({ testId, label, description, action, ...restProps }, ref) {\n const testIds = useTestIds(testId, getBannerTestIds);\n\n return (\n <StyledBannerMessage {...restProps} ref={ref}>\n <span data-testid={testIds.messageLabel}>{label}</span>\n {description && (\n <>\n {' '}\n <Text data-testid={testIds.messageDescription} variant='secondary'>\n {description}\n </Text>\n </>\n )}\n {action && (\n <>\n {' '}\n <Text variant='secondary'>\n <Button\n data-testid={testIds.messageAction}\n variant='link'\n href={action.href}\n onClick={action.onClick}\n {...action}\n >\n {action.text}\n </Button>\n </Text>\n </>\n )}\n </StyledBannerMessage>\n );\n});\n\nconst prepareMessages = (\n messages: (string | BannerMessage)[],\n testId: TestIdProp['testId']\n): [messages: ReactNode[], count: number] => {\n let count = 0;\n\n return [\n messages.flatMap(msg => {\n count += 1;\n\n if (typeof msg === 'string') {\n return [<BannerMessageItem label={msg} />];\n }\n\n if (msg.items) {\n const { items, ...restMsg } = msg;\n const [subMessages, subCount] = prepareMessages(items, testId);\n count += subCount;\n return [<BannerMessageItem {...restMsg} testId={testId} />, subMessages];\n }\n\n return [<BannerMessageItem {...msg} testId={testId} />];\n }),\n count\n ];\n};\n\nexport default withTestIds(\n forwardRef<RefElement<BannerProps>, PropsWithoutRef<BannerProps>>(function Banner(\n { testId, variant, headingTag = 'h2', messages, onDismiss, handle, ...restProps },\n ref\n ) {\n const testIds = useTestIds(testId, getBannerTestIds);\n const [messagesToRender, count] = useMemo(() => prepareMessages(messages, testId), [messages]);\n const t = useI18n();\n const [collapsed, setCollapsed] = useState(count > 2);\n\n const bannerRef = useConsolidatedRef(ref);\n\n let role: string;\n let icon: string;\n let heading: string;\n let ariaLive: string;\n\n switch (variant) {\n case 'urgent':\n heading = t('error');\n icon = 'warn-solid';\n role = 'alert';\n ariaLive = 'assertive';\n break;\n case 'warning':\n heading = t('warning');\n icon = 'flag-wave-solid';\n role = 'alert';\n ariaLive = 'assertive';\n break;\n case 'success':\n heading = t('success');\n icon = 'check';\n role = 'none';\n ariaLive = 'polite';\n break;\n case 'info':\n default:\n heading = t('information');\n icon = 'information-solid';\n role = 'none';\n ariaLive = 'polite';\n break;\n }\n\n useImperativeHandle(\n handle,\n () => ({\n focus: () => {\n // Empty timeout ensures that the banner will take focus after any other programmatic focus events\n setTimeout(() => {\n if (bannerRef.current) {\n focusHeadingOrContainer(bannerRef.current, heading);\n }\n });\n }\n }),\n []\n );\n\n return (\n <Grid\n data-testid={testIds.root}\n {...restProps}\n as={StyledBanner}\n container={{ cols: '2rem minmax(0, 1fr)' }}\n role={role}\n aria-live={ariaLive}\n headingTag={headingTag}\n ref={bannerRef}\n >\n <Flex\n as={StyledBannerStatus}\n container={{ justify: 'center', alignItems: 'start', pad: [1.5, 0] }}\n variant={variant}\n >\n <Icon name={icon} />\n </Flex>\n {count === 1 ? (\n <Flex container={{ alignItems: 'start' }} as={StyledBannerContent}>\n <VisuallyHiddenText as={headingTag}>{`${heading} ${count}`}</VisuallyHiddenText>\n <Flex item={{ alignSelf: 'center', grow: 1 }} as='ul'>\n {typeof messages[0] === 'string' ? (\n <BannerMessageItem testId={testId} label={messages[0]} as='li' />\n ) : (\n <BannerMessageItem {...messages[0]} testId={testId} as='li' />\n )}\n </Flex>\n {onDismiss && (\n <Button\n data-testid={testIds.dismiss}\n onClick={onDismiss}\n label={t('dismiss')}\n aria-label={t('banner_dismiss_button_label_a11y')}\n variant='simple'\n icon\n >\n <Icon name='times' />\n </Button>\n )}\n </Flex>\n ) : (\n <StyledBannerContent expandable>\n <Grid\n as={StyledBannerHeader}\n container={{ cols: 'auto 1fr auto', areas: '\"toggle heading dismiss\"', gap: 0.5 }}\n >\n <Grid\n data-testid={testIds.heading}\n container={{ cols: 'min-content min-content', gap: 0.5, alignItems: 'center' }}\n item={{ area: 'heading', alignSelf: 'center' }}\n as={Text}\n forwardedAs={headingTag}\n variant='h2'\n >\n {heading} <Count>{count}</Count>\n </Grid>\n <Grid item={{ area: 'toggle', alignSelf: 'center' }}>\n <Button\n data-testid={testIds.expandCollapse}\n onClick={() => {\n setCollapsed(cur => !cur);\n }}\n label={t(collapsed ? 'expand' : 'collapse')}\n aria-label={t(collapsed ? 'expand_noun' : 'collapse_noun', [heading])}\n aria-expanded={collapsed ? 'false' : 'true'}\n variant='simple'\n icon\n >\n <Icon name='caret-right' />\n </Button>\n </Grid>\n <Grid item={{ area: 'dismiss', alignSelf: 'center' }}>\n {onDismiss && (\n <Button\n data-testid={testIds.dismiss}\n onClick={onDismiss}\n label={t('dismiss')}\n aria-label={t('banner_dismiss_button_label_a11y')}\n variant='simple'\n icon\n >\n <Icon name='times' />\n </Button>\n )}\n </Grid>\n </Grid>\n <ExpandCollapse collapsed={collapsed}>\n <StyledBannerMessageList items={messagesToRender} />\n </ExpandCollapse>\n </StyledBannerContent>\n )}\n </Grid>\n );\n }),\n getBannerTestIds\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,SAAS,EAET,GAAG,EAGJ,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAiBtF,MAAM,WAAW,WAAY,SAAQ,SAAS,EAAE,MAAM;IACpD,sCAAsC;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2FAA2F;IAC3F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/D;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IACrC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E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O,CAAC;IAClB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;CAC9B;AAED,KAAK,uBAAuB,GAAG,iBAAiB,CAC9C,WAAW,EACX,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CACrD,CAAC;AAqEF,eAAO,MAAM,YAAY,qGAiPxB,CAAC;AAIF,eAAO,MAAM,gBAAgB,gJAoD3B,CAAC;AAIH,QAAA,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,GAAG,YAAY,CAgGxD,CAAC;AAEH,eAAe,MAAM,CAAC"}
@@ -3,7 +3,7 @@ import { useRef, useEffect, forwardRef } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
4
  import { meetsContrastGuidelines, mix } from 'polished';
5
5
  import { defaultThemeProp } from '../../theme';
6
- import { tryCatch } from '../../utils';
6
+ import { isPositionWithinRect, tryCatch } from '../../utils';
7
7
  import { getActiveColors, getHoverColors, omitProps, readableColor, readableHue } from '../../styles';
8
8
  import { useElement, useConsolidatedRef } from '../../hooks';
9
9
  import Tooltip from '../Tooltip';
@@ -43,9 +43,26 @@ const baseStyles = (theme) => {
43
43
  }
44
44
  `;
45
45
  };
46
+ const getFilledButtonStyles = (color) => ({
47
+ contrastColor: tryCatch(() => readableColor(color)),
48
+ hoverColors: getHoverColors(color),
49
+ activeColors: getActiveColors(color)
50
+ });
51
+ const getOutlinedButtonStyles = (color, backgroundColor) => {
52
+ const backgroundUsable = meetsContrastGuidelines(color, backgroundColor).AA;
53
+ const usableColor = backgroundUsable ? color : readableHue(color, backgroundColor);
54
+ const hoverBackgroundColor = tryCatch(() => mix(0.9, backgroundColor, usableColor));
55
+ const activeBackgroundColor = tryCatch(() => mix(0.8, backgroundColor, usableColor));
56
+ return {
57
+ textColor: backgroundUsable ? color : readableColor(color),
58
+ hoverBg: hoverBackgroundColor,
59
+ hoverFg: readableHue(usableColor, hoverBackgroundColor ?? 'transparent'),
60
+ activeBg: tryCatch(() => mix(0.8, backgroundColor, usableColor)),
61
+ activeFg: readableHue(usableColor, activeBackgroundColor ?? 'transparent')
62
+ };
63
+ };
46
64
  export const StyledButton = styled.button.withConfig(omitProps('loading'))(({ variant, icon, loading, compact, theme }) => {
47
- const { base: { spacing, 'border-radius': baseBorderRadius, palette: { 'primary-background': backgroundColor }, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger, 'compact-min': hitAreaCompact }, animation: { speed, timing: { ease } } }, components: { button: { color, 'secondary-color': secondaryColor, padding, 'border-radius': borderRadius, 'border-width': borderWidth, touch: { padding: touchPadding } } } } = theme;
48
- const contrastColor = tryCatch(() => readableColor(color));
65
+ const { base: { spacing, 'border-radius': baseBorderRadius, palette: { 'primary-background': backgroundColor }, 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger, 'compact-min': hitAreaCompact }, animation: { speed, timing: { ease } } }, components: { button: { color, 'secondary-color': secondaryColor, 'secondary-fill-style': fillStyle, padding, 'border-radius': borderRadius, 'border-width': borderWidth, touch: { padding: touchPadding } } } } = theme;
49
66
  // Base
50
67
  const base = baseStyles(theme);
51
68
  // Non-text base
@@ -112,13 +129,12 @@ export const StyledButton = styled.button.withConfig(omitProps('loading'))(({ va
112
129
  translate: 0 -0.0625rem;
113
130
  }
114
131
  `;
115
- // Primary
116
- const hoverColors = getHoverColors(color);
117
- const activeColors = getActiveColors(color);
118
- const primary = css `
119
- --button-background-color: ${color};
132
+ // Primary and Secondary-filled
133
+ const { contrastColor, hoverColors, activeColors } = getFilledButtonStyles(variant === 'primary' ? color : secondaryColor);
134
+ const solidButtonStyles = css `
135
+ --button-background-color: ${variant === 'primary' ? color : secondaryColor};
120
136
  color: ${contrastColor};
121
- background-color: ${color};
137
+ background-color: ${variant === 'primary' ? color : secondaryColor};
122
138
 
123
139
  @media (hover: hover) {
124
140
  &:hover {
@@ -134,39 +150,35 @@ export const StyledButton = styled.button.withConfig(omitProps('loading'))(({ va
134
150
  text-decoration: none;
135
151
  }
136
152
  `;
137
- // Secondary
138
- const backgroundUsable = meetsContrastGuidelines(color, secondaryColor).AA;
139
- const usableColor = backgroundUsable ? color : readableHue(color, secondaryColor);
140
- const secondaryHoverBackgroundColor = tryCatch(() => mix(0.9, secondaryColor, usableColor));
141
- const secondaryHoverForegroundColor = readableHue(usableColor, secondaryHoverBackgroundColor ?? 'transparent');
142
- const secondaryActiveBackgroundColor = tryCatch(() => mix(0.8, secondaryColor, usableColor));
143
- const secondaryActiveForegroundColor = readableHue(usableColor, secondaryActiveBackgroundColor ?? 'transparent');
153
+ // Secondary-outline
154
+ const secondaryOutlineButtonStyles = getOutlinedButtonStyles(secondaryColor, backgroundColor);
144
155
  const secondary = css `
145
- --button-background-color: ${secondaryColor};
146
- color: ${usableColor};
147
- background-color: ${secondaryColor};
148
- border-color: ${usableColor};
156
+ --button-background-color: ${backgroundColor};
157
+ color: ${secondaryOutlineButtonStyles.textColor};
158
+ background-color: ${backgroundColor};
159
+ border-color: ${secondaryColor};
149
160
 
150
161
  @media (hover: hover) {
151
162
  &:hover {
152
- color: ${secondaryHoverForegroundColor};
153
- background-color: ${secondaryHoverBackgroundColor};
163
+ color: ${secondaryOutlineButtonStyles.hoverFg};
164
+ background-color: ${secondaryOutlineButtonStyles.hoverBg};
154
165
  text-decoration: none;
155
- border-color: ${secondaryHoverForegroundColor};
166
+ border-color: ${secondaryOutlineButtonStyles.hoverFg};
156
167
  }
157
168
  }
158
169
 
159
170
  &:active {
160
- color: ${secondaryActiveForegroundColor};
161
- background-color: ${secondaryActiveBackgroundColor};
162
- border-color: ${secondaryActiveForegroundColor};
171
+ color: ${secondaryOutlineButtonStyles.activeFg};
172
+ background-color: ${secondaryOutlineButtonStyles.activeBg};
173
+ border-color: ${secondaryOutlineButtonStyles.activeFg};
163
174
  text-decoration: none;
164
175
  }
165
176
  `;
166
177
  // Simple
178
+ const simpleButtonStyles = getOutlinedButtonStyles(fillStyle === 'outline' ? secondaryColor : color, backgroundColor);
167
179
  const simple = css `
168
180
  --button-background-color: ${icon ? 'transparent' : backgroundColor};
169
- color: ${icon ? 'currentColor' : usableColor};
181
+ color: ${icon ? 'currentColor' : simpleButtonStyles.textColor};
170
182
  background-color: ${icon ? 'transparent' : backgroundColor};
171
183
 
172
184
  @media (hover: hover) {
@@ -188,9 +200,9 @@ export const StyledButton = styled.button.withConfig(omitProps('loading'))(({ va
188
200
 
189
201
  ${!icon &&
190
202
  css `
191
- background-color: ${secondaryHoverBackgroundColor};
192
- color: ${secondaryHoverForegroundColor};
193
- border-color: ${secondaryHoverForegroundColor};
203
+ background-color: ${simpleButtonStyles.hoverBg};
204
+ color: ${simpleButtonStyles.hoverFg};
205
+ border-color: ${simpleButtonStyles.hoverFg};
194
206
  text-decoration: none;
195
207
  `}
196
208
  }
@@ -213,9 +225,9 @@ export const StyledButton = styled.button.withConfig(omitProps('loading'))(({ va
213
225
 
214
226
  ${!icon &&
215
227
  css `
216
- background-color: ${secondaryActiveBackgroundColor};
217
- color: ${secondaryActiveForegroundColor};
218
- border-color: ${secondaryActiveForegroundColor};
228
+ background-color: ${simpleButtonStyles.activeBg};
229
+ color: ${simpleButtonStyles.activeFg};
230
+ border-color: ${simpleButtonStyles.activeFg};
219
231
  text-decoration: none;
220
232
  `}
221
233
  }
@@ -224,8 +236,9 @@ export const StyledButton = styled.button.withConfig(omitProps('loading'))(({ va
224
236
  return css `
225
237
  ${base}
226
238
  ${nonTextual}
227
- ${variant === 'primary' && primary}
228
- ${variant === 'secondary' && secondary}
239
+ ${(variant === 'primary' || (variant === 'secondary' && fillStyle === 'fill')) &&
240
+ solidButtonStyles}
241
+ ${variant === 'secondary' && fillStyle === 'outline' && secondary}
229
242
  ${variant === 'simple' && simple}
230
243
 
231
244
  ${loading &&
@@ -293,22 +306,41 @@ StyledButtonLink.defaultProps = defaultThemeProp;
293
306
  const Button = forwardRef(function Button({ variant = 'secondary', type = 'button', disabled = false, icon = false, compact = false, href, as, forwardedAs, label, 'aria-label': ariaLabel, loading = false, children, ...restProps }, ref) {
294
307
  const [buttonEl, setButtonEl] = useElement();
295
308
  const mouseDownEvent = useRef();
309
+ const mouseDownPosition = useRef();
310
+ const mouseDownTimestamp = useRef();
296
311
  const buttonRef = useConsolidatedRef(ref, setButtonEl);
297
312
  const isTextual = ['link', 'text'].includes(variant);
298
313
  const showProgress = loading && !isTextual;
299
314
  const StyledComp = isTextual ? StyledButtonLink : StyledButton;
315
+ const handleClickWithElementShift = (e) => {
316
+ if (buttonRef.current &&
317
+ mouseDownPosition.current &&
318
+ mouseDownTimestamp.current &&
319
+ isPositionWithinRect({ x: e.clientX, y: e.clientY }, mouseDownPosition.current) &&
320
+ Date.now() - mouseDownTimestamp.current < 500) {
321
+ buttonRef.current.click();
322
+ }
323
+ };
300
324
  useEffect(() => {
325
+ document.addEventListener('mouseup', handleClickWithElementShift);
301
326
  return () => {
327
+ document.removeEventListener('mouseup', handleClickWithElementShift);
302
328
  mouseDownEvent.current = undefined;
329
+ mouseDownPosition.current = undefined;
330
+ mouseDownTimestamp.current = undefined;
303
331
  };
304
332
  }, []);
305
333
  return (_jsxs(_Fragment, { children: [_jsxs(StyledComp, { ...restProps, ref: buttonRef, as: as || (href ? 'a' : 'button'), forwardedAs: forwardedAs || (href ? 'a' : 'button'), variant: variant, icon: icon, compact: compact, type: href ? undefined : type, href: href, disabled: disabled && !href, loading: showProgress, "aria-label": ariaLabel || label, onMouseDown: (e) => {
306
334
  restProps.onMouseDown?.(e);
307
335
  e.persist();
308
336
  mouseDownEvent.current = e;
337
+ mouseDownPosition.current = e.currentTarget.getBoundingClientRect();
338
+ mouseDownTimestamp.current = Date.now();
309
339
  }, onMouseUp: (e) => {
310
340
  const shouldFocus = mouseDownEvent.current && !mouseDownEvent.current.defaultPrevented;
311
341
  mouseDownEvent.current = undefined;
342
+ mouseDownPosition.current = undefined;
343
+ mouseDownTimestamp.current = undefined;
312
344
  if (shouldFocus && buttonRef.current !== document.activeElement) {
313
345
  buttonRef.current?.focus();
314
346
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAStD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EACL,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,WAAW,EACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,QAAQ,EAAE,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAkD3C,MAAM,UAAU,GAAG,CAAC,KAAmB,EAAE,EAAE;IACzC,MAAM,EACJ,IAAI,EAAE,EACJ,OAAO,EACP,SAAS,EAAE,EACT,KAAK,EACL,MAAM,EAAE,EAAE,IAAI,EAAE,EACjB,EACD,kBAAkB,EAAE,eAAe,EACpC,EACD,UAAU,EAAE,EACV,MAAM,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,EACxC,EACF,GAAG,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,OAAO,EAAE,CAAC;oBACZ,cAAc,CAAC,OAAO,GAAG,CAAC,CAAC;gBAC7B,CAAC,EACD,SAAS,EAAE,CAAC,CAAoD,EAAE,EAAE;oBAClE,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,gBAAgB,CAAC;oBACvF,cAAc,CAAC,OAAO,GAAG,SAAS,CAAC;oBAEnC,IAAI,WAAW,IAAI,SAAS,CAAC,OAAO,KAAK,QAAQ,CAAC,aAAa,EAAE;wBAC/D,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;qBAC5B;oBAED,OAAQ,SAAS,CAAC,SAA2C,EAAE,CAAC,CAAC,CAAC,CAAC;gBACrE,CAAC,aAEA,YAAY,IAAI,KAAC,QAAQ,IAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAC,QAAQ,GAAG,EAC9D,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAC9B,EAEZ,QAAQ,IAAI,KAAK,IAAI,CACpB,KAAC,OAAO,IAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,EAAC,cAAc,EAAE,KAAK,YAC/E,KAAK,GACE,CACX,IACA,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC","sourcesContent":["import { useRef, useEffect, forwardRef } from 'react';\nimport type {\n FunctionComponent,\n ReactNode,\n PropsWithoutRef,\n Ref,\n MouseEvent,\n MouseEventHandler\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport type { DefaultTheme } from 'styled-components';\nimport { meetsContrastGuidelines, mix } from 'polished';\n\nimport type { BaseProps, ForwardProps, PropsWithDefaults, AsProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport {\n getActiveColors,\n getHoverColors,\n omitProps,\n readableColor,\n readableHue\n} from '../../styles';\nimport { useElement, useConsolidatedRef } from '../../hooks';\nimport Tooltip from '../Tooltip';\nimport Progress, { StyledProgressRing } from '../Progress';\nimport { StyledBackdrop } from '../Backdrop';\nimport { StyledIcon } from '../Icon';\nimport { StyledPopover } from '../Popover';\n\nexport interface ButtonProps extends BaseProps, AsProp {\n /** Text or content for the Button. */\n children: ReactNode;\n /**\n * Determines if the Button will be disabled.\n * @default false\n */\n disabled?: boolean;\n /** A location to navigate to. Passing an href will render an anchor styled as a Button. */\n href?: string;\n /**\n * Controls the styling of the Button.\n * @default 'secondary'\n */\n variant?: 'primary' | 'secondary' | 'simple' | 'link' | 'text';\n /**\n * Controls the behavior of a Button within a Form.\n * @default 'button'\n */\n type?: 'button' | 'reset' | 'submit';\n /**\n * Set the Icon prop to `true` if you're using just an Icon in your Button. Make sure to pass an Icon as children if `true`.\n * @default false\n */\n icon?: boolean;\n /**\n * Used for a smaller sized button.\n * @default false\n */\n compact?: boolean;\n /** The label text will be used inside a Tooltip. */\n label?: string;\n /** The aria label text will be inserted as the aria-label on the Button. */\n 'aria-label'?: string;\n /**\n * Optionally renders an indeterminate progress indicator in a button.\n * @default false\n */\n loading?: boolean;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLButtonElement>;\n}\n\ntype ButtonPropsWithDefaults = PropsWithDefaults<\n ButtonProps,\n 'variant' | 'type' | 'disabled' | 'icon' | 'loading'\n>;\n\nconst baseStyles = (theme: DefaultTheme) => {\n const {\n base: {\n spacing,\n animation: {\n speed,\n timing: { ease }\n },\n 'disabled-opacity': disabledOpacity\n },\n components: {\n button: { 'focus-shadow': focusShadow }\n }\n } = theme;\n\n return css`\n outline: none;\n text-decoration: none;\n transition-property: background-color, color, border-color, box-shadow, translate;\n transition-duration: calc(0.5 * ${speed});\n transition-timing-function: ${ease};\n cursor: pointer;\n\n & + & {\n margin-inline-start: ${spacing};\n }\n\n /* Not able to combine with selector above. Stylis bug? */\n & + ${StyledPopover} + & {\n margin-inline-start: ${spacing};\n }\n\n &:disabled,\n &[disabled] {\n opacity: ${disabledOpacity};\n cursor: not-allowed;\n pointer-events: none;\n }\n\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: ${focusShadow};\n }\n `;\n};\n\nexport const StyledButton = styled.button.withConfig<ButtonPropsWithDefaults>(omitProps('loading'))(\n ({ variant, icon, loading, compact, theme }) => {\n const {\n base: {\n spacing,\n 'border-radius': baseBorderRadius,\n palette: { 'primary-background': backgroundColor },\n 'hit-area': {\n 'mouse-min': hitAreaMouse,\n 'finger-min': hitAreaFinger,\n 'compact-min': hitAreaCompact\n },\n animation: {\n speed,\n timing: { ease }\n }\n },\n components: {\n button: {\n color,\n 'secondary-color': secondaryColor,\n padding,\n 'border-radius': borderRadius,\n 'border-width': borderWidth,\n touch: { padding: touchPadding }\n }\n }\n } = theme;\n const contrastColor = tryCatch(() => readableColor(color));\n\n // Base\n const base = baseStyles(theme);\n\n // Non-text base\n const nonTextual = css`\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-height: ${hitAreaMouse};\n min-width: ${hitAreaMouse};\n border: ${borderWidth} solid transparent;\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n -webkit-user-select: none;\n user-select: none;\n\n ${!icon &&\n css`\n padding: ${padding};\n `}\n\n ${icon &&\n css`\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n\n > svg {\n display: block;\n }\n `}\n\n ${compact &&\n css`\n min-height: ${hitAreaCompact};\n min-width: ${hitAreaCompact};\n `}\n\n @media (pointer: coarse) {\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n\n ${!compact &&\n css`\n min-height: ${hitAreaFinger};\n min-width: ${hitAreaFinger};\n `}\n\n ${!icon &&\n css`\n padding: ${touchPadding};\n `}\n }\n\n &:active {\n translate: 0 0.0625rem;\n }\n\n &::after {\n content: '';\n position: absolute;\n inset: calc(-1 * ${borderWidth});\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n transition: translate calc(0.5 * ${speed}) ${ease};\n }\n\n &:active::after {\n translate: 0 -0.0625rem;\n }\n `;\n\n // Primary\n const hoverColors = getHoverColors(color);\n const activeColors = getActiveColors(color);\n const primary = css`\n --button-background-color: ${color};\n color: ${contrastColor};\n background-color: ${color};\n\n @media (hover: hover) {\n &:hover {\n background-color: ${hoverColors.background};\n color: ${hoverColors.foreground};\n text-decoration: none;\n }\n }\n\n &:active {\n background-color: ${activeColors.background};\n color: ${activeColors.foreground};\n text-decoration: none;\n }\n `;\n\n // Secondary\n const backgroundUsable = meetsContrastGuidelines(color, secondaryColor).AA;\n const usableColor = backgroundUsable ? color : readableHue(color, secondaryColor);\n const secondaryHoverBackgroundColor = tryCatch(() => mix(0.9, secondaryColor, usableColor));\n const secondaryHoverForegroundColor = readableHue(\n usableColor,\n secondaryHoverBackgroundColor ?? 'transparent'\n );\n const secondaryActiveBackgroundColor = tryCatch(() => mix(0.8, secondaryColor, usableColor));\n const secondaryActiveForegroundColor = readableHue(\n usableColor,\n secondaryActiveBackgroundColor ?? 'transparent'\n );\n const secondary = css`\n --button-background-color: ${secondaryColor};\n color: ${usableColor};\n background-color: ${secondaryColor};\n border-color: ${usableColor};\n\n @media (hover: hover) {\n &:hover {\n color: ${secondaryHoverForegroundColor};\n background-color: ${secondaryHoverBackgroundColor};\n text-decoration: none;\n border-color: ${secondaryHoverForegroundColor};\n }\n }\n\n &:active {\n color: ${secondaryActiveForegroundColor};\n background-color: ${secondaryActiveBackgroundColor};\n border-color: ${secondaryActiveForegroundColor};\n text-decoration: none;\n }\n `;\n\n // Simple\n const simple = css`\n --button-background-color: ${icon ? 'transparent' : backgroundColor};\n color: ${icon ? 'currentColor' : usableColor};\n background-color: ${icon ? 'transparent' : backgroundColor};\n\n @media (hover: hover) {\n &:hover {\n ${icon &&\n css`\n ::before {\n content: '';\n position: absolute;\n top: calc(${borderWidth} * -1);\n bottom: calc(${borderWidth} * -1);\n left: calc(${borderWidth} * -1);\n right: calc(${borderWidth} * -1);\n border-radius: inherit;\n background-color: currentColor;\n opacity: 0.1;\n }\n `}\n\n ${!icon &&\n css`\n background-color: ${secondaryHoverBackgroundColor};\n color: ${secondaryHoverForegroundColor};\n border-color: ${secondaryHoverForegroundColor};\n text-decoration: none;\n `}\n }\n\n &:active {\n ${icon &&\n css`\n ::before {\n content: '';\n position: absolute;\n top: calc(${borderWidth} * -1);\n bottom: calc(${borderWidth} * -1);\n left: calc(${borderWidth} * -1);\n right: calc(${borderWidth} * -1);\n border-radius: inherit;\n background-color: currentColor;\n opacity: 0.2;\n }\n `}\n\n ${!icon &&\n css`\n background-color: ${secondaryActiveBackgroundColor};\n color: ${secondaryActiveForegroundColor};\n border-color: ${secondaryActiveForegroundColor};\n text-decoration: none;\n `}\n }\n }\n `;\n\n return css`\n ${base}\n ${nonTextual}\n ${variant === 'primary' && primary}\n ${variant === 'secondary' && secondary}\n ${variant === 'simple' && simple}\n\n ${loading &&\n css`\n ${StyledBackdrop} {\n background-color: var(--button-background-color);\n border-radius: inherit;\n }\n\n ${StyledProgressRing} {\n width: 1em;\n height: 1em;\n\n ${!icon &&\n css`\n margin-inline-end: calc(${spacing} / 2);\n `}\n\n circle:nth-child(2) {\n animation-duration: calc(${speed} * 2);\n }\n }\n `}\n `;\n }\n);\n\nStyledButton.defaultProps = defaultThemeProp;\n\nexport const StyledButtonLink = styled.a.withConfig<\n Pick<ButtonPropsWithDefaults, 'variant'> &\n // Needed for omitProps\n Pick<ButtonProps, 'loading'>\n>(omitProps('loading'))(({ theme, variant }) => {\n const {\n base: {\n palette: { 'foreground-color': textColor }\n },\n components: {\n link: { color: linkColor }\n }\n } = theme;\n\n const base = baseStyles(theme);\n\n const textual = css`\n background-color: transparent;\n display: inline;\n text-align: start;\n border: none;\n\n @media (hover: hover) {\n &:hover {\n text-decoration: underline;\n }\n }\n\n > ${StyledIcon} {\n vertical-align: bottom;\n }\n `;\n\n const { background: activeColor } = getActiveColors(linkColor);\n const link = css`\n color: ${linkColor};\n\n &:active {\n color: ${activeColor};\n }\n `;\n\n const text = css`\n color: ${textColor};\n `;\n\n return css`\n ${base}\n ${textual}\n ${variant === 'link' && link}\n ${variant === 'text' && text}\n `;\n});\n\nStyledButtonLink.defaultProps = defaultThemeProp;\n\nconst Button: FunctionComponent<ButtonProps & ForwardProps> = forwardRef(function Button(\n {\n variant = 'secondary',\n type = 'button',\n disabled = false,\n icon = false,\n compact = false,\n href,\n as,\n forwardedAs,\n label,\n 'aria-label': ariaLabel,\n loading = false,\n children,\n ...restProps\n }: PropsWithoutRef<ButtonProps> & ForwardProps,\n ref: Ref<HTMLButtonElement>\n) {\n const [buttonEl, setButtonEl] = useElement();\n const mouseDownEvent = useRef<MouseEvent>();\n const buttonRef = useConsolidatedRef<HTMLButtonElement>(ref, setButtonEl);\n const isTextual = ['link', 'text'].includes(variant);\n const showProgress = loading && !isTextual;\n const StyledComp: React.ElementType = isTextual ? StyledButtonLink : StyledButton;\n\n useEffect(() => {\n return () => {\n mouseDownEvent.current = undefined;\n };\n }, []);\n\n return (\n <>\n <StyledComp\n {...restProps}\n ref={buttonRef}\n as={as || (href ? 'a' : 'button')}\n forwardedAs={forwardedAs || (href ? 'a' : 'button')}\n variant={variant}\n icon={icon}\n compact={compact}\n type={href ? undefined : type}\n href={href}\n disabled={disabled && !href}\n loading={showProgress}\n aria-label={ariaLabel || label}\n onMouseDown={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n (restProps.onMouseDown as MouseEventHandler | undefined)?.(e);\n e.persist();\n mouseDownEvent.current = e;\n }}\n onMouseUp={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n const shouldFocus = mouseDownEvent.current && !mouseDownEvent.current.defaultPrevented;\n mouseDownEvent.current = undefined;\n\n if (shouldFocus && buttonRef.current !== document.activeElement) {\n buttonRef.current?.focus();\n }\n\n return (restProps.onMouseUp as MouseEventHandler | undefined)?.(e);\n }}\n >\n {showProgress && <Progress variant='ring' placement='inline' />}\n {!icon || !showProgress ? children : null}\n </StyledComp>\n\n {buttonEl && label && (\n <Tooltip target={buttonEl} showDelay='none' hideDelay='none' describeTarget={false}>\n {label}\n </Tooltip>\n )}\n </>\n );\n});\n\nexport default Button;\n"]}
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAStD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACL,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,WAAW,EACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,QAAQ,EAAE,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAkD3C,MAAM,UAAU,GAAG,CAAC,KAAmB,EAAE,EAAE;IACzC,MAAM,EACJ,IAAI,EAAE,EACJ,OAAO,EACP,SAAS,EAAE,EACT,KAAK,EACL,MAAM,EAAE,EAAE,IAAI,EAAE,EACjB,EACD,kBAAkB,EAAE,eAAe,EACpC,EACD,UAAU,EAAE,EACV,MAAM,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,EACxC,EACF,GAAG,KAAK,CAAC;IAEV,OAAO,GAAG,CAAA;;;;sCA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,SAAS,CAAC,SAA2C,EAAE,CAAC,CAAC,CAAC,CAAC;gBACrE,CAAC,aAEA,YAAY,IAAI,KAAC,QAAQ,IAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAC,QAAQ,GAAG,EAC9D,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAC9B,EAEZ,QAAQ,IAAI,KAAK,IAAI,CACpB,KAAC,OAAO,IAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,EAAC,cAAc,EAAE,KAAK,YAC/E,KAAK,GACE,CACX,IACA,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC","sourcesContent":["import { useRef, useEffect, forwardRef } from 'react';\nimport type {\n FunctionComponent,\n ReactNode,\n PropsWithoutRef,\n Ref,\n MouseEventHandler,\n MouseEvent as ReactMouseEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport type { DefaultTheme } from 'styled-components';\nimport { meetsContrastGuidelines, mix } from 'polished';\n\nimport type { BaseProps, ForwardProps, PropsWithDefaults, AsProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { isPositionWithinRect, tryCatch } from '../../utils';\nimport {\n getActiveColors,\n getHoverColors,\n omitProps,\n readableColor,\n readableHue\n} from '../../styles';\nimport { useElement, useConsolidatedRef } from '../../hooks';\nimport Tooltip from '../Tooltip';\nimport Progress, { StyledProgressRing } from '../Progress';\nimport { StyledBackdrop } from '../Backdrop';\nimport { StyledIcon } from '../Icon';\nimport { StyledPopover } from '../Popover';\n\nexport interface ButtonProps extends BaseProps, AsProp {\n /** Text or content for the Button. */\n children: ReactNode;\n /**\n * Determines if the Button will be disabled.\n * @default false\n */\n disabled?: boolean;\n /** A location to navigate to. Passing an href will render an anchor styled as a Button. */\n href?: string;\n /**\n * Controls the styling of the Button.\n * @default 'secondary'\n */\n variant?: 'primary' | 'secondary' | 'simple' | 'link' | 'text';\n /**\n * Controls the behavior of a Button within a Form.\n * @default 'button'\n */\n type?: 'button' | 'reset' | 'submit';\n /**\n * Set the Icon prop to `true` if you're using just an Icon in your Button. Make sure to pass an Icon as children if `true`.\n * @default false\n */\n icon?: boolean;\n /**\n * Used for a smaller sized button.\n * @default false\n */\n compact?: boolean;\n /** The label text will be used inside a Tooltip. */\n label?: string;\n /** The aria label text will be inserted as the aria-label on the Button. */\n 'aria-label'?: string;\n /**\n * Optionally renders an indeterminate progress indicator in a button.\n * @default false\n */\n loading?: boolean;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLButtonElement>;\n}\n\ntype ButtonPropsWithDefaults = PropsWithDefaults<\n ButtonProps,\n 'variant' | 'type' | 'disabled' | 'icon' | 'loading'\n>;\n\nconst baseStyles = (theme: DefaultTheme) => {\n const {\n base: {\n spacing,\n animation: {\n speed,\n timing: { ease }\n },\n 'disabled-opacity': disabledOpacity\n },\n components: {\n button: { 'focus-shadow': focusShadow }\n }\n } = theme;\n\n return css`\n outline: none;\n text-decoration: none;\n transition-property: background-color, color, border-color, box-shadow, translate;\n transition-duration: calc(0.5 * ${speed});\n transition-timing-function: ${ease};\n cursor: pointer;\n\n & + & {\n margin-inline-start: ${spacing};\n }\n\n /* Not able to combine with selector above. Stylis bug? */\n & + ${StyledPopover} + & {\n margin-inline-start: ${spacing};\n }\n\n &:disabled,\n &[disabled] {\n opacity: ${disabledOpacity};\n cursor: not-allowed;\n pointer-events: none;\n }\n\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: ${focusShadow};\n }\n `;\n};\n\nconst getFilledButtonStyles = (color: string) => ({\n contrastColor: tryCatch(() => readableColor(color)),\n hoverColors: getHoverColors(color),\n activeColors: getActiveColors(color)\n});\n\nconst getOutlinedButtonStyles = (color: string, backgroundColor: string) => {\n const backgroundUsable = meetsContrastGuidelines(color, backgroundColor).AA;\n const usableColor = backgroundUsable ? color : readableHue(color, backgroundColor);\n const hoverBackgroundColor = tryCatch(() => mix(0.9, backgroundColor, usableColor));\n const activeBackgroundColor = tryCatch(() => mix(0.8, backgroundColor, usableColor));\n\n return {\n textColor: backgroundUsable ? color : readableColor(color),\n hoverBg: hoverBackgroundColor,\n hoverFg: readableHue(usableColor, hoverBackgroundColor ?? 'transparent'),\n activeBg: tryCatch(() => mix(0.8, backgroundColor, usableColor)),\n activeFg: readableHue(usableColor, activeBackgroundColor ?? 'transparent')\n };\n};\n\nexport const StyledButton = styled.button.withConfig<ButtonPropsWithDefaults>(omitProps('loading'))(\n ({ variant, icon, loading, compact, theme }) => {\n const {\n base: {\n spacing,\n 'border-radius': baseBorderRadius,\n palette: { 'primary-background': backgroundColor },\n 'hit-area': {\n 'mouse-min': hitAreaMouse,\n 'finger-min': hitAreaFinger,\n 'compact-min': hitAreaCompact\n },\n animation: {\n speed,\n timing: { ease }\n }\n },\n components: {\n button: {\n color,\n 'secondary-color': secondaryColor,\n 'secondary-fill-style': fillStyle,\n padding,\n 'border-radius': borderRadius,\n 'border-width': borderWidth,\n touch: { padding: touchPadding }\n }\n }\n } = theme;\n\n // Base\n const base = baseStyles(theme);\n\n // Non-text base\n const nonTextual = css`\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-height: ${hitAreaMouse};\n min-width: ${hitAreaMouse};\n border: ${borderWidth} solid transparent;\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n -webkit-user-select: none;\n user-select: none;\n\n ${!icon &&\n css`\n padding: ${padding};\n `}\n\n ${icon &&\n css`\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n\n > svg {\n display: block;\n }\n `}\n\n ${compact &&\n css`\n min-height: ${hitAreaCompact};\n min-width: ${hitAreaCompact};\n `}\n\n @media (pointer: coarse) {\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n\n ${!compact &&\n css`\n min-height: ${hitAreaFinger};\n min-width: ${hitAreaFinger};\n `}\n\n ${!icon &&\n css`\n padding: ${touchPadding};\n `}\n }\n\n &:active {\n translate: 0 0.0625rem;\n }\n\n &::after {\n content: '';\n position: absolute;\n inset: calc(-1 * ${borderWidth});\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n transition: translate calc(0.5 * ${speed}) ${ease};\n }\n\n &:active::after {\n translate: 0 -0.0625rem;\n }\n `;\n\n // Primary and Secondary-filled\n const { contrastColor, hoverColors, activeColors } = getFilledButtonStyles(\n variant === 'primary' ? color : secondaryColor\n );\n const solidButtonStyles = css`\n --button-background-color: ${variant === 'primary' ? color : secondaryColor};\n color: ${contrastColor};\n background-color: ${variant === 'primary' ? color : secondaryColor};\n\n @media (hover: hover) {\n &:hover {\n background-color: ${hoverColors.background};\n color: ${hoverColors.foreground};\n text-decoration: none;\n }\n }\n\n &:active {\n background-color: ${activeColors.background};\n color: ${activeColors.foreground};\n text-decoration: none;\n }\n `;\n\n // Secondary-outline\n const secondaryOutlineButtonStyles = getOutlinedButtonStyles(secondaryColor, backgroundColor);\n const secondary = css`\n --button-background-color: ${backgroundColor};\n color: ${secondaryOutlineButtonStyles.textColor};\n background-color: ${backgroundColor};\n border-color: ${secondaryColor};\n\n @media (hover: hover) {\n &:hover {\n color: ${secondaryOutlineButtonStyles.hoverFg};\n background-color: ${secondaryOutlineButtonStyles.hoverBg};\n text-decoration: none;\n border-color: ${secondaryOutlineButtonStyles.hoverFg};\n }\n }\n\n &:active {\n color: ${secondaryOutlineButtonStyles.activeFg};\n background-color: ${secondaryOutlineButtonStyles.activeBg};\n border-color: ${secondaryOutlineButtonStyles.activeFg};\n text-decoration: none;\n }\n `;\n\n // Simple\n const simpleButtonStyles = getOutlinedButtonStyles(\n fillStyle === 'outline' ? secondaryColor : color,\n backgroundColor\n );\n const simple = css`\n --button-background-color: ${icon ? 'transparent' : backgroundColor};\n color: ${icon ? 'currentColor' : simpleButtonStyles.textColor};\n background-color: ${icon ? 'transparent' : backgroundColor};\n\n @media (hover: hover) {\n &:hover {\n ${icon &&\n css`\n ::before {\n content: '';\n position: absolute;\n top: calc(${borderWidth} * -1);\n bottom: calc(${borderWidth} * -1);\n left: calc(${borderWidth} * -1);\n right: calc(${borderWidth} * -1);\n border-radius: inherit;\n background-color: currentColor;\n opacity: 0.1;\n }\n `}\n\n ${!icon &&\n css`\n background-color: ${simpleButtonStyles.hoverBg};\n color: ${simpleButtonStyles.hoverFg};\n border-color: ${simpleButtonStyles.hoverFg};\n text-decoration: none;\n `}\n }\n\n &:active {\n ${icon &&\n css`\n ::before {\n content: '';\n position: absolute;\n top: calc(${borderWidth} * -1);\n bottom: calc(${borderWidth} * -1);\n left: calc(${borderWidth} * -1);\n right: calc(${borderWidth} * -1);\n border-radius: inherit;\n background-color: currentColor;\n opacity: 0.2;\n }\n `}\n\n ${!icon &&\n css`\n background-color: ${simpleButtonStyles.activeBg};\n color: ${simpleButtonStyles.activeFg};\n border-color: ${simpleButtonStyles.activeFg};\n text-decoration: none;\n `}\n }\n }\n `;\n\n return css`\n ${base}\n ${nonTextual}\n ${(variant === 'primary' || (variant === 'secondary' && fillStyle === 'fill')) &&\n solidButtonStyles}\n ${variant === 'secondary' && fillStyle === 'outline' && secondary}\n ${variant === 'simple' && simple}\n\n ${loading &&\n css`\n ${StyledBackdrop} {\n background-color: var(--button-background-color);\n border-radius: inherit;\n }\n\n ${StyledProgressRing} {\n width: 1em;\n height: 1em;\n\n ${!icon &&\n css`\n margin-inline-end: calc(${spacing} / 2);\n `}\n\n circle:nth-child(2) {\n animation-duration: calc(${speed} * 2);\n }\n }\n `}\n `;\n }\n);\n\nStyledButton.defaultProps = defaultThemeProp;\n\nexport const StyledButtonLink = styled.a.withConfig<\n Pick<ButtonPropsWithDefaults, 'variant'> &\n // Needed for omitProps\n Pick<ButtonProps, 'loading'>\n>(omitProps('loading'))(({ theme, variant }) => {\n const {\n base: {\n palette: { 'foreground-color': textColor }\n },\n components: {\n link: { color: linkColor }\n }\n } = theme;\n\n const base = baseStyles(theme);\n\n const textual = css`\n background-color: transparent;\n display: inline;\n text-align: start;\n border: none;\n\n @media (hover: hover) {\n &:hover {\n text-decoration: underline;\n }\n }\n\n > ${StyledIcon} {\n vertical-align: bottom;\n }\n `;\n\n const { background: activeColor } = getActiveColors(linkColor);\n const link = css`\n color: ${linkColor};\n\n &:active {\n color: ${activeColor};\n }\n `;\n\n const text = css`\n color: ${textColor};\n `;\n\n return css`\n ${base}\n ${textual}\n ${variant === 'link' && link}\n ${variant === 'text' && text}\n `;\n});\n\nStyledButtonLink.defaultProps = defaultThemeProp;\n\nconst Button: FunctionComponent<ButtonProps & ForwardProps> = forwardRef(function Button(\n {\n variant = 'secondary',\n type = 'button',\n disabled = false,\n icon = false,\n compact = false,\n href,\n as,\n forwardedAs,\n label,\n 'aria-label': ariaLabel,\n loading = false,\n children,\n ...restProps\n }: PropsWithoutRef<ButtonProps> & ForwardProps,\n ref: Ref<HTMLButtonElement>\n) {\n const [buttonEl, setButtonEl] = useElement();\n const mouseDownEvent = useRef<ReactMouseEvent>();\n const mouseDownPosition = useRef<DOMRect>();\n const mouseDownTimestamp = useRef<number>();\n const buttonRef = useConsolidatedRef<HTMLButtonElement>(ref, setButtonEl);\n const isTextual = ['link', 'text'].includes(variant);\n const showProgress = loading && !isTextual;\n const StyledComp: React.ElementType = isTextual ? StyledButtonLink : StyledButton;\n\n const handleClickWithElementShift = (e: MouseEvent) => {\n if (\n buttonRef.current &&\n mouseDownPosition.current &&\n mouseDownTimestamp.current &&\n isPositionWithinRect({ x: e.clientX, y: e.clientY }, mouseDownPosition.current) &&\n Date.now() - mouseDownTimestamp.current < 500\n ) {\n buttonRef.current.click();\n }\n };\n\n useEffect(() => {\n document.addEventListener('mouseup', handleClickWithElementShift);\n\n return () => {\n document.removeEventListener('mouseup', handleClickWithElementShift);\n mouseDownEvent.current = undefined;\n mouseDownPosition.current = undefined;\n mouseDownTimestamp.current = undefined;\n };\n }, []);\n\n return (\n <>\n <StyledComp\n {...restProps}\n ref={buttonRef}\n as={as || (href ? 'a' : 'button')}\n forwardedAs={forwardedAs || (href ? 'a' : 'button')}\n variant={variant}\n icon={icon}\n compact={compact}\n type={href ? undefined : type}\n href={href}\n disabled={disabled && !href}\n loading={showProgress}\n aria-label={ariaLabel || label}\n onMouseDown={(e: ReactMouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n (restProps.onMouseDown as MouseEventHandler | undefined)?.(e);\n e.persist();\n mouseDownEvent.current = e;\n mouseDownPosition.current = e.currentTarget.getBoundingClientRect();\n mouseDownTimestamp.current = Date.now();\n }}\n onMouseUp={(e: ReactMouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n const shouldFocus = mouseDownEvent.current && !mouseDownEvent.current.defaultPrevented;\n mouseDownEvent.current = undefined;\n mouseDownPosition.current = undefined;\n mouseDownTimestamp.current = undefined;\n\n if (shouldFocus && buttonRef.current !== document.activeElement) {\n buttonRef.current?.focus();\n }\n\n return (restProps.onMouseUp as MouseEventHandler | undefined)?.(e);\n }}\n >\n {showProgress && <Progress variant='ring' placement='inline' />}\n {!icon || !showProgress ? children : null}\n </StyledComp>\n\n {buttonEl && label && (\n <Tooltip target={buttonEl} showDelay='none' hideDelay='none' describeTarget={false}>\n {label}\n </Tooltip>\n )}\n </>\n );\n});\n\nexport default Button;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../src/components/Card/Card.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAmB,SAAS,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKnG,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKnE,MAAM,WAAW,SAAU,SAAQ,SAAS,EAAE,MAAM;IAClD,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kCAAkC;IAClC,OAAO,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACzC,6CAA6C;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACxB;AAED,eAAO,MAAM,UAAU,6HAqCrB,CAAC;AAIH,QAAA,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,GAAG,YAAY,CA6BpD,CAAC;AAEH,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../src/components/Card/Card.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAmB,SAAS,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKnG,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMnE,MAAM,WAAW,SAAU,SAAQ,SAAS,EAAE,MAAM;IAClD,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kCAAkC;IAClC,OAAO,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACzC,6CAA6C;IAC7C,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACxB;AAED,eAAO,MAAM,UAAU,6HA6CrB,CAAC;AAIH,QAAA,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,GAAG,YAAY,CA6BpD,CAAC;AAEH,eAAe,IAAI,CAAC"}
@@ -4,8 +4,10 @@ import styled, { css } from 'styled-components';
4
4
  import { defaultThemeProp } from '../../theme';
5
5
  import Flex from '../Flex';
6
6
  import { StyledPopover } from '../Popover';
7
+ import { useFullscreenContext } from '../Fullscreen';
7
8
  import { StyledCardMedia } from './CardMedia';
8
9
  export const StyledCard = styled.article(props => {
10
+ const fullscreen = useFullscreenContext();
9
11
  const { 'border-radius': borderRadius, 'border-color': borderColor, background } = props.theme.components.card;
10
12
  const interactive = props.interactive
11
13
  ? css `
@@ -35,6 +37,12 @@ export const StyledCard = styled.article(props => {
35
37
  border-radius: ${borderRadius} ${borderRadius} 0 0;
36
38
  }
37
39
  }
40
+
41
+ ${fullscreen?.[0] &&
42
+ css `
43
+ block-size: 100%;
44
+ border-radius: 0;
45
+ `}
38
46
  }
39
47
  `;
40
48
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Card.js","sourceRoot":"","sources":["../../../src/components/Card/Card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAiB9C,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAqB,KAAK,CAAC,EAAE;IACnE,MAAM,EACJ,eAAe,EAAE,YAAY,EAC7B,cAAc,EAAE,WAAW,EAC3B,UAAU,EACX,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;IAChC,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW;QACnC,CAAC,CAAC,GAAG,CAAA;;;wCAG+B,WAAW;;;;uCAIZ,WAAW;;OAE3C;QACH,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,GAAG,CAAA;MACN,aAAa;0BACO,UAAU;uBACb,YAAY;;;;;;QAM3B,WAAW;;QAEX,eAAe;;2BAEI,YAAY,IAAI,YAAY;;;;GAIpD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE3C,MAAM,IAAI,GAAgD,UAAU,CAAC,SAAS,IAAI,CAChF,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,WAAW,GAAG,KAAK,EAAE,GAAG,SAAS,EAA8B,EACxF,GAAqB;IAErB,MAAM,gBAAgB,GAAG;QACvB,GAAG,CAAC,OAAO,IAAI;YACb,OAAO;YACP,QAAQ,EAAE,CAAC;YACX,IAAI,EAAE,QAAQ;SACf,CAAC;QACF,GAAG,CAAC,WAAW,IAAI;YACjB,QAAQ,EAAE,CAAC;SACZ,CAAC;QACF,WAAW;KACZ,CAAC;IAEF,OAAO,CACL,KAAC,IAAI,IACH,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAClC,EAAE,EAAE,UAAU,EACd,WAAW,EAAE,EAAE,EACf,GAAG,EAAE,GAAG,KACJ,gBAAgB,KAChB,SAAS,YAEZ,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { FunctionComponent, Ref, PropsWithoutRef, ReactNode, MouseEventHandler } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport type { ForwardProps, BaseProps, AsProp } from '../../types';\nimport { StyledPopover } from '../Popover';\n\nimport { StyledCardMedia } from './CardMedia';\n\nexport interface CardProps extends BaseProps, AsProp {\n /** Components and content for the Card. */\n children?: ReactNode;\n /**\n * Enables the focus, hover, and active styles.\n * @default false\n * @deprecated\n */\n interactive?: boolean;\n /** Callback for onClick event. */\n onClick?: MouseEventHandler<HTMLElement>;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLElement>;\n}\n\nexport const StyledCard = styled.article<Partial<CardProps>>(props => {\n const {\n 'border-radius': borderRadius,\n 'border-color': borderColor,\n background\n } = props.theme.components.card;\n const interactive = props.interactive\n ? css`\n &:hover {\n border: 0;\n box-shadow: 0 0 0 0.0625rem ${borderColor};\n }\n &:focus {\n border: 0;\n box-shadow: 0 0 0 0.125rem ${borderColor};\n }\n `\n : undefined;\n\n return css`\n ${StyledPopover} &, &:not(& &) {\n background-color: ${background};\n border-radius: ${borderRadius};\n\n &:focus {\n outline: none;\n }\n\n ${interactive}\n\n ${StyledCardMedia} {\n &:first-child img {\n border-radius: ${borderRadius} ${borderRadius} 0 0;\n }\n }\n }\n `;\n});\n\nStyledCard.defaultProps = defaultThemeProp;\n\nconst Card: FunctionComponent<CardProps & ForwardProps> = forwardRef(function Card(\n { children, as, onClick, interactive = false, ...restProps }: PropsWithoutRef<CardProps>,\n ref: CardProps['ref']\n) {\n const interactiveProps = {\n ...(onClick && {\n onClick,\n tabIndex: 0,\n role: 'button'\n }),\n ...(interactive && {\n tabIndex: 0\n }),\n interactive\n };\n\n return (\n <Flex\n role='none'\n container={{ direction: 'column' }}\n as={StyledCard}\n forwardedAs={as}\n ref={ref}\n {...interactiveProps}\n {...restProps}\n >\n {children}\n </Flex>\n );\n});\n\nexport default Card;\n"]}
1
+ {"version":3,"file":"Card.js","sourceRoot":"","sources":["../../../src/components/Card/Card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAiB9C,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAqB,KAAK,CAAC,EAAE;IACnE,MAAM,UAAU,GAAG,oBAAoB,EAAE,CAAC;IAE1C,MAAM,EACJ,eAAe,EAAE,YAAY,EAC7B,cAAc,EAAE,WAAW,EAC3B,UAAU,EACX,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;IAChC,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW;QACnC,CAAC,CAAC,GAAG,CAAA;;;wCAG+B,WAAW;;;;uCAIZ,WAAW;;OAE3C;QACH,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,GAAG,CAAA;MACN,aAAa;0BACO,UAAU;uBACb,YAAY;;;;;;QAM3B,WAAW;;QAEX,eAAe;;2BAEI,YAAY,IAAI,YAAY;;;;QAI/C,UAAU,EAAE,CAAC,CAAC,CAAC;QACjB,GAAG,CAAA;;;OAGF;;GAEJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE3C,MAAM,IAAI,GAAgD,UAAU,CAAC,SAAS,IAAI,CAChF,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,WAAW,GAAG,KAAK,EAAE,GAAG,SAAS,EAA8B,EACxF,GAAqB;IAErB,MAAM,gBAAgB,GAAG;QACvB,GAAG,CAAC,OAAO,IAAI;YACb,OAAO;YACP,QAAQ,EAAE,CAAC;YACX,IAAI,EAAE,QAAQ;SACf,CAAC;QACF,GAAG,CAAC,WAAW,IAAI;YACjB,QAAQ,EAAE,CAAC;SACZ,CAAC;QACF,WAAW;KACZ,CAAC;IAEF,OAAO,CACL,KAAC,IAAI,IACH,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAClC,EAAE,EAAE,UAAU,EACd,WAAW,EAAE,EAAE,EACf,GAAG,EAAE,GAAG,KACJ,gBAAgB,KAChB,SAAS,YAEZ,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { FunctionComponent, Ref, PropsWithoutRef, ReactNode, MouseEventHandler } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport type { ForwardProps, BaseProps, AsProp } from '../../types';\nimport { StyledPopover } from '../Popover';\nimport { useFullscreenContext } from '../Fullscreen';\n\nimport { StyledCardMedia } from './CardMedia';\n\nexport interface CardProps extends BaseProps, AsProp {\n /** Components and content for the Card. */\n children?: ReactNode;\n /**\n * Enables the focus, hover, and active styles.\n * @default false\n * @deprecated\n */\n interactive?: boolean;\n /** Callback for onClick event. */\n onClick?: MouseEventHandler<HTMLElement>;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLElement>;\n}\n\nexport const StyledCard = styled.article<Partial<CardProps>>(props => {\n const fullscreen = useFullscreenContext();\n\n const {\n 'border-radius': borderRadius,\n 'border-color': borderColor,\n background\n } = props.theme.components.card;\n const interactive = props.interactive\n ? css`\n &:hover {\n border: 0;\n box-shadow: 0 0 0 0.0625rem ${borderColor};\n }\n &:focus {\n border: 0;\n box-shadow: 0 0 0 0.125rem ${borderColor};\n }\n `\n : undefined;\n\n return css`\n ${StyledPopover} &, &:not(& &) {\n background-color: ${background};\n border-radius: ${borderRadius};\n\n &:focus {\n outline: none;\n }\n\n ${interactive}\n\n ${StyledCardMedia} {\n &:first-child img {\n border-radius: ${borderRadius} ${borderRadius} 0 0;\n }\n }\n\n ${fullscreen?.[0] &&\n css`\n block-size: 100%;\n border-radius: 0;\n `}\n }\n `;\n});\n\nStyledCard.defaultProps = defaultThemeProp;\n\nconst Card: FunctionComponent<CardProps & ForwardProps> = forwardRef(function Card(\n { children, as, onClick, interactive = false, ...restProps }: PropsWithoutRef<CardProps>,\n ref: CardProps['ref']\n) {\n const interactiveProps = {\n ...(onClick && {\n onClick,\n tabIndex: 0,\n role: 'button'\n }),\n ...(interactive && {\n tabIndex: 0\n }),\n interactive\n };\n\n return (\n <Flex\n role='none'\n container={{ direction: 'column' }}\n as={StyledCard}\n forwardedAs={as}\n ref={ref}\n {...interactiveProps}\n {...restProps}\n >\n {children}\n </Flex>\n );\n});\n\nexport default Card;\n"]}
@@ -103,6 +103,6 @@ export default withTestIds(forwardRef(function ColorPicker(props, ref) {
103
103
  hsl: { h, s, l }
104
104
  }, e);
105
105
  };
106
- return (_jsx(FormField, { testId: testIds, inline: inline, container: inline ? { justify: 'between' } : undefined, as: StyledColorPicker, id: id, label: label, labelHidden: labelHidden, swatchOnly: swatchOnly, info: info, disabled: disabled, status: status, required: required, additionalInfo: additionalInfo, children: _jsxs(Flex, { container: { alignItems: 'center' }, item: swatchOnly ? { alignSelf: 'start' } : undefined, as: StyledFormControl, disabled: disabled, status: status, required: required, readOnly: readOnly, onClick: readOnly || disabled ? undefined : () => setShowColorPicker(true), children: [_jsx("input", { "data-testid": testIds.control, ...restProps, id: id, type: readOnly ? undefined : 'color', ref: inputRef, defaultValue: value, disabled: disabled, required: required, readOnly: readOnly, onChange: onChangeHandler }), _jsx("div", { style: { backgroundColor: value } }), !swatchOnly && value] }) }));
106
+ return (_jsx(FormField, { testId: testIds, inline: inline, container: inline ? { justify: 'between' } : undefined, as: StyledColorPicker, id: id, label: label, labelHidden: labelHidden, swatchOnly: swatchOnly, info: info, disabled: disabled, status: status, required: required, additionalInfo: additionalInfo, children: _jsxs(Flex, { container: { alignItems: 'center' }, item: swatchOnly ? { alignSelf: 'start' } : undefined, as: StyledFormControl, disabled: disabled, status: status, required: required, readOnly: readOnly, onClick: readOnly || disabled ? undefined : () => setShowColorPicker(true), children: [_jsx("input", { "data-testid": testIds.control, ...restProps, id: id, type: readOnly ? undefined : 'color', ref: inputRef, value: value, disabled: disabled, required: required, readOnly: readOnly, onChange: onChangeHandler }), _jsx("div", { style: { backgroundColor: value } }), !swatchOnly && value] }) }));
107
107
  }), getColorPickerTestIds);
108
108
  //# sourceMappingURL=ColorPicker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAA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AAS,EACrD,EAAE,EAAE,iBAAiB,EACrB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,aAE1E,+BACe,OAAO,CAAC,OAAO,KACxB,SAAS,EACb,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EACpC,GAAG,EAAE,QAAQ,EACb,YAAY,EAAE,KAAK,EACnB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,eAAe,GACzB,EACF,cAAK,KAAK,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,GAAI,EACzC,CAAC,UAAU,IAAI,KAAK,IAChB,GACG,CACb,CAAC;AACJ,CAAC,CACF,EACD,qBAAqB,CACtB,CAAC","sourcesContent":["import { forwardRef, useState, useEffect } from 'react';\nimport type { PropsWithoutRef, ChangeEvent } from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually, parseToHsl, parseToRgb } from 'polished';\n\nimport type {\n NoChildrenProp,\n PropsWithDefaults,\n RefElement,\n TestIdProp,\n WithAttributes\n} from '../../types';\nimport { withTestIds } from '../../utils';\nimport FormField from '../FormField';\nimport type { FormFieldProps } from '../FormField';\nimport { defaultThemeProp } from '../../theme';\nimport { StyledFormControl } from '../FormControl';\nimport type { FormControlProps } from '../FormControl';\nimport Flex from '../Flex';\nimport { useConsolidatedRef, useUID, useOuterEvent, useTestIds } from '../../hooks';\n\nimport { getColorPickerTestIds } from './ColorPicker.test-ids';\n\nexport type ColorPickerProps = WithAttributes<\n 'input',\n TestIdProp &\n NoChildrenProp & {\n /** label for the color picker control */\n label: FormControlProps['label'];\n /**\n * Color picker value in hex\n * @default '#000000'\n */\n value?: FormControlProps['value'];\n /**\n * Show color swatch without hex value display.\n * @default false\n */\n swatchOnly?: boolean;\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Layout field elements inline in a row. */\n inline?: FormFieldProps['inline'];\n /** Button when clicked will show additional information on the color picker */\n additionalInfo?: FormFieldProps['additionalInfo'];\n /** onChange event handler that gets called on change of value. */\n onChange?: ColorChangeHandler;\n /** onBeforeClose of the color picker */\n onBeforeClose?: () => void;\n }\n>;\n\ntype RGBColor = {\n r: number;\n g: number;\n b: number;\n};\n\ntype HSLColor = {\n h: number;\n s: number;\n l: number;\n};\n\ntype ColorResult = {\n hex: string;\n rgb: RGBColor;\n hsl: HSLColor;\n};\n\ntype ColorChangeHandler = (color: ColorResult, event: ChangeEvent<HTMLInputElement>) => void;\n\ntype ColorPickerPropsWithDefaults = PropsWithDefaults<ColorPickerProps, 'value' | 'swatchOnly'>;\n\nconst StyledColorPicker = styled.div<Pick<ColorPickerPropsWithDefaults, 'swatchOnly'>>(\n ({ theme, swatchOnly }) => {\n const size = theme.components.input.height;\n const borderWidth = theme.components['form-control']['border-width'];\n\n return css`\n ${StyledFormControl} {\n overflow: hidden;\n text-transform: uppercase;\n ${!swatchOnly &&\n css`\n min-width: 8rem;\n `}\n\n ${!swatchOnly &&\n css`\n padding-inline-end: ${theme.base.spacing};\n `}\n\n &:focus-within {\n box-shadow: ${theme.base.shadow.focus};\n border: none;\n }\n\n & > input {\n ${hideVisually}\n\n & + div {\n height: calc(${size} - (2 * ${borderWidth}));\n\n ${swatchOnly\n ? css`\n width: calc(${size} - (2 * ${borderWidth}));\n `\n : css`\n min-width: calc(${size} - ${borderWidth});\n margin-inline-end: ${theme.base.spacing};\n border-inline-end: ${borderWidth} solid\n ${theme.components['form-control']['border-color']};\n `}\n }\n\n &:focus + div {\n width: ${size};\n height: ${size};\n }\n }\n\n & input {\n height: 2rem !important;\n min-height: 2rem;\n color: #000000 !important;\n background-color: #ffffff !important;\n font-size: 0.8125rem !important;\n font-family: ${theme.base['font-family']};\n\n & + label {\n font-weight: 600;\n color: rgba(0, 0, 0, 0.6) !important;\n font-size: 0.8125rem !important;\n font-family: ${theme.base['font-family']};\n }\n }\n }\n `;\n }\n);\n\nStyledColorPicker.defaultProps = defaultThemeProp;\n\nexport default withTestIds(\n forwardRef<RefElement<ColorPickerProps>, PropsWithoutRef<ColorPickerProps>>(\n function ColorPicker(props, ref) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n value = '#000000',\n label,\n info,\n disabled,\n status,\n required,\n readOnly,\n labelHidden,\n swatchOnly = false,\n inline,\n onClick,\n onChange,\n onBeforeClose,\n additionalInfo,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getColorPickerTestIds);\n\n const inputRef = useConsolidatedRef(ref);\n const [showColorPicker, setShowColorPicker] = useState(false);\n\n const hideColorPicker = () => {\n if (showColorPicker) {\n onBeforeClose?.();\n }\n\n setShowColorPicker(false);\n };\n\n useOuterEvent('mousedown', [inputRef], hideColorPicker);\n\n useEffect(() => {\n if (showColorPicker) {\n inputRef?.current?.focus();\n inputRef?.current?.click();\n }\n }, [showColorPicker]);\n\n const onChangeHandler = (e: ChangeEvent<HTMLInputElement>) => {\n const color = e.target.value;\n const { red: r, green: g, blue: b } = parseToRgb(color);\n const { hue: h, saturation: s, lightness: l } = parseToHsl(color);\n onChange?.(\n {\n hex: color,\n rgb: { r, g, b },\n hsl: { h, s, l }\n },\n e\n );\n };\n\n return (\n <FormField\n testId={testIds}\n inline={inline}\n container={inline ? { justify: 'between' } : undefined}\n as={StyledColorPicker}\n id={id}\n label={label}\n labelHidden={labelHidden}\n swatchOnly={swatchOnly}\n info={info}\n disabled={disabled}\n status={status}\n required={required}\n additionalInfo={additionalInfo}\n >\n <Flex\n container={{ alignItems: 'center' }}\n item={swatchOnly ? { alignSelf: 'start' } : undefined}\n as={StyledFormControl}\n disabled={disabled}\n status={status}\n required={required}\n readOnly={readOnly}\n onClick={readOnly || disabled ? undefined : () => setShowColorPicker(true)}\n >\n <input\n data-testid={testIds.control}\n {...restProps}\n id={id}\n type={readOnly ? undefined : 'color'}\n ref={inputRef}\n defaultValue={value}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n onChange={onChangeHandler}\n />\n <div style={{ backgroundColor: value }} />\n {!swatchOnly && value}\n </Flex>\n </FormField>\n );\n }\n ),\n getColorPickerTestIds\n);\n"]}
1
+ {"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAShE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAyD/D,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAClC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE;IACxB,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,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ACtB,CAAC","sourcesContent":["import { forwardRef, useState, useEffect } from 'react';\nimport type { PropsWithoutRef, ChangeEvent } from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually, parseToHsl, parseToRgb } from 'polished';\n\nimport type {\n NoChildrenProp,\n PropsWithDefaults,\n RefElement,\n TestIdProp,\n WithAttributes\n} from '../../types';\nimport { withTestIds } from '../../utils';\nimport FormField from '../FormField';\nimport type { FormFieldProps } from '../FormField';\nimport { defaultThemeProp } from '../../theme';\nimport { StyledFormControl } from '../FormControl';\nimport type { FormControlProps } from '../FormControl';\nimport Flex from '../Flex';\nimport { useConsolidatedRef, useUID, useOuterEvent, useTestIds } from '../../hooks';\n\nimport { getColorPickerTestIds } from './ColorPicker.test-ids';\n\nexport type ColorPickerProps = WithAttributes<\n 'input',\n TestIdProp &\n NoChildrenProp & {\n /** label for the color picker control */\n label: FormControlProps['label'];\n /**\n * Color picker value in hex\n * @default '#000000'\n */\n value?: FormControlProps['value'];\n /**\n * Show color swatch without hex value display.\n * @default false\n */\n swatchOnly?: boolean;\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Layout field elements inline in a row. */\n inline?: FormFieldProps['inline'];\n /** Button when clicked will show additional information on the color picker */\n additionalInfo?: FormFieldProps['additionalInfo'];\n /** onChange event handler that gets called on change of value. */\n onChange?: ColorChangeHandler;\n /** onBeforeClose of the color picker */\n onBeforeClose?: () => void;\n }\n>;\n\ntype RGBColor = {\n r: number;\n g: number;\n b: number;\n};\n\ntype HSLColor = {\n h: number;\n s: number;\n l: number;\n};\n\ntype ColorResult = {\n hex: string;\n rgb: RGBColor;\n hsl: HSLColor;\n};\n\ntype ColorChangeHandler = (color: ColorResult, event: ChangeEvent<HTMLInputElement>) => void;\n\ntype ColorPickerPropsWithDefaults = PropsWithDefaults<ColorPickerProps, 'value' | 'swatchOnly'>;\n\nconst StyledColorPicker = styled.div<Pick<ColorPickerPropsWithDefaults, 'swatchOnly'>>(\n ({ theme, swatchOnly }) => {\n const size = theme.components.input.height;\n const borderWidth = theme.components['form-control']['border-width'];\n\n return css`\n ${StyledFormControl} {\n overflow: hidden;\n text-transform: uppercase;\n ${!swatchOnly &&\n css`\n min-width: 8rem;\n `}\n\n ${!swatchOnly &&\n css`\n padding-inline-end: ${theme.base.spacing};\n `}\n\n &:focus-within {\n box-shadow: ${theme.base.shadow.focus};\n border: none;\n }\n\n & > input {\n ${hideVisually}\n\n & + div {\n height: calc(${size} - (2 * ${borderWidth}));\n\n ${swatchOnly\n ? css`\n width: calc(${size} - (2 * ${borderWidth}));\n `\n : css`\n min-width: calc(${size} - ${borderWidth});\n margin-inline-end: ${theme.base.spacing};\n border-inline-end: ${borderWidth} solid\n ${theme.components['form-control']['border-color']};\n `}\n }\n\n &:focus + div {\n width: ${size};\n height: ${size};\n }\n }\n\n & input {\n height: 2rem !important;\n min-height: 2rem;\n color: #000000 !important;\n background-color: #ffffff !important;\n font-size: 0.8125rem !important;\n font-family: ${theme.base['font-family']};\n\n & + label {\n font-weight: 600;\n color: rgba(0, 0, 0, 0.6) !important;\n font-size: 0.8125rem !important;\n font-family: ${theme.base['font-family']};\n }\n }\n }\n `;\n }\n);\n\nStyledColorPicker.defaultProps = defaultThemeProp;\n\nexport default withTestIds(\n forwardRef<RefElement<ColorPickerProps>, PropsWithoutRef<ColorPickerProps>>(\n function ColorPicker(props, ref) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n value = '#000000',\n label,\n info,\n disabled,\n status,\n required,\n readOnly,\n labelHidden,\n swatchOnly = false,\n inline,\n onClick,\n onChange,\n onBeforeClose,\n additionalInfo,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getColorPickerTestIds);\n\n const inputRef = useConsolidatedRef(ref);\n const [showColorPicker, setShowColorPicker] = useState(false);\n\n const hideColorPicker = () => {\n if (showColorPicker) {\n onBeforeClose?.();\n }\n\n setShowColorPicker(false);\n };\n\n useOuterEvent('mousedown', [inputRef], hideColorPicker);\n\n useEffect(() => {\n if (showColorPicker) {\n inputRef?.current?.focus();\n inputRef?.current?.click();\n }\n }, [showColorPicker]);\n\n const onChangeHandler = (e: ChangeEvent<HTMLInputElement>) => {\n const color = e.target.value;\n const { red: r, green: g, blue: b } = parseToRgb(color);\n const { hue: h, saturation: s, lightness: l } = parseToHsl(color);\n onChange?.(\n {\n hex: color,\n rgb: { r, g, b },\n hsl: { h, s, l }\n },\n e\n );\n };\n\n return (\n <FormField\n testId={testIds}\n inline={inline}\n container={inline ? { justify: 'between' } : undefined}\n as={StyledColorPicker}\n id={id}\n label={label}\n labelHidden={labelHidden}\n swatchOnly={swatchOnly}\n info={info}\n disabled={disabled}\n status={status}\n required={required}\n additionalInfo={additionalInfo}\n >\n <Flex\n container={{ alignItems: 'center' }}\n item={swatchOnly ? { alignSelf: 'start' } : undefined}\n as={StyledFormControl}\n disabled={disabled}\n status={status}\n required={required}\n readOnly={readOnly}\n onClick={readOnly || disabled ? undefined : () => setShowColorPicker(true)}\n >\n <input\n data-testid={testIds.control}\n {...restProps}\n id={id}\n type={readOnly ? undefined : 'color'}\n ref={inputRef}\n value={value}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n onChange={onChangeHandler}\n />\n <div style={{ backgroundColor: value }} />\n {!swatchOnly && value}\n </Flex>\n </FormField>\n );\n }\n ),\n getColorPickerTestIds\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.styles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB,yGAyD5B,CAAC;AAIH,eAAO,MAAM,cAAc;;SAczB,CAAC"}
1
+ {"version":3,"file":"ComboBox.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.styles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB,yGAyD5B,CAAC;AAIH,eAAO,MAAM,cAAc;;SAkBzB,CAAC"}
@@ -67,6 +67,10 @@ export const StyledComboBox = styled(StyledFormControl)(() => {
67
67
  return css `
68
68
  border: 0;
69
69
 
70
+ &:focus {
71
+ z-index: 1;
72
+ }
73
+
70
74
  ${StyledPopover} {
71
75
  border-top-left-radius: 0;
72
76
  border-top-right-radius: 0;
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.styles.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE;IAC9E,OAAO,GAAG,CAAA;;oBAEQ,IAAI,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC;;;;;UAKxC,UAAU,CAAC,KAAK,CAAC,MAAM,UAAU,UAAU,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC;;;;;sBAK/D,UAAU,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC;oBACtD,UAAU,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC;;;;;;;;;;qBAUjD,UAAU,CAAC,KAAK,CAAC,MAAM,UAAU,UAAU,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC;eACjF,UAAU,CAAC,cAAc,CAAC,CAAC,kBAAkB,CAAC;;uBAEtC,IAAI,CAAC,OAAO;;;;;;;;;;;;;;;UAezB,YAAY;;;;;;;UAOZ,IAAI,CAAC,eAAe,CAAC,MAAM,UAAU,CAAC,cAAc,CAAC,CAAC,eAAe,CAAC;;;;UAItE,IAAI,CAAC,eAAe,CAAC,MAAM,UAAU,CAAC,cAAc,CAAC,CAAC,eAAe,CAAC;;;GAG7E,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,GAAG,EAAE;IAC3D,OAAO,GAAG,CAAA;;;MAGN,aAAa;;;;QAIX,UAAU;QACV,qBAAqB;;;;GAI1B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { StyledButton } from '../Button';\nimport { StyledFormControl } from '../FormControl';\nimport { StyledPopover } from '../Popover';\nimport { StyledMenu, StyledMenuListWrapper } from '../Menu/Menu.styles';\n\nexport const StyledSelectInput = styled.div(({ theme: { base, components } }) => {\n return css`\n @media (pointer: coarse) {\n min-height: ${base['hit-area']['finger-min']};\n }\n\n div {\n min-height: calc(\n ${components.input.height} - 2 * ${components['form-control']['border-width']}\n );\n }\n\n &:focus-within {\n border-color: ${components['form-control'][':focus']['border-color']};\n box-shadow: ${components['form-control'][':focus']['box-shadow']};\n }\n\n &:hover:not([readonly]):not([disabled]):focus-within {\n border-color: transparent;\n }\n\n input {\n min-width: 0;\n width: 100%;\n height: calc(${components.input.height} - 2 * ${components['form-control']['border-width']});\n color: ${components['form-control']['foreground-color']};\n text-overflow: ellipsis;\n margin-inline: ${base.spacing};\n }\n\n input,\n input:focus {\n border: none;\n outline: none;\n flex-grow: 1;\n background-color: transparent;\n\n &:read-only {\n cursor: default;\n }\n }\n\n & > ${StyledButton} {\n align-self: stretch;\n height: auto;\n margin-block: -0.0625rem;\n margin-inline-end: -0.0625rem;\n border-start-start-radius: 0;\n border-start-end-radius: calc(\n ${base['border-radius']} * ${components['form-control']['border-radius']}\n );\n border-end-start-radius: 0;\n border-end-end-radius: calc(\n ${base['border-radius']} * ${components['form-control']['border-radius']}\n );\n }\n `;\n});\n\nStyledSelectInput.defaultProps = defaultThemeProp;\n\nexport const StyledComboBox = styled(StyledFormControl)(() => {\n return css`\n border: 0;\n\n ${StyledPopover} {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n\n ${StyledMenu},\n ${StyledMenuListWrapper} {\n max-height: inherit;\n }\n }\n `;\n});\n\nStyledComboBox.defaultProps = defaultThemeProp;\n"]}
1
+ {"version":3,"file":"ComboBox.styles.js","sourceRoot":"","sources":["../../../src/components/ComboBox/ComboBox.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE;IAC9E,OAAO,GAAG,CAAA;;oBAEQ,IAAI,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC;;;;;UAKxC,UAAU,CAAC,KAAK,CAAC,MAAM,UAAU,UAAU,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC;;;;;sBAK/D,UAAU,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC;oBACtD,UAAU,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC;;;;;;;;;;qBAUjD,UAAU,CAAC,KAAK,CAAC,MAAM,UAAU,UAAU,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC;eACjF,UAAU,CAAC,cAAc,CAAC,CAAC,kBAAkB,CAAC;;uBAEtC,IAAI,CAAC,OAAO;;;;;;;;;;;;;;;UAezB,YAAY;;;;;;;UAOZ,IAAI,CAAC,eAAe,CAAC,MAAM,UAAU,CAAC,cAAc,CAAC,CAAC,eAAe,CAAC;;;;UAItE,IAAI,CAAC,eAAe,CAAC,MAAM,UAAU,CAAC,cAAc,CAAC,CAAC,eAAe,CAAC;;;GAG7E,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,GAAG,EAAE;IAC3D,OAAO,GAAG,CAAA;;;;;;;MAON,aAAa;;;;QAIX,UAAU;QACV,qBAAqB;;;;GAI1B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { StyledButton } from '../Button';\nimport { StyledFormControl } from '../FormControl';\nimport { StyledPopover } from '../Popover';\nimport { StyledMenu, StyledMenuListWrapper } from '../Menu/Menu.styles';\n\nexport const StyledSelectInput = styled.div(({ theme: { base, components } }) => {\n return css`\n @media (pointer: coarse) {\n min-height: ${base['hit-area']['finger-min']};\n }\n\n div {\n min-height: calc(\n ${components.input.height} - 2 * ${components['form-control']['border-width']}\n );\n }\n\n &:focus-within {\n border-color: ${components['form-control'][':focus']['border-color']};\n box-shadow: ${components['form-control'][':focus']['box-shadow']};\n }\n\n &:hover:not([readonly]):not([disabled]):focus-within {\n border-color: transparent;\n }\n\n input {\n min-width: 0;\n width: 100%;\n height: calc(${components.input.height} - 2 * ${components['form-control']['border-width']});\n color: ${components['form-control']['foreground-color']};\n text-overflow: ellipsis;\n margin-inline: ${base.spacing};\n }\n\n input,\n input:focus {\n border: none;\n outline: none;\n flex-grow: 1;\n background-color: transparent;\n\n &:read-only {\n cursor: default;\n }\n }\n\n & > ${StyledButton} {\n align-self: stretch;\n height: auto;\n margin-block: -0.0625rem;\n margin-inline-end: -0.0625rem;\n border-start-start-radius: 0;\n border-start-end-radius: calc(\n ${base['border-radius']} * ${components['form-control']['border-radius']}\n );\n border-end-start-radius: 0;\n border-end-end-radius: calc(\n ${base['border-radius']} * ${components['form-control']['border-radius']}\n );\n }\n `;\n});\n\nStyledSelectInput.defaultProps = defaultThemeProp;\n\nexport const StyledComboBox = styled(StyledFormControl)(() => {\n return css`\n border: 0;\n\n &:focus {\n z-index: 1;\n }\n\n ${StyledPopover} {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n\n ${StyledMenu},\n ${StyledMenuListWrapper} {\n max-height: inherit;\n }\n }\n `;\n});\n\nStyledComboBox.defaultProps = defaultThemeProp;\n"]}
@@ -5,6 +5,7 @@ import type { StyleSheetManagerProps } from 'styled-components';
5
5
  import '../../init';
6
6
  import type { ThemeMachineLike, DefaultSettableTheme, DefaultThemeDefinition } from '../../theme';
7
7
  import type { Translation, TranslationPack } from '../../i18n';
8
+ import './connected-watcher';
8
9
  export interface ConfigurationProps {
9
10
  /** Any components or nodes that should be impacted by the settings applied by this Configuration component. */
10
11
  children: ReactNode;