@cloudscape-design/components 3.0.696 → 3.0.698

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 (89) hide show
  1. package/app-layout/internal.d.ts.map +1 -1
  2. package/app-layout/internal.js +2 -2
  3. package/app-layout/internal.js.map +1 -1
  4. package/app-layout/utils/feature-flags.d.ts +2 -0
  5. package/app-layout/utils/feature-flags.d.ts.map +1 -0
  6. package/app-layout/utils/feature-flags.js +5 -0
  7. package/app-layout/utils/feature-flags.js.map +1 -0
  8. package/app-layout/visual-refresh-toolbar/index.js +1 -1
  9. package/app-layout/visual-refresh-toolbar/index.js.map +1 -1
  10. package/app-layout/visual-refresh-toolbar/multi-layout.d.ts.map +1 -1
  11. package/app-layout/visual-refresh-toolbar/multi-layout.js +2 -1
  12. package/app-layout/visual-refresh-toolbar/multi-layout.js.map +1 -1
  13. package/app-layout/visual-refresh-toolbar/toolbar/drawer-triggers.d.ts.map +1 -1
  14. package/app-layout/visual-refresh-toolbar/toolbar/drawer-triggers.js +1 -4
  15. package/app-layout/visual-refresh-toolbar/toolbar/drawer-triggers.js.map +1 -1
  16. package/app-layout/visual-refresh-toolbar/toolbar/index.d.ts.map +1 -1
  17. package/app-layout/visual-refresh-toolbar/toolbar/index.js +4 -1
  18. package/app-layout/visual-refresh-toolbar/toolbar/index.js.map +1 -1
  19. package/column-layout/flexible-column-layout/index.js +1 -1
  20. package/column-layout/flexible-column-layout/index.js.map +1 -1
  21. package/drawer/implementation.d.ts.map +1 -1
  22. package/drawer/implementation.js +2 -3
  23. package/drawer/implementation.js.map +1 -1
  24. package/internal/environment.js +1 -1
  25. package/internal/environment.json +1 -1
  26. package/internal/manifest.json +1 -1
  27. package/internal/plugins/helpers/use-global-breadcrumbs.d.ts.map +1 -1
  28. package/internal/plugins/helpers/use-global-breadcrumbs.js +2 -2
  29. package/internal/plugins/helpers/use-global-breadcrumbs.js.map +1 -1
  30. package/package.json +1 -1
  31. package/pie-chart/pie-chart.d.ts.map +1 -1
  32. package/pie-chart/pie-chart.js +9 -1
  33. package/pie-chart/pie-chart.js.map +1 -1
  34. package/pie-chart/segments.d.ts +2 -1
  35. package/pie-chart/segments.d.ts.map +1 -1
  36. package/pie-chart/segments.js +2 -2
  37. package/pie-chart/segments.js.map +1 -1
  38. package/s3-resource-selector/interfaces.d.ts +1 -0
  39. package/s3-resource-selector/interfaces.d.ts.map +1 -1
  40. package/s3-resource-selector/interfaces.js.map +1 -1
  41. package/s3-resource-selector/s3-modal/basic-table.d.ts +8 -9
  42. package/s3-resource-selector/s3-modal/basic-table.d.ts.map +1 -1
  43. package/s3-resource-selector/s3-modal/basic-table.js +34 -2
  44. package/s3-resource-selector/s3-modal/basic-table.js.map +1 -1
  45. package/s3-resource-selector/s3-modal/styles.css.js +3 -2
  46. package/s3-resource-selector/s3-modal/styles.scoped.css +102 -2
  47. package/s3-resource-selector/s3-modal/styles.selectors.js +3 -2
  48. package/side-navigation/implementation.d.ts.map +1 -1
  49. package/side-navigation/implementation.js +2 -3
  50. package/side-navigation/implementation.js.map +1 -1
  51. package/split-panel/bottom.d.ts.map +1 -1
  52. package/split-panel/bottom.js +3 -3
  53. package/split-panel/bottom.js.map +1 -1
  54. package/split-panel/implementation.d.ts.map +1 -1
  55. package/split-panel/implementation.js +2 -3
  56. package/split-panel/implementation.js.map +1 -1
  57. package/split-panel/side.d.ts.map +1 -1
  58. package/split-panel/side.js +3 -4
  59. package/split-panel/side.js.map +1 -1
  60. package/test-utils/dom/autosuggest/index.js +2 -3
  61. package/test-utils/dom/autosuggest/index.js.map +1 -1
  62. package/test-utils/dom/button-dropdown/index.js +2 -2
  63. package/test-utils/dom/button-dropdown/index.js.map +1 -1
  64. package/test-utils/dom/code-editor/index.js +2 -2
  65. package/test-utils/dom/code-editor/index.js.map +1 -1
  66. package/test-utils/dom/date-range-picker/index.js +2 -2
  67. package/test-utils/dom/date-range-picker/index.js.map +1 -1
  68. package/test-utils/dom/input/base-input.js +4 -3
  69. package/test-utils/dom/input/base-input.js.map +1 -1
  70. package/test-utils/dom/internal/dropdown-host.js +4 -5
  71. package/test-utils/dom/internal/dropdown-host.js.map +1 -1
  72. package/test-utils/dom/prompt-input/index.js +2 -1
  73. package/test-utils/dom/prompt-input/index.js.map +1 -1
  74. package/test-utils/dom/textarea/index.js +2 -1
  75. package/test-utils/dom/textarea/index.js.map +1 -1
  76. package/test-utils/selectors/autosuggest/index.js +2 -0
  77. package/test-utils/selectors/autosuggest/index.js.map +1 -1
  78. package/test-utils/selectors/button-dropdown/index.js +2 -0
  79. package/test-utils/selectors/button-dropdown/index.js.map +1 -1
  80. package/test-utils/selectors/code-editor/index.js +2 -0
  81. package/test-utils/selectors/code-editor/index.js.map +1 -1
  82. package/test-utils/selectors/date-range-picker/index.js +2 -0
  83. package/test-utils/selectors/date-range-picker/index.js.map +1 -1
  84. package/test-utils/selectors/input/base-input.js.map +1 -1
  85. package/test-utils/selectors/internal/dropdown-host.js +2 -0
  86. package/test-utils/selectors/internal/dropdown-host.js.map +1 -1
  87. package/test-utils/selectors/prompt-input/index.js.map +1 -1
  88. package/test-utils/selectors/textarea/index.js.map +1 -1
  89. package/test-utils/tsconfig.tsbuildinfo +1 -1
