@cloudscape-design/components 3.0.711 → 3.0.713

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 (40) hide show
  1. package/autosuggest/options-controller.d.ts.map +1 -1
  2. package/autosuggest/options-controller.js +11 -4
  3. package/autosuggest/options-controller.js.map +1 -1
  4. package/internal/components/dropdown/index.d.ts.map +1 -1
  5. package/internal/components/dropdown/index.js +9 -11
  6. package/internal/components/dropdown/index.js.map +1 -1
  7. package/internal/environment.js +1 -1
  8. package/internal/environment.json +1 -1
  9. package/internal/manifest.json +1 -1
  10. package/internal/utils/scrollable-containers.d.ts.map +1 -1
  11. package/internal/utils/scrollable-containers.js +6 -4
  12. package/internal/utils/scrollable-containers.js.map +1 -1
  13. package/package.json +1 -1
  14. package/property-filter/index.d.ts.map +1 -1
  15. package/property-filter/index.js +4 -14
  16. package/property-filter/index.js.map +1 -1
  17. package/property-filter/styles.css.js +46 -31
  18. package/property-filter/styles.scoped.css +134 -33
  19. package/property-filter/styles.selectors.js +46 -31
  20. package/property-filter/test-classes/styles.css.js +16 -14
  21. package/property-filter/test-classes/styles.scoped.css +22 -14
  22. package/property-filter/test-classes/styles.selectors.js +16 -14
  23. package/property-filter/token-editor-grouped.d.ts +32 -0
  24. package/property-filter/token-editor-grouped.d.ts.map +1 -0
  25. package/property-filter/token-editor-grouped.js +114 -0
  26. package/property-filter/token-editor-grouped.js.map +1 -0
  27. package/property-filter/token-editor.d.ts +34 -3
  28. package/property-filter/token-editor.d.ts.map +1 -1
  29. package/property-filter/token-editor.js +8 -13
  30. package/property-filter/token-editor.js.map +1 -1
  31. package/property-filter/token.d.ts.map +1 -1
  32. package/property-filter/token.js +6 -1
  33. package/property-filter/token.js.map +1 -1
  34. package/test-utils/dom/property-filter/index.d.ts +12 -0
  35. package/test-utils/dom/property-filter/index.js +40 -1
  36. package/test-utils/dom/property-filter/index.js.map +1 -1
  37. package/test-utils/selectors/property-filter/index.d.ts +12 -0
  38. package/test-utils/selectors/property-filter/index.js +40 -1
  39. package/test-utils/selectors/property-filter/index.js.map +1 -1
  40. package/test-utils/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"options-controller.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/options-controller.ts"],"names":[],"mappings":"AASA,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EAEvB,MAAM,gEAAgE,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGjE,KAAK,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;AAExC,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAC9C,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC;IACrD,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,YAAY,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,qBAAsB,SAAQ,sBAAsB,CAAC,eAAe,CAAC;IACpF,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,SAAS,GAAG,gBAAgB,CAAC,WAAW,CAAC;CACnF;AAED,MAAM,WAAW,wBAAyB,SAAQ,yBAAyB,CAAC,eAAe,CAAC;IAC1F,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,mCAAmC,IAAI,OAAO,CAAC;IAC/C,+BAA+B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrD,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACnD;AAQD,eAAO,MAAM,mBAAmB,+GAQ7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"}
@@ -37,11 +37,18 @@ export const useAutosuggestItems = ({ options, filterValue, filterText, filterin
37
37
  isHighlightable,
38
38
  });
