@cloudscape-design/components-themeable 3.0.1340 → 3.0.1341

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 (65) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/input/styles.scss +231 -37
  3. package/lib/internal/scss/internal/components/chart-legend/styles.scss +1 -0
  4. package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
  5. package/lib/internal/template/button-dropdown/filter.d.ts +1 -1
  6. package/lib/internal/template/button-dropdown/filter.d.ts.map +1 -1
  7. package/lib/internal/template/button-dropdown/internal.d.ts.map +1 -1
  8. package/lib/internal/template/button-dropdown/internal.js +2 -2
  9. package/lib/internal/template/button-dropdown/internal.js.map +1 -1
  10. package/lib/internal/template/button-dropdown/utils/use-button-dropdown.d.ts +1 -0
  11. package/lib/internal/template/button-dropdown/utils/use-button-dropdown.d.ts.map +1 -1
  12. package/lib/internal/template/button-dropdown/utils/use-button-dropdown.js +9 -0
  13. package/lib/internal/template/button-dropdown/utils/use-button-dropdown.js.map +1 -1
  14. package/lib/internal/template/i18n/context.d.ts +16 -4
  15. package/lib/internal/template/i18n/context.d.ts.map +1 -1
  16. package/lib/internal/template/i18n/context.js +10 -4
  17. package/lib/internal/template/i18n/context.js.map +1 -1
  18. package/lib/internal/template/i18n/index.d.ts +2 -0
  19. package/lib/internal/template/i18n/index.d.ts.map +1 -1
  20. package/lib/internal/template/i18n/index.js +1 -0
  21. package/lib/internal/template/i18n/index.js.map +1 -1
  22. package/lib/internal/template/input/index.d.ts.map +1 -1
  23. package/lib/internal/template/input/index.js +4 -2
  24. package/lib/internal/template/input/index.js.map +1 -1
  25. package/lib/internal/template/input/interfaces.d.ts +9 -0
  26. package/lib/internal/template/input/interfaces.d.ts.map +1 -1
  27. package/lib/internal/template/input/interfaces.js.map +1 -1
  28. package/lib/internal/template/input/internal.d.ts +5 -5
  29. package/lib/internal/template/input/internal.d.ts.map +1 -1
  30. package/lib/internal/template/input/internal.js +60 -24
  31. package/lib/internal/template/input/internal.js.map +1 -1
  32. package/lib/internal/template/input/styles.css.js +28 -18
  33. package/lib/internal/template/input/styles.scoped.css +213 -52
  34. package/lib/internal/template/input/styles.selectors.js +28 -18
  35. package/lib/internal/template/input/utils.js +3 -3
  36. package/lib/internal/template/input/utils.js.map +1 -1
  37. package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
  38. package/lib/internal/template/internal/components/chart-legend/styles.css.js +6 -6
  39. package/lib/internal/template/internal/components/chart-legend/styles.scoped.css +16 -14
  40. package/lib/internal/template/internal/components/chart-legend/styles.selectors.js +6 -6
  41. package/lib/internal/template/internal/environment.js +2 -2
  42. package/lib/internal/template/internal/environment.json +2 -2
  43. package/lib/internal/template/multiselect/embedded.d.ts +1 -1
  44. package/lib/internal/template/select/parts/filter.d.ts +1 -1
  45. package/lib/internal/template/select/parts/filter.d.ts.map +1 -1
  46. package/lib/internal/template/status-indicator/interfaces.d.ts +1 -1
  47. package/lib/internal/template/status-indicator/interfaces.d.ts.map +1 -1
  48. package/lib/internal/template/status-indicator/interfaces.js.map +1 -1
  49. package/lib/internal/template/status-indicator/internal.d.ts +2 -6
  50. package/lib/internal/template/status-indicator/internal.d.ts.map +1 -1
  51. package/lib/internal/template/status-indicator/internal.js.map +1 -1
  52. package/lib/internal/template/steps/interfaces.d.ts +2 -2
  53. package/lib/internal/template/steps/interfaces.d.ts.map +1 -1
  54. package/lib/internal/template/steps/interfaces.js.map +1 -1
  55. package/lib/internal/template/test-utils/dom/input/index.d.ts +2 -0
  56. package/lib/internal/template/test-utils/dom/input/index.js +6 -0
  57. package/lib/internal/template/test-utils/dom/input/index.js.map +1 -1
  58. package/lib/internal/template/test-utils/selectors/input/index.d.ts +2 -0
  59. package/lib/internal/template/test-utils/selectors/input/index.js +6 -0
  60. package/lib/internal/template/test-utils/selectors/input/index.js.map +1 -1
  61. package/package.json +1 -1
  62. package/lib/internal/template/status-indicator/internal-interfaces.d.ts +0 -3
  63. package/lib/internal/template/status-indicator/internal-interfaces.d.ts.map +0 -1
  64. package/lib/internal/template/status-indicator/internal-interfaces.js +0 -2
  65. package/lib/internal/template/status-indicator/internal-interfaces.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"use-button-dropdown.js","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/use-button-dropdown.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,6DAA6D,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGjD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,kBAAkB,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AA2BjF,MAAM,UAAU,iBAAiB,CAAC,EAChC,KAAK,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,kBAAkB,GAAG,KAAK,EAC1B,gBAAgB,GAAG,KAAK,EACxB,YAAY,GACa;IACzB,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEzD,MAAM,aAAa,GAAG,OAAO,CAC3B,GAAG,EAAE,CAAC,CAAC,YAAY,IAAI,cAAc,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EACnF,CAAC,YAAY,EAAE,cAAc,EAAE,KAAK,CAAC,CACtC,CAAC;IAEF,MAAM,oBAAoB,GAAG,mBAAmB,IAAI,CAAC,cAA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EAAE,CAAC;YAC9E,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,MAAM;QACN,UAAU;QACV,aAAa;QACb,mBAAmB;QACnB,UAAU;QACV,aAAa;QACb,SAAS;QACT,OAAO;QACP,cAAc;QACd,aAAa;QACb,oBAAoB;QACpB,cAAc;QACd,aAAa;QACb,eAAe;QACf,cAAc;QACd,iBAAiB;QACjB,aAAa;QACb,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\n\nimport { useOpenState } from '../../internal/components/options-list/utils/use-open-state';\nimport { fireCancelableEvent, isPlainLeftClick } from '../../internal/events';\nimport { KeyCode } from '../../internal/keycode';\nimport { CancelableEventHandler } from '../../types/events';\nimport { ButtonDropdownProps, ButtonDropdownSettings, GroupToggle, HighlightProps, ItemActivate } from '../interfaces';\nimport { filterItems } from './filter-items';\nimport useHighlightedMenu from './use-highlighted-menu';\nimport { getItemTarget, isCheckboxItem, isItemGroup, isLinkItem } from './utils';\n\ninterface UseButtonDropdownOptions extends ButtonDropdownSettings {\n items: ButtonDropdownProps.Items;\n onItemClick?: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n onItemFollow?: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n onReturnFocus: () => void;\n expandToViewport?: boolean;\n hasFiltering: boolean;\n}\n\ninterface UseButtonDropdownApi extends HighlightProps {\n isOpen: boolean;\n onKeyDown: (event: React.KeyboardEvent) => void;\n onKeyUp: (event: React.KeyboardEvent) => void;\n onItemActivate: ItemActivate;\n onGroupToggle: GroupToggle;\n onDropdownFocusLeave: () => void;\n toggleDropdown: (options?: { moveHighlightOnOpen?: boolean }) => void;\n closeDropdown: () => void;\n setIsUsingMouse: (isUsingMouse: boolean) => void;\n filteringValue: string;\n setFilteringValue: (value: string) => void;\n filteredItems: ButtonDropdownProps.Items;\n showExpandableGroups: boolean;\n}\n\nexport function useButtonDropdown({\n items,\n onItemClick,\n onItemFollow,\n onReturnFocus,\n hasExpandableGroups,\n isInRestrictedView = false,\n expandToViewport = false,\n hasFiltering,\n}: UseButtonDropdownOptions): UseButtonDropdownApi {\n const [filteringValue, setFilteringValue] = useState('');\n\n const filteredItems = useMemo(\n () => (hasFiltering && filteringValue ? filterItems(items, filteringValue) : items),\n [hasFiltering, filteringValue, items]\n );\n\n const showExpandableGroups = hasExpandableGroups && !filteringValue;\n\n const {\n targetItem,\n isHighlighted,\n isKeyboardHighlight,\n isExpanded,\n highlightItem,\n moveHighlight,\n expandGroup,\n collapseGroup,\n reset,\n setIsUsingMouse,\n } = useHighlightedMenu({\n items: filteredItems,\n hasExpandableGroups: showExpandableGroups,\n isInRestrictedView,\n });\n\n // If the filtering input changes, the options list also changes,\n // so the highlight isn't valid anymore.\n const prevFilteringValue = useRef(filteringValue);\n useEffect(() => {\n if (prevFilteringValue.current !== filteringValue) {\n prevFilteringValue.current = filteringValue;\n reset();\n }\n }, [filteringValue, reset]);\n\n const { isOpen, closeDropdown: closeDropdownState, ...openStateProps } = useOpenState({ onClose: reset });\n\n const closeDropdown = () => {\n setFilteringValue('');\n closeDropdownState();\n };\n\n const toggleDropdown = (options: { moveHighlightOnOpen?: boolean } = {}) => {\n const moveHighlightOnOpen = options.moveHighlightOnOpen ?? true;\n if (!isOpen && moveHighlightOnOpen && !hasFiltering) {\n moveHighlight(1);\n }\n if (isOpen) {\n setFilteringValue('');\n }\n openStateProps.toggleDropdown();\n };\n\n const onDropdownFocusLeave = () => {\n if (hasFiltering && isOpen) {\n if (expandToViewport) {\n // When expanded to viewport the focus can't move naturally to the next element.\n // Returning the focus to the trigger instead.\n onReturnFocus();\n }\n closeDropdown();\n }\n };\n\n const onGroupToggle: GroupToggle = item => (!isExpanded(item) ? expandGroup(item) : collapseGroup());\n\n const onItemActivate: ItemActivate = (item, event) => {\n const isCheckbox = isCheckboxItem(item);\n const isLink = isLinkItem(item);\n const details = {\n id: item.id || 'undefined',\n href: isLink ? item.href : undefined,\n external: isLink ? item.external : undefined,\n target: isLink ? getItemTarget(item) : undefined,\n checked: isCheckbox ? !item.checked : undefined,\n };\n onReturnFocus();\n if (onItemFollow && isLink && isPlainLeftClick(event)) {\n fireCancelableEvent(onItemFollow, details, event);\n }\n if (onItemClick) {\n fireCancelableEvent(onItemClick, details, event);\n }\n closeDropdown();\n };\n\n const openAndSelectFirst = (event: React.KeyboardEvent) => {\n toggleDropdown();\n event.preventDefault();\n };\n\n const actOnParentDropdown = (event: React.KeyboardEvent) => {\n // if there is no highlighted item we act on the trigger by opening or closing dropdown\n if (!targetItem) {\n if (isOpen && !isInRestrictedView) {\n toggleDropdown();\n } else {\n openAndSelectFirst(event);\n }\n } else {\n if (isItemGroup(targetItem)) {\n onGroupToggle(targetItem, event);\n } else {\n onItemActivate(targetItem, event);\n }\n }\n };\n\n const activate = (event: React.KeyboardEvent, isEnter?: boolean) => {\n setIsUsingMouse(false);\n\n // if item is a link we rely on default behavior of an anchor, no need to prevent\n if (targetItem && isLinkItem(targetItem) && isEnter) {\n return;\n }\n\n event.preventDefault();\n actOnParentDropdown(event);\n };\n\n const onKeyDown = (event: React.KeyboardEvent) => {\n setIsUsingMouse(false);\n switch (event.keyCode) {\n case KeyCode.down: {\n if (!isOpen) {\n toggleDropdown();\n if (!hasFiltering) {\n moveHighlight(1, true);\n }\n } else {\n moveHighlight(1);\n }\n event.preventDefault();\n break;\n }\n case KeyCode.up: {\n if (!isOpen) {\n toggleDropdown();\n if (!hasFiltering) {\n moveHighlight(-1, true);\n }\n } else {\n moveHighlight(-1);\n }\n event.preventDefault();\n break;\n }\n case KeyCode.space: {\n // Prevent scrolling the list of items and highlighting the trigger when filtering\n // isn't active. Hitting space when filtering is active should just type a space\n // character into the input, or activate the clear button.\n if (!hasFiltering && !isOpen) {\n event.preventDefault();\n }\n break;\n }\n case KeyCode.enter: {\n // While filtering, pressing Enter without a highlighted item should not select\n // any item or close the dropdown.\n if (isOpen && hasFiltering && !targetItem) {\n break;\n }\n if (!targetItem?.disabled) {\n activate(event, true);\n }\n break;\n }\n case KeyCode.left:\n case KeyCode.right: {\n // When filtering is enabled and there's text in the filter input, left/right\n // arrow keys should move the caret between the characters.\n if (hasFiltering && filteringValue) {\n break;\n }\n if (targetItem && !targetItem.disabled && isItemGroup(targetItem) && !isExpanded(targetItem)) {\n expandGroup();\n } else if (hasExpandableGroups) {\n collapseGroup();\n }\n\n event.preventDefault();\n break;\n }\n case KeyCode.escape: {\n onReturnFocus();\n closeDropdown();\n event.preventDefault();\n if (isOpen) {\n event.stopPropagation();\n }\n break;\n }\n case KeyCode.tab: {\n // In filtering mode the dropdown contains multiple focusable elements (the filter\n // input and its clear button). Tabbing between them must not close the dropdown, so\n // closing on Tab is handled by onDropdownFocusLeave instead, which only fires once\n // focus actually leaves the dropdown.\n if (hasFiltering) {\n break;\n }\n // When expanded to viewport the focus can't move naturally to the next element.\n // Returning the focus to the trigger instead.\n if (expandToViewport) {\n onReturnFocus();\n }\n closeDropdown();\n break;\n }\n }\n };\n const onKeyUp = (event: React.KeyboardEvent) => {\n // When using a roving tabindex (filtering disabled), we need to handle activating items\n // with Space separately because there is a bug in Firefox where changing the focus during\n // a Space keydown event it will trigger unexpected click events on the new element.\n // See https://bugzilla.mozilla.org/show_bug.cgi?id=1220143\n if (event.keyCode === KeyCode.space && !targetItem?.disabled && !hasFiltering) {\n activate(event);\n }\n };\n\n return {\n isOpen,\n targetItem,\n isHighlighted,\n isKeyboardHighlight,\n isExpanded,\n highlightItem,\n onKeyDown,\n onKeyUp,\n onItemActivate,\n onGroupToggle,\n onDropdownFocusLeave,\n toggleDropdown,\n closeDropdown,\n setIsUsingMouse,\n filteringValue,\n setFilteringValue,\n filteredItems,\n showExpandableGroups,\n };\n}\n"]}
