@pega/cosmos-react-core 7.0.0-build.22.2 → 7.0.0-build.22.20
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.
- package/lib/components/AIButton/AIButton.d.ts +2 -0
- package/lib/components/AIButton/AIButton.d.ts.map +1 -1
- package/lib/components/AIButton/AIButton.js +4 -4
- package/lib/components/AIButton/AIButton.js.map +1 -1
- package/lib/components/Actions/Actions.d.ts +1 -1
- package/lib/components/Actions/Actions.d.ts.map +1 -1
- package/lib/components/Actions/Actions.js +3 -3
- package/lib/components/Actions/Actions.js.map +1 -1
- package/lib/components/AppShell/AppHeader.d.ts.map +1 -1
- package/lib/components/AppShell/AppHeader.js +4 -6
- package/lib/components/AppShell/AppHeader.js.map +1 -1
- package/lib/components/AppShell/AppHeader.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppHeader.styles.js +6 -2
- package/lib/components/AppShell/AppHeader.styles.js.map +1 -1
- package/lib/components/Banner/Banner.d.ts.map +1 -1
- package/lib/components/Banner/Banner.js +1 -1
- package/lib/components/Banner/Banner.js.map +1 -1
- package/lib/components/Button/Button.d.ts.map +1 -1
- package/lib/components/Button/Button.js +47 -34
- package/lib/components/Button/Button.js.map +1 -1
- package/lib/components/Card/Card.d.ts.map +1 -1
- package/lib/components/Card/Card.js +8 -0
- package/lib/components/Card/Card.js.map +1 -1
- package/lib/components/Configuration/Configuration.d.ts +1 -0
- package/lib/components/Configuration/Configuration.d.ts.map +1 -1
- package/lib/components/Configuration/Configuration.js +58 -30
- package/lib/components/Configuration/Configuration.js.map +1 -1
- package/lib/components/Configuration/connected-watcher.d.ts +17 -0
- package/lib/components/Configuration/connected-watcher.d.ts.map +1 -0
- package/lib/components/Configuration/connected-watcher.js +13 -0
- package/lib/components/Configuration/connected-watcher.js.map +1 -0
- package/lib/components/DateTime/Input/MonthInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/MonthInput.js +21 -10
- package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.js +5 -32
- package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
- package/lib/components/DateTime/Picker/utils.d.ts +9 -0
- package/lib/components/DateTime/Picker/utils.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/utils.js +16 -0
- package/lib/components/DateTime/Picker/utils.js.map +1 -1
- package/lib/components/File/CompactList.js +1 -1
- package/lib/components/File/CompactList.js.map +1 -1
- package/lib/components/File/FileInput.d.ts +30 -6
- package/lib/components/File/FileInput.d.ts.map +1 -1
- package/lib/components/File/FileInput.js +105 -89
- package/lib/components/File/FileInput.js.map +1 -1
- package/lib/components/File/FileInput.styles.d.ts +23 -0
- package/lib/components/File/FileInput.styles.d.ts.map +1 -0
- package/lib/components/File/FileInput.styles.js +141 -0
- package/lib/components/File/FileInput.styles.js.map +1 -0
- package/lib/components/File/FileItem.d.ts +3 -5
- package/lib/components/File/FileItem.d.ts.map +1 -1
- package/lib/components/File/FileItem.js +7 -14
- package/lib/components/File/FileItem.js.map +1 -1
- package/lib/components/File/FileList.d.ts +0 -2
- package/lib/components/File/FileList.d.ts.map +1 -1
- package/lib/components/File/FileList.js +2 -2
- package/lib/components/File/FileList.js.map +1 -1
- package/lib/components/Fullscreen/Fullscreen.d.ts +18 -0
- package/lib/components/Fullscreen/Fullscreen.d.ts.map +1 -0
- package/lib/components/Fullscreen/Fullscreen.js +51 -0
- package/lib/components/Fullscreen/Fullscreen.js.map +1 -0
- package/lib/components/Fullscreen/Fullscreen.test-ids.d.ts +2 -0
- package/lib/components/Fullscreen/Fullscreen.test-ids.d.ts.map +1 -0
- package/lib/components/Fullscreen/Fullscreen.test-ids.js +3 -0
- package/lib/components/Fullscreen/Fullscreen.test-ids.js.map +1 -0
- package/lib/components/Fullscreen/FullscreenButton.d.ts +6 -0
- package/lib/components/Fullscreen/FullscreenButton.d.ts.map +1 -0
- package/lib/components/Fullscreen/FullscreenButton.js +33 -0
- package/lib/components/Fullscreen/FullscreenButton.js.map +1 -0
- package/lib/components/Fullscreen/index.d.ts +4 -0
- package/lib/components/Fullscreen/index.d.ts.map +1 -0
- package/lib/components/Fullscreen/index.js +4 -0
- package/lib/components/Fullscreen/index.js.map +1 -0
- package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.js +3 -2
- package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
- package/lib/components/Location/Location.types.d.ts +1 -0
- package/lib/components/Location/Location.types.d.ts.map +1 -1
- package/lib/components/Location/Location.types.js.map +1 -1
- package/lib/components/Location/LocationView.d.ts.map +1 -1
- package/lib/components/Location/LocationView.js +31 -7
- package/lib/components/Location/LocationView.js.map +1 -1
- package/lib/components/Location/utils.d.ts.map +1 -1
- package/lib/components/Location/utils.js +23 -21
- package/lib/components/Location/utils.js.map +1 -1
- package/lib/components/Modal/ModalManager.d.ts.map +1 -1
- package/lib/components/Modal/ModalManager.js +5 -1
- package/lib/components/Modal/ModalManager.js.map +1 -1
- package/lib/components/Popover/modifiers.js +4 -4
- package/lib/components/Popover/modifiers.js.map +1 -1
- package/lib/components/Tabs/Tab.d.ts.map +1 -1
- package/lib/components/Tabs/Tab.js +4 -0
- package/lib/components/Tabs/Tab.js.map +1 -1
- package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/lib/components/Tooltip/Tooltip.js +3 -1
- package/lib/components/Tooltip/Tooltip.js.map +1 -1
- package/lib/hooks/useArrows.d.ts.map +1 -1
- package/lib/hooks/useArrows.js +3 -1
- package/lib/hooks/useArrows.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +11 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/hooks/useScrollToggle.d.ts.map +1 -1
- package/lib/hooks/useScrollToggle.js +1 -0
- package/lib/hooks/useScrollToggle.js.map +1 -1
- package/lib/i18n/default.d.ts +11 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +12 -0
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +11 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/theme/theme.d.ts +6 -0
- package/lib/theme/theme.d.ts.map +1 -1
- package/lib/theme/themeDefinition.json +5 -1
- package/lib/theme/themeOverrides.schema.json +3 -0
- package/package.json +7 -4
|
@@ -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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,EAC3B,OAAO,EAAE,YAAY,gBACT,SAAS,IAAI,KAAK,EAC9B,WAAW,EAAE,CAAC,CAAoD,EAAE,EAAE;oBACnE,SAAS,CAAC,WAA6C,EAAE,CAAC,CAAC,CAAC,CAAC;oBAC9D,CAAC,CAAC,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,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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,CAAC,CAAC;oBAC9D,CAAC,CAAC,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\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<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 +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;
|
|
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,UA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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"]}
|
|
@@ -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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../../src/components/Configuration/Configuration.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAiB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAMlG,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../../src/components/Configuration/Configuration.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAiB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAMlG,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAM/D,OAAO,qBAAqB,CAAC;AAE7B,MAAM,WAAW,kBAAkB;IACjC,+GAA+G;IAC/G,QAAQ,EAAE,SAAS,CAAC;IACpB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2GAA2G;IAC3G,SAAS,CAAC,EAAE,KAAK,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C;AAErE,UAAU,mBAAmB;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,CAAC,aAAa,CAAC,CAAC,EAAE;YAChB,IAAI,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;SAC/C,CAAC;KACH;CACF;AAID,UAAU,cAAe,SAAQ,mBAAmB;IAClD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AA4BD,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAiB,aAAa;QAC5B,SAAS,CAAC,EAAE,CAAC,cAAc,GAAG,mBAAmB,CAAC,EAAE,CAAC;QACrD,oBAAoB,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC;KAC3D;CACF;AAuBD,QAAA,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,CAkLxD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createContext, useContext, useMemo, useEffect } from 'react';
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo, useEffect, useState } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import { ThemeProvider, StyleSheetManager } from 'styled-components';
|
|
5
5
|
import '../../init';
|
|
@@ -9,6 +9,7 @@ import { createTranslationPack, DefaultTranslation, direction as directionOfLoca
|
|
|
9
9
|
import { documentIsAvailable, navigatorIsAvailable, windowIsAvailable } from '../../utils';
|
|
10
10
|
import pkg from '../../../package.json';
|
|
11
11
|
import useElement from '../../hooks/useElement';
|
|
12
|
+
import './connected-watcher';
|
|
12
13
|
const defaultLocale = navigatorIsAvailable ? navigator.language : 'en';
|
|
13
14
|
export const ConfigurationContext = createContext({
|
|
14
15
|
locale: defaultLocale,
|
|
@@ -72,10 +73,24 @@ const Configuration = ({ children, locale, direction, translations: customTransl
|
|
|
72
73
|
: ctx.themeMachine;
|
|
73
74
|
const translations = useMemo(() => createTranslationPack({ ...ctx.translations, ...customTranslations }), [ctx.translations, customTranslations]);
|
|
74
75
|
const [wrapperEl, setWrapperEl] = useElement();
|
|
76
|
+
const [connectedWatcherEl, setConnectedWatcherEl] = useElement();
|
|
77
|
+
// State tracking if the DOM nodes are connected. Only used to trigger rerenders when connected state changes.
|
|
78
|
+
const [, setConnected] = useState(null);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (!connectedWatcherEl)
|
|
81
|
+
return;
|
|
82
|
+
const connectDisconnectListener = () => {
|
|
83
|
+
setConnected(connectedWatcherEl.isConnected);
|
|
84
|
+
};
|
|
85
|
+
connectedWatcherEl.addEventListener('connect-disconnect', connectDisconnectListener);
|
|
86
|
+
return () => {
|
|
87
|
+
connectedWatcherEl.removeEventListener('connect-disconnect', connectDisconnectListener);
|
|
88
|
+
};
|
|
89
|
+
}, [connectedWatcherEl]);
|
|
75
90
|
// Determine valid style sheet and portal target with ShadowDOM handling.
|
|
76
91
|
const [resolvedStyleSheetTarget, resolvedPortalTarget] = useMemo(() => {
|
|
77
92
|
// When rendering on the server, or before the wrapper is in the DOM, just bail.
|
|
78
|
-
if (!documentIsAvailable || !wrapperEl)
|
|
93
|
+
if (!documentIsAvailable || !wrapperEl?.isConnected)
|
|
79
94
|
return [undefined, undefined];
|
|
80
95
|
const rootNode = wrapperEl.getRootNode();
|
|
81
96
|
// When within the ShadowDOM, the default target is the ShadowRoot, otherwise default to head/body element.
|
|
@@ -91,9 +106,20 @@ const Configuration = ({ children, locale, direction, translations: customTransl
|
|
|
91
106
|
: defaultStyleSheetTarget,
|
|
92
107
|
rootNode.contains(requestedPortalTarget ?? null) ? requestedPortalTarget : defaultPortalTarget
|
|
93
108
|
];
|
|
94
|
-
}, [
|
|
95
|
-
|
|
96
|
-
|
|
109
|
+
}, [
|
|
110
|
+
wrapperEl,
|
|
111
|
+
wrapperEl?.isConnected,
|
|
112
|
+
styleSheetTarget,
|
|
113
|
+
portalTarget,
|
|
114
|
+
ctx.styleSheetTarget,
|
|
115
|
+
ctx.portalTarget
|
|
116
|
+
]);
|
|
117
|
+
// Load global fonts and styles if this configuration instance is...
|
|
118
|
+
const shouldInitialize = useMemo(() =>
|
|
119
|
+
// the first configuration instance or...
|
|
120
|
+
!ctx.initialized ||
|
|
121
|
+
// is not within the same root node as the previous configuration instance.
|
|
122
|
+
!!(wrapperEl && wrapperEl.getRootNode() !== ctx.styleSheetTarget?.getRootNode()), [ctx.initialized, wrapperEl]);
|
|
97
123
|
// Check if this StyleSheetManager is mounted above this Configuration.
|
|
98
124
|
const stylesheetManagerMounted = useMemo(() => !!ctx.mountedStyleSheetManagers?.includes(StyleSheetManager), [ctx.mountedStyleSheetManagers]);
|
|
99
125
|
useEffect(() => {
|
|
@@ -103,37 +129,39 @@ const Configuration = ({ children, locale, direction, translations: customTransl
|
|
|
103
129
|
unmountConfig(sym);
|
|
104
130
|
};
|
|
105
131
|
}, [id]);
|
|
106
|
-
const wrappedChildren =
|
|
132
|
+
const wrappedChildren = shouldInitialize ? (_jsxs(_Fragment, { children: [!disableDefaultFontLoading &&
|
|
107
133
|
resolvedStyleSheetTarget &&
|
|
108
|
-
createPortal(_jsx("link", { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400..700;1,400..700&family=Inter:wght@400..700&display=swap', "data-cosmos-global-style": true }), resolvedStyleSheetTarget), _jsx(GlobalStyle, {}), children] }));
|
|
134
|
+
createPortal(_jsx("link", { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400..700;1,400..700&family=Inter:wght@400..700&display=swap', "data-cosmos-global-style": true }), resolvedStyleSheetTarget), _jsx(GlobalStyle, {}), children] })) : (_jsx(_Fragment, { children: children }));
|
|
109
135
|
const styledWrappedChildren = stylesheetManagerMounted ? (wrappedChildren) : (_jsx(StyleSheetManager, { disableVendorPrefixes: true, target:
|
|
110
136
|
// Target must be undefined in a JSDOM environment due to Styled Components server mode handling.
|
|
111
|
-
navigatorIsAvailable &&
|
|
137
|
+
navigatorIsAvailable &&
|
|
138
|
+
resolvedStyleSheetTarget?.isConnected &&
|
|
139
|
+
!navigator.userAgent.includes('jsdom')
|
|
112
140
|
? resolvedStyleSheetTarget
|
|
113
141
|
: undefined, children: wrappedChildren }));
|
|
114
|
-
return (
|
|
142
|
+
return (_jsxs("div", {
|
|
115
143
|
// Need to use inline styles because the StyleSheetManager is configured within this div.
|
|
116
|
-
style: { display: 'contents' }, ref: setWrapperEl, children: _jsx(context.Provider
|
|
117
|
-
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
118
|
-
, {
|
|
144
|
+
style: { display: 'contents' }, ref: setWrapperEl, children: [_jsx(context.Provider
|
|
119
145
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
146
|
+
, {
|
|
147
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
148
|
+
value: {
|
|
149
|
+
locale: locale ?? ctx.locale,
|
|
150
|
+
direction: direction ?? (locale !== undefined ? directionOfLocale(locale) : ctx.direction),
|
|
151
|
+
translations,
|
|
152
|
+
themeMachine,
|
|
153
|
+
styleSheetTarget: resolvedStyleSheetTarget,
|
|
154
|
+
portalTarget: resolvedPortalTarget,
|
|
155
|
+
loadedRef: ctx.loadedRef,
|
|
156
|
+
renderNativeControls: renderNativeControls ?? ctx.renderNativeControls,
|
|
157
|
+
testIds: testIds ?? ctx.testIds,
|
|
158
|
+
mountedStyleSheetManagers: stylesheetManagerMounted
|
|
159
|
+
? ctx.mountedStyleSheetManagers
|
|
160
|
+
: [...(ctx.mountedStyleSheetManagers ?? []), StyleSheetManager],
|
|
161
|
+
initialized: true
|
|
162
|
+
}, children: _jsxs(ThemeProvider, { theme: themeMachine.theme, children: [styleSheetURLs &&
|
|
163
|
+
resolvedStyleSheetTarget &&
|
|
164
|
+
createPortal(styleSheetURLs.map(url => (_jsx("link", { rel: 'stylesheet', href: url, "data-cosmos-global-style": true }, url))), resolvedStyleSheetTarget), styledWrappedChildren] }) }), _jsx("pega-connected-watcher", { ref: setConnectedWatcherEl })] }));
|
|
137
165
|
};
|
|
138
166
|
export default Configuration;
|
|
139
167
|
//# sourceMappingURL=Configuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../src/components/Configuration/Configuration.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGrE,OAAO,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,SAAS,IAAI,iBAAiB,EAC/B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,GAAG,MAAM,uBAAuB,CAAC;AACxC,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAyDhD,MAAM,aAAa,GAAG,oBA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AAG,CAAC,yBAAyB;oBAC/B,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,yBAAyB,IAAI,EAAE,CAAC,EAAE,iBAAiB,CAAC;gBACjE,WAAW,EAAE,IAAI;aAClB,YAED,MAAC,aAAa,IAAC,KAAK,EAAE,YAAY,CAAC,KAAK,aACrC,cAAc;wBACb,wBAAwB;wBACxB,YAAY,CACV,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CACxB,eAAM,GAAG,EAAC,YAAY,EAAC,IAAI,EAAE,GAAG,sCAAO,GAAG,CAA6B,CACxE,CAAC,EACF,wBAAwB,CACzB,EACF,qBAAqB,IACR,GACC,GACf,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { createContext, useContext, useMemo, useEffect } from 'react';\nimport type { FunctionComponent, ReactNode, Context, MutableRefObject } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ThemeProvider, StyleSheetManager } from 'styled-components';\nimport type { StyleSheetManagerProps } from 'styled-components';\n\nimport '../../init';\nimport { GlobalStyle } from '../../styles';\nimport { ThemeMachine, BaseThemeMachine } from '../../theme';\nimport type { ThemeMachineLike, DefaultSettableTheme, DefaultThemeDefinition } from '../../theme';\nimport {\n createTranslationPack,\n DefaultTranslation,\n direction as directionOfLocale\n} from '../../i18n';\nimport type { Translation, TranslationPack } from '../../i18n';\nimport { documentIsAvailable, navigatorIsAvailable, windowIsAvailable } from '../../utils';\nimport pkg from '../../../package.json';\nimport useElement from '../../hooks/useElement';\n\nexport interface ConfigurationProps {\n /** Any components or nodes that should be impacted by the settings applied by this Configuration component. */\n children: ReactNode;\n /** User locale as defined in [BCP-47](https://www.techonthenet.com/js/language_tags.php). */\n locale?: string;\n /** Override rendering direction of the document. Direction will be based on the locale if now provided. */\n direction?: 'ltr' | 'rtl';\n /** Object with (partial) translations. */\n translations?: Translation;\n /** Theme object used to override any or all Cosmos theme properties. */\n theme?: DefaultSettableTheme;\n /** Disables loading Open Sans or Inter from Google Fonts. Only takes effect on the root configuration. */\n disableDefaultFontLoading?: boolean;\n /** List of style sheets to inject in style sheet target. */\n styleSheets?: string[];\n /**\n * Target element for loading styles related to `styled-components`.\n * @deprecated\n */\n styleSheetTarget?: StyleSheetManagerProps['target'];\n /**\n * Target element for rendering a `ReactDOM` portal.\n * @deprecated\n */\n portalTarget?: Parameters<typeof createPortal>[1];\n /**\n * Use native HTML5 controls for inputs instead of rich ones.\n * @default false\n */\n renderNativeControls?: boolean;\n /** String to identify this configuration instance. */\n id?: string;\n /**\n * Enable/disable testId attribute rendering for all components.\n * @default true\n */\n testIds?: boolean;\n}\n\nexport interface ConfigurationContextValue {\n locale: string;\n direction: NonNullable<ConfigurationProps['direction']>;\n translations: TranslationPack;\n themeMachine: ThemeMachineLike<DefaultThemeDefinition>;\n styleSheetTarget: ConfigurationProps['styleSheetTarget'];\n portalTarget: ConfigurationProps['portalTarget'];\n loadedRef: MutableRefObject<boolean>;\n renderNativeControls: boolean;\n testIds: NonNullable<ConfigurationProps['testIds']>;\n /** @internal */\n mountedStyleSheetManagers?: (typeof StyleSheetManager)[];\n /** @internal */\n initialized: boolean;\n}\n\nconst defaultLocale = navigatorIsAvailable ? navigator.language : 'en';\n\nexport const ConfigurationContext = createContext<ConfigurationContextValue>({\n locale: defaultLocale,\n direction: directionOfLocale(defaultLocale),\n translations: DefaultTranslation,\n themeMachine: BaseThemeMachine,\n styleSheetTarget: documentIsAvailable ? document.head : undefined,\n portalTarget: documentIsAvailable ? document.body : undefined,\n loadedRef: { current: false },\n renderNativeControls: false,\n testIds: true,\n mountedStyleSheetManagers: [],\n initialized: false\n});\n\nconst legacyMetaKey = Symbol.for('@pega/cosmos-react-core.metadata');\n\ninterface LegacyCosmosInstace {\n version: string;\n}\n\ndeclare global {\n interface Window {\n [legacyMetaKey]?: {\n push: (instance: LegacyCosmosInstace) => void;\n };\n }\n}\n\nconst mountedConfigs = new Set<symbol>();\n\ninterface CosmosInstance extends LegacyCosmosInstace {\n mountedConfigs: string[];\n mountOrder: string[];\n mountCount: Record<string, number>;\n}\n\nconst instance: CosmosInstance = {\n version: pkg.version,\n mountedConfigs: [],\n mountOrder: [],\n mountCount: {}\n};\n\nconst mountConfig = (sym: symbol) => {\n mountedConfigs.add(sym);\n instance.mountedConfigs = [...mountedConfigs].map(i => i.description ?? 'Unknown');\n\n const description = sym.description ?? 'Unknown';\n\n instance.mountOrder.push(description);\n\n if (!(description in instance.mountCount)) {\n instance.mountCount[description] = 0;\n }\n instance.mountCount[description] += 1;\n};\n\nconst unmountConfig = (sym: symbol) => {\n mountedConfigs.delete(sym);\n instance.mountedConfigs = [...mountedConfigs].map(i => i.description ?? 'Unknown');\n};\n\ndeclare module '../../init' {\n export interface CosmosGlobals {\n instances?: (CosmosInstance | LegacyCosmosInstace)[];\n configurationContext?: Context<ConfigurationContextValue>;\n }\n}\n\nif (windowIsAvailable) {\n if (!window.cosmos.instances) {\n window.cosmos.instances = [];\n }\n\n window.cosmos.instances.push(instance);\n\n if (Array.isArray(window[legacyMetaKey])) {\n window.cosmos.instances.push(...window[legacyMetaKey]);\n delete window[legacyMetaKey];\n }\n\n if (!window[legacyMetaKey]) {\n window[legacyMetaKey] = {\n push: inst => {\n window.cosmos.instances?.push(inst);\n }\n };\n }\n}\n\nconst Configuration: FunctionComponent<ConfigurationProps> = ({\n children,\n locale,\n direction,\n translations: customTranslations,\n theme,\n disableDefaultFontLoading,\n styleSheets: styleSheetURLs,\n styleSheetTarget,\n portalTarget,\n renderNativeControls,\n testIds,\n id\n}: ConfigurationProps) => {\n const context = windowIsAvailable\n ? window.cosmos.configurationContext ?? ConfigurationContext\n : ConfigurationContext;\n const ctx = useContext(context);\n const themeMachine = theme\n ? new ThemeMachine<DefaultThemeDefinition>({ theme, parent: ctx.themeMachine })\n : ctx.themeMachine;\n const translations = useMemo(\n () => createTranslationPack({ ...ctx.translations, ...customTranslations }),\n [ctx.translations, customTranslations]\n );\n\n const [wrapperEl, setWrapperEl] = useElement<HTMLDivElement>();\n\n // Determine valid style sheet and portal target with ShadowDOM handling.\n const [resolvedStyleSheetTarget, resolvedPortalTarget] = useMemo(() => {\n // When rendering on the server, or before the wrapper is in the DOM, just bail.\n if (!documentIsAvailable || !wrapperEl) return [undefined, undefined];\n\n const rootNode = wrapperEl.getRootNode();\n\n // When within the ShadowDOM, the default target is the ShadowRoot, otherwise default to head/body element.\n const defaultStyleSheetTarget = rootNode instanceof ShadowRoot ? rootNode : document.head;\n const defaultPortalTarget = rootNode instanceof ShadowRoot ? rootNode : document.body;\n\n // Currently passed prop or previous context value\n const requestedStyleSheetTarget = styleSheetTarget ?? ctx.styleSheetTarget;\n const requestedPortalTarget = portalTarget ?? ctx.portalTarget;\n\n // If the \"requested\" target is within the root node, it is valid, so use that, otherwise fallback to the default.\n return [\n rootNode.contains(requestedStyleSheetTarget ?? null)\n ? requestedStyleSheetTarget\n : defaultStyleSheetTarget,\n rootNode.contains(requestedPortalTarget ?? null) ? requestedPortalTarget : defaultPortalTarget\n ];\n }, [wrapperEl, styleSheetTarget, portalTarget, ctx.styleSheetTarget, ctx.portalTarget]);\n\n // Reload global fonts and styles if this configuration instance is not within the same root node as the previous configuration instance.\n const reinitialize = useMemo(\n () => !!(wrapperEl && wrapperEl.getRootNode() !== ctx.styleSheetTarget?.getRootNode()),\n [wrapperEl]\n );\n\n // Check if this StyleSheetManager is mounted above this Configuration.\n const stylesheetManagerMounted = useMemo(\n () => !!ctx.mountedStyleSheetManagers?.includes(StyleSheetManager),\n [ctx.mountedStyleSheetManagers]\n );\n\n useEffect(() => {\n const sym = Symbol(id);\n mountConfig(sym);\n\n return () => {\n unmountConfig(sym);\n };\n }, [id]);\n\n const wrappedChildren =\n ctx.initialized && !reinitialize ? (\n <>{children}</>\n ) : (\n <>\n {!disableDefaultFontLoading &&\n resolvedStyleSheetTarget &&\n createPortal(\n <link\n rel='stylesheet'\n href='https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400..700;1,400..700&family=Inter:wght@400..700&display=swap'\n data-cosmos-global-style\n />,\n resolvedStyleSheetTarget\n )}\n <GlobalStyle />\n {children}\n </>\n );\n\n const styledWrappedChildren = stylesheetManagerMounted ? (\n wrappedChildren\n ) : (\n <StyleSheetManager\n disableVendorPrefixes\n target={\n // Target must be undefined in a JSDOM environment due to Styled Components server mode handling.\n navigatorIsAvailable && !navigator.userAgent.includes('jsdom')\n ? resolvedStyleSheetTarget\n : undefined\n }\n >\n {wrappedChildren}\n </StyleSheetManager>\n );\n\n return (\n <div\n // Need to use inline styles because the StyleSheetManager is configured within this div.\n style={{ display: 'contents' }}\n ref={setWrapperEl}\n >\n <context.Provider\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n value={{\n locale: locale ?? ctx.locale,\n direction:\n direction ?? (locale !== undefined ? directionOfLocale(locale) : ctx.direction),\n translations,\n themeMachine,\n styleSheetTarget: resolvedStyleSheetTarget,\n portalTarget: resolvedPortalTarget,\n loadedRef: ctx.loadedRef,\n renderNativeControls: renderNativeControls ?? ctx.renderNativeControls,\n testIds: testIds ?? ctx.testIds,\n mountedStyleSheetManagers: stylesheetManagerMounted\n ? ctx.mountedStyleSheetManagers\n : [...(ctx.mountedStyleSheetManagers ?? []), StyleSheetManager],\n initialized: true\n }}\n >\n <ThemeProvider theme={themeMachine.theme}>\n {styleSheetURLs &&\n resolvedStyleSheetTarget &&\n createPortal(\n styleSheetURLs.map(url => (\n <link rel='stylesheet' href={url} key={url} data-cosmos-global-style />\n )),\n resolvedStyleSheetTarget\n )}\n {styledWrappedChildren}\n </ThemeProvider>\n </context.Provider>\n </div>\n );\n};\n\nexport default Configuration;\n"]}
|
|
1
|
+
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../src/components/Configuration/Configuration.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhF,OAAO,EAAE,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GAAG,CAAC,yBAAyB;wBAC/B,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,yBAAyB,IAAI,EAAE,CAAC,EAAE,iBAAiB,CAAC;oBACjE,WAAW,EAAE,IAAI;iBAClB,YAED,MAAC,aAAa,IAAC,KAAK,EAAE,YAAY,CAAC,KAAK,aACrC,cAAc;4BACb,wBAAwB;4BACxB,YAAY,CACV,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CACxB,eAAM,GAAG,EAAC,YAAY,EAAC,IAAI,EAAE,GAAG,sCAAO,GAAG,CAA6B,CACxE,CAAC,EACF,wBAAwB,CACzB,EACF,qBAAqB,IACR,GACC,EACnB,iCAAwB,GAAG,EAAE,qBAAqB,GAAI,IAClD,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { createContext, useContext, useMemo, useEffect, useState } from 'react';\nimport type { FunctionComponent, ReactNode, Context, MutableRefObject } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ThemeProvider, StyleSheetManager } from 'styled-components';\nimport type { StyleSheetManagerProps } from 'styled-components';\n\nimport '../../init';\nimport { GlobalStyle } from '../../styles';\nimport { ThemeMachine, BaseThemeMachine } from '../../theme';\nimport type { ThemeMachineLike, DefaultSettableTheme, DefaultThemeDefinition } from '../../theme';\nimport {\n createTranslationPack,\n DefaultTranslation,\n direction as directionOfLocale\n} from '../../i18n';\nimport type { Translation, TranslationPack } from '../../i18n';\nimport { documentIsAvailable, navigatorIsAvailable, windowIsAvailable } from '../../utils';\nimport pkg from '../../../package.json';\nimport useElement from '../../hooks/useElement';\n\nimport type PegaConnectedWatcher from './connected-watcher';\nimport './connected-watcher';\n\nexport interface ConfigurationProps {\n /** Any components or nodes that should be impacted by the settings applied by this Configuration component. */\n children: ReactNode;\n /** User locale as defined in [BCP-47](https://www.techonthenet.com/js/language_tags.php). */\n locale?: string;\n /** Override rendering direction of the document. Direction will be based on the locale if now provided. */\n direction?: 'ltr' | 'rtl';\n /** Object with (partial) translations. */\n translations?: Translation;\n /** Theme object used to override any or all Cosmos theme properties. */\n theme?: DefaultSettableTheme;\n /** Disables loading Open Sans or Inter from Google Fonts. Only takes effect on the root configuration. */\n disableDefaultFontLoading?: boolean;\n /** List of style sheets to inject in style sheet target. */\n styleSheets?: string[];\n /**\n * Target element for loading styles related to `styled-components`.\n * @deprecated\n */\n styleSheetTarget?: StyleSheetManagerProps['target'];\n /**\n * Target element for rendering a `ReactDOM` portal.\n * @deprecated\n */\n portalTarget?: Parameters<typeof createPortal>[1];\n /**\n * Use native HTML5 controls for inputs instead of rich ones.\n * @default false\n */\n renderNativeControls?: boolean;\n /** String to identify this configuration instance. */\n id?: string;\n /**\n * Enable/disable testId attribute rendering for all components.\n * @default true\n */\n testIds?: boolean;\n}\n\nexport interface ConfigurationContextValue {\n locale: string;\n direction: NonNullable<ConfigurationProps['direction']>;\n translations: TranslationPack;\n themeMachine: ThemeMachineLike<DefaultThemeDefinition>;\n styleSheetTarget: ConfigurationProps['styleSheetTarget'];\n portalTarget: ConfigurationProps['portalTarget'];\n loadedRef: MutableRefObject<boolean>;\n renderNativeControls: boolean;\n testIds: NonNullable<ConfigurationProps['testIds']>;\n /** @internal */\n mountedStyleSheetManagers?: (typeof StyleSheetManager)[];\n /** @internal */\n initialized: boolean;\n}\n\nconst defaultLocale = navigatorIsAvailable ? navigator.language : 'en';\n\nexport const ConfigurationContext = createContext<ConfigurationContextValue>({\n locale: defaultLocale,\n direction: directionOfLocale(defaultLocale),\n translations: DefaultTranslation,\n themeMachine: BaseThemeMachine,\n styleSheetTarget: documentIsAvailable ? document.head : undefined,\n portalTarget: documentIsAvailable ? document.body : undefined,\n loadedRef: { current: false },\n renderNativeControls: false,\n testIds: true,\n mountedStyleSheetManagers: [],\n initialized: false\n});\n\nconst legacyMetaKey = Symbol.for('@pega/cosmos-react-core.metadata');\n\ninterface LegacyCosmosInstace {\n version: string;\n}\n\ndeclare global {\n interface Window {\n [legacyMetaKey]?: {\n push: (instance: LegacyCosmosInstace) => void;\n };\n }\n}\n\nconst mountedConfigs = new Set<symbol>();\n\ninterface CosmosInstance extends LegacyCosmosInstace {\n mountedConfigs: string[];\n mountOrder: string[];\n mountCount: Record<string, number>;\n}\n\nconst instance: CosmosInstance = {\n version: pkg.version,\n mountedConfigs: [],\n mountOrder: [],\n mountCount: {}\n};\n\nconst mountConfig = (sym: symbol) => {\n mountedConfigs.add(sym);\n instance.mountedConfigs = [...mountedConfigs].map(i => i.description ?? 'Unknown');\n\n const description = sym.description ?? 'Unknown';\n\n instance.mountOrder.push(description);\n\n if (!(description in instance.mountCount)) {\n instance.mountCount[description] = 0;\n }\n instance.mountCount[description] += 1;\n};\n\nconst unmountConfig = (sym: symbol) => {\n mountedConfigs.delete(sym);\n instance.mountedConfigs = [...mountedConfigs].map(i => i.description ?? 'Unknown');\n};\n\ndeclare module '../../init' {\n export interface CosmosGlobals {\n instances?: (CosmosInstance | LegacyCosmosInstace)[];\n configurationContext?: Context<ConfigurationContextValue>;\n }\n}\n\nif (windowIsAvailable) {\n if (!window.cosmos.instances) {\n window.cosmos.instances = [];\n }\n\n window.cosmos.instances.push(instance);\n\n if (Array.isArray(window[legacyMetaKey])) {\n window.cosmos.instances.push(...window[legacyMetaKey]);\n delete window[legacyMetaKey];\n }\n\n if (!window[legacyMetaKey]) {\n window[legacyMetaKey] = {\n push: inst => {\n window.cosmos.instances?.push(inst);\n }\n };\n }\n}\n\nconst Configuration: FunctionComponent<ConfigurationProps> = ({\n children,\n locale,\n direction,\n translations: customTranslations,\n theme,\n disableDefaultFontLoading,\n styleSheets: styleSheetURLs,\n styleSheetTarget,\n portalTarget,\n renderNativeControls,\n testIds,\n id\n}: ConfigurationProps) => {\n const context = windowIsAvailable\n ? window.cosmos.configurationContext ?? ConfigurationContext\n : ConfigurationContext;\n const ctx = useContext(context);\n const themeMachine = theme\n ? new ThemeMachine<DefaultThemeDefinition>({ theme, parent: ctx.themeMachine })\n : ctx.themeMachine;\n const translations = useMemo(\n () => createTranslationPack({ ...ctx.translations, ...customTranslations }),\n [ctx.translations, customTranslations]\n );\n\n const [wrapperEl, setWrapperEl] = useElement<HTMLDivElement>();\n const [connectedWatcherEl, setConnectedWatcherEl] = useElement<PegaConnectedWatcher>();\n // State tracking if the DOM nodes are connected. Only used to trigger rerenders when connected state changes.\n const [, setConnected] = useState<boolean | null>(null);\n\n useEffect(() => {\n if (!connectedWatcherEl) return;\n\n const connectDisconnectListener = () => {\n setConnected(connectedWatcherEl.isConnected);\n };\n\n connectedWatcherEl.addEventListener('connect-disconnect', connectDisconnectListener);\n\n return () => {\n connectedWatcherEl.removeEventListener('connect-disconnect', connectDisconnectListener);\n };\n }, [connectedWatcherEl]);\n\n // Determine valid style sheet and portal target with ShadowDOM handling.\n const [resolvedStyleSheetTarget, resolvedPortalTarget] = useMemo(() => {\n // When rendering on the server, or before the wrapper is in the DOM, just bail.\n if (!documentIsAvailable || !wrapperEl?.isConnected) return [undefined, undefined];\n\n const rootNode = wrapperEl.getRootNode();\n\n // When within the ShadowDOM, the default target is the ShadowRoot, otherwise default to head/body element.\n const defaultStyleSheetTarget = rootNode instanceof ShadowRoot ? rootNode : document.head;\n const defaultPortalTarget = rootNode instanceof ShadowRoot ? rootNode : document.body;\n\n // Currently passed prop or previous context value\n const requestedStyleSheetTarget = styleSheetTarget ?? ctx.styleSheetTarget;\n const requestedPortalTarget = portalTarget ?? ctx.portalTarget;\n\n // If the \"requested\" target is within the root node, it is valid, so use that, otherwise fallback to the default.\n return [\n rootNode.contains(requestedStyleSheetTarget ?? null)\n ? requestedStyleSheetTarget\n : defaultStyleSheetTarget,\n rootNode.contains(requestedPortalTarget ?? null) ? requestedPortalTarget : defaultPortalTarget\n ];\n }, [\n wrapperEl,\n wrapperEl?.isConnected,\n styleSheetTarget,\n portalTarget,\n ctx.styleSheetTarget,\n ctx.portalTarget\n ]);\n\n // Load global fonts and styles if this configuration instance is...\n const shouldInitialize = useMemo(\n () =>\n // the first configuration instance or...\n !ctx.initialized ||\n // is not within the same root node as the previous configuration instance.\n !!(wrapperEl && wrapperEl.getRootNode() !== ctx.styleSheetTarget?.getRootNode()),\n [ctx.initialized, wrapperEl]\n );\n\n // Check if this StyleSheetManager is mounted above this Configuration.\n const stylesheetManagerMounted = useMemo(\n () => !!ctx.mountedStyleSheetManagers?.includes(StyleSheetManager),\n [ctx.mountedStyleSheetManagers]\n );\n\n useEffect(() => {\n const sym = Symbol(id);\n mountConfig(sym);\n\n return () => {\n unmountConfig(sym);\n };\n }, [id]);\n\n const wrappedChildren = shouldInitialize ? (\n <>\n {!disableDefaultFontLoading &&\n resolvedStyleSheetTarget &&\n createPortal(\n <link\n rel='stylesheet'\n href='https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400..700;1,400..700&family=Inter:wght@400..700&display=swap'\n data-cosmos-global-style\n />,\n resolvedStyleSheetTarget\n )}\n <GlobalStyle />\n {children}\n </>\n ) : (\n <>{children}</>\n );\n\n const styledWrappedChildren = stylesheetManagerMounted ? (\n wrappedChildren\n ) : (\n <StyleSheetManager\n disableVendorPrefixes\n target={\n // Target must be undefined in a JSDOM environment due to Styled Components server mode handling.\n navigatorIsAvailable &&\n resolvedStyleSheetTarget?.isConnected &&\n !navigator.userAgent.includes('jsdom')\n ? resolvedStyleSheetTarget\n : undefined\n }\n >\n {wrappedChildren}\n </StyleSheetManager>\n );\n\n return (\n <div\n // Need to use inline styles because the StyleSheetManager is configured within this div.\n style={{ display: 'contents' }}\n ref={setWrapperEl}\n >\n <context.Provider\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n value={{\n locale: locale ?? ctx.locale,\n direction:\n direction ?? (locale !== undefined ? directionOfLocale(locale) : ctx.direction),\n translations,\n themeMachine,\n styleSheetTarget: resolvedStyleSheetTarget,\n portalTarget: resolvedPortalTarget,\n loadedRef: ctx.loadedRef,\n renderNativeControls: renderNativeControls ?? ctx.renderNativeControls,\n testIds: testIds ?? ctx.testIds,\n mountedStyleSheetManagers: stylesheetManagerMounted\n ? ctx.mountedStyleSheetManagers\n : [...(ctx.mountedStyleSheetManagers ?? []), StyleSheetManager],\n initialized: true\n }}\n >\n <ThemeProvider theme={themeMachine.theme}>\n {styleSheetURLs &&\n resolvedStyleSheetTarget &&\n createPortal(\n styleSheetURLs.map(url => (\n <link rel='stylesheet' href={url} key={url} data-cosmos-global-style />\n )),\n resolvedStyleSheetTarget\n )}\n {styledWrappedChildren}\n </ThemeProvider>\n </context.Provider>\n <pega-connected-watcher ref={setConnectedWatcherEl} />\n </div>\n );\n};\n\nexport default Configuration;\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLElementTagNameMap {
|
|
4
|
+
'pega-connected-watcher': PegaConnectedWatcher;
|
|
5
|
+
}
|
|
6
|
+
namespace JSX {
|
|
7
|
+
interface IntrinsicElements {
|
|
8
|
+
'pega-connected-watcher': DetailedHTMLProps<HTMLAttributes<PegaConnectedWatcher>, PegaConnectedWatcher>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
declare class PegaConnectedWatcher extends HTMLElement {
|
|
13
|
+
connectedCallback(): void;
|
|
14
|
+
disconnectedCallback(): void;
|
|
15
|
+
}
|
|
16
|
+
export default PegaConnectedWatcher;
|
|
17
|
+
//# sourceMappingURL=connected-watcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connected-watcher.d.ts","sourceRoot":"","sources":["../../../src/components/Configuration/connected-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,wBAAwB,EAAE,oBAAoB,CAAC;KAChD;IAED,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,wBAAwB,EAAE,iBAAiB,CACzC,cAAc,CAAC,oBAAoB,CAAC,EACpC,oBAAoB,CACrB,CAAC;SACH;KACF;CACF;AAED,cAAM,oBAAqB,SAAQ,WAAW;IAC5C,iBAAiB;IAIjB,oBAAoB;CAGrB;AAMD,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class PegaConnectedWatcher extends HTMLElement {
|
|
2
|
+
connectedCallback() {
|
|
3
|
+
this.dispatchEvent(new Event('connect-disconnect', { bubbles: false }));
|
|
4
|
+
}
|
|
5
|
+
disconnectedCallback() {
|
|
6
|
+
this.dispatchEvent(new Event('connect-disconnect', { bubbles: false }));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
if (!customElements.get('pega-connected-watcher')) {
|
|
10
|
+
customElements.define('pega-connected-watcher', PegaConnectedWatcher);
|
|
11
|
+
}
|
|
12
|
+
export default PegaConnectedWatcher;
|
|
13
|
+
//# sourceMappingURL=connected-watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connected-watcher.js","sourceRoot":"","sources":["../../../src/components/Configuration/connected-watcher.ts"],"names":[],"mappings":"AAiBA,MAAM,oBAAqB,SAAQ,WAAW;IAC5C,iBAAiB;QACf,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,oBAAoB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,oBAAoB;QAClB,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,oBAAoB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;CACF;AAED,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,wBAAwB,CAAC,EAAE;IACjD,cAAc,CAAC,MAAM,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,CAAC;CACvE;AAED,eAAe,oBAAoB,CAAC","sourcesContent":["import type { DetailedHTMLProps, HTMLAttributes } from 'react';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pega-connected-watcher': PegaConnectedWatcher;\n }\n\n namespace JSX {\n interface IntrinsicElements {\n 'pega-connected-watcher': DetailedHTMLProps<\n HTMLAttributes<PegaConnectedWatcher>,\n PegaConnectedWatcher\n >;\n }\n }\n}\n\nclass PegaConnectedWatcher extends HTMLElement {\n connectedCallback() {\n this.dispatchEvent(new Event('connect-disconnect', { bubbles: false }));\n }\n\n disconnectedCallback() {\n this.dispatchEvent(new Event('connect-disconnect', { bubbles: false }));\n }\n}\n\nif (!customElements.get('pega-connected-watcher')) {\n customElements.define('pega-connected-watcher', PegaConnectedWatcher);\n}\n\nexport default PegaConnectedWatcher;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonthInput.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime/Input/MonthInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAwB,MAAM,OAAO,CAAC;AAIrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AASnD,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,8EAA8E;IAC9E,cAAc,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CACrD;AAED,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"MonthInput.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime/Input/MonthInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAwB,MAAM,OAAO,CAAC;AAIrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AASnD,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,8EAA8E;IAC9E,cAAc,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CACrD;AAED,eAAO,MAAM,gBAAgB,sHAkC5B,CAAC;;;;AAgOF,wBAA6D"}
|
|
@@ -10,35 +10,42 @@ import { StyledSelect } from '../../Select/Select';
|
|
|
10
10
|
import Flex from '../../Flex';
|
|
11
11
|
import { StyledFormControl } from '../../FormControl';
|
|
12
12
|
import { getMonthInputTestIds } from '../DateTime.test-ids';
|
|
13
|
-
import { StyledFormField } from '../../FormField/FormField';
|
|
13
|
+
import { StyledFormField, StyledFormFieldInfo } from '../../FormField/FormField';
|
|
14
14
|
import { parseToDate, getLocalizedMonths, getLocalizedYear } from './utils';
|
|
15
15
|
import StyledDateTime from './DateTime.styles';
|
|
16
16
|
export const StyledMonthInput = styled(StyledDateTime) `
|
|
17
17
|
padding: 0;
|
|
18
18
|
border: 0;
|
|
19
|
+
background-color: transparent;
|
|
19
20
|
|
|
20
21
|
${StyledFormField}:enabled > &:focus-within {
|
|
21
22
|
box-shadow: none;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
${
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
&:focus {
|
|
25
|
+
${StyledFormField} {
|
|
26
|
+
> ${StyledSelect}:focus {
|
|
28
27
|
z-index: 1;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
:first-child {
|
|
31
|
+
flex-grow: 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:first-child > ${StyledSelect} {
|
|
32
35
|
border-start-end-radius: 0;
|
|
33
36
|
border-end-end-radius: 0;
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
:last-child > ${StyledSelect} {
|
|
40
|
+
width: max-content;
|
|
38
41
|
margin-inline-start: -0.0625rem;
|
|
39
42
|
border-start-start-radius: 0;
|
|
40
43
|
border-end-start-radius: 0;
|
|
41
44
|
}
|
|
45
|
+
|
|
46
|
+
:first-child > ${StyledFormFieldInfo}, :last-child > ${StyledFormFieldInfo} {
|
|
47
|
+
display: none;
|
|
48
|
+
}
|
|
42
49
|
}
|
|
43
50
|
`;
|
|
44
51
|
StyledMonthInput.defaultProps = defaultThemeProp;
|
|
@@ -46,6 +53,10 @@ const convertToCallbackParameter = (date, { month, year }) => {
|
|
|
46
53
|
if ([month, year].every(Boolean)) {
|
|
47
54
|
const resultDate = new Date(date);
|
|
48
55
|
resultDate.setUTCFullYear(Number(year), Number(month));
|
|
56
|
+
// handle month overflowing
|
|
57
|
+
if (resultDate.getUTCMonth() !== Number(month)) {
|
|
58
|
+
resultDate.setUTCDate(0);
|
|
59
|
+
}
|
|
49
60
|
return {
|
|
50
61
|
valueAsISOString: resultDate.toISOString(),
|
|
51
62
|
valueAsTimestamp: resultDate.getTime()
|
|
@@ -118,8 +129,8 @@ const MonthInput = forwardRef(function MonthInput(props, ref) {
|
|
|
118
129
|
style: 'long',
|
|
119
130
|
type: 'dateTimeField'
|
|
120
131
|
}), [locale]);
|
|
121
|
-
const Month = (_jsxs(Select, { "data-testid": testIds.controlMonth, label:
|
|
122
|
-
const Year = (_jsxs(Select, { "data-testid": testIds.controlYear, label:
|
|
132
|
+
const Month = (_jsxs(Select, { "data-testid": testIds.controlMonth, label: cap(displayNames.of('month')), labelHidden: innerLabelsHidden, ref: monthSelectRef, "aria-label": displayNames.of('month'), readOnly: readOnly, required: required, onChange: onSelectChange, status: status, disabled: disabled, autoFocus: autoFocus, children: [!required && _jsx(Option, { children: " " }, 'null'), monthOptions] }, 'month'));
|
|
133
|
+
const Year = (_jsxs(Select, { "data-testid": testIds.controlYear, label: cap(displayNames.of('year')), labelHidden: innerLabelsHidden, ref: yearSelectRef, "aria-label": displayNames.of('year'), readOnly: readOnly, required: required, onChange: onSelectChange, status: status, disabled: disabled, children: [!required && _jsx(Option, { children: " " }, 'null'), yearOptions] }, 'year'));
|
|
123
134
|
const Comp = (_jsxs(Flex, { as: StyledMonthInput, forwardedAs: StyledFormControl, container: { alignItems: 'center', wrap: 'nowrap' }, ref: containerRef, status: status, disabled: disabled, readOnly: readOnly, ...restProps, children: [Month, Year] }));
|
|
124
135
|
return label ? (_jsx(FormField, { testId: testIds, as: 'fieldset', labelAs: 'legend', label: label, labelHidden: labelHidden, id: id, info: info, status: status, required: required, disabled: disabled, additionalInfo: additionalInfo, children: Comp })) : (Comp);
|
|
125
136
|
});
|