@cloudscape-design/components 3.0.676 → 3.0.677

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/button-dropdown/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAMnD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,QAAA,MAAM,cAAc,qGA4CnB,CAAC;AAGF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/button-dropdown/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAOnD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,QAAA,MAAM,cAAc,qGAgDnB,CAAC;AAGF,eAAe,cAAc,CAAC"}
@@ -3,6 +3,7 @@ import { __rest } from "tslib";
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  import React from 'react';
5
5
  import InternalButtonDropdown from './internal';
6
+ import { hasCheckboxItems } from './utils/utils';
6
7
  import { getBaseProps } from '../internal/base-component';
7
8
  import { applyDisplayName } from '../internal/utils/apply-display-name';
8
9
  import useBaseComponent from '../internal/hooks/use-base-component';
@@ -10,6 +11,10 @@ const ButtonDropdown = React.forwardRef((_a, ref) => {
10
11
  var { items, variant = 'normal', loading = false, loadingText, disabled = false, expandableGroups = false, expandToViewport = false, ariaLabel, children, onItemClick, onItemFollow, mainAction } = _a, props = __rest(_a, ["items", "variant", "loading", "loadingText", "disabled", "expandableGroups", "expandToViewport", "ariaLabel", "children", "onItemClick", "onItemFollow", "mainAction"]);
11
12
  const baseComponentProps = useBaseComponent('ButtonDropdown', {
12
13
  props: { expandToViewport, expandableGroups, variant },
14
+ metadata: {
15
+ mainAction: !!mainAction,
16
+ checkboxItems: hasCheckboxItems(items),
17
+ },
13
18
  });
14
19
  const baseProps = getBaseProps(props);
15
20
  return (React.createElement(InternalButtonDropdown, Object.assign({}, baseProps, baseComponentProps, { ref: ref, items: items, variant: variant, loading: loading, loadingText: loadingText, disabled: disabled, expandableGroups: expandableGroups, expandToViewport: expandToViewport, ariaLabel: ariaLabel, onItemClick: onItemClick, onItemFollow: onItemFollow, mainAction: mainAction }), children));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/button-dropdown/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,sBAAsB,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAIpE,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,CACE,EAcsB,EACtB,GAAuC,EACvC,EAAE;QAhBF,EACE,KAAK,EACL,OAAO,GAAG,QAAQ,EAClB,OAAO,GAAG,KAAK,EACf,WAAW,EACX,QAAQ,GAAG,KAAK,EAChB,gBAAgB,GAAG,KAAK,EACxB,gBAAgB,GAAG,KAAK,EACxB,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,OAEU,EADjB,KAAK,cAbV,wKAcC,CADS;IAIV,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,gBAAgB,EAAE;QAC5D,KAAK,EAAE,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE;KACvD,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,CACL,oBAAC,sBAAsB,oBACjB,SAAS,EACT,kBAAkB,IACtB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,KAErB,QAAQ,CACc,CAC1B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AACnD,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { ButtonDropdownProps } from './interfaces';\nimport InternalButtonDropdown from './internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\n\nexport { ButtonDropdownProps };\n\nconst ButtonDropdown = React.forwardRef(\n (\n {\n items,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n expandableGroups = false,\n expandToViewport = false,\n ariaLabel,\n children,\n onItemClick,\n onItemFollow,\n mainAction,\n ...props\n }: ButtonDropdownProps,\n ref: React.Ref<ButtonDropdownProps.Ref>\n ) => {\n const baseComponentProps = useBaseComponent('ButtonDropdown', {\n props: { expandToViewport, expandableGroups, variant },\n });\n const baseProps = getBaseProps(props);\n return (\n <InternalButtonDropdown\n {...baseProps}\n {...baseComponentProps}\n ref={ref}\n items={items}\n variant={variant}\n loading={loading}\n loadingText={loadingText}\n disabled={disabled}\n expandableGroups={expandableGroups}\n expandToViewport={expandToViewport}\n ariaLabel={ariaLabel}\n onItemClick={onItemClick}\n onItemFollow={onItemFollow}\n mainAction={mainAction}\n >\n {children}\n </InternalButtonDropdown>\n );\n }\n);\n\napplyDisplayName(ButtonDropdown, 'ButtonDropdown');\nexport default ButtonDropdown;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/button-dropdown/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,sBAAsB,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAIpE,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,CACE,EAcsB,EACtB,GAAuC,EACvC,EAAE;QAhBF,EACE,KAAK,EACL,OAAO,GAAG,QAAQ,EAClB,OAAO,GAAG,KAAK,EACf,WAAW,EACX,QAAQ,GAAG,KAAK,EAChB,gBAAgB,GAAG,KAAK,EACxB,gBAAgB,GAAG,KAAK,EACxB,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,OAEU,EADjB,KAAK,cAbV,wKAcC,CADS;IAIV,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,gBAAgB,EAAE;QAC5D,KAAK,EAAE,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE;QACtD,QAAQ,EAAE;YACR,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,aAAa,EAAE,gBAAgB,CAAC,KAAK,CAAC;SACvC;KACF,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,CACL,oBAAC,sBAAsB,oBACjB,SAAS,EACT,kBAAkB,IACtB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,KAErB,QAAQ,CACc,CAC1B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AACnD,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { ButtonDropdownProps } from './interfaces';\nimport InternalButtonDropdown from './internal';\nimport { hasCheckboxItems } from './utils/utils';\nimport { getBaseProps } from '../internal/base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\n\nexport { ButtonDropdownProps };\n\nconst ButtonDropdown = React.forwardRef(\n (\n {\n items,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n expandableGroups = false,\n expandToViewport = false,\n ariaLabel,\n children,\n onItemClick,\n onItemFollow,\n mainAction,\n ...props\n }: ButtonDropdownProps,\n ref: React.Ref<ButtonDropdownProps.Ref>\n ) => {\n const baseComponentProps = useBaseComponent('ButtonDropdown', {\n props: { expandToViewport, expandableGroups, variant },\n metadata: {\n mainAction: !!mainAction,\n checkboxItems: hasCheckboxItems(items),\n },\n });\n const baseProps = getBaseProps(props);\n return (\n <InternalButtonDropdown\n {...baseProps}\n {...baseComponentProps}\n ref={ref}\n items={items}\n variant={variant}\n loading={loading}\n loadingText={loadingText}\n disabled={disabled}\n expandableGroups={expandableGroups}\n expandToViewport={expandToViewport}\n ariaLabel={ariaLabel}\n onItemClick={onItemClick}\n onItemFollow={onItemFollow}\n mainAction={mainAction}\n >\n {children}\n </InternalButtonDropdown>\n );\n }\n);\n\napplyDisplayName(ButtonDropdown, 'ButtonDropdown');\nexport default ButtonDropdown;\n"]}
@@ -7,5 +7,6 @@ interface ItemsTreeApi {
7
7
  getParentIndex: (item: ButtonDropdownProps.ItemOrGroup) => TreeIndex | null;
8
8
  }
9
9
  export default function createItemsTree(items: ButtonDropdownProps.Items): ItemsTreeApi;
10
+ export declare function traverseItems(items: ButtonDropdownProps.Items, act: (item: ButtonDropdownProps.ItemOrGroup, index: TreeIndex) => void, parentIndex?: TreeIndex): void;
10
11
  export {};
11
12
  //# sourceMappingURL=create-items-tree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-items-tree.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/create-items-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAMpD,MAAM,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;AAEjC,UAAU,YAAY;IAEpB,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,mBAAmB,CAAC,WAAW,GAAG,IAAI,CAAC;IAGtE,YAAY,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,WAAW,KAAK,SAAS,CAAC;IAEnE,kBAAkB,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,SAAS,GAAG,IAAI,CAAC;IAE9E,cAAc,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,WAAW,KAAK,SAAS,GAAG,IAAI,CAAC;CAC7E;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,GAAG,YAAY,CAwDtF"}
1
+ {"version":3,"file":"create-items-tree.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/create-items-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAMpD,MAAM,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;AAEjC,UAAU,YAAY;IAEpB,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,mBAAmB,CAAC,WAAW,GAAG,IAAI,CAAC;IAGtE,YAAY,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,WAAW,KAAK,SAAS,CAAC;IAEnE,kBAAkB,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,SAAS,GAAG,IAAI,CAAC;IAE9E,cAAc,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,WAAW,KAAK,SAAS,GAAG,IAAI,CAAC;CAC7E;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,GAAG,YAAY,CAwDtF;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,mBAAmB,CAAC,KAAK,EAChC,GAAG,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,WAAW,EAAE,KAAK,EAAE,SAAS,KAAK,IAAI,EACtE,WAAW,GAAE,SAAc,QAU5B"}
@@ -46,7 +46,7 @@ export default function createItemsTree(items) {
46
46
  },
47
47
  };
48
48
  }