1
+ {"version":3,"file":"use-button-dropdown.js","sourceRoot":"","sources":["../../../../src/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AAQ,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,MAAM;QACN,UAAU;QACV,aAAa;QACb,mBAAmB;QACnB,UAAU;QACV,aAAa;QACb,SAAS;QACT,OAAO;QACP,cAAc;QACd,aAAa;QACb,oBAAoB;QACpB,cAAc;QACd,cAAc;QACd,aAAa;QACb,eAAe;QACf,cAAc;QACd,iBAAiB;QACjB,aAAa;QACb,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\n\nimport { useOpenState } from '../../internal/components/options-list/utils/use-open-state';\nimport { fireCancelableEvent, isPlainLeftClick } from '../../internal/events';\nimport { KeyCode } from '../../internal/keycode';\nimport { CancelableEventHandler } from '../../types/events';\nimport { ButtonDropdownProps, ButtonDropdownSettings, GroupToggle, HighlightProps, ItemActivate } from '../interfaces';\nimport { filterItems } from './filter-items';\nimport useHighlightedMenu from './use-highlighted-menu';\nimport { getItemTarget, isCheckboxItem, isItemGroup, isLinkItem } from './utils';\n\ninterface UseButtonDropdownOptions extends ButtonDropdownSettings {\n items: ButtonDropdownProps.Items;\n onItemClick?: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n onItemFollow?: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n onReturnFocus: () => void;\n expandToViewport?: boolean;\n hasFiltering: boolean;\n}\n\ninterface UseButtonDropdownApi extends HighlightProps {\n isOpen: boolean;\n onKeyDown: (event: React.KeyboardEvent) => void;\n onKeyUp: (event: React.KeyboardEvent) => void;\n onItemActivate: ItemActivate;\n onGroupToggle: GroupToggle;\n onDropdownFocusLeave: () => void;\n onDropdownBlur: () => void;\n toggleDropdown: (options?: { moveHighlightOnOpen?: boolean }) => void;\n closeDropdown: () => void;\n setIsUsingMouse: (isUsingMouse: boolean) => void;\n filteringValue: string;\n setFilteringValue: (value: string) => void;\n filteredItems: ButtonDropdownProps.Items;\n showExpandableGroups: boolean;\n}\n\nexport function useButtonDropdown({\n items,\n onItemClick,\n onItemFollow,\n onReturnFocus,\n hasExpandableGroups,\n isInRestrictedView = false,\n expandToViewport = false,\n hasFiltering,\n}: UseButtonDropdownOptions): UseButtonDropdownApi {\n const [filteringValue, setFilteringValue] = useState('');\n\n const filteredItems = useMemo(\n () => (hasFiltering && filteringValue ? filterItems(items, filteringValue) : items),\n [hasFiltering, filteringValue, items]\n );\n\n const showExpandableGroups = hasExpandableGroups && !filteringValue;\n\n const {\n targetItem,\n isHighlighted,\n isKeyboardHighlight,\n isExpanded,\n highlightItem,\n moveHighlight,\n expandGroup,\n collapseGroup,\n reset,\n setIsUsingMouse,\n } = useHighlightedMenu({\n items: filteredItems,\n hasExpandableGroups: showExpandableGroups,\n isInRestrictedView,\n });\n\n // If the filtering input changes, the options list also changes,\n // so the highlight isn't valid anymore.\n const prevFilteringValue = useRef(filteringValue);\n useEffect(() => {\n if (prevFilteringValue.current !== filteringValue) {\n prevFilteringValue.current = filteringValue;\n reset();\n }\n }, [filteringValue, reset]);\n\n const { isOpen, closeDropdown: closeDropdownState, ...openStateProps } = useOpenState({ onClose: reset });\n\n const closeDropdown = () => {\n setFilteringValue('');\n closeDropdownState();\n };\n\n const toggleDropdown = (options: { moveHighlightOnOpen?: boolean } = {}) => {\n const moveHighlightOnOpen = options.moveHighlightOnOpen ?? true;\n if (!isOpen && moveHighlightOnOpen && !hasFiltering) {\n moveHighlight(1);\n }\n if (isOpen) {\n setFilteringValue('');\n }\n openStateProps.toggleDropdown();\n };\n\n const onDropdownFocusLeave = () => {\n if (hasFiltering && isOpen) {\n if (expandToViewport) {\n // When expanded to viewport the focus can't move naturally to the next element.\n // Returning the focus to the trigger instead.\n onReturnFocus();\n }\n closeDropdown();\n }\n };\n\n // Close when focus leaves the entire widget (trigger and menu), for example when focus\n // moves to an app layout drawer or an element in a different frame. The filtering variant\n // keeps focus inside the dropdown content and closes via onDropdownFocusLeave instead.\n const onDropdownBlur = () => {\n if (isOpen && !hasFiltering) {\n closeDropdown();\n }\n };\n\n const onGroupToggle: GroupToggle = item => (!isExpanded(item) ? expandGroup(item) : collapseGroup());\n\n const onItemActivate: ItemActivate = (item, event) => {\n const isCheckbox = isCheckboxItem(item);\n const isLink = isLinkItem(item);\n const details = {\n id: item.id || 'undefined',\n href: isLink ? item.href : undefined,\n external: isLink ? item.external : undefined,\n target: isLink ? getItemTarget(item) : undefined,\n checked: isCheckbox ? !item.checked : undefined,\n };\n onReturnFocus();\n if (onItemFollow && isLink && isPlainLeftClick(event)) {\n fireCancelableEvent(onItemFollow, details, event);\n }\n if (onItemClick) {\n fireCancelableEvent(onItemClick, details, event);\n }\n closeDropdown();\n };\n\n const openAndSelectFirst = (event: React.KeyboardEvent) => {\n toggleDropdown();\n event.preventDefault();\n };\n\n const actOnParentDropdown = (event: React.KeyboardEvent) => {\n // if there is no highlighted item we act on the trigger by opening or closing dropdown\n if (!targetItem) {\n if (isOpen && !isInRestrictedView) {\n toggleDropdown();\n } else {\n openAndSelectFirst(event);\n }\n } else {\n if (isItemGroup(targetItem)) {\n onGroupToggle(targetItem, event);\n } else {\n onItemActivate(targetItem, event);\n }\n }\n };\n\n const activate = (event: React.KeyboardEvent, isEnter?: boolean) => {\n setIsUsingMouse(false);\n\n // if item is a link we rely on default behavior of an anchor, no need to prevent\n if (targetItem && isLinkItem(targetItem) && isEnter) {\n return;\n }\n\n event.preventDefault();\n actOnParentDropdown(event);\n };\n\n const onKeyDown = (event: React.KeyboardEvent) => {\n setIsUsingMouse(false);\n switch (event.keyCode) {\n case KeyCode.down: {\n if (!isOpen) {\n toggleDropdown();\n if (!hasFiltering) {\n moveHighlight(1, true);\n }\n } else {\n moveHighlight(1);\n }\n event.preventDefault();\n break;\n }\n case KeyCode.up: {\n if (!isOpen) {\n toggleDropdown();\n if (!hasFiltering) {\n moveHighlight(-1, true);\n }\n } else {\n moveHighlight(-1);\n }\n event.preventDefault();\n break;\n }\n case KeyCode.space: {\n // Prevent scrolling the list of items and highlighting the trigger when filtering\n // isn't active. Hitting space when filtering is active should just type a space\n // character into the input, or activate the clear button.\n if (!hasFiltering && !isOpen) {\n event.preventDefault();\n }\n break;\n }\n case KeyCode.enter: {\n // While filtering, pressing Enter without a highlighted item should not select\n // any item or close the dropdown.\n if (isOpen && hasFiltering && !targetItem) {\n break;\n }\n if (!targetItem?.disabled) {\n activate(event, true);\n }\n break;\n }\n case KeyCode.left:\n case KeyCode.right: {\n // When filtering is enabled and there's text in the filter input, left/right\n // arrow keys should move the caret between the characters.\n if (hasFiltering && filteringValue) {\n break;\n }\n if (targetItem && !targetItem.disabled && isItemGroup(targetItem) && !isExpanded(targetItem)) {\n expandGroup();\n } else if (hasExpandableGroups) {\n collapseGroup();\n }\n\n event.preventDefault();\n break;\n }\n case KeyCode.escape: {\n onReturnFocus();\n closeDropdown();\n event.preventDefault();\n if (isOpen) {\n event.stopPropagation();\n }\n break;\n }\n case KeyCode.tab: {\n // In filtering mode the dropdown contains multiple focusable elements (the filter\n // input and its clear button). Tabbing between them must not close the dropdown, so\n // closing on Tab is handled by onDropdownFocusLeave instead, which only fires once\n // focus actually leaves the dropdown.\n if (hasFiltering) {\n break;\n }\n // When expanded to viewport the focus can't move naturally to the next element.\n // Returning the focus to the trigger instead.\n if (expandToViewport) {\n onReturnFocus();\n }\n closeDropdown();\n break;\n }\n }\n };\n const onKeyUp = (event: React.KeyboardEvent) => {\n // When using a roving tabindex (filtering disabled), we need to handle activating items\n // with Space separately because there is a bug in Firefox where changing the focus during\n // a Space keydown event it will trigger unexpected click events on the new element.\n // See https://bugzilla.mozilla.org/show_bug.cgi?id=1220143\n if (event.keyCode === KeyCode.space && !targetItem?.disabled && !hasFiltering) {\n activate(event);\n }\n };\n\n return {\n isOpen,\n targetItem,\n isHighlighted,\n isKeyboardHighlight,\n isExpanded,\n highlightItem,\n onKeyDown,\n onKeyUp,\n onItemActivate,\n onGroupToggle,\n onDropdownFocusLeave,\n onDropdownBlur,\n toggleDropdown,\n closeDropdown,\n setIsUsingMouse,\n filteringValue,\n setFilteringValue,\n filteredItems,\n showExpandableGroups,\n };\n}\n"]}
@@ -18,11 +18,23 @@ export declare function useLocale(): string | null;
18
18
  * TypeScript allows those types because JS implicitly casts them to string.