39
39
  const selectHighlightedOptionWithKeyboard = () => {
40
- if (highlightedOptionState.highlightedOption && isInteractive(highlightedOptionState.highlightedOption)) {
41
- onSelectItem(highlightedOptionState.highlightedOption);
42
- return true;
40
+ var _a;
41
+ if (highlightedOptionState.highlightedOption && !isInteractive(highlightedOptionState.highlightedOption)) {
42
+ // skip selection when a non-interactive item is active
43
+ return false;
43
44
  }
44
- return false;
45
+ onSelectItem((_a = highlightedOptionState.highlightedOption) !== null && _a !== void 0 ? _a : {
46
+ // put use-entered item as a fallback
47
+ value: filterValue,
48
+ type: 'use-entered',
49
+ option: { value: filterValue },
50
+ });
51
+ return true;
45
52
  };
46
53
  const highlightVisibleOptionWithMouse = (index) => {
47
54
  if (filteredItems[index] && isHighlightable(filteredItems[index])) {
@@ -1 +1 @@
1
- {"version":3,"file":"options-controller.js","sourceRoot":"","sources":["../../../src/autosuggest/options-controller.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,EAGL,oBAAoB,GACrB,MAAM,gEAAgE,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AA2B9C,MAAM,eAAe,GAAG,CAAC,MAAwB,EAAE,EAAE;IACnD,OAAO,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,MAAwB,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAA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G,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;SACzC;QAED,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,uBAAuB,CAAC;QAEjE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,OAAO,CAAC,aAAsC;IACrD,OAAO,SAAS,IAAI,aAAa,CAAC;AACpC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useMemo, useState } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { generateTestIndexes } from '../internal/components/options-list/utils/test-indexes';\nimport {\n HighlightedOptionHandlers,\n HighlightedOptionState,\n useHighlightedOption,\n} from '../internal/components/options-list/utils/use-highlight-option';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\nimport { filterOptions } from './utils/utils';\n\ntype Options = AutosuggestProps.Options;\n\nexport interface UseAutosuggestItemsProps {\n options: Options;\n filterValue: string;\n filterText: string;\n filteringType: AutosuggestProps.FilteringType;\n enteredTextLabel?: AutosuggestProps.EnteredTextLabel;\n hideEnteredTextLabel?: boolean;\n onSelectItem: (option: AutosuggestItem) => void;\n}\n\nexport interface AutosuggestItemsState extends HighlightedOptionState<AutosuggestItem> {\n items: readonly AutosuggestItem[];\n showAll: boolean;\n getItemGroup: (item: AutosuggestItem) => undefined | AutosuggestProps.OptionGroup;\n}\n\nexport interface AutosuggestItemsHandlers extends HighlightedOptionHandlers<AutosuggestItem> {\n setShowAll(value: boolean): void;\n selectHighlightedOptionWithKeyboard(): boolean;\n highlightVisibleOptionWithMouse(index: number): void;\n selectVisibleOptionWithMouse(index: number): void;\n}\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst isInteractive = (option?: AutosuggestItem) => !!option && !option.disabled && option.type !== 'parent';\n\nexport const useAutosuggestItems = ({\n options,\n filterValue,\n filterText,\n filteringType,\n enteredTextLabel,\n hideEnteredTextLabel,\n onSelectItem,\n}: UseAutosuggestItemsProps): [AutosuggestItemsState, AutosuggestItemsHandlers] => {\n const i18n = useInternalI18n('autosuggest');\n const [showAll, setShowAll] = useState(false);\n\n const { items, getItemGroup, getItemParent } = useMemo(() => createItems(options), [options]);\n\n const enteredItemLabel = i18n('enteredTextLabel', enteredTextLabel?.(filterValue), format =>\n format({ value: filterValue })\n );\n if (!enteredItemLabel) {\n warnOnce('Autosuggest', 'A value for enteredTextLabel must be provided.');\n }\n\n const filteredItems = useMemo(() => {\n const filteredItems = filteringType === 'auto' && !showAll ? filterOptions(items, filterText) : [...items];\n if (filterValue && !hideEnteredTextLabel) {\n filteredItems.unshift({\n value: filterValue,\n type: 'use-entered',\n label: enteredItemLabel,\n option: { value: filterValue },\n });\n }\n generateTestIndexes(filteredItems, getItemParent);\n return filteredItems;\n }, [filteringType, showAll, items, filterText, filterValue, hideEnteredTextLabel, getItemParent, enteredItemLabel]);\n\n const [highlightedOptionState, highlightedOptionHandlers] = useHighlightedOption({\n options: filteredItems,\n isHighlightable,\n });\n\n const selectHighlightedOptionWithKeyboard = () => {\n if (highlightedOptionState.highlightedOption && isInteractive(highlightedOptionState.highlightedOption)) {\n onSelectItem(highlightedOptionState.highlightedOption);\n return true;\n }\n return false;\n };\n\n const highlightVisibleOptionWithMouse = (index: number) => {\n if (filteredItems[index] && isHighlightable(filteredItems[index])) {\n highlightedOptionHandlers.setHighlightedIndexWithMouse(index);\n }\n };\n\n const selectVisibleOptionWithMouse = (index: number) => {\n if (filteredItems[index] && isInteractive(filteredItems[index])) {\n onSelectItem(filteredItems[index]);\n }\n };\n\n return [\n { ...highlightedOptionState, items: filteredItems, showAll, getItemGroup },\n {\n ...highlightedOptionHandlers,\n setShowAll,\n selectHighlightedOptionWithKeyboard,\n highlightVisibleOptionWithMouse,\n selectVisibleOptionWithMouse,\n },\n ];\n};\n\nfunction createItems(options: Options) {\n const items: AutosuggestItem[] = [];\n const itemToGroup = new WeakMap<AutosuggestItem, AutosuggestItem>();\n const getItemParent = (item: AutosuggestItem) => itemToGroup.get(item);\n const getItemGroup = (item: AutosuggestItem) => getItemParent(item)?.option as AutosuggestProps.OptionGroup;\n\n for (const option of options) {\n if (isGroup(option)) {\n for (const item of flattenGroup(option)) {\n items.push(item);\n }\n } else {\n items.push({ ...option, option });\n }\n }\n\n function flattenGroup(group: AutosuggestProps.OptionGroup) {\n const { options, ...rest } = group;\n\n let hasOnlyDisabledChildren = true;\n\n const groupItem: AutosuggestItem = { ...rest, type: 'parent', option: group };\n\n const items: AutosuggestItem[] = [groupItem];\n\n for (const option of options) {\n if (!option.disabled) {\n hasOnlyDisabledChildren = false;\n }\n\n const childOption: AutosuggestItem = {\n ...option,\n type: 'child',\n disabled: option.disabled || rest.disabled,\n option,\n };\n\n items.push(childOption);\n\n itemToGroup.set(childOption, groupItem);\n }\n\n items[0].disabled = items[0].disabled || hasOnlyDisabledChildren;\n\n return items;\n }\n\n return { items, getItemGroup, getItemParent };\n}\n\nfunction isGroup(optionOrGroup: AutosuggestProps.Option): optionOrGroup is AutosuggestProps.OptionGroup {\n return 'options' in optionOrGroup;\n}\n"]}
1
+ {"version":3,"file":"options-controller.js","sourceRoot":"","sources":["../../../src/autosuggest/options-controller.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,EAGL,oBAAoB,GACrB,MAAM,gEAAgE,CAA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AQ,EAAE,MAAM,EAAE,KAAK,GAAE,CAAC;QAE9E,MAAM,KAAK,GAAsB,CAAC,SAAS,CAAC,CAAC;QAE7C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;gBACpB,uBAAuB,GAAG,KAAK,CAAC;aACjC;YAED,MAAM,WAAW,mCACZ,MAAM,KACT,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAC1C,MAAM,GACP,CAAC;YAEF,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAExB,WAAW,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;SACzC;QAED,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,uBAAuB,CAAC;QAEjE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,OAAO,CAAC,aAAsC;IACrD,OAAO,SAAS,IAAI,aAAa,CAAC;AACpC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useMemo, useState } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { generateTestIndexes } from '../internal/components/options-list/utils/test-indexes';\nimport {\n HighlightedOptionHandlers,\n HighlightedOptionState,\n useHighlightedOption,\n} from '../internal/components/options-list/utils/use-highlight-option';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\nimport { filterOptions } from './utils/utils';\n\ntype Options = AutosuggestProps.Options;\n\nexport interface UseAutosuggestItemsProps {\n options: Options;\n filterValue: string;\n filterText: string;\n filteringType: AutosuggestProps.FilteringType;\n enteredTextLabel?: AutosuggestProps.EnteredTextLabel;\n hideEnteredTextLabel?: boolean;\n onSelectItem: (option: AutosuggestItem) => void;\n}\n\nexport interface AutosuggestItemsState extends HighlightedOptionState<AutosuggestItem> {\n items: readonly AutosuggestItem[];\n showAll: boolean;\n getItemGroup: (item: AutosuggestItem) => undefined | AutosuggestProps.OptionGroup;\n}\n\nexport interface AutosuggestItemsHandlers extends HighlightedOptionHandlers<AutosuggestItem> {\n setShowAll(value: boolean): void;\n selectHighlightedOptionWithKeyboard(): boolean;\n highlightVisibleOptionWithMouse(index: number): void;\n selectVisibleOptionWithMouse(index: number): void;\n}\n\nconst isHighlightable = (option?: AutosuggestItem) => {\n return !!option && option.type !== 'parent';\n};\n\nconst isInteractive = (option?: AutosuggestItem) => !!option && !option.disabled && option.type !== 'parent';\n\nexport const useAutosuggestItems = ({\n options,\n filterValue,\n filterText,\n filteringType,\n enteredTextLabel,\n hideEnteredTextLabel,\n onSelectItem,\n}: UseAutosuggestItemsProps): [AutosuggestItemsState, AutosuggestItemsHandlers] => {\n const i18n = useInternalI18n('autosuggest');\n const [showAll, setShowAll] = useState(false);\n\n const { items, getItemGroup, getItemParent } = useMemo(() => createItems(options), [options]);\n\n const enteredItemLabel = i18n('enteredTextLabel', enteredTextLabel?.(filterValue), format =>\n format({ value: filterValue })\n );\n if (!enteredItemLabel) {\n warnOnce('Autosuggest', 'A value for enteredTextLabel must be provided.');\n }\n\n const filteredItems = useMemo(() => {\n const filteredItems = filteringType === 'auto' && !showAll ? filterOptions(items, filterText) : [...items];\n if (filterValue && !hideEnteredTextLabel) {\n filteredItems.unshift({\n value: filterValue,\n type: 'use-entered',\n label: enteredItemLabel,\n option: { value: filterValue },\n });\n }\n generateTestIndexes(filteredItems, getItemParent);\n return filteredItems;\n }, [filteringType, showAll, items, filterText, filterValue, hideEnteredTextLabel, getItemParent, enteredItemLabel]);\n\n const [highlightedOptionState, highlightedOptionHandlers] = useHighlightedOption({\n options: filteredItems,\n isHighlightable,\n });\n\n const selectHighlightedOptionWithKeyboard = () => {\n if (highlightedOptionState.highlightedOption && !isInteractive(highlightedOptionState.highlightedOption)) {\n // skip selection when a non-interactive item is active\n return false;\n }\n onSelectItem(\n highlightedOptionState.highlightedOption ?? {\n // put use-entered item as a fallback\n value: filterValue,\n type: 'use-entered',\n option: { value: filterValue },\n }\n );\n return true;\n };\n\n const highlightVisibleOptionWithMouse = (index: number) => {\n if (filteredItems[index] && isHighlightable(filteredItems[index])) {\n highlightedOptionHandlers.setHighlightedIndexWithMouse(index);\n }\n };\n\n const selectVisibleOptionWithMouse = (index: number) => {\n if (filteredItems[index] && isInteractive(filteredItems[index])) {\n onSelectItem(filteredItems[index]);\n }\n };\n\n return [\n { ...highlightedOptionState, items: filteredItems, showAll, getItemGroup },\n {\n ...highlightedOptionHandlers,\n setShowAll,\n selectHighlightedOptionWithKeyboard,\n highlightVisibleOptionWithMouse,\n selectVisibleOptionWithMouse,\n },\n ];\n};\n\nfunction createItems(options: Options) {\n const items: AutosuggestItem[] = [];\n const itemToGroup = new WeakMap<AutosuggestItem, AutosuggestItem>();\n const getItemParent = (item: AutosuggestItem) => itemToGroup.get(item);\n const getItemGroup = (item: AutosuggestItem) => getItemParent(item)?.option as AutosuggestProps.OptionGroup;\n\n for (const option of options) {\n if (isGroup(option)) {\n for (const item of flattenGroup(option)) {\n items.push(item);\n }\n } else {\n items.push({ ...option, option });\n }\n }\n\n function flattenGroup(group: AutosuggestProps.OptionGroup) {\n const { options, ...rest } = group;\n\n let hasOnlyDisabledChildren = true;\n\n const groupItem: AutosuggestItem = { ...rest, type: 'parent', option: group };\n\n const items: AutosuggestItem[] = [groupItem];\n\n for (const option of options) {\n if (!option.disabled) {\n hasOnlyDisabledChildren = false;\n }\n\n const childOption: AutosuggestItem = {\n ...option,\n type: 'child',\n disabled: option.disabled || rest.disabled,\n option,\n };\n\n items.push(childOption);\n\n itemToGroup.set(childOption, groupItem);\n }\n\n items[0].disabled = items[0].disabled || hasOnlyDisabledChildren;\n\n return items;\n }\n\n return { items, getItemGroup, getItemParent };\n}\n\nfunction isGroup(optionOrGroup: AutosuggestProps.Option): optionOrGroup is AutosuggestProps.OptionGroup {\n return 'options' in optionOrGroup;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":";AA4BA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAsH7C,QAAA,MAAM,QAAQ,iXA2BX,aAAa,gBAmTf,CAAC;AAMF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":";AA4BA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA6H7C,QAAA,MAAM,QAAQ,iXA2BX,aAAa,gBAoTf,CAAC;AAMF,eAAe,QAAQ,CAAC"}
@@ -19,18 +19,16 @@ import { Transition } from '../transition';
19
19
  import { DropdownContextProvider } from './context';
20
20
  import { calculatePosition, defaultMaxDropdownWidth, hasEnoughSpaceToStretchBeyondTriggerWidth, } from './dropdown-fit-handler';
21
21
  import styles from './styles.css.js';
22
- const DropdownContainer = ({ children, renderWithPortal = false, id, referrerId, open }) => {
23
- if (renderWithPortal) {
24
- if (open) {
25
- return createPortal(React.createElement("div", { id: id, "data-awsui-referrer-id": referrerId }, children), document.body);
26
- }
27
- else {
28
- return null;
29
- }
30
- }
31
- else {
22
+ const DropdownContainer = ({ triggerRef, children, renderWithPortal, id, referrerId, open, }) => {
23
+ var _a, _b;
24
+ if (!renderWithPortal) {
32
25
  return React.createElement(React.Fragment, null, children);
33
26
  }
27
+ if (!open) {
28
+ return null;
29
+ }
30
+ const currentDocument = (_b = (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument) !== null && _b !== void 0 ? _b : document;
31
+ return createPortal(React.createElement("div", { id: id, "data-awsui-referrer-id": referrerId }, children), currentDocument.body);
34
32
  };
35
33
  const TransitionContent = ({ state, transitionRef, dropdownClasses, stretchWidth, interior, isRefresh, dropdownRef, verticalContainerRef, expandToViewport, stretchBeyondTriggerWidth, header, children, footer, position, open, onMouseDown, id, role, ariaLabelledby, ariaDescribedby, }) => {
36
34
  const contentRef = useMergeRefs(dropdownRef, transitionRef);
@@ -254,7 +252,7 @@ const Dropdown = ({ children, trigger, open, onDropdownClose, onMouseDown, heade
254
252
  return (React.createElement("div", { className: clsx(styles.root, interior && styles.interior, stretchTriggerHeight && styles['stretch-trigger-height']), ref: wrapperRef, onFocus: focusHandler, onBlur: blurHandler },
255
253
  React.createElement("div", { id: referrerId, className: clsx(stretchTriggerHeight && styles['stretch-trigger-height']), ref: triggerRef }, trigger),
256
254
  React.createElement(TabTrap, { focusNextCallback: () => { var _a; return dropdownRef.current && ((_a = getFirstFocusable(dropdownRef.current)) === null || _a === void 0 ? void 0 : _a.focus()); }, disabled: !open || !loopFocus }),
257
- React.createElement(DropdownContainer, { renderWithPortal: expandToViewport && !interior, id: dropdownId, referrerId: referrerId, open: open },
255
+ React.createElement(DropdownContainer, { triggerRef: triggerRef, renderWithPortal: expandToViewport && !interior, id: dropdownId, referrerId: referrerId, open: open },
258
256
  React.createElement(Transition, { in: open !== null && open !== void 0 ? open : false, exit: false }, (state, ref) => (React.createElement("div", { ref: dropdownContainerRef },
259
257
  React.createElement(TabTrap, { focusNextCallback: () => { var _a; return triggerRef.current && ((_a = getLastFocusable(triggerRef.current)) === null || _a === void 0 ? void 0 : _a.focus()); }, disabled: !open || !loopFocus }),
260
258
  React.createElement(TransitionContent, { state: state, transitionRef: ref, dropdownClasses: dropdownClasses, open: open, stretchWidth: stretchWidth, interior: interior, header: header, expandToViewport: expandToViewport, stretchBeyondTriggerWidth: stretchBeyondTriggerWidth, footer: footer, onMouseDown: onMouseDown, isRefresh: isRefresh, dropdownRef: dropdownRef, verticalContainerRef: verticalContainerRef, position: position, id: dropdownContentId, role: dropdownContentRole, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby }, children),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,cAAc,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAoB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAgC,MAAM,WAAW,CAAC;AAClF,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EAEvB,yCAAyC,GAE1C,MAAM,wBAAwB,CAAC;AAGhC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAUrC,MAAM,iBAAiB,GAAG,CAAC,EAAE,QAAQ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,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,QAAqD,EACf,EAAE,CAAE,QAAqC,CAAC,aAAa,KAAK,SAAS,CAAC;AAE9G,eAAe,QAAQ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport clsx from 'clsx';\n\nimport { useResizeObserver } from '@cloudscape-design/component-toolkit/internal';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { fireNonCancelableEvent } from '../../events';\nimport customCssProps from '../../generated/custom-css-properties';\nimport { useMergeRefs } from '../../hooks/use-merge-refs';\nimport { useMobile } from '../../hooks/use-mobile';\nimport { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';\nimport { useUniqueId } from '../../hooks/use-unique-id/index.js';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport { getFirstFocusable, getLastFocusable } from '../focus-lock/utils.js';\nimport TabTrap from '../tab-trap/index.js';\nimport { Transition, TransitionStatus } from '../transition';\nimport { DropdownContextProvider, DropdownContextProviderProps } from './context';\nimport {\n calculatePosition,\n defaultMaxDropdownWidth,\n DropdownPosition,\n hasEnoughSpaceToStretchBeyondTriggerWidth,\n InteriorDropdownPosition,\n} from './dropdown-fit-handler';\nimport { DropdownProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ninterface DropdownContainerProps {\n children?: React.ReactNode;\n renderWithPortal?: boolean;\n id?: string;\n referrerId?: string;\n open?: boolean;\n}\n\nconst DropdownContainer = ({ children, renderWithPortal = false, id, referrerId, open }: DropdownContainerProps) => {\n if (renderWithPortal) {\n if (open) {\n return createPortal(\n <div id={id} data-awsui-referrer-id={referrerId}>\n {children}\n </div>,\n document.body\n );\n } else {\n return null;\n }\n } else {\n return <>{children}</>;\n }\n};\n\ninterface TransitionContentProps {\n state: TransitionStatus;\n transitionRef: React.MutableRefObject<any>;\n dropdownClasses: string;\n stretchWidth: boolean;\n interior: boolean;\n isRefresh: boolean;\n dropdownRef: React.RefObject<HTMLDivElement>;\n verticalContainerRef: React.RefObject<HTMLDivElement>;\n expandToViewport?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n header?: React.ReactNode;\n children?: React.ReactNode;\n footer?: React.ReactNode;\n position?: DropdownContextProviderProps['position'];\n open?: boolean;\n onMouseDown?: React.MouseEventHandler<Element>;\n id?: string;\n role?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n stretchWidth,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n stretchBeyondTriggerWidth,\n header,\n children,\n footer,\n position,\n open,\n onMouseDown,\n id,\n role,\n ariaLabelledby,\n ariaDescribedby,\n}: TransitionContentProps) => {\n const contentRef = useMergeRefs(dropdownRef, transitionRef);\n return (\n <div\n className={clsx(styles.dropdown, dropdownClasses, {\n [styles.open]: open,\n [styles['with-limited-width']]: !stretchWidth,\n [styles['hide-block-border']]: stretchWidth,\n [styles.interior]: interior,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n [styles['stretch-beyond-trigger-width']]: stretchBeyondTriggerWidth,\n })}\n ref={contentRef}\n id={id}\n role={role}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n style={\n stretchBeyondTriggerWidth ? { [customCssProps.dropdownDefaultMaxWidth]: `${defaultMaxDropdownWidth}px` } : {}\n }\n onMouseDown={onMouseDown}\n >\n <div\n className={clsx(\n styles['dropdown-content-wrapper'],\n !header && !children && styles['is-empty'],\n isRefresh && styles.refresh\n )}\n >\n <div ref={verticalContainerRef} className={styles['dropdown-content']}>\n <DropdownContextProvider position={position}>\n {header}\n {children}\n {footer}\n </DropdownContextProvider>\n </div>\n </div>\n </div>\n );\n};\n\nconst Dropdown = ({\n children,\n trigger,\n open,\n onDropdownClose,\n onMouseDown,\n header,\n footer,\n dropdownId,\n stretchTriggerHeight = false,\n stretchWidth = true,\n stretchHeight = false,\n stretchToTriggerWidth = true,\n stretchBeyondTriggerWidth = false,\n expandToViewport = false,\n preferCenter = false,\n interior = false,\n minWidth,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n contentKey,\n dropdownContentId,\n dropdownContentRole,\n ariaLabelledby,\n ariaDescribedby,\n}: DropdownProps) => {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLDivElement | null>(null);\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n const dropdownContainerRef = useRef<HTMLDivElement | null>(null);\n const verticalContainerRef = useRef<HTMLDivElement>(null);\n // To keep track of the initial position (drop up/down) which is kept the same during fixed repositioning\n const fixedPosition = useRef<DropdownPosition | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n const dropdownClasses = usePortalModeClasses(triggerRef);\n const [position, setPosition] = useState<DropdownContextProviderProps['position']>('bottom-right');\n\n const isMobile = useMobile();\n\n const setDropdownPosition = (\n position: DropdownPosition | InteriorDropdownPosition,\n triggerBox: DOMRect,\n target: HTMLDivElement,\n verticalContainer: HTMLDivElement\n ) => {\n const entireWidth = !interior && stretchWidth;\n if (!stretchWidth) {\n // 1px offset for dropdowns where the dropdown itself needs a border, rather than on the items\n verticalContainer.style.maxBlockSize = `${parseInt(position.blockSize) + 1}px`;\n } else {\n verticalContainer.style.maxBlockSize = position.blockSize;\n }\n\n if (entireWidth && !expandToViewport) {\n if (stretchToTriggerWidth) {\n target.classList.add(styles['occupy-entire-width']);\n }\n } else {\n target.style.inlineSize = position.inlineSize;\n }\n\n // Using styles for main dropdown to adjust its position as preferred alternative\n if (position.dropBlockStart && !interior) {\n target.classList.add(styles['dropdown-drop-up']);\n if (!expandToViewport) {\n target.style.insetBlockEnd = '100%';\n }\n } else {\n target.classList.remove(styles['dropdown-drop-up']);\n }\n target.classList.add(position.dropInlineStart ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);\n\n if (position.insetInlineStart && position.insetInlineStart !== 'auto') {\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n // Position normal overflow dropdowns with fixed positioning relative to viewport\n if (expandToViewport && !interior) {\n target.style.position = 'fixed';\n if (position.dropBlockStart) {\n target.style.insetBlockEnd = `calc(100% - ${triggerBox.top}px)`;\n } else {\n target.style.insetBlockStart = `${triggerBox.bottom}px`;\n }\n if (position.dropInlineStart) {\n target.style.insetInlineStart = `calc(${triggerBox.right}px - ${position.inlineSize})`;\n } else {\n target.style.insetInlineStart = `${triggerBox.left}px`;\n }\n // Keep track of the initial dropdown position and direction.\n // Dropdown direction doesn't need to change as the user scrolls, just needs to stay attached to the trigger.\n fixedPosition.current = position;\n return;\n }\n\n // For an interior dropdown (the fly out) we need exact values for positioning\n // and classes are not enough\n // usage of relative position is impossible due to overwrite of overflow-x\n if (interior && isInteriorPosition(position)) {\n if (position.dropBlockStart) {\n target.style.insetBlockEnd = position.insetBlockEnd;\n } else {\n target.style.insetBlockStart = position.insetBlockStart;\n }\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n if (position.dropBlockStart && position.dropInlineStart) {\n setPosition('top-left');\n } else if (position.dropBlockStart) {\n setPosition('top-right');\n } else if (position.dropInlineStart) {\n setPosition('bottom-left');\n } else {\n setPosition('bottom-right');\n }\n };\n\n const isOutsideDropdown = (element: Element) =>\n (!wrapperRef.current || !nodeBelongs(wrapperRef.current, element)) &&\n (!dropdownContainerRef.current || !nodeBelongs(dropdownContainerRef.current, element));\n\n const focusHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onFocus, event);\n }\n };\n\n const blurHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onBlur, event);\n }\n };\n\n // Prevent the dropdown width from stretching beyond the trigger width\n // if that is going to cause the dropdown to be cropped because of overflow\n const fixStretching = () => {\n const classNameToRemove = styles['stretch-beyond-trigger-width'];\n if (\n open &&\n stretchBeyondTriggerWidth &&\n dropdownRef.current &&\n triggerRef.current &&\n dropdownRef.current.classList.contains(classNameToRemove) &&\n !hasEnoughSpaceToStretchBeyondTriggerWidth({\n triggerElement: triggerRef.current,\n dropdownElement: dropdownRef.current,\n desiredMinWidth: minWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n })\n ) {\n dropdownRef.current.classList.remove(classNameToRemove);\n }\n };\n\n useResizeObserver(() => dropdownRef.current, fixStretching);\n\n useLayoutEffect(() => {\n const onDropdownOpen = () => {\n if (open && dropdownRef.current && triggerRef.current && verticalContainerRef.current) {\n // calculate scroll width only for dropdowns that has a scrollbar and ignore it for date picker components\n if (scrollable) {\n dropdownRef.current.classList.add(styles.nowrap);\n }\n setDropdownPosition(\n ...calculatePosition(\n dropdownRef.current,\n triggerRef.current,\n verticalContainerRef.current,\n interior,\n expandToViewport,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n minWidth,\n stretchBeyondTriggerWidth\n ),\n dropdownRef.current,\n verticalContainerRef.current\n );\n if (scrollable) {\n dropdownRef.current.classList.remove(styles.nowrap);\n }\n }\n };\n onDropdownOpen();\n\n if (open) {\n // window may scroll when dropdown opens, for example when soft keyboard shows up\n window.addEventListener('scroll', onDropdownOpen);\n // only listen to window scroll within very short time after the dropdown opens\n // do not want to interfere dropdown position on scroll afterwards\n const timeoutId = setTimeout(() => {\n window.removeEventListener('scroll', onDropdownOpen);\n }, 500);\n\n return () => {\n clearTimeout(timeoutId);\n window.removeEventListener('scroll', onDropdownOpen);\n };\n }\n // See AWSUI-13040\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, dropdownRef, triggerRef, verticalContainerRef, interior, stretchWidth, isMobile, contentKey]);\n\n // subscribe to outside click\n useEffect(() => {\n if (!open) {\n return;\n }\n const clickListener = (e: MouseEvent) => {\n if (!nodeBelongs(dropdownRef.current, e.target) && !nodeBelongs(triggerRef.current, e.target)) {\n fireNonCancelableEvent(onDropdownClose);\n }\n };\n window.addEventListener('click', clickListener, true);\n\n return () => {\n window.removeEventListener('click', clickListener, true);\n };\n }, [open, onDropdownClose]);\n\n // sync dropdown position on scroll and resize\n useLayoutEffect(() => {\n if (!expandToViewport || !open) {\n return;\n }\n const updateDropdownPosition = () => {\n if (triggerRef.current && dropdownRef.current && verticalContainerRef.current) {\n const triggerRect = getLogicalBoundingClientRect(triggerRef.current);\n const target = dropdownRef.current;\n if (fixedPosition.current) {\n if (fixedPosition.current.dropBlockStart) {\n dropdownRef.current.style.insetBlockEnd = `calc(100% - ${triggerRect.insetBlockStart}px)`;\n } else {\n target.style.insetBlockStart = `${triggerRect.insetBlockEnd}px`;\n }\n if (fixedPosition.current.dropInlineStart) {\n target.style.insetInlineStart = `calc(${triggerRect.insetInlineEnd}px - ${fixedPosition.current.inlineSize})`;\n } else {\n target.style.insetInlineStart = `${triggerRect.insetInlineStart}px`;\n }\n }\n }\n };\n\n updateDropdownPosition();\n\n window.addEventListener('scroll', updateDropdownPosition, true);\n window.addEventListener('resize', updateDropdownPosition, true);\n return () => {\n window.removeEventListener('scroll', updateDropdownPosition, true);\n window.removeEventListener('resize', updateDropdownPosition, true);\n };\n }, [open, expandToViewport]);\n\n const referrerId = useUniqueId();\n\n return (\n <div\n className={clsx(\n styles.root,\n interior && styles.interior,\n stretchTriggerHeight && styles['stretch-trigger-height']\n )}\n ref={wrapperRef}\n onFocus={focusHandler}\n onBlur={blurHandler}\n >\n <div id={referrerId} className={clsx(stretchTriggerHeight && styles['stretch-trigger-height'])} ref={triggerRef}>\n {trigger}\n </div>\n\n <TabTrap\n focusNextCallback={() => dropdownRef.current && getFirstFocusable(dropdownRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <DropdownContainer\n renderWithPortal={expandToViewport && !interior}\n id={dropdownId}\n referrerId={referrerId}\n open={open}\n >\n <Transition in={open ?? false} exit={false}>\n {(state, ref) => (\n <div ref={dropdownContainerRef}>\n <TabTrap\n focusNextCallback={() => triggerRef.current && getLastFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <TransitionContent\n state={state}\n transitionRef={ref}\n dropdownClasses={dropdownClasses}\n open={open}\n stretchWidth={stretchWidth}\n interior={interior}\n header={header}\n expandToViewport={expandToViewport}\n stretchBeyondTriggerWidth={stretchBeyondTriggerWidth}\n footer={footer}\n onMouseDown={onMouseDown}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n id={dropdownContentId}\n role={dropdownContentRole}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n >\n {children}\n </TransitionContent>\n\n <TabTrap\n focusNextCallback={() => triggerRef.current && getFirstFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n </div>\n )}\n </Transition>\n </DropdownContainer>\n </div>\n );\n};\n\nconst isInteriorPosition = (\n position: DropdownPosition | InteriorDropdownPosition\n): position is InteriorDropdownPosition => (position as InteriorDropdownPosition).insetBlockEnd !== undefined;\n\nexport default Dropdown;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,E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AK,EAAE,CAAA,CAAA,EAAA,EAC5F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B;gBAEF,oBAAC,iBAAiB,IAChB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,GAAG,EAClB,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,yBAAyB,EAAE,yBAAyB,EACpD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,iBAAiB,EACrB,IAAI,EAAE,mBAAmB,EACzB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,IAE/B,QAAQ,CACS;gBAEpB,oBAAC,OAAO,IACN,iBAAiB,EAAE,GAAG,EAAE,WAAC,OAAA,UAAU,CAAC,OAAO,KAAI,MAAA,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC7F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B,CACE,CACP,CACU,CACK,CAChB,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,QAAqD,EACf,EAAE,CAAE,QAAqC,CAAC,aAAa,KAAK,SAAS,CAAC;AAE9G,eAAe,QAAQ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport clsx from 'clsx';\n\nimport { useResizeObserver } from '@cloudscape-design/component-toolkit/internal';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { fireNonCancelableEvent } from '../../events';\nimport customCssProps from '../../generated/custom-css-properties';\nimport { useMergeRefs } from '../../hooks/use-merge-refs';\nimport { useMobile } from '../../hooks/use-mobile';\nimport { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';\nimport { useUniqueId } from '../../hooks/use-unique-id/index.js';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport { getFirstFocusable, getLastFocusable } from '../focus-lock/utils.js';\nimport TabTrap from '../tab-trap/index.js';\nimport { Transition, TransitionStatus } from '../transition';\nimport { DropdownContextProvider, DropdownContextProviderProps } from './context';\nimport {\n calculatePosition,\n defaultMaxDropdownWidth,\n DropdownPosition,\n hasEnoughSpaceToStretchBeyondTriggerWidth,\n InteriorDropdownPosition,\n} from './dropdown-fit-handler';\nimport { DropdownProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ninterface DropdownContainerProps {\n triggerRef: React.RefObject<HTMLElement>;\n children?: React.ReactNode;\n renderWithPortal: boolean;\n id?: string;\n referrerId?: string;\n open?: boolean;\n}\n\nconst DropdownContainer = ({\n triggerRef,\n children,\n renderWithPortal,\n id,\n referrerId,\n open,\n}: DropdownContainerProps) => {\n if (!renderWithPortal) {\n return <>{children}</>;\n }\n if (!open) {\n return null;\n }\n const currentDocument = triggerRef.current?.ownerDocument ?? document;\n return createPortal(\n <div id={id} data-awsui-referrer-id={referrerId}>\n {children}\n </div>,\n currentDocument.body\n );\n};\n\ninterface TransitionContentProps {\n state: TransitionStatus;\n transitionRef: React.MutableRefObject<any>;\n dropdownClasses: string;\n stretchWidth: boolean;\n interior: boolean;\n isRefresh: boolean;\n dropdownRef: React.RefObject<HTMLDivElement>;\n verticalContainerRef: React.RefObject<HTMLDivElement>;\n expandToViewport?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n header?: React.ReactNode;\n children?: React.ReactNode;\n footer?: React.ReactNode;\n position?: DropdownContextProviderProps['position'];\n open?: boolean;\n onMouseDown?: React.MouseEventHandler<Element>;\n id?: string;\n role?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n stretchWidth,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n stretchBeyondTriggerWidth,\n header,\n children,\n footer,\n position,\n open,\n onMouseDown,\n id,\n role,\n ariaLabelledby,\n ariaDescribedby,\n}: TransitionContentProps) => {\n const contentRef = useMergeRefs(dropdownRef, transitionRef);\n return (\n <div\n className={clsx(styles.dropdown, dropdownClasses, {\n [styles.open]: open,\n [styles['with-limited-width']]: !stretchWidth,\n [styles['hide-block-border']]: stretchWidth,\n [styles.interior]: interior,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n [styles['stretch-beyond-trigger-width']]: stretchBeyondTriggerWidth,\n })}\n ref={contentRef}\n id={id}\n role={role}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n style={\n stretchBeyondTriggerWidth ? { [customCssProps.dropdownDefaultMaxWidth]: `${defaultMaxDropdownWidth}px` } : {}\n }\n onMouseDown={onMouseDown}\n >\n <div\n className={clsx(\n styles['dropdown-content-wrapper'],\n !header && !children && styles['is-empty'],\n isRefresh && styles.refresh\n )}\n >\n <div ref={verticalContainerRef} className={styles['dropdown-content']}>\n <DropdownContextProvider position={position}>\n {header}\n {children}\n {footer}\n </DropdownContextProvider>\n </div>\n </div>\n </div>\n );\n};\n\nconst Dropdown = ({\n children,\n trigger,\n open,\n onDropdownClose,\n onMouseDown,\n header,\n footer,\n dropdownId,\n stretchTriggerHeight = false,\n stretchWidth = true,\n stretchHeight = false,\n stretchToTriggerWidth = true,\n stretchBeyondTriggerWidth = false,\n expandToViewport = false,\n preferCenter = false,\n interior = false,\n minWidth,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n contentKey,\n dropdownContentId,\n dropdownContentRole,\n ariaLabelledby,\n ariaDescribedby,\n}: DropdownProps) => {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLDivElement | null>(null);\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n const dropdownContainerRef = useRef<HTMLDivElement | null>(null);\n const verticalContainerRef = useRef<HTMLDivElement>(null);\n // To keep track of the initial position (drop up/down) which is kept the same during fixed repositioning\n const fixedPosition = useRef<DropdownPosition | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n const dropdownClasses = usePortalModeClasses(triggerRef);\n const [position, setPosition] = useState<DropdownContextProviderProps['position']>('bottom-right');\n\n const isMobile = useMobile();\n\n const setDropdownPosition = (\n position: DropdownPosition | InteriorDropdownPosition,\n triggerBox: DOMRect,\n target: HTMLDivElement,\n verticalContainer: HTMLDivElement\n ) => {\n const entireWidth = !interior && stretchWidth;\n if (!stretchWidth) {\n // 1px offset for dropdowns where the dropdown itself needs a border, rather than on the items\n verticalContainer.style.maxBlockSize = `${parseInt(position.blockSize) + 1}px`;\n } else {\n verticalContainer.style.maxBlockSize = position.blockSize;\n }\n\n if (entireWidth && !expandToViewport) {\n if (stretchToTriggerWidth) {\n target.classList.add(styles['occupy-entire-width']);\n }\n } else {\n target.style.inlineSize = position.inlineSize;\n }\n\n // Using styles for main dropdown to adjust its position as preferred alternative\n if (position.dropBlockStart && !interior) {\n target.classList.add(styles['dropdown-drop-up']);\n if (!expandToViewport) {\n target.style.insetBlockEnd = '100%';\n }\n } else {\n target.classList.remove(styles['dropdown-drop-up']);\n }\n target.classList.add(position.dropInlineStart ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);\n\n if (position.insetInlineStart && position.insetInlineStart !== 'auto') {\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n // Position normal overflow dropdowns with fixed positioning relative to viewport\n if (expandToViewport && !interior) {\n target.style.position = 'fixed';\n if (position.dropBlockStart) {\n target.style.insetBlockEnd = `calc(100% - ${triggerBox.top}px)`;\n } else {\n target.style.insetBlockStart = `${triggerBox.bottom}px`;\n }\n if (position.dropInlineStart) {\n target.style.insetInlineStart = `calc(${triggerBox.right}px - ${position.inlineSize})`;\n } else {\n target.style.insetInlineStart = `${triggerBox.left}px`;\n }\n // Keep track of the initial dropdown position and direction.\n // Dropdown direction doesn't need to change as the user scrolls, just needs to stay attached to the trigger.\n fixedPosition.current = position;\n return;\n }\n\n // For an interior dropdown (the fly out) we need exact values for positioning\n // and classes are not enough\n // usage of relative position is impossible due to overwrite of overflow-x\n if (interior && isInteriorPosition(position)) {\n if (position.dropBlockStart) {\n target.style.insetBlockEnd = position.insetBlockEnd;\n } else {\n target.style.insetBlockStart = position.insetBlockStart;\n }\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n if (position.dropBlockStart && position.dropInlineStart) {\n setPosition('top-left');\n } else if (position.dropBlockStart) {\n setPosition('top-right');\n } else if (position.dropInlineStart) {\n setPosition('bottom-left');\n } else {\n setPosition('bottom-right');\n }\n };\n\n const isOutsideDropdown = (element: Element) =>\n (!wrapperRef.current || !nodeBelongs(wrapperRef.current, element)) &&\n (!dropdownContainerRef.current || !nodeBelongs(dropdownContainerRef.current, element));\n\n const focusHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onFocus, event);\n }\n };\n\n const blurHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onBlur, event);\n }\n };\n\n // Prevent the dropdown width from stretching beyond the trigger width\n // if that is going to cause the dropdown to be cropped because of overflow\n const fixStretching = () => {\n const classNameToRemove = styles['stretch-beyond-trigger-width'];\n if (\n open &&\n stretchBeyondTriggerWidth &&\n dropdownRef.current &&\n triggerRef.current &&\n dropdownRef.current.classList.contains(classNameToRemove) &&\n !hasEnoughSpaceToStretchBeyondTriggerWidth({\n triggerElement: triggerRef.current,\n dropdownElement: dropdownRef.current,\n desiredMinWidth: minWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n })\n ) {\n dropdownRef.current.classList.remove(classNameToRemove);\n }\n };\n\n useResizeObserver(() => dropdownRef.current, fixStretching);\n\n useLayoutEffect(() => {\n const onDropdownOpen = () => {\n if (open && dropdownRef.current && triggerRef.current && verticalContainerRef.current) {\n // calculate scroll width only for dropdowns that has a scrollbar and ignore it for date picker components\n if (scrollable) {\n dropdownRef.current.classList.add(styles.nowrap);\n }\n setDropdownPosition(\n ...calculatePosition(\n dropdownRef.current,\n triggerRef.current,\n verticalContainerRef.current,\n interior,\n expandToViewport,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n minWidth,\n stretchBeyondTriggerWidth\n ),\n dropdownRef.current,\n verticalContainerRef.current\n );\n if (scrollable) {\n dropdownRef.current.classList.remove(styles.nowrap);\n }\n }\n };\n onDropdownOpen();\n\n if (open) {\n // window may scroll when dropdown opens, for example when soft keyboard shows up\n window.addEventListener('scroll', onDropdownOpen);\n // only listen to window scroll within very short time after the dropdown opens\n // do not want to interfere dropdown position on scroll afterwards\n const timeoutId = setTimeout(() => {\n window.removeEventListener('scroll', onDropdownOpen);\n }, 500);\n\n return () => {\n clearTimeout(timeoutId);\n window.removeEventListener('scroll', onDropdownOpen);\n };\n }\n // See AWSUI-13040\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, dropdownRef, triggerRef, verticalContainerRef, interior, stretchWidth, isMobile, contentKey]);\n\n // subscribe to outside click\n useEffect(() => {\n if (!open) {\n return;\n }\n const clickListener = (e: MouseEvent) => {\n if (!nodeBelongs(dropdownRef.current, e.target) && !nodeBelongs(triggerRef.current, e.target)) {\n fireNonCancelableEvent(onDropdownClose);\n }\n };\n window.addEventListener('click', clickListener, true);\n\n return () => {\n window.removeEventListener('click', clickListener, true);\n };\n }, [open, onDropdownClose]);\n\n // sync dropdown position on scroll and resize\n useLayoutEffect(() => {\n if (!expandToViewport || !open) {\n return;\n }\n const updateDropdownPosition = () => {\n if (triggerRef.current && dropdownRef.current && verticalContainerRef.current) {\n const triggerRect = getLogicalBoundingClientRect(triggerRef.current);\n const target = dropdownRef.current;\n if (fixedPosition.current) {\n if (fixedPosition.current.dropBlockStart) {\n dropdownRef.current.style.insetBlockEnd = `calc(100% - ${triggerRect.insetBlockStart}px)`;\n } else {\n target.style.insetBlockStart = `${triggerRect.insetBlockEnd}px`;\n }\n if (fixedPosition.current.dropInlineStart) {\n target.style.insetInlineStart = `calc(${triggerRect.insetInlineEnd}px - ${fixedPosition.current.inlineSize})`;\n } else {\n target.style.insetInlineStart = `${triggerRect.insetInlineStart}px`;\n }\n }\n }\n };\n\n updateDropdownPosition();\n\n window.addEventListener('scroll', updateDropdownPosition, true);\n window.addEventListener('resize', updateDropdownPosition, true);\n return () => {\n window.removeEventListener('scroll', updateDropdownPosition, true);\n window.removeEventListener('resize', updateDropdownPosition, true);\n };\n }, [open, expandToViewport]);\n\n const referrerId = useUniqueId();\n\n return (\n <div\n className={clsx(\n styles.root,\n interior && styles.interior,\n stretchTriggerHeight && styles['stretch-trigger-height']\n )}\n ref={wrapperRef}\n onFocus={focusHandler}\n onBlur={blurHandler}\n >\n <div id={referrerId} className={clsx(stretchTriggerHeight && styles['stretch-trigger-height'])} ref={triggerRef}>\n {trigger}\n </div>\n\n <TabTrap\n focusNextCallback={() => dropdownRef.current && getFirstFocusable(dropdownRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <DropdownContainer\n triggerRef={triggerRef}\n renderWithPortal={expandToViewport && !interior}\n id={dropdownId}\n referrerId={referrerId}\n open={open}\n >\n <Transition in={open ?? false} exit={false}>\n {(state, ref) => (\n <div ref={dropdownContainerRef}>\n <TabTrap\n focusNextCallback={() => triggerRef.current && getLastFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <TransitionContent\n state={state}\n transitionRef={ref}\n dropdownClasses={dropdownClasses}\n open={open}\n stretchWidth={stretchWidth}\n interior={interior}\n header={header}\n expandToViewport={expandToViewport}\n stretchBeyondTriggerWidth={stretchBeyondTriggerWidth}\n footer={footer}\n onMouseDown={onMouseDown}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n id={dropdownContentId}\n role={dropdownContentRole}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n >\n {children}\n </TransitionContent>\n\n <TabTrap\n focusNextCallback={() => triggerRef.current && getFirstFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n </div>\n )}\n </Transition>\n </DropdownContainer>\n </div>\n );\n};\n\nconst isInteriorPosition = (\n position: DropdownPosition | InteriorDropdownPosition\n): position is InteriorDropdownPosition => (position as InteriorDropdownPosition).insetBlockEnd !== undefined;\n\nexport default Dropdown;\n"]}
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (83b7b6f2)";
2
+ export var PACKAGE_VERSION = "3.0.0 (25b74388)";
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 (83b7b6f2)",
3
+ "PACKAGE_VERSION": "3.0.0 (25b74388)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "83b7b6f2dc8c0964113ed9de41737d0c68387728"
2
+ "commit": "25b74388a43972ba025c883d10ba398619634e19"
3
3
  }
@@ -1 +1 @@
1
- {"version":3,"file":"scrollable-containers.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/scrollable-containers.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,kBAAkB,YAAa,WAAW,KAAG,WAAW,EAQpE,CAAC;AAEF,eAAO,MAAM,2BAA2B;aAM7B,WAAW;0BACE,OAAO;sBACX,OAAO;8BACC,OAAO;MAC/B,WAAW,EAqCd,CAAC;AAEF,KAAK,qBAAqB,GAAG,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1E;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,OAAO,GAAE,qBAA+D,QAGzE;AAED,wBAAgB,eAAe,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,WAAW,UAW1E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,WAAW,EAAE,gBAAgB,CAAC,EAAE,WAAW,QAKvF;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,CAOtF"}
1
+ {"version":3,"file":"scrollable-containers.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/scrollable-containers.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,kBAAkB,YAAa,WAAW,KAAG,WAAW,EAQpE,CAAC;AAEF,eAAO,MAAM,2BAA2B;aAM7B,WAAW;0BACE,OAAO;sBACX,OAAO;8BACC,OAAO;MAC/B,WAAW,EAuCd,CAAC;AAEF,KAAK,qBAAqB,GAAG,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1E;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,OAAO,GAAE,qBAA+D,QAGzE;AAED,wBAAgB,eAAe,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,WAAW,UAW1E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,WAAW,EAAE,gBAAgB,CAAC,EAAE,WAAW,QAKvF;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,CAOtF"}
@@ -4,13 +4,13 @@ import { findUpUntil } from './dom';
4
4
  export const getOverflowParents = (element) => {
5
5
  const parents = [];
6
6
  let node = element;
7
- while ((node = node.parentElement) && node !== document.body) {
7
+ while ((node = node.parentElement) && node !== element.ownerDocument.body) {
8
8
  getComputedStyle(node).overflow !== 'visible' && parents.push(node);
9
9
  }
10
10
  return parents;
11
11
  };
12
12
  export const getOverflowParentDimensions = ({ element, excludeClosestParent = false, expandToViewport = false, canExpandOutsideViewport = false, }) => {
13
- var _a, _b, _c, _d;
13
+ var _a, _b, _c, _d, _e;
14
14
  const parents = expandToViewport
15
15
  ? []
16
16
  : getOverflowParents(element).map(el => {
@@ -25,6 +25,7 @@ export const getOverflowParentDimensions = ({ element, excludeClosestParent = fa
25
25
  };
26
26
  });
27
27
  if (canExpandOutsideViewport && !expandToViewport) {
28
+ const document = element.ownerDocument;
28
29
  const documentDimensions = document.documentElement.getBoundingClientRect();
29
30
  parents.push({
30
31
  inlineSize: Math.max(documentDimensions.width, document.documentElement.clientWidth),
@@ -34,9 +35,10 @@ export const getOverflowParentDimensions = ({ element, excludeClosestParent = fa
34
35
  });
35
36
  }
36
37
  else {
38
+ const owningWindow = (_a = element.ownerDocument.defaultView) !== null && _a !== void 0 ? _a : window;
37
39
  parents.push({
38
- blockSize: (_b = (_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : window.innerHeight,
39
- inlineSize: (_d = (_c = window.visualViewport) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : window.innerWidth,
40
+ blockSize: (_c = (_b = owningWindow.visualViewport) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : owningWindow.innerHeight,
41
+ inlineSize: (_e = (_d = owningWindow.visualViewport) === null || _d === void 0 ? void 0 : _d.width) !== null && _e !== void 0 ? _e : owningWindow.innerWidth,
40
42
  insetBlockStart: 0,
41
43
  insetInlineStart: 0,
42
44
  });
@@ -1 +1 @@
1
- {"version":3,"file":"scrollable-containers.js","sourceRoot":"","sources":["../../../../src/internal/utils/scrollable-containers.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAQpC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAoB,EAAiB,EAAE;IACxE,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,IAAI,IAAI,GAAuB,OAAO,CAAC;IAEvC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE;QAC5D,gBAAgB,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACrE;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,EAC1C,OAAO,EACP,oBAAoB,GAAG,KAAK,EAC5B,gBAAgB,GAAG,KAAK,EACxB,wBAAwB,GAAG,KAAK,GAMjC,EAAiB,EAAE;;IAClB,MAAM,OAAO,GAAG,gBAAgB;QAC9B,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YACnC,MAAM,EAAE,MAAM,EAAE,KAAK,EAA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\nimport { findUpUntil } from './dom';\nexport interface BoundingBox {\n blockSize: number;\n inlineSize: number;\n insetBlockStart: number;\n insetInlineStart: number;\n}\n\nexport const getOverflowParents = (element: HTMLElement): HTMLElement[] => {\n const parents = [];\n let node: HTMLElement | null = element;\n\n while ((node = node.parentElement) && node !== document.body) {\n getComputedStyle(node).overflow !== 'visible' && parents.push(node);\n }\n return parents;\n};\n\nexport const getOverflowParentDimensions = ({\n element,\n excludeClosestParent = false,\n expandToViewport = false,\n canExpandOutsideViewport = false,\n}: {\n element: HTMLElement;\n excludeClosestParent: boolean;\n expandToViewport: boolean;\n canExpandOutsideViewport: boolean;\n}): BoundingBox[] => {\n const parents = expandToViewport\n ? []\n : getOverflowParents(element).map(el => {\n const { height, width, top, left } = el.getBoundingClientRect();\n return {\n // Treat the whole scrollable area as the available height\n // if we're allowed to expand past the viewport.\n blockSize: canExpandOutsideViewport ? el.scrollHeight : height,\n inlineSize: width,\n insetBlockStart: top,\n insetInlineStart: left,\n };\n });\n\n if (canExpandOutsideViewport && !expandToViewport) {\n const documentDimensions = document.documentElement.getBoundingClientRect();\n parents.push({\n inlineSize: Math.max(documentDimensions.width, document.documentElement.clientWidth),\n blockSize: Math.max(documentDimensions.height, document.documentElement.clientHeight),\n insetBlockStart: documentDimensions.top,\n insetInlineStart: documentDimensions.left,\n });\n } else {\n parents.push({\n blockSize: window.visualViewport?.height ?? window.innerHeight,\n inlineSize: window.visualViewport?.width ?? window.innerWidth,\n insetBlockStart: 0,\n insetInlineStart: 0,\n });\n }\n\n if (excludeClosestParent && !expandToViewport) {\n parents.shift();\n }\n\n return parents;\n};\n\ntype ScrollIntoViewOptions = Parameters<HTMLElement['scrollIntoView']>[0];\n\n/**\n * Calls `scrollIntoView` on the provided element with sensible defaults. If\n * the element does not exist or does not support the `scrollIntoView`\n * method, it will do nothing. This wrapper is created to support environments\n * where the native function is not available like JSDom (feature request:\n * https://github.com/jsdom/jsdom/issues/1422).\n *\n * @param element to be scrolled into view\n * @param options native options for `scrollIntoView`\n */\nexport function scrollElementIntoView(\n element: HTMLElement | undefined,\n options: ScrollIntoViewOptions = { block: 'nearest', inline: 'nearest' }\n) {\n element?.scrollIntoView?.(options);\n}\n\nexport function calculateScroll({ insetBlockStart, blockSize }: BoundingBox) {\n if (insetBlockStart < 0) {\n return insetBlockStart;\n } else if (insetBlockStart + blockSize > window.innerHeight) {\n if (blockSize > window.innerHeight) {\n return insetBlockStart;\n } else {\n return insetBlockStart + blockSize - window.innerHeight;\n }\n }\n return 0;\n}\n\n/**\n * For elements with fixed position, the browser's native scrollIntoView API doesn't work,\n * so we need to manually scroll to the element's position.\n * Supports only vertical scrolling.\n */\nexport function scrollRectangleIntoView(box: BoundingBox, scrollableParent?: HTMLElement) {\n const scrollAmount = calculateScroll(box);\n if (scrollAmount) {\n (scrollableParent || window).scrollBy(0, scrollAmount);\n }\n}\n\nexport function getFirstScrollableParent(element: HTMLElement): HTMLElement | undefined {\n return (\n findUpUntil(element, el => {\n const overflows = el.scrollHeight > el.clientHeight;\n return overflows && ['scroll', 'auto'].includes(getComputedStyle(el).overflowY);\n }) || undefined\n );\n}\n"]}
1
+ {"version":3,"file":"scrollable-containers.js","sourceRoot":"","sources":["../../../../src/internal/utils/scrollable-containers.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAQpC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAoB,EAAiB,EAAE;IACxE,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,IAAI,IAAI,GAAuB,OAAO,CAAC;IAEvC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,KAAK,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE;QACzE,gBAAgB,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACrE;I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AAM,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;KACxD;AACH,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAAoB;IAC3D,OAAO,CACL,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE;QACxB,MAAM,SAAS,GAAG,EAAE,CAAC,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC;QACpD,OAAO,SAAS,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;IAClF,CAAC,CAAC,IAAI,SAAS,CAChB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { findUpUntil } from './dom';\nexport interface BoundingBox {\n blockSize: number;\n inlineSize: number;\n insetBlockStart: number;\n insetInlineStart: number;\n}\n\nexport const getOverflowParents = (element: HTMLElement): HTMLElement[] => {\n const parents = [];\n let node: HTMLElement | null = element;\n\n while ((node = node.parentElement) && node !== element.ownerDocument.body) {\n getComputedStyle(node).overflow !== 'visible' && parents.push(node);\n }\n return parents;\n};\n\nexport const getOverflowParentDimensions = ({\n element,\n excludeClosestParent = false,\n expandToViewport = false,\n canExpandOutsideViewport = false,\n}: {\n element: HTMLElement;\n excludeClosestParent: boolean;\n expandToViewport: boolean;\n canExpandOutsideViewport: boolean;\n}): BoundingBox[] => {\n const parents = expandToViewport\n ? []\n : getOverflowParents(element).map(el => {\n const { height, width, top, left } = el.getBoundingClientRect();\n return {\n // Treat the whole scrollable area as the available height\n // if we're allowed to expand past the viewport.\n blockSize: canExpandOutsideViewport ? el.scrollHeight : height,\n inlineSize: width,\n insetBlockStart: top,\n insetInlineStart: left,\n };\n });\n\n if (canExpandOutsideViewport && !expandToViewport) {\n const document = element.ownerDocument;\n const documentDimensions = document.documentElement.getBoundingClientRect();\n parents.push({\n inlineSize: Math.max(documentDimensions.width, document.documentElement.clientWidth),\n blockSize: Math.max(documentDimensions.height, document.documentElement.clientHeight),\n insetBlockStart: documentDimensions.top,\n insetInlineStart: documentDimensions.left,\n });\n } else {\n const owningWindow = element.ownerDocument.defaultView ?? window;\n parents.push({\n blockSize: owningWindow.visualViewport?.height ?? owningWindow.innerHeight,\n inlineSize: owningWindow.visualViewport?.width ?? owningWindow.innerWidth,\n insetBlockStart: 0,\n insetInlineStart: 0,\n });\n }\n\n if (excludeClosestParent && !expandToViewport) {\n parents.shift();\n }\n\n return parents;\n};\n\ntype ScrollIntoViewOptions = Parameters<HTMLElement['scrollIntoView']>[0];\n\n/**\n * Calls `scrollIntoView` on the provided element with sensible defaults. If\n * the element does not exist or does not support the `scrollIntoView`\n * method, it will do nothing. This wrapper is created to support environments\n * where the native function is not available like JSDom (feature request:\n * https://github.com/jsdom/jsdom/issues/1422).\n *\n * @param element to be scrolled into view\n * @param options native options for `scrollIntoView`\n */\nexport function scrollElementIntoView(\n element: HTMLElement | undefined,\n options: ScrollIntoViewOptions = { block: 'nearest', inline: 'nearest' }\n) {\n element?.scrollIntoView?.(options);\n}\n\nexport function calculateScroll({ insetBlockStart, blockSize }: BoundingBox) {\n if (insetBlockStart < 0) {\n return insetBlockStart;\n } else if (insetBlockStart + blockSize > window.innerHeight) {\n if (blockSize > window.innerHeight) {\n return insetBlockStart;\n } else {\n return insetBlockStart + blockSize - window.innerHeight;\n }\n }\n return 0;\n}\n\n/**\n * For elements with fixed position, the browser's native scrollIntoView API doesn't work,\n * so we need to manually scroll to the element's position.\n * Supports only vertical scrolling.\n */\nexport function scrollRectangleIntoView(box: BoundingBox, scrollableParent?: HTMLElement) {\n const scrollAmount = calculateScroll(box);\n if (scrollAmount) {\n (scrollableParent || window).scrollBy(0, scrollAmount);\n }\n}\n\nexport function getFirstScrollableParent(element: HTMLElement): HTMLElement | undefined {\n return (\n findUpUntil(element, el => {\n const overflows = el.scrollHeight > el.clientHeight;\n return overflows && ['scroll', 'auto'].includes(getComputedStyle(el).overflowY);\n }) || undefined\n );\n}\n"]}
package/package.json CHANGED
@@ -126,7 +126,7 @@
126
126
  "./internal/base-component/index.js",
127
127
  "./internal/base-component/styles.css.js"
128
128
  ],
129
- "version": "3.0.711",
129
+ "version": "3.0.713",
130
130
  "repository": {
131
131
  "type": "git",
132
132
  "url": "https://github.com/cloudscape-design/components.git"
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/property-filter/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAgD,MAAM,OAAO,CAAC;AAoBrE,OAAO,EASL,mBAAmB,EAGpB,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,QAAA,MAAM,cAAc,qGAgZnB,CAAC;AAGF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/property-filter/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAgD,MAAM,OAAO,CAAC;AAmBrE,OAAO,EASL,mBAAmB,EAGpB,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,QAAA,MAAM,cAAc,qGAsYnB,CAAC;AAGF,eAAe,cAAc,CAAC"}
@@ -10,7 +10,6 @@ import TokenList from '../internal/components/token-list';
10
10
  import { fireNonCancelableEvent } from '../internal/events';
11
11
  import useBaseComponent from '../internal/hooks/use-base-component';
12
12
  import { useUniqueId } from '../internal/hooks/use-unique-id/index';
13
- import { KeyCode } from '../internal/keycode';
14
13
  import { applyDisplayName } from '../internal/utils/apply-display-name';
15
14
  import { joinStrings } from '../internal/utils/strings';
16
15
  import InternalSpaceBetween from '../space-between/internal';
@@ -117,12 +116,6 @@ const PropertyFilter = React.forwardRef((_a, ref) => {
117
116
  addToken(newToken);
118
117
  setFilteringText('');
119
118
  };
120
- const ignoreKeyDown = useRef(false);
121
- const handleKeyDown = event => {
122
- if (filteringText && !ignoreKeyDown.current && event.detail.keyCode === KeyCode.enter) {
123
- createToken(filteringText);
124
- }
125
- };
126
119
  const getLoadMoreDetail = (parsedText, filteringText) => {
127
120
  const loadMoreDetail = {
128
121
  filteringProperty: undefined,
@@ -150,14 +143,11 @@ const PropertyFilter = React.forwardRef((_a, ref) => {
150
143
  ? Object.assign(Object.assign({}, inputLoadItemsHandlers), asyncProps) : {};
151
144
  const handleSelected = event => {
152
145
  var _a;
153
- // The ignoreKeyDown flag makes sure `createToken` routine runs only once. Autosuggest's `onKeyDown` fires,
154
- // when an item is selected from the list using "enter" key.
155
- ignoreKeyDown.current = true;
156
- setTimeout(() => {
157
- ignoreKeyDown.current = false;
158
- }, 0);
159
146
  const { detail: option } = event;
160
147
  const value = option.value || '';
148
+ if (!value) {
149
+ return;
150
+ }
161
151
  if (!('keepOpenOnSelect' in option)) {
162
152
  createToken(value);
163
153
  return;
@@ -187,7 +177,7 @@ const PropertyFilter = React.forwardRef((_a, ref) => {
187
177
  return (React.createElement("div", Object.assign({}, baseProps, { className: clsx(baseProps.className, styles.root), ref: __internalRootRef }),
188
178
  React.createElement("div", { className: styles['search-field'] },
189
179
  customControl && React.createElement("div", { className: styles['custom-control'] }, customControl),
190
- React.createElement(PropertyFilterAutosuggest, Object.assign({ ref: inputRef, virtualScroll: virtualScroll, enteredTextLabel: i18nStrings.enteredTextLabel, ariaLabel: filteringAriaLabel !== null && filteringAriaLabel !== void 0 ? filteringAriaLabel : i18nStrings.filteringAriaLabel, placeholder: filteringPlaceholder !== null && filteringPlaceholder !== void 0 ? filteringPlaceholder : i18nStrings.filteringPlaceholder, ariaLabelledby: rest.ariaLabelledby, ariaDescribedby: textboxAriaDescribedBy, controlId: rest.controlId, value: filteringText, disabled: disabled, onKeyDown: handleKeyDown }, autosuggestOptions, { onChange: event => setFilteringText(event.detail.value), empty: filteringEmpty }, asyncAutosuggestProps, { expandToViewport: expandToViewport, onOptionClick: handleSelected, customForm: operatorForm && (React.createElement(PropertyEditor, { property: parsedText.property, operator: parsedText.operator, filter: parsedText.value, operatorForm: operatorForm, i18nStrings: i18nStrings, onCancel: () => {
180
+ React.createElement(PropertyFilterAutosuggest, Object.assign({ ref: inputRef, virtualScroll: virtualScroll, enteredTextLabel: i18nStrings.enteredTextLabel, ariaLabel: filteringAriaLabel !== null && filteringAriaLabel !== void 0 ? filteringAriaLabel : i18nStrings.filteringAriaLabel, placeholder: filteringPlaceholder !== null && filteringPlaceholder !== void 0 ? filteringPlaceholder : i18nStrings.filteringPlaceholder, ariaLabelledby: rest.ariaLabelledby, ariaDescribedby: textboxAriaDescribedBy, controlId: rest.controlId, value: filteringText, disabled: disabled }, autosuggestOptions, { onChange: event => setFilteringText(event.detail.value), empty: filteringEmpty }, asyncAutosuggestProps, { expandToViewport: expandToViewport, onOptionClick: handleSelected, customForm: operatorForm && (React.createElement(PropertyEditor, { property: parsedText.property, operator: parsedText.operator, filter: parsedText.value, operatorForm: operatorForm, i18nStrings: i18nStrings, onCancel: () => {
191
181
  var _a, _b;
192
182
  setFilteringText('');
193
183
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.close();