@cloudscape-design/components 3.0.132 → 3.0.133
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/internal/environment.js
CHANGED
package/internal/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../../../src/top-navigation/parts/utility.tsx"],"names":[],"mappings":"AAQA,OAAqB,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../../../src/top-navigation/parts/utility.tsx"],"names":[],"mappings":"AAQA,OAAqB,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAMnD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,kBAAkB,CAAC,OAAO,CAAC;IACvC,WAAW,CAAC,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;CAChD;AAED,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,YAAY,sBA0FlF"}
|
|
@@ -9,6 +9,7 @@ import InternalIcon from '../../icon/internal';
|
|
|
9
9
|
import MenuDropdown from '../../internal/components/menu-dropdown';
|
|
10
10
|
import styles from '../styles.css.js';
|
|
11
11
|
import { checkSafeUrl } from '../../internal/utils/check-safe-url';
|
|
12
|
+
import { joinStrings } from '../../internal/utils/strings';
|
|
12
13
|
export default function Utility(_a) {
|
|
13
14
|
var _b;
|
|
14
15
|
var hideText = _a.hideText, definition = _a.definition, offsetRight = _a.offsetRight;
|
|
@@ -16,6 +17,9 @@ export default function Utility(_a) {
|
|
|
16
17
|
var shouldHideText = hideText && !definition.disableTextCollapse && hasIcon;
|
|
17
18
|
var ariaLabel = (_b = definition.ariaLabel) !== null && _b !== void 0 ? _b : definition.text;
|
|
18
19
|
if (definition.type === 'button') {
|
|
20
|
+
ariaLabel = definition.ariaLabel
|
|
21
|
+
? definition.ariaLabel
|
|
22
|
+
: joinStrings(definition.text, definition.externalIconAriaLabel);
|
|
19
23
|
checkSafeUrl('TopNavigation', definition.href);
|
|
20
24
|
if (definition.variant === 'primary-button') {
|
|
21
25
|
return (React.createElement("span", { className: styles["offset-right-".concat(offsetRight)] },
|
|
@@ -29,13 +33,9 @@ export default function Utility(_a) {
|
|
|
29
33
|
else {
|
|
30
34
|
// Link
|
|
31
35
|
return (React.createElement("span", { className: styles["offset-right-".concat(offsetRight)] },
|
|
32
|
-
React.createElement(InternalLink, { variant: "top-navigation", href: definition.href,
|
|
36
|
+
React.createElement(InternalLink, { variant: "top-navigation", href: definition.href, external: definition.external, onFollow: definition.onClick, ariaLabel: ariaLabel },
|
|
33
37
|
hasIcon && (React.createElement(InternalIcon, { name: definition.iconName, url: definition.iconUrl, alt: definition.iconAlt, svg: definition.iconSvg, badge: definition.badge })),
|
|
34
|
-
!shouldHideText && definition.text && (React.createElement("span", { className: hasIcon ? styles['utility-link-icon'] : undefined }, definition.text))
|
|
35
|
-
definition.external && (React.createElement(React.Fragment, null,
|
|
36
|
-
' ',
|
|
37
|
-
React.createElement("span", { role: definition.externalIconAriaLabel ? 'img' : undefined, "aria-label": definition.externalIconAriaLabel },
|
|
38
|
-
React.createElement(InternalIcon, { name: "external", size: "normal" })))))));
|
|
38
|
+
!shouldHideText && definition.text && (React.createElement("span", { className: hasIcon ? styles['utility-link-icon'] : undefined }, definition.text)))));
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
else if (definition.type === 'menu-dropdown') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../src/top-navigation/parts/utility.tsx"],"names":[],"mappings":";AAAA,q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AU,CAAC,IAAI,CACtB,CAChB,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,uBAAuB,CAAC,WAAuC;IACtE,KAAmB,UAAW,EAAX,2BAAW,EAAX,yBAAW,EAAX,IAAW,EAAE;QAA3B,IAAM,IAAI,oBAAA;QACb,YAAY,CAAC,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzC,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 InternalLink from '../../link/internal';\nimport InternalIcon from '../../icon/internal';\nimport MenuDropdown, { MenuDropdownProps } from '../../internal/components/menu-dropdown';\n\nimport { TopNavigationProps } from '../interfaces';\n\nimport styles from '../styles.css.js';\nimport { checkSafeUrl } from '../../internal/utils/check-safe-url';\nimport { joinStrings } from '../../internal/utils/strings';\n\nexport interface UtilityProps {\n hideText: boolean;\n definition: TopNavigationProps.Utility;\n offsetRight?: MenuDropdownProps['offsetRight'];\n}\n\nexport default function Utility({ hideText, definition, offsetRight }: UtilityProps) {\n const hasIcon = !!definition.iconName || !!definition.iconUrl || !!definition.iconAlt || !!definition.iconSvg;\n const shouldHideText = hideText && !definition.disableTextCollapse && hasIcon;\n let ariaLabel = definition.ariaLabel ?? definition.text;\n\n if (definition.type === 'button') {\n ariaLabel = definition.ariaLabel\n ? definition.ariaLabel\n : joinStrings(definition.text, definition.externalIconAriaLabel);\n checkSafeUrl('TopNavigation', definition.href);\n if (definition.variant === 'primary-button') {\n return (\n <span className={styles[`offset-right-${offsetRight}`]}>\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 >\n {shouldHideText ? null : (\n <>\n {definition.text}\n {definition.external && (\n <>\n {' '}\n <span\n className={clsx(styles['utility-button-external-icon'], styles[`offset-right-${offsetRight}`])}\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 </span>\n );\n } else {\n // Link\n return (\n <span className={styles[`offset-right-${offsetRight}`]}>\n <InternalLink\n variant=\"top-navigation\"\n href={definition.href}\n external={definition.external}\n onFollow={definition.onClick}\n ariaLabel={ariaLabel}\n >\n {hasIcon && (\n <InternalIcon\n name={definition.iconName}\n url={definition.iconUrl}\n alt={definition.iconAlt}\n svg={definition.iconSvg}\n badge={definition.badge}\n />\n )}\n {!shouldHideText && definition.text && (\n <span className={hasIcon ? styles['utility-link-icon'] : undefined}>{definition.text}</span>\n )}\n </InternalLink>\n </span>\n );\n }\n } else if (definition.type === 'menu-dropdown') {\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 offsetRight={offsetRight}\n >\n {!shouldHideText && definition.text}\n </MenuDropdown>\n );\n }\n\n return null;\n}\n\nfunction checkSafeUrlRecursively(itemOrGroup: MenuDropdownProps['items']) {\n for (const item of itemOrGroup) {\n checkSafeUrl('TopNavigation', item.href);\n\n if ('items' in item) {\n checkSafeUrlRecursively(item.items);\n }\n }\n}\n"]}
|