@@ -53,6 +53,7 @@ export default ({ fitHeight, height: explicitHeight, variant, size, width, i18nS
53
53
  const popoverContent = popoverData && React.createElement(SeriesDetails, { details: details, compactList: true, ref: popoverContentRef });
54
54
  const popoverDismissedRecently = useRef(false);
55
55
  const escapePressed = useRef(false);
56
+ const duringTouch = useRef(false);
56
57
  const highlightSegment = useCallback((internalDatum) => {
57
58
  const segment = internalDatum.datum;
58
59
  if (segment !== highlightedSegment) {
@@ -111,11 +112,18 @@ export default ({ fitHeight, height: explicitHeight, variant, size, width, i18nS
111
112
  escapePressed.current = false;
112
113
  return;
113
114
  }
115
+ if (duringTouch.current) {
116
+ duringTouch.current = false;
117
+ return;
118
+ }
114
119
  if (pinnedSegment !== null) {
115
120
  return;
116
121
  }
117
122
  highlightSegment(internalDatum);
118
123
  }, [pinnedSegment, highlightSegment]);
124
+ const onTouchStart = useCallback(() => {
125
+ duringTouch.current = true;
126
+ }, []);
119
127
  const onKeyDown = useCallback((event) => {
120
128
  const keyCode = event.keyCode;
121
129
  if (keyCode !== KeyCode.right &&
@@ -180,7 +188,7 @@ export default ({ fitHeight, height: explicitHeight, variant, size, width, i18nS
180
188
  return (React.createElement("div", { className: clsx(styles['chart-container'], fitHeight && styles['chart-container--fit-height']), ref: containerRef },
181
189
  React.createElement("div", { className: clsx(styles['chart-container-chart-plot'], fitHeight && styles['chart-container-chart-plot--fit-height']) },
182
190
  React.createElement(ChartPlot, { ref: plotRef, width: "100%", height: fitHeight ? '100%' : height, transform: `translate(${width / 2} ${height / 2})`, isPrecise: true, isClickable: !isPopoverOpen, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, ariaDescription: ariaDescription, ariaDescribedby: hasInnerContent ? innerMetricId : undefined, ariaRoleDescription: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.chartAriaRoleDescription, activeElementRef: focusedSegmentRef, activeElementKey: highlightedSegmentIndex === null || highlightedSegmentIndex === void 0 ? void 0 : highlightedSegmentIndex.toString(), onApplicationFocus: onApplicationFocus, onApplicationBlur: onApplicationBlur, onKeyDown: onKeyDown, onMouseOut: checkMouseLeave },
183
- React.createElement(Segments, { pieData: pieData, dimensions: dimensions, variant: variant, focusedSegmentRef: focusedSegmentRef, popoverTrackRef: popoverTrackRef, highlightedSegment: highlightedSegment, segmentAriaRoleDescription: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.segmentAriaRoleDescription, onMouseDown: onMouseDown, onMouseOver: onMouseOver }),
191
+ React.createElement(Segments, { pieData: pieData, dimensions: dimensions, variant: variant, focusedSegmentRef: focusedSegmentRef, popoverTrackRef: popoverTrackRef, highlightedSegment: highlightedSegment, segmentAriaRoleDescription: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.segmentAriaRoleDescription, onMouseDown: onMouseDown, onMouseOver: onMouseOver, onTouchStart: onTouchStart }),
184
192
  hasLabels && (React.createElement(Labels, { pieData: pieData, dimensions: dimensions, segmentDescription: segmentDescription, visibleDataSum: dataSum, hideTitles: hideTitles, hideDescriptions: hideDescriptions, highlightedSegment: highlightedSegment, containerRef: containerRef })))),
185
193
  hasInnerContent && (React.createElement("div", { className: styles['inner-content'], id: innerMetricId },
186
194
  innerMetricValue && (React.createElement(InternalBox, { variant: dimensions.size === 'small' ? 'h3' : 'h1', tagOverride: "div", color: "inherit", padding: "n" }, innerMetricValue)),
@@ -1 +1 @@
1
- {"version":3,"file":"pie-chart.js","sourceRoot":"","sources":["../../../src/pie-chart/pie-chart.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,SAA2B,MAAM,mCAAmC,CAAC;AAC5E,OAAO,YAAY,MAAM,sCAAsC,CAAC;AAChE,OAAO,kBAAkB,MAAM,6CAA6C,CAAC;AAC7E,OAAO,aAAa,MAAM,6CAA6C,CAAC;AACxE,OAAO,YAAY,MAAM,4CAA4C,CAAC;AACtE,OAAO,UAAU,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAA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,aAAa,IAAI,WAAW,IAAI,CAC/B,oBAAC,YAAY,IACX,GAAG,EAAE,UAAU,EACf,KAAK,EACH,WAAW,CAAC,MAAM,IAAI,CACpB,oBAAC,WAAW,IAAC,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAC,QAAQ;gBAChE,oBAAC,YAAY,IAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,UAAU,GAAI;gBAAC,GAAG;gBACzF,WAAW,CAAC,MAAM,CAAC,KAAK,CACb,CACf,EAEH,QAAQ,EAAE,WAAW,CAAC,QAAQ,EAC9B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,EAClC,aAAa,EAAE,aAAa,KAAK,IAAI,EACrC,gBAAgB,EAAE,WAAW,CAAC,6BAA6B,EAC3D,SAAS,EAAE,gBAAgB,EAC3B,SAAS,EAAE,CAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,GAAG,KAAI,IAAI,EACvC,IAAI,EAAE,iBAAiB,EACvB,YAAY,EAAE,eAAe,EAC7B,MAAM,EAAE,iBAAiB;YAExB,cAAc;YACd,0BAA0B,IAAI,oBAAC,kBAAkB,QAAE,0BAA0B,CAAsB,CACvF,CAChB;QACD,oBAAC,UAAU,IAAC,MAAM,EAAE,CAAC,iBAAiB,CAAC,GAAI,CACvC,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { PieArcDatum } from 'd3-shape';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\n\nimport InternalBox from '../box/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport ChartPlot, { ChartPlotRef } from '../internal/components/chart-plot';\nimport ChartPopover from '../internal/components/chart-popover';\nimport ChartPopoverFooter from '../internal/components/chart-popover-footer';\nimport SeriesDetails from '../internal/components/chart-series-details';\nimport SeriesMarker from '../internal/components/chart-series-marker';\nimport LiveRegion from '../internal/components/live-region';\nimport { useHeightMeasure } from '../internal/hooks/container-queries/use-height-measure';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { KeyCode } from '../internal/keycode';\nimport { SomeRequired } from '../internal/types';\nimport { nodeBelongs } from '../internal/utils/node-belongs';\nimport { PieChartProps, SeriesInfo } from './interfaces';\nimport Labels from './labels';\nimport Segments from './segments';\nimport { defaultDetails, getDimensionsBySize } from './utils';\n\nimport styles from './styles.css.js';\n\nexport interface InternalChartDatum<T> {\n index: number;\n color: string;\n datum: Readonly<T>;\n}\n\ninterface InternalPieChartProps<T extends PieChartProps.Datum>\n extends SomeRequired<\n Omit<PieChartProps<T>, 'onHighlightChange' | 'statusType'>,\n 'variant' | 'size' | 'i18nStrings' | 'hideTitles' | 'hideDescriptions'\n > {\n width: number;\n height: number;\n\n highlightedSegment: T | null;\n onHighlightChange: (segment: null | T) => void;\n\n legendSegment: T | null;\n\n pieData: PieArcDatum<InternalChartDatum<T>>[];\n dataSum: number;\n}\n\nexport interface PopoverData<T> {\n datum: T;\n trackRef: React.RefObject<SVGElement>;\n series: SeriesInfo;\n}\n\nexport default <T extends PieChartProps.Datum>({\n fitHeight,\n height: explicitHeight,\n variant,\n size,\n width,\n i18nStrings,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n innerMetricValue,\n innerMetricDescription,\n hideTitles,\n hideDescriptions,\n detailPopoverContent,\n detailPopoverSize,\n detailPopoverFooter,\n segmentDescription,\n highlightedSegment,\n onHighlightChange,\n legendSegment,\n pieData,\n dataSum,\n}: InternalPieChartProps<T>) => {\n const [pinnedSegment, setPinnedSegment] = useState<T | null>(null);\n const plotRef = useRef<ChartPlotRef>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const focusedSegmentRef = useRef<SVGGElement>(null);\n const popoverTrackRef = useRef<SVGCircleElement>(null);\n const popoverRef = useRef<HTMLElement | null>(null);\n\n const hasLabels = !(hideTitles && hideDescriptions);\n const isRefresh = useVisualRefresh();\n\n const height = useHeightMeasure(() => plotRef.current?.svg ?? null, !fitHeight) ?? explicitHeight;\n\n const dimensions = useMemo(\n () =>\n getDimensionsBySize({ size: fitHeight ? Math.min(height, width) : size, hasLabels, visualRefresh: isRefresh }),\n [fitHeight, height, width, size, hasLabels, isRefresh]\n );\n\n // Inner content is only available for donut charts and the inner description is not displayed for small charts\n const hasInnerContent =\n variant === 'donut' && (innerMetricValue || (innerMetricDescription && dimensions.size !== 'small'));\n\n const innerMetricId = useUniqueId('awsui-pie-chart__inner');\n\n const [isPopoverOpen, setPopoverOpen] = useState<boolean>(false);\n const [popoverData, setPopoverData] = useState<PopoverData<T>>();\n\n const highlightedSegmentIndex = useMemo(() => {\n for (let index = 0; index < pieData.length; index++) {\n if (pieData[index].data.datum === highlightedSegment) {\n return index;\n }\n }\n return null;\n }, [pieData, highlightedSegment]);\n\n const detailPopoverFooterContent = useMemo(\n () => (detailPopoverFooter && highlightedSegment ? detailPopoverFooter(highlightedSegment) : null),\n [detailPopoverFooter, highlightedSegment]\n );\n\n const i18n = useInternalI18n('pie-chart');\n const detailFunction = detailPopoverContent || defaultDetails(i18n, i18nStrings);\n const details = popoverData ? detailFunction(popoverData.datum, dataSum) : [];\n const popoverContentRef = useRef<HTMLDivElement | null>(null);\n const popoverContent = popoverData && <SeriesDetails details={details} compactList={true} ref={popoverContentRef} />;\n\n const popoverDismissedRecently = useRef(false);\n const escapePressed = useRef(false);\n\n const highlightSegment = useCallback(\n (internalDatum: InternalChartDatum<T>) => {\n const segment = internalDatum.datum;\n if (segment !== highlightedSegment) {\n onHighlightChange(segment);\n }\n\n if (popoverTrackRef.current) {\n setPopoverData({\n datum: internalDatum.datum,\n series: {\n color: internalDatum.color,\n index: internalDatum.index,\n label: internalDatum.datum.title,\n markerType: 'rectangle',\n },\n trackRef: popoverTrackRef,\n });\n setPopoverOpen(true);\n }\n },\n [highlightedSegment, setPopoverOpen, onHighlightChange]\n );\n\n const clearHighlightedSegment = useCallback(() => {\n setPopoverOpen(false);\n onHighlightChange(null);\n }, [onHighlightChange, setPopoverOpen]);\n\n const checkMouseLeave = (event: React.MouseEvent) => {\n if (pinnedSegment !== null) {\n return;\n }\n\n if (\n nodeContains(popoverRef.current, event.relatedTarget) ||\n nodeContains(focusedSegmentRef.current, event.relatedTarget)\n ) {\n return;\n }\n\n clearHighlightedSegment();\n };\n\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n clearHighlightedSegment();\n escapePressed.current = true;\n }\n };\n document.addEventListener('keydown', onKeyDown);\n return () => document.removeEventListener('keydown', onKeyDown);\n }, [clearHighlightedSegment]);\n\n const onMouseDown = useCallback(\n (internalDatum: InternalChartDatum<T>) => {\n if (pinnedSegment === internalDatum.datum) {\n setPinnedSegment(null);\n clearHighlightedSegment();\n } else {\n setPinnedSegment(internalDatum.datum);\n highlightSegment(internalDatum);\n }\n },\n [pinnedSegment, clearHighlightedSegment, setPinnedSegment, highlightSegment]\n );\n const onMouseOver = useCallback(\n (internalDatum: InternalChartDatum<T>) => {\n if (escapePressed.current) {\n escapePressed.current = false;\n return;\n }\n if (pinnedSegment !== null) {\n return;\n }\n highlightSegment(internalDatum);\n },\n [pinnedSegment, highlightSegment]\n );\n\n const onKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n const keyCode = event.keyCode;\n if (\n keyCode !== KeyCode.right &&\n keyCode !== KeyCode.left &&\n keyCode !== KeyCode.enter &&\n keyCode !== KeyCode.space\n ) {\n return;\n }\n\n event.preventDefault();\n\n let nextIndex = highlightedSegmentIndex || 0;\n const MAX = pieData.length - 1;\n if (keyCode === KeyCode.right) {\n nextIndex++;\n if (nextIndex > MAX) {\n nextIndex = 0;\n }\n } else if (keyCode === KeyCode.left) {\n nextIndex--;\n if (nextIndex < 0) {\n nextIndex = MAX;\n }\n }\n if (keyCode === KeyCode.enter || keyCode === KeyCode.space) {\n setPinnedSegment(pieData[nextIndex].data.datum);\n }\n highlightSegment(pieData[nextIndex].data);\n },\n [setPinnedSegment, highlightSegment, pieData, highlightedSegmentIndex]\n );\n const onApplicationFocus = useCallback(\n (_event: any, target: 'keyboard' | 'mouse') => {\n if (pinnedSegment !== null || popoverDismissedRecently.current || target === 'mouse') {\n return;\n }\n\n const segment = highlightedSegment || legendSegment || pieData[0].data.datum;\n const matched = pieData.filter(d => d.data.datum === segment);\n highlightSegment(matched[0].data);\n },\n [pinnedSegment, pieData, highlightSegment, highlightedSegment, legendSegment]\n );\n\n const onApplicationBlur = useCallback(\n (event: React.FocusEvent) => {\n const blurTarget = event.relatedTarget || event.target;\n if (blurTarget === null || !(blurTarget instanceof Element) || !nodeBelongs(containerRef.current, blurTarget)) {\n // We only need to close the popover and remove the pinned segment so that we keep track of the current\n // highlighted legendSeries. using clearHighlightedSegment() would set the legendSeries to null, in that case\n // using Keyboard Tab will always highlight the first legend item in the legend component.\n setPopoverOpen(false);\n setPinnedSegment(null);\n }\n },\n [setPinnedSegment]\n );\n const onPopoverDismiss = (outsideClick?: boolean) => {\n setPopoverOpen(false);\n setPinnedSegment(null);\n\n if (!outsideClick) {\n // The delay is needed to bypass focus events caused by click or keypress needed to unpin the popover.\n setTimeout(() => {\n popoverDismissedRecently.current = true;\n plotRef.current!.focusApplication();\n popoverDismissedRecently.current = false;\n }, 0);\n } else {\n onHighlightChange(null);\n }\n };\n\n return (\n <div\n className={clsx(styles['chart-container'], fitHeight && styles['chart-container--fit-height'])}\n ref={containerRef}\n >\n <div\n className={clsx(\n styles['chart-container-chart-plot'],\n fitHeight && styles['chart-container-chart-plot--fit-height']\n )}\n >\n <ChartPlot\n ref={plotRef}\n width=\"100%\"\n height={fitHeight ? '100%' : height}\n transform={`translate(${width / 2} ${height / 2})`}\n isPrecise={true}\n isClickable={!isPopoverOpen}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n ariaDescribedby={hasInnerContent ? innerMetricId : undefined}\n ariaRoleDescription={i18nStrings?.chartAriaRoleDescription}\n activeElementRef={focusedSegmentRef}\n activeElementKey={highlightedSegmentIndex?.toString()}\n onApplicationFocus={onApplicationFocus}\n onApplicationBlur={onApplicationBlur}\n onKeyDown={onKeyDown}\n onMouseOut={checkMouseLeave}\n >\n <Segments\n pieData={pieData}\n dimensions={dimensions}\n variant={variant}\n focusedSegmentRef={focusedSegmentRef}\n popoverTrackRef={popoverTrackRef}\n highlightedSegment={highlightedSegment}\n segmentAriaRoleDescription={i18nStrings?.segmentAriaRoleDescription}\n onMouseDown={onMouseDown}\n onMouseOver={onMouseOver}\n />\n {hasLabels && (\n <Labels\n pieData={pieData}\n dimensions={dimensions}\n segmentDescription={segmentDescription}\n visibleDataSum={dataSum}\n hideTitles={hideTitles}\n hideDescriptions={hideDescriptions}\n highlightedSegment={highlightedSegment}\n containerRef={containerRef}\n />\n )}\n </ChartPlot>\n </div>\n\n {hasInnerContent && (\n <div className={styles['inner-content']} id={innerMetricId}>\n {innerMetricValue && (\n <InternalBox\n variant={dimensions.size === 'small' ? 'h3' : 'h1'}\n tagOverride=\"div\"\n color=\"inherit\"\n padding=\"n\"\n >\n {innerMetricValue}\n </InternalBox>\n )}\n {innerMetricDescription && dimensions.size !== 'small' && (\n <InternalBox variant=\"h3\" color=\"text-body-secondary\" tagOverride=\"div\" padding=\"n\">\n {innerMetricDescription}\n </InternalBox>\n )}\n </div>\n )}\n {isPopoverOpen && popoverData && (\n <ChartPopover\n ref={popoverRef}\n title={\n popoverData.series && (\n <InternalBox className={styles['popover-header']} variant=\"strong\">\n <SeriesMarker color={popoverData.series.color} type={popoverData.series.markerType} />{' '}\n {popoverData.series.label}\n </InternalBox>\n )\n }\n trackRef={popoverData.trackRef}\n trackKey={popoverData.series.index}\n dismissButton={pinnedSegment !== null}\n dismissAriaLabel={i18nStrings.detailPopoverDismissAriaLabel}\n onDismiss={onPopoverDismiss}\n container={plotRef.current?.svg || null}\n size={detailPopoverSize}\n onMouseLeave={checkMouseLeave}\n onBlur={onApplicationBlur}\n >\n {popoverContent}\n {detailPopoverFooterContent && <ChartPopoverFooter>{detailPopoverFooterContent}</ChartPopoverFooter>}\n </ChartPopover>\n )}\n <LiveRegion source={[popoverContentRef]} />\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"pie-chart.js","sourceRoot":"","sources":["../../../src/pie-chart/pie-chart.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,SAA2B,MAAM,mCAAmC,CAAC;AAC5E,OAAO,YAAY,MAAM,sCAAsC,CAAC;AAChE,OAAO,kBAAkB,MAAM,6CAA6C,CAAC;AAC7E,OAAO,aAAa,MAAM,6CAA6C,CAAC;AACxE,OAAO,YAAY,MAAM,4CAA4C,CAAC;AACtE,OAAO,UAAU,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,QAAQ,MAAM,YAA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UAAU,CAAC,IAAI,KAAK,OAAO,IAAI,CACxD,oBAAC,WAAW,IAAC,OAAO,EAAC,IAAI,EAAC,KAAK,EAAC,qBAAqB,EAAC,WAAW,EAAC,KAAK,EAAC,OAAO,EAAC,GAAG,IAChF,sBAAsB,CACX,CACf,CACG,CACP;QACA,aAAa,IAAI,WAAW,IAAI,CAC/B,oBAAC,YAAY,IACX,GAAG,EAAE,UAAU,EACf,KAAK,EACH,WAAW,CAAC,MAAM,IAAI,CACpB,oBAAC,WAAW,IAAC,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAC,QAAQ;gBAChE,oBAAC,YAAY,IAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,UAAU,GAAI;gBAAC,GAAG;gBACzF,WAAW,CAAC,MAAM,CAAC,KAAK,CACb,CACf,EAEH,QAAQ,EAAE,WAAW,CAAC,QAAQ,EAC9B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,EAClC,aAAa,EAAE,aAAa,KAAK,IAAI,EACrC,gBAAgB,EAAE,WAAW,CAAC,6BAA6B,EAC3D,SAAS,EAAE,gBAAgB,EAC3B,SAAS,EAAE,CAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,GAAG,KAAI,IAAI,EACvC,IAAI,EAAE,iBAAiB,EACvB,YAAY,EAAE,eAAe,EAC7B,MAAM,EAAE,iBAAiB;YAExB,cAAc;YACd,0BAA0B,IAAI,oBAAC,kBAAkB,QAAE,0BAA0B,CAAsB,CACvF,CAChB;QACD,oBAAC,UAAU,IAAC,MAAM,EAAE,CAAC,iBAAiB,CAAC,GAAI,CACvC,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { PieArcDatum } from 'd3-shape';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\n\nimport InternalBox from '../box/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport ChartPlot, { ChartPlotRef } from '../internal/components/chart-plot';\nimport ChartPopover from '../internal/components/chart-popover';\nimport ChartPopoverFooter from '../internal/components/chart-popover-footer';\nimport SeriesDetails from '../internal/components/chart-series-details';\nimport SeriesMarker from '../internal/components/chart-series-marker';\nimport LiveRegion from '../internal/components/live-region';\nimport { useHeightMeasure } from '../internal/hooks/container-queries/use-height-measure';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { KeyCode } from '../internal/keycode';\nimport { SomeRequired } from '../internal/types';\nimport { nodeBelongs } from '../internal/utils/node-belongs';\nimport { PieChartProps, SeriesInfo } from './interfaces';\nimport Labels from './labels';\nimport Segments from './segments';\nimport { defaultDetails, getDimensionsBySize } from './utils';\n\nimport styles from './styles.css.js';\n\nexport interface InternalChartDatum<T> {\n index: number;\n color: string;\n datum: Readonly<T>;\n}\n\ninterface InternalPieChartProps<T extends PieChartProps.Datum>\n extends SomeRequired<\n Omit<PieChartProps<T>, 'onHighlightChange' | 'statusType'>,\n 'variant' | 'size' | 'i18nStrings' | 'hideTitles' | 'hideDescriptions'\n > {\n width: number;\n height: number;\n\n highlightedSegment: T | null;\n onHighlightChange: (segment: null | T) => void;\n\n legendSegment: T | null;\n\n pieData: PieArcDatum<InternalChartDatum<T>>[];\n dataSum: number;\n}\n\nexport interface PopoverData<T> {\n datum: T;\n trackRef: React.RefObject<SVGElement>;\n series: SeriesInfo;\n}\n\nexport default <T extends PieChartProps.Datum>({\n fitHeight,\n height: explicitHeight,\n variant,\n size,\n width,\n i18nStrings,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n innerMetricValue,\n innerMetricDescription,\n hideTitles,\n hideDescriptions,\n detailPopoverContent,\n detailPopoverSize,\n detailPopoverFooter,\n segmentDescription,\n highlightedSegment,\n onHighlightChange,\n legendSegment,\n pieData,\n dataSum,\n}: InternalPieChartProps<T>) => {\n const [pinnedSegment, setPinnedSegment] = useState<T | null>(null);\n const plotRef = useRef<ChartPlotRef>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const focusedSegmentRef = useRef<SVGGElement>(null);\n const popoverTrackRef = useRef<SVGCircleElement>(null);\n const popoverRef = useRef<HTMLElement | null>(null);\n\n const hasLabels = !(hideTitles && hideDescriptions);\n const isRefresh = useVisualRefresh();\n\n const height = useHeightMeasure(() => plotRef.current?.svg ?? null, !fitHeight) ?? explicitHeight;\n\n const dimensions = useMemo(\n () =>\n getDimensionsBySize({ size: fitHeight ? Math.min(height, width) : size, hasLabels, visualRefresh: isRefresh }),\n [fitHeight, height, width, size, hasLabels, isRefresh]\n );\n\n // Inner content is only available for donut charts and the inner description is not displayed for small charts\n const hasInnerContent =\n variant === 'donut' && (innerMetricValue || (innerMetricDescription && dimensions.size !== 'small'));\n\n const innerMetricId = useUniqueId('awsui-pie-chart__inner');\n\n const [isPopoverOpen, setPopoverOpen] = useState<boolean>(false);\n const [popoverData, setPopoverData] = useState<PopoverData<T>>();\n\n const highlightedSegmentIndex = useMemo(() => {\n for (let index = 0; index < pieData.length; index++) {\n if (pieData[index].data.datum === highlightedSegment) {\n return index;\n }\n }\n return null;\n }, [pieData, highlightedSegment]);\n\n const detailPopoverFooterContent = useMemo(\n () => (detailPopoverFooter && highlightedSegment ? detailPopoverFooter(highlightedSegment) : null),\n [detailPopoverFooter, highlightedSegment]\n );\n\n const i18n = useInternalI18n('pie-chart');\n const detailFunction = detailPopoverContent || defaultDetails(i18n, i18nStrings);\n const details = popoverData ? detailFunction(popoverData.datum, dataSum) : [];\n const popoverContentRef = useRef<HTMLDivElement | null>(null);\n const popoverContent = popoverData && <SeriesDetails details={details} compactList={true} ref={popoverContentRef} />;\n\n const popoverDismissedRecently = useRef(false);\n const escapePressed = useRef(false);\n const duringTouch = useRef(false);\n\n const highlightSegment = useCallback(\n (internalDatum: InternalChartDatum<T>) => {\n const segment = internalDatum.datum;\n if (segment !== highlightedSegment) {\n onHighlightChange(segment);\n }\n\n if (popoverTrackRef.current) {\n setPopoverData({\n datum: internalDatum.datum,\n series: {\n color: internalDatum.color,\n index: internalDatum.index,\n label: internalDatum.datum.title,\n markerType: 'rectangle',\n },\n trackRef: popoverTrackRef,\n });\n setPopoverOpen(true);\n }\n },\n [highlightedSegment, setPopoverOpen, onHighlightChange]\n );\n\n const clearHighlightedSegment = useCallback(() => {\n setPopoverOpen(false);\n onHighlightChange(null);\n }, [onHighlightChange, setPopoverOpen]);\n\n const checkMouseLeave = (event: React.MouseEvent) => {\n if (pinnedSegment !== null) {\n return;\n }\n\n if (\n nodeContains(popoverRef.current, event.relatedTarget) ||\n nodeContains(focusedSegmentRef.current, event.relatedTarget)\n ) {\n return;\n }\n\n clearHighlightedSegment();\n };\n\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n clearHighlightedSegment();\n escapePressed.current = true;\n }\n };\n document.addEventListener('keydown', onKeyDown);\n return () => document.removeEventListener('keydown', onKeyDown);\n }, [clearHighlightedSegment]);\n\n const onMouseDown = useCallback(\n (internalDatum: InternalChartDatum<T>) => {\n if (pinnedSegment === internalDatum.datum) {\n setPinnedSegment(null);\n clearHighlightedSegment();\n } else {\n setPinnedSegment(internalDatum.datum);\n highlightSegment(internalDatum);\n }\n },\n [pinnedSegment, clearHighlightedSegment, setPinnedSegment, highlightSegment]\n );\n const onMouseOver = useCallback(\n (internalDatum: InternalChartDatum<T>) => {\n if (escapePressed.current) {\n escapePressed.current = false;\n return;\n }\n if (duringTouch.current) {\n duringTouch.current = false;\n return;\n }\n if (pinnedSegment !== null) {\n return;\n }\n highlightSegment(internalDatum);\n },\n [pinnedSegment, highlightSegment]\n );\n const onTouchStart = useCallback(() => {\n duringTouch.current = true;\n }, []);\n\n const onKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n const keyCode = event.keyCode;\n if (\n keyCode !== KeyCode.right &&\n keyCode !== KeyCode.left &&\n keyCode !== KeyCode.enter &&\n keyCode !== KeyCode.space\n ) {\n return;\n }\n\n event.preventDefault();\n\n let nextIndex = highlightedSegmentIndex || 0;\n const MAX = pieData.length - 1;\n if (keyCode === KeyCode.right) {\n nextIndex++;\n if (nextIndex > MAX) {\n nextIndex = 0;\n }\n } else if (keyCode === KeyCode.left) {\n nextIndex--;\n if (nextIndex < 0) {\n nextIndex = MAX;\n }\n }\n if (keyCode === KeyCode.enter || keyCode === KeyCode.space) {\n setPinnedSegment(pieData[nextIndex].data.datum);\n }\n highlightSegment(pieData[nextIndex].data);\n },\n [setPinnedSegment, highlightSegment, pieData, highlightedSegmentIndex]\n );\n const onApplicationFocus = useCallback(\n (_event: any, target: 'keyboard' | 'mouse') => {\n if (pinnedSegment !== null || popoverDismissedRecently.current || target === 'mouse') {\n return;\n }\n\n const segment = highlightedSegment || legendSegment || pieData[0].data.datum;\n const matched = pieData.filter(d => d.data.datum === segment);\n highlightSegment(matched[0].data);\n },\n [pinnedSegment, pieData, highlightSegment, highlightedSegment, legendSegment]\n );\n\n const onApplicationBlur = useCallback(\n (event: React.FocusEvent) => {\n const blurTarget = event.relatedTarget || event.target;\n if (blurTarget === null || !(blurTarget instanceof Element) || !nodeBelongs(containerRef.current, blurTarget)) {\n // We only need to close the popover and remove the pinned segment so that we keep track of the current\n // highlighted legendSeries. using clearHighlightedSegment() would set the legendSeries to null, in that case\n // using Keyboard Tab will always highlight the first legend item in the legend component.\n setPopoverOpen(false);\n setPinnedSegment(null);\n }\n },\n [setPinnedSegment]\n );\n const onPopoverDismiss = (outsideClick?: boolean) => {\n setPopoverOpen(false);\n setPinnedSegment(null);\n\n if (!outsideClick) {\n // The delay is needed to bypass focus events caused by click or keypress needed to unpin the popover.\n setTimeout(() => {\n popoverDismissedRecently.current = true;\n plotRef.current!.focusApplication();\n popoverDismissedRecently.current = false;\n }, 0);\n } else {\n onHighlightChange(null);\n }\n };\n\n return (\n <div\n className={clsx(styles['chart-container'], fitHeight && styles['chart-container--fit-height'])}\n ref={containerRef}\n >\n <div\n className={clsx(\n styles['chart-container-chart-plot'],\n fitHeight && styles['chart-container-chart-plot--fit-height']\n )}\n >\n <ChartPlot\n ref={plotRef}\n width=\"100%\"\n height={fitHeight ? '100%' : height}\n transform={`translate(${width / 2} ${height / 2})`}\n isPrecise={true}\n isClickable={!isPopoverOpen}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n ariaDescribedby={hasInnerContent ? innerMetricId : undefined}\n ariaRoleDescription={i18nStrings?.chartAriaRoleDescription}\n activeElementRef={focusedSegmentRef}\n activeElementKey={highlightedSegmentIndex?.toString()}\n onApplicationFocus={onApplicationFocus}\n onApplicationBlur={onApplicationBlur}\n onKeyDown={onKeyDown}\n onMouseOut={checkMouseLeave}\n >\n <Segments\n pieData={pieData}\n dimensions={dimensions}\n variant={variant}\n focusedSegmentRef={focusedSegmentRef}\n popoverTrackRef={popoverTrackRef}\n highlightedSegment={highlightedSegment}\n segmentAriaRoleDescription={i18nStrings?.segmentAriaRoleDescription}\n onMouseDown={onMouseDown}\n onMouseOver={onMouseOver}\n onTouchStart={onTouchStart}\n />\n {hasLabels && (\n <Labels\n pieData={pieData}\n dimensions={dimensions}\n segmentDescription={segmentDescription}\n visibleDataSum={dataSum}\n hideTitles={hideTitles}\n hideDescriptions={hideDescriptions}\n highlightedSegment={highlightedSegment}\n containerRef={containerRef}\n />\n )}\n </ChartPlot>\n </div>\n\n {hasInnerContent && (\n <div className={styles['inner-content']} id={innerMetricId}>\n {innerMetricValue && (\n <InternalBox\n variant={dimensions.size === 'small' ? 'h3' : 'h1'}\n tagOverride=\"div\"\n color=\"inherit\"\n padding=\"n\"\n >\n {innerMetricValue}\n </InternalBox>\n )}\n {innerMetricDescription && dimensions.size !== 'small' && (\n <InternalBox variant=\"h3\" color=\"text-body-secondary\" tagOverride=\"div\" padding=\"n\">\n {innerMetricDescription}\n </InternalBox>\n )}\n </div>\n )}\n {isPopoverOpen && popoverData && (\n <ChartPopover\n ref={popoverRef}\n title={\n popoverData.series && (\n <InternalBox className={styles['popover-header']} variant=\"strong\">\n <SeriesMarker color={popoverData.series.color} type={popoverData.series.markerType} />{' '}\n {popoverData.series.label}\n </InternalBox>\n )\n }\n trackRef={popoverData.trackRef}\n trackKey={popoverData.series.index}\n dismissButton={pinnedSegment !== null}\n dismissAriaLabel={i18nStrings.detailPopoverDismissAriaLabel}\n onDismiss={onPopoverDismiss}\n container={plotRef.current?.svg || null}\n size={detailPopoverSize}\n onMouseLeave={checkMouseLeave}\n onBlur={onApplicationBlur}\n >\n {popoverContent}\n {detailPopoverFooterContent && <ChartPopoverFooter>{detailPopoverFooterContent}</ChartPopoverFooter>}\n </ChartPopover>\n )}\n <LiveRegion source={[popoverContentRef]} />\n </div>\n );\n};\n"]}
@@ -13,7 +13,8 @@ interface SegmentsProps<T> {
13
13
  segmentAriaRoleDescription?: string;
14
14
  onMouseDown: (datum: InternalChartDatum<T>) => void;
15
15
  onMouseOver: (datum: InternalChartDatum<T>) => void;
16
+ onTouchStart: () => void;
16
17
  }
17
- export default function Segments<T extends PieChartProps.Datum>({ pieData, highlightedSegment, dimensions, variant, focusedSegmentRef, popoverTrackRef, segmentAriaRoleDescription, onMouseDown, onMouseOver, }: SegmentsProps<T>): JSX.Element;
18
+ export default function Segments<T extends PieChartProps.Datum>({ pieData, highlightedSegment, dimensions, variant, focusedSegmentRef, popoverTrackRef, segmentAriaRoleDescription, onMouseDown, onMouseOver, onTouchStart, }: SegmentsProps<T>): JSX.Element;
18
19
  export {};
19
20
  //# sourceMappingURL=segments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"segments.d.ts","sourceRoot":"","sources":["../../../src/pie-chart/segments.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAO,WAAW,EAAE,MAA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CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpC,UAAU,aAAa,CAAC,CAAC;IACvB,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,kBAAkB,EAAE,CAAC,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,SAAS,CAAC;IACtB,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAClC,iBAAiB,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAChD,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACnD,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,WAAW,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACpD,WAAW,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACpD,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,CAAC,SAAS,aAAa,CAAC,KAAK,EAAE,EAC9D,OAAO,EACP,kBAAkB,EAClB,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,0BAA0B,EAC1B,WAAW,EACX,WAAW,EACX,YAAY,GACb,EAAE,aAAa,CAAC,CAAC,CAAC,eAwElB"}
@@ -5,7 +5,7 @@ import clsx from 'clsx';
5
5
  import { arc } from 'd3-shape';
6
6
  import { useInternalI18n } from '../i18n/context';
7
7
  import styles from './styles.css.js';
8
- export default function Segments({ pieData, highlightedSegment, dimensions, variant, focusedSegmentRef, popoverTrackRef, segmentAriaRoleDescription, onMouseDown, onMouseOver, }) {
8
+ export default function Segments({ pieData, highlightedSegment, dimensions, variant, focusedSegmentRef, popoverTrackRef, segmentAriaRoleDescription, onMouseDown, onMouseOver, onTouchStart, }) {
9
9
  const i18n = useInternalI18n('pie-chart');
10
10
  const { arcFactory, highlightedArcFactory } = useMemo(() => {
11
11
  const radius = dimensions.outerRadius;
@@ -38,7 +38,7 @@ export default function Segments({ pieData, highlightedSegment, dimensions, vari
38
38
  const isDimmed = highlightedSegment !== null && !isHighlighted;
39
39
  const arcPath = arcFactory(datum) || undefined;
40
40
  const highlightedPath = highlightedArcFactory(datum) || undefined;
41
- return (React.createElement("g", { key: datum.data.index, onMouseDown: e => {
41
+ return (React.createElement("g", { key: datum.data.index, onTouchStart: () => onTouchStart(), onMouseDown: e => {
42
42
  onMouseDown(datum.data);
43
43
  e.preventDefault();
44
44
  }, onMouseOver: () => onMouseOver(datum.data), className: clsx(styles.segment, {
@@ -1 +1 @@
1
- {"version":3,"file":"segments.js","sourceRoot":"","sources":["../../../src/pie-chart/segments.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,GAAG,EAAe,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKlD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAcrC,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAgC,EAC9D,OAAO,EACP,kBAAkB,EAClB,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,0BAA0B,EAC1B,WAAW,EACX,WAAW,GACM;IACjB,MAAM,IAAI,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAE1C,MAAM,EAAE,UAAU,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;QACzD,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC;QACtC,MAAM,WAAW,GAAG,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,WA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iliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useMemo } from 'react';\nimport clsx from 'clsx';\nimport { arc, PieArcDatum } from 'd3-shape';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { PieChartProps } from './interfaces';\nimport { InternalChartDatum } from './pie-chart';\nimport { Dimension } from './utils';\n\nimport styles from './styles.css.js';\n\ninterface SegmentsProps<T> {\n pieData: Array<PieArcDatum<InternalChartDatum<T>>>;\n highlightedSegment: T | null;\n dimensions: Dimension;\n variant: PieChartProps['variant'];\n focusedSegmentRef: React.RefObject<SVGGElement>;\n popoverTrackRef: React.RefObject<SVGCircleElement>;\n segmentAriaRoleDescription?: string;\n onMouseDown: (datum: InternalChartDatum<T>) => void;\n onMouseOver: (datum: InternalChartDatum<T>) => void;\n}\n\nexport default function Segments<T extends PieChartProps.Datum>({\n pieData,\n highlightedSegment,\n dimensions,\n variant,\n focusedSegmentRef,\n popoverTrackRef,\n segmentAriaRoleDescription,\n onMouseDown,\n onMouseOver,\n}: SegmentsProps<T>) {\n const i18n = useInternalI18n('pie-chart');\n\n const { arcFactory, highlightedArcFactory } = useMemo(() => {\n const radius = dimensions.outerRadius;\n const innerRadius = variant === 'pie' ? 0 : dimensions.innerRadius;\n const cornerRadius = dimensions.cornerRadius || 0;\n\n const arcFactory = arc<PieArcDatum<InternalChartDatum<any>>>()\n .innerRadius(innerRadius)\n .outerRadius(radius)\n .cornerRadius(cornerRadius);\n\n const highlightedArcFactory = arc<PieArcDatum<InternalChartDatum<any>>>()\n .innerRadius(radius + 4)\n .outerRadius(radius + 6);\n\n return {\n arcFactory,\n highlightedArcFactory,\n };\n }, [dimensions, variant]);\n\n const centroid = useMemo(() => {\n for (const datum of pieData) {\n if (datum.data.datum === highlightedSegment) {\n const [centroidLeft, centroidTop] = arcFactory.centroid(datum);\n return { cx: centroidLeft, cy: centroidTop };\n }\n }\n return null;\n }, [highlightedSegment, pieData, arcFactory]);\n\n return (\n <g>\n {pieData.map(datum => {\n const isHighlighted = highlightedSegment === datum.data.datum;\n const isDimmed = highlightedSegment !== null && !isHighlighted;\n const arcPath = arcFactory(datum) || undefined;\n const highlightedPath = highlightedArcFactory(datum) || undefined;\n return (\n <g\n key={datum.data.index}\n onMouseDown={e => {\n onMouseDown(datum.data);\n e.preventDefault();\n }}\n onMouseOver={() => onMouseOver(datum.data)}\n className={clsx(styles.segment, {\n [styles['segment--highlighted']]: isHighlighted,\n [styles['segment--dimmed']]: isDimmed,\n })}\n ref={isHighlighted ? focusedSegmentRef : undefined}\n aria-label={`${datum.data.datum.title} (${datum.data.datum.value})`}\n role=\"button\"\n aria-roledescription={i18n('i18nStrings.segmentAriaRoleDescription', segmentAriaRoleDescription)}\n >\n <path d={arcPath} fill={datum.data.color} className={styles.segment__path} aria-hidden=\"true\" />\n <path\n d={highlightedPath}\n fill={datum.data.color}\n className={clsx(styles.segment__path, styles.segment__highlight)}\n aria-hidden=\"true\"\n />\n </g>\n );\n })}\n\n <circle {...centroid} ref={popoverTrackRef} r=\"1\" opacity=\"0\" aria-hidden=\"true\" />\n </g>\n );\n}\n"]}
1
+ {"version":3,"file":"segments.js","sourceRoot":"","sources":["../../../src/pie-chart/segments.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,GAAG,EAAe,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKlD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAerC,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAgC,EAC9D,OAAO,EACP,kBAAkB,EAClB,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,0BAA0B,EAC1B,WAAW,EACX,WAAW,EACX,YAAY,GACK;IACjB,MAAM,IAAI,GAAG,eAAe,CAAC,W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AAI,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,kBAAkB,CAAC,iBACpD,MAAM,GAClB,CACA,CACL,CAAC;QACJ,CAAC,CAAC;QAEF,gDAAY,QAAQ,IAAE,GAAG,EAAE,eAAe,EAAE,CAAC,EAAC,GAAG,EAAC,OAAO,EAAC,GAAG,iBAAa,MAAM,IAAG,CACjF,CACL,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useMemo } from 'react';\nimport clsx from 'clsx';\nimport { arc, PieArcDatum } from 'd3-shape';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { PieChartProps } from './interfaces';\nimport { InternalChartDatum } from './pie-chart';\nimport { Dimension } from './utils';\n\nimport styles from './styles.css.js';\n\ninterface SegmentsProps<T> {\n pieData: Array<PieArcDatum<InternalChartDatum<T>>>;\n highlightedSegment: T | null;\n dimensions: Dimension;\n variant: PieChartProps['variant'];\n focusedSegmentRef: React.RefObject<SVGGElement>;\n popoverTrackRef: React.RefObject<SVGCircleElement>;\n segmentAriaRoleDescription?: string;\n onMouseDown: (datum: InternalChartDatum<T>) => void;\n onMouseOver: (datum: InternalChartDatum<T>) => void;\n onTouchStart: () => void;\n}\n\nexport default function Segments<T extends PieChartProps.Datum>({\n pieData,\n highlightedSegment,\n dimensions,\n variant,\n focusedSegmentRef,\n popoverTrackRef,\n segmentAriaRoleDescription,\n onMouseDown,\n onMouseOver,\n onTouchStart,\n}: SegmentsProps<T>) {\n const i18n = useInternalI18n('pie-chart');\n\n const { arcFactory, highlightedArcFactory } = useMemo(() => {\n const radius = dimensions.outerRadius;\n const innerRadius = variant === 'pie' ? 0 : dimensions.innerRadius;\n const cornerRadius = dimensions.cornerRadius || 0;\n\n const arcFactory = arc<PieArcDatum<InternalChartDatum<any>>>()\n .innerRadius(innerRadius)\n .outerRadius(radius)\n .cornerRadius(cornerRadius);\n\n const highlightedArcFactory = arc<PieArcDatum<InternalChartDatum<any>>>()\n .innerRadius(radius + 4)\n .outerRadius(radius + 6);\n\n return {\n arcFactory,\n highlightedArcFactory,\n };\n }, [dimensions, variant]);\n\n const centroid = useMemo(() => {\n for (const datum of pieData) {\n if (datum.data.datum === highlightedSegment) {\n const [centroidLeft, centroidTop] = arcFactory.centroid(datum);\n return { cx: centroidLeft, cy: centroidTop };\n }\n }\n return null;\n }, [highlightedSegment, pieData, arcFactory]);\n\n return (\n <g>\n {pieData.map(datum => {\n const isHighlighted = highlightedSegment === datum.data.datum;\n const isDimmed = highlightedSegment !== null && !isHighlighted;\n const arcPath = arcFactory(datum) || undefined;\n const highlightedPath = highlightedArcFactory(datum) || undefined;\n return (\n <g\n key={datum.data.index}\n onTouchStart={() => onTouchStart()}\n onMouseDown={e => {\n onMouseDown(datum.data);\n e.preventDefault();\n }}\n onMouseOver={() => onMouseOver(datum.data)}\n className={clsx(styles.segment, {\n [styles['segment--highlighted']]: isHighlighted,\n [styles['segment--dimmed']]: isDimmed,\n })}\n ref={isHighlighted ? focusedSegmentRef : undefined}\n aria-label={`${datum.data.datum.title} (${datum.data.datum.value})`}\n role=\"button\"\n aria-roledescription={i18n('i18nStrings.segmentAriaRoleDescription', segmentAriaRoleDescription)}\n >\n <path d={arcPath} fill={datum.data.color} className={styles.segment__path} aria-hidden=\"true\" />\n <path\n d={highlightedPath}\n fill={datum.data.color}\n className={clsx(styles.segment__path, styles.segment__highlight)}\n aria-hidden=\"true\"\n />\n </g>\n );\n })}\n\n <circle {...centroid} ref={popoverTrackRef} r=\"1\" opacity=\"0\" aria-hidden=\"true\" />\n </g>\n );\n}\n"]}
@@ -183,6 +183,7 @@ export declare namespace S3ResourceSelectorProps {
183
183
  modalCancelButton?: string;
184
184
  modalSubmitButton?: string;
185
185
  modalBreadcrumbRootItem?: string;
186
+ modalLastUpdatedText?: string;
186
187
  selectionBuckets?: string;
187
188
  selectionObjects?: string;
188
189
  selectionVersions?: string;
@@ -1 +1 @@
1
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aces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { BaseModalProps } from '../modal/interfaces';\nimport { PaginationProps } from '../pagination/interfaces';\nimport { TableProps } from '../table/interfaces';\n\nexport interface S3ResourceSelectorProps extends BaseComponentProps, BaseModalProps {\n /**\n * Specifies additional information about component status.\n */\n alert?: React.ReactNode;\n\n /**\n * Adds `aria-labelledby` to the component. If you're using this component within a form field,\n * don't set this property because the form field component automatically sets it.\n *\n * Use this property if the component isn't surrounded by a form field, or you want to override the value\n * automatically set by the form field (for example, if you have two components within a single form field).\n *\n * To use it correctly, define an ID for the element you want to use as label and set the property to that ID.\n */\n ariaLabelledby?: string;\n\n /**\n * Adds `aria-describedby` to the component. If you're using this component within a form field,\n * don't set this property because the form field component automatically sets it.\n *\n * Use this property if the component isn't surrounded by a form field, or you want to override the value\n * automatically set by the form field (for example, if you have two components within a single form field).\n *\n * To use it correctly, define an ID for each element that you want to use as a description\n * and set the property to a string of each ID separated by spaces (for example, `\"id1 id2 id3\"`).\n */\n ariaDescribedby?: string;\n\n /**\n * Adds `aria-label` to the component.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-labelledby` to the S3 URI input. If you're using this component within a form field,\n * you do not need to set this property, as the form field component will set it automatically.\n *\n * Use this property if the component isn't surrounded by a form field, or you want to override the value\n * automatically set by the form field (for example, if you have two components within a single form field).\n *\n * To use it correctly, define an ID for the element you want to use as label and set the property to that ID.\n */\n inputAriaDescribedby?: string;\n\n /**\n * Adds a placeholder to the S3 URI input.\n */\n inputPlaceholder?: string;\n\n /**\n * An array of the item types that are selectable in the table view. The array may contain the following items:\n * 'buckets', 'objects', or 'versions'. Example: ['buckets', 'objects']. By default, no items are selectable.\n * This property determines whether the component operates in Read mode or Write mode:\n * * Read mode - When 'objects' and 'versions' values are provided (folder selection should be disabled by\n * customizing `objectsIsItemDisabled` function).\n * * Write mode - When 'buckets' and 'objects' values are provided (file selection should be disabled by\n * customizing `objectsIsItemDisabled` function).\n */\n selectableItemsTypes?: ReadonlyArray<S3ResourceSelectorProps.SelectableItems>;\n\n /**\n * Href of the selected object that is applied to the View button.\n */\n viewHref?: string;\n\n /**\n * Whether the S3 URI input field is in invalid state.\n */\n invalid?: boolean;\n\n /**\n * Optionally overrides the set of visible columns in the Buckets view. Available columns: 'Name', 'CreationDate',\n * and 'Region'.\n */\n bucketsVisibleColumns?: ReadonlyArray<string>;\n\n /**\n * Optionally overrides the set of visible columns in the Objects view. Available columns: 'Key', 'LastModified',\n * and 'Size'.\n */\n objectsVisibleColumns?: ReadonlyArray<string>;\n\n /**\n * Optionally overrides the set of visible columns in the Versions view. Available columns: 'ID', 'CreationDate',\n * and 'Size'.\n */\n versionsVisibleColumns?: ReadonlyArray<string>;\n\n /**\n * Optionally overrides whether a bucket should be disabled for selection in the Buckets view or not.\n * It has higher priority than `selectableItemsTypes`. Example: if `selectableItemsTypes` has `['buckets']` value and\n * `bucketsIsItemDisabled` returns false for a bucket, then the bucket is disabled for selection.\n */\n bucketsIsItemDisabled?: (item: S3ResourceSelectorProps.Bucket) => boolean;\n\n /**\n * Optionally overrides whether an object should be disabled for selection in the Objects view or not. Similar to\n * `bucketsIsItemDisabled` this property takes precedence over the `selectableItemsTypes` property.\n */\n objectsIsItemDisabled?: (item: S3ResourceSelectorProps.Object) => boolean;\n\n /**\n * Optionally overrides whether a version should be disabled for selection in the Versions view or not. Similar to\n * `bucketsIsItemDisabled` this property takes precedence over the `selectableItemsTypes` property.\n */\n versionsIsItemDisabled?: (item: S3ResourceSelectorProps.Version) => boolean;\n\n /**\n * The current selected resource. Resource has the following properties:\n * - `uri` (string) - URI of the resource.\n * - `versionId` (string) - (Optional) Version ID of the selected resource.\n */\n resource: S3ResourceSelectorProps.Resource;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * @i18n\n */\n i18nStrings?: S3ResourceSelectorProps.I18nStrings;\n\n /**\n * Specifies a function that returns all available buckets. The return type of the function should be a promise\n * that resolves to a list of objects with the following properties:\n * - `Name` (string) - Name of the bucket.\n * - `CreationDate` (string) - (Optional) Creation date of the bucket.\n * - `Region` (string) - (Optional) Region of the bucket.\n */\n fetchBuckets: () => Promise<ReadonlyArray<S3ResourceSelectorProps.Bucket>>;\n\n /**\n * Specifies a function that returns available objects and object prefixes for the given `bucketName` and `pathPrefix`.\n * The return type of the function should be a promise that resolves to a list of objects with the following properties:\n * - `Key` (string) - Name of the object or object prefix.\n * - `LastModified` (string) - (Optional) Date when this object was last modified.\n * - `Size` (number) - (Optional) Size of the object.\n * - `IsFolder` (boolean) - (Optional) Determines whether the entry is an object prefix (folder).\n */\n fetchObjects: (bucketName: string, pathPrefix: string) => Promise<ReadonlyArray<S3ResourceSelectorProps.Object>>;\n\n /**\n * Specifies a function that returns available versions for the given `bucketName` and `pathPrefix`.\n * The return type of the function should be a promise that resolves to a list of versions with the following properties:\n * - `VersionId` (string) - Version ID of an object.\n * - `LastModified` (string) - (Optional) Date when this object was last modified.\n * - `Size` (number) - (Optional) Size of the object version.\n */\n fetchVersions: (bucketName: string, pathPrefix: string) => Promise<ReadonlyArray<S3ResourceSelectorProps.Version>>;\n\n /**\n * Fired when the resource selection is changed. The event detail object contains resource that represents the full\n * path of the selected resource and `errorText` that may contain a validation error.\n */\n onChange?: NonCancelableEventHandler<S3ResourceSelectorProps.ChangeDetail>;\n}\n\n// Does not use TableProps.AriaLabels, because here we do not need \"allItemsSelectionLabel\"\n// it is not applicable to single selection mode\ninterface SelectionLabels<T> {\n itemSelectionLabel: (data: TableProps.SelectionState<T>, row: T) => string;\n selectionGroupLabel: string;\n}\n\ntype SortingColumnContainingString = (columnName: string) => string;\n\nexport namespace S3ResourceSelectorProps {\n export interface Bucket {\n Name?: string;\n CreationDate?: string;\n // artificial field, does not exist on the real s3 response\n Region?: string;\n }\n export interface Object {\n Key?: string;\n LastModified?: string;\n Size?: number;\n // artificial field, does not exist on the real s3 response\n IsFolder?: boolean;\n }\n export interface Version {\n VersionId?: string;\n LastModified?: string;\n Size?: number;\n }\n\n export interface Resource {\n uri: string;\n versionId?: string;\n }\n\n export type SelectableItems = 'buckets' | 'objects' | 'versions';\n\n export interface I18nStrings {\n /**\n * @deprecated Use `inputPlaceholder` on the component instead.\n */\n inContextInputPlaceholder?: string;\n inContextInputClearAriaLabel?: string;\n inContextSelectPlaceholder?: string;\n inContextBrowseButton?: string;\n inContextViewButton?: string;\n inContextViewButtonAriaLabel?: string;\n inContextLoadingText?: string;\n inContextUriLabel?: string;\n inContextVersionSelectLabel?: string;\n\n modalTitle?: string;\n modalCancelButton?: string;\n modalSubmitButton?: string;\n modalBreadcrumbRootItem?: string;\n\n selectionBuckets?: string;\n selectionObjects?: string;\n selectionVersions?: string;\n selectionBucketsSearchPlaceholder?: string;\n selectionObjectsSearchPlaceholder?: string;\n selectionVersionsSearchPlaceholder?: string;\n selectionBucketsLoading?: string;\n selectionBucketsNoItems?: string;\n selectionObjectsLoading?: string;\n selectionObjectsNoItems?: string;\n selectionVersionsLoading?: string;\n selectionVersionsNoItems?: string;\n\n filteringCounterText?: (count: number) => string;\n filteringNoMatches?: string;\n filteringCantFindMatch?: string;\n clearFilterButtonText?: string;\n\n columnBucketName?: string;\n columnBucketCreationDate?: string;\n columnBucketRegion?: string;\n columnObjectKey?: string;\n columnObjectLastModified?: string;\n columnObjectSize?: string;\n columnVersionID?: string;\n columnVersionLastModified?: string;\n columnVersionSize?: string;\n\n validationPathMustBegin?: string;\n validationBucketLowerCase?: string;\n validationBucketMustNotContain?: string;\n validationBucketLength?: string;\n validationBucketMustComplyDns?: string;\n\n labelSortedDescending?: SortingColumnContainingString;\n labelSortedAscending?: SortingColumnContainingString;\n labelNotSorted?: SortingColumnContainingString;\n labelsPagination?: PaginationProps.Labels;\n labelsBucketsSelection?: SelectionLabels<Bucket>;\n labelsObjectsSelection?: SelectionLabels<S3ResourceSelectorProps.Object>;\n labelsVersionsSelection?: SelectionLabels<Version>;\n labelFiltering?: (itemsType: string) => string;\n labelRefresh?: string;\n labelModalDismiss?: string;\n labelBreadcrumbs?: string;\n labelExpandBreadcrumbs?: string;\n labelClearFilter?: string;\n }\n\n export interface ChangeDetail {\n resource: Resource;\n errorText?: string;\n }\n\n export interface Ref {\n /**\n * Focuses the S3 URI input field\n */\n focus(): void;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/s3-resource-selector/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { BaseModalProps } from '../modal/interfaces';\nimport { PaginationProps } from '../pagination/interfaces';\nimport { TableProps } from '../table/interfaces';\n\nexport interface S3ResourceSelectorProps extends BaseComponentProps, BaseModalProps {\n /**\n * Specifies additional information about component status.\n */\n alert?: React.ReactNode;\n\n /**\n * Adds `aria-labelledby` to the component. If you're using this component within a form field,\n * don't set this property because the form field component automatically sets it.\n *\n * Use this property if the component isn't surrounded by a form field, or you want to override the value\n * automatically set by the form field (for example, if you have two components within a single form field).\n *\n * To use it correctly, define an ID for the element you want to use as label and set the property to that ID.\n */\n ariaLabelledby?: string;\n\n /**\n * Adds `aria-describedby` to the component. If you're using this component within a form field,\n * don't set this property because the form field component automatically sets it.\n *\n * Use this property if the component isn't surrounded by a form field, or you want to override the value\n * automatically set by the form field (for example, if you have two components within a single form field).\n *\n * To use it correctly, define an ID for each element that you want to use as a description\n * and set the property to a string of each ID separated by spaces (for example, `\"id1 id2 id3\"`).\n */\n ariaDescribedby?: string;\n\n /**\n * Adds `aria-label` to the component.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-labelledby` to the S3 URI input. If you're using this component within a form field,\n * you do not need to set this property, as the form field component will set it automatically.\n *\n * Use this property if the component isn't surrounded by a form field, or you want to override the value\n * automatically set by the form field (for example, if you have two components within a single form field).\n *\n * To use it correctly, define an ID for the element you want to use as label and set the property to that ID.\n */\n inputAriaDescribedby?: string;\n\n /**\n * Adds a placeholder to the S3 URI input.\n */\n inputPlaceholder?: string;\n\n /**\n * An array of the item types that are selectable in the table view. The array may contain the following items:\n * 'buckets', 'objects', or 'versions'. Example: ['buckets', 'objects']. By default, no items are selectable.\n * This property determines whether the component operates in Read mode or Write mode:\n * * Read mode - When 'objects' and 'versions' values are provided (folder selection should be disabled by\n * customizing `objectsIsItemDisabled` function).\n * * Write mode - When 'buckets' and 'objects' values are provided (file selection should be disabled by\n * customizing `objectsIsItemDisabled` function).\n */\n selectableItemsTypes?: ReadonlyArray<S3ResourceSelectorProps.SelectableItems>;\n\n /**\n * Href of the selected object that is applied to the View button.\n */\n viewHref?: string;\n\n /**\n * Whether the S3 URI input field is in invalid state.\n */\n invalid?: boolean;\n\n /**\n * Optionally overrides the set of visible columns in the Buckets view. Available columns: 'Name', 'CreationDate',\n * and 'Region'.\n */\n bucketsVisibleColumns?: ReadonlyArray<string>;\n\n /**\n * Optionally overrides the set of visible columns in the Objects view. Available columns: 'Key', 'LastModified',\n * and 'Size'.\n */\n objectsVisibleColumns?: ReadonlyArray<string>;\n\n /**\n * Optionally overrides the set of visible columns in the Versions view. Available columns: 'ID', 'CreationDate',\n * and 'Size'.\n */\n versionsVisibleColumns?: ReadonlyArray<string>;\n\n /**\n * Optionally overrides whether a bucket should be disabled for selection in the Buckets view or not.\n * It has higher priority than `selectableItemsTypes`. Example: if `selectableItemsTypes` has `['buckets']` value and\n * `bucketsIsItemDisabled` returns false for a bucket, then the bucket is disabled for selection.\n */\n bucketsIsItemDisabled?: (item: S3ResourceSelectorProps.Bucket) => boolean;\n\n /**\n * Optionally overrides whether an object should be disabled for selection in the Objects view or not. Similar to\n * `bucketsIsItemDisabled` this property takes precedence over the `selectableItemsTypes` property.\n */\n objectsIsItemDisabled?: (item: S3ResourceSelectorProps.Object) => boolean;\n\n /**\n * Optionally overrides whether a version should be disabled for selection in the Versions view or not. Similar to\n * `bucketsIsItemDisabled` this property takes precedence over the `selectableItemsTypes` property.\n */\n versionsIsItemDisabled?: (item: S3ResourceSelectorProps.Version) => boolean;\n\n /**\n * The current selected resource. Resource has the following properties:\n * - `uri` (string) - URI of the resource.\n * - `versionId` (string) - (Optional) Version ID of the selected resource.\n */\n resource: S3ResourceSelectorProps.Resource;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * @i18n\n */\n i18nStrings?: S3ResourceSelectorProps.I18nStrings;\n\n /**\n * Specifies a function that returns all available buckets. The return type of the function should be a promise\n * that resolves to a list of objects with the following properties:\n * - `Name` (string) - Name of the bucket.\n * - `CreationDate` (string) - (Optional) Creation date of the bucket.\n * - `Region` (string) - (Optional) Region of the bucket.\n */\n fetchBuckets: () => Promise<ReadonlyArray<S3ResourceSelectorProps.Bucket>>;\n\n /**\n * Specifies a function that returns available objects and object prefixes for the given `bucketName` and `pathPrefix`.\n * The return type of the function should be a promise that resolves to a list of objects with the following properties:\n * - `Key` (string) - Name of the object or object prefix.\n * - `LastModified` (string) - (Optional) Date when this object was last modified.\n * - `Size` (number) - (Optional) Size of the object.\n * - `IsFolder` (boolean) - (Optional) Determines whether the entry is an object prefix (folder).\n */\n fetchObjects: (bucketName: string, pathPrefix: string) => Promise<ReadonlyArray<S3ResourceSelectorProps.Object>>;\n\n /**\n * Specifies a function that returns available versions for the given `bucketName` and `pathPrefix`.\n * The return type of the function should be a promise that resolves to a list of versions with the following properties:\n * - `VersionId` (string) - Version ID of an object.\n * - `LastModified` (string) - (Optional) Date when this object was last modified.\n * - `Size` (number) - (Optional) Size of the object version.\n */\n fetchVersions: (bucketName: string, pathPrefix: string) => Promise<ReadonlyArray<S3ResourceSelectorProps.Version>>;\n\n /**\n * Fired when the resource selection is changed. The event detail object contains resource that represents the full\n * path of the selected resource and `errorText` that may contain a validation error.\n */\n onChange?: NonCancelableEventHandler<S3ResourceSelectorProps.ChangeDetail>;\n}\n\n// Does not use TableProps.AriaLabels, because here we do not need \"allItemsSelectionLabel\"\n// it is not applicable to single selection mode\ninterface SelectionLabels<T> {\n itemSelectionLabel: (data: TableProps.SelectionState<T>, row: T) => string;\n selectionGroupLabel: string;\n}\n\ntype SortingColumnContainingString = (columnName: string) => string;\n\nexport namespace S3ResourceSelectorProps {\n export interface Bucket {\n Name?: string;\n CreationDate?: string;\n // artificial field, does not exist on the real s3 response\n Region?: string;\n }\n export interface Object {\n Key?: string;\n LastModified?: string;\n Size?: number;\n // artificial field, does not exist on the real s3 response\n IsFolder?: boolean;\n }\n export interface Version {\n VersionId?: string;\n LastModified?: string;\n Size?: number;\n }\n\n export interface Resource {\n uri: string;\n versionId?: string;\n }\n\n export type SelectableItems = 'buckets' | 'objects' | 'versions';\n\n export interface I18nStrings {\n /**\n * @deprecated Use `inputPlaceholder` on the component instead.\n */\n inContextInputPlaceholder?: string;\n inContextInputClearAriaLabel?: string;\n inContextSelectPlaceholder?: string;\n inContextBrowseButton?: string;\n inContextViewButton?: string;\n inContextViewButtonAriaLabel?: string;\n inContextLoadingText?: string;\n inContextUriLabel?: string;\n inContextVersionSelectLabel?: string;\n\n modalTitle?: string;\n modalCancelButton?: string;\n modalSubmitButton?: string;\n modalBreadcrumbRootItem?: string;\n modalLastUpdatedText?: string;\n\n selectionBuckets?: string;\n selectionObjects?: string;\n selectionVersions?: string;\n selectionBucketsSearchPlaceholder?: string;\n selectionObjectsSearchPlaceholder?: string;\n selectionVersionsSearchPlaceholder?: string;\n selectionBucketsLoading?: string;\n selectionBucketsNoItems?: string;\n selectionObjectsLoading?: string;\n selectionObjectsNoItems?: string;\n selectionVersionsLoading?: string;\n selectionVersionsNoItems?: string;\n\n filteringCounterText?: (count: number) => string;\n filteringNoMatches?: string;\n filteringCantFindMatch?: string;\n clearFilterButtonText?: string;\n\n columnBucketName?: string;\n columnBucketCreationDate?: string;\n columnBucketRegion?: string;\n columnObjectKey?: string;\n columnObjectLastModified?: string;\n columnObjectSize?: string;\n columnVersionID?: string;\n columnVersionLastModified?: string;\n columnVersionSize?: string;\n\n validationPathMustBegin?: string;\n validationBucketLowerCase?: string;\n validationBucketMustNotContain?: string;\n validationBucketLength?: string;\n validationBucketMustComplyDns?: string;\n\n labelSortedDescending?: SortingColumnContainingString;\n labelSortedAscending?: SortingColumnContainingString;\n labelNotSorted?: SortingColumnContainingString;\n labelsPagination?: PaginationProps.Labels;\n labelsBucketsSelection?: SelectionLabels<Bucket>;\n labelsObjectsSelection?: SelectionLabels<S3ResourceSelectorProps.Object>;\n labelsVersionsSelection?: SelectionLabels<Version>;\n labelFiltering?: (itemsType: string) => string;\n labelRefresh?: string;\n labelModalDismiss?: string;\n labelBreadcrumbs?: string;\n labelExpandBreadcrumbs?: string;\n labelClearFilter?: string;\n }\n\n export interface ChangeDetail {\n resource: Resource;\n errorText?: string;\n }\n\n export interface Ref {\n /**\n * Focuses the S3 URI input field\n */\n focus(): void;\n }\n}\n"]}
@@ -13,6 +13,7 @@ interface BasicS3TableStrings<T> {
13
13
  filteringAriaLabel?: string;
14
14
  filteringClearAriaLabel?: string;
15
15
  filteringCounterText?: S3ResourceSelectorProps.I18nStrings['filteringCounterText'];
16
+ lastUpdatedText?: string;
16
17
  emptyText?: string;
17
18
  noMatchTitle?: string;
18
19
  noMatchSubtitle?: string;
@@ -30,15 +31,13 @@ interface BasicS3TableProps<T> {
30
31
  isItemDisabled: TableProps.IsItemDisabled<T> | undefined;
31
32
  onSelect: (item: T | undefined) => void;
32
33
  }
33
- export declare function getSharedI18Strings(i18n: ComponentFormatFunction<'s3-resource-selector'>, i18nStrings: S3ResourceSelectorProps.I18nStrings | undefined): {
34
- filteringCounterText: ((count: number) => string) | undefined;
35
- labelRefresh: string | undefined;
36
- labelsPagination: PaginationProps.Labels | undefined;
37
- noMatchTitle: string | undefined;
38
- noMatchSubtitle: string | undefined;
39
- clearFilterButtonText: string | undefined;
40
- filteringClearAriaLabel: string | undefined;
41
- };
34
+ export declare function getSharedI18Strings(i18n: ComponentFormatFunction<'s3-resource-selector'>, i18nStrings: S3ResourceSelectorProps.I18nStrings | undefined): BasicS3TableStrings<unknown>;
42
35
  export declare function BasicS3Table<T>({ forwardFocusRef, columnDefinitions, fetchData, trackBy, i18nStrings, isVisualRefresh, visibleColumns, isItemDisabled, onSelect, }: BasicS3TableProps<T>): JSX.Element;
36
+ interface InternalHeaderActionsProps<T> {
37
+ reloadData: () => void;
38
+ i18nStrings: BasicS3TableProps<T>['i18nStrings'];
39
+ lastUpdated: Date | undefined;
40
+ }
41
+ export declare function InternalHeaderActions<T>({ i18nStrings, reloadData, lastUpdated }: InternalHeaderActionsProps<T>): JSX.Element;
43
42
  export {};
44
43
  //# sourceMappingURL=basic-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"basic-table.d.ts","sourceRoot":"","sources":["../../../../src/s3-resource-selector/s3-modal/basic-table.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAO3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAwB,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,UAAU,mBAAmB,CAAC,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,uBAAuB,CAAC,EAAE,MAAM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AM,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC/B,WAAW,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;IACpC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,cAAc,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACzD,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,CAAC;CACzC;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,EACrD,WAAW,EAAE,uBAAuB,CAAC,WAAW,GAAG,SAAS,GAC3D,mBAAmB,CAAC,OAAO,CAAC,CAe9B;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAC9B,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,WAAgB,EAChB,eAAe,EACf,cAAc,EACd,cAAc,EACd,QAAQ,GACT,EAAE,iBAAiB,CAAC,CAAC,CAAC,eAsGtB;AAED,UAAU,0BAA0B,CAAC,CAAC;IACpC,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;IACjD,WAAW,EAAE,IAAI,GAAG,SAAS,CAAC;CAC/B;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,0BAA0B,CAAC,CAAC,CAAC,eA2B/G"}
@@ -1,3 +1,4 @@
1
+ import { __awaiter } from "tslib";
1
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
3
  // SPDX-License-Identifier: Apache-2.0
3
4
  import React, { useEffect, useRef, useState } from 'react';
@@ -5,11 +6,15 @@ import { useCollection } from '@cloudscape-design/collection-hooks';
5
6
  import { useStableCallback } from '@cloudscape-design/component-toolkit/internal';
6
7
  import { InternalButton } from '../../button/internal';
7
8
  import InternalHeader from '../../header/internal';
9
+ import LiveRegion from '../../internal/components/live-region';
8
10
  import useForwardFocus from '../../internal/hooks/forward-focus';
11
+ import formatDateLocalized from '../../internal/utils/date-time/format-date-localized';
9
12
  import InternalPagination from '../../pagination/internal';
13
+ import InternalSpaceBetween from '../../space-between/internal';
10
14
  import InternalTable from '../../table/internal';
11
15
  import InternalTextFilter from '../../text-filter/internal';
12
16
  import { EmptyState } from './empty-state';
17
+ import styles from './styles.css.js';
13
18
  export function getSharedI18Strings(i18n, i18nStrings) {
14
19
  return {
15
20
  filteringCounterText: i18n('i18nStrings.filteringCounterText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.filteringCounterText, format => count => format({ count })),
@@ -19,17 +24,19 @@ export function getSharedI18Strings(i18n, i18nStrings) {
19
24
  noMatchSubtitle: i18n('i18nStrings.filteringCantFindMatch', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.filteringCantFindMatch),
20
25
  clearFilterButtonText: i18n('i18nStrings.clearFilterButtonText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.clearFilterButtonText),
21
26
  filteringClearAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.labelClearFilter,
27
+ lastUpdatedText: i18n('i18nStrings.modalLastUpdatedText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.modalLastUpdatedText),
22
28
  };
23
29
  }
24
30
  export function BasicS3Table({ forwardFocusRef, columnDefinitions, fetchData, trackBy, i18nStrings = {}, isVisualRefresh, visibleColumns, isItemDisabled, onSelect, }) {
25
31
  var _a;
26
32
  const [loading, setLoading] = useState(false);
27
33
  const [allItems, setAllItems] = useState([]);
34
+ const [lastUpdated, setLastUpdated] = useState();
28
35
  const textFilterRef = useRef(null);
29
36
  const onSelectLatest = useStableCallback(onSelect);
30
37
  function loadData() {
31
38
  setLoading(true);
32
- fetchData()
39
+ return fetchData()
33
40
  .then(items => {
34
41
  setAllItems(items);
35
42
  setLoading(false);
@@ -39,6 +46,12 @@ export function BasicS3Table({ forwardFocusRef, columnDefinitions, fetchData, tr
39
46
  setLoading(false);
40
47
  });
41
48
  }
49
+ function reloadData() {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ yield loadData();
52
+ setLastUpdated(new Date());
53
+ });
54
+ }
42
55
  useEffect(() => {
43
56
  loadData();
44
57
  // Data loading is only happening on initial render, or via refresh button
@@ -60,6 +73,25 @@ export function BasicS3Table({ forwardFocusRef, columnDefinitions, fetchData, tr
60
73
  useEffect(() => {
61
74
  onSelectLatest(selectedItem);
62
75
  }, [selectedItem, onSelectLatest]);
63
- return (React.createElement(InternalTable, Object.assign({ variant: isVisualRefresh ? 'borderless' : 'container' }, collectionProps, { header: React.createElement(InternalHeader, { variant: isVisualRefresh ? 'h3' : 'h2', headingTagOverride: 'h3', actions: React.createElement(InternalButton, { iconName: "refresh", ariaLabel: i18nStrings.labelRefresh, onClick: loadData }), counter: selectedItem ? `(1/${allItems.length})` : `(${allItems.length})` }, i18nStrings.header), trackBy: trackBy, filter: React.createElement(InternalTextFilter, Object.assign({}, filterProps, { ref: textFilterRef, filteringAriaLabel: i18nStrings.filteringAriaLabel, filteringClearAriaLabel: i18nStrings.filteringClearAriaLabel, filteringPlaceholder: i18nStrings.filteringPlaceholder, countText: i18nStrings.filteringCounterText ? i18nStrings.filteringCounterText(filteredItemsCount) : '' })), pagination: React.createElement(InternalPagination, Object.assign({}, paginationProps, { ariaLabels: i18nStrings.labelsPagination })), selectionType: "single", ariaLabels: i18nStrings.selectionLabels, loading: loading, loadingText: i18nStrings.loadingText, items: items, visibleColumns: visibleColumns, isItemDisabled: isItemDisabled, columnDefinitions: columnDefinitions, enableKeyboardNavigation: true })));
76
+ return (React.createElement(InternalTable, Object.assign({ variant: isVisualRefresh ? 'borderless' : 'container' }, collectionProps, { header: React.createElement(InternalHeader, { variant: isVisualRefresh ? 'h3' : 'h2', headingTagOverride: 'h3', actions: React.createElement(InternalHeaderActions, { reloadData: reloadData, i18nStrings: i18nStrings, lastUpdated: lastUpdated }), counter: selectedItem ? `(1/${allItems.length})` : `(${allItems.length})` }, i18nStrings.header), trackBy: trackBy, filter: React.createElement(InternalTextFilter, Object.assign({}, filterProps, { ref: textFilterRef, filteringAriaLabel: i18nStrings.filteringAriaLabel, filteringClearAriaLabel: i18nStrings.filteringClearAriaLabel, filteringPlaceholder: i18nStrings.filteringPlaceholder, countText: i18nStrings.filteringCounterText ? i18nStrings.filteringCounterText(filteredItemsCount) : '' })), pagination: React.createElement(InternalPagination, Object.assign({}, paginationProps, { ariaLabels: i18nStrings.labelsPagination })), selectionType: "single", ariaLabels: i18nStrings.selectionLabels, loading: loading, loadingText: i18nStrings.loadingText, items: items, visibleColumns: visibleColumns, isItemDisabled: isItemDisabled, columnDefinitions: columnDefinitions, enableKeyboardNavigation: true })));
77
+ }
78
+ export function InternalHeaderActions({ i18nStrings, reloadData, lastUpdated }) {
79
+ function getLastUpdated() {
80
+ if (!lastUpdated || !i18nStrings.lastUpdatedText) {
81
+ return null;
82
+ }
83
+ const formattedDate = formatDateLocalized({
84
+ date: lastUpdated.toString(),
85
+ isDateOnly: false,
86
+ });
87
+ return (React.createElement("div", { className: styles['last-updated-caption'] },
88
+ i18nStrings.lastUpdatedText,
89
+ React.createElement("br", null),
90
+ formattedDate,
91
+ React.createElement(LiveRegion, { visible: false, source: [i18nStrings.lastUpdatedText, formattedDate] })));
92
+ }
93
+ return (React.createElement(InternalSpaceBetween, { size: "s", direction: "horizontal", alignItems: "center" },
94
+ getLastUpdated(),
95
+ React.createElement(InternalButton, { iconName: "refresh", ariaLabel: i18nStrings.labelRefresh, onClick: reloadData })));
64
96
  }
65
97
  //# sourceMappingURL=basic-table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"basic-table.js","sourceRoot":"","sources":["../../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kB,EAClD,uBAAuB,EAAE,WAAW,CAAC,uBAAuB,EAC5D,oBAAoB,EAAE,WAAW,CAAC,oBAAoB,EACtD,SAAS,EAAE,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,oBAAoB,CAAC,kBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE,IACxG,EAEJ,UAAU,EAAE,oBAAC,kBAAkB,oBAAK,eAAe,IAAE,UAAU,EAAE,WAAW,CAAC,gBAAgB,IAAI,EACjG,aAAa,EAAC,QAAQ,EACtB,UAAU,EAAE,WAAW,CAAC,eAAe,EACvC,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,CAAC,WAAW,EACpC,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,iBAAiB,EACpC,wBAAwB,EAAE,IAAI,IAC9B,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\n\nimport { useCollection } from '@cloudscape-design/collection-hooks';\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\n\nimport { InternalButton } from '../../button/internal';\nimport InternalHeader from '../../header/internal';\nimport { ComponentFormatFunction } from '../../i18n/context';\nimport useForwardFocus, { ForwardFocusRef } from '../../internal/hooks/forward-focus';\nimport { PaginationProps } from '../../pagination/interfaces';\nimport InternalPagination from '../../pagination/internal';\nimport { TableProps } from '../../table/interfaces';\nimport InternalTable from '../../table/internal';\nimport { TextFilterProps } from '../../text-filter/interfaces';\nimport InternalTextFilter from '../../text-filter/internal';\nimport { S3ResourceSelectorProps } from '../interfaces';\nimport { EmptyState } from './empty-state';\n\ninterface BasicS3TableStrings<T> {\n labelRefresh?: string;\n labelsPagination?: PaginationProps.Labels;\n header?: string;\n loadingText?: string;\n filteringPlaceholder?: string;\n filteringAriaLabel?: string;\n filteringClearAriaLabel?: string;\n filteringCounterText?: S3ResourceSelectorProps.I18nStrings['filteringCounterText'];\n emptyText?: string;\n noMatchTitle?: string;\n noMatchSubtitle?: string;\n clearFilterButtonText?: string;\n selectionLabels?: TableProps.AriaLabels<T>;\n}\n\ninterface BasicS3TableProps<T> {\n // We do not use idiomatic `ref` prop because it does not allow generics.\n // Option 3 from this solution: https://stackoverflow.com/a/58473012/1297743\n forwardFocusRef: React.Ref<ForwardFocusRef>;\n columnDefinitions: ReadonlyArray<TableProps.ColumnDefinition<T>>;\n fetchData: () => Promise<ReadonlyArray<T>>;\n trackBy: TableProps.TrackBy<T>;\n i18nStrings: BasicS3TableStrings<T>;\n isVisualRefresh?: boolean;\n visibleColumns: ReadonlyArray<string>;\n isItemDisabled: TableProps.IsItemDisabled<T> | undefined;\n onSelect: (item: T | undefined) => void;\n}\n\nexport function getSharedI18Strings(\n i18n: ComponentFormatFunction<'s3-resource-selector'>,\n i18nStrings: S3ResourceSelectorProps.I18nStrings | undefined\n) {\n return {\n filteringCounterText: i18n(\n 'i18nStrings.filteringCounterText',\n i18nStrings?.filteringCounterText,\n format => count => format({ count })\n ),\n labelRefresh: i18n('i18nStrings.labelRefresh', i18nStrings?.labelRefresh),\n labelsPagination: i18nStrings?.labelsPagination,\n noMatchTitle: i18n('i18nStrings.filteringNoMatches', i18nStrings?.filteringNoMatches),\n noMatchSubtitle: i18n('i18nStrings.filteringCantFindMatch', i18nStrings?.filteringCantFindMatch),\n clearFilterButtonText: i18n('i18nStrings.clearFilterButtonText', i18nStrings?.clearFilterButtonText),\n filteringClearAriaLabel: i18nStrings?.labelClearFilter,\n };\n}\n\nexport function BasicS3Table<T>({\n forwardFocusRef,\n columnDefinitions,\n fetchData,\n trackBy,\n i18nStrings = {},\n isVisualRefresh,\n visibleColumns,\n isItemDisabled,\n onSelect,\n}: BasicS3TableProps<T>) {\n const [loading, setLoading] = useState(false);\n const [allItems, setAllItems] = useState<ReadonlyArray<T>>([]);\n const textFilterRef = useRef<TextFilterProps.Ref>(null);\n const onSelectLatest = useStableCallback(onSelect);\n\n function loadData() {\n setLoading(true);\n fetchData()\n .then(items => {\n setAllItems(items);\n setLoading(false);\n })\n .catch(() => {\n // error handling should happen on the customer side, outside of this component\n setLoading(false);\n });\n }\n\n useEffect(() => {\n loadData();\n // Data loading is only happening on initial render, or via refresh button\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useForwardFocus(forwardFocusRef, textFilterRef);\n\n const { items, filteredItemsCount, collectionProps, filterProps, paginationProps, actions } = useCollection(\n allItems,\n {\n selection: { trackBy },\n filtering: {\n empty: i18nStrings.emptyText,\n noMatch: (\n <EmptyState\n title={i18nStrings.noMatchTitle}\n subtitle={i18nStrings.noMatchSubtitle}\n action={\n <InternalButton onClick={() => actions.setFiltering('')}>\n {i18nStrings.clearFilterButtonText}\n </InternalButton>\n }\n />\n ),\n },\n pagination: {},\n sorting: {},\n }\n );\n const selectedItem = collectionProps.selectedItems?.[0];\n\n // selectedItem can change internally inside the hook after pagination or filtering\n // useEffect will capture all possible changes\n useEffect(() => {\n onSelectLatest(selectedItem);\n }, [selectedItem, onSelectLatest]);\n\n return (\n <InternalTable<T>\n variant={isVisualRefresh ? 'borderless' : 'container'}\n {...collectionProps}\n header={\n <InternalHeader\n variant={isVisualRefresh ? 'h3' : 'h2'}\n headingTagOverride={'h3'}\n actions={<InternalButton iconName=\"refresh\" ariaLabel={i18nStrings.labelRefresh} onClick={loadData} />}\n counter={selectedItem ? `(1/${allItems.length})` : `(${allItems.length})`}\n >\n {i18nStrings.header}\n </InternalHeader>\n }\n trackBy={trackBy}\n filter={\n <InternalTextFilter\n {...filterProps}\n ref={textFilterRef}\n filteringAriaLabel={i18nStrings.filteringAriaLabel}\n filteringClearAriaLabel={i18nStrings.filteringClearAriaLabel}\n filteringPlaceholder={i18nStrings.filteringPlaceholder}\n countText={i18nStrings.filteringCounterText ? i18nStrings.filteringCounterText(filteredItemsCount!) : ''}\n />\n }\n pagination={<InternalPagination {...paginationProps} ariaLabels={i18nStrings.labelsPagination} />}\n selectionType=\"single\"\n ariaLabels={i18nStrings.selectionLabels}\n loading={loading}\n loadingText={i18nStrings.loadingText}\n items={items}\n visibleColumns={visibleColumns}\n isItemDisabled={isItemDisabled}\n columnDefinitions={columnDefinitions}\n enableKeyboardNavigation={true}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"basic-table.js","sourceRoot":"","sources":["../../../../src/s3-resource-selector/s3-modal/basic-table.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,cAAc,MAAM,uBAAuB,CAAC;AAEnD,OAAO,UAAU,MAAM,uCAAuC,CAAC;AAC/D,OAAO,eAAoC,MAAM,oCAAoC,CAAC;AACtF,OAAO,mBAAmB,MAAM,sDAAsD,CAAC;AAEvF,OAAO,kBAAkB,MAAM,2BAA2B,CAAC;AAC3D,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAEhE,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAEjD,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAiCrC,MAAM,UAAU,mBAAmB,CACjC,IAAqD,EACrD,WAA4D;IAE5D,OAAO;QACL,oBAAoB,EAAE,IAAI,CACxB,kCAAkC,EAClC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,oBAAoB,EACjC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,C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B,EAAE,iBAAiB,EACpC,wBAAwB,EAAE,IAAI,IAC9B,CACH,CAAC;AACJ,CAAC;AAQD,MAAM,UAAU,qBAAqB,CAAI,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAiC;IAC9G,SAAS,cAAc;QACrB,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE;YAChD,OAAO,IAAI,CAAC;SACb;QAED,MAAM,aAAa,GAAG,mBAAmB,CAAC;YACxC,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE;YAC5B,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;QAEH,OAAO,CACL,6BAAK,SAAS,EAAE,MAAM,CAAC,sBAAsB,CAAC;YAC3C,WAAW,CAAC,eAAe;YAC5B,+BAAM;YACL,aAAa;YACd,oBAAC,UAAU,IAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,WAAW,CAAC,eAAe,EAAE,aAAa,CAAC,GAAI,CAChF,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,oBAAC,oBAAoB,IAAC,IAAI,EAAC,GAAG,EAAC,SAAS,EAAC,YAAY,EAAC,UAAU,EAAC,QAAQ;QACtE,cAAc,EAAE;QACjB,oBAAC,cAAc,IAAC,QAAQ,EAAC,SAAS,EAAC,SAAS,EAAE,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,UAAU,GAAI,CAC1E,CACxB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\n\nimport { useCollection } from '@cloudscape-design/collection-hooks';\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\n\nimport { InternalButton } from '../../button/internal';\nimport InternalHeader from '../../header/internal';\nimport { ComponentFormatFunction } from '../../i18n/context';\nimport LiveRegion from '../../internal/components/live-region';\nimport useForwardFocus, { ForwardFocusRef } from '../../internal/hooks/forward-focus';\nimport formatDateLocalized from '../../internal/utils/date-time/format-date-localized';\nimport { PaginationProps } from '../../pagination/interfaces';\nimport InternalPagination from '../../pagination/internal';\nimport InternalSpaceBetween from '../../space-between/internal';\nimport { TableProps } from '../../table/interfaces';\nimport InternalTable from '../../table/internal';\nimport { TextFilterProps } from '../../text-filter/interfaces';\nimport InternalTextFilter from '../../text-filter/internal';\nimport { S3ResourceSelectorProps } from '../interfaces';\nimport { EmptyState } from './empty-state';\n\nimport styles from './styles.css.js';\n\ninterface BasicS3TableStrings<T> {\n labelRefresh?: string;\n labelsPagination?: PaginationProps.Labels;\n header?: string;\n loadingText?: string;\n filteringPlaceholder?: string;\n filteringAriaLabel?: string;\n filteringClearAriaLabel?: string;\n filteringCounterText?: S3ResourceSelectorProps.I18nStrings['filteringCounterText'];\n lastUpdatedText?: string;\n emptyText?: string;\n noMatchTitle?: string;\n noMatchSubtitle?: string;\n clearFilterButtonText?: string;\n selectionLabels?: TableProps.AriaLabels<T>;\n}\n\ninterface BasicS3TableProps<T> {\n // We do not use idiomatic `ref` prop because it does not allow generics.\n // Option 3 from this solution: https://stackoverflow.com/a/58473012/1297743\n forwardFocusRef: React.Ref<ForwardFocusRef>;\n columnDefinitions: ReadonlyArray<TableProps.ColumnDefinition<T>>;\n fetchData: () => Promise<ReadonlyArray<T>>;\n trackBy: TableProps.TrackBy<T>;\n i18nStrings: BasicS3TableStrings<T>;\n isVisualRefresh?: boolean;\n visibleColumns: ReadonlyArray<string>;\n isItemDisabled: TableProps.IsItemDisabled<T> | undefined;\n onSelect: (item: T | undefined) => void;\n}\n\nexport function getSharedI18Strings(\n i18n: ComponentFormatFunction<'s3-resource-selector'>,\n i18nStrings: S3ResourceSelectorProps.I18nStrings | undefined\n): BasicS3TableStrings<unknown> {\n return {\n filteringCounterText: i18n(\n 'i18nStrings.filteringCounterText',\n i18nStrings?.filteringCounterText,\n format => count => format({ count })\n ),\n labelRefresh: i18n('i18nStrings.labelRefresh', i18nStrings?.labelRefresh),\n labelsPagination: i18nStrings?.labelsPagination,\n noMatchTitle: i18n('i18nStrings.filteringNoMatches', i18nStrings?.filteringNoMatches),\n noMatchSubtitle: i18n('i18nStrings.filteringCantFindMatch', i18nStrings?.filteringCantFindMatch),\n clearFilterButtonText: i18n('i18nStrings.clearFilterButtonText', i18nStrings?.clearFilterButtonText),\n filteringClearAriaLabel: i18nStrings?.labelClearFilter,\n lastUpdatedText: i18n('i18nStrings.modalLastUpdatedText', i18nStrings?.modalLastUpdatedText),\n };\n}\n\nexport function BasicS3Table<T>({\n forwardFocusRef,\n columnDefinitions,\n fetchData,\n trackBy,\n i18nStrings = {},\n isVisualRefresh,\n visibleColumns,\n isItemDisabled,\n onSelect,\n}: BasicS3TableProps<T>) {\n const [loading, setLoading] = useState(false);\n const [allItems, setAllItems] = useState<ReadonlyArray<T>>([]);\n const [lastUpdated, setLastUpdated] = useState<Date>();\n const textFilterRef = useRef<TextFilterProps.Ref>(null);\n const onSelectLatest = useStableCallback(onSelect);\n\n function loadData() {\n setLoading(true);\n return fetchData()\n .then(items => {\n setAllItems(items);\n setLoading(false);\n })\n .catch(() => {\n // error handling should happen on the customer side, outside of this component\n setLoading(false);\n });\n }\n\n async function reloadData() {\n await loadData();\n setLastUpdated(new Date());\n }\n\n useEffect(() => {\n loadData();\n // Data loading is only happening on initial render, or via refresh button\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useForwardFocus(forwardFocusRef, textFilterRef);\n\n const { items, filteredItemsCount, collectionProps, filterProps, paginationProps, actions } = useCollection(\n allItems,\n {\n selection: { trackBy },\n filtering: {\n empty: i18nStrings.emptyText,\n noMatch: (\n <EmptyState\n title={i18nStrings.noMatchTitle}\n subtitle={i18nStrings.noMatchSubtitle}\n action={\n <InternalButton onClick={() => actions.setFiltering('')}>\n {i18nStrings.clearFilterButtonText}\n </InternalButton>\n }\n />\n ),\n },\n pagination: {},\n sorting: {},\n }\n );\n const selectedItem = collectionProps.selectedItems?.[0];\n\n // selectedItem can change internally inside the hook after pagination or filtering\n // useEffect will capture all possible changes\n useEffect(() => {\n onSelectLatest(selectedItem);\n }, [selectedItem, onSelectLatest]);\n\n return (\n <InternalTable<T>\n variant={isVisualRefresh ? 'borderless' : 'container'}\n {...collectionProps}\n header={\n <InternalHeader\n variant={isVisualRefresh ? 'h3' : 'h2'}\n headingTagOverride={'h3'}\n actions={\n <InternalHeaderActions<T> reloadData={reloadData} i18nStrings={i18nStrings} lastUpdated={lastUpdated} />\n }\n counter={selectedItem ? `(1/${allItems.length})` : `(${allItems.length})`}\n >\n {i18nStrings.header}\n </InternalHeader>\n }\n trackBy={trackBy}\n filter={\n <InternalTextFilter\n {...filterProps}\n ref={textFilterRef}\n filteringAriaLabel={i18nStrings.filteringAriaLabel}\n filteringClearAriaLabel={i18nStrings.filteringClearAriaLabel}\n filteringPlaceholder={i18nStrings.filteringPlaceholder}\n countText={i18nStrings.filteringCounterText ? i18nStrings.filteringCounterText(filteredItemsCount!) : ''}\n />\n }\n pagination={<InternalPagination {...paginationProps} ariaLabels={i18nStrings.labelsPagination} />}\n selectionType=\"single\"\n ariaLabels={i18nStrings.selectionLabels}\n loading={loading}\n loadingText={i18nStrings.loadingText}\n items={items}\n visibleColumns={visibleColumns}\n isItemDisabled={isItemDisabled}\n columnDefinitions={columnDefinitions}\n enableKeyboardNavigation={true}\n />\n );\n}\n\ninterface InternalHeaderActionsProps<T> {\n reloadData: () => void;\n i18nStrings: BasicS3TableProps<T>['i18nStrings'];\n lastUpdated: Date | undefined;\n}\n\nexport function InternalHeaderActions<T>({ i18nStrings, reloadData, lastUpdated }: InternalHeaderActionsProps<T>) {\n function getLastUpdated() {\n if (!lastUpdated || !i18nStrings.lastUpdatedText) {\n return null;\n }\n\n const formattedDate = formatDateLocalized({\n date: lastUpdated.toString(),\n isDateOnly: false,\n });\n\n return (\n <div className={styles['last-updated-caption']}>\n {i18nStrings.lastUpdatedText}\n <br />\n {formattedDate}\n <LiveRegion visible={false} source={[i18nStrings.lastUpdatedText, formattedDate]} />\n </div>\n );\n }\n\n return (\n <InternalSpaceBetween size=\"s\" direction=\"horizontal\" alignItems=\"center\">\n {getLastUpdated()}\n <InternalButton iconName=\"refresh\" ariaLabel={i18nStrings.labelRefresh} onClick={reloadData} />\n </InternalSpaceBetween>\n );\n}\n"]}
@@ -1,7 +1,8 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "modal-actions": "awsui_modal-actions_12hyz_1p88p_5",
5
- "submit-button": "awsui_submit-button_12hyz_1p88p_9"
4
+ "modal-actions": "awsui_modal-actions_12hyz_1iljt_97",
5
+ "submit-button": "awsui_submit-button_12hyz_1iljt_101",
6
+ "last-updated-caption": "awsui_last-updated-caption_12hyz_1iljt_105"
6
7
  };
7
8