49
- function traverseItems(items, act, parentIndex = []) {
49
+ export function traverseItems(items, act, parentIndex = []) {
50
50
  items.forEach((item, index) => {
51
51
  const itemIndex = [...parentIndex, index];
52
52
  act(item, itemIndex);
@@ -1 +1 @@
1
- {"version":3,"file":"create-items-tree.js","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/create-items-tree.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAqBtC,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAgC;IACtE,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2C,CAAC;IACvE,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2C,CAAC;IACvE,MAAM,WAAW,GAAa,EAAE,CAAC;IA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CAAC,CAAC;YAEvC,IAAI,CAAC,QAAQ,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;aAC5D;YAED,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;YAEnC,YAAY;YACZ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;gBACtB,OAAO,IAAI,CAAC;aACb;YAED,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CACpB,KAAgC,EAChC,GAAsE,EACtE,cAAyB,EAAE;IAE3B,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,MAAM,SAAS,GAAG,CAAC,GAAG,WAAW,EAAE,KAAK,CAAC,CAAC;QAC1C,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAErB,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE;YACrB,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;SAC3C;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,KAAgB;IACtC,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAClD,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { isItemGroup } from './utils';\nimport { ButtonDropdownProps } from '../interfaces';\n\n// The function turns a tree of items into a structure optimized for lookup of\n// items and corresponding indices as well as iteration on indices in the given order.\n\n// As trees are multidimensional, the index is represented as an array\nexport type TreeIndex = number[];\n\ninterface ItemsTreeApi {\n // Returns an item for the given tree index or null if not found\n getItem: (index: TreeIndex) => ButtonDropdownProps.ItemOrGroup | null;\n // Returns the tree index of the given item. The item must be present\n // in the tree (referential comparison), or an error will be thrown\n getItemIndex: (item: ButtonDropdownProps.ItemOrGroup) => TreeIndex;\n // Returns the index of next or previous sequential node or null if out of bounds\n getSequentialIndex: (index: TreeIndex, direction: -1 | 1) => TreeIndex | null;\n // Returns parent tree index of a given item or null if no parent is present\n getParentIndex: (item: ButtonDropdownProps.ItemOrGroup) => TreeIndex | null;\n}\n\nexport default function createItemsTree(items: ButtonDropdownProps.Items): ItemsTreeApi {\n const itemToIndex = new Map<ButtonDropdownProps.ItemOrGroup, string>();\n const indexToItem = new Map<string, ButtonDropdownProps.ItemOrGroup>();\n const flatIndices: string[] = [];\n\n traverseItems(items, (item, index) => {\n const indexKey = stringifyIndex(index);\n itemToIndex.set(item, indexKey);\n indexToItem.set(indexKey, item);\n flatIndices.push(indexKey);\n });\n\n return {\n getItem: (index: TreeIndex): ButtonDropdownProps.ItemOrGroup | null => {\n const indexKey = stringifyIndex(index);\n\n return indexToItem.get(indexKey) || null;\n },\n getItemIndex: (item: ButtonDropdownProps.ItemOrGroup): TreeIndex => {\n const indexKey = itemToIndex.get(item);\n\n if (!indexKey) {\n throw new Error('Invariant violation: item is not found.');\n }\n\n return parseIndex(indexKey);\n },\n getSequentialIndex: (index: TreeIndex, direction: -1 | 1): TreeIndex | null => {\n const indexKey = stringifyIndex(index);\n const position = flatIndices.indexOf(indexKey);\n\n const nextIndexKey = flatIndices[position + direction];\n\n if (!nextIndexKey) {\n return null;\n }\n\n return parseIndex(nextIndexKey);\n },\n getParentIndex: (item: ButtonDropdownProps.ItemOrGroup): TreeIndex | null => {\n const indexKey = itemToIndex.get(item);\n\n if (!indexKey) {\n throw new Error('Invariant violation: item is not found.');\n }\n\n const index = parseIndex(indexKey);\n\n // No parent\n if (index.length === 1) {\n return null;\n }\n\n return index.slice(0, index.length - 1);\n },\n };\n}\n\nfunction traverseItems(\n items: ButtonDropdownProps.Items,\n act: (item: ButtonDropdownProps.ItemOrGroup, index: TreeIndex) => void,\n parentIndex: TreeIndex = []\n) {\n items.forEach((item, index) => {\n const itemIndex = [...parentIndex, index];\n act(item, itemIndex);\n\n if (isItemGroup(item)) {\n traverseItems(item.items, act, itemIndex);\n }\n });\n}\n\nfunction stringifyIndex(index: TreeIndex): string {\n return index.join('-');\n}\n\nfunction parseIndex(index: string): TreeIndex {\n return index.split('-').map(it => parseInt(it));\n}\n"]}
1
+ {"version":3,"file":"create-items-tree.js","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/create-items-tree.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAqBtC,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAgC;IACtE,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2C,CAAC;IACvE,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2C,CAAC;IACvE,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,aAAa,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACnC,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QACvC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAChC,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAChC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,CAAC,KAAgB,EAA0C,EAAE;YACpE,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;YAEvC,OAAO,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC;Q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EAAE,EAAE;QAC5B,MAAM,SAAS,GAAG,CAAC,GAAG,WAAW,EAAE,KAAK,CAAC,CAAC;QAC1C,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAErB,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE;YACrB,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;SAC3C;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,KAAgB;IACtC,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAClD,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { isItemGroup } from './utils';\nimport { ButtonDropdownProps } from '../interfaces';\n\n// The function turns a tree of items into a structure optimized for lookup of\n// items and corresponding indices as well as iteration on indices in the given order.\n\n// As trees are multidimensional, the index is represented as an array\nexport type TreeIndex = number[];\n\ninterface ItemsTreeApi {\n // Returns an item for the given tree index or null if not found\n getItem: (index: TreeIndex) => ButtonDropdownProps.ItemOrGroup | null;\n // Returns the tree index of the given item. The item must be present\n // in the tree (referential comparison), or an error will be thrown\n getItemIndex: (item: ButtonDropdownProps.ItemOrGroup) => TreeIndex;\n // Returns the index of next or previous sequential node or null if out of bounds\n getSequentialIndex: (index: TreeIndex, direction: -1 | 1) => TreeIndex | null;\n // Returns parent tree index of a given item or null if no parent is present\n getParentIndex: (item: ButtonDropdownProps.ItemOrGroup) => TreeIndex | null;\n}\n\nexport default function createItemsTree(items: ButtonDropdownProps.Items): ItemsTreeApi {\n const itemToIndex = new Map<ButtonDropdownProps.ItemOrGroup, string>();\n const indexToItem = new Map<string, ButtonDropdownProps.ItemOrGroup>();\n const flatIndices: string[] = [];\n\n traverseItems(items, (item, index) => {\n const indexKey = stringifyIndex(index);\n itemToIndex.set(item, indexKey);\n indexToItem.set(indexKey, item);\n flatIndices.push(indexKey);\n });\n\n return {\n getItem: (index: TreeIndex): ButtonDropdownProps.ItemOrGroup | null => {\n const indexKey = stringifyIndex(index);\n\n return indexToItem.get(indexKey) || null;\n },\n getItemIndex: (item: ButtonDropdownProps.ItemOrGroup): TreeIndex => {\n const indexKey = itemToIndex.get(item);\n\n if (!indexKey) {\n throw new Error('Invariant violation: item is not found.');\n }\n\n return parseIndex(indexKey);\n },\n getSequentialIndex: (index: TreeIndex, direction: -1 | 1): TreeIndex | null => {\n const indexKey = stringifyIndex(index);\n const position = flatIndices.indexOf(indexKey);\n\n const nextIndexKey = flatIndices[position + direction];\n\n if (!nextIndexKey) {\n return null;\n }\n\n return parseIndex(nextIndexKey);\n },\n getParentIndex: (item: ButtonDropdownProps.ItemOrGroup): TreeIndex | null => {\n const indexKey = itemToIndex.get(item);\n\n if (!indexKey) {\n throw new Error('Invariant violation: item is not found.');\n }\n\n const index = parseIndex(indexKey);\n\n // No parent\n if (index.length === 1) {\n return null;\n }\n\n return index.slice(0, index.length - 1);\n },\n };\n}\n\nexport function traverseItems(\n items: ButtonDropdownProps.Items,\n act: (item: ButtonDropdownProps.ItemOrGroup, index: TreeIndex) => void,\n parentIndex: TreeIndex = []\n) {\n items.forEach((item, index) => {\n const itemIndex = [...parentIndex, index];\n act(item, itemIndex);\n\n if (isItemGroup(item)) {\n traverseItems(item.items, act, itemIndex);\n }\n });\n}\n\nfunction stringifyIndex(index: TreeIndex): string {\n return index.join('-');\n}\n\nfunction parseIndex(index: string): TreeIndex {\n return index.split('-').map(it => parseInt(it));\n}\n"]}
@@ -5,4 +5,5 @@ export declare const isCheckboxItem: (item: ButtonDropdownProps.ItemOrGroup) =>
5
5
  export declare const getItemTarget: (item: ButtonDropdownProps.Item) => "_blank" | undefined;
6
6
  export declare function indexIncludes(source: number[], target: number[]): boolean;
7
7
  export declare function indexEquals(left: number[], right: number[]): boolean;
8
+ export declare function hasCheckboxItems(items: ButtonDropdownProps.Items): boolean;
8
9
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9D,eAAO,MAAM,WAAW,SAAU,oBAAoB,WAAW,0CACI,CAAC;AAEtE,eAAO,MAAM,UAAU,SAAU,QAAQ,GAAG,oBAAoB,WAAW,qBAC5B,CAAC;AAEhD,eAAO,MAAM,cAAc,SAAU,oBAAoB,WAAW,6CACQ,CAAC;AAE7E,eAAO,MAAM,aAAa,SAAU,oBAAoB,IAAI,yBAA2C,CAAC;AAExG,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAQ/D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,WAY1D"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9D,eAAO,MAAM,WAAW,SAAU,oBAAoB,WAAW,0CACI,CAAC;AAEtE,eAAO,MAAM,UAAU,SAAU,QAAQ,GAAG,oBAAoB,WAAW,qBAC5B,CAAC;AAEhD,eAAO,MAAM,cAAc,SAAU,oBAAoB,WAAW,6CACQ,CAAC;AAE7E,eAAO,MAAM,aAAa,SAAU,oBAAoB,IAAI,yBAA2C,CAAC;AAExG,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAQ/D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,WAY1D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,WAQhE"}
@@ -1,3 +1,4 @@
1
+ import { traverseItems } from './create-items-tree';
1
2
  export const isItemGroup = (item) => item && item.items !== undefined;
2
3
  export const isLinkItem = (item) => item && item.href !== undefined;
3
4
  export const isCheckboxItem = (item) => item && item.itemType === 'checkbox';
@@ -21,4 +22,13 @@ export function indexEquals(left, right) {
21
22
  }
22
23
  return true;
23
24
  }
