@cloudscape-design/components 3.0.647 → 3.0.649
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app-layout/drawer/index.js +2 -2
- package/app-layout/drawer/index.js.map +1 -1
- package/app-layout/mobile-toolbar/index.js +1 -1
- package/app-layout/mobile-toolbar/index.js.map +1 -1
- package/app-layout/utils/sticky-offsets.d.ts +1 -1
- package/app-layout/utils/sticky-offsets.d.ts.map +1 -1
- package/app-layout/utils/sticky-offsets.js +2 -2
- package/app-layout/utils/sticky-offsets.js.map +1 -1
- package/app-layout/visual-refresh/background.d.ts.map +1 -1
- package/app-layout/visual-refresh/background.js +2 -5
- package/app-layout/visual-refresh/background.js.map +1 -1
- package/app-layout/visual-refresh/breadcrumbs.d.ts.map +1 -1
- package/app-layout/visual-refresh/breadcrumbs.js +1 -2
- package/app-layout/visual-refresh/breadcrumbs.js.map +1 -1
- package/app-layout/visual-refresh/context.d.ts +0 -2
- package/app-layout/visual-refresh/context.d.ts.map +1 -1
- package/app-layout/visual-refresh/context.js +2 -7
- package/app-layout/visual-refresh/context.js.map +1 -1
- package/app-layout/visual-refresh/drawers.js +2 -2
- package/app-layout/visual-refresh/drawers.js.map +1 -1
- package/app-layout/visual-refresh/layout.d.ts.map +1 -1
- package/app-layout/visual-refresh/layout.js +1 -3
- package/app-layout/visual-refresh/layout.js.map +1 -1
- package/app-layout/visual-refresh/main.d.ts.map +1 -1
- package/app-layout/visual-refresh/main.js +2 -4
- package/app-layout/visual-refresh/main.js.map +1 -1
- package/app-layout/visual-refresh/navigation.js +2 -2
- package/app-layout/visual-refresh/navigation.js.map +1 -1
- package/app-layout/visual-refresh/notifications.d.ts.map +1 -1
- package/app-layout/visual-refresh/notifications.js +3 -1
- package/app-layout/visual-refresh/notifications.js.map +1 -1
- package/app-layout/visual-refresh/styles.css.js +82 -83
- package/app-layout/visual-refresh/styles.scoped.css +168 -190
- package/app-layout/visual-refresh/styles.selectors.js +82 -83
- package/app-layout/visual-refresh/tools.js +2 -2
- package/app-layout/visual-refresh/tools.js.map +1 -1
- package/app-layout/visual-refresh/trigger-button.js +1 -1
- package/app-layout/visual-refresh/trigger-button.js.map +1 -1
- package/app-layout/visual-refresh/use-background-overlap.d.ts +0 -6
- package/app-layout/visual-refresh/use-background-overlap.d.ts.map +1 -1
- package/app-layout/visual-refresh/use-background-overlap.js +0 -6
- package/app-layout/visual-refresh/use-background-overlap.js.map +1 -1
- package/button-dropdown/category-elements/category-element.js +1 -1
- package/button-dropdown/category-elements/category-element.js.map +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.js +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.js.map +1 -1
- package/button-dropdown/mobile-expandable-group/mobile-expandable-group.js +1 -1
- package/button-dropdown/mobile-expandable-group/mobile-expandable-group.js.map +1 -1
- package/container/internal.d.ts.map +1 -1
- package/container/internal.js +7 -25
- package/container/internal.js.map +1 -1
- package/container/styles.css.js +30 -29
- package/container/styles.scoped.css +60 -53
- package/container/styles.selectors.js +30 -29
- package/container/use-sticky-header.d.ts +3 -2
- package/container/use-sticky-header.d.ts.map +1 -1
- package/container/use-sticky-header.js +5 -3
- package/container/use-sticky-header.js.map +1 -1
- package/content-layout/internal.js +2 -2
- package/content-layout/internal.js.map +1 -1
- package/drawer/implementation.js +2 -2
- package/drawer/implementation.js.map +1 -1
- package/help-panel/implementation.js +2 -2
- package/help-panel/implementation.js.map +1 -1
- package/icon/icons.js +1 -1
- package/icon/interfaces.d.ts +1 -1
- package/icon/interfaces.d.ts.map +1 -1
- package/icon/interfaces.js.map +1 -1
- package/internal/analytics/index.d.ts +7 -1
- package/internal/analytics/index.d.ts.map +1 -1
- package/internal/analytics/index.js +10 -0
- package/internal/analytics/index.js.map +1 -1
- package/internal/analytics/interfaces.d.ts +12 -0
- package/internal/analytics/interfaces.d.ts.map +1 -1
- package/internal/analytics/interfaces.js.map +1 -1
- package/internal/base-component/index.d.ts +5 -3
- package/internal/base-component/index.d.ts.map +1 -1
- package/internal/base-component/index.js.map +1 -1
- package/internal/components/cartesian-chart/inline-start-labels.js +1 -1
- package/internal/components/cartesian-chart/inline-start-labels.js.map +1 -1
- package/internal/components/option/highlight-match.d.ts.map +1 -1
- package/internal/components/option/highlight-match.js +1 -2
- package/internal/components/option/highlight-match.js.map +1 -1
- package/internal/components/option/index.js +2 -2
- package/internal/components/option/index.js.map +1 -1
- package/internal/context/reset-contexts-for-modal.d.ts.map +1 -1
- package/internal/context/reset-contexts-for-modal.js +6 -8
- package/internal/context/reset-contexts-for-modal.js.map +1 -1
- package/internal/context/single-tab-stop-navigation-context.d.ts +16 -2
- package/internal/context/single-tab-stop-navigation-context.d.ts.map +1 -1
- package/internal/context/single-tab-stop-navigation-context.js +51 -1
- package/internal/context/single-tab-stop-navigation-context.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/hooks/use-table-interaction-metrics/index.d.ts +10 -0
- package/internal/hooks/use-table-interaction-metrics/index.d.ts.map +1 -0
- package/internal/hooks/use-table-interaction-metrics/index.js +47 -0
- package/internal/hooks/use-table-interaction-metrics/index.js.map +1 -0
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/popover/index.d.ts +1 -1
- package/popover/index.d.ts.map +1 -1
- package/popover/index.js +2 -2
- package/popover/index.js.map +1 -1
- package/popover/interfaces.d.ts +5 -0
- package/popover/interfaces.d.ts.map +1 -1
- package/popover/interfaces.js.map +1 -1
- package/popover/internal.js +2 -2
- package/popover/internal.js.map +1 -1
- package/popover/styles.css.js +50 -49
- package/popover/styles.scoped.css +74 -66
- package/popover/styles.selectors.js +50 -49
- package/slider/internal.js +1 -1
- package/slider/internal.js.map +1 -1
- package/slider/slider-labels.js +1 -1
- package/slider/slider-labels.js.map +1 -1
- package/slider/tick-marks.js +2 -2
- package/slider/tick-marks.js.map +1 -1
- package/split-panel/side.js +3 -3
- package/split-panel/side.js.map +1 -1
- package/table/internal.d.ts.map +1 -1
- package/table/internal.js +23 -17
- package/table/internal.js.map +1 -1
- package/table/selection/selection-control.js +1 -1
- package/table/selection/selection-control.js.map +1 -1
- package/table/table-role/grid-navigation.d.ts.map +1 -1
- package/table/table-role/grid-navigation.js +40 -67
- package/table/table-role/grid-navigation.js.map +1 -1
- package/table/thead.d.ts +1 -0
- package/table/thead.d.ts.map +1 -1
- package/table/thead.js +5 -2
- package/table/thead.js.map +1 -1
- package/table/tools-header.d.ts +2 -1
- package/table/tools-header.d.ts.map +1 -1
- package/table/tools-header.js +4 -4
- package/table/tools-header.js.map +1 -1
- package/tabs/tab-header-bar.d.ts.map +1 -1
- package/tabs/tab-header-bar.js +106 -55
- package/tabs/tab-header-bar.js.map +1 -1
- package/token-group/dismiss-button.d.ts.map +1 -1
- package/token-group/dismiss-button.js +1 -2
- package/token-group/dismiss-button.js.map +1 -1
- package/wizard/wizard-form-header.js +1 -1
- package/wizard/wizard-form-header.js.map +1 -1
- package/wizard/wizard-form.js +1 -1
- package/wizard/wizard-form.js.map +1 -1
- package/wizard/wizard-navigation.js +3 -3
- package/wizard/wizard-navigation.js.map +1 -1
- package/internal/context/app-layout-context.d.ts +0 -8
- package/internal/context/app-layout-context.d.ts.map +0 -1
- package/internal/context/app-layout-context.js +0 -9
- package/internal/context/app-layout-context.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight-match.js","sourceRoot":"","sources":["../../../../../src/internal/components/option/highlight-match.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"highlight-match.js","sourceRoot":"","sources":["../../../../../src/internal/components/option/highlight-match.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC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E,GAAG,EAAE,EAAE;QACjC,WAAW,CAAC,IAAI,CAAC,8BAAM,GAAG,EAAE,WAAW,GAAG,EAAE,IAAG,OAAO,CAAQ,CAAC,CAAC;QAEhE,IAAI,OAAO,IAAI,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE;YACnC,WAAW,CAAC,IAAI,CAAC,oBAAC,SAAS,IAAC,GAAG,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAI,CAAC,CAAC;SACzE;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,kCAAO,WAAW,CAAQ,CAAC;AACpC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport styles from './styles.css.js';\n\nconst splitOnFiltering = (str: string, highlightText: string) => {\n // We match by creating a regex using user-provided strings, so we skip\n // highlighting if the generated regex would be too memory intensive.\n if (highlightText.length > 100000) {\n return { noMatches: [str], matches: null };\n }\n\n // Filtering needs to be case insensitive\n const filteringPattern = highlightText.replace(/[-[\\]/{}()*+?.\\\\^$|]/g, '\\\\$&');\n const regexp = new RegExp(filteringPattern, 'gi');\n const noMatches = str.split(regexp);\n const matches = str.match(regexp);\n\n return { noMatches, matches };\n};\n\nexport interface HighlightMatchProps {\n str?: string;\n highlightText?: string;\n}\n\nconst Highlight = ({ str }: HighlightMatchProps) =>\n str ? <span className={styles['filtering-match-highlight']}>{str}</span> : null;\n\nexport default function HighlightMatch({ str, highlightText }: HighlightMatchProps) {\n if (!str || !highlightText) {\n return <span>{str}</span>;\n }\n\n if (str === highlightText) {\n return <Highlight str={str} />;\n }\n\n const { noMatches, matches } = splitOnFiltering(str, highlightText);\n\n const highlighted: (string | JSX.Element)[] = [];\n\n noMatches.forEach((noMatch, idx) => {\n highlighted.push(<span key={`noMatch-${idx}`}>{noMatch}</span>);\n\n if (matches && idx < matches.length) {\n highlighted.push(<Highlight key={`match-${idx}`} str={matches[idx]} />);\n }\n });\n\n return <span>{highlighted}</span>;\n}\n"]}
|
|
@@ -45,8 +45,8 @@ const Option = (_a) => {
|
|
|
45
45
|
: undefined;
|
|
46
46
|
return (React.createElement("span", Object.assign({ "data-value": option.value, className: className, lang: option.lang }, genericGroupProps, baseProps),
|
|
47
47
|
icon,
|
|
48
|
-
React.createElement("span", { className:
|
|
49
|
-
React.createElement("span", { className:
|
|
48
|
+
React.createElement("span", { className: styles.content },
|
|
49
|
+
React.createElement("span", { className: styles['label-content'] },
|
|
50
50
|
React.createElement(Label, { label: (_e = option.label) !== null && _e !== void 0 ? _e : option.value, prefix: option.__labelPrefix, highlightText: highlightText, triggerVariant: triggerVariant }),
|
|
51
51
|
React.createElement(LabelTag, { labelTag: option.labelTag, highlightText: highlightText, triggerVariant: triggerVariant })),
|
|
52
52
|
React.createElement(Description, { description: option.description, highlightedOption: highlightedOption, selectedOption: selectedOption, highlightText: highlightText, triggerVariant: triggerVariant }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/option/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,SAAS,mBAAmB,CAAC,KAAyB,EAAE,YAAoB;IAC1E,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,OAAO,KAAK,KAAK,QAAQ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AChG;YACP,oBAAC,WAAW,IACV,WAAW,EAAE,MAAM,CAAC,WAAW,EAC/B,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,GAC9B;YACF,oBAAC,IAAI,IACH,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,GAC9B;YACF,oBAAC,aAAa,IACZ,aAAa,EAAE,MAAM,CAAC,aAAa,EACnC,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,GAC9B,CACG,CACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport { OptionProps } from './interfaces';\nimport { Label, LabelTag, Description, Tags, FilteringTags, OptionIcon } from './option-parts';\nimport { getBaseProps } from '../../base-component';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { isDevelopment } from '../../is-development';\n\nexport { OptionProps };\n\nfunction validateStringValue(value: string | undefined, propertyName: string) {\n if (typeof value !== 'undefined' && typeof value !== 'string') {\n warnOnce(\n 'DropdownOption',\n `This component only supports string values, but \"option.${propertyName}\" has ${typeof value} type. The component may work incorrectly.`\n );\n }\n}\n\nconst Option = ({\n option,\n highlightText,\n triggerVariant = false,\n isGroupOption = false,\n isGenericGroup = true,\n highlightedOption = false,\n selectedOption = false,\n ...restProps\n}: OptionProps) => {\n if (!option) {\n return null;\n }\n const { disabled } = option;\n const baseProps = getBaseProps(restProps);\n\n if (isDevelopment) {\n validateStringValue(option.label, 'label');\n validateStringValue(option.description, 'description');\n validateStringValue(option.labelTag, 'labelTag');\n option.tags?.forEach((tag, index) => {\n validateStringValue(tag, `tags[${index}]`);\n });\n option.filteringTags?.forEach((tag, index) => {\n validateStringValue(tag, `filteringTags[${index}]`);\n });\n }\n\n const className = clsx(\n styles.option,\n disabled && styles.disabled,\n isGroupOption && styles.parent,\n highlightedOption && styles.highlighted\n );\n\n const icon = option.__customIcon || (\n <OptionIcon\n name={option.iconName}\n url={option.iconUrl}\n svg={option.iconSvg}\n alt={option.iconAlt}\n size={option.description || option.tags ? 'big' : 'normal'}\n />\n );\n\n // The option is conditionally assigned 'title' and 'aria-disabled' attributes to ensure it is viewed as a (generic) group by assistive technology only when necessary.\n // Omitting the props might be necessary if they are provided on the parent element to avoid nested groups.\n // See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/generic_role\n const genericGroupProps = isGenericGroup\n ? {\n title: option.label ?? option.value,\n 'aria-disabled': disabled,\n }\n : undefined;\n\n return (\n <span data-value={option.value} className={className} lang={option.lang} {...genericGroupProps} {...baseProps}>\n {icon}\n <span className={styles.content}>\n <span className={styles['label-content']}>\n <Label\n label={option.label ?? option.value}\n prefix={option.__labelPrefix}\n highlightText={highlightText}\n triggerVariant={triggerVariant}\n />\n <LabelTag labelTag={option.labelTag} highlightText={highlightText} triggerVariant={triggerVariant} />\n </span>\n <Description\n description={option.description}\n highlightedOption={highlightedOption}\n selectedOption={selectedOption}\n highlightText={highlightText}\n triggerVariant={triggerVariant}\n />\n <Tags\n tags={option.tags}\n highlightedOption={highlightedOption}\n selectedOption={selectedOption}\n highlightText={highlightText}\n triggerVariant={triggerVariant}\n />\n <FilteringTags\n filteringTags={option.filteringTags}\n highlightedOption={highlightedOption}\n selectedOption={selectedOption}\n highlightText={highlightText}\n triggerVariant={triggerVariant}\n />\n </span>\n </span>\n );\n};\n\nexport default Option;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset-contexts-for-modal.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/reset-contexts-for-modal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"reset-contexts-for-modal.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/reset-contexts-for-modal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAe1B,QAAA,MAAM,qBAAqB;cAA8B,MAAM,SAAS;iBAcvE,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -5,19 +5,17 @@ import { FormFieldContext } from './form-field-context';
|
|
|
5
5
|
import { ButtonContext } from './button-context';
|
|
6
6
|
import { CollectionLabelContext } from './collection-label-context';
|
|
7
7
|
import { InfoLinkLabelContext } from './info-link-label-context';
|
|
8
|
-
import { AppLayoutContext, defaultValue as appLayoutDefaultValue } from './app-layout-context';
|
|
9
8
|
import { LinkDefaultVariantContext, defaultValue as linkDefaultValue } from './link-default-variant-context';
|
|
10
9
|
import { SingleTabStopNavigationContext, defaultValue as singleTabStopDefaultValue, } from './single-tab-stop-navigation-context';
|
|
11
10
|
/*
|
|
12
11
|
Use this context-resetter when creating a new modal-type context where typically the contents
|
|
13
12
|
of the modal should not be affected by the surrounding components/DOM.
|
|
14
13
|
*/
|
|
15
|
-
const ResetContextsForModal = ({ children }) => (React.createElement(
|
|
16
|
-
React.createElement(
|
|
17
|
-
React.createElement(
|
|
18
|
-
React.createElement(
|
|
19
|
-
React.createElement(
|
|
20
|
-
React.createElement(
|
|
21
|
-
React.createElement(SingleTabStopNavigationContext.Provider, { value: singleTabStopDefaultValue }, children))))))));
|
|
14
|
+
const ResetContextsForModal = ({ children }) => (React.createElement(ButtonContext.Provider, { value: { onClick: () => { } } },
|
|
15
|
+
React.createElement(CollectionLabelContext.Provider, { value: { assignId: () => { } } },
|
|
16
|
+
React.createElement(FormFieldContext.Provider, { value: {} },
|
|
17
|
+
React.createElement(InfoLinkLabelContext.Provider, { value: "" },
|
|
18
|
+
React.createElement(LinkDefaultVariantContext.Provider, { value: linkDefaultValue },
|
|
19
|
+
React.createElement(SingleTabStopNavigationContext.Provider, { value: singleTabStopDefaultValue }, children)))))));
|
|
22
20
|
export default ResetContextsForModal;
|
|
23
21
|
//# sourceMappingURL=reset-contexts-for-modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset-contexts-for-modal.js","sourceRoot":"","sources":["../../../../src/internal/context/reset-contexts-for-modal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"reset-contexts-for-modal.js","sourceRoot":"","sources":["../../../../src/internal/context/reset-contexts-for-modal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAC7G,OAAO,EACL,8BAA8B,EAC9B,YAAY,IAAI,yBAAyB,GAC1C,MAAM,sCAAsC,CAAC;AAE9C;;;GAGG;AACH,MAAM,qBAAqB,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE,CAAC,CAC7E,oBAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE;IAClD,oBAAC,sBAAsB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE;QAC5D,oBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE;YAClC,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAC,EAAE;gBACrC,oBAAC,yBAAyB,CAAC,QAAQ,IAAC,KAAK,EAAE,gBAAgB;oBACzD,oBAAC,8BAA8B,CAAC,QAAQ,IAAC,KAAK,EAAE,yBAAyB,IACtE,QAAQ,CAC+B,CACP,CACP,CACN,CACI,CACX,CAC1B,CAAC;AAEF,eAAe,qBAAqB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { FormFieldContext } from './form-field-context';\nimport { ButtonContext } from './button-context';\nimport { CollectionLabelContext } from './collection-label-context';\nimport { InfoLinkLabelContext } from './info-link-label-context';\nimport { LinkDefaultVariantContext, defaultValue as linkDefaultValue } from './link-default-variant-context';\nimport {\n SingleTabStopNavigationContext,\n defaultValue as singleTabStopDefaultValue,\n} from './single-tab-stop-navigation-context';\n\n/*\n Use this context-resetter when creating a new modal-type context where typically the contents\n of the modal should not be affected by the surrounding components/DOM.\n */\nconst ResetContextsForModal = ({ children }: { children: React.ReactNode }) => (\n <ButtonContext.Provider value={{ onClick: () => {} }}>\n <CollectionLabelContext.Provider value={{ assignId: () => {} }}>\n <FormFieldContext.Provider value={{}}>\n <InfoLinkLabelContext.Provider value=\"\">\n <LinkDefaultVariantContext.Provider value={linkDefaultValue}>\n <SingleTabStopNavigationContext.Provider value={singleTabStopDefaultValue}>\n {children}\n </SingleTabStopNavigationContext.Provider>\n </LinkDefaultVariantContext.Provider>\n </InfoLinkLabelContext.Provider>\n </FormFieldContext.Provider>\n </CollectionLabelContext.Provider>\n </ButtonContext.Provider>\n);\n\nexport default ResetContextsForModal;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export type FocusableChangeHandler = (isFocusable: boolean) => void;
|
|
3
3
|
export interface SingleTabStopNavigationOptions {
|
|
4
4
|
tabIndex?: number;
|
|
@@ -11,7 +11,7 @@ export declare const defaultValue: {
|
|
|
11
11
|
* Single tab stop navigation context is used together with keyboard navigation that requires a single tab stop.
|
|
12
12
|
* It instructs interactive elements to override tab indices for just a single one to remain user-focusable.
|
|
13
13
|
*/
|
|
14
|
-
export declare const SingleTabStopNavigationContext:
|
|
14
|
+
export declare const SingleTabStopNavigationContext: React.Context<{
|
|
15
15
|
navigationActive: boolean;
|
|
16
16
|
registerFocusable(focusable: HTMLElement, handler: FocusableChangeHandler): () => void;
|
|
17
17
|
}>;
|
|
@@ -21,4 +21,18 @@ export declare function useSingleTabStopNavigation(focusable: null | React.RefOb
|
|
|
21
21
|
navigationActive: boolean;
|
|
22
22
|
tabIndex: number | undefined;
|
|
23
23
|
};
|
|
24
|
+
export interface SingleTabStopNavigationProviderProps {
|
|
25
|
+
navigationActive: boolean;
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
getNextFocusTarget: () => null | HTMLElement;
|
|
28
|
+
isElementSuppressed?(focusableElement: Element): boolean;
|
|
29
|
+
onRegisterFocusable?(focusableElement: Element): void;
|
|
30
|
+
onUnregisterFocusable?(focusableElement: Element): void;
|
|
31
|
+
}
|
|
32
|
+
export interface SingleTabStopNavigationAPI {
|
|
33
|
+
updateFocusTarget(): void;
|
|
34
|
+
getFocusTarget(): null | HTMLElement;
|
|
35
|
+
isRegistered(element: Element): boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare const SingleTabStopNavigationProvider: React.ForwardRefExoticComponent<SingleTabStopNavigationProviderProps & React.RefAttributes<SingleTabStopNavigationAPI>>;
|
|
24
38
|
//# sourceMappingURL=single-tab-stop-navigation-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-tab-stop-navigation-context.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/single-tab-stop-navigation-context.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"single-tab-stop-navigation-context.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/single-tab-stop-navigation-context.tsx"],"names":[],"mappings":"AAGA,OAAO,KAQN,MAAM,OAAO,CAAC;AAEf,MAAM,MAAM,sBAAsB,GAAG,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,CAAC;AAEpE,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,EAAE;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,sBAAsB,GAAG,MAAM,IAAI,CAAC;CAIxF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B;sBAXvB,OAAO;iCACI,WAAW,WAAW,sBAAsB,GAAG,MAAM,IAAI;EAUf,CAAC;AAE1E,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EAC9C,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE;;;EAoBhC;AAED,MAAM,WAAW,oCAAoC;IACnD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,kBAAkB,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;IAC7C,mBAAmB,CAAC,CAAC,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAC;IACzD,mBAAmB,CAAC,CAAC,gBAAgB,EAAE,OAAO,GAAG,IAAI,CAAC;IACtD,qBAAqB,CAAC,CAAC,gBAAgB,EAAE,OAAO,GAAG,IAAI,CAAC;CACzD;AAED,MAAM,WAAW,0BAA0B;IACzC,iBAAiB,IAAI,IAAI,CAAC;IAC1B,cAAc,IAAI,IAAI,GAAG,WAAW,CAAC;IACrC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;CACzC;AAED,eAAO,MAAM,+BAA+B,yHAsE3C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { createContext, useContext, useLayoutEffect, useState } from 'react';
|
|
3
|
+
import React, { createContext, useContext, useLayoutEffect, useRef, useState, useImperativeHandle, forwardRef, } from 'react';
|
|
4
4
|
export const defaultValue = {
|
|
5
5
|
navigationActive: false,
|
|
6
6
|
registerFocusable: () => () => { },
|
|
@@ -28,4 +28,54 @@ export function useSingleTabStopNavigation(focusable, options) {
|
|
|
28
28
|
}
|
|
29
29
|
return { navigationActive, tabIndex };
|
|
30
30
|
}
|
|
31
|
+
export const SingleTabStopNavigationProvider = forwardRef(({ navigationActive, children, getNextFocusTarget, isElementSuppressed, onRegisterFocusable, onUnregisterFocusable, }, ref) => {
|
|
32
|
+
// A set of registered focusable elements that can use keyboard navigation.
|
|
33
|
+
const focusables = useRef(new Set());
|
|
34
|
+
// A map of registered focusable element handlers to update the respective tab indices.
|
|
35
|
+
const focusHandlers = useRef(new Map());
|
|
36
|
+
// A map of focusable element states to avoid issuing unnecessary updates to registered elements.
|
|
37
|
+
const focusablesState = useRef(new WeakMap());
|
|
38
|
+
// A reference to the currently focused element.
|
|
39
|
+
const focusTarget = useRef(null);
|
|
40
|
+
// Register a focusable element to allow navigating into it.
|
|
41
|
+
// The focusable element tabIndex is only set to 0 if the element matches the focus target.
|
|
42
|
+
function registerFocusable(focusableElement, changeHandler) {
|
|
43
|
+
focusables.current.add(focusableElement);
|
|
44
|
+
focusHandlers.current.set(focusableElement, changeHandler);
|
|
45
|
+
const isFocusable = !!focusablesState.current.get(focusableElement);
|
|
46
|
+
const newIsFocusable = focusTarget.current === focusableElement || !!(isElementSuppressed === null || isElementSuppressed === void 0 ? void 0 : isElementSuppressed(focusableElement));
|
|
47
|
+
if (newIsFocusable !== isFocusable) {
|
|
48
|
+
focusablesState.current.set(focusableElement, newIsFocusable);
|
|
49
|
+
changeHandler(newIsFocusable);
|
|
50
|
+
}
|
|
51
|
+
onRegisterFocusable === null || onRegisterFocusable === void 0 ? void 0 : onRegisterFocusable(focusableElement);
|
|
52
|
+
return () => unregisterFocusable(focusableElement);
|
|
53
|
+
}
|
|
54
|
+
function unregisterFocusable(focusableElement) {
|
|
55
|
+
focusables.current.delete(focusableElement);
|
|
56
|
+
focusHandlers.current.delete(focusableElement);
|
|
57
|
+
onUnregisterFocusable === null || onUnregisterFocusable === void 0 ? void 0 : onUnregisterFocusable(focusableElement);
|
|
58
|
+
}
|
|
59
|
+
// Update focus target with next single focusable element and notify all registered focusables of a change.
|
|
60
|
+
function updateFocusTarget() {
|
|
61
|
+
var _a;
|
|
62
|
+
focusTarget.current = getNextFocusTarget();
|
|
63
|
+
for (const focusableElement of focusables.current) {
|
|
64
|
+
const isFocusable = (_a = focusablesState.current.get(focusableElement)) !== null && _a !== void 0 ? _a : false;
|
|
65
|
+
const newIsFocusable = focusTarget.current === focusableElement || !!(isElementSuppressed === null || isElementSuppressed === void 0 ? void 0 : isElementSuppressed(focusableElement));
|
|
66
|
+
if (newIsFocusable !== isFocusable) {
|
|
67
|
+
focusablesState.current.set(focusableElement, newIsFocusable);
|
|
68
|
+
focusHandlers.current.get(focusableElement)(newIsFocusable);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function getFocusTarget() {
|
|
73
|
+
return focusTarget.current;
|
|
74
|
+
}
|
|
75
|
+
function isRegistered(element) {
|
|
76
|
+
return focusables.current.has(element);
|
|
77
|
+
}
|
|
78
|
+
useImperativeHandle(ref, () => ({ updateFocusTarget, getFocusTarget, isRegistered }));
|
|
79
|
+
return (React.createElement(SingleTabStopNavigationContext.Provider, { value: { navigationActive, registerFocusable } }, children));
|
|
80
|
+
});
|
|
31
81
|
//# sourceMappingURL=single-tab-stop-navigation-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-tab-stop-navigation-context.js","sourceRoot":"","sources":["../../../../src/internal/context/single-tab-stop-navigation-context.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"single-tab-stop-navigation-context.js","sourceRoot":"","sources":["../../../../src/internal/context/single-tab-stop-navigation-context.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,UAAU,EACV,eAAe,EACf,MAAM,EACN,QAAQ,EACR,mBAAmB,EACnB,UAAU,GACX,MAAM,OAAO,CAAC;AAQf,MAAM,CAAC,MAAM,YAAY,GAGrB;IACF,gBAAgB,EAAE,KAAK;IACvB,iBAAiB,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAE,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;AAE1E,MAAM,UAAU,0BAA0B,CACxC,SAA8C,EAC9C,OAA+B;;IAE/B,MAAM,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,8BAA8B,CAAC,CAAC;IACpH,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClE,MAAM,kBAAkB,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,KAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,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3E,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,KAAK,gBAAgB,IAAI,CAAC,CAAC,CAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAG,gBAAgB,CAAC,CAAA,CAAC;YAC7G,IAAI,cAAc,KAAK,WAAW,EAAE;gBAClC,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;gBAC9D,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAE,CAAC,cAAc,CAAC,CAAC;aAC9D;SACF;IACH,CAAC;IAED,SAAS,cAAc;QACrB,OAAO,WAAW,CAAC,OAAO,CAAC;IAC7B,CAAC;IAED,SAAS,YAAY,CAAC,OAAgB;QACpC,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;IAEtF,OAAO,CACL,oBAAC,8BAA8B,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,IACpF,QAAQ,CAC+B,CAC3C,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, {\n createContext,\n useContext,\n useLayoutEffect,\n useRef,\n useState,\n useImperativeHandle,\n forwardRef,\n} from 'react';\n\nexport type FocusableChangeHandler = (isFocusable: boolean) => void;\n\nexport interface SingleTabStopNavigationOptions {\n tabIndex?: number;\n}\n\nexport const defaultValue: {\n navigationActive: boolean;\n registerFocusable(focusable: HTMLElement, handler: FocusableChangeHandler): () => void;\n} = {\n navigationActive: false,\n registerFocusable: () => () => {},\n};\n\n/**\n * Single tab stop navigation context is used together with keyboard navigation that requires a single tab stop.\n * It instructs interactive elements to override tab indices for just a single one to remain user-focusable.\n */\nexport const SingleTabStopNavigationContext = createContext(defaultValue);\n\nexport function useSingleTabStopNavigation(\n focusable: null | React.RefObject<HTMLElement>,\n options?: { tabIndex?: number }\n) {\n const { navigationActive: contextNavigationActive, registerFocusable } = useContext(SingleTabStopNavigationContext);\n const [focusTargetActive, setFocusTargetActive] = useState(false);\n const navigationDisabled = options?.tabIndex && options?.tabIndex < 0;\n const navigationActive = contextNavigationActive && !navigationDisabled;\n\n useLayoutEffect(() => {\n if (navigationActive && focusable && focusable.current) {\n const unregister = registerFocusable(focusable.current, isFocusable => setFocusTargetActive(isFocusable));\n return () => unregister();\n }\n });\n\n let tabIndex = options?.tabIndex;\n if (navigationActive) {\n tabIndex = !focusTargetActive ? -1 : options?.tabIndex ?? 0;\n }\n\n return { navigationActive, tabIndex };\n}\n\nexport interface SingleTabStopNavigationProviderProps {\n navigationActive: boolean;\n children: React.ReactNode;\n getNextFocusTarget: () => null | HTMLElement;\n isElementSuppressed?(focusableElement: Element): boolean;\n onRegisterFocusable?(focusableElement: Element): void;\n onUnregisterFocusable?(focusableElement: Element): void;\n}\n\nexport interface SingleTabStopNavigationAPI {\n updateFocusTarget(): void;\n getFocusTarget(): null | HTMLElement;\n isRegistered(element: Element): boolean;\n}\n\nexport const SingleTabStopNavigationProvider = forwardRef(\n (\n {\n navigationActive,\n children,\n getNextFocusTarget,\n isElementSuppressed,\n onRegisterFocusable,\n onUnregisterFocusable,\n }: SingleTabStopNavigationProviderProps,\n ref: React.Ref<SingleTabStopNavigationAPI>\n ) => {\n // A set of registered focusable elements that can use keyboard navigation.\n const focusables = useRef(new Set<Element>());\n // A map of registered focusable element handlers to update the respective tab indices.\n const focusHandlers = useRef(new Map<Element, FocusableChangeHandler>());\n // A map of focusable element states to avoid issuing unnecessary updates to registered elements.\n const focusablesState = useRef(new WeakMap<Element, boolean>());\n // A reference to the currently focused element.\n const focusTarget = useRef<null | HTMLElement>(null);\n\n // Register a focusable element to allow navigating into it.\n // The focusable element tabIndex is only set to 0 if the element matches the focus target.\n function registerFocusable(focusableElement: Element, changeHandler: FocusableChangeHandler) {\n focusables.current.add(focusableElement);\n focusHandlers.current.set(focusableElement, changeHandler);\n const isFocusable = !!focusablesState.current.get(focusableElement);\n const newIsFocusable = focusTarget.current === focusableElement || !!isElementSuppressed?.(focusableElement);\n if (newIsFocusable !== isFocusable) {\n focusablesState.current.set(focusableElement, newIsFocusable);\n changeHandler(newIsFocusable);\n }\n onRegisterFocusable?.(focusableElement);\n return () => unregisterFocusable(focusableElement);\n }\n function unregisterFocusable(focusableElement: Element) {\n focusables.current.delete(focusableElement);\n focusHandlers.current.delete(focusableElement);\n onUnregisterFocusable?.(focusableElement);\n }\n\n // Update focus target with next single focusable element and notify all registered focusables of a change.\n function updateFocusTarget() {\n focusTarget.current = getNextFocusTarget();\n for (const focusableElement of focusables.current) {\n const isFocusable = focusablesState.current.get(focusableElement) ?? false;\n const newIsFocusable = focusTarget.current === focusableElement || !!isElementSuppressed?.(focusableElement);\n if (newIsFocusable !== isFocusable) {\n focusablesState.current.set(focusableElement, newIsFocusable);\n focusHandlers.current.get(focusableElement)!(newIsFocusable);\n }\n }\n }\n\n function getFocusTarget() {\n return focusTarget.current;\n }\n\n function isRegistered(element: Element) {\n return focusables.current.has(element);\n }\n\n useImperativeHandle(ref, () => ({ updateFocusTarget, getFocusTarget, isRegistered }));\n\n return (\n <SingleTabStopNavigationContext.Provider value={{ navigationActive, registerFocusable }}>\n {children}\n </SingleTabStopNavigationContext.Provider>\n );\n }\n);\n"]}
|
package/internal/environment.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface UseTableInteractionMetricsProps {
|
|
2
|
+
instanceIdentifier: string | undefined;
|
|
3
|
+
loading: boolean | undefined;
|
|
4
|
+
itemCount: number;
|
|
5
|
+
getComponentIdentifier: () => string | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare function useTableInteractionMetrics({ itemCount, instanceIdentifier, getComponentIdentifier, loading, }: UseTableInteractionMetricsProps): {
|
|
8
|
+
setLastUserAction: (name: string) => undefined;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,+BAA+B;IAC9C,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CAClD;AAED,wBAAgB,0BAA0B,CAAC,EACzC,SAAS,EACT,kBAAkB,EAClB,sBAAsB,EACtB,OAAe,GAChB,EAAE,+BAA+B;8BAqCJ,MAAM;EAEnC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import { useEffectOnUpdate } from '../use-effect-on-update';
|
|
5
|
+
import { PerformanceMetrics } from '../../analytics';
|
|
6
|
+
/*
|
|
7
|
+
If the last user interaction is more than this time ago, it is not considered
|
|
8
|
+
to be the cause of the current loading state.
|
|
9
|
+
*/
|
|
10
|
+
const USER_ACTION_TIME_LIMIT = 1000;
|
|
11
|
+
export function useTableInteractionMetrics({ itemCount, instanceIdentifier, getComponentIdentifier, loading = false, }) {
|
|
12
|
+
const lastUserAction = useRef(null);
|
|
13
|
+
const capturedUserAction = useRef(null);
|
|
14
|
+
const loadingStartTime = useRef(null);
|
|
15
|
+
const metadata = useRef({ itemCount, getComponentIdentifier });
|
|
16
|
+
metadata.current = { itemCount, getComponentIdentifier };
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (loading) {
|
|
19
|
+
loadingStartTime.current = performance.now();
|
|
20
|
+
if (lastUserAction.current && lastUserAction.current.time > performance.now() - USER_ACTION_TIME_LIMIT) {
|
|
21
|
+
capturedUserAction.current = lastUserAction.current.name;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
capturedUserAction.current = null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, [loading]);
|
|
28
|
+
useEffectOnUpdate(() => {
|
|
29
|
+
var _a;
|
|
30
|
+
if (!loading && loadingStartTime.current !== null) {
|
|
31
|
+
const loadingDuration = performance.now() - loadingStartTime.current;
|
|
32
|
+
loadingStartTime.current = null;
|
|
33
|
+
PerformanceMetrics.tableInteraction({
|
|
34
|
+
userAction: (_a = capturedUserAction.current) !== null && _a !== void 0 ? _a : '',
|
|
35
|
+
interactionTime: Math.round(loadingDuration),
|
|
36
|
+
interactionMetadata: undefined,
|
|
37
|
+
componentIdentifier: metadata.current.getComponentIdentifier(),
|
|
38
|
+
instanceIdentifier,
|
|
39
|
+
noOfResourcesInTable: metadata.current.itemCount,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}, [instanceIdentifier, loading]);
|
|
43
|
+
return {
|
|
44
|
+
setLastUserAction: (name) => void (lastUserAction.current = { name, time: performance.now() }),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;EAGE;AACF,MAAM,sBAAsB,GAAG,IAAK,CAAC;AASrC,M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mB,EAAE,SAAS;gBAC9B,mBAAmB,EAAE,QAAQ,CAAC,OAAO,CAAC,sBAAsB,EAAE;gBAC9D,kBAAkB;gBAClB,oBAAoB,EAAE,QAAQ,CAAC,OAAO,CAAC,SAAS;aACjD,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,CAAC;IAElC,OAAO;QACL,iBAAiB,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,EAAE,CAAC;KACvG,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useEffect, useRef } from 'react';\nimport { useEffectOnUpdate } from '../use-effect-on-update';\nimport { PerformanceMetrics } from '../../analytics';\n\n/*\nIf the last user interaction is more than this time ago, it is not considered\nto be the cause of the current loading state.\n*/\nconst USER_ACTION_TIME_LIMIT = 1_000;\n\nexport interface UseTableInteractionMetricsProps {\n instanceIdentifier: string | undefined;\n loading: boolean | undefined;\n itemCount: number;\n getComponentIdentifier: () => string | undefined;\n}\n\nexport function useTableInteractionMetrics({\n itemCount,\n instanceIdentifier,\n getComponentIdentifier,\n loading = false,\n}: UseTableInteractionMetricsProps) {\n const lastUserAction = useRef<{ name: string; time: number } | null>(null);\n const capturedUserAction = useRef<string | null>(null);\n const loadingStartTime = useRef<number | null>(null);\n\n const metadata = useRef({ itemCount, getComponentIdentifier });\n metadata.current = { itemCount, getComponentIdentifier };\n\n useEffect(() => {\n if (loading) {\n loadingStartTime.current = performance.now();\n\n if (lastUserAction.current && lastUserAction.current.time > performance.now() - USER_ACTION_TIME_LIMIT) {\n capturedUserAction.current = lastUserAction.current.name;\n } else {\n capturedUserAction.current = null;\n }\n }\n }, [loading]);\n\n useEffectOnUpdate(() => {\n if (!loading && loadingStartTime.current !== null) {\n const loadingDuration = performance.now() - loadingStartTime.current;\n loadingStartTime.current = null;\n\n PerformanceMetrics.tableInteraction({\n userAction: capturedUserAction.current ?? '',\n interactionTime: Math.round(loadingDuration),\n interactionMetadata: undefined,\n componentIdentifier: metadata.current.getComponentIdentifier(),\n instanceIdentifier,\n noOfResourcesInTable: metadata.current.itemCount,\n });\n }\n }, [instanceIdentifier, loading]);\n\n return {\n setLastUserAction: (name: string) => void (lastUserAction.current = { name, time: performance.now() }),\n };\n}\n"]}
|
package/internal/manifest.json
CHANGED
package/package.json
CHANGED
package/popover/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PopoverProps } from './interfaces';
|
|
3
3
|
export { PopoverProps };
|
|
4
|
-
export default function Popover({ position, size, fixedWidth, triggerType, dismissButton, renderWithPortal, header, ...rest }: PopoverProps): JSX.Element;
|
|
4
|
+
export default function Popover({ position, size, fixedWidth, triggerType, dismissButton, renderWithPortal, wrapTriggerText, header, ...rest }: PopoverProps): JSX.Element;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/popover/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/popover/index.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,QAAkB,EAClB,IAAe,EACf,UAAkB,EAClB,WAAoB,EACpB,aAAoB,EACpB,gBAAwB,EACxB,MAAM,EACN,GAAG,IAAI,EACR,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/popover/index.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,QAAkB,EAClB,IAAe,EACf,UAAkB,EAClB,WAAoB,EACpB,aAAoB,EACpB,gBAAwB,EACxB,eAAsB,EACtB,MAAM,EACN,GAAG,IAAI,EACR,EAAE,YAAY,eAyBd"}
|
package/popover/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import useBaseComponent from '../internal/hooks/use-base-component';
|
|
|
9
9
|
import { isDevelopment } from '../internal/is-development';
|
|
10
10
|
import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
|
|
11
11
|
export default function Popover(_a) {
|
|
12
|
-
var { position = 'right', size = 'medium', fixedWidth = false, triggerType = 'text', dismissButton = true, renderWithPortal = false, header } = _a, rest = __rest(_a, ["position", "size", "fixedWidth", "triggerType", "dismissButton", "renderWithPortal", "header"]);
|
|
12
|
+
var { position = 'right', size = 'medium', fixedWidth = false, triggerType = 'text', dismissButton = true, renderWithPortal = false, wrapTriggerText = true, header } = _a, rest = __rest(_a, ["position", "size", "fixedWidth", "triggerType", "dismissButton", "renderWithPortal", "wrapTriggerText", "header"]);
|
|
13
13
|
if (isDevelopment) {
|
|
14
14
|
if (dismissButton && !header) {
|
|
15
15
|
warnOnce('Popover', `You should provide a \`header\` when \`dismissButton\` is true.`);
|
|
@@ -19,7 +19,7 @@ export default function Popover(_a) {
|
|
|
19
19
|
props: { dismissButton, fixedWidth, position, renderWithPortal, size, triggerType },
|
|
20
20
|
});
|
|
21
21
|
const externalProps = getExternalProps(rest);
|
|
22
|
-
return (React.createElement(InternalPopover, Object.assign({ header: header, position: position, size: size, fixedWidth: fixedWidth, triggerType: triggerType, dismissButton: dismissButton, renderWithPortal: renderWithPortal }, externalProps, baseComponentProps)));
|
|
22
|
+
return (React.createElement(InternalPopover, Object.assign({ header: header, position: position, size: size, fixedWidth: fixedWidth, triggerType: triggerType, dismissButton: dismissButton, renderWithPortal: renderWithPortal, wrapTriggerText: wrapTriggerText }, externalProps, baseComponentProps)));
|
|
23
23
|
}
|
|
24
24
|
applyDisplayName(Popover, 'Popover');
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
package/popover/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/popover/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAKzE,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/popover/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAKzE,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAUjB;QAViB,EAC9B,QAAQ,GAAG,OAAO,EAClB,IAAI,GAAG,QAAQ,EACf,UAAU,GAAG,KAAK,EAClB,WAAW,GAAG,MAAM,EACpB,aAAa,GAAG,IAAI,EACpB,gBAAgB,GAAG,KAAK,EACxB,eAAe,GAAG,IAAI,EACtB,MAAM,OAEO,EADV,IAAI,cATuB,mHAU/B,CADQ;IAEP,IAAI,aAAa,EAAE;QACjB,IAAI,aAAa,IAAI,CAAC,MAAM,EAAE;YAC5B,QAAQ,CAAC,SAAS,EAAE,iEAAiE,CAAC,CAAC;SACxF;KACF;IAED,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,SAAS,EAAE;QACrD,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,EAAE;KACpF,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,CACL,oBAAC,eAAe,kBACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,eAAe,EAAE,eAAe,IAC5B,aAAa,EACb,kBAAkB,EACtB,CACH,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport InternalPopover from './internal';\nimport { getExternalProps } from '../internal/utils/external-props';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { isDevelopment } from '../internal/is-development';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { PopoverProps } from './interfaces';\n\nexport { PopoverProps };\n\nexport default function Popover({\n position = 'right',\n size = 'medium',\n fixedWidth = false,\n triggerType = 'text',\n dismissButton = true,\n renderWithPortal = false,\n wrapTriggerText = true,\n header,\n ...rest\n}: PopoverProps) {\n if (isDevelopment) {\n if (dismissButton && !header) {\n warnOnce('Popover', `You should provide a \\`header\\` when \\`dismissButton\\` is true.`);\n }\n }\n\n const baseComponentProps = useBaseComponent('Popover', {\n props: { dismissButton, fixedWidth, position, renderWithPortal, size, triggerType },\n });\n const externalProps = getExternalProps(rest);\n return (\n <InternalPopover\n header={header}\n position={position}\n size={size}\n fixedWidth={fixedWidth}\n triggerType={triggerType}\n dismissButton={dismissButton}\n renderWithPortal={renderWithPortal}\n wrapTriggerText={wrapTriggerText}\n {...externalProps}\n {...baseComponentProps}\n />\n );\n}\n\napplyDisplayName(Popover, 'Popover');\n"]}
|
package/popover/interfaces.d.ts
CHANGED
|
@@ -27,6 +27,11 @@ export interface PopoverProps extends BaseComponentProps {
|
|
|
27
27
|
* that don't have visible text, and to distinguish between multiple triggers with identical visible text.
|
|
28
28
|
*/
|
|
29
29
|
triggerAriaLabel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Specifies if the text trigger content should wrap. If you set it to false, it prevents the text from
|
|
32
|
+
* wrapping and truncates it with an ellipsis.
|
|
33
|
+
*/
|
|
34
|
+
wrapTriggerText?: boolean;
|
|
30
35
|
/**
|
|
31
36
|
* Element that triggers the popover when selected by the user.
|
|
32
37
|
* @displayname trigger
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/popover/interfaces.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,WAAW,YAAa,SAAQ,kBAAkB;IACtD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC;IAEjC;;OAEG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC;IAEzB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,WAAW,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC;IAEvC;;;OAGG;IACH,gBAAgB,CAAC,E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 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/popover/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\n\nexport interface PopoverProps extends BaseComponentProps {\n /**\n * Determines where the popover is displayed when opened, relative to the trigger.\n * If the popover doesn't have enough space to open in this direction, it\n * automatically chooses a better direction based on available space.\n */\n position?: PopoverProps.Position;\n\n /**\n * Determines the maximum width for the popover.\n */\n size?: PopoverProps.Size;\n\n /**\n * Expands the popover body to its maximum width regardless of content.\n * For example, use it when you need to place a column layout in the popover content.\n */\n fixedWidth?: boolean;\n\n /**\n * Specifies the type of content inside the trigger region. The following types are available:\n * - `text` - Use for inline text triggers.\n * - `custom` - Use for the [button](/components/button/) component.\n */\n triggerType?: PopoverProps.TriggerType;\n\n /**\n * Adds `aria-label` to the text trigger button. Use this to provide an accessible name for triggers\n * that don't have visible text, and to distinguish between multiple triggers with identical visible text.\n */\n triggerAriaLabel?: string;\n\n /**\n * Element that triggers the popover when selected by the user.\n * @displayname trigger\n */\n children?: React.ReactNode;\n\n /**\n * Specifies optional header text for the popover.\n */\n header?: string;\n\n /**\n * Content of the popover.\n */\n content?: React.ReactNode;\n\n /**\n * Determines whether the dismiss button is shown in the popover body.\n */\n dismissButton?: boolean;\n\n /**\n * Adds an `aria-label` to the dismiss button for accessibility.\n * @i18n\n */\n dismissAriaLabel?: string;\n\n /**\n * By default, the popover is constrained to fit inside its parent\n * [stacking context](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context).\n * Enabling this property will allow the popover to be rendered in the root stack context using\n * [React Portals](https://reactjs.org/docs/portals.html).\n * Enable this setting if you need the popover to ignore its parent stacking context, such as in side navigation.\n *\n * Note: Using popover rendered with portal within a Modal is not supported.\n */\n renderWithPortal?: boolean;\n}\n\n/**\n * The position the popover is actually in, given space constraints.\n */\nexport type InternalPosition =\n | 'right-top'\n | 'right-bottom'\n | 'left-top'\n | 'left-bottom'\n | 'top-center'\n | 'top-right'\n | 'top-left'\n | 'bottom-center'\n | 'bottom-right'\n | 'bottom-left';\n\nexport interface Offset {\n insetInlineStart: number;\n insetBlockStart: number;\n}\n\nexport interface Dimensions {\n inlineSize: number;\n blockSize: number;\n}\n\nexport type BoundingBox = Dimensions & Offset;\n\nexport namespace PopoverProps {\n export type Position = 'top' | 'right' | 'bottom' | 'left';\n export type Size = 'small' | 'medium' | 'large';\n export type TriggerType = 'text' | 'custom';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/popover/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\n\nexport interface PopoverProps extends BaseComponentProps {\n /**\n * Determines where the popover is displayed when opened, relative to the trigger.\n * If the popover doesn't have enough space to open in this direction, it\n * automatically chooses a better direction based on available space.\n */\n position?: PopoverProps.Position;\n\n /**\n * Determines the maximum width for the popover.\n */\n size?: PopoverProps.Size;\n\n /**\n * Expands the popover body to its maximum width regardless of content.\n * For example, use it when you need to place a column layout in the popover content.\n */\n fixedWidth?: boolean;\n\n /**\n * Specifies the type of content inside the trigger region. The following types are available:\n * - `text` - Use for inline text triggers.\n * - `custom` - Use for the [button](/components/button/) component.\n */\n triggerType?: PopoverProps.TriggerType;\n\n /**\n * Adds `aria-label` to the text trigger button. Use this to provide an accessible name for triggers\n * that don't have visible text, and to distinguish between multiple triggers with identical visible text.\n */\n triggerAriaLabel?: string;\n\n /**\n * Specifies if the text trigger content should wrap. If you set it to false, it prevents the text from\n * wrapping and truncates it with an ellipsis.\n */\n wrapTriggerText?: boolean;\n\n /**\n * Element that triggers the popover when selected by the user.\n * @displayname trigger\n */\n children?: React.ReactNode;\n\n /**\n * Specifies optional header text for the popover.\n */\n header?: string;\n\n /**\n * Content of the popover.\n */\n content?: React.ReactNode;\n\n /**\n * Determines whether the dismiss button is shown in the popover body.\n */\n dismissButton?: boolean;\n\n /**\n * Adds an `aria-label` to the dismiss button for accessibility.\n * @i18n\n */\n dismissAriaLabel?: string;\n\n /**\n * By default, the popover is constrained to fit inside its parent\n * [stacking context](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context).\n * Enabling this property will allow the popover to be rendered in the root stack context using\n * [React Portals](https://reactjs.org/docs/portals.html).\n * Enable this setting if you need the popover to ignore its parent stacking context, such as in side navigation.\n *\n * Note: Using popover rendered with portal within a Modal is not supported.\n */\n renderWithPortal?: boolean;\n}\n\n/**\n * The position the popover is actually in, given space constraints.\n */\nexport type InternalPosition =\n | 'right-top'\n | 'right-bottom'\n | 'left-top'\n | 'left-bottom'\n | 'top-center'\n | 'top-right'\n | 'top-left'\n | 'bottom-center'\n | 'bottom-right'\n | 'bottom-left';\n\nexport interface Offset {\n insetInlineStart: number;\n insetBlockStart: number;\n}\n\nexport interface Dimensions {\n inlineSize: number;\n blockSize: number;\n}\n\nexport type BoundingBox = Dimensions & Offset;\n\nexport namespace PopoverProps {\n export type Position = 'top' | 'right' | 'bottom' | 'left';\n export type Size = 'small' | 'medium' | 'large';\n export type TriggerType = 'text' | 'custom';\n}\n"]}
|
package/popover/internal.js
CHANGED
|
@@ -21,7 +21,7 @@ import ResetContextsForModal from '../internal/context/reset-contexts-for-modal'
|
|
|
21
21
|
import { useSingleTabStopNavigation } from '../internal/context/single-tab-stop-navigation-context';
|
|
22
22
|
export default React.forwardRef(InternalPopover);
|
|
23
23
|
function InternalPopover(_a, ref) {
|
|
24
|
-
var { position = 'right', size = 'medium', fixedWidth = false, triggerType = 'text', dismissButton = true, children, header, content, triggerAriaLabel, renderWithPortal = false, __onOpen, __internalRootRef = null } = _a, restProps = __rest(_a, ["position", "size", "fixedWidth", "triggerType", "dismissButton", "children", "header", "content", "triggerAriaLabel", "renderWithPortal", "__onOpen", "__internalRootRef"]);
|
|
24
|
+
var { position = 'right', size = 'medium', fixedWidth = false, triggerType = 'text', dismissButton = true, children, header, content, triggerAriaLabel, wrapTriggerText = true, renderWithPortal = false, __onOpen, __internalRootRef = null } = _a, restProps = __rest(_a, ["position", "size", "fixedWidth", "triggerType", "dismissButton", "children", "header", "content", "triggerAriaLabel", "wrapTriggerText", "renderWithPortal", "__onOpen", "__internalRootRef"]);
|
|
25
25
|
const baseProps = getBaseProps(restProps);
|
|
26
26
|
const triggerRef = useRef(null);
|
|
27
27
|
const popoverRef = useRef(null);
|
|
@@ -96,7 +96,7 @@ function InternalPopover(_a, ref) {
|
|
|
96
96
|
clickFrameId.current = null;
|
|
97
97
|
});
|
|
98
98
|
} }),
|
|
99
|
-
triggerType === 'text' ? (React.createElement("button", Object.assign({}, triggerProps, { tabIndex: triggerTabIndex, type: "button", "aria-haspopup": "dialog", id: referrerId, "aria-label": triggerAriaLabel }), children)) : (React.createElement("span", Object.assign({}, triggerProps, { id: referrerId }), children)),
|
|
99
|
+
triggerType === 'text' ? (React.createElement("button", Object.assign({}, triggerProps, { className: clsx(triggerProps.className, wrapTriggerText === false && styles['overflow-ellipsis']), tabIndex: triggerTabIndex, type: "button", "aria-haspopup": "dialog", id: referrerId, "aria-label": triggerAriaLabel }), children)) : (React.createElement("span", Object.assign({}, triggerProps, { id: referrerId }), children)),
|
|
100
100
|
React.createElement(ResetContextsForModal, null, renderWithPortal ? React.createElement(Portal, null, popoverContent) : popoverContent)));
|
|
101
101
|
}
|
|
102
102
|
//# sourceMappingURL=internal.js.map
|
package/popover/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/popover/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE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,CAAC,GAAG,EAAE;gBAChD,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;YAC9B,CAAC,CAAC,CAAC;QACL,CAAC;QAEA,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,CACxB,gDACM,YAAY,IAChB,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAC,QAAQ,mBACC,QAAQ,EACtB,EAAE,EAAE,UAAU,gBACF,gBAAgB,KAE3B,QAAQ,CACF,CACV,CAAC,CAAC,CAAC,CACF,8CAAU,YAAY,IAAE,EAAE,EAAE,UAAU,KACnC,QAAQ,CACJ,CACR;QACD,oBAAC,qBAAqB,QACnB,gBAAgB,CAAC,CAAC,CAAC,oBAAC,MAAM,QAAE,cAAc,CAAU,CAAC,CAAC,CAAC,cAAc,CAChD,CACnB,CACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useRef, useState, useImperativeHandle } from 'react';\nimport clsx from 'clsx';\n\nimport { KeyCode } from '../internal/keycode';\nimport { getBaseProps } from '../internal/base-component';\n\nimport Arrow from './arrow';\nimport Portal from '../internal/components/portal';\nimport { PopoverProps } from './interfaces';\nimport PopoverContainer from './container';\nimport PopoverBody from './body';\n\nimport styles from './styles.css.js';\nimport { NonCancelableEventHandler, fireNonCancelableEvent } from '../internal/events/index';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { usePortalModeClasses } from '../internal/hooks/use-portal-mode-classes';\nimport { useInternalI18n } from '../i18n/context';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { getFirstFocusable } from '../internal/components/focus-lock/utils';\nimport { LinkDefaultVariantContext } from '../internal/context/link-default-variant-context';\nimport ResetContextsForModal from '../internal/context/reset-contexts-for-modal';\nimport { useSingleTabStopNavigation } from '../internal/context/single-tab-stop-navigation-context';\n\nexport interface InternalPopoverProps extends PopoverProps, InternalBaseComponentProps {\n __onOpen?: NonCancelableEventHandler<null>;\n}\n\nexport interface InternalPopoverRef {\n dismissPopover: () => void;\n}\n\nexport default React.forwardRef(InternalPopover);\n\nfunction InternalPopover(\n {\n position = 'right',\n size = 'medium',\n fixedWidth = false,\n triggerType = 'text',\n dismissButton = true,\n\n children,\n header,\n content,\n triggerAriaLabel,\n\n renderWithPortal = false,\n\n __onOpen,\n __internalRootRef = null,\n ...restProps\n }: InternalPopoverProps,\n ref: React.Ref<InternalPopoverRef>\n) {\n const baseProps = getBaseProps(restProps);\n const triggerRef = useRef<HTMLElement | null>(null);\n const popoverRef = useRef<HTMLDivElement | null>(null);\n const clickFrameId = useRef<number | null>(null);\n\n const i18n = useInternalI18n('popover');\n const dismissAriaLabel = i18n('dismissAriaLabel', restProps.dismissAriaLabel);\n\n const [visible, setVisible] = useState(false);\n\n const focusTrigger = useCallback(() => {\n if (triggerType === 'text') {\n triggerRef.current?.focus();\n } else {\n triggerRef.current && getFirstFocusable(triggerRef.current)?.focus();\n }\n }, [triggerType]);\n\n const onTriggerClick = useCallback(() => {\n fireNonCancelableEvent(__onOpen);\n setVisible(true);\n }, [__onOpen]);\n\n const onDismiss = useCallback(() => {\n setVisible(false);\n focusTrigger();\n }, [focusTrigger]);\n\n const onTriggerKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n const isEscapeKey = event.keyCode === KeyCode.escape;\n const isTabKey = event.keyCode === KeyCode.tab;\n if (isEscapeKey && visible) {\n event.stopPropagation();\n }\n if (isTabKey || isEscapeKey) {\n setVisible(false);\n }\n },\n [visible]\n );\n\n useImperativeHandle(ref, () => ({\n dismissPopover: onDismiss,\n }));\n\n useEffect(() => {\n if (!triggerRef.current) {\n return;\n }\n const document = triggerRef.current.ownerDocument;\n\n const onDocumentClick = () => {\n // Dismiss popover unless there was a click inside within the last animation frame.\n if (clickFrameId.current === null) {\n setVisible(false);\n }\n };\n\n document.addEventListener('mousedown', onDocumentClick);\n\n return () => {\n document.removeEventListener('mousedown', onDocumentClick);\n };\n }, []);\n\n const popoverClasses = usePortalModeClasses(triggerRef);\n\n const triggerProps = {\n // https://github.com/microsoft/TypeScript/issues/36659\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref: triggerRef as any,\n onClick: onTriggerClick,\n onKeyDown: onTriggerKeyDown,\n className: clsx(styles.trigger, styles[`trigger-type-${triggerType}`]),\n };\n const { tabIndex: triggerTabIndex } = useSingleTabStopNavigation(triggerRef);\n\n const referrerId = useUniqueId();\n\n const popoverContent = (\n <div\n aria-live={dismissButton ? undefined : 'polite'}\n aria-atomic={dismissButton ? undefined : true}\n className={clsx(popoverClasses, !renderWithPortal && styles['popover-inline-content'])}\n data-awsui-referrer-id={referrerId}\n >\n {visible && (\n <PopoverContainer\n size={size}\n fixedWidth={fixedWidth}\n position={position}\n trackRef={triggerRef}\n arrow={position => <Arrow position={position} />}\n renderWithPortal={renderWithPortal}\n zIndex={renderWithPortal ? 7000 : undefined}\n >\n <LinkDefaultVariantContext.Provider value={{ defaultVariant: 'primary' }}>\n <PopoverBody\n dismissButton={dismissButton}\n dismissAriaLabel={dismissAriaLabel}\n header={header}\n onDismiss={onDismiss}\n overflowVisible=\"both\"\n >\n {content}\n </PopoverBody>\n </LinkDefaultVariantContext.Provider>\n </PopoverContainer>\n )}\n </div>\n );\n\n const mergedRef = useMergeRefs(popoverRef, __internalRootRef);\n\n return (\n <span\n {...baseProps}\n className={clsx(styles.root, baseProps.className)}\n ref={mergedRef}\n onMouseDown={() => {\n // Indicate there was a click inside popover recently, including nested portals.\n clickFrameId.current = requestAnimationFrame(() => {\n clickFrameId.current = null;\n });\n }}\n >\n {triggerType === 'text' ? (\n <button\n {...triggerProps}\n tabIndex={triggerTabIndex}\n type=\"button\"\n aria-haspopup=\"dialog\"\n id={referrerId}\n aria-label={triggerAriaLabel}\n >\n {children}\n </button>\n ) : (\n <span {...triggerProps} id={referrerId}>\n {children}\n </span>\n )}\n <ResetContextsForModal>\n {renderWithPortal ? <Portal>{popoverContent}</Portal> : popoverContent}\n </ResetContextsForModal>\n </span>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/popover/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC7F,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,MAAM,MAAM,+BAA+B,CAAC;AAEnD,OAAO,gBAAgB,MAAM,aAAa,CAAC;AAC3C,OAAO,WAAW,MAAM,QAAQ,CAAC;AAEjC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAA6B,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAE7F,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,qBAAqB,MAAM,8CAA8C,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,wDAAwD,CAAC;AAUpG,eAAe,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AAEjD,SAAS,eAAe,CACtB,EAkBuB,EACvB,GAAkC;QAnBlC,EACE,QAAQ,GAAG,OAAO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EF,MAAM,SAAS,GAAG,YAAY,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;IAE9D,OAAO,CACL,8CACM,SAAS,IACb,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,EACjD,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,GAAG,EAAE;YAChB,gFAAgF;YAChF,YAAY,CAAC,OAAO,GAAG,qBAAqB,CAAC,GAAG,EAAE;gBAChD,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;YAC9B,CAAC,CAAC,CAAC;QACL,CAAC;QAEA,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,CACxB,gDACM,YAAY,IAChB,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,eAAe,KAAK,KAAK,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC,EACjG,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAC,QAAQ,mBACC,QAAQ,EACtB,EAAE,EAAE,UAAU,gBACF,gBAAgB,KAE3B,QAAQ,CACF,CACV,CAAC,CAAC,CAAC,CACF,8CAAU,YAAY,IAAE,EAAE,EAAE,UAAU,KACnC,QAAQ,CACJ,CACR;QACD,oBAAC,qBAAqB,QACnB,gBAAgB,CAAC,CAAC,CAAC,oBAAC,MAAM,QAAE,cAAc,CAAU,CAAC,CAAC,CAAC,cAAc,CAChD,CACnB,CACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useRef, useState, useImperativeHandle } from 'react';\nimport clsx from 'clsx';\n\nimport { KeyCode } from '../internal/keycode';\nimport { getBaseProps } from '../internal/base-component';\n\nimport Arrow from './arrow';\nimport Portal from '../internal/components/portal';\nimport { PopoverProps } from './interfaces';\nimport PopoverContainer from './container';\nimport PopoverBody from './body';\n\nimport styles from './styles.css.js';\nimport { NonCancelableEventHandler, fireNonCancelableEvent } from '../internal/events/index';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { usePortalModeClasses } from '../internal/hooks/use-portal-mode-classes';\nimport { useInternalI18n } from '../i18n/context';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { getFirstFocusable } from '../internal/components/focus-lock/utils';\nimport { LinkDefaultVariantContext } from '../internal/context/link-default-variant-context';\nimport ResetContextsForModal from '../internal/context/reset-contexts-for-modal';\nimport { useSingleTabStopNavigation } from '../internal/context/single-tab-stop-navigation-context';\n\nexport interface InternalPopoverProps extends PopoverProps, InternalBaseComponentProps {\n __onOpen?: NonCancelableEventHandler<null>;\n}\n\nexport interface InternalPopoverRef {\n dismissPopover: () => void;\n}\n\nexport default React.forwardRef(InternalPopover);\n\nfunction InternalPopover(\n {\n position = 'right',\n size = 'medium',\n fixedWidth = false,\n triggerType = 'text',\n dismissButton = true,\n\n children,\n header,\n content,\n triggerAriaLabel,\n\n wrapTriggerText = true,\n renderWithPortal = false,\n\n __onOpen,\n __internalRootRef = null,\n ...restProps\n }: InternalPopoverProps,\n ref: React.Ref<InternalPopoverRef>\n) {\n const baseProps = getBaseProps(restProps);\n const triggerRef = useRef<HTMLElement | null>(null);\n const popoverRef = useRef<HTMLDivElement | null>(null);\n const clickFrameId = useRef<number | null>(null);\n\n const i18n = useInternalI18n('popover');\n const dismissAriaLabel = i18n('dismissAriaLabel', restProps.dismissAriaLabel);\n\n const [visible, setVisible] = useState(false);\n\n const focusTrigger = useCallback(() => {\n if (triggerType === 'text') {\n triggerRef.current?.focus();\n } else {\n triggerRef.current && getFirstFocusable(triggerRef.current)?.focus();\n }\n }, [triggerType]);\n\n const onTriggerClick = useCallback(() => {\n fireNonCancelableEvent(__onOpen);\n setVisible(true);\n }, [__onOpen]);\n\n const onDismiss = useCallback(() => {\n setVisible(false);\n focusTrigger();\n }, [focusTrigger]);\n\n const onTriggerKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n const isEscapeKey = event.keyCode === KeyCode.escape;\n const isTabKey = event.keyCode === KeyCode.tab;\n if (isEscapeKey && visible) {\n event.stopPropagation();\n }\n if (isTabKey || isEscapeKey) {\n setVisible(false);\n }\n },\n [visible]\n );\n\n useImperativeHandle(ref, () => ({\n dismissPopover: onDismiss,\n }));\n\n useEffect(() => {\n if (!triggerRef.current) {\n return;\n }\n const document = triggerRef.current.ownerDocument;\n\n const onDocumentClick = () => {\n // Dismiss popover unless there was a click inside within the last animation frame.\n if (clickFrameId.current === null) {\n setVisible(false);\n }\n };\n\n document.addEventListener('mousedown', onDocumentClick);\n\n return () => {\n document.removeEventListener('mousedown', onDocumentClick);\n };\n }, []);\n\n const popoverClasses = usePortalModeClasses(triggerRef);\n\n const triggerProps = {\n // https://github.com/microsoft/TypeScript/issues/36659\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref: triggerRef as any,\n onClick: onTriggerClick,\n onKeyDown: onTriggerKeyDown,\n className: clsx(styles.trigger, styles[`trigger-type-${triggerType}`]),\n };\n const { tabIndex: triggerTabIndex } = useSingleTabStopNavigation(triggerRef);\n\n const referrerId = useUniqueId();\n\n const popoverContent = (\n <div\n aria-live={dismissButton ? undefined : 'polite'}\n aria-atomic={dismissButton ? undefined : true}\n className={clsx(popoverClasses, !renderWithPortal && styles['popover-inline-content'])}\n data-awsui-referrer-id={referrerId}\n >\n {visible && (\n <PopoverContainer\n size={size}\n fixedWidth={fixedWidth}\n position={position}\n trackRef={triggerRef}\n arrow={position => <Arrow position={position} />}\n renderWithPortal={renderWithPortal}\n zIndex={renderWithPortal ? 7000 : undefined}\n >\n <LinkDefaultVariantContext.Provider value={{ defaultVariant: 'primary' }}>\n <PopoverBody\n dismissButton={dismissButton}\n dismissAriaLabel={dismissAriaLabel}\n header={header}\n onDismiss={onDismiss}\n overflowVisible=\"both\"\n >\n {content}\n </PopoverBody>\n </LinkDefaultVariantContext.Provider>\n </PopoverContainer>\n )}\n </div>\n );\n\n const mergedRef = useMergeRefs(popoverRef, __internalRootRef);\n\n return (\n <span\n {...baseProps}\n className={clsx(styles.root, baseProps.className)}\n ref={mergedRef}\n onMouseDown={() => {\n // Indicate there was a click inside popover recently, including nested portals.\n clickFrameId.current = requestAnimationFrame(() => {\n clickFrameId.current = null;\n });\n }}\n >\n {triggerType === 'text' ? (\n <button\n {...triggerProps}\n className={clsx(triggerProps.className, wrapTriggerText === false && styles['overflow-ellipsis'])}\n tabIndex={triggerTabIndex}\n type=\"button\"\n aria-haspopup=\"dialog\"\n id={referrerId}\n aria-label={triggerAriaLabel}\n >\n {children}\n </button>\n ) : (\n <span {...triggerProps} id={referrerId}>\n {children}\n </span>\n )}\n <ResetContextsForModal>\n {renderWithPortal ? <Portal>{popoverContent}</Portal> : popoverContent}\n </ResetContextsForModal>\n </span>\n );\n}\n"]}
|