@cloudscape-design/components-themeable 3.0.817 → 3.0.819

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 (79) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/app-layout/test-classes/styles.scss +23 -67
  3. package/lib/internal/scss/app-layout/visual-refresh-toolbar/toolbar/styles.scss +5 -0
  4. package/lib/internal/scss/{file-upload/dropzone → internal/components/file-dropzone}/styles.scss +9 -4
  5. package/lib/internal/template/app-layout/drawer/index.d.ts.map +1 -1
  6. package/lib/internal/template/app-layout/drawer/index.js +3 -2
  7. package/lib/internal/template/app-layout/drawer/index.js.map +1 -1
  8. package/lib/internal/template/app-layout/test-classes/styles.css.js +23 -22
  9. package/lib/internal/template/app-layout/test-classes/styles.scoped.css +23 -85
  10. package/lib/internal/template/app-layout/test-classes/styles.selectors.js +23 -22
  11. package/lib/internal/template/app-layout/toggles/index.d.ts.map +1 -1
  12. package/lib/internal/template/app-layout/toggles/index.js +4 -1
  13. package/lib/internal/template/app-layout/toggles/index.js.map +1 -1
  14. package/lib/internal/template/app-layout/visual-refresh/drawers.d.ts.map +1 -1
  15. package/lib/internal/template/app-layout/visual-refresh/drawers.js +8 -2
  16. package/lib/internal/template/app-layout/visual-refresh/drawers.js.map +1 -1
  17. package/lib/internal/template/app-layout/visual-refresh/navigation.d.ts.map +1 -1
  18. package/lib/internal/template/app-layout/visual-refresh/navigation.js +3 -3
  19. package/lib/internal/template/app-layout/visual-refresh/navigation.js.map +1 -1
  20. package/lib/internal/template/app-layout/visual-refresh/tools.js +1 -1
  21. package/lib/internal/template/app-layout/visual-refresh/tools.js.map +1 -1
  22. package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/index.d.ts.map +1 -1
  23. package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/index.js +4 -2
  24. package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/index.js.map +1 -1
  25. package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/styles.css.js +15 -13
  26. package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/styles.scoped.css +19 -15
  27. package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/styles.selectors.js +15 -13
  28. package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.d.ts.map +1 -1
  29. package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.js +1 -0
  30. package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.js.map +1 -1
  31. package/lib/internal/template/file-upload/internal.d.ts.map +1 -1
  32. package/lib/internal/template/file-upload/internal.js +3 -3
  33. package/lib/internal/template/file-upload/internal.js.map +1 -1
  34. package/lib/internal/template/internal/base-component/styles.scoped.css +47 -32
  35. package/lib/internal/template/internal/components/file-dropzone/index.d.ts +6 -0
  36. package/lib/internal/template/internal/components/file-dropzone/index.d.ts.map +1 -0
  37. package/lib/internal/template/internal/components/file-dropzone/index.js +33 -0
  38. package/lib/internal/template/internal/components/file-dropzone/index.js.map +1 -0
  39. package/lib/internal/template/internal/components/file-dropzone/interfaces.d.ts +20 -0
  40. package/lib/internal/template/internal/components/file-dropzone/interfaces.d.ts.map +1 -0
  41. package/lib/internal/template/internal/components/file-dropzone/interfaces.js +2 -0
  42. package/lib/internal/template/internal/components/file-dropzone/interfaces.js.map +1 -0
  43. package/lib/internal/template/internal/components/file-dropzone/styles.css.js +8 -0
  44. package/lib/internal/template/{file-upload/dropzone → internal/components/file-dropzone}/styles.scoped.css +6 -2
  45. package/lib/internal/template/{file-upload/dropzone → internal/components/file-dropzone}/styles.selectors.js +3 -2
  46. package/lib/internal/template/internal/components/file-dropzone/use-files-dragging.d.ts +10 -0
  47. package/lib/internal/template/internal/components/file-dropzone/use-files-dragging.d.ts.map +1 -0
  48. package/lib/internal/template/{file-upload/dropzone/index.js → internal/components/file-dropzone/use-files-dragging.js} +16 -38
  49. package/lib/internal/template/internal/components/file-dropzone/use-files-dragging.js.map +1 -0
  50. package/lib/internal/template/internal/environment.js +1 -1
  51. package/lib/internal/template/internal/environment.json +1 -1
  52. package/lib/internal/template/internal/generated/styles/tokens.js +3 -3
  53. package/lib/internal/template/internal/generated/theming/index.cjs +41 -41
  54. package/lib/internal/template/internal/generated/theming/index.js +41 -41
  55. package/lib/internal/template/internal/plugins/controllers/breadcrumbs.d.ts +5 -4
  56. package/lib/internal/template/internal/plugins/controllers/breadcrumbs.d.ts.map +1 -1
  57. package/lib/internal/template/internal/plugins/controllers/breadcrumbs.js +2 -4
  58. package/lib/internal/template/internal/plugins/controllers/breadcrumbs.js.map +1 -1
  59. package/lib/internal/template/internal/plugins/helpers/use-global-breadcrumbs.d.ts.map +1 -1
  60. package/lib/internal/template/internal/plugins/helpers/use-global-breadcrumbs.js +1 -1
  61. package/lib/internal/template/internal/plugins/helpers/use-global-breadcrumbs.js.map +1 -1
  62. package/lib/internal/template/test-utils/dom/app-layout/index.d.ts +12 -1
  63. package/lib/internal/template/test-utils/dom/app-layout/index.js +28 -2
  64. package/lib/internal/template/test-utils/dom/app-layout/index.js.map +1 -1
  65. package/lib/internal/template/test-utils/dom/internal/file-dropzone.d.ts +5 -0
  66. package/lib/internal/template/test-utils/dom/internal/file-dropzone.js +14 -0
  67. package/lib/internal/template/test-utils/dom/internal/file-dropzone.js.map +1 -0
  68. package/lib/internal/template/test-utils/selectors/app-layout/index.d.ts +12 -1
  69. package/lib/internal/template/test-utils/selectors/app-layout/index.js +28 -2
  70. package/lib/internal/template/test-utils/selectors/app-layout/index.js.map +1 -1
  71. package/lib/internal/template/test-utils/selectors/internal/file-dropzone.d.ts +5 -0
  72. package/lib/internal/template/test-utils/selectors/internal/file-dropzone.js +14 -0
  73. package/lib/internal/template/test-utils/selectors/internal/file-dropzone.js.map +1 -0
  74. package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
  75. package/package.json +1 -1
  76. package/lib/internal/template/file-upload/dropzone/index.d.ts +0 -9
  77. package/lib/internal/template/file-upload/dropzone/index.d.ts.map +0 -1
  78. package/lib/internal/template/file-upload/dropzone/index.js.map +0 -1
  79. package/lib/internal/template/file-upload/dropzone/styles.css.js +0 -7
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtF,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,IAAI,MAAM,2BAA2B,CAAC;AAC7C,OAAO,OAAO,MAAM,yCAAyC,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AAEnF,OAAO,cAAc,MAAM,qCAAqC,CAAC;AACjE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAoDrC,SAAS,aAAa,CACpB,EACE,SAAS,EACT,SAAS,EACT,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,QAAQ,GAAG,KAAK,EAChB,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,UAAU,GAAG,KAAK,EAClB,WAAW,EACX,aAAa,GAAG,KAAK,EACrB,QAAQ,GAAG,KAAK,EAChB,yBAAyB,GAAG,KAAK,EACjC,eAAe,GAAG,KAAK,GACJ,EACrB,GAA+B;IAE/B,MAAM,YAAY,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAC/D,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/B;gBACE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ;gBAC3B,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK;aACtB,EACD,SAAS,CACV,EACD,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,GAA6B,EAClC,IAAI,EAAC,QAAQ,iBACA,MAAM,sBACF,6BAA6B;YAE9C,8BAAM,SAAS,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC,IACnG,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,oBAAC,IAAI,IAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,GAAI,CAC3D,CACA;QACR,KAAK,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,GAAG,GAAI;QACvC,cAAc,IAAI,CACjB,oBAAC,OAAO,IAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,CAAC,iBAAiB,CAAC,GAAI,CACvG,CACG,CACP,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { ButtonProps } from '../../../../button/interfaces';\nimport { IconProps } from '../../../../icon/interfaces';\nimport Icon from '../../../../icon/internal';\nimport Tooltip from '../../../../internal/components/tooltip';\nimport { registerTooltip } from '../../../../internal/components/tooltip/registry';\n\nimport testutilStyles from '../../../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\nexport interface TriggerButtonProps {\n ariaLabel?: string;\n className?: string;\n iconName?: IconProps.Name;\n iconSvg?: React.ReactNode;\n ariaExpanded: boolean | undefined;\n ariaControls?: string;\n disabled?: boolean;\n /**\n * Ovewrwrites any internal testIds when provided\n */\n testId?: string;\n /**\n * If button is selected. Used only for desktop and applies a selected class\n */\n selected?: boolean;\n onClick: React.MouseEventHandler<HTMLButtonElement>;\n\n badge?: boolean;\n /**\n * If the button is expected to have a tooltip. When false it will not set the event listeners\n *\n * defaults to false\n */\n hasTooltip?: boolean;\n /**\n * This text allows for a customized tooltip.\n *\n * When falsy, the tooltip will parse the tooltip form the aria-lable\n */\n tooltipText?: string;\n hasOpenDrawer?: boolean;\n /**\n * If the AppLayout is in mobile mode\n * Used to determine if and where to render tooltips\n */\n isMobile?: boolean;\n /**\n * set to true if the trigger button was used to open the last active drawer\n * this is also used to hide the tooltip should the focus be set programmatically\n * on focus from a drawer close using this\n */\n isForPreviousActiveDrawer?: boolean;\n /**\n * if the trigger button is for the split panel\n */\n isForSplitPanel?: boolean;\n tabIndex?: number | undefined;\n}\n\nfunction TriggerButton(\n {\n ariaLabel,\n className,\n iconName,\n iconSvg,\n ariaExpanded,\n ariaControls,\n onClick,\n testId,\n disabled = false,\n badge,\n selected = false,\n hasTooltip = false,\n tooltipText,\n hasOpenDrawer = false,\n isMobile = false,\n isForPreviousActiveDrawer = false,\n isForSplitPanel = false,\n }: TriggerButtonProps,\n ref: React.Ref<ButtonProps.Ref>\n) {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const tooltipValue = tooltipText ? tooltipText : ariaLabel ? ariaLabel : '';\n const [showTooltip, setShowTooltip] = useState<boolean>(false);\n const [suppressTooltip, setSupressTooltip] = useState<boolean>(false);\n\n const handleTriggerClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation(); // Stop the event from propagating to the badge icon\n setShowTooltip(false);\n setSupressTooltip(true);\n onClick(event);\n };\n\n const handleBlur = (keepSupressed = false) => {\n setSupressTooltip(keepSupressed);\n setShowTooltip(false);\n };\n\n const handlePointerEnter = () => {\n setSupressTooltip(false);\n setShowTooltip(true);\n };\n\n /**\n * Takes the drawer being closed and the data-shift-focus value from a close button on that drawer that persists\n * on the event relatedTarget to determine not to show the tooltip\n * @param event\n */\n const handleOnFocus = useCallback(\n (event: FocusEvent) => {\n let shouldShowTooltip = false;\n const eventWithRelatedTarget = event as any;\n const relatedTarget = eventWithRelatedTarget?.relatedTarget;\n const isFromAnotherTrigger = relatedTarget?.dataset?.shiftFocus === 'awsui-layout-drawer-trigger';\n if (\n (isForSplitPanel && !!relatedTarget) || // relatedTarget is null when split panel is closed\n (!isForSplitPanel &&\n (isFromAnotherTrigger || // for key navigation from another trigger button\n !isForPreviousActiveDrawer)) // for when the drawer was not opened recently\n ) {\n shouldShowTooltip = true;\n }\n setSupressTooltip(!shouldShowTooltip);\n setShowTooltip(true);\n },\n [\n // To assert reference equality check\n isForPreviousActiveDrawer,\n isForSplitPanel,\n ]\n );\n\n const tooltipVisible = useMemo(() => {\n return (\n hasTooltip &&\n showTooltip &&\n !suppressTooltip &&\n !!containerRef?.current &&\n tooltipValue &&\n !(isMobile && hasOpenDrawer)\n );\n }, [hasTooltip, showTooltip, containerRef, tooltipValue, isMobile, hasOpenDrawer, suppressTooltip]);\n\n useEffect(() => {\n if (hasTooltip && tooltipValue) {\n const close = () => {\n setShowTooltip(false);\n setSupressTooltip(false);\n };\n\n const shouldCloseTooltip = (event: PointerEvent) => {\n if (event.target && containerRef && (containerRef.current as any)?.contains(event.target as HTMLElement)) {\n return false;\n }\n return true;\n };\n\n const handlePointerDownEvent = (event: PointerEvent) => {\n if (shouldCloseTooltip(event)) {\n close();\n }\n };\n\n const handleKeyDownEvent = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n close();\n }\n };\n\n const wrapperDiv = containerRef.current;\n if (wrapperDiv) {\n wrapperDiv.addEventListener('pointerdown', handlePointerDownEvent);\n wrapperDiv.addEventListener('keydown', handleKeyDownEvent);\n\n return () => {\n wrapperDiv.removeEventListener('pointerdown', handlePointerDownEvent);\n wrapperDiv.removeEventListener('keydown', handleKeyDownEvent);\n };\n }\n }\n }, [containerRef, hasTooltip, tooltipValue]);\n\n useEffect(() => {\n if (tooltipVisible) {\n return registerTooltip(() => {\n setShowTooltip(false);\n setSupressTooltip(false);\n });\n }\n }, [tooltipVisible]);\n\n return (\n <div\n ref={containerRef}\n {...(hasTooltip && {\n onPointerEnter: () => handlePointerEnter(),\n onPointerLeave: () => handleBlur(true),\n onFocus: e => handleOnFocus(e as any),\n onBlur: () => handleBlur(true),\n })}\n className={styles['trigger-wrapper']}\n >\n <button\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n aria-haspopup={true}\n aria-label={ariaLabel}\n aria-disabled={disabled}\n disabled={disabled}\n className={clsx(\n styles.trigger,\n styles['trigger-button-styles'],\n {\n [styles.selected]: selected,\n [styles.badge]: badge,\n },\n className\n )}\n onClick={handleTriggerClick}\n ref={ref as Ref<HTMLButtonElement>}\n type=\"button\"\n data-testid={testId}\n data-shift-focus=\"awsui-layout-drawer-trigger\"\n >\n <span className={clsx(badge && clsx(styles['trigger-badge-wrapper'], styles['trigger-button-styles']))}>\n {(iconName || iconSvg) && <Icon name={iconName} svg={iconSvg} />}\n </span>\n </button>\n {badge && <div className={styles.dot} />}\n {tooltipVisible && (\n <Tooltip trackRef={containerRef} value={tooltipValue} className={testutilStyles['trigger-tooltip']} />\n )}\n </div>\n );\n}\n\nexport default React.forwardRef(TriggerButton);\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtF,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,IAAI,MAAM,2BAA2B,CAAC;AAC7C,OAAO,OAAO,MAAM,yCAAyC,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,kD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AC3D,CACA;QACR,KAAK,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,GAAG,GAAI;QACvC,cAAc,IAAI,CACjB,oBAAC,OAAO,IAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,CAAC,iBAAiB,CAAC,GAAI,CACvG,CACG,CACP,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { ButtonProps } from '../../../../button/interfaces';\nimport { IconProps } from '../../../../icon/interfaces';\nimport Icon from '../../../../icon/internal';\nimport Tooltip from '../../../../internal/components/tooltip';\nimport { registerTooltip } from '../../../../internal/components/tooltip/registry';\n\nimport testutilStyles from '../../../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\nexport interface TriggerButtonProps {\n ariaLabel?: string;\n className?: string;\n iconName?: IconProps.Name;\n iconSvg?: React.ReactNode;\n ariaExpanded: boolean | undefined;\n ariaControls?: string;\n disabled?: boolean;\n /**\n * Ovewrwrites any internal testIds when provided\n */\n testId?: string;\n /**\n * If button is selected. Used only for desktop and applies a selected class\n */\n selected?: boolean;\n onClick: React.MouseEventHandler<HTMLButtonElement>;\n\n badge?: boolean;\n /**\n * If the button is expected to have a tooltip. When false it will not set the event listeners\n *\n * defaults to false\n */\n hasTooltip?: boolean;\n /**\n * This text allows for a customized tooltip.\n *\n * When falsy, the tooltip will parse the tooltip form the aria-lable\n */\n tooltipText?: string;\n hasOpenDrawer?: boolean;\n /**\n * If the AppLayout is in mobile mode\n * Used to determine if and where to render tooltips\n */\n isMobile?: boolean;\n /**\n * set to true if the trigger button was used to open the last active drawer\n * this is also used to hide the tooltip should the focus be set programmatically\n * on focus from a drawer close using this\n */\n isForPreviousActiveDrawer?: boolean;\n /**\n * if the trigger button is for the split panel\n */\n isForSplitPanel?: boolean;\n tabIndex?: number | undefined;\n}\n\nfunction TriggerButton(\n {\n ariaLabel,\n className,\n iconName,\n iconSvg,\n ariaExpanded,\n ariaControls,\n onClick,\n testId,\n disabled = false,\n badge,\n selected = false,\n hasTooltip = false,\n tooltipText,\n hasOpenDrawer = false,\n isMobile = false,\n isForPreviousActiveDrawer = false,\n isForSplitPanel = false,\n }: TriggerButtonProps,\n ref: React.Ref<ButtonProps.Ref>\n) {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const tooltipValue = tooltipText ? tooltipText : ariaLabel ? ariaLabel : '';\n const [showTooltip, setShowTooltip] = useState<boolean>(false);\n const [suppressTooltip, setSupressTooltip] = useState<boolean>(false);\n\n const handleTriggerClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation(); // Stop the event from propagating to the badge icon\n setShowTooltip(false);\n setSupressTooltip(true);\n onClick(event);\n };\n\n const handleBlur = (keepSupressed = false) => {\n setSupressTooltip(keepSupressed);\n setShowTooltip(false);\n };\n\n const handlePointerEnter = () => {\n setSupressTooltip(false);\n setShowTooltip(true);\n };\n\n /**\n * Takes the drawer being closed and the data-shift-focus value from a close button on that drawer that persists\n * on the event relatedTarget to determine not to show the tooltip\n * @param event\n */\n const handleOnFocus = useCallback(\n (event: FocusEvent) => {\n let shouldShowTooltip = false;\n const eventWithRelatedTarget = event as any;\n const relatedTarget = eventWithRelatedTarget?.relatedTarget;\n const isFromAnotherTrigger = relatedTarget?.dataset?.shiftFocus === 'awsui-layout-drawer-trigger';\n if (\n (isForSplitPanel && !!relatedTarget) || // relatedTarget is null when split panel is closed\n (!isForSplitPanel &&\n (isFromAnotherTrigger || // for key navigation from another trigger button\n !isForPreviousActiveDrawer)) // for when the drawer was not opened recently\n ) {\n shouldShowTooltip = true;\n }\n setSupressTooltip(!shouldShowTooltip);\n setShowTooltip(true);\n },\n [\n // To assert reference equality check\n isForPreviousActiveDrawer,\n isForSplitPanel,\n ]\n );\n\n const tooltipVisible = useMemo(() => {\n return (\n hasTooltip &&\n showTooltip &&\n !suppressTooltip &&\n !!containerRef?.current &&\n tooltipValue &&\n !(isMobile && hasOpenDrawer)\n );\n }, [hasTooltip, showTooltip, containerRef, tooltipValue, isMobile, hasOpenDrawer, suppressTooltip]);\n\n useEffect(() => {\n if (hasTooltip && tooltipValue) {\n const close = () => {\n setShowTooltip(false);\n setSupressTooltip(false);\n };\n\n const shouldCloseTooltip = (event: PointerEvent) => {\n if (event.target && containerRef && (containerRef.current as any)?.contains(event.target as HTMLElement)) {\n return false;\n }\n return true;\n };\n\n const handlePointerDownEvent = (event: PointerEvent) => {\n if (shouldCloseTooltip(event)) {\n close();\n }\n };\n\n const handleKeyDownEvent = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n close();\n }\n };\n\n const wrapperDiv = containerRef.current;\n if (wrapperDiv) {\n wrapperDiv.addEventListener('pointerdown', handlePointerDownEvent);\n wrapperDiv.addEventListener('keydown', handleKeyDownEvent);\n\n return () => {\n wrapperDiv.removeEventListener('pointerdown', handlePointerDownEvent);\n wrapperDiv.removeEventListener('keydown', handleKeyDownEvent);\n };\n }\n }\n }, [containerRef, hasTooltip, tooltipValue]);\n\n useEffect(() => {\n if (tooltipVisible) {\n return registerTooltip(() => {\n setShowTooltip(false);\n setSupressTooltip(false);\n });\n }\n }, [tooltipVisible]);\n\n return (\n <div\n ref={containerRef}\n {...(hasTooltip && {\n onPointerEnter: () => handlePointerEnter(),\n onPointerLeave: () => handleBlur(true),\n onFocus: e => handleOnFocus(e as any),\n onBlur: () => handleBlur(true),\n })}\n className={styles['trigger-wrapper']}\n >\n <button\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n aria-haspopup={true}\n aria-label={ariaLabel}\n aria-disabled={disabled}\n disabled={disabled}\n className={clsx(\n styles.trigger,\n styles['trigger-button-styles'],\n {\n [styles.selected]: selected,\n [styles.badge]: badge,\n [testutilStyles['drawers-trigger-with-badge']]: badge,\n },\n className\n )}\n onClick={handleTriggerClick}\n ref={ref as Ref<HTMLButtonElement>}\n type=\"button\"\n data-testid={testId}\n data-shift-focus=\"awsui-layout-drawer-trigger\"\n >\n <span className={clsx(badge && clsx(styles['trigger-badge-wrapper'], styles['trigger-button-styles']))}>\n {(iconName || iconSvg) && <Icon name={iconName} svg={iconSvg} />}\n </span>\n </button>\n {badge && <div className={styles.dot} />}\n {tooltipVisible && (\n <Tooltip trackRef={containerRef} value={tooltipValue} className={testutilStyles['trigger-tooltip']} />\n )}\n </div>\n );\n}\n\nexport default React.forwardRef(TriggerButton);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/file-upload/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAM9D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAOnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAUlF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;;AAQ/C,wBAAoD"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/file-upload/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAM9D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AASlF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;;AAQ/C,wBAAoD"}
@@ -8,6 +8,7 @@ import InternalBox from '../box/internal';
8
8
  import { useFormFieldContext } from '../contexts/form-field';
9
9
  import { ConstraintText, FormFieldError, FormFieldWarning } from '../form-field/internal';
10
10
  import { getBaseProps } from '../internal/base-component';
11
+ import InternalFileDropzone, { useFilesDragging } from '../internal/components/file-dropzone';
11
12
  import TokenList from '../internal/components/token-list';
12
13
  import { fireNonCancelableEvent } from '../internal/events';
13
14
  import checkControlled from '../internal/hooks/check-controlled';
@@ -17,7 +18,6 @@ import { useUniqueId } from '../internal/hooks/use-unique-id';
17
18
  import { joinStrings } from '../internal/utils/strings';
18
19
  import InternalSpaceBetween from '../space-between/internal';
19
20
  import { Token } from '../token-group/token';
20
- import { Dropzone, useDropzoneVisible } from './dropzone';
21
21
  import FileInput from './file-input';
22
22
  import { FileOption } from './file-option';
23
23
  import tokenListStyles from '../internal/components/token-list/styles.css.js';
@@ -58,7 +58,7 @@ function InternalFileUpload(_a, externalRef) {
58
58
  fireNonCancelableEvent(onChange, { value: newValue });
59
59
  setNextFocusIndex(removeFileIndex);
60
60
  };
61
- const isDropzoneVisible = useDropzoneVisible(multiple);
61
+ const { areFilesDragging } = useFilesDragging();
62
62
  const showWarning = warningText && !errorText;
63
63
  if (warningText && errorText) {
64
64
  warnOnce('FileUpload', 'Both `errorText` and `warningText` exist. `warningText` will not be shown.');
@@ -69,7 +69,7 @@ function InternalFileUpload(_a, externalRef) {
69
69
  const invalid = restProps.invalid || formFieldContext.invalid || hasError;
70
70
  return (React.createElement(InternalSpaceBetween, Object.assign({}, baseProps, { size: "xs", className: clsx(baseProps.className, styles.root), __internalRootRef: __internalRootRef, ref: tokenListRef }),
71
71
  React.createElement(InternalBox, null,
72
- isDropzoneVisible ? (React.createElement(Dropzone, { onChange: handleFilesChange }, i18nStrings.dropzoneText(multiple))) : (React.createElement(FileInput, Object.assign({ ref: ref, accept: accept, ariaRequired: ariaRequired, multiple: multiple, onChange: handleFilesChange, value: value }, restProps, { ariaDescribedby: ariaDescribedBy, invalid: invalid }), i18nStrings.uploadButtonText(multiple))),
72
+ areFilesDragging ? (React.createElement(InternalFileDropzone, { onChange: event => handleFilesChange(event.detail.value) }, i18nStrings.dropzoneText(multiple))) : (React.createElement(FileInput, Object.assign({ ref: ref, accept: accept, ariaRequired: ariaRequired, multiple: multiple, onChange: handleFilesChange, value: value }, restProps, { ariaDescribedby: ariaDescribedBy, invalid: invalid }), i18nStrings.uploadButtonText(multiple))),
73
73
  (constraintText || errorText || warningText) && (React.createElement("div", { className: styles.hints },
74
74
  errorText && (React.createElement(FormFieldError, { id: errorId, errorIconAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.errorIconAriaLabel }, errorText)),
75
75
  showWarning && (React.createElement(FormFieldWarning, { id: warningId, warningIconAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.warningIconAriaLabel }, warningText)),
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/file-upload/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,SAAS,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,s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CAAC,oBAAoB,gBAC1C,CAAC;gBAEb,oBAAC,UAAU,IAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAI,CACtE,CACI,CACf,CAAC,CAAC,CAAC,IAAI;QAEP,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC9B,oBAAC,WAAW;YACV,oBAAC,SAAS,IACR,SAAS,EAAC,UAAU,EACpB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAC/B,oBAAC,KAAK,IACJ,SAAS,EAAE,IAAI,CAAC,IAAI,EACpB,YAAY,EAAE,WAAW,CAAC,mBAAmB,CAAC,SAAS,CAAC,EACxD,SAAS,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,EACxC,SAAS,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,SAAS,CAAC,EAClC,WAAW,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,SAAS,CAAC,EACtC,kBAAkB,EAAE,WAAW,CAAC,kBAAkB,EAClD,oBAAoB,EAAE,WAAW,CAAC,oBAAoB,gBAC1C,SAAS;oBAErB,oBAAC,UAAU,IAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAI,CAClE,CACT,EACD,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE;oBACX,cAAc,EAAE,WAAW,CAAC,cAAc;oBAC1C,aAAa,EAAE,WAAW,CAAC,aAAa;iBACzC,GACD,CACU,CACf,CAAC,CAAC,CAAC,IAAI,CACa,CACxB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { ForwardedRef, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalBox from '../box/internal';\nimport { ButtonProps } from '../button/interfaces';\nimport { useFormFieldContext } from '../contexts/form-field';\nimport { ConstraintText, FormFieldError, FormFieldWarning } from '../form-field/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport TokenList from '../internal/components/token-list';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useListFocusController } from '../internal/hooks/use-list-focus-controller';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { joinStrings } from '../internal/utils/strings';\nimport InternalSpaceBetween from '../space-between/internal';\nimport { Token } from '../token-group/token';\nimport { Dropzone, useDropzoneVisible } from './dropzone';\nimport FileInput from './file-input';\nimport { FileOption } from './file-option';\nimport { FileUploadProps } from './interfaces';\n\nimport tokenListStyles from '../internal/components/token-list/styles.css.js';\nimport fileInputStyles from './file-input/styles.css.js';\nimport styles from './styles.css.js';\n\ntype InternalFileUploadProps = FileUploadProps & InternalBaseComponentProps;\n\nexport default React.forwardRef(InternalFileUpload);\n\nfunction InternalFileUpload(\n {\n accept,\n ariaRequired,\n multiple = false,\n onChange,\n value,\n tokenLimit,\n showFileSize,\n showFileLastModified,\n showFileThumbnail,\n i18nStrings,\n __internalRootRef = null,\n constraintText,\n errorText,\n warningText,\n fileErrors,\n fileWarnings,\n ...restProps\n }: InternalFileUploadProps,\n externalRef: ForwardedRef<ButtonProps.Ref>\n) {\n const [nextFocusIndex, setNextFocusIndex] = useState<null | number>(null);\n const tokenListRef = useListFocusController({\n nextFocusIndex,\n onFocusMoved: target => {\n target.focus();\n setNextFocusIndex(null);\n },\n listItemSelector: `.${tokenListStyles['list-item']}`,\n showMoreSelector: `.${tokenListStyles.toggle}`,\n fallbackSelector: `.${fileInputStyles['upload-input']}`,\n });\n\n const baseProps = getBaseProps(restProps);\n const metadata = { showFileSize, showFileLastModified, showFileThumbnail };\n\n const errorId = useUniqueId('error-');\n const warningId = useUniqueId('warning-');\n const constraintTextId = useUniqueId('constraint-text-');\n\n const fileInputRef = useRef<ButtonProps.Ref>(null);\n const ref = useMergeRefs(fileInputRef, externalRef);\n\n checkControlled('FileUpload', 'value', value, 'onChange', onChange);\n\n if (!multiple && value.length > 1) {\n warnOnce('FileUpload', 'Value must be an array of size 0 or 1 when `multiple=false`.');\n }\n\n const handleFilesChange = (newFiles: File[]) => {\n const newValue = multiple ? [...value, ...newFiles] : newFiles[0] ? newFiles.slice(0, 1) : [...value];\n fireNonCancelableEvent(onChange, { value: newValue });\n };\n\n const onFileRemove = (removeFileIndex: number) => {\n const newValue = value.filter((_, fileIndex) => fileIndex !== removeFileIndex);\n fireNonCancelableEvent(onChange, { value: newValue });\n setNextFocusIndex(removeFileIndex);\n };\n\n const isDropzoneVisible = useDropzoneVisible(multiple);\n\n const showWarning = warningText && !errorText;\n\n if (warningText && errorText) {\n warnOnce('FileUpload', 'Both `errorText` and `warningText` exist. `warningText` will not be shown.');\n }\n\n const formFieldContext = useFormFieldContext(restProps);\n const ariaDescribedBy = joinStrings(\n restProps.ariaDescribedby ?? formFieldContext.ariaDescribedby,\n errorText ? errorId : undefined,\n showWarning ? warningId : undefined,\n constraintText ? constraintTextId : undefined\n );\n\n const hasError = Boolean(errorText || fileErrors?.filter(Boolean).length);\n const invalid = restProps.invalid || formFieldContext.invalid || hasError;\n\n return (\n <InternalSpaceBetween\n {...baseProps}\n size=\"xs\"\n className={clsx(baseProps.className, styles.root)}\n __internalRootRef={__internalRootRef}\n ref={tokenListRef}\n >\n <InternalBox>\n {isDropzoneVisible ? (\n <Dropzone onChange={handleFilesChange}>{i18nStrings.dropzoneText(multiple)}</Dropzone>\n ) : (\n <FileInput\n ref={ref}\n accept={accept}\n ariaRequired={ariaRequired}\n multiple={multiple}\n onChange={handleFilesChange}\n value={value}\n {...restProps}\n ariaDescribedby={ariaDescribedBy}\n invalid={invalid}\n >\n {i18nStrings.uploadButtonText(multiple)}\n </FileInput>\n )}\n\n {(constraintText || errorText || warningText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={errorId} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {showWarning && (\n <FormFieldWarning id={warningId} warningIconAriaLabel={i18nStrings?.warningIconAriaLabel}>\n {warningText}\n </FormFieldWarning>\n )}\n {constraintText && (\n <ConstraintText id={constraintTextId} hasValidationText={!!errorText || !!warningText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </InternalBox>\n\n {!multiple && value.length > 0 ? (\n <InternalBox>\n <Token\n ariaLabel={value[0].name}\n dismissLabel={i18nStrings.removeFileAriaLabel(0)}\n onDismiss={() => onFileRemove(0)}\n errorText={fileErrors?.[0]}\n warningText={fileWarnings?.[0]}\n errorIconAriaLabel={i18nStrings.errorIconAriaLabel}\n warningIconAriaLabel={i18nStrings.warningIconAriaLabel}\n data-index={0}\n >\n <FileOption file={value[0]} metadata={metadata} i18nStrings={i18nStrings} />\n </Token>\n </InternalBox>\n ) : null}\n\n {multiple && value.length > 0 ? (\n <InternalBox>\n <TokenList\n alignment=\"vertical\"\n items={value}\n renderItem={(file, fileIndex) => (\n <Token\n ariaLabel={file.name}\n dismissLabel={i18nStrings.removeFileAriaLabel(fileIndex)}\n onDismiss={() => onFileRemove(fileIndex)}\n errorText={fileErrors?.[fileIndex]}\n warningText={fileWarnings?.[fileIndex]}\n errorIconAriaLabel={i18nStrings.errorIconAriaLabel}\n warningIconAriaLabel={i18nStrings.warningIconAriaLabel}\n data-index={fileIndex}\n >\n <FileOption file={file} metadata={metadata} i18nStrings={i18nStrings} />\n </Token>\n )}\n limit={tokenLimit}\n i18nStrings={{\n limitShowFewer: i18nStrings.limitShowFewer,\n limitShowMore: i18nStrings.limitShowMore,\n }}\n />\n </InternalBox>\n ) : null}\n </InternalSpaceBetween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C,CAAC,CAAC,CAAC,CAC9B,oBAAC,WAAW;YACV,oBAAC,SAAS,IACR,SAAS,EAAC,UAAU,EACpB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAC/B,oBAAC,KAAK,IACJ,SAAS,EAAE,IAAI,CAAC,IAAI,EACpB,YAAY,EAAE,WAAW,CAAC,mBAAmB,CAAC,SAAS,CAAC,EACxD,SAAS,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,EACxC,SAAS,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,SAAS,CAAC,EAClC,WAAW,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,SAAS,CAAC,EACtC,kBAAkB,EAAE,WAAW,CAAC,kBAAkB,EAClD,oBAAoB,EAAE,WAAW,CAAC,oBAAoB,gBAC1C,SAAS;oBAErB,oBAAC,UAAU,IAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAI,CAClE,CACT,EACD,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE;oBACX,cAAc,EAAE,WAAW,CAAC,cAAc;oBAC1C,aAAa,EAAE,WAAW,CAAC,aAAa;iBACzC,GACD,CACU,CACf,CAAC,CAAC,CAAC,IAAI,CACa,CACxB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { ForwardedRef, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalBox from '../box/internal';\nimport { ButtonProps } from '../button/interfaces';\nimport { useFormFieldContext } from '../contexts/form-field';\nimport { ConstraintText, FormFieldError, FormFieldWarning } from '../form-field/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport InternalFileDropzone, { useFilesDragging } from '../internal/components/file-dropzone';\nimport TokenList from '../internal/components/token-list';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useListFocusController } from '../internal/hooks/use-list-focus-controller';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { joinStrings } from '../internal/utils/strings';\nimport InternalSpaceBetween from '../space-between/internal';\nimport { Token } from '../token-group/token';\nimport FileInput from './file-input';\nimport { FileOption } from './file-option';\nimport { FileUploadProps } from './interfaces';\n\nimport tokenListStyles from '../internal/components/token-list/styles.css.js';\nimport fileInputStyles from './file-input/styles.css.js';\nimport styles from './styles.css.js';\n\ntype InternalFileUploadProps = FileUploadProps & InternalBaseComponentProps;\n\nexport default React.forwardRef(InternalFileUpload);\n\nfunction InternalFileUpload(\n {\n accept,\n ariaRequired,\n multiple = false,\n onChange,\n value,\n tokenLimit,\n showFileSize,\n showFileLastModified,\n showFileThumbnail,\n i18nStrings,\n __internalRootRef = null,\n constraintText,\n errorText,\n warningText,\n fileErrors,\n fileWarnings,\n ...restProps\n }: InternalFileUploadProps,\n externalRef: ForwardedRef<ButtonProps.Ref>\n) {\n const [nextFocusIndex, setNextFocusIndex] = useState<null | number>(null);\n const tokenListRef = useListFocusController({\n nextFocusIndex,\n onFocusMoved: target => {\n target.focus();\n setNextFocusIndex(null);\n },\n listItemSelector: `.${tokenListStyles['list-item']}`,\n showMoreSelector: `.${tokenListStyles.toggle}`,\n fallbackSelector: `.${fileInputStyles['upload-input']}`,\n });\n\n const baseProps = getBaseProps(restProps);\n const metadata = { showFileSize, showFileLastModified, showFileThumbnail };\n\n const errorId = useUniqueId('error-');\n const warningId = useUniqueId('warning-');\n const constraintTextId = useUniqueId('constraint-text-');\n\n const fileInputRef = useRef<ButtonProps.Ref>(null);\n const ref = useMergeRefs(fileInputRef, externalRef);\n\n checkControlled('FileUpload', 'value', value, 'onChange', onChange);\n\n if (!multiple && value.length > 1) {\n warnOnce('FileUpload', 'Value must be an array of size 0 or 1 when `multiple=false`.');\n }\n\n const handleFilesChange = (newFiles: File[]) => {\n const newValue = multiple ? [...value, ...newFiles] : newFiles[0] ? newFiles.slice(0, 1) : [...value];\n fireNonCancelableEvent(onChange, { value: newValue });\n };\n\n const onFileRemove = (removeFileIndex: number) => {\n const newValue = value.filter((_, fileIndex) => fileIndex !== removeFileIndex);\n fireNonCancelableEvent(onChange, { value: newValue });\n setNextFocusIndex(removeFileIndex);\n };\n\n const { areFilesDragging } = useFilesDragging();\n\n const showWarning = warningText && !errorText;\n\n if (warningText && errorText) {\n warnOnce('FileUpload', 'Both `errorText` and `warningText` exist. `warningText` will not be shown.');\n }\n\n const formFieldContext = useFormFieldContext(restProps);\n const ariaDescribedBy = joinStrings(\n restProps.ariaDescribedby ?? formFieldContext.ariaDescribedby,\n errorText ? errorId : undefined,\n showWarning ? warningId : undefined,\n constraintText ? constraintTextId : undefined\n );\n\n const hasError = Boolean(errorText || fileErrors?.filter(Boolean).length);\n const invalid = restProps.invalid || formFieldContext.invalid || hasError;\n\n return (\n <InternalSpaceBetween\n {...baseProps}\n size=\"xs\"\n className={clsx(baseProps.className, styles.root)}\n __internalRootRef={__internalRootRef}\n ref={tokenListRef}\n >\n <InternalBox>\n {areFilesDragging ? (\n <InternalFileDropzone onChange={event => handleFilesChange(event.detail.value)}>\n {i18nStrings.dropzoneText(multiple)}\n </InternalFileDropzone>\n ) : (\n <FileInput\n ref={ref}\n accept={accept}\n ariaRequired={ariaRequired}\n multiple={multiple}\n onChange={handleFilesChange}\n value={value}\n {...restProps}\n ariaDescribedby={ariaDescribedBy}\n invalid={invalid}\n >\n {i18nStrings.uploadButtonText(multiple)}\n </FileInput>\n )}\n\n {(constraintText || errorText || warningText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={errorId} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {showWarning && (\n <FormFieldWarning id={warningId} warningIconAriaLabel={i18nStrings?.warningIconAriaLabel}>\n {warningText}\n </FormFieldWarning>\n )}\n {constraintText && (\n <ConstraintText id={constraintTextId} hasValidationText={!!errorText || !!warningText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </InternalBox>\n\n {!multiple && value.length > 0 ? (\n <InternalBox>\n <Token\n ariaLabel={value[0].name}\n dismissLabel={i18nStrings.removeFileAriaLabel(0)}\n onDismiss={() => onFileRemove(0)}\n errorText={fileErrors?.[0]}\n warningText={fileWarnings?.[0]}\n errorIconAriaLabel={i18nStrings.errorIconAriaLabel}\n warningIconAriaLabel={i18nStrings.warningIconAriaLabel}\n data-index={0}\n >\n <FileOption file={value[0]} metadata={metadata} i18nStrings={i18nStrings} />\n </Token>\n </InternalBox>\n ) : null}\n\n {multiple && value.length > 0 ? (\n <InternalBox>\n <TokenList\n alignment=\"vertical\"\n items={value}\n renderItem={(file, fileIndex) => (\n <Token\n ariaLabel={file.name}\n dismissLabel={i18nStrings.removeFileAriaLabel(fileIndex)}\n onDismiss={() => onFileRemove(fileIndex)}\n errorText={fileErrors?.[fileIndex]}\n warningText={fileWarnings?.[fileIndex]}\n errorIconAriaLabel={i18nStrings.errorIconAriaLabel}\n warningIconAriaLabel={i18nStrings.warningIconAriaLabel}\n data-index={fileIndex}\n >\n <FileOption file={file} metadata={metadata} i18nStrings={i18nStrings} />\n </Token>\n )}\n limit={tokenLimit}\n i18nStrings={{\n limitShowFewer: i18nStrings.limitShowFewer,\n limitShowMore: i18nStrings.limitShowMore,\n }}\n />\n </InternalBox>\n ) : null}\n </InternalSpaceBetween>\n );\n}\n"]}
@@ -243,9 +243,9 @@
243
243
  --color-text-avatar-7icw2p:#ffffff;
244
244
  --color-background-loading-bar-gen-ai-p03hst:linear-gradient(90deg, #99f7ff 0%, #0096fa 10%, #bf80ff 24%, #7300e5 50%, #bf80ff 76%, #0096fa 90%, #99f7ff 100%);
245
245
  --color-background-chat-bubble-outgoing-7ajv6t:transparent;
246
- --color-background-chat-bubble-incoming-b6y6od:#f2f3f3;
247
- --color-text-chat-bubble-outgoing-kk7vbt:#545b64;
248
- --color-text-chat-bubble-incoming-iw4zm4:#545b64;
246
+ --color-background-chat-bubble-incoming-g2lfei:#f2f3f3;
247
+ --color-text-chat-bubble-outgoing-a4whbc:#16191f;
248
+ --color-text-chat-bubble-incoming-wpxwg5:#16191f;
249
249
  --color-border-button-normal-active-vm8kc9:#545b64;
250
250
  --color-border-button-normal-default-g4ujwl:#545b64;
251
251
  --color-border-toggle-button-normal-pressed-dxcaaj:#545b64;
@@ -876,9 +876,9 @@
876
876
  --color-background-tiles-disabled-c21opp:#2a2e33;
877
877
  --color-background-toggle-checked-disabled-m1mknq:#0a4a74;
878
878
  --color-background-toggle-default-yhlddz:#879596;
879
- --color-background-chat-bubble-incoming-b6y6od:#131920;
880
- --color-text-chat-bubble-outgoing-kk7vbt:#d5dbdb;
881
- --color-text-chat-bubble-incoming-iw4zm4:#d5dbdb;
879
+ --color-background-chat-bubble-incoming-g2lfei:#16191f;
880
+ --color-text-chat-bubble-outgoing-a4whbc:#d5dbdb;
881
+ --color-text-chat-bubble-incoming-wpxwg5:#d5dbdb;
882
882
  --color-border-button-normal-active-vm8kc9:#879596;
883
883
  --color-border-button-normal-default-g4ujwl:#879596;
884
884
  --color-border-toggle-button-normal-pressed-dxcaaj:#879596;
@@ -1191,9 +1191,9 @@
1191
1191
  --color-background-tiles-disabled-c21opp:#2a2e33;
1192
1192
  --color-background-toggle-checked-disabled-m1mknq:#0a4a74;
1193
1193
  --color-background-toggle-default-yhlddz:#879596;
1194
- --color-background-chat-bubble-incoming-b6y6od:#131920;
1195
- --color-text-chat-bubble-outgoing-kk7vbt:#d5dbdb;
1196
- --color-text-chat-bubble-incoming-iw4zm4:#d5dbdb;
1194
+ --color-background-chat-bubble-incoming-g2lfei:#16191f;
1195
+ --color-text-chat-bubble-outgoing-a4whbc:#d5dbdb;
1196
+ --color-text-chat-bubble-incoming-wpxwg5:#d5dbdb;
1197
1197
  --color-border-button-normal-active-vm8kc9:#879596;
1198
1198
  --color-border-button-normal-default-g4ujwl:#879596;
1199
1199
  --color-border-toggle-button-normal-pressed-dxcaaj:#879596;
@@ -1333,6 +1333,8 @@
1333
1333
  }
1334
1334
 
1335
1335
  .awsui-context-flashbar:not(#\9) {
1336
+ --color-text-chat-bubble-outgoing-a4whbc:#fafafa;
1337
+ --color-text-chat-bubble-incoming-wpxwg5:#fafafa;
1336
1338
  --color-border-calendar-grid-3f7bvh:#fafafa;
1337
1339
  --color-border-calendar-grid-selected-focus-ring-faye0i:#fafafa;
1338
1340
  --color-border-container-divider-xr1vlc:#fafafa;
@@ -1404,6 +1406,8 @@
1404
1406
  }
1405
1407
  @media not print {
1406
1408
  .awsui-dark-mode .awsui-context-flashbar-warning:not(#\9) {
1409
+ --color-text-chat-bubble-outgoing-a4whbc:#16191f;
1410
+ --color-text-chat-bubble-incoming-wpxwg5:#16191f;
1407
1411
  --color-border-tabs-shadow-eb3y7s:rgba(0, 0, 0, 0.3);
1408
1412
  --color-text-body-default-agk00h:#16191f;
1409
1413
  --color-text-expandable-section-hover-4hvgvf:#16191f;
@@ -1411,6 +1415,8 @@
1411
1415
  }
1412
1416
  @media not print {
1413
1417
  .awsui-context-flashbar-warning.awsui-dark-mode:not(#\9) {
1418
+ --color-text-chat-bubble-outgoing-a4whbc:#16191f;
1419
+ --color-text-chat-bubble-incoming-wpxwg5:#16191f;
1414
1420
  --color-border-tabs-shadow-eb3y7s:rgba(0, 0, 0, 0.3);
1415
1421
  --color-text-body-default-agk00h:#16191f;
1416
1422
  --color-text-expandable-section-hover-4hvgvf:#16191f;
@@ -1525,9 +1531,9 @@
1525
1531
  --color-background-toggle-checked-disabled-m1mknq:#b8e7ff;
1526
1532
  --color-background-toggle-default-yhlddz:#424650;
1527
1533
  --color-background-avatar-default-mwwgjf:#424650;
1528
- --color-background-chat-bubble-incoming-b6y6od:#f3f3f7;
1529
- --color-text-chat-bubble-outgoing-kk7vbt:#424650;
1530
- --color-text-chat-bubble-incoming-iw4zm4:#424650;
1534
+ --color-background-chat-bubble-incoming-g2lfei:#f3f3f7;
1535
+ --color-text-chat-bubble-outgoing-a4whbc:#0f141a;
1536
+ --color-text-chat-bubble-incoming-wpxwg5:#0f141a;
1531
1537
  --color-border-button-normal-active-vm8kc9:#002b66;
1532
1538
  --color-border-button-normal-default-g4ujwl:#006ce0;
1533
1539
  --color-border-toggle-button-normal-pressed-dxcaaj:#006ce0;
@@ -1894,9 +1900,9 @@
1894
1900
  --color-background-tiles-disabled-c21opp:#1b232d;
1895
1901
  --color-background-toggle-checked-disabled-m1mknq:#002b66;
1896
1902
  --color-background-toggle-default-yhlddz:#8c8c94;
1897
- --color-background-chat-bubble-incoming-b6y6od:#131920;
1898
- --color-text-chat-bubble-outgoing-kk7vbt:#c6c6cd;
1899
- --color-text-chat-bubble-incoming-iw4zm4:#c6c6cd;
1903
+ --color-background-chat-bubble-incoming-g2lfei:#0f141a;
1904
+ --color-text-chat-bubble-outgoing-a4whbc:#c6c6cd;
1905
+ --color-text-chat-bubble-incoming-wpxwg5:#c6c6cd;
1900
1906
  --color-border-button-normal-active-vm8kc9:#75cfff;
1901
1907
  --color-border-button-normal-default-g4ujwl:#42b4ff;
1902
1908
  --color-border-toggle-button-normal-pressed-dxcaaj:#42b4ff;
@@ -2171,8 +2177,9 @@
2171
2177
  --color-background-tiles-disabled-c21opp:#1b232d;
2172
2178
  --color-background-toggle-checked-disabled-m1mknq:#002b66;
2173
2179
  --color-background-toggle-default-yhlddz:#8c8c94;
2174
- --color-text-chat-bubble-outgoing-kk7vbt:#c6c6cd;
2175
- --color-text-chat-bubble-incoming-iw4zm4:#c6c6cd;
2180
+ --color-background-chat-bubble-incoming-g2lfei:#0f141a;
2181
+ --color-text-chat-bubble-outgoing-a4whbc:#c6c6cd;
2182
+ --color-text-chat-bubble-incoming-wpxwg5:#c6c6cd;
2176
2183
  --color-border-button-normal-active-vm8kc9:#75cfff;
2177
2184
  --color-border-button-normal-default-g4ujwl:#42b4ff;
2178
2185
  --color-border-toggle-button-normal-pressed-dxcaaj:#42b4ff;
@@ -2378,9 +2385,9 @@
2378
2385
  --color-background-tiles-disabled-c21opp:#1b232d;
2379
2386
  --color-background-toggle-checked-disabled-m1mknq:#002b66;
2380
2387
  --color-background-toggle-default-yhlddz:#8c8c94;
2381
- --color-background-chat-bubble-incoming-b6y6od:#131920;
2382
- --color-text-chat-bubble-outgoing-kk7vbt:#c6c6cd;
2383
- --color-text-chat-bubble-incoming-iw4zm4:#c6c6cd;
2388
+ --color-background-chat-bubble-incoming-g2lfei:#0f141a;
2389
+ --color-text-chat-bubble-outgoing-a4whbc:#c6c6cd;
2390
+ --color-text-chat-bubble-incoming-wpxwg5:#c6c6cd;
2384
2391
  --color-border-button-normal-active-vm8kc9:#75cfff;
2385
2392
  --color-border-button-normal-default-g4ujwl:#42b4ff;
2386
2393
  --color-border-toggle-button-normal-pressed-dxcaaj:#42b4ff;
@@ -2583,9 +2590,9 @@
2583
2590
  --color-background-tiles-disabled-c21opp:#1b232d;
2584
2591
  --color-background-toggle-checked-disabled-m1mknq:#002b66;
2585
2592
  --color-background-toggle-default-yhlddz:#8c8c94;
2586
- --color-background-chat-bubble-incoming-b6y6od:#131920;
2587
- --color-text-chat-bubble-outgoing-kk7vbt:#c6c6cd;
2588
- --color-text-chat-bubble-incoming-iw4zm4:#c6c6cd;
2593
+ --color-background-chat-bubble-incoming-g2lfei:#0f141a;
2594
+ --color-text-chat-bubble-outgoing-a4whbc:#c6c6cd;
2595
+ --color-text-chat-bubble-incoming-wpxwg5:#c6c6cd;
2589
2596
  --color-border-button-normal-active-vm8kc9:#75cfff;
2590
2597
  --color-border-button-normal-default-g4ujwl:#42b4ff;
2591
2598
  --color-border-toggle-button-normal-pressed-dxcaaj:#42b4ff;
@@ -2801,9 +2808,9 @@
2801
2808
  --color-background-tiles-disabled-c21opp:#1b232d;
2802
2809
  --color-background-toggle-checked-disabled-m1mknq:#002b66;
2803
2810
  --color-background-toggle-default-yhlddz:#8c8c94;
2804
- --color-background-chat-bubble-incoming-b6y6od:#131920;
2805
- --color-text-chat-bubble-outgoing-kk7vbt:#c6c6cd;
2806
- --color-text-chat-bubble-incoming-iw4zm4:#c6c6cd;
2811
+ --color-background-chat-bubble-incoming-g2lfei:#0f141a;
2812
+ --color-text-chat-bubble-outgoing-a4whbc:#c6c6cd;
2813
+ --color-text-chat-bubble-incoming-wpxwg5:#c6c6cd;
2807
2814
  --color-border-button-normal-active-vm8kc9:#75cfff;
2808
2815
  --color-border-button-normal-default-g4ujwl:#42b4ff;
2809
2816
  --color-border-toggle-button-normal-pressed-dxcaaj:#42b4ff;
@@ -2965,6 +2972,8 @@
2965
2972
  --color-background-button-primary-hover-288r60:#ffffff;
2966
2973
  --color-background-segment-default-i67ckm:transparent;
2967
2974
  --color-background-segment-hover-rizmh0:transparent;
2975
+ --color-text-chat-bubble-outgoing-a4whbc:#f9f9fa;
2976
+ --color-text-chat-bubble-incoming-wpxwg5:#f9f9fa;
2968
2977
  --color-border-button-normal-active-vm8kc9:#ffffff;
2969
2978
  --color-border-button-normal-default-g4ujwl:#f9f9fa;
2970
2979
  --color-border-button-normal-hover-eyyshk:#ffffff;
@@ -3002,6 +3011,8 @@
3002
3011
  --color-background-button-primary-hover-288r60:#ffffff;
3003
3012
  --color-background-segment-default-i67ckm:transparent;
3004
3013
  --color-background-segment-hover-rizmh0:transparent;
3014
+ --color-text-chat-bubble-outgoing-a4whbc:#f9f9fa;
3015
+ --color-text-chat-bubble-incoming-wpxwg5:#f9f9fa;
3005
3016
  --color-border-button-normal-active-vm8kc9:#ffffff;
3006
3017
  --color-border-button-normal-default-g4ujwl:#f9f9fa;
3007
3018
  --color-border-button-normal-hover-eyyshk:#ffffff;
@@ -3213,9 +3224,9 @@
3213
3224
  --color-background-tiles-disabled-c21opp:#1b232d;
3214
3225
  --color-background-toggle-checked-disabled-m1mknq:#002b66;
3215
3226
  --color-background-toggle-default-yhlddz:#8c8c94;
3216
- --color-background-chat-bubble-incoming-b6y6od:#131920;
3217
- --color-text-chat-bubble-outgoing-kk7vbt:#c6c6cd;
3218
- --color-text-chat-bubble-incoming-iw4zm4:#c6c6cd;
3227
+ --color-background-chat-bubble-incoming-g2lfei:#0f141a;
3228
+ --color-text-chat-bubble-outgoing-a4whbc:#c6c6cd;
3229
+ --color-text-chat-bubble-incoming-wpxwg5:#c6c6cd;
3219
3230
  --color-border-button-normal-active-vm8kc9:#ffffff;
3220
3231
  --color-border-button-normal-default-g4ujwl:#dedee3;
3221
3232
  --color-border-toggle-button-normal-pressed-dxcaaj:#42b4ff;
@@ -3419,9 +3430,9 @@
3419
3430
  --color-background-tiles-disabled-c21opp:#1b232d;
3420
3431
  --color-background-toggle-checked-disabled-m1mknq:#002b66;
3421
3432
  --color-background-toggle-default-yhlddz:#8c8c94;
3422
- --color-background-chat-bubble-incoming-b6y6od:#131920;
3423
- --color-text-chat-bubble-outgoing-kk7vbt:#c6c6cd;
3424
- --color-text-chat-bubble-incoming-iw4zm4:#c6c6cd;
3433
+ --color-background-chat-bubble-incoming-g2lfei:#0f141a;
3434
+ --color-text-chat-bubble-outgoing-a4whbc:#c6c6cd;
3435
+ --color-text-chat-bubble-incoming-wpxwg5:#c6c6cd;
3425
3436
  --color-border-button-normal-active-vm8kc9:#ffffff;
3426
3437
  --color-border-button-normal-default-g4ujwl:#dedee3;
3427
3438
  --color-border-toggle-button-normal-pressed-dxcaaj:#42b4ff;
@@ -3581,6 +3592,8 @@
3581
3592
  }
3582
3593
  @media not print {
3583
3594
  .awsui-dark-mode.awsui-visual-refresh .awsui-context-flashbar-warning:not(#\9) {
3595
+ --color-text-chat-bubble-outgoing-a4whbc:#0f141a;
3596
+ --color-text-chat-bubble-incoming-wpxwg5:#0f141a;
3584
3597
  --color-border-calendar-grid-selected-focus-ring-faye0i:#161d26;
3585
3598
  --color-border-dropdown-item-selected-3l3bsn:#42b4ff;
3586
3599
  --color-border-input-focused-rg4ms2:#b8e7ff;
@@ -3590,6 +3603,8 @@
3590
3603
  }
3591
3604
  @media not print {
3592
3605
  .awsui-context-flashbar-warning.awsui-dark-mode.awsui-visual-refresh:not(#\9) {
3606
+ --color-text-chat-bubble-outgoing-a4whbc:#0f141a;
3607
+ --color-text-chat-bubble-incoming-wpxwg5:#0f141a;
3593
3608
  --color-border-calendar-grid-selected-focus-ring-faye0i:#161d26;
3594
3609
  --color-border-dropdown-item-selected-3l3bsn:#42b4ff;
3595
3610
  --color-border-input-focused-rg4ms2:#b8e7ff;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { FileDropzoneProps } from './interfaces';
3
+ import { useFilesDragging } from './use-files-dragging';
4
+ export { FileDropzoneProps, useFilesDragging };
5
+ export default function InternalFileDropzone({ onChange, children }: FileDropzoneProps): JSX.Element;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/file-dropzone/index.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAIxD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;AAE/C,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,iBAAiB,eAqCrF"}
@@ -0,0 +1,33 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React, { useState } from 'react';
4
+ import clsx from 'clsx';
5
+ import { fireNonCancelableEvent } from '../../events';
6
+ import { useFilesDragging } from './use-files-dragging';
7
+ import styles from './styles.css.js';
8
+ export { useFilesDragging };
9
+ export default function InternalFileDropzone({ onChange, children }) {
10
+ const [isDropzoneHovered, setDropzoneHovered] = useState(false);
11
+ const onDragOver = (event) => {
12
+ event.preventDefault();
13
+ if (event.dataTransfer) {
14
+ setDropzoneHovered(true);
15
+ event.dataTransfer.dropEffect = 'copy';
16
+ }
17
+ };
18
+ const onDragLeave = (event) => {
19
+ event.preventDefault();
20
+ setDropzoneHovered(false);
21
+ if (event.dataTransfer) {
22
+ event.dataTransfer.dropEffect = 'none';
23
+ }
24
+ };
25
+ const onDrop = (event) => {
26
+ event.preventDefault();
27
+ setDropzoneHovered(false);
28
+ fireNonCancelableEvent(onChange, { value: Array.from(event.dataTransfer.files) });
29
+ };
30
+ return (React.createElement("div", { className: clsx(styles.root, isDropzoneHovered && styles.hovered), onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop },
31
+ React.createElement("div", { className: styles.content }, children)));
32
+ }
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/file-dropzone/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAqB,gBAAgB,EAAE,CAAC;AAE/C,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAqB;IACpF,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhE,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;QAC5C,KAAK,CAAC,cAAc,EAAE,CAAC;QAEvB,IAAI,KAAK,CAAC,YAAY,EAAE;YACtB,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACzB,KAAK,CAAC,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC;SACxC;IACH,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,KAAsB,EAAE,EAAE;QAC7C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,KAAK,CAAC,YAAY,EAAE;YACtB,KAAK,CAAC,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC;SACxC;IACH,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,KAAsB,EAAE,EAAE;QACxC,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAE1B,sBAAsB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC,CAAC;IAEF,OAAO,CACL,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,iBAAiB,IAAI,MAAM,CAAC,OAAO,CAAC,EACjE,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM;QAEd,6BAAK,SAAS,EAAE,MAAM,CAAC,OAAO,IAAG,QAAQ,CAAO,CAC5C,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useState } from 'react';\nimport clsx from 'clsx';\n\nimport { fireNonCancelableEvent } from '../../events';\nimport { FileDropzoneProps } from './interfaces';\nimport { useFilesDragging } from './use-files-dragging';\n\nimport styles from './styles.css.js';\n\nexport { FileDropzoneProps, useFilesDragging };\n\nexport default function InternalFileDropzone({ onChange, children }: FileDropzoneProps) {\n const [isDropzoneHovered, setDropzoneHovered] = useState(false);\n\n const onDragOver = (event: React.DragEvent) => {\n event.preventDefault();\n\n if (event.dataTransfer) {\n setDropzoneHovered(true);\n event.dataTransfer.dropEffect = 'copy';\n }\n };\n\n const onDragLeave = (event: React.DragEvent) => {\n event.preventDefault();\n setDropzoneHovered(false);\n if (event.dataTransfer) {\n event.dataTransfer.dropEffect = 'none';\n }\n };\n\n const onDrop = (event: React.DragEvent) => {\n event.preventDefault();\n setDropzoneHovered(false);\n\n fireNonCancelableEvent(onChange, { value: Array.from(event.dataTransfer.files) });\n };\n\n return (\n <div\n className={clsx(styles.root, isDropzoneHovered && styles.hovered)}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n onDrop={onDrop}\n >\n <div className={styles.content}>{children}</div>\n </div>\n );\n}\n"]}
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ import { BaseComponentProps } from '../../base-component';
3
+ import { NonCancelableEventHandler } from '../../events';
4
+ export interface FileDropzoneProps extends BaseComponentProps {
5
+ /**
6
+ * Called when the user selects new file(s), or removes a file.
7
+ * The event `detail` contains the current value of the component.
8
+ */
9
+ onChange: NonCancelableEventHandler<FileDropzoneProps.ChangeDetail>;
10
+ /**
11
+ * Children of the Dropzone.
12
+ */
13
+ children: React.ReactNode;
14
+ }
15
+ export declare namespace FileDropzoneProps {
16
+ interface ChangeDetail {
17
+ value: File[];
18
+ }
19
+ }
20
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/file-dropzone/interfaces.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D;;;OAGG;IACH,QAAQ,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACpE;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,yBAAiB,iBAAiB,CAAC;IACjC,UAAiB,YAAY;QAC3B,KAAK,EAAE,IAAI,EAAE,CAAC;KACf;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/internal/components/file-dropzone/interfaces.tsx"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../../base-component';\nimport { NonCancelableEventHandler } from '../../events';\n\nexport interface FileDropzoneProps extends BaseComponentProps {\n /**\n * Called when the user selects new file(s), or removes a file.\n * The event `detail` contains the current value of the component.\n */\n onChange: NonCancelableEventHandler<FileDropzoneProps.ChangeDetail>;\n /**\n * Children of the Dropzone.\n */\n children: React.ReactNode;\n}\n\nexport namespace FileDropzoneProps {\n export interface ChangeDetail {\n value: File[];\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "root": "awsui_root_1tk3k_1vhpc_177",
5
+ "hovered": "awsui_hovered_1tk3k_1vhpc_193",
6
+ "content": "awsui_content_1tk3k_1vhpc_198"
7
+ };
8
+
@@ -174,7 +174,7 @@
174
174
  */
175
175
  /* Style used for links in slots/components that are text heavy, to help links stand out among
176
176
  surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
177
- .awsui_dropzone_1fham_1kqsy_177:not(#\9) {
177
+ .awsui_root_1tk3k_1vhpc_177:not(#\9) {
178
178
  display: flex;
179
179
  flex-direction: column;
180
180
  align-items: center;
@@ -190,7 +190,11 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
190
190
  background-color: var(--color-dropzone-background-active-4m4xof, #d5dbdb);
191
191
  font-weight: 700;
192
192
  }
193
- .awsui_dropzone-hovered_1fham_1kqsy_193:not(#\9) {
193
+ .awsui_root_1tk3k_1vhpc_177.awsui_hovered_1tk3k_1vhpc_193:not(#\9) {
194
194
  color: var(--color-dropzone-text-hover-72s7mu, #12293b);
195
195
  background-color: var(--color-dropzone-background-hover-7rdkke, #99cbe4);
196
+ }
197
+
198
+ .awsui_content_1tk3k_1vhpc_198:not(#\9) {
199
+ /* used in test-utils */
196
200
  }
@@ -2,7 +2,8 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "dropzone": "awsui_dropzone_1fham_1kqsy_177",
6
- "dropzone-hovered": "awsui_dropzone-hovered_1fham_1kqsy_193"
5
+ "root": "awsui_root_1tk3k_1vhpc_177",
6
+ "hovered": "awsui_hovered_1tk3k_1vhpc_193",
7
+ "content": "awsui_content_1tk3k_1vhpc_198"
7
8
  };
8
9
 
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A utility to determine whether or not a file is being currently dragged into the window.
3
+ *
4
+ * @returns An object with the following arguments:
5
+ * `areFilesDragging`: True if a file is being dragged over the current window, false otherwise.
6
+ */
7
+ export declare function useFilesDragging(): {
8
+ areFilesDragging: boolean;
9
+ };
10
+ //# sourceMappingURL=use-files-dragging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-files-dragging.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/file-dropzone/use-files-dragging.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAgB,gBAAgB;;EAoD/B"}
@@ -1,11 +1,14 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import React, { useEffect, useState } from 'react';
4
- import clsx from 'clsx';
5
- import InternalIcon from '../../icon/internal';
6
- import styles from './styles.css.js';
7
- export function useDropzoneVisible(multiple) {
8
- const [isDropzoneVisible, setDropzoneVisible] = useState(false);
3
+ import { useEffect, useState } from 'react';
4
+ /**
5
+ * A utility to determine whether or not a file is being currently dragged into the window.
6
+ *
7
+ * @returns An object with the following arguments:
8
+ * `areFilesDragging`: True if a file is being dragged over the current window, false otherwise.
9
+ */
10
+ export function useFilesDragging() {
11
+ const [areFilesDragging, setFilesDragging] = useState(false);
9
12
  // Registering global drag events listeners.
10
13
  useEffect(() => {
11
14
  // The timer helps avoiding dropzone blinking.
@@ -20,20 +23,20 @@ export function useDropzoneVisible(multiple) {
20
23
  files++;
21
24
  }
22
25
  }
23
- if (files > 0 && (multiple || files === 1)) {
24
- setDropzoneVisible(true);
26
+ if (files > 0) {
27
+ setFilesDragging(true);
25
28
  dragTimer && clearTimeout(dragTimer);
26
29
  }
27
30
  };
28
31
  // When the files are no longer dragged over the browser the state must be reset.
29
32
  const onDocumentDragLeave = (event) => {
30
33
  event.preventDefault();
31
- dragTimer = setTimeout(() => setDropzoneVisible(false), 25);
34
+ dragTimer = setTimeout(() => setFilesDragging(false), 25);
32
35
  };
33
36
  // If the files were dropped the state must be reset.
34
37
  const onDocumentDrop = (event) => {
35
38
  event.preventDefault();
36
- dragTimer = setTimeout(() => setDropzoneVisible(false), 25);
39
+ dragTimer = setTimeout(() => setFilesDragging(false), 25);
37
40
  };
38
41
  document.addEventListener('dragover', onDocumentDragOver, false);
39
42
  document.addEventListener('dragleave', onDocumentDragLeave, false);
@@ -44,32 +47,7 @@ export function useDropzoneVisible(multiple) {
44
47
  document.removeEventListener('dragleave', onDocumentDragLeave);
45
48
  document.removeEventListener('drop', onDocumentDrop);
46
49
  };
47
- }, [multiple]);
48
- return isDropzoneVisible;
50
+ }, []);
51
+ return { areFilesDragging };
49
52
  }
50
- export function Dropzone({ onChange, children }) {
51
- const [isDropzoneHovered, setDropzoneHovered] = useState(false);
52
- const onDragOver = (event) => {
53
- event.preventDefault();
54
- if (event.dataTransfer) {
55
- setDropzoneHovered(true);
56
- event.dataTransfer.dropEffect = 'copy';
57
- }
58
- };
59
- const onDragLeave = (event) => {
60
- event.preventDefault();
61
- setDropzoneHovered(false);
62
- if (event.dataTransfer) {
63
- event.dataTransfer.dropEffect = 'none';
64
- }
65
- };
66
- const onDrop = (event) => {
67
- event.preventDefault();
68
- setDropzoneHovered(false);
69
- onChange(Array.from(event.dataTransfer.files));
70
- };
71
- return (React.createElement("div", { className: clsx(styles.dropzone, isDropzoneHovered && styles['dropzone-hovered']), onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop },
72
- React.createElement(InternalIcon, { name: "upload" }),
73
- React.createElement("span", null, children)));
74
- }
75
- //# sourceMappingURL=index.js.map
53
+ //# sourceMappingURL=use-files-dragging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-files-dragging.js","sourceRoot":"","sources":["../../../../../src/internal/components/file-dropzone/use-files-dragging.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE7D,4CAA4C;IAC5C,SAAS,CAAC,GAAG,EAAE;QACb,8CAA8C;QAC9C,IAAI,SAAS,GAAyC,IAAI,CAAC;QAE3D,mFAAmF;QACnF,MAAM,kBAAkB,GAAG,CAAC,KAAgB,EAAE,EAAE;;YAC9C,KAAK,CAAC,cAAc,EAAE,CAAC;YAEvB,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,CAAA,MAAA,KAAK,CAAC,YAAY,0CAAE,KAAK,CAAC,MAAM,KAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;gBACzE,IAAI,CAAA,MAAA,KAAK,CAAC,YAAY,0CAAE,KAAK,CAAC,IAAI,CAAC,MAAK,OAAO,EAAE;oBAC/C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Content":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useEffect, useState } from 'react';\n\n/**\n * A utility to determine whether or not a file is being currently dragged into the window.\n *\n * @returns An object with the following arguments:\n * `areFilesDragging`: True if a file is being dragged over the current window, false otherwise.\n */\nexport function useFilesDragging() {\n const [areFilesDragging, setFilesDragging] = useState(false);\n\n // Registering global drag events listeners.\n useEffect(() => {\n // The timer helps avoiding dropzone blinking.\n let dragTimer: null | ReturnType<typeof setTimeout> = null;\n\n // The file-upload dropzone is shown when the user drags files over to the browser.\n const onDocumentDragOver = (event: DragEvent) => {\n event.preventDefault();\n\n let files = 0;\n for (let item = 0; item < (event.dataTransfer?.types.length || 0); item++) {\n if (event.dataTransfer?.types[item] === 'Files') {\n files++;\n }\n }\n\n if (files > 0) {\n setFilesDragging(true);\n dragTimer && clearTimeout(dragTimer);\n }\n };\n\n // When the files are no longer dragged over the browser the state must be reset.\n const onDocumentDragLeave = (event: DragEvent) => {\n event.preventDefault();\n\n dragTimer = setTimeout(() => setFilesDragging(false), 25);\n };\n\n // If the files were dropped the state must be reset.\n const onDocumentDrop = (event: DragEvent) => {\n event.preventDefault();\n\n dragTimer = setTimeout(() => setFilesDragging(false), 25);\n };\n\n document.addEventListener('dragover', onDocumentDragOver, false);\n document.addEventListener('dragleave', onDocumentDragLeave, false);\n document.addEventListener('drop', onDocumentDrop, false);\n\n return () => {\n dragTimer && clearTimeout(dragTimer);\n document.removeEventListener('dragover', onDocumentDragOver);\n document.removeEventListener('dragleave', onDocumentDragLeave);\n document.removeEventListener('drop', onDocumentDrop);\n };\n }, []);\n\n return { areFilesDragging };\n}\n"]}