19
19
  */
20
20
  type StringKeyOf<T> = Extract<keyof T, string>;
21
- export interface ComponentFormatFunction<ComponentName extends StringKeyOf<I18nFormatArgTypes>> {
22
- <MessageKey extends StringKeyOf<I18nFormatArgTypes[ComponentName]>>(key: MessageKey, provided: string, handler?: CustomHandler<string, I18nFormatArgTypes[ComponentName][MessageKey]>): string;
23
- <MessageKey extends StringKeyOf<I18nFormatArgTypes[ComponentName]>>(key: MessageKey, provided: string | undefined, handler?: CustomHandler<string, I18nFormatArgTypes[ComponentName][MessageKey]>): string | undefined;
24
- <MessageKey extends StringKeyOf<I18nFormatArgTypes[ComponentName]>, ReturnValue>(key: MessageKey, provided: ReturnValue, handler: I18nFormatArgTypes[ComponentName][MessageKey] extends never ? never : CustomHandler<ReturnValue, I18nFormatArgTypes[ComponentName][MessageKey]>): ReturnValue;
21
+ export interface GenericI18nFormatArgTypes {
22
+ [componentName: string]: {
23
+ [messageKey: string]: Record<string, string | number> | never;
24
+ };
25
25
  }
26
+ export interface GenericI18nFormatFunction<NamespaceTypes = GenericI18nFormatArgTypes, ComponentName extends StringKeyOf<NamespaceTypes> = StringKeyOf<NamespaceTypes>> {
27
+ <MessageKey extends StringKeyOf<NamespaceTypes[ComponentName]>>(key: MessageKey, provided: string, handler?: CustomHandler<string, NamespaceTypes[ComponentName][MessageKey]>): string;
28
+ <MessageKey extends StringKeyOf<NamespaceTypes[ComponentName]>>(key: MessageKey, provided: string | undefined, handler?: CustomHandler<string | undefined, NamespaceTypes[ComponentName][MessageKey]>): string | undefined;
29
+ <MessageKey extends StringKeyOf<NamespaceTypes[ComponentName]>, ReturnValue>(key: MessageKey, provided: ReturnValue, handler: NamespaceTypes[ComponentName][MessageKey] extends never ? never : CustomHandler<ReturnValue, NamespaceTypes[ComponentName][MessageKey]>): ReturnValue;
30
+ }
31
+ export type I18nFormatFunction<NamespaceTypes = GenericI18nFormatArgTypes, ComponentName extends StringKeyOf<NamespaceTypes> = StringKeyOf<NamespaceTypes>> = GenericI18nFormatFunction<NamespaceTypes, ComponentName>;
32
+ export type ComponentFormatFunction<ComponentName extends StringKeyOf<I18nFormatArgTypes>> = I18nFormatFunction<I18nFormatArgTypes, ComponentName>;
33
+ /**
34
+ * Public hook for third-party component libraries to resolve translations
35
+ * through I18nProvider under their own namespace.
36
+ */
37
+ export declare function useCustomI18n<NamespaceTypes = GenericI18nFormatArgTypes, ComponentName extends StringKeyOf<NamespaceTypes> = StringKeyOf<NamespaceTypes>>(namespace: string, componentName: ComponentName): I18nFormatFunction<NamespaceTypes, ComponentName>;
26
38
  export declare function useInternalI18n<ComponentName extends StringKeyOf<I18nFormatArgTypes>>(componentName: ComponentName): ComponentFormatFunction<ComponentName>;
27
39
  export {};
28
40
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/i18n/context.ts"],"names":[],"mappings":"AAGA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,MAAM,aAAa,CAAC,WAAW,EAAE,YAAY,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,MAAM,KAAK,WAAW,CAAC;AAEjH,MAAM,WAAW,cAAc;IAC7B,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9E,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,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AAE,cAAc,CAAC,aAAa,CAAC,CAAC,UAAU,CAAC,SAAS,KAAK,GAC5D,KAAK,GACL,aAAa,CAAC,WAAW,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC,UAAU,CAAC,CAAC,GACxE,WAAW,CAAC;CAChB;AAED,MAAM,MAAM,kBAAkB,CAC5B,cAAc,GAAG,yBAAyB,EAC1C,aAAa,SAAS,WAAW,CAAC,cAAc,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,IAC7E,yBAAyB,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;AAE7D,MAAM,MAAM,uBAAuB,CAAC,aAAa,SAAS,WAAW,CAAC,kBAAkB,CAAC,IAAI,kBAAkB,CAC7G,kBAAkB,EAClB,aAAa,CACd,CAAC;AAEF;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,cAAc,GAAG,yBAAyB,EAC1C,aAAa,SAAS,WAAW,CAAC,cAAc,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,EAC/E,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,kBAAkB,CAAC,cAAc,EAAE,aAAa,CAAC,CAQpG;AAED,wBAAgB,eAAe,CAAC,aAAa,SAAS,WAAW,CAAC,kBAAkB,CAAC,EACnF,aAAa,EAAE,aAAa,GAC3B,uBAAuB,CAAC,aAAa,CAAC,CAExC"}
@@ -12,11 +12,17 @@ export function useLocale() {
12
12
  var _a;
13
13
  return ((_a = useContext(InternalI18nContext)) !== null && _a !== void 0 ? _a : defaultContextValue).locale;
14
14
  }
15
- export function useInternalI18n(componentName) {
15
+ /**
16
+ * Public hook for third-party component libraries to resolve translations
17
+ * through I18nProvider under their own namespace.
18
+ */
19
+ export function useCustomI18n(namespace, componentName) {
16
20
  var _a;
17
21
  const { format } = (_a = useContext(InternalI18nContext)) !== null && _a !== void 0 ? _a : defaultContextValue;
18
- return (key, provided, customHandler) => {
19
- return format(namespace, componentName, key, provided, customHandler);
20
- };
22
+ const formatFunction = (key, provided, customHandler) => format(namespace, componentName, key, provided, customHandler);
23
+ return formatFunction;
24
+ }
25
+ export function useInternalI18n(componentName) {
26
+ return useCustomI18n(namespace, componentName);
21
27
  }
22
28
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/i18n/context.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAgB/D,MAAM,CAAC,MAAM,SAAS,GAAG,8BAA8B,CAAC;AAExD,MAAM,mBAAmB,GAA6B;IACpD,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,CAAI,UAAkB,EAAE,UAAkB,EAAE,IAAY,EAAE,QAAW,EAAE,EAAE,CAAC,QAAQ;CAC3F,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC,mBAAmB,CAAC,aAAa,CACvF,KAAK,EACL,qBAAqB,CACtB,CAAC;AAEF,MAAM,UAAU,SAAS;;IACvB,OAAO,CAAC,MAAA,UAAU,CAAC,mBAAmB,CAAC,mCAAI,mBAAmB,CAAC,CAAC,MAAM,CAAC;AACzE,CAAC;AA4BD,MAAM,UAAU,eAAe,CAC7B,aAA4B;;IAE5B,MAAM,EAAE,MAAM,EAAE,GAAG,MAAA,UAAU,CAAC,mBAAmB,CAAC,mCAAI,mBAAmB,CAAC;IAC1E,OAAO,CACL,GAAe,EACf,QAAmB,EACnB,aAAuF,EACvF,EAAE;QACF,OAAO,MAAM,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;IACxE,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useContext } from 'react';\n\nimport { awsuiPluginsInternal } from '../internal/plugins/api';\nimport { I18nFormatArgTypes } from './messages-types';\n\nexport type CustomHandler<ReturnValue, FormatFnArgs> = (formatFn: (args: FormatFnArgs) => string) => ReturnValue;\n\nexport interface FormatFunction {\n (namespace: string, component: string, key: string, provided: string): string;\n (namespace: string, component: string, key: string, provided: string | undefined): string | undefined;\n <T, A = unknown>(namespace: string, component: string, key: string, provided: T, handler?: CustomHandler<T, A>): T;\n}\n\ninterface InternalI18nContextProps {\n locale: string | null;\n format: FormatFunction;\n}\n\nexport const namespace = 'cloudscape-design-components';\n\nconst defaultContextValue: InternalI18nContextProps = {\n locale: null,\n format: <T>(_namespace: string, _component: string, _key: string, provided: T) => provided,\n};\n\nexport const InternalI18nContext = awsuiPluginsInternal.sharedReactContexts.createContext<InternalI18nContextProps>(\n React,\n 'InternalI18nContext'\n);\n\nexport function useLocale(): string | null {\n return (useContext(InternalI18nContext) ?? defaultContextValue).locale;\n}\n\n/**\n * Utility to get \"keyof T\" but exclude number or symbol types.\n * TypeScript allows those types because JS implicitly casts them to string.\n */\ntype StringKeyOf<T> = Extract<keyof T, string>;\n\nexport interface ComponentFormatFunction<ComponentName extends StringKeyOf<I18nFormatArgTypes>> {\n <MessageKey extends StringKeyOf<I18nFormatArgTypes[ComponentName]>>(\n key: MessageKey,\n provided: string,\n handler?: CustomHandler<string, I18nFormatArgTypes[ComponentName][MessageKey]>\n ): string;\n <MessageKey extends StringKeyOf<I18nFormatArgTypes[ComponentName]>>(\n key: MessageKey,\n provided: string | undefined,\n handler?: CustomHandler<string, I18nFormatArgTypes[ComponentName][MessageKey]>\n ): string | undefined;\n <MessageKey extends StringKeyOf<I18nFormatArgTypes[ComponentName]>, ReturnValue>(\n key: MessageKey,\n provided: ReturnValue,\n handler: I18nFormatArgTypes[ComponentName][MessageKey] extends never\n ? never\n : CustomHandler<ReturnValue, I18nFormatArgTypes[ComponentName][MessageKey]>\n ): ReturnValue;\n}\n\nexport function useInternalI18n<ComponentName extends StringKeyOf<I18nFormatArgTypes>>(\n componentName: ComponentName\n): ComponentFormatFunction<ComponentName> {\n const { format } = useContext(InternalI18nContext) ?? defaultContextValue;\n return <MessageKey extends StringKeyOf<I18nFormatArgTypes[ComponentName]>, ValueType>(\n key: MessageKey,\n provided: ValueType,\n customHandler?: CustomHandler<ValueType, I18nFormatArgTypes[ComponentName][MessageKey]>\n ) => {\n return format(namespace, componentName, key, provided, customHandler);\n };\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/i18n/context.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAgB/D,MAAM,CAAC,MAAM,SAAS,GAAG,8BAA8B,CAAC;AAExD,MAAM,mBAAmB,GAA6B;IACpD,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,CAAI,UAAkB,EAAE,UAAkB,EAAE,IAAY,EAAE,QAAW,EAAE,EAAE,CAAC,QAAQ;CAC3F,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC,mBAAmB,CAAC,aAAa,CACvF,KAAK,EACL,qBAAqB,CACtB,CAAC;AAEF,MAAM,UAAU,SAAS;;IACvB,OAAO,CAAC,MAAA,UAAU,CAAC,mBAAmB,CAAC,mCAAI,mBAAmB,CAAC,CAAC,MAAM,CAAC;AACzE,CAAC;AA+CD;;;GAGG;AACH,MAAM,UAAU,aAAa,CAG3B,SAAiB,EAAE,aAA4B;;IAC/C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAA,UAAU,CAAC,mBAAmB,CAAC,mCAAI,mBAAmB,CAAC;IAC1E,MAAM,cAAc,GAAG,CACrB,GAAe,EACf,QAAmB,EACnB,aAAmF,EACnF,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;IACpE,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,aAA4B;IAE5B,OAAO,aAAa,CAAoC,SAAS,EAAE,aAAa,CAAC,CAAC;AACpF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useContext } from 'react';\n\nimport { awsuiPluginsInternal } from '../internal/plugins/api';\nimport { I18nFormatArgTypes } from './messages-types';\n\nexport type CustomHandler<ReturnValue, FormatFnArgs> = (formatFn: (args: FormatFnArgs) => string) => ReturnValue;\n\nexport interface FormatFunction {\n (namespace: string, component: string, key: string, provided: string): string;\n (namespace: string, component: string, key: string, provided: string | undefined): string | undefined;\n <T, A = unknown>(namespace: string, component: string, key: string, provided: T, handler?: CustomHandler<T, A>): T;\n}\n\ninterface InternalI18nContextProps {\n locale: string | null;\n format: FormatFunction;\n}\n\nexport const namespace = 'cloudscape-design-components';\n\nconst defaultContextValue: InternalI18nContextProps = {\n locale: null,\n format: <T>(_namespace: string, _component: string, _key: string, provided: T) => provided,\n};\n\nexport const InternalI18nContext = awsuiPluginsInternal.sharedReactContexts.createContext<InternalI18nContextProps>(\n React,\n 'InternalI18nContext'\n);\n\nexport function useLocale(): string | null {\n return (useContext(InternalI18nContext) ?? defaultContextValue).locale;\n}\n\n/**\n * Utility to get \"keyof T\" but exclude number or symbol types.\n * TypeScript allows those types because JS implicitly casts them to string.\n */\ntype StringKeyOf<T> = Extract<keyof T, string>;\n\nexport interface GenericI18nFormatArgTypes {\n [componentName: string]: {\n [messageKey: string]: Record<string, string | number> | never;\n };\n}\n\nexport interface GenericI18nFormatFunction<\n NamespaceTypes = GenericI18nFormatArgTypes,\n ComponentName extends StringKeyOf<NamespaceTypes> = StringKeyOf<NamespaceTypes>,\n> {\n <MessageKey extends StringKeyOf<NamespaceTypes[ComponentName]>>(\n key: MessageKey,\n provided: string,\n handler?: CustomHandler<string, NamespaceTypes[ComponentName][MessageKey]>\n ): string;\n <MessageKey extends StringKeyOf<NamespaceTypes[ComponentName]>>(\n key: MessageKey,\n provided: string | undefined,\n handler?: CustomHandler<string | undefined, NamespaceTypes[ComponentName][MessageKey]>\n ): string | undefined;\n <MessageKey extends StringKeyOf<NamespaceTypes[ComponentName]>, ReturnValue>(\n key: MessageKey,\n provided: ReturnValue,\n handler: NamespaceTypes[ComponentName][MessageKey] extends never\n ? never\n : CustomHandler<ReturnValue, NamespaceTypes[ComponentName][MessageKey]>\n ): ReturnValue;\n}\n\nexport type I18nFormatFunction<\n NamespaceTypes = GenericI18nFormatArgTypes,\n ComponentName extends StringKeyOf<NamespaceTypes> = StringKeyOf<NamespaceTypes>,\n> = GenericI18nFormatFunction<NamespaceTypes, ComponentName>;\n\nexport type ComponentFormatFunction<ComponentName extends StringKeyOf<I18nFormatArgTypes>> = I18nFormatFunction<\n I18nFormatArgTypes,\n ComponentName\n>;\n\n/**\n * Public hook for third-party component libraries to resolve translations\n * through I18nProvider under their own namespace.\n */\nexport function useCustomI18n<\n NamespaceTypes = GenericI18nFormatArgTypes,\n ComponentName extends StringKeyOf<NamespaceTypes> = StringKeyOf<NamespaceTypes>,\n>(namespace: string, componentName: ComponentName): I18nFormatFunction<NamespaceTypes, ComponentName> {\n const { format } = useContext(InternalI18nContext) ?? defaultContextValue;\n const formatFunction = <MessageKey extends StringKeyOf<NamespaceTypes[ComponentName]>, ValueType>(\n key: MessageKey,\n provided: ValueType,\n customHandler?: CustomHandler<ValueType, NamespaceTypes[ComponentName][MessageKey]>\n ) => format(namespace, componentName, key, provided, customHandler);\n return formatFunction;\n}\n\nexport function useInternalI18n<ComponentName extends StringKeyOf<I18nFormatArgTypes>>(\n componentName: ComponentName\n): ComponentFormatFunction<ComponentName> {\n return useCustomI18n<I18nFormatArgTypes, ComponentName>(namespace, componentName);\n}\n"]}
@@ -1,3 +1,5 @@
1
1
  export { I18nProvider as default, I18nProvider, I18nProviderProps } from './provider';
2
2
  export { importMessages } from './dynamic';
3
+ export { useCustomI18n } from './context';
4
+ export type { I18nFormatFunction } from './context';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/i18n/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/i18n/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
@@ -3,4 +3,5 @@
3
3
  'use client';
4
4
  export { I18nProvider as default, I18nProvider } from './provider';
5
5
  export { importMessages } from './dynamic';
6
+ export { useCustomI18n } from './context';
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,YAAY,CAAC;AACb,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\nexport { I18nProvider as default, I18nProvider, I18nProviderProps } from './provider';\nexport { importMessages } from './dynamic';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,YAAY,CAAC;AACb,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\nexport { I18nProvider as default, I18nProvider, I18nProviderProps } from './provider';\nexport { importMessages } from './dynamic';\nexport { useCustomI18n } from './context';\nexport type { I18nFormatFunction } from './context';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAMhE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,QAAA,MAAM,KAAK,mFA8FV,CAAC;AAGF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAMhE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,QAAA,MAAM,KAAK,mFAkGV,CAAC;AAGF,eAAe,KAAK,CAAC"}
@@ -8,7 +8,7 @@ import useBaseComponent from '../internal/hooks/use-base-component';
8
8
  import { applyDisplayName } from '../internal/utils/apply-display-name';
9
9
  import InternalInput from './internal';
10
10
  import styles from './styles.css.js';
11
- const Input = React.forwardRef(({ value, type = 'text', step, inputMode, autoComplete = true, spellcheck, disabled, readOnly, disableBrowserAutocorrect, onKeyDown, onKeyUp, onChange, onBlur, onFocus, ariaRequired, name, placeholder, autoFocus, ariaLabel, ariaLabelledby, ariaDescribedby, invalid, warning, controlId, clearAriaLabel, nativeInputAttributes, style, ...rest }, ref) => {
11
+ const Input = React.forwardRef(({ value, type = 'text', step, inputMode, autoComplete = true, spellcheck, disabled, readOnly, disableBrowserAutocorrect, onKeyDown, onKeyUp, onChange, onBlur, onFocus, ariaRequired, name, placeholder, autoFocus, ariaLabel, ariaLabelledby, ariaDescribedby, invalid, warning, controlId, clearAriaLabel, nativeInputAttributes, style, prefix, suffix, ...rest }, ref) => {
12
12
  const baseComponentProps = useBaseComponent('Input', {
13
13
  props: { autoComplete, autoFocus, disableBrowserAutocorrect, inputMode, readOnly, spellcheck, type },
14
14
  });
@@ -52,7 +52,9 @@ const Input = React.forwardRef(({ value, type = 'text', step, inputMode, autoCom
52
52
  controlId,
53
53
  clearAriaLabel,
54
54
  nativeInputAttributes,
55
- style, className: clsx(styles.root, baseProps.className), __inheritFormFieldProps: true, __injectAnalyticsComponentMetadata: true }));
55
+ style,
56
+ prefix,
57
+ suffix, className: clsx(styles.root, baseProps.className), __inheritFormFieldProps: true, __injectAnalyticsComponentMetadata: true }));
56
58
  });