25
+ export function hasCheckboxItems(items) {
26
+ let hasCheckboxItems = false;
27
+ traverseItems(items, item => {
28
+ if (item.itemType === 'checkbox') {
29
+ hasCheckboxItems = true;
30
+ }
31
+ });
32
+ return hasCheckboxItems;
33
+ }
24
34
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/utils.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAqC,EAAyC,EAAE,CAC1G,IAAI,IAAK,IAAsC,CAAC,KAAK,KAAK,SAAS,CAAC;AAEtE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAgD,EAAoB,EAAE,CAC/F,IAAI,IAAK,IAAiB,CAAC,IAAI,KAAK,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAqC,EAA4C,EAAE,CAChH,IAAI,IAAK,IAAyC,CAAC,QAAQ,KAAK,UAAU,CAAC;AAE7E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAA8B,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAExG,MAAM,UAAU,aAAa,CAAC,MAAgB,EAAE,MAAgB;IAC9D,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAClD,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE;YACnC,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAc,EAAE,KAAe;IACzD,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE;QAChC,OAAO,KAAK,CAAC;KACd;IAED,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAChD,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,EAAE;YAChC,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ButtonDropdownProps, LinkItem } from '../interfaces';\n\nexport const isItemGroup = (item: ButtonDropdownProps.ItemOrGroup): item is ButtonDropdownProps.ItemGroup =>\n item && (item as ButtonDropdownProps.ItemGroup).items !== undefined;\n\nexport const isLinkItem = (item: LinkItem | ButtonDropdownProps.ItemOrGroup): item is LinkItem =>\n item && (item as LinkItem).href !== undefined;\n\nexport const isCheckboxItem = (item: ButtonDropdownProps.ItemOrGroup): item is ButtonDropdownProps.CheckboxItem =>\n item && (item as ButtonDropdownProps.CheckboxItem).itemType === 'checkbox';\n\nexport const getItemTarget = (item: ButtonDropdownProps.Item) => (item.external ? '_blank' : undefined);\n\nexport function indexIncludes(source: number[], target: number[]) {\n for (let index = 0; index < source.length; index++) {\n if (source[index] !== target[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function indexEquals(left: number[], right: number[]) {\n if (left.length !== right.length) {\n return false;\n }\n\n for (let index = 0; index < left.length; index++) {\n if (left[index] !== right[index]) {\n return false;\n }\n }\n\n return true;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAqC,EAAyC,EAAE,CAC1G,IAAI,IAAK,IAAsC,CAAC,KAAK,KAAK,SAAS,CAAC;AAEtE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAgD,EAAoB,EAAE,CAC/F,IAAI,IAAK,IAAiB,CAAC,IAAI,KAAK,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAqC,EAA4C,EAAE,CAChH,IAAI,IAAK,IAAyC,CAAC,QAAQ,KAAK,UAAU,CAAC;AAE7E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAA8B,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAExG,MAAM,UAAU,aAAa,CAAC,MAAgB,EAAE,MAAgB;IAC9D,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAClD,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE;YACnC,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAc,EAAE,KAAe;IACzD,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE;QAChC,OAAO,KAAK,CAAC;KACd;IAED,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAChD,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,EAAE;YAChC,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAgC;IAC/D,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE;QAC1B,IAAI,IAAI,CAAC,QAAQ,KAAK,UAAU,EAAE;YAChC,gBAAgB,GAAG,IAAI,CAAC;SACzB;IACH,CAAC,CAAC,CAAC;IACH,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ButtonDropdownProps, LinkItem } from '../interfaces';\nimport { traverseItems } from './create-items-tree';\n\nexport const isItemGroup = (item: ButtonDropdownProps.ItemOrGroup): item is ButtonDropdownProps.ItemGroup =>\n item && (item as ButtonDropdownProps.ItemGroup).items !== undefined;\n\nexport const isLinkItem = (item: LinkItem | ButtonDropdownProps.ItemOrGroup): item is LinkItem =>\n item && (item as LinkItem).href !== undefined;\n\nexport const isCheckboxItem = (item: ButtonDropdownProps.ItemOrGroup): item is ButtonDropdownProps.CheckboxItem =>\n item && (item as ButtonDropdownProps.CheckboxItem).itemType === 'checkbox';\n\nexport const getItemTarget = (item: ButtonDropdownProps.Item) => (item.external ? '_blank' : undefined);\n\nexport function indexIncludes(source: number[], target: number[]) {\n for (let index = 0; index < source.length; index++) {\n if (source[index] !== target[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function indexEquals(left: number[], right: number[]) {\n if (left.length !== right.length) {\n return false;\n }\n\n for (let index = 0; index < left.length; index++) {\n if (left[index] !== right[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function hasCheckboxItems(items: ButtonDropdownProps.Items) {\n let hasCheckboxItems = false;\n traverseItems(items, item => {\n if (item.itemType === 'checkbox') {\n hasCheckboxItems = true;\n }\n });\n return hasCheckboxItems;\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (dba99012)";
2
+ export var PACKAGE_VERSION = "3.0.0 (fcd9ab11)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (dba99012)",
3
+ "PACKAGE_VERSION": "3.0.0 (fcd9ab11)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "dba99012a8367a488ec497052ba97f2b58964ed9"
2
+ "commit": "fcd9ab11a71083f7476ba2c5f0a494ef7c047398"
3
3
  }
package/package.json CHANGED
@@ -120,7 +120,7 @@
120
120
  "./internal/base-component/index.js",
121
121
  "./internal/base-component/styles.css.js"
122
122
  ],
123
- "version": "3.0.676",
123
+ "version": "3.0.677",
124
124
  "repository": {
125
125
  "type": "git",
126
126
  "url": "https://github.com/cloudscape-design/components.git"