@cloudscape-design/components-themeable 3.0.1052 → 3.0.1053

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 (48) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/internal/components/button-trigger/styles.scss +4 -2
  3. package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
  4. package/lib/internal/template/button-dropdown/internal.d.ts.map +1 -1
  5. package/lib/internal/template/button-dropdown/internal.js +2 -2
  6. package/lib/internal/template/button-dropdown/internal.js.map +1 -1
  7. package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
  8. package/lib/internal/template/internal/components/button-trigger/styles.css.js +13 -13
  9. package/lib/internal/template/internal/components/button-trigger/styles.scoped.css +36 -31
  10. package/lib/internal/template/internal/components/button-trigger/styles.selectors.js +13 -13
  11. package/lib/internal/template/internal/environment.js +2 -2
  12. package/lib/internal/template/internal/environment.json +2 -2
  13. package/lib/internal/template/package.json +0 -1
  14. package/package.json +1 -1
  15. package/lib/internal/scss/top-navigation/1.0-beta/styles.scss +0 -219
  16. package/lib/internal/template/test-utils/dom/top-navigation/1.0-beta/index.d.ts +0 -28
  17. package/lib/internal/template/test-utils/dom/top-navigation/1.0-beta/index.js +0 -72
  18. package/lib/internal/template/test-utils/dom/top-navigation/1.0-beta/index.js.map +0 -1
  19. package/lib/internal/template/test-utils/selectors/top-navigation/1.0-beta/index.d.ts +0 -28
  20. package/lib/internal/template/test-utils/selectors/top-navigation/1.0-beta/index.js +0 -72
  21. package/lib/internal/template/test-utils/selectors/top-navigation/1.0-beta/index.js.map +0 -1
  22. package/lib/internal/template/top-navigation/1.0-beta/index.d.ts +0 -10
  23. package/lib/internal/template/top-navigation/1.0-beta/index.d.ts.map +0 -1
  24. package/lib/internal/template/top-navigation/1.0-beta/index.js +0 -19
  25. package/lib/internal/template/top-navigation/1.0-beta/index.js.map +0 -1
  26. package/lib/internal/template/top-navigation/1.0-beta/interfaces.d.ts +0 -103
  27. package/lib/internal/template/top-navigation/1.0-beta/interfaces.d.ts.map +0 -1
  28. package/lib/internal/template/top-navigation/1.0-beta/interfaces.js +0 -2
  29. package/lib/internal/template/top-navigation/1.0-beta/interfaces.js.map +0 -1
  30. package/lib/internal/template/top-navigation/1.0-beta/internal.d.ts +0 -7
  31. package/lib/internal/template/top-navigation/1.0-beta/internal.d.ts.map +0 -1
  32. package/lib/internal/template/top-navigation/1.0-beta/internal.js +0 -93
  33. package/lib/internal/template/top-navigation/1.0-beta/internal.js.map +0 -1
  34. package/lib/internal/template/top-navigation/1.0-beta/parts/overflow-menu.d.ts +0 -17
  35. package/lib/internal/template/top-navigation/1.0-beta/parts/overflow-menu.d.ts.map +0 -1
  36. package/lib/internal/template/top-navigation/1.0-beta/parts/overflow-menu.js +0 -54
  37. package/lib/internal/template/top-navigation/1.0-beta/parts/overflow-menu.js.map +0 -1
  38. package/lib/internal/template/top-navigation/1.0-beta/parts/utility.d.ts +0 -10
  39. package/lib/internal/template/top-navigation/1.0-beta/parts/utility.d.ts.map +0 -1
  40. package/lib/internal/template/top-navigation/1.0-beta/parts/utility.js +0 -56
  41. package/lib/internal/template/top-navigation/1.0-beta/parts/utility.js.map +0 -1
  42. package/lib/internal/template/top-navigation/1.0-beta/styles.css.js +0 -28
  43. package/lib/internal/template/top-navigation/1.0-beta/styles.scoped.css +0 -360
  44. package/lib/internal/template/top-navigation/1.0-beta/styles.selectors.js +0 -29
  45. package/lib/internal/template/top-navigation/1.0-beta/use-top-navigation.d.ts +0 -25
  46. package/lib/internal/template/top-navigation/1.0-beta/use-top-navigation.d.ts.map +0 -1
  47. package/lib/internal/template/top-navigation/1.0-beta/use-top-navigation.js +0 -154
  48. package/lib/internal/template/top-navigation/1.0-beta/use-top-navigation.js.map +0 -1
