@cloudscape-design/components 3.0.1021 → 3.0.1023

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 (83) hide show
  1. package/index.d.ts +1 -0
  2. package/index.d.ts.map +1 -1
  3. package/index.js +1 -0
  4. package/index.js.map +1 -1
  5. package/internal/analytics/interfaces.d.ts +2 -2
  6. package/internal/analytics/interfaces.d.ts.map +1 -1
  7. package/internal/analytics/interfaces.js.map +1 -1
  8. package/internal/base-component/styles.scoped.css +1 -1
  9. package/{table/expandable-rows/expand-toggle-button.d.ts → internal/components/expand-toggle-button/index.d.ts} +4 -2
  10. package/internal/components/expand-toggle-button/index.d.ts.map +1 -0
  11. package/{table/expandable-rows/expand-toggle-button.js → internal/components/expand-toggle-button/index.js} +5 -6
  12. package/internal/components/expand-toggle-button/index.js.map +1 -0
  13. package/internal/components/expand-toggle-button/styles.css.js +8 -0
  14. package/{table/expandable-rows → internal/components/expand-toggle-button}/styles.scoped.css +18 -18
  15. package/{table/expandable-rows → internal/components/expand-toggle-button}/styles.selectors.js +3 -3
  16. package/internal/components/structured-item/index.d.ts +2 -1
  17. package/internal/components/structured-item/index.d.ts.map +1 -1
  18. package/internal/components/structured-item/index.js +2 -2
  19. package/internal/components/structured-item/index.js.map +1 -1
  20. package/internal/components/structured-item/interfaces.d.ts +1 -0
  21. package/internal/components/structured-item/interfaces.d.ts.map +1 -1
  22. package/internal/components/structured-item/interfaces.js.map +1 -1
  23. package/internal/components/structured-item/styles.css.js +7 -6
  24. package/internal/components/structured-item/styles.scoped.css +10 -8
  25. package/internal/components/structured-item/styles.selectors.js +7 -6
  26. package/internal/environment.js +2 -2
  27. package/internal/environment.json +2 -2
  28. package/internal/manifest.json +1 -1
  29. package/multiselect/internal.d.ts.map +1 -1
  30. package/multiselect/internal.js +3 -2
  31. package/multiselect/internal.js.map +1 -1
  32. package/package.json +2 -1
  33. package/table/body-cell/td-element.d.ts.map +1 -1
  34. package/table/body-cell/td-element.js +1 -1
  35. package/table/body-cell/td-element.js.map +1 -1
  36. package/test-utils/dom/index.d.ts +20 -0
  37. package/test-utils/dom/index.js +12 -1
  38. package/test-utils/dom/index.js.map +1 -1
  39. package/test-utils/dom/table/index.js +7 -7
  40. package/test-utils/dom/table/index.js.map +1 -1
  41. package/test-utils/dom/tree-view/index.d.ts +61 -0
  42. package/test-utils/dom/tree-view/index.js +95 -0
  43. package/test-utils/dom/tree-view/index.js.map +1 -0
  44. package/test-utils/selectors/index.d.ts +18 -0
  45. package/test-utils/selectors/index.js +12 -1
  46. package/test-utils/selectors/index.js.map +1 -1
  47. package/test-utils/selectors/table/index.js +7 -7
  48. package/test-utils/selectors/table/index.js.map +1 -1
  49. package/test-utils/selectors/tree-view/index.d.ts +61 -0
  50. package/test-utils/selectors/tree-view/index.js +95 -0
  51. package/test-utils/selectors/tree-view/index.js.map +1 -0
  52. package/token-group/internal.d.ts +4 -1
  53. package/token-group/internal.d.ts.map +1 -1
  54. package/token-group/internal.js +2 -2
  55. package/token-group/internal.js.map +1 -1
  56. package/tree-view/index.d.ts +5 -0
  57. package/tree-view/index.d.ts.map +1 -0
  58. package/tree-view/index.js +17 -0
  59. package/tree-view/index.js.map +1 -0
  60. package/tree-view/interfaces.d.ts +79 -0
  61. package/tree-view/interfaces.d.ts.map +1 -0
  62. package/tree-view/interfaces.js +2 -0
  63. package/tree-view/interfaces.js.map +1 -0
  64. package/tree-view/internal.d.ts +20 -0
  65. package/tree-view/internal.d.ts.map +1 -0
  66. package/tree-view/internal.js +35 -0
  67. package/tree-view/internal.js.map +1 -0
  68. package/tree-view/styles.css.js +7 -0
  69. package/tree-view/styles.scoped.css +223 -0
  70. package/tree-view/styles.selectors.js +8 -0
  71. package/tree-view/test-classes/styles.css.js +10 -0
  72. package/tree-view/test-classes/styles.scoped.css +11 -0
  73. package/tree-view/test-classes/styles.selectors.js +11 -0
  74. package/tree-view/tree-item/index.d.ts +21 -0
  75. package/tree-view/tree-item/index.d.ts.map +1 -0
  76. package/tree-view/tree-item/index.js +40 -0
  77. package/tree-view/tree-item/index.js.map +1 -0
  78. package/tree-view/tree-item/styles.css.js +10 -0
  79. package/tree-view/tree-item/styles.scoped.css +216 -0
  80. package/tree-view/tree-item/styles.selectors.js +11 -0
  81. package/table/expandable-rows/expand-toggle-button.d.ts.map +0 -1
  82. package/table/expandable-rows/expand-toggle-button.js.map +0 -1
  83. package/table/expandable-rows/styles.css.js +0 -8
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/token-group/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,MAAM,MAAM,+BAA+B,CAAC;AACnD,OAAO,SAAS,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAGrF,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,eAAe,MAAM,iDAAiD,CAAC;AAC9E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAYjB;QAZiB,EACzC,SAAS,EACT,KAAK,EACL,SAAS,EACT,KAAK,EACL,WAAW,EACX,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,QAAQ,EACR,iBAAiB,OAEO,EADrB,KAAK,cAXiC,wKAY1C,CADS;IA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AAC,CAAC;gBAC/B,CAAC,EACD,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,QAAQ,EAAE,QAAQ,IACd,CAAC,IAAI,CAAC,QAAQ,IAAI,QAAQ;gBAC5B,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,6BAA6B,CAAC,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,GAAG,SAAS,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBAEhF,oBAAC,MAAM,IAAC,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,GAAI,CACzC,CACT,EACD,WAAW,EAAE,WAAW,EACxB,uBAAuB,EAAE,uBAAuB,EAChD,sBAAsB,EAAE,sBAAsB,EAC9C,eAAe,EAAE,UAAU,CAAC,EAAE;gBAC5B,IAAI,UAAU,IAAI,KAAK,EAAE;oBACvB,iBAAiB,CAAC,KAAK,CAAC,CAAC;iBAC1B;qBAAM;oBACL,iBAAiB,CAAC,IAAI,CAAC,CAAC;iBACzB;YACH,CAAC,GACD,CACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { getBaseProps } from '../internal/base-component';\nimport Option from '../internal/components/option';\nimport TokenList from '../internal/components/token-list';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useListFocusController } from '../internal/hooks/use-list-focus-controller';\nimport { SomeRequired } from '../internal/types';\nimport { TokenGroupProps } from './interfaces';\nimport { Token } from './token';\n\nimport tokenListStyles from '../internal/components/token-list/styles.css.js';\nimport styles from './styles.css.js';\n\ntype InternalTokenGroupProps = SomeRequired<TokenGroupProps, 'items' | 'alignment'> & InternalBaseComponentProps;\n\nexport default function InternalTokenGroup({\n alignment,\n items,\n onDismiss,\n limit,\n i18nStrings,\n disableOuterPadding,\n limitShowFewerAriaLabel,\n limitShowMoreAriaLabel,\n readOnly,\n __internalRootRef,\n ...props\n}: InternalTokenGroupProps) {\n checkControlled('TokenGroup', 'items', items, 'onDismiss', onDismiss);\n\n const [nextFocusIndex, setNextFocusIndex] = useState<null | number>(null);\n const tokenListRef = useListFocusController({\n nextFocusIndex,\n onFocusMoved: target => {\n target.focus();\n setNextFocusIndex(null);\n },\n listItemSelector: `.${tokenListStyles['list-item']}`,\n showMoreSelector: `.${tokenListStyles.toggle}`,\n });\n\n const baseProps = getBaseProps(props);\n const hasItems = items.length > 0;\n const mergedRef = useMergeRefs(__internalRootRef, tokenListRef);\n return (\n <div\n {...baseProps}\n className={clsx(\n baseProps.className,\n styles.root,\n hasItems && styles['has-items'],\n disableOuterPadding && styles['no-padding']\n )}\n ref={mergedRef}\n >\n <TokenList\n alignment={alignment}\n items={items}\n limit={limit}\n renderItem={(item, itemIndex) => (\n <Token\n ariaLabel={item.label}\n dismissLabel={item.dismissLabel}\n onDismiss={() => {\n fireNonCancelableEvent(onDismiss, { itemIndex });\n setNextFocusIndex(itemIndex);\n }}\n disabled={item.disabled}\n readOnly={readOnly}\n {...(item.disabled || readOnly\n ? {}\n : getAnalyticsMetadataAttribute({ detail: { position: `${itemIndex + 1}` } }))}\n >\n <Option option={item} isGenericGroup={false} />\n </Token>\n )}\n i18nStrings={i18nStrings}\n limitShowFewerAriaLabel={limitShowFewerAriaLabel}\n limitShowMoreAriaLabel={limitShowMoreAriaLabel}\n onExpandedClick={isExpanded => {\n if (isExpanded && limit) {\n setNextFocusIndex(limit);\n } else {\n setNextFocusIndex(null);\n }\n }}\n />\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/token-group/internal.tsx"],"names":[],"mappings":";AA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MAAM,IAAC,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,GAAI,CACzC,CACT,EACD,WAAW,EAAE,WAAW,EACxB,uBAAuB,EAAE,uBAAuB,EAChD,sBAAsB,EAAE,sBAAsB,EAC9C,eAAe,EAAE,UAAU,CAAC,EAAE;gBAC5B,IAAI,UAAU,IAAI,KAAK,EAAE;oBACvB,iBAAiB,CAAC,KAAK,CAAC,CAAC;iBAC1B;qBAAM;oBACL,iBAAiB,CAAC,IAAI,CAAC,CAAC;iBACzB;YACH,CAAC,GACD,CACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { getBaseProps } from '../internal/base-component';\nimport Option from '../internal/components/option';\nimport TokenList from '../internal/components/token-list';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useListFocusController } from '../internal/hooks/use-list-focus-controller';\nimport { SomeRequired } from '../internal/types';\nimport { TokenGroupProps } from './interfaces';\nimport { Token } from './token';\n\nimport tokenListStyles from '../internal/components/token-list/styles.css.js';\nimport styles from './styles.css.js';\n\ntype InternalTokenGroupProps = SomeRequired<TokenGroupProps, 'items' | 'alignment'> &\n InternalBaseComponentProps & {\n isItemReadOnly?: (item: TokenGroupProps.Item) => boolean;\n };\n\nexport default function InternalTokenGroup({\n alignment,\n items,\n onDismiss,\n limit,\n i18nStrings,\n disableOuterPadding,\n limitShowFewerAriaLabel,\n limitShowMoreAriaLabel,\n readOnly,\n isItemReadOnly,\n __internalRootRef,\n ...props\n}: InternalTokenGroupProps) {\n checkControlled('TokenGroup', 'items', items, 'onDismiss', onDismiss);\n\n const [nextFocusIndex, setNextFocusIndex] = useState<null | number>(null);\n const tokenListRef = useListFocusController({\n nextFocusIndex,\n onFocusMoved: target => {\n target.focus();\n setNextFocusIndex(null);\n },\n listItemSelector: `.${tokenListStyles['list-item']}`,\n showMoreSelector: `.${tokenListStyles.toggle}`,\n });\n\n const baseProps = getBaseProps(props);\n const hasItems = items.length > 0;\n const mergedRef = useMergeRefs(__internalRootRef, tokenListRef);\n return (\n <div\n {...baseProps}\n className={clsx(\n baseProps.className,\n styles.root,\n hasItems && styles['has-items'],\n disableOuterPadding && styles['no-padding']\n )}\n ref={mergedRef}\n >\n <TokenList\n alignment={alignment}\n items={items}\n limit={limit}\n renderItem={(item, itemIndex) => (\n <Token\n ariaLabel={item.label}\n dismissLabel={item.dismissLabel}\n onDismiss={() => {\n fireNonCancelableEvent(onDismiss, { itemIndex });\n setNextFocusIndex(itemIndex);\n }}\n disabled={item.disabled}\n readOnly={readOnly || isItemReadOnly?.(item)}\n {...(item.disabled || readOnly\n ? {}\n : getAnalyticsMetadataAttribute({ detail: { position: `${itemIndex + 1}` } }))}\n >\n <Option option={item} isGenericGroup={false} />\n </Token>\n )}\n i18nStrings={i18nStrings}\n limitShowFewerAriaLabel={limitShowFewerAriaLabel}\n limitShowMoreAriaLabel={limitShowMoreAriaLabel}\n onExpandedClick={isExpanded => {\n if (isExpanded && limit) {\n setNextFocusIndex(limit);\n } else {\n setNextFocusIndex(null);\n }\n }}\n />\n </div>\n );\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { TreeViewProps } from './interfaces';
3
+ export { TreeViewProps };
4
+ declare const TreeView: <T>(props: TreeViewProps<T>) => JSX.Element;
5
+ export default TreeView;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tree-view/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,QAAA,MAAM,QAAQ,6CAMb,CAAC;AAGF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,17 @@
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 { getBaseProps } from '../internal/base-component';
5
+ import useBaseComponent from '../internal/hooks/use-base-component';
6
+ import { applyDisplayName } from '../internal/utils/apply-display-name';
7
+ import { getExternalProps } from '../internal/utils/external-props';
8
+ import InternalTreeView from './internal';
9
+ const TreeView = (props) => {
10
+ const baseComponentProps = useBaseComponent('TreeView');
11
+ const baseProps = getBaseProps(props);
12
+ const externalProps = getExternalProps(props);
13
+ return React.createElement(InternalTreeView, Object.assign({}, baseProps, baseComponentProps, externalProps, props));
14
+ };
15
+ applyDisplayName(TreeView, 'TreeView');
16
+ export default TreeView;
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tree-view/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,gBAAgB,MAAM,YAAY,CAAC;AAI1C,MAAM,QAAQ,GAAG,CAAK,KAAuB,EAAE,EAAE;IAC/C,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAE9C,OAAO,oBAAC,gBAAgB,oBAAK,SAAS,EAAM,kBAAkB,EAAM,aAAa,EAAM,KAAK,EAAI,CAAC;AACnG,CAAC,CAAC;AAEF,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AACvC,eAAe,QAAQ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { getBaseProps } from '../internal/base-component';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { getExternalProps } from '../internal/utils/external-props';\nimport { TreeViewProps } from './interfaces';\nimport InternalTreeView from './internal';\n\nexport { TreeViewProps };\n\nconst TreeView = <T,>(props: TreeViewProps<T>) => {\n const baseComponentProps = useBaseComponent('TreeView');\n const baseProps = getBaseProps(props);\n const externalProps = getExternalProps(props);\n\n return <InternalTreeView {...baseProps} {...baseComponentProps} {...externalProps} {...props} />;\n};\n\napplyDisplayName(TreeView, 'TreeView');\nexport default TreeView;\n"]}
@@ -0,0 +1,79 @@
1
+ import React from 'react';
2
+ import { BaseComponentProps } from '../internal/base-component';
3
+ import { NonCancelableEventHandler } from '../internal/events';
4
+ export interface TreeViewProps<T = any> extends BaseComponentProps {
5
+ /**
6
+ * Specifies the top-level items to display in the tree view. Use `getItemChildren` to provide nested items.
7
+ */
8
+ items: ReadonlyArray<T>;
9
+ /**
10
+ * Use this property to map your data to tree view items. This property must return an object with the following properties:
11
+ * * `content` (ReactNode) - The content of the item.
12
+ * * `icon` (ReactNode) - (Optional) The icon of the item.
13
+ * * `secondaryContent` (ReactNode) - (Optional) Secondary content of the item, such as a description of the item.
14
+ * * `actions` (ReactNode) - (Optional) Actions related to the item. Use [button](/components/button/?tabId=playground&example=inline-icon-button) with inline-icon or inline-link variants. For items with multiple actions, use [button dropdown](/components/button-dropdown/?tabId=playground&example=inline-icon-button-dropdown) with the inline-icon variant.
15
+ * * `announcementLabel` (string) - (Optional) An announcement label for the item, used for labeling the toggle button. By default, the `content` is used. Make sure to provide the `announcementLabel` if `content` is not a string.
16
+ */
17
+ renderItem: (item: T, index: number) => TreeViewProps.TreeItem;
18
+ /**
19
+ * Provides a unique identifier for each tree view item.
20
+ */
21
+ getItemId: (item: T, index: number) => string;
22
+ /**
23
+ * Specifies the nested items that are displayed when a tree view item gets expanded.
24
+ */
25
+ getItemChildren: (item: T, index: number) => ReadonlyArray<T> | undefined;
26
+ /**
27
+ * Provides the IDs of the expanded tree view items. It controls whether an item is expanded or collapsed.
28
+ */
29
+ expandedItems?: ReadonlyArray<string>;
30
+ /**
31
+ * Provides an `aria-label` to the tree view that screen readers can read (for accessibility).
32
+ * Don't use `ariaLabel` and `ariaLabelledby` at the same time.
33
+ */
34
+ ariaLabel?: string;
35
+ /**
36
+ * Sets the `aria-labelledby` property on the tree view.
37
+ * If there's a visible label element that you can reference, use this instead of `ariaLabel`.
38
+ * Don't use `ariaLabel` and `ariaLabelledby` at the same time.
39
+ */
40
+ ariaLabelledby?: string;
41
+ /**
42
+ * Sets the `aria-describedby` property on the tree view.
43
+ */
44
+ ariaDescribedby?: string;
45
+ /**
46
+ * Called when an item expands or collapses.
47
+ */
48
+ onItemToggle?: NonCancelableEventHandler<TreeViewProps.ItemToggleDetail<T>>;
49
+ /**
50
+ * An object containing all the necessary localized strings required by the component.
51
+ * @i18n
52
+ */
53
+ i18nStrings?: TreeViewProps.I18nStrings<T>;
54
+ /**
55
+ * Use this property to display a custom icon in the toggle button.
56
+ */
57
+ renderItemToggleIcon?: (data: TreeViewProps.ItemToggleRenderIconData) => React.ReactNode;
58
+ }
59
+ export declare namespace TreeViewProps {
60
+ interface TreeItem {
61
+ content: React.ReactNode;
62
+ icon?: React.ReactNode;
63
+ secondaryContent?: React.ReactNode;
64
+ actions?: React.ReactNode;
65
+ announcementLabel?: string;
66
+ }
67
+ interface ItemToggleDetail<T> {
68
+ id: string;
69
+ item: T;
70
+ expanded: boolean;
71
+ }
72
+ interface ItemToggleRenderIconData {
73
+ expanded: boolean;
74
+ }
75
+ interface I18nStrings<T> {
76
+ collapseButtonLabel?: (item: T) => string;
77
+ expandButtonLabel?: (item: T) => string;
78
+ }
79
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/tree-view/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,kBAAkB;IAChE;;OAEG;IACH,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAExB;;;;;;;OAOG;IACH,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,aAAa,CAAC,QAAQ,CAAC;IAE/D;;OAEG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAE9C;;OAEG;IACH,eAAe,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAE1E;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAEtC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,YAAY,CAAC,EAAE,yBAAyB,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAE5E;;;OAGG;IACH,WAAW,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAE3C;;OAEG;IACH,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,wBAAwB,KAAK,KAAK,CAAC,SAAS,CAAC;CAC1F;AAED,yBAAiB,aAAa,CAAC;IAC7B,UAAiB,QAAQ;QACvB,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;QACzB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QACvB,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QACnC,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B;IAED,UAAiB,gBAAgB,CAAC,CAAC;QACjC,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,CAAC,CAAC;QACR,QAAQ,EAAE,OAAO,CAAC;KACnB;IAED,UAAiB,wBAAwB;QACvC,QAAQ,EAAE,OAAO,CAAC;KACnB;IAED,UAAiB,WAAW,CAAC,CAAC;QAC5B,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;QAC1C,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;KACzC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/tree-view/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface TreeViewProps<T = any> extends BaseComponentProps {\n /**\n * Specifies the top-level items to display in the tree view. Use `getItemChildren` to provide nested items.\n */\n items: ReadonlyArray<T>;\n\n /**\n * Use this property to map your data to tree view items. This property must return an object with the following properties:\n * * `content` (ReactNode) - The content of the item.\n * * `icon` (ReactNode) - (Optional) The icon of the item.\n * * `secondaryContent` (ReactNode) - (Optional) Secondary content of the item, such as a description of the item.\n * * `actions` (ReactNode) - (Optional) Actions related to the item. Use [button](/components/button/?tabId=playground&example=inline-icon-button) with inline-icon or inline-link variants. For items with multiple actions, use [button dropdown](/components/button-dropdown/?tabId=playground&example=inline-icon-button-dropdown) with the inline-icon variant.\n * * `announcementLabel` (string) - (Optional) An announcement label for the item, used for labeling the toggle button. By default, the `content` is used. Make sure to provide the `announcementLabel` if `content` is not a string.\n */\n renderItem: (item: T, index: number) => TreeViewProps.TreeItem;\n\n /**\n * Provides a unique identifier for each tree view item.\n */\n getItemId: (item: T, index: number) => string;\n\n /**\n * Specifies the nested items that are displayed when a tree view item gets expanded.\n */\n getItemChildren: (item: T, index: number) => ReadonlyArray<T> | undefined;\n\n /**\n * Provides the IDs of the expanded tree view items. It controls whether an item is expanded or collapsed.\n */\n expandedItems?: ReadonlyArray<string>;\n\n /**\n * Provides an `aria-label` to the tree view that screen readers can read (for accessibility).\n * Don't use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabel?: string;\n\n /**\n * Sets the `aria-labelledby` property on the tree view.\n * If there's a visible label element that you can reference, use this instead of `ariaLabel`.\n * Don't use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabelledby?: string;\n\n /**\n * Sets the `aria-describedby` property on the tree view.\n */\n ariaDescribedby?: string;\n\n /**\n * Called when an item expands or collapses.\n */\n onItemToggle?: NonCancelableEventHandler<TreeViewProps.ItemToggleDetail<T>>;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * @i18n\n */\n i18nStrings?: TreeViewProps.I18nStrings<T>;\n\n /**\n * Use this property to display a custom icon in the toggle button.\n */\n renderItemToggleIcon?: (data: TreeViewProps.ItemToggleRenderIconData) => React.ReactNode;\n}\n\nexport namespace TreeViewProps {\n export interface TreeItem {\n content: React.ReactNode;\n icon?: React.ReactNode;\n secondaryContent?: React.ReactNode;\n actions?: React.ReactNode;\n announcementLabel?: string;\n }\n\n export interface ItemToggleDetail<T> {\n id: string;\n item: T;\n expanded: boolean;\n }\n\n export interface ItemToggleRenderIconData {\n expanded: boolean;\n }\n\n export interface I18nStrings<T> {\n collapseButtonLabel?: (item: T) => string;\n expandButtonLabel?: (item: T) => string;\n }\n}\n"]}
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
3
+ import { TreeViewProps } from './interfaces';
4
+ type InternalTreeViewProps<T> = TreeViewProps<T> & InternalBaseComponentProps;
5
+ declare const InternalTreeView: <T>({
6
+ expandedItems: controlledExpandedItems,
7
+ items,
8
+ renderItem,
9
+ getItemId,
10
+ getItemChildren,
11
+ onItemToggle,
12
+ renderItemToggleIcon,
13
+ ariaLabel,
14
+ ariaLabelledby,
15
+ ariaDescribedby,
16
+ i18nStrings,
17
+ __internalRootRef,
18
+ ...rest
19
+ }: InternalTreeViewProps<T>) => JSX.Element;
20
+ export default InternalTreeView;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/tree-view/internal.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAM7C,KAAK,qBAAqB,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG,0BAA0B,CAAC;AAE9E,QAAA,MAAM,gBAAgB,kQA6DrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,35 @@
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 { getBaseProps } from '../internal/base-component';
7
+ import { fireNonCancelableEvent } from '../internal/events';
8
+ import { useControllable } from '../internal/hooks/use-controllable';
9
+ import InternalTreeItem from './tree-item';
10
+ import styles from './styles.css.js';
11
+ import testUtilStyles from './test-classes/styles.css.js';
12
+ const InternalTreeView = (_a) => {
13
+ var { expandedItems: controlledExpandedItems, items, renderItem, getItemId, getItemChildren, onItemToggle, renderItemToggleIcon, ariaLabel, ariaLabelledby, ariaDescribedby, i18nStrings, __internalRootRef } = _a, rest = __rest(_a, ["expandedItems", "items", "renderItem", "getItemId", "getItemChildren", "onItemToggle", "renderItemToggleIcon", "ariaLabel", "ariaLabelledby", "ariaDescribedby", "i18nStrings", "__internalRootRef"]);
14
+ const baseProps = getBaseProps(rest);
15
+ const [expandedItems, setExpandedItems] = useControllable(controlledExpandedItems, onItemToggle, [], {
16
+ componentName: 'TreeView',
17
+ controlledProp: 'expandedItems',
18
+ changeHandler: 'onItemToggle',
19
+ });
20
+ const onToggle = ({ id, item, expanded }) => {
21
+ if (expanded) {
22
+ setExpandedItems([...(expandedItems || []), id]);
23
+ }
24
+ else {
25
+ setExpandedItems((expandedItems || []).filter(expandedId => expandedId !== id));
26
+ }
27
+ fireNonCancelableEvent(onItemToggle, { id, item, expanded });
28
+ };
29
+ return (React.createElement("div", Object.assign({}, baseProps, { ref: __internalRootRef, className: clsx(baseProps.className, styles.root, testUtilStyles.root) }),
30
+ React.createElement("ul", { className: clsx(styles.tree, testUtilStyles.tree), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby }, items.map((item, index) => {
31
+ return (React.createElement(InternalTreeItem, { key: index, item: item, level: 1, index: index, expandedItems: expandedItems, i18nStrings: i18nStrings, onItemToggle: onToggle, renderItem: renderItem, getItemId: getItemId, getItemChildren: getItemChildren, renderItemToggleIcon: renderItemToggleIcon }));
32
+ }))));
33
+ };
34
+ export default InternalTreeView;
35
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/tree-view/internal.tsx"],"names":[],"mappings":";AAAA,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AsB,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC/D,CAAC,CAAC;IAEF,OAAO,CACL,6CAAS,SAAS,IAAE,GAAG,EAAE,iBAAiB,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC;QAEhH,4BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,gBACrC,SAAS,qBACJ,cAAc,sBACb,eAAe,IAEhC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACzB,OAAO,CACL,oBAAC,gBAAgB,IACf,GAAG,EAAE,KAAK,EACV,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,CAAC,EACR,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,QAAQ,EACtB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,eAAe,EAChC,oBAAoB,EAAE,oBAAoB,GAC1C,CACH,CAAC;QACJ,CAAC,CAAC,CACC,CACD,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,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 { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useControllable } from '../internal/hooks/use-controllable';\nimport { TreeViewProps } from './interfaces';\nimport InternalTreeItem from './tree-item';\n\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\ntype InternalTreeViewProps<T> = TreeViewProps<T> & InternalBaseComponentProps;\n\nconst InternalTreeView = <T,>({\n expandedItems: controlledExpandedItems,\n items,\n renderItem,\n getItemId,\n getItemChildren,\n onItemToggle,\n renderItemToggleIcon,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n i18nStrings,\n __internalRootRef,\n ...rest\n}: InternalTreeViewProps<T>) => {\n const baseProps = getBaseProps(rest);\n\n const [expandedItems, setExpandedItems] = useControllable(controlledExpandedItems, onItemToggle, [], {\n componentName: 'TreeView',\n controlledProp: 'expandedItems',\n changeHandler: 'onItemToggle',\n });\n\n const onToggle = ({ id, item, expanded }: TreeViewProps.ItemToggleDetail<T>) => {\n if (expanded) {\n setExpandedItems([...(expandedItems || []), id]);\n } else {\n setExpandedItems((expandedItems || []).filter(expandedId => expandedId !== id));\n }\n fireNonCancelableEvent(onItemToggle, { id, item, expanded });\n };\n\n return (\n <div {...baseProps} ref={__internalRootRef} className={clsx(baseProps.className, styles.root, testUtilStyles.root)}>\n {/* Role `tree` isn't used in the initial release per discussion with A11Y team. It requires focus management to be implemented so they will be added as a follow up together. */}\n <ul\n className={clsx(styles.tree, testUtilStyles.tree)}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n >\n {items.map((item, index) => {\n return (\n <InternalTreeItem\n key={index}\n item={item}\n level={1}\n index={index}\n expandedItems={expandedItems}\n i18nStrings={i18nStrings}\n onItemToggle={onToggle}\n renderItem={renderItem}\n getItemId={getItemId}\n getItemChildren={getItemChildren}\n renderItemToggleIcon={renderItemToggleIcon}\n />\n );\n })}\n </ul>\n </div>\n );\n};\n\nexport default InternalTreeView;\n"]}
@@ -0,0 +1,7 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "root": "awsui_root_18gnm_17ax2_181",
5
+ "tree": "awsui_tree_18gnm_17ax2_218"
6
+ };
7
+
@@ -0,0 +1,223 @@
1
+ /*
2
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ /*
6
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7
+ SPDX-License-Identifier: Apache-2.0
8
+ */
9
+ /*
10
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
11
+ SPDX-License-Identifier: Apache-2.0
12
+ */
13
+ /*
14
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
15
+ SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ /*
18
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
19
+ SPDX-License-Identifier: Apache-2.0
20
+ */
21
+ /*
22
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
23
+ SPDX-License-Identifier: Apache-2.0
24
+ */
25
+ /*
26
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
27
+ SPDX-License-Identifier: Apache-2.0
28
+ */
29
+ /*
30
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
31
+ SPDX-License-Identifier: Apache-2.0
32
+ */
33
+ /*
34
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
35
+ SPDX-License-Identifier: Apache-2.0
36
+ */
37
+ /*
38
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
39
+ SPDX-License-Identifier: Apache-2.0
40
+ */
41
+ /*
42
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
43
+ SPDX-License-Identifier: Apache-2.0
44
+ */
45
+ /*
46
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
47
+ SPDX-License-Identifier: Apache-2.0
48
+ */
49
+ /*
50
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
51
+ SPDX-License-Identifier: Apache-2.0
52
+ */
53
+ /*
54
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
55
+ SPDX-License-Identifier: Apache-2.0
56
+ */
57
+ /*
58
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
59
+ SPDX-License-Identifier: Apache-2.0
60
+ */
61
+ /*
62
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
63
+ SPDX-License-Identifier: Apache-2.0
64
+ */
65
+ /*
66
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
67
+ SPDX-License-Identifier: Apache-2.0
68
+ */
69
+ /*
70
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
71
+ SPDX-License-Identifier: Apache-2.0
72
+ */
73
+ /*
74
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
75
+ SPDX-License-Identifier: Apache-2.0
76
+ */
77
+ /*
78
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
79
+ SPDX-License-Identifier: Apache-2.0
80
+ */
81
+ /*
82
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
83
+ SPDX-License-Identifier: Apache-2.0
84
+ */
85
+ /*
86
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
87
+ SPDX-License-Identifier: Apache-2.0
88
+ */
89
+ /*
90
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
91
+ SPDX-License-Identifier: Apache-2.0
92
+ */
93
+ /*
94
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
95
+ SPDX-License-Identifier: Apache-2.0
96
+ */
97
+ /*
98
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
99
+ SPDX-License-Identifier: Apache-2.0
100
+ */
101
+ /*
102
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
103
+ SPDX-License-Identifier: Apache-2.0
104
+ */
105
+ /*
106
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
107
+ SPDX-License-Identifier: Apache-2.0
108
+ */
109
+ /*
110
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
111
+ SPDX-License-Identifier: Apache-2.0
112
+ */
113
+ /*
114
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
115
+ SPDX-License-Identifier: Apache-2.0
116
+ */
117
+ /*
118
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
119
+ SPDX-License-Identifier: Apache-2.0
120
+ */
121
+ /*
122
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
123
+ SPDX-License-Identifier: Apache-2.0
124
+ */
125
+ /*
126
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
127
+ SPDX-License-Identifier: Apache-2.0
128
+ */
129
+ /*
130
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
131
+ SPDX-License-Identifier: Apache-2.0
132
+ */
133
+ /*
134
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
135
+ SPDX-License-Identifier: Apache-2.0
136
+ */
137
+ /* stylelint-disable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
138
+ /* stylelint-enable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
139
+ /*
140
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
141
+ SPDX-License-Identifier: Apache-2.0
142
+ */
143
+ /*
144
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
145
+ SPDX-License-Identifier: Apache-2.0
146
+ */
147
+ /*
148
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
149
+ SPDX-License-Identifier: Apache-2.0
150
+ */
151
+ /*
152
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
153
+ SPDX-License-Identifier: Apache-2.0
154
+ */
155
+ /*
156
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
157
+ SPDX-License-Identifier: Apache-2.0
158
+ */
159
+ /*
160
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
161
+ SPDX-License-Identifier: Apache-2.0
162
+ */
163
+ /*
164
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
165
+ SPDX-License-Identifier: Apache-2.0
166
+ */
167
+ /*
168
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
169
+ SPDX-License-Identifier: Apache-2.0
170
+ */
171
+ /*
172
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
173
+ SPDX-License-Identifier: Apache-2.0
174
+ */
175
+ /*
176
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
177
+ SPDX-License-Identifier: Apache-2.0
178
+ */
179
+ /* Style used for links in slots/components that are text heavy, to help links stand out among
180
+ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
181
+ .awsui_root_18gnm_17ax2_181:not(#\9) {
182
+ border-collapse: separate;
183
+ border-spacing: 0;
184
+ box-sizing: border-box;
185
+ caption-side: top;
186
+ cursor: auto;
187
+ direction: inherit;
188
+ empty-cells: show;
189
+ font-family: serif;
190
+ font-style: normal;
191
+ font-variant: normal;
192
+ font-stretch: normal;
193
+ hyphens: none;
194
+ letter-spacing: normal;
195
+ list-style: disc outside none;
196
+ tab-size: 8;
197
+ text-align: start;
198
+ text-indent: 0;
199
+ text-shadow: none;
200
+ text-transform: none;
201
+ visibility: visible;
202
+ white-space: normal;
203
+ word-spacing: normal;
204
+ font-size: var(--font-size-body-m-a7nh2n, 14px);
205
+ line-height: var(--line-height-body-m-2mh3ke, 20px);
206
+ color: var(--color-text-body-default-vvtq8u, #0f141a);
207
+ font-weight: 400;
208
+ font-family: var(--font-family-base-gmnpzl, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
209
+ -webkit-font-smoothing: auto;
210
+ -moz-osx-font-smoothing: auto;
211
+ font-family: var(--font-family-base-gmnpzl, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
212
+ font-size: var(--font-size-body-m-a7nh2n, 14px);
213
+ line-height: var(--line-height-heading-m-uoaqdh, 22px);
214
+ padding-block: var(--space-scaled-xxs-pfm1nx, 4px);
215
+ padding-inline: var(--space-scaled-xxs-pfm1nx, 4px);
216
+ }
217
+
218
+ .awsui_tree_18gnm_17ax2_218:not(#\9) {
219
+ margin-block: 0;
220
+ margin-inline: 0;
221
+ padding-block: 0;
222
+ padding-inline: 0;
223
+ }
@@ -0,0 +1,8 @@
1
+
2
+ // es-module interop with Babel and Typescript
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ module.exports.default = {
5
+ "root": "awsui_root_18gnm_17ax2_181",
6
+ "tree": "awsui_tree_18gnm_17ax2_218"
7
+ };
8
+
@@ -0,0 +1,10 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "root": "awsui_root_1js4f_l7ca9_5",
5
+ "tree": "awsui_tree_1js4f_l7ca9_6",
6
+ "treeitem": "awsui_treeitem_1js4f_l7ca9_7",
7
+ "expandable": "awsui_expandable_1js4f_l7ca9_8",
8
+ "expanded": "awsui_expanded_1js4f_l7ca9_9"
9
+ };
10
+
@@ -0,0 +1,11 @@
1
+ /*
2
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ .awsui_root_1js4f_l7ca9_5:not(#\9),
6
+ .awsui_tree_1js4f_l7ca9_6:not(#\9),
7
+ .awsui_treeitem_1js4f_l7ca9_7:not(#\9),
8
+ .awsui_expandable_1js4f_l7ca9_8:not(#\9),
9
+ .awsui_expanded_1js4f_l7ca9_9:not(#\9) {
10
+ /* used in test-utils */
11
+ }
@@ -0,0 +1,11 @@
1
+
2
+ // es-module interop with Babel and Typescript
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ module.exports.default = {
5
+ "root": "awsui_root_1js4f_l7ca9_5",
6
+ "tree": "awsui_tree_1js4f_l7ca9_6",
7
+ "treeitem": "awsui_treeitem_1js4f_l7ca9_7",
8
+ "expandable": "awsui_expandable_1js4f_l7ca9_8",
9
+ "expanded": "awsui_expanded_1js4f_l7ca9_9"
10
+ };
11
+
@@ -0,0 +1,21 @@
1
+ /// <reference types="react" />
2
+ import { TreeViewProps } from '../interfaces';
3
+ interface InternalTreeItemProps<T> extends Pick<TreeViewProps, 'expandedItems' | 'renderItem' | 'getItemId' | 'getItemChildren' | 'renderItemToggleIcon' | 'i18nStrings'> {
4
+ item: T;
5
+ index: number;
6
+ level: number;
7
+ onItemToggle: (detail: TreeViewProps.ItemToggleDetail<T>) => void;
8
+ }
9
+ declare const InternalTreeItem: <T>({
10
+ item,
11
+ index,
12
+ level,
13
+ i18nStrings,
14
+ expandedItems,
15
+ renderItemToggleIcon,
16
+ renderItem,
17
+ getItemId,
18
+ getItemChildren,
19
+ onItemToggle
20
+ }: InternalTreeItemProps<T>) => JSX.Element;
21
+ export default InternalTreeItem;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tree-view/tree-item/index.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,UAAU,qBAAqB,CAAC,CAAC,CAC/B,SAAQ,IAAI,CACV,aAAa,EACb,eAAe,GAAG,YAAY,GAAG,WAAW,GAAG,iBAAiB,GAAG,sBAAsB,GAAG,aAAa,CAC1G;IACD,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CACnE;AAED,QAAA,MAAM,gBAAgB,+KAmGrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,40 @@
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 { useInternalI18n } from '../../i18n/context';
6
+ import { ExpandToggleButton } from '../../internal/components/expand-toggle-button';
7
+ import InternalStructuredItem from '../../internal/components/structured-item';
8
+ import { joinStrings } from '../../internal/utils/strings';
9
+ import testUtilStyles from '../test-classes/styles.css.js';
10
+ import styles from './styles.css.js';
11
+ const InternalTreeItem = ({ item, index, level, i18nStrings, expandedItems = [], renderItemToggleIcon, renderItem, getItemId, getItemChildren, onItemToggle, }) => {
12
+ var _a, _b;
13
+ const i18n = useInternalI18n('tree-view');
14
+ const { icon, content, secondaryContent, actions, announcementLabel } = renderItem(item, index);
15
+ const id = getItemId(item, index);
16
+ const children = getItemChildren(item, index) || [];
17
+ const isExpandable = children.length > 0;
18
+ const isExpanded = isExpandable && expandedItems.includes(id);
19
+ const nextLevel = level + 1;
20
+ let customIcon = undefined;
21
+ if (isExpandable && renderItemToggleIcon) {
22
+ customIcon = renderItemToggleIcon({ expanded: isExpanded });
23
+ }
24
+ const itemLabelToAnnounce = announcementLabel
25
+ ? announcementLabel
26
+ : typeof content === 'string'
27
+ ? content
28
+ : '';
29
+ // Role `treeitem` isn't used in the initial release per discussion with A11Y team. It requires focus management to be implemented so they will be added as a follow up together.
30
+ return (React.createElement("li", { id: id, className: clsx(styles.treeitem, testUtilStyles.treeitem, isExpandable && [testUtilStyles.expandable], isExpanded && [testUtilStyles.expanded]), "aria-expanded": isExpandable ? isExpanded : undefined, "aria-level": level, "data-testid": `awsui-treeitem-${id}` },
31
+ React.createElement("div", { className: styles['expand-toggle-wrapper'] }, isExpandable && (React.createElement("div", { className: styles.toggle },
32
+ React.createElement(ExpandToggleButton, { isExpanded: isExpanded, customIcon: customIcon, expandButtonLabel: joinStrings(i18n('i18nStrings.expandButtonLabel', (_a = i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.expandButtonLabel) === null || _a === void 0 ? void 0 : _a.call(i18nStrings, item)), itemLabelToAnnounce), collapseButtonLabel: joinStrings(i18n('i18nStrings.collapseButtonLabel', (_b = i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.collapseButtonLabel) === null || _b === void 0 ? void 0 : _b.call(i18nStrings, item)), itemLabelToAnnounce), onExpandableItemToggle: () => onItemToggle({ id, item, expanded: !isExpanded }) })))),
33
+ React.createElement("div", { className: styles['structured-item-wrapper'] },
34
+ React.createElement(InternalStructuredItem, { icon: icon, content: content, secondaryContent: secondaryContent, actions: actions, wrapActions: false })),
35
+ isExpanded && children.length && (React.createElement("ul", { className: styles['treeitem-group'] }, children.map((child, index) => {
36
+ return (React.createElement(InternalTreeItem, { item: child, index: index, key: `${nextLevel}-${index}`, level: nextLevel, expandedItems: expandedItems, i18nStrings: i18nStrings, onItemToggle: onItemToggle, renderItem: renderItem, getItemId: getItemId, getItemChildren: getItemChildren, renderItemToggleIcon: renderItemToggleIcon }));
37
+ })))));
38
+ };
39
+ export default InternalTreeItem;
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tree-view/tree-item/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,sBAAsB,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D,OAAO,cAAc,MAAM,+BAA+B,CAAC;AAC3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAarC,MAAM,gBAAgB,GAAG,CAAK,EAC5B,IAAI,EACJ,KAAK,EACL,KAAK,EACL,WAAW,EACX,aAAa,GAAG,EAAE,EAClB,oBAAoB,EACpB,UAAU,EACV,SAAS,EACT,eAAe,EACf,YAAY,GACa,EAAE,EAAE;;IAC7B,MAAM,IAAI,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAE1C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,UAAU,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AAC","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 { useInternalI18n } from '../../i18n/context';\nimport { ExpandToggleButton } from '../../internal/components/expand-toggle-button';\nimport InternalStructuredItem from '../../internal/components/structured-item';\nimport { joinStrings } from '../../internal/utils/strings';\nimport { TreeViewProps } from '../interfaces';\n\nimport testUtilStyles from '../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface InternalTreeItemProps<T>\n extends Pick<\n TreeViewProps,\n 'expandedItems' | 'renderItem' | 'getItemId' | 'getItemChildren' | 'renderItemToggleIcon' | 'i18nStrings'\n > {\n item: T;\n index: number;\n level: number;\n onItemToggle: (detail: TreeViewProps.ItemToggleDetail<T>) => void;\n}\n\nconst InternalTreeItem = <T,>({\n item,\n index,\n level,\n i18nStrings,\n expandedItems = [],\n renderItemToggleIcon,\n renderItem,\n getItemId,\n getItemChildren,\n onItemToggle,\n}: InternalTreeItemProps<T>) => {\n const i18n = useInternalI18n('tree-view');\n\n const { icon, content, secondaryContent, actions, announcementLabel } = renderItem(item, index);\n const id = getItemId(item, index);\n const children = getItemChildren(item, index) || [];\n const isExpandable = children.length > 0;\n const isExpanded = isExpandable && expandedItems.includes(id);\n const nextLevel = level + 1;\n\n let customIcon: React.ReactNode | undefined = undefined;\n if (isExpandable && renderItemToggleIcon) {\n customIcon = renderItemToggleIcon({ expanded: isExpanded });\n }\n\n const itemLabelToAnnounce = announcementLabel\n ? announcementLabel\n : typeof content === 'string'\n ? (content as string)\n : '';\n\n // Role `treeitem` isn't used in the initial release per discussion with A11Y team. It requires focus management to be implemented so they will be added as a follow up together.\n return (\n <li\n id={id}\n className={clsx(\n styles.treeitem,\n testUtilStyles.treeitem,\n isExpandable && [testUtilStyles.expandable],\n isExpanded && [testUtilStyles.expanded]\n )}\n aria-expanded={isExpandable ? isExpanded : undefined}\n aria-level={level}\n data-testid={`awsui-treeitem-${id}`}\n >\n <div className={styles['expand-toggle-wrapper']}>\n {isExpandable && (\n <div className={styles.toggle}>\n <ExpandToggleButton\n isExpanded={isExpanded}\n customIcon={customIcon}\n expandButtonLabel={joinStrings(\n i18n('i18nStrings.expandButtonLabel', i18nStrings?.expandButtonLabel?.(item)),\n itemLabelToAnnounce\n )}\n collapseButtonLabel={joinStrings(\n i18n('i18nStrings.collapseButtonLabel', i18nStrings?.collapseButtonLabel?.(item)),\n itemLabelToAnnounce\n )}\n onExpandableItemToggle={() => onItemToggle({ id, item, expanded: !isExpanded })}\n />\n </div>\n )}\n </div>\n\n <div className={styles['structured-item-wrapper']}>\n <InternalStructuredItem\n icon={icon}\n content={content}\n secondaryContent={secondaryContent}\n actions={actions}\n wrapActions={false}\n />\n </div>\n\n {isExpanded && children.length && (\n <ul className={styles['treeitem-group']}>\n {children.map((child, index) => {\n return (\n <InternalTreeItem\n item={child}\n index={index}\n key={`${nextLevel}-${index}`}\n level={nextLevel}\n expandedItems={expandedItems}\n i18nStrings={i18nStrings}\n onItemToggle={onItemToggle}\n renderItem={renderItem}\n getItemId={getItemId}\n getItemChildren={getItemChildren}\n renderItemToggleIcon={renderItemToggleIcon}\n />\n );\n })}\n </ul>\n )}\n </li>\n );\n};\n\nexport default InternalTreeItem;\n"]}
@@ -0,0 +1,10 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "treeitem-group": "awsui_treeitem-group_1agpu_1w0en_181",
5
+ "treeitem": "awsui_treeitem_1agpu_1w0en_181",
6
+ "expand-toggle-wrapper": "awsui_expand-toggle-wrapper_1agpu_1w0en_198",
7
+ "toggle": "awsui_toggle_1agpu_1w0en_203",
8
+ "structured-item-wrapper": "awsui_structured-item-wrapper_1agpu_1w0en_208"
9
+ };
10
+