57
59
  applyDisplayName(Input, 'Input');
58
60
  export default Input;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/input/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EAAO,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,aAAa,MAAM,YAAY,CAAC;AAEvC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,K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AAM;QACN,OAAO;QACP,WAAW;QACX,QAAQ;QACR,IAAI;QACJ,IAAI;QACJ,SAAS;QACT,UAAU;QACV,KAAK;QACL,eAAe;QACf,cAAc;QACd,OAAO;QACP,OAAO;QACP,SAAS;QACT,cAAc;QACd,qBAAqB;QACrB,KAAK,EAEP,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,EACjD,uBAAuB,EAAE,IAAI,EAC7B,kCAAkC,EAAE,IAAI,GACxC,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACjC,eAAe,KAAK,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n'use client';\nimport React, { Ref, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { InputProps } from './interfaces';\nimport InternalInput from './internal';\n\nimport styles from './styles.css.js';\n\nexport { InputProps };\n\nconst Input = React.forwardRef(\n (\n {\n value,\n type = 'text',\n step,\n inputMode,\n autoComplete = true,\n spellcheck,\n disabled,\n readOnly,\n disableBrowserAutocorrect,\n onKeyDown,\n onKeyUp,\n onChange,\n onBlur,\n onFocus,\n ariaRequired,\n name,\n placeholder,\n autoFocus,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n invalid,\n warning,\n controlId,\n clearAriaLabel,\n nativeInputAttributes,\n style,\n ...rest\n }: InputProps,\n ref: Ref<InputProps.Ref>\n ) => {\n const baseComponentProps = useBaseComponent('Input', {\n props: { autoComplete, autoFocus, disableBrowserAutocorrect, inputMode, readOnly, spellcheck, type },\n });\n const baseProps = getBaseProps(rest);\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n useImperativeHandle(\n ref,\n () => ({\n focus(...args: Parameters<HTMLElement['focus']>) {\n inputRef.current?.focus(...args);\n },\n select() {\n inputRef.current?.select();\n },\n }),\n [inputRef]\n );\n\n return (\n <InternalInput\n ref={inputRef}\n {...{\n ...baseProps,\n ...baseComponentProps,\n autoComplete,\n ariaLabel,\n ariaRequired,\n autoFocus,\n disabled,\n disableBrowserAutocorrect,\n name,\n onKeyDown,\n onKeyUp,\n onChange,\n onBlur,\n onFocus,\n placeholder,\n readOnly,\n type,\n step,\n inputMode,\n spellcheck,\n value,\n ariaDescribedby,\n ariaLabelledby,\n invalid,\n warning,\n controlId,\n clearAriaLabel,\n nativeInputAttributes,\n style,\n }}\n className={clsx(styles.root, baseProps.className)}\n __inheritFormFieldProps={true}\n __injectAnalyticsComponentMetadata={true}\n />\n );\n }\n);\n\napplyDisplayName(Input, 'Input');\nexport default Input;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/input/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EAAO,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,aAAa,MAAM,YAAY,CAAC;AAEvC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAC5B,CACE,EACE,KAAK,EACL,IAAI,GAAG,MAAM,EACb,IAAI,EACJ,SAAS,EACT,YAAY,GAAG,IAAI,EACnB,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,yBAAyB,EACzB,SAAS,EACT,OAAO,EACP,QAAQ,EACR,MAAM,EACN,OAAO,EACP,YAAY,EACZ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AAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,EACjD,uBAAuB,EAAE,IAAI,EAC7B,kCAAkC,EAAE,IAAI,GACxC,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACjC,eAAe,KAAK,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n'use client';\nimport React, { Ref, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { InputProps } from './interfaces';\nimport InternalInput from './internal';\n\nimport styles from './styles.css.js';\n\nexport { InputProps };\n\nconst Input = React.forwardRef(\n (\n {\n value,\n type = 'text',\n step,\n inputMode,\n autoComplete = true,\n spellcheck,\n disabled,\n readOnly,\n disableBrowserAutocorrect,\n onKeyDown,\n onKeyUp,\n onChange,\n onBlur,\n onFocus,\n ariaRequired,\n name,\n placeholder,\n autoFocus,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n invalid,\n warning,\n controlId,\n clearAriaLabel,\n nativeInputAttributes,\n style,\n prefix,\n suffix,\n ...rest\n }: InputProps,\n ref: Ref<InputProps.Ref>\n ) => {\n const baseComponentProps = useBaseComponent('Input', {\n props: { autoComplete, autoFocus, disableBrowserAutocorrect, inputMode, readOnly, spellcheck, type },\n });\n const baseProps = getBaseProps(rest);\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n useImperativeHandle(\n ref,\n () => ({\n focus(...args: Parameters<HTMLElement['focus']>) {\n inputRef.current?.focus(...args);\n },\n select() {\n inputRef.current?.select();\n },\n }),\n [inputRef]\n );\n\n return (\n <InternalInput\n ref={inputRef}\n {...{\n ...baseProps,\n ...baseComponentProps,\n autoComplete,\n ariaLabel,\n ariaRequired,\n autoFocus,\n disabled,\n disableBrowserAutocorrect,\n name,\n onKeyDown,\n onKeyUp,\n onChange,\n onBlur,\n onFocus,\n placeholder,\n readOnly,\n type,\n step,\n inputMode,\n spellcheck,\n value,\n ariaDescribedby,\n ariaLabelledby,\n invalid,\n warning,\n controlId,\n clearAriaLabel,\n nativeInputAttributes,\n style,\n prefix,\n suffix,\n }}\n className={clsx(styles.root, baseProps.className)}\n __inheritFormFieldProps={true}\n __injectAnalyticsComponentMetadata={true}\n />\n );\n }\n);\n\napplyDisplayName(Input, 'Input');\nexport default Input;\n"]}
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from 'react';
1
2
  import { BaseComponentProps } from '../types/base-component';
2
3
  import { BaseKeyDetail, CancelableEventHandler, NonCancelableEventHandler } from '../types/events';
3
4
  import { FormFieldValidationControlProps } from '../types/form-field';
@@ -156,6 +157,14 @@ export interface InputProps extends BaseComponentProps, BaseInputProps, InputKey
156
157
  * @awsuiSystem core
157
158
  */
158
159
  style?: InputProps.Style;
160
+ /**
161
+ * Use for content rendered before the editable value.
162
+ */
163
+ prefix?: ReactNode;
164
+ /**
165
+ * Use for content rendered after the editable value.
166
+ */
167
+ suffix?: ReactNode;
159
168
  }
160
169
  export declare namespace InputProps {
161
170
  type Type = 'text' | 'password' | 'search' | 'number' | 'email' | 'url';
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/input/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AACtE;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC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M,CAAC;YACf,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,UAAU,CAAC,EAAE,MAAM,CAAC;SACrB,CAAC;KACH;CACF;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/input/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../types/base-component';\nimport { BaseKeyDetail, CancelableEventHandler, NonCancelableEventHandler } from '../types/events';\nimport { FormFieldValidationControlProps } from '../types/form-field';\n/**\n * @awsuiSystem core\n */\nimport { NativeAttributes } from '../types/native-attributes';\n\nexport interface BaseInputProps {\n /**\n * Specifies the text entered into the form element.\n */\n value: string;\n\n /**\n * Specifies the name of the control used in HTML forms.\n */\n name?: string;\n\n /**\n * Specifies the placeholder text rendered when the value is an empty string.\n */\n placeholder?: string;\n\n /**\n * Specifies if the control is disabled, which prevents the\n * user from modifying the value and prevents the value from\n * being included in a form submission. A disabled control can't\n * receive focus.\n */\n disabled?: boolean;\n\n /**\n * Specifies if the control is read-only, which prevents the\n * user from modifying the value but includes it in a form\n * submission. A read-only control can receive focus.\n *\n * Don't use read-only inputs outside a form.\n */\n readOnly?: boolean;\n\n /**\n * Indicates whether the control should be focused as\n * soon as the page loads, which enables the user to\n * start typing without having to manually focus the control. Don't\n * use this option on pages where the control may be\n * scrolled out of the viewport.\n */\n autoFocus?: boolean;\n\n /**\n * Adds an `aria-label` to the native control.\n *\n * Use this if you don't have a visible label for this control.\n */\n ariaLabel?: string;\n\n /**\n * Specifies whether to add `aria-required` to the native control.\n */\n ariaRequired?: boolean;\n\n /**\n * Called when input focus is removed from the UI control.\n */\n onBlur?: NonCancelableEventHandler<null>;\n\n /**\n * Called when input focus is moved to the UI control.\n */\n onFocus?: NonCancelableEventHandler<null>;\n\n /**\n * Called whenever a user changes the input value (by typing or pasting).\n * The event `detail` contains the current value of the field.\n */\n onChange?: NonCancelableEventHandler<InputProps.ChangeDetail>;\n\n /**\n * Attributes to add to the native `input` element.\n * Some attributes will be automatically combined with internal attribute values:\n * - `className` will be appended.\n * - Event handlers will be chained, unless the default is prevented.\n *\n * We do not support using this attribute to apply custom styling.\n *\n * @awsuiSystem core\n */\n nativeInputAttributes?: NativeAttributes<React.InputHTMLAttributes<HTMLInputElement>>;\n}\n\nexport interface InputAutoCorrect {\n /**\n * Specifies whether to disable browser autocorrect and related features.\n * If you set this to `true`, it disables any native browser capabilities\n * that automatically correct user input, such as `autocorrect` and\n * `autocapitalize`. If you don't set it, the behavior follows the default behavior\n * of the user's browser.\n */\n disableBrowserAutocorrect?: boolean;\n}\n\nexport interface InputAutoComplete {\n /**\n * Specifies whether to enable a browser's autocomplete functionality for this input.\n * In some cases it might be appropriate to disable autocomplete (for example, for security-sensitive fields).\n * To use it correctly, set the `name` property.\n *\n * You can either provide a boolean value to set the property to \"on\" or \"off\", or specify a string value\n * for the [autocomplete](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) attribute.\n */\n autoComplete?: boolean | string;\n}\n\nexport interface InputSpellcheck {\n /**\n * Specifies the value of the `spellcheck` attribute on the native control.\n * This value controls the native browser capability to check for spelling/grammar errors.\n * If not set, the browser default behavior is to perform spellchecking.\n * For more details, check the [spellcheck MDN article](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck).\n *\n * Enhanced spellchecking features of your browser and/or operating system may send input values to external parties.\n * Make sure it’s deactivated for fields with sensitive information to prevent\n * inadvertently sending data (such as user passwords) to third parties.\n */\n spellcheck?: boolean;\n}\n\nexport interface InputKeyEvents {\n /**\n * Called when the underlying native textarea emits a `keydown` event.\n * The event `detail` contains the `keyCode` and information\n * about modifiers (that is, CTRL, ALT, SHIFT, META, etc.).\n */\n onKeyDown?: CancelableEventHandler<InputProps.KeyDetail>;\n\n /**\n * Called when the underlying native textarea emits a `keyup` event.\n * The event `detail` contains the `keyCode` and information\n * about modifiers (that is, CTRL, ALT, SHIFT, META, etc.).\n */\n onKeyUp?: CancelableEventHandler<InputProps.KeyDetail>;\n}\n\nexport interface InputClearLabel {\n /**\n * Adds an `aria-label` to the clear button inside the search input.\n * @i18n\n */\n clearAriaLabel?: string;\n}\n\nexport interface InputProps\n extends BaseComponentProps,\n BaseInputProps,\n InputKeyEvents,\n InputAutoCorrect,\n InputAutoComplete,\n InputSpellcheck,\n InputClearLabel,\n FormFieldValidationControlProps {\n /**\n * Specifies the type of control to render.\n * Inputs with a `number` type use the native element behavior, which might\n * be slightly different across browsers.\n */\n type?: InputProps.Type;\n\n /**\n * Adds a hint to the browser about the type of data a user may enter into this field.\n * Some devices may render a different virtual keyboard depending on this value.\n * This value may not be supported by all browsers or devices.\n */\n inputMode?: InputProps.InputMode;\n\n /**\n * The step attribute is a number that specifies the granularity that the value\n * must adhere to or the keyword \"any\". It is valid for the numeric input types,\n * including the date, month, week, time, datetime-local, number and range types.\n */\n step?: InputProps.Step;\n\n /**\n * An object containing CSS properties to customize the input's visual appearance.\n * Refer to the [style](/components/input/?tabId=style) tab for more details.\n * @awsuiSystem core\n */\n style?: InputProps.Style;\n}\n\nexport namespace InputProps {\n export type Type = 'text' | 'password' | 'search' | 'number' | 'email' | 'url';\n export type InputMode = 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';\n export type Step = number | 'any';\n\n export type ChangeDetail = BaseChangeDetail;\n export type KeyDetail = BaseKeyDetail;\n\n export interface Ref {\n /**\n * Sets input focus onto the UI control.\n */\n focus(): void;\n\n /**\n * Selects all text in the input control.\n */\n select(): void;\n }\n\n export interface Style {\n root?: {\n backgroundColor?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n borderColor?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n borderRadius?: string;\n borderWidth?: string;\n boxShadow?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n color?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n fontSize?: string;\n fontWeight?: string;\n paddingBlock?: string;\n paddingInline?: string;\n };\n placeholder?: {\n color?: string;\n fontSize?: string;\n fontStyle?: string;\n fontWeight?: string;\n };\n }\n}\n\nexport interface BaseChangeDetail {\n value: string;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/input/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ReactNode } from 'react';\n\nimport { BaseComponentProps } from '../types/base-component';\nimport { BaseKeyDetail, CancelableEventHandler, NonCancelableEventHandler } from '../types/events';\nimport { FormFieldValidationControlProps } from '../types/form-field';\n/**\n * @awsuiSystem core\n */\nimport { NativeAttributes } from '../types/native-attributes';\n\nexport interface BaseInputProps {\n /**\n * Specifies the text entered into the form element.\n */\n value: string;\n\n /**\n * Specifies the name of the control used in HTML forms.\n */\n name?: string;\n\n /**\n * Specifies the placeholder text rendered when the value is an empty string.\n */\n placeholder?: string;\n\n /**\n * Specifies if the control is disabled, which prevents the\n * user from modifying the value and prevents the value from\n * being included in a form submission. A disabled control can't\n * receive focus.\n */\n disabled?: boolean;\n\n /**\n * Specifies if the control is read-only, which prevents the\n * user from modifying the value but includes it in a form\n * submission. A read-only control can receive focus.\n *\n * Don't use read-only inputs outside a form.\n */\n readOnly?: boolean;\n\n /**\n * Indicates whether the control should be focused as\n * soon as the page loads, which enables the user to\n * start typing without having to manually focus the control. Don't\n * use this option on pages where the control may be\n * scrolled out of the viewport.\n */\n autoFocus?: boolean;\n\n /**\n * Adds an `aria-label` to the native control.\n *\n * Use this if you don't have a visible label for this control.\n */\n ariaLabel?: string;\n\n /**\n * Specifies whether to add `aria-required` to the native control.\n */\n ariaRequired?: boolean;\n\n /**\n * Called when input focus is removed from the UI control.\n */\n onBlur?: NonCancelableEventHandler<null>;\n\n /**\n * Called when input focus is moved to the UI control.\n */\n onFocus?: NonCancelableEventHandler<null>;\n\n /**\n * Called whenever a user changes the input value (by typing or pasting).\n * The event `detail` contains the current value of the field.\n */\n onChange?: NonCancelableEventHandler<InputProps.ChangeDetail>;\n\n /**\n * Attributes to add to the native `input` element.\n * Some attributes will be automatically combined with internal attribute values:\n * - `className` will be appended.\n * - Event handlers will be chained, unless the default is prevented.\n *\n * We do not support using this attribute to apply custom styling.\n *\n * @awsuiSystem core\n */\n nativeInputAttributes?: NativeAttributes<React.InputHTMLAttributes<HTMLInputElement>>;\n}\n\nexport interface InputAutoCorrect {\n /**\n * Specifies whether to disable browser autocorrect and related features.\n * If you set this to `true`, it disables any native browser capabilities\n * that automatically correct user input, such as `autocorrect` and\n * `autocapitalize`. If you don't set it, the behavior follows the default behavior\n * of the user's browser.\n */\n disableBrowserAutocorrect?: boolean;\n}\n\nexport interface InputAutoComplete {\n /**\n * Specifies whether to enable a browser's autocomplete functionality for this input.\n * In some cases it might be appropriate to disable autocomplete (for example, for security-sensitive fields).\n * To use it correctly, set the `name` property.\n *\n * You can either provide a boolean value to set the property to \"on\" or \"off\", or specify a string value\n * for the [autocomplete](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) attribute.\n */\n autoComplete?: boolean | string;\n}\n\nexport interface InputSpellcheck {\n /**\n * Specifies the value of the `spellcheck` attribute on the native control.\n * This value controls the native browser capability to check for spelling/grammar errors.\n * If not set, the browser default behavior is to perform spellchecking.\n * For more details, check the [spellcheck MDN article](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck).\n *\n * Enhanced spellchecking features of your browser and/or operating system may send input values to external parties.\n * Make sure it’s deactivated for fields with sensitive information to prevent\n * inadvertently sending data (such as user passwords) to third parties.\n */\n spellcheck?: boolean;\n}\n\nexport interface InputKeyEvents {\n /**\n * Called when the underlying native textarea emits a `keydown` event.\n * The event `detail` contains the `keyCode` and information\n * about modifiers (that is, CTRL, ALT, SHIFT, META, etc.).\n */\n onKeyDown?: CancelableEventHandler<InputProps.KeyDetail>;\n\n /**\n * Called when the underlying native textarea emits a `keyup` event.\n * The event `detail` contains the `keyCode` and information\n * about modifiers (that is, CTRL, ALT, SHIFT, META, etc.).\n */\n onKeyUp?: CancelableEventHandler<InputProps.KeyDetail>;\n}\n\nexport interface InputClearLabel {\n /**\n * Adds an `aria-label` to the clear button inside the search input.\n * @i18n\n */\n clearAriaLabel?: string;\n}\n\nexport interface InputProps\n extends BaseComponentProps,\n BaseInputProps,\n InputKeyEvents,\n InputAutoCorrect,\n InputAutoComplete,\n InputSpellcheck,\n InputClearLabel,\n FormFieldValidationControlProps {\n /**\n * Specifies the type of control to render.\n * Inputs with a `number` type use the native element behavior, which might\n * be slightly different across browsers.\n */\n type?: InputProps.Type;\n\n /**\n * Adds a hint to the browser about the type of data a user may enter into this field.\n * Some devices may render a different virtual keyboard depending on this value.\n * This value may not be supported by all browsers or devices.\n */\n inputMode?: InputProps.InputMode;\n\n /**\n * The step attribute is a number that specifies the granularity that the value\n * must adhere to or the keyword \"any\". It is valid for the numeric input types,\n * including the date, month, week, time, datetime-local, number and range types.\n */\n step?: InputProps.Step;\n\n /**\n * An object containing CSS properties to customize the input's visual appearance.\n * Refer to the [style](/components/input/?tabId=style) tab for more details.\n * @awsuiSystem core\n */\n style?: InputProps.Style;\n\n /**\n * Use for content rendered before the editable value.\n */\n prefix?: ReactNode;\n\n /**\n * Use for content rendered after the editable value.\n */\n suffix?: ReactNode;\n}\n\nexport namespace InputProps {\n export type Type = 'text' | 'password' | 'search' | 'number' | 'email' | 'url';\n export type InputMode = 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';\n export type Step = number | 'any';\n\n export type ChangeDetail = BaseChangeDetail;\n export type KeyDetail = BaseKeyDetail;\n\n export interface Ref {\n /**\n * Sets input focus onto the UI control.\n */\n focus(): void;\n\n /**\n * Selects all text in the input control.\n */\n select(): void;\n }\n\n export interface Style {\n root?: {\n backgroundColor?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n borderColor?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n borderRadius?: string;\n borderWidth?: string;\n boxShadow?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n color?: {\n default?: string;\n disabled?: string;\n focus?: string;\n hover?: string;\n readonly?: string;\n };\n fontSize?: string;\n fontWeight?: string;\n paddingBlock?: string;\n paddingInline?: string;\n };\n placeholder?: {\n color?: string;\n fontSize?: string;\n fontStyle?: string;\n fontWeight?: string;\n };\n }\n}\n\nexport interface BaseChangeDetail {\n value: string;\n}\n"]}
@@ -8,11 +8,11 @@ import { FormFieldValidationControlProps } from '../types/form-field';
8
8
  import { BaseChangeDetail, BaseInputProps, InputAutoCorrect, InputProps } from './interfaces';
9
9
  export interface InternalInputProps extends BaseComponentProps, BaseInputProps, Omit<InputProps, 'type'>, InputAutoCorrect, FormFieldValidationControlProps, InternalBaseComponentProps {
10
10
  type?: InputProps['type'] | 'visualSearch';
11
- __leftIcon?: IconProps['name'];
12
- __leftIconVariant?: IconProps['variant'];
13
- __onLeftIconClick?: () => void;
14
- __rightIcon?: IconProps['name'];
15
- __onRightIconClick?: () => void;
11
+ __startIcon?: IconProps['name'];
12
+ __startIconVariant?: IconProps['variant'];
13
+ __onStartIconClick?: () => void;
14
+ __endIcon?: IconProps['name'];
15
+ __onEndIconClick?: () => void;
16
16
  __noBorderRadius?: boolean;
17
17
  __onDelayedInput?: NonCancelableEventHandler<BaseChangeDetail>;
18
18
  __onBlurWithDetail?: NonCancelableEventHandler<{
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/input/internal.tsx"],"names":[],"m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CAAC;QAAE,aAAa,EAAE,IAAI,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IAE/E,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C,8BAA8B,CAAC,EAAE,YAAY,CAAC;IAC9C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;;AAyRD,wBAA+C"}
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import React, { useRef } from 'react';
4
4
  import clsx from 'clsx';
5
- import { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';
5
+ import { useMergeRefs, warnOnce } from '@cloudscape-design/component-toolkit/internal';
6
6
  import { copyAnalyticsMetadataAttribute, getAnalyticsMetadataAttribute, } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
7
7
  import InternalButton from '../button/internal';
8
8
  import { useInternalI18n } from '../i18n/context';
@@ -11,11 +11,12 @@ import { getBaseProps } from '../internal/base-component';
11
11
  import { useFormFieldContext } from '../internal/context/form-field-context';
12
12
  import { fireKeyboardEvent, fireNonCancelableEvent } from '../internal/events';
13
13
  import { useDebounceCallback } from '../internal/hooks/use-debounce-callback';
14
+ import { isDevelopment } from '../internal/is-development';
14
15
  import WithNativeAttributes from '../internal/utils/with-native-attributes';
15
16
  import { getInputStyles } from './styles';
16
17
  import { convertAutoComplete, useSearchProps } from './utils';
17
18
  import styles from './styles.css.js';
18
- function InternalInput({ type = 'text', step, inputMode, autoComplete = true, ariaLabel, clearAriaLabel: clearAriaLabelOverride, name, value, placeholder, autoFocus, disabled, readOnly, disableBrowserAutocorrect, spellcheck, __noBorderRadius, __leftIcon, __leftIconVariant = 'subtle', __onLeftIconClick, ariaRequired, __rightIcon, __onRightIconClick, onKeyDown, onKeyUp, onChange, __onDelayedInput, __onBlurWithDetail, onBlur, onFocus, nativeInputAttributes, __internalRootRef, __inheritFormFieldProps, __injectAnalyticsComponentMetadata, __skipNativeAttributesWarnings, __inlineLabelText, __fullWidth, style, ...rest }, ref) {
19
+ function InternalInput({ type = 'text', step, inputMode, autoComplete = true, ariaLabel, clearAriaLabel: clearAriaLabelOverride, name, value, placeholder, autoFocus, disabled, readOnly, disableBrowserAutocorrect, spellcheck, __noBorderRadius, __startIcon, __startIconVariant = 'subtle', __onStartIconClick, ariaRequired, __endIcon, __onEndIconClick, onKeyDown, onKeyUp, onChange, __onDelayedInput, __onBlurWithDetail, onBlur, onFocus, nativeInputAttributes, __internalRootRef, __inheritFormFieldProps, __injectAnalyticsComponentMetadata, __skipNativeAttributesWarnings, __inlineLabelText, __fullWidth, style, prefix, suffix, ...rest }, ref) {
19
20
  const baseProps = getBaseProps(rest);
20
21
  const i18n = useInternalI18n('input');
21
22
  const fireDelayedInput = useDebounceCallback((value) => fireNonCancelableEvent(__onDelayedInput, { value }));
@@ -25,13 +26,34 @@ function InternalInput({ type = 'text', step, inputMode, autoComplete = true, ar
25
26
  };
26
27
  const inputRef = useRef(null);
27
28
  const searchProps = useSearchProps(type, disabled, readOnly, value, inputRef, handleChange);
28
- __leftIcon = __leftIcon !== null && __leftIcon !== void 0 ? __leftIcon : searchProps.__leftIcon;
29
- __rightIcon = __rightIcon !== null && __rightIcon !== void 0 ? __rightIcon : searchProps.__rightIcon;
30
- __onRightIconClick = __onRightIconClick !== null && __onRightIconClick !== void 0 ? __onRightIconClick : searchProps.__onRightIconClick;
29
+ __startIcon = __startIcon !== null && __startIcon !== void 0 ? __startIcon : searchProps.__startIcon;
30
+ __endIcon = __endIcon !== null && __endIcon !== void 0 ? __endIcon : searchProps.__endIcon;
31
+ __onEndIconClick = __onEndIconClick !== null && __onEndIconClick !== void 0 ? __onEndIconClick : searchProps.__onEndIconClick;
32
+ // Search inputs use built-in search and clear icons that would overlap adornments.
33
+ const isSearch = type === 'search' || type === 'visualSearch';
34
+ if (isDevelopment) {
35
+ if (isSearch && (prefix !== undefined || suffix !== undefined)) {
36
+ warnOnce('Input', 'prefix and suffix are ignored when type is search.');
37
+ }
38
+ }
39
+ if (isSearch) {
40
+ prefix = undefined;
41
+ suffix = undefined;
42
+ }
31
43
  const formFieldContext = useFormFieldContext(rest);
32
44
  const { ariaLabelledby, ariaDescribedby, controlId, invalid, warning } = __inheritFormFieldProps
33
45
  ? formFieldContext
34
46
  : rest;
47
+ const hasPrefix = !!prefix;
48
+ const hasSuffix = !!suffix;
49
+ const hasPrefixOrSuffix = hasPrefix || hasSuffix;
50
+ const inputStyles = getInputStyles(style);
51
+ const nativeInputStyles = hasPrefixOrSuffix && inputStyles
52
+ ? { ...inputStyles, borderRadius: undefined, borderWidth: undefined }
53
+ : inputStyles;
54
+ const adornedContainerStyles = hasPrefixOrSuffix && inputStyles
55
+ ? { ...inputStyles, paddingBlock: undefined, paddingInline: undefined }
56
+ : undefined;
35
57
  const attributes = {
36
58
  'aria-label': ariaLabel,
37
59
  // aria-labelledby has precedence over aria-label in accessible name calculation.
@@ -43,10 +65,10 @@ function InternalInput({ type = 'text', step, inputMode, autoComplete = true, ar
43
65
  placeholder,
44
66
  autoFocus,
45
67
  id: controlId,
46
- className: clsx(styles.input, type && styles[`input-type-${type}`], __rightIcon && styles['input-has-icon-right'], __leftIcon && styles['input-has-icon-left'], __noBorderRadius && styles['input-has-no-border-radius'], {
68
+ className: clsx(styles.input, type && styles[`input-type-${type}`], __endIcon && styles['input-has-icon-end'], __startIcon && styles['input-has-icon-start'], __noBorderRadius && styles['input-has-no-border-radius'], hasPrefixOrSuffix && styles['input-adorned'], {
47
69
  [styles['input-readonly']]: readOnly,
48
- [styles['input-invalid']]: invalid,
49
- [styles['input-warning']]: warning && !invalid,
70
+ [styles['input-invalid']]: invalid && !hasPrefixOrSuffix,
71
+ [styles['input-warning']]: warning && !invalid && !hasPrefixOrSuffix,
50
72
  }),
51
73
  autoComplete: convertAutoComplete(autoComplete),
52
74
  disabled,
@@ -96,25 +118,39 @@ function InternalInput({ type = 'text', step, inputMode, autoComplete = true, ar
96
118
  value: value || '',
97
119
  },
98
120
  };
99
- const mainInput = (React.createElement(WithNativeAttributes, { ...attributes, tag: "input", componentName: "Input", nativeAttributes: nativeInputAttributes, skipWarnings: __skipNativeAttributesWarnings, ref: mergedRef, style: getInputStyles(style) }));
121
+ const mainInput = (React.createElement(WithNativeAttributes, { ...attributes, tag: "input", componentName: "Input", nativeAttributes: nativeInputAttributes, skipWarnings: __skipNativeAttributesWarnings, ref: mergedRef, style: nativeInputStyles }));
122
+ const inputWithLabel = __inlineLabelText ? (React.createElement("div", { className: clsx(styles['inline-label-wrapper'], __fullWidth && styles['inline-label-wrapper-full-width']) },
123
+ React.createElement("label", { htmlFor: controlId, className: styles['inline-label'] }, __inlineLabelText),
124
+ React.createElement("div", { className: clsx(styles['inline-label-trigger-wrapper'], __fullWidth && styles['inline-label-trigger-wrapper-full-width']) }, mainInput))) : (mainInput);
125
+ const endIcon = __endIcon ? (React.createElement("span", { className: styles['input-icon-end'], ...(__endIcon === 'close'
126
+ ? getAnalyticsMetadataAttribute({
127
+ action: 'clearInput',
128
+ })
129
+ : {}) },
130
+ React.createElement(InternalButton
131
+ // Used for test utils
132
+ , {
133
+ // Used for test utils
134
+ className: styles['input-button-right'], variant: "inline-icon-pointer-target", formAction: "none", iconName: __endIcon, onClick: __onEndIconClick, ariaLabel: i18n('clearAriaLabel', clearAriaLabelOverride), disabled: disabled }))) : null;
100
135
  return (React.createElement("div", { ...baseProps, className: clsx(baseProps.className, styles['input-container']), ref: __internalRootRef, dir: type === 'email' ? 'ltr' : undefined, ...(__injectAnalyticsComponentMetadata
101
136
  ? getAnalyticsMetadataAttribute({ component: componentAnalyticsMetadata })
102
137
  : copyAnalyticsMetadataAttribute(rest)) },
103
- __leftIcon && (React.createElement("span", { onClick: __onLeftIconClick, className: styles['input-icon-left'] },
104
- React.createElement(InternalIcon, { name: __leftIcon, variant: disabled || readOnly ? 'disabled' : __leftIconVariant }))),
105
- __inlineLabelText ? (React.createElement("div", { className: clsx(styles['inline-label-wrapper'], __fullWidth && styles['inline-label-wrapper-full-width']) },
106
- React.createElement("label", { htmlFor: controlId, className: styles['inline-label'] }, __inlineLabelText),
107
- React.createElement("div", { className: clsx(styles['inline-label-trigger-wrapper'], __fullWidth && styles['inline-label-trigger-wrapper-full-width']) }, mainInput))) : (mainInput),
108
- __rightIcon && (React.createElement("span", { className: styles['input-icon-right'], ...(__rightIcon === 'close'
109
- ? getAnalyticsMetadataAttribute({
110
- action: 'clearInput',
111
- })
112
- : {}) },
113
- React.createElement(InternalButton
114
- // Used for test utils
115
- , {
116
- // Used for test utils
117
- className: styles['input-button-right'], variant: "inline-icon-pointer-target", formAction: "none", iconName: __rightIcon, onClick: __onRightIconClick, ariaLabel: i18n('clearAriaLabel', clearAriaLabelOverride), disabled: disabled })))));
138
+ __startIcon && (React.createElement("span", { onClick: __onStartIconClick, className: styles['input-icon-start'] },
139
+ React.createElement(InternalIcon, { name: __startIcon, variant: disabled || readOnly ? 'disabled' : __startIconVariant }))),
140
+ hasPrefixOrSuffix ? (
141
+ // [prefix][divider][input][divider][suffix] - one flex bar owns the border and focus ring.
142
+ React.createElement("div", { className: clsx(styles['input-adorned-container'], invalid && styles['input-adorned-container-invalid'], warning && !invalid && styles['input-adorned-container-warning'], disabled && styles['input-adorned-container-disabled'], readOnly && !disabled && styles['input-adorned-container-readonly']), "aria-disabled": disabled || undefined, style: adornedContainerStyles },
143
+ hasPrefix && (React.createElement(React.Fragment, null,
144
+ React.createElement("span", { className: styles['input-prefix'], "aria-hidden": "true" },
145
+ React.createElement("span", { className: styles['input-adornment-content'] }, prefix)),
146
+ React.createElement("span", { className: styles['input-adornment-divider'] }))),
147
+ inputWithLabel,
148
+ hasSuffix && (React.createElement(React.Fragment, null,
149
+ React.createElement("span", { className: styles['input-adornment-divider'] }),
150
+ React.createElement("span", { className: styles['input-suffix'], "aria-hidden": "true" },
151
+ React.createElement("span", { className: styles['input-adornment-content'] }, suffix)))),
152
+ endIcon)) : (inputWithLabel),
153
+ !hasPrefixOrSuffix && endIcon));
118
154
  }
119
155
  export default React.forwardRef(InternalInput);
120
156
  //# sourceMappingURL=internal.js.map