@@ -1,93 +0,0 @@
1
- import { __rest } from "tslib";
2
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- // SPDX-License-Identifier: Apache-2.0
4
- import React from 'react';
5
- import clsx from 'clsx';
6
- import { Portal } from '@cloudscape-design/component-toolkit/internal';
7
- import { getBaseProps } from '../../internal/base-component';
8
- import VisualContext from '../../internal/components/visual-context';
9
- import { fireCancelableEvent, isPlainLeftClick } from '../../internal/events';
10
- import { checkSafeUrl } from '../../internal/utils/check-safe-url';
11
- import OverflowMenu from './parts/overflow-menu';
12
- import Utility from './parts/utility';
13
- import { useTopNavigation } from './use-top-navigation.js';
14
- import styles from './styles.css.js';
15
- export default function InternalTopNavigation(_a) {
16
- var { __internalRootRef, identity, i18nStrings, utilities = [], search } = _a, restProps = __rest(_a, ["__internalRootRef", "identity", "i18nStrings", "utilities", "search"]);
17
- checkSafeUrl('TopNavigation', identity.href);
18
- const baseProps = getBaseProps(restProps);
19
- const { ref, virtualRef, breakpoint, responsiveState, isSearchExpanded, onSearchUtilityClick } = useTopNavigation({
20
- __internalRootRef,
21
- identity,
22
- search,
23
- utilities,
24
- });
25
- const isNarrowViewport = breakpoint === 'default';
26
- const isMediumViewport = breakpoint === 'xxs';
27
- const onIdentityClick = (event) => {
28
- if (isPlainLeftClick(event)) {
29
- fireCancelableEvent(identity.onFollow, {}, event);
30
- }
31
- };
32
- // Render the top nav twice; once as the top nav that users can see, and another
33
- // "virtual" top nav used just for calculations. The virtual top nav doesn't react to
34
- // layout changes and renders two sets of utilities: one with labels and one without.
35
- const content = (isVirtual) => {
36
- var _a, _b, _c, _d;
37
- const Wrapper = isVirtual ? 'div' : 'header';
38
- const showIdentity = isVirtual || !isSearchExpanded;
39
- const showTitle = isVirtual || !responsiveState.hideTitle;
40
- const showSearchSlot = search && (isVirtual || !responsiveState.hideSearch || isSearchExpanded);
41
- const showSearchUtility = isVirtual || (search && responsiveState.hideSearch);
42
- const showUtilities = isVirtual || !isSearchExpanded;
43
- const showMenuTrigger = isVirtual || (!isSearchExpanded && responsiveState.hideUtilities);
44
- return (React.createElement(Wrapper, { ref: isVirtual ? virtualRef : ref, "aria-hidden": isVirtual ? true : undefined, className: clsx(styles['top-navigation'], {
45
- [styles.hidden]: isVirtual,
46
- [styles.narrow]: isNarrowViewport,
47
- [styles.medium]: isMediumViewport,
48
- }) },
49
- React.createElement("div", { className: styles['padding-box'] },
50
- showIdentity && (React.createElement("div", { className: clsx(styles.identity, !identity.logo && styles['no-logo']) },
51
- React.createElement("a", { className: styles['identity-link'], href: identity.href, onClick: onIdentityClick },
52
- identity.logo && (React.createElement("img", { role: "img", src: (_a = identity.logo) === null || _a === void 0 ? void 0 : _a.src, alt: (_b = identity.logo) === null || _b === void 0 ? void 0 : _b.alt, className: clsx(styles.logo, {
53
- [styles.narrow]: isNarrowViewport,
54
- }) })),
55
- showTitle && React.createElement("span", { className: styles.title }, identity.title)))),
56
- React.createElement("div", { className: styles.inputs }, showSearchSlot && (React.createElement("div", { className: clsx(styles.search, !isVirtual && isSearchExpanded && styles['search-expanded']) }, search))),
57
- React.createElement("div", { className: styles.utilities },
58
- showSearchUtility && (React.createElement("div", { className: clsx(styles['utility-wrapper'], styles['utility-type-button'], styles['utility-type-button-link']), "data-utility-special": "search" },
59
- React.createElement(Utility, { hideText: true, isNarrowViewport: isNarrowViewport, definition: {
60
- type: 'button',
61
- iconName: isSearchExpanded ? 'close' : 'search',
62
- ariaLabel: isSearchExpanded
63
- ? i18nStrings.searchDismissIconAriaLabel
64
- : i18nStrings.searchIconAriaLabel,
65
- onClick: onSearchUtilityClick,
66
- } }))),
67
- showUtilities &&
68
- utilities
69
- .filter((_utility, i) => isVirtual || !responsiveState.hideUtilities || responsiveState.hideUtilities.indexOf(i) === -1)
70
- .map((utility, i) => {
71
- var _a;
72
- const hideText = !!responsiveState.hideUtilityText;
73
- const last = (isVirtual || !showMenuTrigger) && i === utilities.length - 1;
74
- return (React.createElement("div", { key: i, className: clsx(styles['utility-wrapper'], styles[`utility-type-${utility.type}`], last && styles['utility-wrapper-last'], utility.type === 'button' && styles[`utility-type-button-${(_a = utility.variant) !== null && _a !== void 0 ? _a : 'link'}`]), "data-utility-index": i, "data-utility-hide": `${hideText}` },
75
- React.createElement(Utility, { hideText: hideText, definition: utility, last: last, isNarrowViewport: isNarrowViewport })));
76
- }),
77
- isVirtual &&
78
- utilities.map((utility, i) => {
79
- var _a;
80
- const hideText = !responsiveState.hideUtilityText;
81
- const last = !showMenuTrigger && i === utilities.length - 1;
82
- return (React.createElement("div", { key: i, className: clsx(styles['utility-wrapper'], styles[`utility-type-${utility.type}`], last && styles['utility-wrapper-last'], utility.type === 'button' && styles[`utility-type-button-${(_a = utility.variant) !== null && _a !== void 0 ? _a : 'link'}`]), "data-utility-index": i, "data-utility-hide": `${hideText}` },
83
- React.createElement(Utility, { hideText: hideText, definition: utility, last: last, isNarrowViewport: isNarrowViewport })));
84
- }),
85
- showMenuTrigger && (React.createElement("div", { className: clsx(styles['utility-wrapper'], styles['utility-type-menu-dropdown'], styles['utility-wrapper-last']), "data-utility-special": "menu-trigger" },
86
- React.createElement(OverflowMenu, { utilities: (_d = (_c = responsiveState.hideUtilities) === null || _c === void 0 ? void 0 : _c.map(i => utilities[i])) !== null && _d !== void 0 ? _d : [], isNarrowViewport: isNarrowViewport }, i18nStrings.overflowMenuTriggerText)))))));
87
- };
88
- return (React.createElement("div", Object.assign({}, baseProps, { ref: __internalRootRef }),
89
- React.createElement(VisualContext, { contextName: "top-navigation" },
90
- content(false),
91
- React.createElement(Portal, null, content(true)))));
92
- }
93
- //# sourceMappingURL=internal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../../src/top-navigation/1.0-beta/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,+CAA+C,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,aAAa,MAAM,0CAA0C,CAAC;AACrE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tC,IAAI,IAAI,MAAM,CAAC,sBAAsB,CAAC,EACtC,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,uBAAuB,MAAA,OAAO,CAAC,OAAO,mCAAI,MAAM,EAAE,CAAC,CACxF,wBACmB,CAAC,uBACF,GAAG,QAAQ,EAAE;gCAEhC,oBAAC,OAAO,IAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,CAChG,CACP,CAAC;wBACJ,CAAC,CAAC;oBAEH,eAAe,IAAI,CAClB,6BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,iBAAiB,CAAC,EACzB,MAAM,CAAC,4BAA4B,CAAC,EACpC,MAAM,CAAC,sBAAsB,CAAC,CAC/B,0BACoB,cAAc;wBAEnC,oBAAC,YAAY,IACX,SAAS,EAAE,MAAA,MAAA,eAAe,CAAC,aAAa,0CAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,mCAAI,EAAE,EACtE,gBAAgB,EAAE,gBAAgB,IAEjC,WAAW,CAAC,uBAAuB,CACvB,CACX,CACP,CACG,CACF,CACE,CACX,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,6CAAS,SAAS,IAAE,GAAG,EAAE,iBAAiB;QACxC,oBAAC,aAAa,IAAC,WAAW,EAAC,gBAAgB;YACxC,OAAO,CAAC,KAAK,CAAC;YACf,oBAAC,MAAM,QAAE,OAAO,CAAC,IAAI,CAAC,CAAU,CAClB,CACZ,CACP,CAAC;AACJ,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';\n\nimport { Portal } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getBaseProps } from '../../internal/base-component';\nimport VisualContext from '../../internal/components/visual-context';\nimport { fireCancelableEvent, isPlainLeftClick } from '../../internal/events';\nimport { InternalBaseComponentProps } from '../../internal/hooks/use-base-component';\nimport { checkSafeUrl } from '../../internal/utils/check-safe-url';\nimport { TopNavigationProps } from './interfaces';\nimport OverflowMenu from './parts/overflow-menu';\nimport Utility from './parts/utility';\nimport { useTopNavigation } from './use-top-navigation.js';\n\nimport styles from './styles.css.js';\n\ntype InternalTopNavigationProps = TopNavigationProps & InternalBaseComponentProps;\n\nexport default function InternalTopNavigation({\n __internalRootRef,\n identity,\n i18nStrings,\n utilities = [],\n search,\n ...restProps\n}: InternalTopNavigationProps) {\n checkSafeUrl('TopNavigation', identity.href);\n const baseProps = getBaseProps(restProps);\n const { ref, virtualRef, breakpoint, responsiveState, isSearchExpanded, onSearchUtilityClick } = useTopNavigation({\n __internalRootRef,\n identity,\n search,\n utilities,\n });\n\n const isNarrowViewport = breakpoint === 'default';\n const isMediumViewport = breakpoint === 'xxs';\n\n const onIdentityClick = (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireCancelableEvent(identity.onFollow, {}, event);\n }\n };\n\n // Render the top nav twice; once as the top nav that users can see, and another\n // \"virtual\" top nav used just for calculations. The virtual top nav doesn't react to\n // layout changes and renders two sets of utilities: one with labels and one without.\n const content = (isVirtual: boolean) => {\n const Wrapper = isVirtual ? 'div' : 'header';\n const showIdentity = isVirtual || !isSearchExpanded;\n const showTitle = isVirtual || !responsiveState.hideTitle;\n const showSearchSlot = search && (isVirtual || !responsiveState.hideSearch || isSearchExpanded);\n const showSearchUtility = isVirtual || (search && responsiveState.hideSearch);\n const showUtilities = isVirtual || !isSearchExpanded;\n const showMenuTrigger = isVirtual || (!isSearchExpanded && responsiveState.hideUtilities);\n\n return (\n <Wrapper\n ref={isVirtual ? virtualRef : ref}\n aria-hidden={isVirtual ? true : undefined}\n className={clsx(styles['top-navigation'], {\n [styles.hidden]: isVirtual,\n [styles.narrow]: isNarrowViewport,\n [styles.medium]: isMediumViewport,\n })}\n >\n <div className={styles['padding-box']}>\n {showIdentity && (\n <div className={clsx(styles.identity, !identity.logo && styles['no-logo'])}>\n <a className={styles['identity-link']} href={identity.href} onClick={onIdentityClick}>\n {identity.logo && (\n <img\n role=\"img\"\n src={identity.logo?.src}\n alt={identity.logo?.alt}\n className={clsx(styles.logo, {\n [styles.narrow]: isNarrowViewport,\n })}\n />\n )}\n {showTitle && <span className={styles.title}>{identity.title}</span>}\n </a>\n </div>\n )}\n\n <div className={styles.inputs}>\n {showSearchSlot && (\n <div className={clsx(styles.search, !isVirtual && isSearchExpanded && styles['search-expanded'])}>\n {search}\n </div>\n )}\n </div>\n\n <div className={styles.utilities}>\n {showSearchUtility && (\n <div\n className={clsx(\n styles['utility-wrapper'],\n styles['utility-type-button'],\n styles['utility-type-button-link']\n )}\n data-utility-special=\"search\"\n >\n <Utility\n hideText={true}\n isNarrowViewport={isNarrowViewport}\n definition={{\n type: 'button',\n iconName: isSearchExpanded ? 'close' : 'search',\n ariaLabel: isSearchExpanded\n ? i18nStrings.searchDismissIconAriaLabel\n : i18nStrings.searchIconAriaLabel,\n onClick: onSearchUtilityClick,\n }}\n />\n </div>\n )}\n\n {showUtilities &&\n utilities\n .filter(\n (_utility, i) =>\n isVirtual || !responsiveState.hideUtilities || responsiveState.hideUtilities.indexOf(i) === -1\n )\n .map((utility, i) => {\n const hideText = !!responsiveState.hideUtilityText;\n const last = (isVirtual || !showMenuTrigger) && i === utilities.length - 1;\n return (\n <div\n key={i}\n className={clsx(\n styles['utility-wrapper'],\n styles[`utility-type-${utility.type}`],\n last && styles['utility-wrapper-last'],\n utility.type === 'button' && styles[`utility-type-button-${utility.variant ?? 'link'}`]\n )}\n data-utility-index={i}\n data-utility-hide={`${hideText}`}\n >\n <Utility\n hideText={hideText}\n definition={utility}\n last={last}\n isNarrowViewport={isNarrowViewport}\n />\n </div>\n );\n })}\n\n {isVirtual &&\n utilities.map((utility, i) => {\n const hideText = !responsiveState.hideUtilityText;\n const last = !showMenuTrigger && i === utilities.length - 1;\n return (\n <div\n key={i}\n className={clsx(\n styles['utility-wrapper'],\n styles[`utility-type-${utility.type}`],\n last && styles['utility-wrapper-last'],\n utility.type === 'button' && styles[`utility-type-button-${utility.variant ?? 'link'}`]\n )}\n data-utility-index={i}\n data-utility-hide={`${hideText}`}\n >\n <Utility hideText={hideText} definition={utility} last={last} isNarrowViewport={isNarrowViewport} />\n </div>\n );\n })}\n\n {showMenuTrigger && (\n <div\n className={clsx(\n styles['utility-wrapper'],\n styles['utility-type-menu-dropdown'],\n styles['utility-wrapper-last']\n )}\n data-utility-special=\"menu-trigger\"\n >\n <OverflowMenu\n utilities={responsiveState.hideUtilities?.map(i => utilities[i]) ?? []}\n isNarrowViewport={isNarrowViewport}\n >\n {i18nStrings.overflowMenuTriggerText}\n </OverflowMenu>\n </div>\n )}\n </div>\n </div>\n </Wrapper>\n );\n };\n\n return (\n <div {...baseProps} ref={__internalRootRef}>\n <VisualContext contextName=\"top-navigation\">\n {content(false)}\n <Portal>{content(true)}</Portal>\n </VisualContext>\n </div>\n );\n}\n"]}
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import { ButtonDropdownProps } from '../../../button-dropdown/interfaces';
3
- import { BaseComponentProps } from '../../../internal/base-component';
4
- import { TopNavigationProps } from '../interfaces';
5
- interface OverflowMenuProps extends BaseComponentProps {
6
- utilities: ReadonlyArray<TopNavigationProps.Utility>;
7
- isNarrowViewport?: boolean;
8
- /**
9
- * Text displayed in the button dropdown trigger.
10
- * @displayname text
11
- */
12
- children?: React.ReactNode;
13
- }
14
- export declare function transformUtility(utility: TopNavigationProps.Utility, index: number): ButtonDropdownProps.ItemOrGroup;
15
- export default function OverflowMenu({ children, utilities, isNarrowViewport }: OverflowMenuProps): JSX.Element;
16
- export {};
17
- //# sourceMappingURL=overflow-menu.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overflow-menu.d.ts","sourceRoot":"","sources":["../../../../../src/top-navigation/1.0-beta/parts/overflow-menu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAGtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAInD,UAAU,iBAAkB,SAAQ,kBAAkB;IACpD,SAAS,EAAE,aAAa,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAErD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAYD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,mBAAmB,CAAC,WAAW,CA2BpH;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,iBAAiB,eA6BhG"}
@@ -1,54 +0,0 @@
1
- import { __rest } from "tslib";
2
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- // SPDX-License-Identifier: Apache-2.0
4
- import React from 'react';
5
- import MenuDropdown from '../../../internal/components/menu-dropdown';
6
- import { fireCancelableEvent } from '../../../internal/events';
7
- import styles from '../styles.css.js';
8
- function transformButtonDropdownItems(items, index) {
9
- return items.map(item => {
10
- const itemCopy = Object.assign(Object.assign({}, item), { id: `${index}__${item.id || ''}` });
11
- if ('items' in itemCopy) {
12
- itemCopy.items = transformButtonDropdownItems(itemCopy.items, index);
13
- }
14
- return itemCopy;
15
- });
16
- }
17
- export function transformUtility(utility, index) {
18
- const title = utility.title || utility.text || '';
19
- const commonProps = {
20
- // Encode index into the ID, so we can pick out the right handler.
21
- id: `${index}__`,
22
- text: title,
23
- iconName: utility.iconName,
24
- iconUrl: utility.iconUrl,
25
- iconAlt: utility.iconAlt,
26
- iconSvg: utility.iconSvg,
27
- };
28
- if (utility.type === 'menu-dropdown') {
29
- return Object.assign(Object.assign({}, commonProps), { items: transformButtonDropdownItems(utility.items, index), description: utility.description });
30
- }
31
- else {
32
- return Object.assign(Object.assign({}, commonProps), { href: utility.href, external: utility.external, externalIconAriaLabel: utility.externalIconAriaLabel });
33
- }
34
- }
35
- export default function OverflowMenu({ children, utilities, isNarrowViewport }) {
36
- const onClick = (isFollow, event) => {
37
- const [index, ...rest] = event.detail.id.split('__');
38
- const utility = utilities[parseInt(index)];
39
- let defaultPrevented = false;
40
- if ('onItemClick' in utility) {
41
- defaultPrevented = fireCancelableEvent(utility.onItemClick, Object.assign(Object.assign({}, event.detail), { id: rest.join('__') }));
42
- }
43
- else if ('onClick' in utility && (isFollow || !utility.href)) {
44
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
45
- const _a = event.detail, { id } = _a, baseNavigationalDetail = __rest(_a, ["id"]);
46
- defaultPrevented = fireCancelableEvent(utility.onClick, baseNavigationalDetail);
47
- }
48
- if (defaultPrevented) {
49
- event.preventDefault();
50
- }
51
- };
52
- return (React.createElement(MenuDropdown, { items: utilities.map(transformUtility), offsetRight: isNarrowViewport ? 'l' : 'xxl', className: styles.trigger, expandableGroups: true, onItemClick: onClick.bind(null, false), onItemFollow: onClick.bind(null, true) }, children));
53
- }
54
- //# sourceMappingURL=overflow-menu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overflow-menu.js","sourceRoot":"","sources":["../../../../../src/top-navigation/1.0-beta/parts/overflow-menu.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,YAAY,MAAM,4CAA4C,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,MAAM,MAAM,kBAAkB,CAAC;AActC,SAAS,4BAA4B,CAAC,KAAgC,EAAE,KAAa;IACnF,OAAO,KAAK,CAAC,GA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":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { ButtonDropdownProps } from '../../../button-dropdown/interfaces';\nimport { BaseComponentProps } from '../../../internal/base-component';\nimport MenuDropdown from '../../../internal/components/menu-dropdown';\nimport { fireCancelableEvent } from '../../../internal/events';\nimport { TopNavigationProps } from '../interfaces';\n\nimport styles from '../styles.css.js';\n\ninterface OverflowMenuProps extends BaseComponentProps {\n utilities: ReadonlyArray<TopNavigationProps.Utility>;\n\n isNarrowViewport?: boolean;\n\n /**\n * Text displayed in the button dropdown trigger.\n * @displayname text\n */\n children?: React.ReactNode;\n}\n\nfunction transformButtonDropdownItems(items: ButtonDropdownProps.Items, index: number): ButtonDropdownProps.Items {\n return items.map(item => {\n const itemCopy = { ...item, id: `${index}__${item.id || ''}` };\n if ('items' in itemCopy) {\n itemCopy.items = transformButtonDropdownItems(itemCopy.items, index);\n }\n return itemCopy;\n });\n}\n\nexport function transformUtility(utility: TopNavigationProps.Utility, index: number): ButtonDropdownProps.ItemOrGroup {\n const title = utility.title || utility.text || '';\n\n const commonProps: Partial<ButtonDropdownProps.ItemOrGroup> = {\n // Encode index into the ID, so we can pick out the right handler.\n id: `${index}__`,\n text: title,\n iconName: utility.iconName,\n iconUrl: utility.iconUrl,\n iconAlt: utility.iconAlt,\n iconSvg: utility.iconSvg,\n };\n\n if (utility.type === 'menu-dropdown') {\n return {\n ...commonProps,\n items: transformButtonDropdownItems(utility.items, index),\n description: utility.description,\n } as ButtonDropdownProps.ItemGroup;\n } else {\n return {\n ...commonProps,\n href: utility.href,\n external: utility.external,\n externalIconAriaLabel: utility.externalIconAriaLabel,\n } as ButtonDropdownProps.Item;\n }\n}\n\nexport default function OverflowMenu({ children, utilities, isNarrowViewport }: OverflowMenuProps) {\n const onClick = (isFollow: boolean, event: CustomEvent<ButtonDropdownProps.ItemClickDetails>) => {\n const [index, ...rest] = event.detail.id.split('__');\n const utility = utilities[parseInt(index)];\n let defaultPrevented = false;\n if ('onItemClick' in utility) {\n defaultPrevented = fireCancelableEvent(utility.onItemClick, { ...event.detail, id: rest.join('__') });\n } else if ('onClick' in utility && (isFollow || !utility.href)) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { id, ...baseNavigationalDetail } = event.detail;\n defaultPrevented = fireCancelableEvent(utility.onClick, baseNavigationalDetail);\n }\n if (defaultPrevented) {\n event.preventDefault();\n }\n };\n\n return (\n <MenuDropdown\n items={utilities.map(transformUtility)}\n offsetRight={isNarrowViewport ? 'l' : 'xxl'}\n className={styles.trigger}\n expandableGroups={true}\n onItemClick={onClick.bind(null, false)}\n onItemFollow={onClick.bind(null, true)}\n >\n {children}\n </MenuDropdown>\n );\n}\n"]}
@@ -1,10 +0,0 @@
1
- /// <reference types="react" />
2
- import { TopNavigationProps } from '../interfaces';
3
- export interface UtilityProps {
4
- hideText: boolean;
5
- definition: TopNavigationProps.Utility;
6
- last?: boolean;
7
- isNarrowViewport?: boolean;
8
- }
9
- export default function Utility({ hideText, definition, last, isNarrowViewport }: UtilityProps): JSX.Element | null;
10
- //# sourceMappingURL=utility.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../../../../src/top-navigation/1.0-beta/parts/utility.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAInD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,kBAAkB,CAAC,OAAO,CAAC;IACvC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,YAAY,sBAuF7F"}
@@ -1,56 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import React from 'react';
4
- import clsx from 'clsx';
5
- import { InternalButton } from '../../../button/internal';
6
- import { isLinkItem } from '../../../button-dropdown/utils/utils';
7
- import InternalIcon from '../../../icon/internal';
8
- import MenuDropdown from '../../../internal/components/menu-dropdown';
9
- import { checkSafeUrl } from '../../../internal/utils/check-safe-url';
10
- import InternalLink from '../../../link/internal';
11
- import styles from '../styles.css.js';
12
- export default function Utility({ hideText, definition, last, isNarrowViewport }) {
13
- var _a;
14
- const shouldHideText = hideText && !definition.disableTextCollapse && hasIcon(definition);
15
- const ariaLabel = (_a = definition.ariaLabel) !== null && _a !== void 0 ? _a : definition.text;
16
- if (definition.type === 'button') {
17
- checkSafeUrl('TopNavigation', definition.href);
18
- if (definition.variant === 'primary-button') {
19
- return (React.createElement(InternalButton, { variant: "primary", href: definition.href, target: definition.external ? '_blank' : undefined, onClick: definition.onClick, ariaLabel: ariaLabel, iconName: definition.iconName, iconUrl: definition.iconUrl, iconAlt: definition.iconAlt, iconSvg: definition.iconSvg, className: clsx(last && styles['last-utility']) }, shouldHideText ? null : (React.createElement(React.Fragment, null,
20
- definition.text,
21
- definition.external && (React.createElement(React.Fragment, null,
22
- ' ',
23
- React.createElement("span", { className: styles['utility-button-external-icon'], "aria-label": definition.externalIconAriaLabel, role: definition.externalIconAriaLabel ? 'img' : undefined },
24
- React.createElement(InternalIcon, { name: "external" }))))))));
25
- }
26
- else {
27
- // Link
28
- return (React.createElement(InternalLink, { variant: "top-navigation", href: definition.href, external: definition.external, externalIconAriaLabel: definition.externalIconAriaLabel, onFollow: definition.onClick, ariaLabel: ariaLabel, className: clsx(last && styles['last-utility']) },
29
- hasIcon(definition) && (React.createElement("span", { className: styles['utility-link-icon'] },
30
- React.createElement(InternalIcon, { name: definition.iconName, url: definition.iconUrl, alt: definition.iconAlt, svg: definition.iconSvg, badge: definition.badge }))),
31
- !shouldHideText && definition.text));
32
- }
33
- }
34
- else if (definition.type === 'menu-dropdown') {
35
- const paddingRight = isNarrowViewport ? 'l' : 'xxl';
36
- const title = definition.title || definition.text;
37
- const shouldShowTitle = shouldHideText || !definition.text;
38
- checkSafeUrlRecursively(definition.items);
39
- return (React.createElement(MenuDropdown, Object.assign({}, definition, { title: shouldShowTitle ? title : '', ariaLabel: ariaLabel, className: styles['utility-dropdown'], offsetRight: last ? paddingRight : undefined }), !shouldHideText && definition.text));
40
- }
41
- return null;
42
- }
43
- function hasIcon(definition) {
44
- return !!definition.iconName || !!definition.iconUrl || !!definition.iconAlt || !!definition.iconSvg;
45
- }
46
- function checkSafeUrlRecursively(itemOrGroup) {
47
- for (const item of itemOrGroup) {
48
- if (isLinkItem(item)) {
49
- checkSafeUrl('TopNavigation', item.href);
50
- }
51
- if ('items' in item) {
52
- checkSafeUrlRecursively(item.items);
53
- }
54
- }
55
- }
56
- //# sourceMappingURL=utility.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../../src/top-navigation/1.0-beta/parts/utility.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,YAAmC,MAAM,4CAA4C,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAGlD,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAStC,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,EAAgB;;IAC5F,MAAM,cAAc,GAAG,QAAQ,IAAI,CAAC,UAAU,CAAC,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U,CAAC,IAAI,CACtB,CAChB,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,OAAO,CAAC,UAAsC;IACrD,OAAO,CAAC,CAAC,UAAU,CAAC,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;AACvG,CAAC;AAED,SAAS,uBAAuB,CAAC,WAAuC;IACtE,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE;QAC9B,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;YACpB,YAAY,CAAC,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;SAC1C;QAED,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACrC;KACF;AACH,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';\n\nimport { InternalButton } from '../../../button/internal';\nimport { isLinkItem } from '../../../button-dropdown/utils/utils';\nimport InternalIcon from '../../../icon/internal';\nimport MenuDropdown, { MenuDropdownProps } from '../../../internal/components/menu-dropdown';\nimport { checkSafeUrl } from '../../../internal/utils/check-safe-url';\nimport InternalLink from '../../../link/internal';\nimport { TopNavigationProps } from '../interfaces';\n\nimport styles from '../styles.css.js';\n\nexport interface UtilityProps {\n hideText: boolean;\n definition: TopNavigationProps.Utility;\n last?: boolean;\n isNarrowViewport?: boolean;\n}\n\nexport default function Utility({ hideText, definition, last, isNarrowViewport }: UtilityProps) {\n const shouldHideText = hideText && !definition.disableTextCollapse && hasIcon(definition);\n const ariaLabel = definition.ariaLabel ?? definition.text;\n\n if (definition.type === 'button') {\n checkSafeUrl('TopNavigation', definition.href);\n if (definition.variant === 'primary-button') {\n return (\n <InternalButton\n variant=\"primary\"\n href={definition.href}\n target={definition.external ? '_blank' : undefined}\n onClick={definition.onClick}\n ariaLabel={ariaLabel}\n iconName={definition.iconName}\n iconUrl={definition.iconUrl}\n iconAlt={definition.iconAlt}\n iconSvg={definition.iconSvg}\n className={clsx(last && styles['last-utility'])}\n >\n {shouldHideText ? null : (\n <>\n {definition.text}\n {definition.external && (\n <>\n {' '}\n <span\n className={styles['utility-button-external-icon']}\n aria-label={definition.externalIconAriaLabel}\n role={definition.externalIconAriaLabel ? 'img' : undefined}\n >\n <InternalIcon name=\"external\" />\n </span>\n </>\n )}\n </>\n )}\n </InternalButton>\n );\n } else {\n // Link\n return (\n <InternalLink\n variant=\"top-navigation\"\n href={definition.href}\n external={definition.external}\n externalIconAriaLabel={definition.externalIconAriaLabel}\n onFollow={definition.onClick}\n ariaLabel={ariaLabel}\n className={clsx(last && styles['last-utility'])}\n >\n {hasIcon(definition) && (\n <span className={styles['utility-link-icon']}>\n <InternalIcon\n name={definition.iconName}\n url={definition.iconUrl}\n alt={definition.iconAlt}\n svg={definition.iconSvg}\n badge={definition.badge}\n />\n </span>\n )}\n {!shouldHideText && definition.text}\n </InternalLink>\n );\n }\n } else if (definition.type === 'menu-dropdown') {\n const paddingRight = isNarrowViewport ? 'l' : 'xxl';\n const title = definition.title || definition.text;\n const shouldShowTitle = shouldHideText || !definition.text;\n\n checkSafeUrlRecursively(definition.items);\n\n return (\n <MenuDropdown\n {...definition}\n title={shouldShowTitle ? title : ''}\n ariaLabel={ariaLabel}\n className={styles['utility-dropdown']}\n offsetRight={last ? paddingRight : undefined}\n >\n {!shouldHideText && definition.text}\n </MenuDropdown>\n );\n }\n\n return null;\n}\n\nfunction hasIcon(definition: TopNavigationProps.Utility): boolean {\n return !!definition.iconName || !!definition.iconUrl || !!definition.iconAlt || !!definition.iconSvg;\n}\n\nfunction checkSafeUrlRecursively(itemOrGroup: MenuDropdownProps['items']) {\n for (const item of itemOrGroup) {\n if (isLinkItem(item)) {\n checkSafeUrl('TopNavigation', item.href);\n }\n\n if ('items' in item) {\n checkSafeUrlRecursively(item.items);\n }\n }\n}\n"]}
@@ -1,28 +0,0 @@
1
-
2
- import './styles.scoped.css';
3
- export default {
4
- "top-navigation": "awsui_top-navigation_1ca1i_dkdy5_145",
5
- "padding-box": "awsui_padding-box_1ca1i_dkdy5_177",
6
- "medium": "awsui_medium_1ca1i_dkdy5_189",
7
- "narrow": "awsui_narrow_1ca1i_dkdy5_189",
8
- "hidden": "awsui_hidden_1ca1i_dkdy5_199",
9
- "\t": "awsui_\t_1ca1i_dkdy5_1",
10
- "identity": "awsui_identity_1ca1i_dkdy5_212",
11
- "identity-link": "awsui_identity-link_1ca1i_dkdy5_212",
12
- "no-logo": "awsui_no-logo_1ca1i_dkdy5_232",
13
- "logo": "awsui_logo_1ca1i_dkdy5_236",
14
- "title": "awsui_title_1ca1i_dkdy5_247",
15
- "inputs": "awsui_inputs_1ca1i_dkdy5_263",
16
- "search": "awsui_search_1ca1i_dkdy5_270",
17
- "search-expanded": "awsui_search-expanded_1ca1i_dkdy5_275",
18
- "utilities": "awsui_utilities_1ca1i_dkdy5_280",
19
- "utility-wrapper": "awsui_utility-wrapper_1ca1i_dkdy5_292",
20
- "utility-wrapper-last": "awsui_utility-wrapper-last_1ca1i_dkdy5_307",
21
- "utility-type-button-primary-button": "awsui_utility-type-button-primary-button_1ca1i_dkdy5_307",
22
- "utility-type-menu-dropdown": "awsui_utility-type-menu-dropdown_1ca1i_dkdy5_320",
23
- "utility-type-button-link": "awsui_utility-type-button-link_1ca1i_dkdy5_336",
24
- "utility-link-icon": "awsui_utility-link-icon_1ca1i_dkdy5_350",
25
- "utility-button-external-icon": "awsui_utility-button-external-icon_1ca1i_dkdy5_354",
26
- "trigger": "awsui_trigger_1ca1i_dkdy5_358"
27
- };
28
-