@cloudscape-design/components 3.0.1085 → 3.0.1086

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 (69) hide show
  1. package/autosuggest/index.js +11 -29
  2. package/autosuggest/internal-do-not-use-core.js +36 -0
  3. package/calendar/grid/index.js +1 -1
  4. package/calendar/grid/index.js.map +1 -1
  5. package/date-input/index.js +10 -8
  6. package/date-input/internal-do-not-use-core.js +16 -0
  7. package/input/index.d.ts.map +1 -1
  8. package/input/index.js +12 -51
  9. package/input/interfaces.d.ts +15 -0
  10. package/input/interfaces.d.ts.map +1 -1
  11. package/input/interfaces.js.map +1 -1
  12. package/input/internal-do-not-use-core.js +58 -0
  13. package/input/internal-do-not-use-core.js.map +1 -0
  14. package/input/internal.d.ts +2 -1
  15. package/input/internal.d.ts.map +1 -1
  16. package/input/internal.js +24 -9
  17. package/input/internal.js.map +1 -1
  18. package/internal/base-component/styles.scoped.css +1 -1
  19. package/internal/components/autosuggest-input/index.d.ts.map +1 -1
  20. package/internal/components/autosuggest-input/index.js +3 -2
  21. package/internal/components/autosuggest-input/index.js.map +1 -1
  22. package/internal/components/masked-input/index.d.ts.map +1 -1
  23. package/internal/components/masked-input/index.js +4 -3
  24. package/internal/components/masked-input/index.js.map +1 -1
  25. package/internal/environment.js +2 -2
  26. package/internal/environment.json +2 -2
  27. package/internal/hooks/use-effect-on-update/index.d.ts.map +1 -0
  28. package/internal/hooks/use-effect-on-update/index.js +37 -0
  29. package/internal/hooks/use-effect-on-update/index.js.map +1 -0
  30. package/internal/manifest.json +1 -1
  31. package/internal/utils/with-native-attributes.d.ts +3 -1
  32. package/internal/utils/with-native-attributes.d.ts.map +1 -1
  33. package/internal/utils/with-native-attributes.js +10 -7
  34. package/internal/utils/with-native-attributes.js.map +1 -1
  35. package/package.json +1 -1
  36. package/prompt-input/index.js +1 -1
  37. package/prompt-input/interfaces.d.ts +15 -1
  38. package/prompt-input/interfaces.d.ts.map +1 -1
  39. package/prompt-input/interfaces.js.map +1 -1
  40. package/prompt-input/internal.d.ts.map +1 -1
  41. package/prompt-input/internal.js +3 -2
  42. package/prompt-input/internal.js.map +1 -1
  43. package/select/parts/filter.d.ts +1 -1
  44. package/select/parts/filter.d.ts.map +1 -1
  45. package/select/parts/filter.js +1 -1
  46. package/select/parts/filter.js.map +1 -1
  47. package/select/utils/use-select.js +1 -1
  48. package/select/utils/use-select.js.map +1 -1
  49. package/textarea/index.d.ts.map +1 -1
  50. package/textarea/index.js +12 -65
  51. package/textarea/interfaces.d.ts +16 -1
  52. package/textarea/interfaces.d.ts.map +1 -1
  53. package/textarea/interfaces.js.map +1 -1
  54. package/textarea/internal-do-not-use-core.js +72 -0
  55. package/textarea/internal-do-not-use-core.js.map +1 -0
  56. package/time-input/index.js +11 -17
  57. package/time-input/internal-do-not-use-core.js +24 -0
  58. package/wizard/wizard-form.d.ts.map +1 -1
  59. package/wizard/wizard-form.js +1 -3
  60. package/wizard/wizard-form.js.map +1 -1
  61. package/input/index.js.map +0 -1
  62. package/internal/hooks/use-effect-on-update.d.ts.map +0 -1
  63. package/internal/hooks/use-effect-on-update.js +0 -18
  64. package/internal/hooks/use-effect-on-update.js.map +0 -1
  65. package/textarea/index.js.map +0 -1
  66. /package/autosuggest/{index.js.map → internal-do-not-use-core.js.map} +0 -0
  67. /package/date-input/{index.js.map → internal-do-not-use-core.js.map} +0 -0
  68. /package/internal/hooks/{use-effect-on-update.d.ts → use-effect-on-update/index.d.ts} +0 -0
  69. /package/time-input/{index.js.map → internal-do-not-use-core.js.map} +0 -0
@@ -2038,5 +2038,5 @@
2038
2038
  }
2039
2039
  }
2040
2040
  :root {
2041
- --awsui-version-info-746aab5c: true;
2041
+ --awsui-version-info-fdbe2311: true;
2042
2042
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/autosuggest-input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAgE,MAAM,OAAO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3B;AAED,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB,CAAC,GAAG;IAC/D,KAAK,CAAC,OAAO,CAAC,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACpD,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;CACf;AAED,QAAA,MAAM,gBAAgB,mGAmPrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/autosuggest-input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAgE,MAAM,OAAO,CAAC;AAGrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,kBAAkB,EAAgB,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,+BAA+B,EAAuB,MAAM,kCAAkC,CAAC;AACxG,OAAO,EAA8D,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACrH,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAK5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI1D,UAAU,qBACR,SAAQ,kBAAkB,EACxB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,+BAA+B,EAC/B,gBAAgB,EAChB,0BAA0B;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAClD,cAAc,CAAC,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;IAC7D,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC;CAC9B;AAED,UAAU,4BAA4B;IACpC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB,CAAC,GAAG;IAC/D,KAAK,CAAC,OAAO,CAAC,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACpD,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;CACf;AAED,QAAA,MAAM,gBAAgB,mGAqPrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -9,10 +9,11 @@ import { useFormFieldContext } from '../../context/form-field-context';
9
9
  import { fireCancelableEvent, fireNonCancelableEvent } from '../../events';
10
10
  import { KeyCode } from '../../keycode';
11
11
  import { nodeBelongs } from '../../utils/node-belongs';
12
+ import { processAttributes } from '../../utils/with-native-attributes';
12
13
  import Dropdown from '../dropdown';
13
14
  import styles from './styles.css.js';
14
15
  const AutosuggestInput = React.forwardRef((_a, ref) => {
15
- var { value, onChange, onBlur, onFocus, onKeyUp, onKeyDown, name, placeholder, disabled, readOnly, autoFocus, ariaLabel, ariaRequired, disableBrowserAutocorrect = false, expandToViewport, ariaControls, ariaActivedescendant, clearAriaLabel, dropdownExpanded = true, dropdownContentKey, dropdownContentFocusable = false, dropdownContent = null, dropdownFooter = null, dropdownWidth, loopFocus, onCloseDropdown, onDelayedInput, onPressArrowDown, onPressArrowUp, onPressEnter, __internalRootRef } = _a, restProps = __rest(_a, ["value", "onChange", "onBlur", "onFocus", "onKeyUp", "onKeyDown", "name", "placeholder", "disabled", "readOnly", "autoFocus", "ariaLabel", "ariaRequired", "disableBrowserAutocorrect", "expandToViewport", "ariaControls", "ariaActivedescendant", "clearAriaLabel", "dropdownExpanded", "dropdownContentKey", "dropdownContentFocusable", "dropdownContent", "dropdownFooter", "dropdownWidth", "loopFocus", "onCloseDropdown", "onDelayedInput", "onPressArrowDown", "onPressArrowUp", "onPressEnter", "__internalRootRef"]);
16
+ var { value, onChange, onBlur, onFocus, onKeyUp, onKeyDown, name, placeholder, disabled, readOnly, autoFocus, ariaLabel, ariaRequired, disableBrowserAutocorrect = false, expandToViewport, ariaControls, ariaActivedescendant, clearAriaLabel, dropdownExpanded = true, dropdownContentKey, dropdownContentFocusable = false, dropdownContent = null, dropdownFooter = null, dropdownWidth, loopFocus, nativeInputAttributes, onCloseDropdown, onDelayedInput, onPressArrowDown, onPressArrowUp, onPressEnter, __internalRootRef } = _a, restProps = __rest(_a, ["value", "onChange", "onBlur", "onFocus", "onKeyUp", "onKeyDown", "name", "placeholder", "disabled", "readOnly", "autoFocus", "ariaLabel", "ariaRequired", "disableBrowserAutocorrect", "expandToViewport", "ariaControls", "ariaActivedescendant", "clearAriaLabel", "dropdownExpanded", "dropdownContentKey", "dropdownContentFocusable", "dropdownContent", "dropdownFooter", "dropdownWidth", "loopFocus", "nativeInputAttributes", "onCloseDropdown", "onDelayedInput", "onPressArrowDown", "onPressArrowUp", "onPressEnter", "__internalRootRef"]);
16
17
  const baseProps = getBaseProps(restProps);
17
18
  const formFieldContext = useFormFieldContext(restProps);
18
19
  const inputRef = useRef(null);
@@ -152,7 +153,7 @@ const AutosuggestInput = React.forwardRef((_a, ref) => {
152
153
  // eslint-disable-next-line react-hooks/exhaustive-deps
153
154
  }, [open]);
154
155
  return (React.createElement("div", Object.assign({}, baseProps, { className: clsx(baseProps.className, styles.root), ref: __internalRootRef }),
155
- React.createElement(Dropdown, { minWidth: dropdownWidth, stretchWidth: !dropdownWidth, stretchBeyondTriggerWidth: true, contentKey: dropdownContentKey, onFocus: handleFocus, onBlur: handleBlur, trigger: React.createElement(InternalInput, Object.assign({ type: "visualSearch", value: value, onChange: event => handleChange(event.detail.value), __onDelayedInput: event => handleDelayedInput(event.detail.value), onKeyDown: handleKeyDown, onKeyUp: onKeyUp, disabled: disabled, disableBrowserAutocorrect: disableBrowserAutocorrect, readOnly: readOnly, ariaRequired: ariaRequired, clearAriaLabel: clearAriaLabel, ref: inputRef, autoComplete: false, __nativeAttributes: nativeAttributes }, formFieldContext)), onMouseDown: handleDropdownMouseDown, open: open && (!!dropdownContent || !!dropdownFooter), footer: dropdownFooterRef && (React.createElement("div", { ref: dropdownFooterRef, className: styles['dropdown-footer'] }, open && dropdownFooter ? dropdownFooter : null)), expandToViewport: expandToViewport, loopFocus: loopFocus }, open && dropdownContent ? (React.createElement("div", { ref: dropdownContentRef, className: styles['dropdown-content'] }, dropdownContent)) : null)));
156
+ React.createElement(Dropdown, { minWidth: dropdownWidth, stretchWidth: !dropdownWidth, stretchBeyondTriggerWidth: true, contentKey: dropdownContentKey, onFocus: handleFocus, onBlur: handleBlur, trigger: React.createElement(InternalInput, Object.assign({ type: "visualSearch", value: value, onChange: event => handleChange(event.detail.value), __onDelayedInput: event => handleDelayedInput(event.detail.value), onKeyDown: handleKeyDown, onKeyUp: onKeyUp, disabled: disabled, disableBrowserAutocorrect: disableBrowserAutocorrect, readOnly: readOnly, ariaRequired: ariaRequired, clearAriaLabel: clearAriaLabel, ref: inputRef, autoComplete: false, nativeInputAttributes: processAttributes(nativeAttributes, nativeInputAttributes, 'Autosuggest'), __skipNativeAttributesWarnings: Object.keys(nativeAttributes) }, formFieldContext)), onMouseDown: handleDropdownMouseDown, open: open && (!!dropdownContent || !!dropdownFooter), footer: dropdownFooterRef && (React.createElement("div", { ref: dropdownFooterRef, className: styles['dropdown-footer'] }, open && dropdownFooter ? dropdownFooter : null)), expandToViewport: expandToViewport, loopFocus: loopFocus }, open && dropdownContent ? (React.createElement("div", { ref: dropdownContentRef, className: styles['dropdown-content'] }, dropdownContent)) : null)));
156
157
  });
157
158
  export default AutosuggestInput;
158
159
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/autosuggest-input/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAO,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrF,OAAO,IAAI,MAAM,MAAM,CAAC;AAUxB,OAAO,aAAqC,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAsB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAmC,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACxG,OAAO,EAAiB,mBAAmB,EAAE,sBAAsB,EAA6B,MAAM,cAAc,CAAC;AAErH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,QAAQ,MAAM,aAAa,CAAC;AAGnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAqCrC,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CACvC,CACE,EAiCwB,EACxB,GAA6B,EAC7B,EAAE;QAnCF,EACE,KAAK,EACL,QAAQ,EACR,MAAM,EACN,OAAO,EACP,OAAO,EACP,SAAS,EACT,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,YAAY,EACZ,yBAAyB,GAAG,KAAK,EACjC,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACpB,cAAc,EACd,gBAAgB,GAAG,IAAI,EACvB,kBAAkB,EAClB,wBAAwB,GAAG,KAAK,EAChC,eAAe,GAAG,IAAI,EACtB,cAAc,GAAG,IAAI,EACrB,aAAa,EACb,SAAS,EACT,eAAe,EACf,cAAc,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// SPDX-License-Identifier: Apache-2.0\n\nimport React, { Ref, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { AutosuggestProps } from '../../../autosuggest/interfaces';\nimport {\n BaseChangeDetail,\n BaseInputProps,\n InputAutoCorrect,\n InputClearLabel,\n InputKeyEvents,\n} from '../../../input/interfaces';\nimport InternalInput, { InternalInputProps } from '../../../input/internal';\nimport { BaseComponentProps, getBaseProps } from '../../base-component';\nimport { FormFieldValidationControlProps, useFormFieldContext } from '../../context/form-field-context';\nimport { BaseKeyDetail, fireCancelableEvent, fireNonCancelableEvent, NonCancelableEventHandler } from '../../events';\nimport { InternalBaseComponentProps } from '../../hooks/use-base-component';\nimport { KeyCode } from '../../keycode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport Dropdown from '../dropdown';\nimport { ExpandToViewport } from '../dropdown/interfaces';\n\nimport styles from './styles.css.js';\n\ninterface AutosuggestInputProps\n extends BaseComponentProps,\n BaseInputProps,\n InputAutoCorrect,\n InputKeyEvents,\n InputClearLabel,\n FormFieldValidationControlProps,\n ExpandToViewport,\n InternalBaseComponentProps {\n ariaControls?: string;\n ariaActivedescendant?: string;\n dropdownExpanded?: boolean;\n dropdownContentKey?: string;\n dropdownContentFocusable?: boolean;\n dropdownContent?: React.ReactNode;\n dropdownFooter?: React.ReactNode;\n dropdownWidth?: number;\n loopFocus?: boolean;\n onCloseDropdown?: NonCancelableEventHandler<null>;\n onDelayedInput?: NonCancelableEventHandler<BaseChangeDetail>;\n onPressArrowDown?: () => void;\n onPressArrowUp?: () => void;\n onPressEnter?: () => boolean;\n}\n\ninterface AutosuggestInputFocusOptions {\n preventDropdown?: boolean;\n}\n\nexport interface AutosuggestInputRef extends AutosuggestProps.Ref {\n focus(options?: AutosuggestInputFocusOptions): void;\n open(): void;\n close(): void;\n}\n\nconst AutosuggestInput = React.forwardRef(\n (\n {\n value,\n onChange,\n onBlur,\n onFocus,\n onKeyUp,\n onKeyDown,\n name,\n placeholder,\n disabled,\n readOnly,\n autoFocus,\n ariaLabel,\n ariaRequired,\n disableBrowserAutocorrect = false,\n expandToViewport,\n ariaControls,\n ariaActivedescendant,\n clearAriaLabel,\n dropdownExpanded = true,\n dropdownContentKey,\n dropdownContentFocusable = false,\n dropdownContent = null,\n dropdownFooter = null,\n dropdownWidth,\n loopFocus,\n onCloseDropdown,\n onDelayedInput,\n onPressArrowDown,\n onPressArrowUp,\n onPressEnter,\n __internalRootRef,\n ...restProps\n }: AutosuggestInputProps,\n ref: Ref<AutosuggestInputRef>\n ) => {\n const baseProps = getBaseProps(restProps);\n const formFieldContext = useFormFieldContext(restProps);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const dropdownContentRef = useRef<HTMLDivElement>(null);\n const dropdownFooterRef = useRef<HTMLDivElement>(null);\n const preventOpenOnFocusRef = useRef(false);\n const preventCloseOnBlurRef = useRef(false);\n\n const [open, setOpen] = useState(false);\n\n const openDropdown = () => !readOnly && setOpen(true);\n\n const closeDropdown = () => {\n setOpen(false);\n fireNonCancelableEvent(onCloseDropdown, null);\n };\n\n useImperativeHandle(ref, () => ({\n focus(options?: AutosuggestInputFocusOptions) {\n if (options?.preventDropdown) {\n preventOpenOnFocusRef.current = true;\n }\n inputRef.current?.focus();\n },\n select() {\n inputRef.current?.select();\n },\n open: openDropdown,\n close: closeDropdown,\n }));\n\n const handleBlur = () => {\n if (!preventCloseOnBlurRef.current) {\n closeDropdown();\n fireNonCancelableEvent(onBlur, null);\n }\n };\n\n const handleFocus = () => {\n if (!preventOpenOnFocusRef.current) {\n openDropdown();\n fireNonCancelableEvent(onFocus, null);\n }\n preventOpenOnFocusRef.current = false;\n };\n\n const fireKeydown = (event: CustomEvent<BaseKeyDetail>) => fireCancelableEvent(onKeyDown, event.detail, event);\n\n const handleKeyDown = (event: CustomEvent<BaseKeyDetail>) => {\n switch (event.detail.keyCode) {\n case KeyCode.down: {\n onPressArrowDown?.();\n openDropdown();\n event.preventDefault();\n break;\n }\n case KeyCode.up: {\n onPressArrowUp?.();\n openDropdown();\n event.preventDefault();\n break;\n }\n case KeyCode.enter: {\n if (open) {\n if (!onPressEnter?.()) {\n closeDropdown();\n }\n event.preventDefault();\n }\n fireKeydown(event);\n break;\n }\n case KeyCode.escape: {\n if (open) {\n event.stopPropagation();\n closeDropdown();\n } else if (value) {\n event.stopPropagation();\n fireNonCancelableEvent(onChange, { value: '' });\n }\n event.preventDefault();\n fireKeydown(event);\n break;\n }\n default: {\n fireKeydown(event);\n }\n }\n };\n\n const handleChange = (value: string) => {\n openDropdown();\n fireNonCancelableEvent(onChange, { value });\n };\n\n const handleDelayedInput = (value: string) => {\n fireNonCancelableEvent(onDelayedInput, { value });\n };\n\n const handleDropdownMouseDown: React.MouseEventHandler = event => {\n // Prevent currently focused element from losing focus.\n if (!dropdownContentFocusable) {\n event.preventDefault();\n }\n // Prevent closing dropdown on click inside.\n else {\n preventCloseOnBlurRef.current = true;\n requestAnimationFrame(() => {\n preventCloseOnBlurRef.current = false;\n });\n }\n };\n\n const expanded = open && dropdownExpanded;\n const nativeAttributes: InternalInputProps['__nativeAttributes'] = {\n name,\n placeholder,\n autoFocus,\n onClick: openDropdown,\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': expanded,\n 'aria-controls': open ? ariaControls : undefined,\n // 'aria-owns' needed for safari+vo to announce activedescendant content\n 'aria-owns': open ? ariaControls : undefined,\n 'aria-label': ariaLabel,\n 'aria-activedescendant': ariaActivedescendant,\n };\n\n // Closes dropdown when outside click is detected.\n // Similar to the internal dropdown implementation but includes the target as well.\n useEffect(() => {\n if (!open) {\n return;\n }\n\n const clickListener = (event: MouseEvent) => {\n if (\n !nodeBelongs(inputRef.current, event.target) &&\n !nodeBelongs(dropdownContentRef.current, event.target) &&\n !nodeBelongs(dropdownFooterRef.current, event.target)\n ) {\n closeDropdown();\n }\n };\n\n window.addEventListener('mousedown', clickListener);\n\n return () => {\n window.removeEventListener('mousedown', clickListener);\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={__internalRootRef}>\n <Dropdown\n minWidth={dropdownWidth}\n stretchWidth={!dropdownWidth}\n stretchBeyondTriggerWidth={true}\n contentKey={dropdownContentKey}\n onFocus={handleFocus}\n onBlur={handleBlur}\n trigger={\n <InternalInput\n type=\"visualSearch\"\n value={value}\n onChange={event => handleChange(event.detail.value)}\n __onDelayedInput={event => handleDelayedInput(event.detail.value)}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n disabled={disabled}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n readOnly={readOnly}\n ariaRequired={ariaRequired}\n clearAriaLabel={clearAriaLabel}\n ref={inputRef}\n autoComplete={false}\n __nativeAttributes={nativeAttributes}\n {...formFieldContext}\n />\n }\n onMouseDown={handleDropdownMouseDown}\n open={open && (!!dropdownContent || !!dropdownFooter)}\n footer={\n dropdownFooterRef && (\n <div ref={dropdownFooterRef} className={styles['dropdown-footer']}>\n {open && dropdownFooter ? dropdownFooter : null}\n </div>\n )\n }\n expandToViewport={expandToViewport}\n loopFocus={loopFocus}\n >\n {open && dropdownContent ? (\n <div ref={dropdownContentRef} className={styles['dropdown-content']}>\n {dropdownContent}\n </div>\n ) : null}\n </Dropdown>\n </div>\n );\n }\n);\n\nexport default AutosuggestInput;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/autosuggest-input/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAO,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrF,OAAO,IAAI,MAAM,MAAM,CAAC;AAUxB,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAsB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAmC,mBAAmB,EAAE,M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,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,GAAG,EAAE,QAAQ,EACb,YAAY,EAAE,KAAK,EACnB,qBAAqB,EAAE,iBAAiB,CAAC,gBAAgB,EAAE,qBAAqB,EAAE,aAAa,CAAC,EAChG,8BAA8B,EAAE,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,IACzD,gBAAgB,EACpB,EAEJ,WAAW,EAAE,uBAAuB,EACpC,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,eAAe,IAAI,CAAC,CAAC,cAAc,CAAC,EACrD,MAAM,EACJ,iBAAiB,IAAI,CACnB,6BAAK,GAAG,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,IAC9D,IAAI,IAAI,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAC3C,CACP,EAEH,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,IAEnB,IAAI,IAAI,eAAe,CAAC,CAAC,CAAC,CACzB,6BAAK,GAAG,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,CAAC,kBAAkB,CAAC,IAChE,eAAe,CACZ,CACP,CAAC,CAAC,CAAC,IAAI,CACC,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { Ref, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { AutosuggestProps } from '../../../autosuggest/interfaces';\nimport {\n BaseChangeDetail,\n BaseInputProps,\n InputAutoCorrect,\n InputClearLabel,\n InputKeyEvents,\n} from '../../../input/interfaces';\nimport InternalInput from '../../../input/internal';\nimport { BaseComponentProps, getBaseProps } from '../../base-component';\nimport { FormFieldValidationControlProps, useFormFieldContext } from '../../context/form-field-context';\nimport { BaseKeyDetail, fireCancelableEvent, fireNonCancelableEvent, NonCancelableEventHandler } from '../../events';\nimport { InternalBaseComponentProps } from '../../hooks/use-base-component';\nimport { KeyCode } from '../../keycode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport { processAttributes } from '../../utils/with-native-attributes';\nimport Dropdown from '../dropdown';\nimport { ExpandToViewport } from '../dropdown/interfaces';\n\nimport styles from './styles.css.js';\n\ninterface AutosuggestInputProps\n extends BaseComponentProps,\n BaseInputProps,\n InputAutoCorrect,\n InputKeyEvents,\n InputClearLabel,\n FormFieldValidationControlProps,\n ExpandToViewport,\n InternalBaseComponentProps {\n ariaControls?: string;\n ariaActivedescendant?: string;\n dropdownExpanded?: boolean;\n dropdownContentKey?: string;\n dropdownContentFocusable?: boolean;\n dropdownContent?: React.ReactNode;\n dropdownFooter?: React.ReactNode;\n dropdownWidth?: number;\n loopFocus?: boolean;\n onCloseDropdown?: NonCancelableEventHandler<null>;\n onDelayedInput?: NonCancelableEventHandler<BaseChangeDetail>;\n onPressArrowDown?: () => void;\n onPressArrowUp?: () => void;\n onPressEnter?: () => boolean;\n}\n\ninterface AutosuggestInputFocusOptions {\n preventDropdown?: boolean;\n}\n\nexport interface AutosuggestInputRef extends AutosuggestProps.Ref {\n focus(options?: AutosuggestInputFocusOptions): void;\n open(): void;\n close(): void;\n}\n\nconst AutosuggestInput = React.forwardRef(\n (\n {\n value,\n onChange,\n onBlur,\n onFocus,\n onKeyUp,\n onKeyDown,\n name,\n placeholder,\n disabled,\n readOnly,\n autoFocus,\n ariaLabel,\n ariaRequired,\n disableBrowserAutocorrect = false,\n expandToViewport,\n ariaControls,\n ariaActivedescendant,\n clearAriaLabel,\n dropdownExpanded = true,\n dropdownContentKey,\n dropdownContentFocusable = false,\n dropdownContent = null,\n dropdownFooter = null,\n dropdownWidth,\n loopFocus,\n nativeInputAttributes,\n onCloseDropdown,\n onDelayedInput,\n onPressArrowDown,\n onPressArrowUp,\n onPressEnter,\n __internalRootRef,\n ...restProps\n }: AutosuggestInputProps,\n ref: Ref<AutosuggestInputRef>\n ) => {\n const baseProps = getBaseProps(restProps);\n const formFieldContext = useFormFieldContext(restProps);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const dropdownContentRef = useRef<HTMLDivElement>(null);\n const dropdownFooterRef = useRef<HTMLDivElement>(null);\n const preventOpenOnFocusRef = useRef(false);\n const preventCloseOnBlurRef = useRef(false);\n\n const [open, setOpen] = useState(false);\n\n const openDropdown = () => !readOnly && setOpen(true);\n\n const closeDropdown = () => {\n setOpen(false);\n fireNonCancelableEvent(onCloseDropdown, null);\n };\n\n useImperativeHandle(ref, () => ({\n focus(options?: AutosuggestInputFocusOptions) {\n if (options?.preventDropdown) {\n preventOpenOnFocusRef.current = true;\n }\n inputRef.current?.focus();\n },\n select() {\n inputRef.current?.select();\n },\n open: openDropdown,\n close: closeDropdown,\n }));\n\n const handleBlur = () => {\n if (!preventCloseOnBlurRef.current) {\n closeDropdown();\n fireNonCancelableEvent(onBlur, null);\n }\n };\n\n const handleFocus = () => {\n if (!preventOpenOnFocusRef.current) {\n openDropdown();\n fireNonCancelableEvent(onFocus, null);\n }\n preventOpenOnFocusRef.current = false;\n };\n\n const fireKeydown = (event: CustomEvent<BaseKeyDetail>) => fireCancelableEvent(onKeyDown, event.detail, event);\n\n const handleKeyDown = (event: CustomEvent<BaseKeyDetail>) => {\n switch (event.detail.keyCode) {\n case KeyCode.down: {\n onPressArrowDown?.();\n openDropdown();\n event.preventDefault();\n break;\n }\n case KeyCode.up: {\n onPressArrowUp?.();\n openDropdown();\n event.preventDefault();\n break;\n }\n case KeyCode.enter: {\n if (open) {\n if (!onPressEnter?.()) {\n closeDropdown();\n }\n event.preventDefault();\n }\n fireKeydown(event);\n break;\n }\n case KeyCode.escape: {\n if (open) {\n event.stopPropagation();\n closeDropdown();\n } else if (value) {\n event.stopPropagation();\n fireNonCancelableEvent(onChange, { value: '' });\n }\n event.preventDefault();\n fireKeydown(event);\n break;\n }\n default: {\n fireKeydown(event);\n }\n }\n };\n\n const handleChange = (value: string) => {\n openDropdown();\n fireNonCancelableEvent(onChange, { value });\n };\n\n const handleDelayedInput = (value: string) => {\n fireNonCancelableEvent(onDelayedInput, { value });\n };\n\n const handleDropdownMouseDown: React.MouseEventHandler = event => {\n // Prevent currently focused element from losing focus.\n if (!dropdownContentFocusable) {\n event.preventDefault();\n }\n // Prevent closing dropdown on click inside.\n else {\n preventCloseOnBlurRef.current = true;\n requestAnimationFrame(() => {\n preventCloseOnBlurRef.current = false;\n });\n }\n };\n\n const expanded = open && dropdownExpanded;\n const nativeAttributes: BaseInputProps['nativeInputAttributes'] = {\n name,\n placeholder,\n autoFocus,\n onClick: openDropdown,\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': expanded,\n 'aria-controls': open ? ariaControls : undefined,\n // 'aria-owns' needed for safari+vo to announce activedescendant content\n 'aria-owns': open ? ariaControls : undefined,\n 'aria-label': ariaLabel,\n 'aria-activedescendant': ariaActivedescendant,\n };\n\n // Closes dropdown when outside click is detected.\n // Similar to the internal dropdown implementation but includes the target as well.\n useEffect(() => {\n if (!open) {\n return;\n }\n\n const clickListener = (event: MouseEvent) => {\n if (\n !nodeBelongs(inputRef.current, event.target) &&\n !nodeBelongs(dropdownContentRef.current, event.target) &&\n !nodeBelongs(dropdownFooterRef.current, event.target)\n ) {\n closeDropdown();\n }\n };\n\n window.addEventListener('mousedown', clickListener);\n\n return () => {\n window.removeEventListener('mousedown', clickListener);\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={__internalRootRef}>\n <Dropdown\n minWidth={dropdownWidth}\n stretchWidth={!dropdownWidth}\n stretchBeyondTriggerWidth={true}\n contentKey={dropdownContentKey}\n onFocus={handleFocus}\n onBlur={handleBlur}\n trigger={\n <InternalInput\n type=\"visualSearch\"\n value={value}\n onChange={event => handleChange(event.detail.value)}\n __onDelayedInput={event => handleDelayedInput(event.detail.value)}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n disabled={disabled}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n readOnly={readOnly}\n ariaRequired={ariaRequired}\n clearAriaLabel={clearAriaLabel}\n ref={inputRef}\n autoComplete={false}\n nativeInputAttributes={processAttributes(nativeAttributes, nativeInputAttributes, 'Autosuggest')}\n __skipNativeAttributesWarnings={Object.keys(nativeAttributes)}\n {...formFieldContext}\n />\n }\n onMouseDown={handleDropdownMouseDown}\n open={open && (!!dropdownContent || !!dropdownFooter)}\n footer={\n dropdownFooterRef && (\n <div ref={dropdownFooterRef} className={styles['dropdown-footer']}>\n {open && dropdownFooter ? dropdownFooter : null}\n </div>\n )\n }\n expandToViewport={expandToViewport}\n loopFocus={loopFocus}\n >\n {open && dropdownContent ? (\n <div ref={dropdownContentRef} className={styles['dropdown-content']}>\n {dropdownContent}\n </div>\n ) : null}\n </Dropdown>\n </div>\n );\n }\n);\n\nexport default AutosuggestInput;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/masked-input/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAQ9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,QAAA,MAAM,WAAW,+FA2DhB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/masked-input/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAS9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,QAAA,MAAM,WAAW,+FAgEhB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,eAAe,WAAW,CAAC"}
@@ -7,10 +7,11 @@ import InternalInput from '../../../input/internal';
7
7
  import { getBaseProps } from '../../base-component';
8
8
  import { useFormFieldContext } from '../../context/form-field-context';
9
9
  import { fireCancelableEvent, fireNonCancelableEvent } from '../../events';
10
+ import { processAttributes } from '../../utils/with-native-attributes';
10
11
  import useMask from './use-mask';
11
12
  import MaskFormat from './utils/mask-format';
12
13
  const MaskedInput = React.forwardRef((_a, ref) => {
13
- var { value, onBlur, onChange, onKeyDown, mask, autofix = false, disableAutocompleteOnBlur = false, showUnmaskedValue = false } = _a, rest = __rest(_a, ["value", "onBlur", "onChange", "onKeyDown", "mask", "autofix", "disableAutocompleteOnBlur", "showUnmaskedValue"]);
14
+ var { value, onBlur, onChange, onKeyDown, mask, autofix = false, disableAutocompleteOnBlur = false, showUnmaskedValue = false, nativeInputAttributes } = _a, rest = __rest(_a, ["value", "onBlur", "onChange", "onKeyDown", "mask", "autofix", "disableAutocompleteOnBlur", "showUnmaskedValue", "nativeInputAttributes"]);
14
15
  const baseProps = getBaseProps(rest);
15
16
  const formFieldContext = useFormFieldContext(rest);
16
17
  const inputRef = React.useRef(null);
@@ -35,9 +36,9 @@ const MaskedInput = React.forwardRef((_a, ref) => {
35
36
  }), { onPaste } = _b, maskProps = __rest(_b, ["onPaste"]);
36
37
  const inputProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), baseProps), formFieldContext), maskProps), { value: showUnmaskedValue ? value : maskProps.value });
37
38
  const mergedRef = useMergeRefs(ref, inputRef);
38
- return (React.createElement(InternalInput, Object.assign({}, inputProps, { ref: mergedRef, __nativeAttributes: {
39
+ return (React.createElement(InternalInput, Object.assign({}, inputProps, { ref: mergedRef, nativeInputAttributes: processAttributes({
39
40
  onPaste,
40
- } })));
41
+ }, nativeInputAttributes, 'MaskedInput') })));
41
42
  });
42
43
  export default MaskedInput;
43
44
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/masked-input/index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;QACxC,MAAM,EAAE,IAAI,UAAU,CAAC,IAAI,CAAC;QAC5B,KAAK;QACL,QAAQ;QACR,OAAO;QACP,yBAAyB;QACzB,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,sBAAsB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC;QAC1F,SAAS,EAAE,CAAC,KAAkB,EAAE,EAAE,CAChC,CAAC,IAAI,CAAC,QAAQ,IAAI,SAAS,IAAI,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;QACpF,MAAM,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,MAAM,CAAC;QAC5C,WAAW,EAAE,iBAAiB;QAC9B,iBAAiB;KAClB,CAAC,EAZI,EAAE,OAAO,OAYb,EAZkB,SAAS,cAAvB,WAAyB,CAY7B,CAAC;IAEH,MAAM,UAAU,6EACX,IAAI,GACJ,SAAS,GACT,gBAAgB,GAChB,SAAS,KACZ,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,GACnD,CAAC;IAEF,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC9C,OAAO,CACL,oBAAC,aAAa,oBACR,UAAU,IACd,GAAG,EAAE,SAAS,EACd,kBAAkB,EAAE;YAClB,OAAO;SACR,IACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAGF,eAAe,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useLayoutEffect, useState } from 'react';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalInput from '../../../input/internal';\nimport { getBaseProps } from '../../base-component';\nimport { useFormFieldContext } from '../../context/form-field-context';\nimport { fireCancelableEvent, fireNonCancelableEvent } from '../../events';\nimport { MaskedInputProps } from './interfaces';\nimport useMask from './use-mask';\nimport MaskFormat from './utils/mask-format';\n\nconst MaskedInput = React.forwardRef(\n (\n {\n value,\n onBlur,\n onChange,\n onKeyDown,\n mask,\n autofix = false,\n disableAutocompleteOnBlur = false,\n showUnmaskedValue = false,\n ...rest\n }: MaskedInputProps,\n ref: Ref<MaskedInputProps.Ref>\n ) => {\n const baseProps = getBaseProps(rest);\n const formFieldContext = useFormFieldContext(rest);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [cursorPosition, setCursorPosition] = useState<number | null>(null);\n\n useLayoutEffect(() => {\n if (cursorPosition !== null) {\n inputRef.current?.setSelectionRange(cursorPosition, cursorPosition);\n }\n }, [cursorPosition, inputRef]);\n\n const { onPaste, ...maskProps } = useMask({\n format: new MaskFormat(mask),\n value,\n inputRef,\n autofix,\n disableAutocompleteOnBlur,\n onChange: (value: string) => !rest.readOnly && fireNonCancelableEvent(onChange, { value }),\n onKeyDown: (event: CustomEvent) =>\n !rest.readOnly && onKeyDown && fireCancelableEvent(onKeyDown, event.detail, event),\n onBlur: () => fireNonCancelableEvent(onBlur),\n setPosition: setCursorPosition,\n showUnmaskedValue,\n });\n\n const inputProps = {\n ...rest,\n ...baseProps,\n ...formFieldContext,\n ...maskProps,\n value: showUnmaskedValue ? value : maskProps.value,\n };\n\n const mergedRef = useMergeRefs(ref, inputRef);\n return (\n <InternalInput\n {...inputProps}\n ref={mergedRef}\n __nativeAttributes={{\n onPaste,\n }}\n />\n );\n }\n);\n\nexport { MaskedInputProps };\nexport default MaskedInput;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/masked-input/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAO,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO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AE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,sBAAsB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC;QAC1F,SAAS,EAAE,CAAC,KAAkB,EAAE,EAAE,CAChC,CAAC,IAAI,CAAC,QAAQ,IAAI,SAAS,IAAI,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;QACpF,MAAM,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,MAAM,CAAC;QAC5C,WAAW,EAAE,iBAAiB;QAC9B,iBAAiB;KAClB,CAAC,EAZI,EAAE,OAAO,OAYb,EAZkB,SAAS,cAAvB,WAAyB,CAY7B,CAAC;IAEH,MAAM,UAAU,6EACX,IAAI,GACJ,SAAS,GACT,gBAAgB,GAChB,SAAS,KACZ,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,GACnD,CAAC;IAEF,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC9C,OAAO,CACL,oBAAC,aAAa,oBACR,UAAU,IACd,GAAG,EAAE,SAAS,EACd,qBAAqB,EAAE,iBAAiB,CACtC;YACE,OAAO;SACR,EACD,qBAAqB,EACrB,aAAa,CACd,IACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAGF,eAAe,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useLayoutEffect, useState } from 'react';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalInput from '../../../input/internal';\nimport { getBaseProps } from '../../base-component';\nimport { useFormFieldContext } from '../../context/form-field-context';\nimport { fireCancelableEvent, fireNonCancelableEvent } from '../../events';\nimport { processAttributes } from '../../utils/with-native-attributes';\nimport { MaskedInputProps } from './interfaces';\nimport useMask from './use-mask';\nimport MaskFormat from './utils/mask-format';\n\nconst MaskedInput = React.forwardRef(\n (\n {\n value,\n onBlur,\n onChange,\n onKeyDown,\n mask,\n autofix = false,\n disableAutocompleteOnBlur = false,\n showUnmaskedValue = false,\n nativeInputAttributes,\n ...rest\n }: MaskedInputProps,\n ref: Ref<MaskedInputProps.Ref>\n ) => {\n const baseProps = getBaseProps(rest);\n const formFieldContext = useFormFieldContext(rest);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [cursorPosition, setCursorPosition] = useState<number | null>(null);\n\n useLayoutEffect(() => {\n if (cursorPosition !== null) {\n inputRef.current?.setSelectionRange(cursorPosition, cursorPosition);\n }\n }, [cursorPosition, inputRef]);\n\n const { onPaste, ...maskProps } = useMask({\n format: new MaskFormat(mask),\n value,\n inputRef,\n autofix,\n disableAutocompleteOnBlur,\n onChange: (value: string) => !rest.readOnly && fireNonCancelableEvent(onChange, { value }),\n onKeyDown: (event: CustomEvent) =>\n !rest.readOnly && onKeyDown && fireCancelableEvent(onKeyDown, event.detail, event),\n onBlur: () => fireNonCancelableEvent(onBlur),\n setPosition: setCursorPosition,\n showUnmaskedValue,\n });\n\n const inputProps = {\n ...rest,\n ...baseProps,\n ...formFieldContext,\n ...maskProps,\n value: showUnmaskedValue ? value : maskProps.value,\n };\n\n const mergedRef = useMergeRefs(ref, inputRef);\n return (\n <InternalInput\n {...inputProps}\n ref={mergedRef}\n nativeInputAttributes={processAttributes(\n {\n onPaste,\n },\n nativeInputAttributes,\n 'MaskedInput'\n )}\n />\n );\n }\n);\n\nexport { MaskedInputProps };\nexport default MaskedInput;\n"]}
@@ -1,6 +1,6 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (746aab5c)";
3
- export var GIT_SHA = "746aab5c";
2
+ export var PACKAGE_VERSION = "3.0.0 (fdbe2311)";
3
+ export var GIT_SHA = "fdbe2311";
4
4
  export var THEME = "open-source-visual-refresh";
5
5
  export var SYSTEM = "console";
6
6
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (746aab5c)",
4
- "GIT_SHA": "746aab5c",
3
+ "PACKAGE_VERSION": "3.0.0 (fdbe2311)",
4
+ "GIT_SHA": "fdbe2311",
5
5
  "THEME": "open-source-visual-refresh",
6
6
  "SYSTEM": "console",
7
7
  "ALWAYS_VISUAL_REFRESH": true
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-effect-on-update/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAqB,MAAM,OAAO,CAAC;AAG1E,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,QAsB/E"}
@@ -0,0 +1,37 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { useEffect, useRef } from 'react';
4
+ // useEffect, which skips the initial render
5
+ export function useEffectOnUpdate(callback, deps) {
6
+ const previousDepsRef = useRef(null);
7
+ useEffect(() => {
8
+ const previousDeps = previousDepsRef.current;
9
+ previousDepsRef.current = deps;
10
+ // The initial render is ignored by design.
11
+ if (previousDeps === null) {
12
+ return;
13
+ }
14
+ // In React 18 strict mode the useEffect callback is executed twice. We prevent the
15
+ // callback from firing in case the dependencies did not actually change.
16
+ if (isDepsEqual(previousDeps, deps)) {
17
+ // This line is only reachable in React 18+ strict mode.
18
+ // istanbul ignore next
19
+ return;
20
+ }
21
+ return callback();
22
+ // This is a useEffect extension, will be validated at the call site
23
+ // eslint-disable-next-line react-hooks/exhaustive-deps
24
+ }, deps);
25
+ }
26
+ function isDepsEqual(prev, next) {
27
+ for (let i = 0; i < Math.max(prev.length, next.length); i++) {
28
+ // This is how React compared dependencies, documented here: https://react.dev/reference/react/useEffect.
29
+ if (!Object.is(prev[i], next[i])) {
30
+ return false;
31
+ }
32
+ }
33
+ // This line is only reachable in React 18+ strict mode.
34
+ // istanbul ignore next
35
+ return true;
36
+ }
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-effect-on-update/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAkC,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1E,4CAA4C;AAC5C,MAAM,UAAU,iBAAiB,CAAC,QAAwB,EAAE,IAAoB;IAC9E,MAAM,eAAe,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAE5D,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,CAAC;QAC7C,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;QAE/B,2CAA2C;QAC3C,IAAI,YAAY,KAAK,IAAI,EAAE;YACzB,OAAO;SACR;QACD,mFAAmF;QACnF,yEAAyE;QACzE,IAAI,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE;YACnC,wDAAwD;YACxD,uBAAuB;YACvB,OAAO;SACR;QACD,OAAO,QAAQ,EAAE,CAAC;QAClB,oEAAoE;QACpE,uDAAuD;IACzD,CAAC,EAAE,IAAI,CAAC,CAAC;AACX,CAAC;AAED,SAAS,WAAW,CAAC,IAAoB,EAAE,IAAoB;IAC7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE;QAC3D,yGAAyG;QACzG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;YAChC,OAAO,KAAK,CAAC;SACd;KACF;IACD,wDAAwD;IACxD,uBAAuB;IACvB,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { DependencyList, EffectCallback, useEffect, useRef } from 'react';\n\n// useEffect, which skips the initial render\nexport function useEffectOnUpdate(callback: EffectCallback, deps: DependencyList) {\n const previousDepsRef = useRef<null | DependencyList>(null);\n\n useEffect(() => {\n const previousDeps = previousDepsRef.current;\n previousDepsRef.current = deps;\n\n // The initial render is ignored by design.\n if (previousDeps === null) {\n return;\n }\n // In React 18 strict mode the useEffect callback is executed twice. We prevent the\n // callback from firing in case the dependencies did not actually change.\n if (isDepsEqual(previousDeps, deps)) {\n // This line is only reachable in React 18+ strict mode.\n // istanbul ignore next\n return;\n }\n return callback();\n // This is a useEffect extension, will be validated at the call site\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n}\n\nfunction isDepsEqual(prev: DependencyList, next: DependencyList) {\n for (let i = 0; i < Math.max(prev.length, next.length); i++) {\n // This is how React compared dependencies, documented here: https://react.dev/reference/react/useEffect.\n if (!Object.is(prev[i], next[i])) {\n return false;\n }\n }\n // This line is only reachable in React 18+ strict mode.\n // istanbul ignore next\n return true;\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "746aab5cdf6a869e1d4a6c2a7886f6eb39a6f489"
2
+ "commit": "fdbe23110e6b1aa619532563394cbb54497f865e"
3
3
  }
@@ -1,9 +1,10 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  export type NativeAttributes<T extends React.HTMLAttributes<HTMLElement>> = (Omit<T, 'children'> & Record<`data-${string}`, string>) | undefined;
3
+ export type SkipWarnings = boolean | string[];
3
4
  type NativeAttributesProps<AT extends React.HTMLAttributes<HTMLElement>> = {
4
5
  tag: string;
5
6
  children?: ReactNode;
6
- skipWarnings?: boolean;
7
+ skipWarnings?: SkipWarnings;
7
8
  nativeAttributes: NativeAttributes<AT>;
8
9
  componentName: string;
9
10
  } & NativeAttributes<AT>;
@@ -12,5 +13,6 @@ interface ForwardRefType {
12
13
  ref?: React.Ref<ET>;
13
14
  }): JSX.Element;
14
15
  }
16
+ export declare function processAttributes<ET extends HTMLElement, AT extends React.HTMLAttributes<ET>>(rest: Omit<NativeAttributesProps<AT>, 'children' | 'tag' | 'skipWarnings' | 'componentName' | 'nativeAttributes'>, nativeAttributes: NativeAttributes<AT>, componentName: string, skipWarnings?: SkipWarnings): any;
15
17
  declare const _default: ForwardRefType;
16
18
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"with-native-attributes.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/with-native-attributes.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKzC,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,IACpE,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,MAAM,CAAC,QAAQ,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,GACxD,SAAS,CAAC;AAEd,KAAK,qBAAqB,CAAC,EAAE,SAAS,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI;IACzE,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;IACvC,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACzB,UAAU,cAAc;IACtB,CAAC,EAAE,SAAS,WAAW,EAAE,EAAE,SAAS,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC,EAC1D,KAAK,EAAE,qBAAqB,CAAC,EAAE,CAAC,GAAG;QAAE,GAAG,CAAC,EAAE,KAAK,CAAC,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,EAAE,CAAC,EAAE,UAAU,GAAG,KAAK,GAAG,cAAc,GAAG,eAAe,GAAG,kBAAkB,CAAC,EACjH,gBAAgB,EAAE,gBAAgB,CAAC,EAAE,CAAC,EACtC,aAAa,EAAE,MAAM,EACrB,YAAY,CAAC,EAAE,YAAY,OAgC5B;;AAED,wBAeoB"}
@@ -4,10 +4,8 @@ import { __rest } from "tslib";
4
4
  import React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
7
- export default React.forwardRef((_a, ref) => {
8
- var { tag, nativeAttributes, children, skipWarnings, componentName } = _a, rest = __rest(_a, ["tag", "nativeAttributes", "children", "skipWarnings", "componentName"]);
9
- const Tag = tag;
10
- const processedAttributes = Object.entries(nativeAttributes || {}).reduce((acc, [key, value]) => {
7
+ export function processAttributes(rest, nativeAttributes, componentName, skipWarnings) {
8
+ return Object.entries(nativeAttributes || {}).reduce((acc, [key, value]) => {
11
9
  // concatenate className
12
10
  if (key === 'className') {
13
11
  acc[key] = clsx(rest.className, value);
@@ -27,13 +25,18 @@ export default React.forwardRef((_a, ref) => {
27
25
  // override other attributes, warning if it already exists
28
26
  }
29
27
  else {
30
- if (key in rest && !skipWarnings) {
28
+ if (key in rest && (!skipWarnings || (skipWarnings !== true && !skipWarnings.includes(key)))) {
31
29
  warnOnce(componentName, `Overriding native attribute [${key}] which has a Cloudscape-provided value`);
32
30
  }
33
31
  acc[key] = value;
34
32
  }
35
33
  return acc;
36
- }, {});
37
- return (React.createElement(Tag, Object.assign({}, rest, processedAttributes, { ref: ref }), children));
34
+ }, Object.assign({}, rest));
35
+ }
36
+ export default React.forwardRef((_a, ref) => {
37
+ var { tag, nativeAttributes, children, skipWarnings, componentName } = _a, rest = __rest(_a, ["tag", "nativeAttributes", "children", "skipWarnings", "componentName"]);
38
+ const Tag = tag;
39
+ const processedAttributes = processAttributes(rest, nativeAttributes, componentName, skipWarnings);
40
+ return (React.createElement(Tag, Object.assign({}, processedAttributes, { ref: ref }), children));
38
41
  });
39
42
  //# sourceMappingURL=with-native-attributes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"with-native-attributes.js","sourceRoot":"","sources":["../../../../src/internal/utils/with-native-attributes.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAmBzE,eAAe,KAAK,CAAC,UAAU,CAC7B,CACE,EAAoG,EACpG,GAAkB,EAClB,EAAE;QAFF,EAAE,GAAG,EAAE,gBAAgB,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,OAAsC,EAAjC,IAAI,cAAvE,wEAAyE,CAAF;IAGvE,MAAM,GAAG,GAAG,GAAG,CAAC;IAEhB,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC9F,wBAAwB;QACxB,IAAI,GAAG,KAAK,WAAW,EAAE;YACvB,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAEvC,cAAc;SACf;aAAM,IAAI,GAAG,KAAK,OAAO,EAAE;YAC1B,GAAG,CAAC,GAAG,CAAC,mCAAQ,IAAI,CAAC,KAAK,GAAK,KAAK,CAAE,CAAC;YAEvC,uBAAuB;SACxB;aAAM,IAAI,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,GAAG,IAAI,IAAI,EAAE;YAC9E,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAY,EAAE,EAAE;gBAC1B,KAAK,CAAC,KAAK,CAAC,CAAC;gBACb,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;oBAC1B,IAAY,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;iBAC3B;YACH,CAAC,CAAC;YAEF,0DAA0D;SAC3D;aAAM;YACL,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,YAAY,EAAE;gBAChC,QAAQ,CAAC,aAAa,EAAE,gCAAgC,GAAG,yCAAyC,CAAC,CAAC;aACvG;YACD,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SAClB;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAS,CAAC,CAAC;IAEd,OAAO,CACL,oBAAC,GAAG,oBAAK,IAAI,EAAM,mBAAmB,IAAE,GAAG,EAAE,GAAG,KAC7C,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CACgB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ReactNode } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nexport type NativeAttributes<T extends React.HTMLAttributes<HTMLElement>> =\n | (Omit<T, 'children'> & Record<`data-${string}`, string>)\n | undefined;\n\ntype NativeAttributesProps<AT extends React.HTMLAttributes<HTMLElement>> = {\n tag: string;\n children?: ReactNode;\n skipWarnings?: boolean;\n nativeAttributes: NativeAttributes<AT>;\n componentName: string;\n} & NativeAttributes<AT>;\ninterface ForwardRefType {\n <ET extends HTMLElement, AT extends React.HTMLAttributes<ET>>(\n props: NativeAttributesProps<AT> & { ref?: React.Ref<ET> }\n ): JSX.Element;\n}\n\nexport default React.forwardRef(\n <ET extends HTMLElement, AT extends React.HTMLAttributes<ET>>(\n { tag, nativeAttributes, children, skipWarnings, componentName, ...rest }: NativeAttributesProps<AT>,\n ref: React.Ref<ET>\n ) => {\n const Tag = tag;\n\n const processedAttributes = Object.entries(nativeAttributes || {}).reduce((acc, [key, value]) => {\n // concatenate className\n if (key === 'className') {\n acc[key] = clsx(rest.className, value);\n\n // merge style\n } else if (key === 'style') {\n acc[key] = { ...rest.style, ...value };\n\n // chain event handlers\n } else if (key.match(/^on[A-Z]/) && typeof value === 'function' && key in rest) {\n acc[key] = (event: Event) => {\n value(event);\n if (!event.defaultPrevented) {\n (rest as any)[key](event);\n }\n };\n\n // override other attributes, warning if it already exists\n } else {\n if (key in rest && !skipWarnings) {\n warnOnce(componentName, `Overriding native attribute [${key}] which has a Cloudscape-provided value`);\n }\n acc[key] = value;\n }\n return acc;\n }, {} as any);\n\n return (\n <Tag {...rest} {...processedAttributes} ref={ref}>\n {children}\n </Tag>\n );\n }\n) as ForwardRefType;\n"]}
1
+ {"version":3,"file":"with-native-attributes.js","sourceRoot":"","sources":["../../../../src/internal/utils/with-native-attributes.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAqBzE,MAAM,UAAU,iBAAiB,CAC/B,IAAiH,EACjH,gBAAsC,EACtC,aAAqB,EACrB,YAA2B;IAE3B,OAAO,MAAM,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,MAAM,CAClD,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACpB,wBAAwB;QACxB,IAAI,GAAG,KAAK,WAAW,EAAE;YACvB,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAEvC,cAAc;SACf;aAAM,IAAI,GAAG,KAAK,OAAO,EAAE;YAC1B,GAAG,CAAC,GAAG,CAAC,mCAAQ,IAAI,CAAC,KAAK,GAAK,KAAK,CAAE,CAAC;YAEvC,uBAAuB;SACxB;aAAM,IAAI,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,GAAG,IAAI,IAAI,EAAE;YAC9E,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAY,EAAE,EAAE;gBAC1B,KAAK,CAAC,KAAK,CAAC,CAAC;gBACb,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;oBAC1B,IAAY,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;iBAC3B;YACH,CAAC,CAAC;YAEF,0DAA0D;SAC3D;aAAM;YACL,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,CAAC,YAAY,IAAI,CAAC,YAAY,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;gBAC5F,QAAQ,CAAC,aAAa,EAAE,gCAAgC,GAAG,yCAAyC,CAAC,CAAC;aACvG;YACD,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SAClB;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EACD,kBAAK,IAAI,CAAS,CACnB,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,UAAU,CAC7B,CACE,EAAoG,EACpG,GAAkB,EAClB,EAAE;QAFF,EAAE,GAAG,EAAE,gBAAgB,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,OAAsC,EAAjC,IAAI,cAAvE,wEAAyE,CAAF;IAGvE,MAAM,GAAG,GAAG,GAAG,CAAC;IAEhB,MAAM,mBAAmB,GAAG,iBAAiB,CAAS,IAAI,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;IAE3G,OAAO,CACL,oBAAC,GAAG,oBAAK,mBAAmB,IAAE,GAAG,EAAE,GAAG,KACnC,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CACgB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ReactNode } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nexport type NativeAttributes<T extends React.HTMLAttributes<HTMLElement>> =\n | (Omit<T, 'children'> & Record<`data-${string}`, string>)\n | undefined;\n\nexport type SkipWarnings = boolean | string[];\n\ntype NativeAttributesProps<AT extends React.HTMLAttributes<HTMLElement>> = {\n tag: string;\n children?: ReactNode;\n skipWarnings?: SkipWarnings;\n nativeAttributes: NativeAttributes<AT>;\n componentName: string;\n} & NativeAttributes<AT>;\ninterface ForwardRefType {\n <ET extends HTMLElement, AT extends React.HTMLAttributes<ET>>(\n props: NativeAttributesProps<AT> & { ref?: React.Ref<ET> }\n ): JSX.Element;\n}\n\nexport function processAttributes<ET extends HTMLElement, AT extends React.HTMLAttributes<ET>>(\n rest: Omit<NativeAttributesProps<AT>, 'children' | 'tag' | 'skipWarnings' | 'componentName' | 'nativeAttributes'>,\n nativeAttributes: NativeAttributes<AT>,\n componentName: string,\n skipWarnings?: SkipWarnings\n) {\n return Object.entries(nativeAttributes || {}).reduce(\n (acc, [key, value]) => {\n // concatenate className\n if (key === 'className') {\n acc[key] = clsx(rest.className, value);\n\n // merge style\n } else if (key === 'style') {\n acc[key] = { ...rest.style, ...value };\n\n // chain event handlers\n } else if (key.match(/^on[A-Z]/) && typeof value === 'function' && key in rest) {\n acc[key] = (event: Event) => {\n value(event);\n if (!event.defaultPrevented) {\n (rest as any)[key](event);\n }\n };\n\n // override other attributes, warning if it already exists\n } else {\n if (key in rest && (!skipWarnings || (skipWarnings !== true && !skipWarnings.includes(key)))) {\n warnOnce(componentName, `Overriding native attribute [${key}] which has a Cloudscape-provided value`);\n }\n acc[key] = value;\n }\n return acc;\n },\n { ...rest } as any\n );\n}\n\nexport default React.forwardRef(\n <ET extends HTMLElement, AT extends React.HTMLAttributes<ET>>(\n { tag, nativeAttributes, children, skipWarnings, componentName, ...rest }: NativeAttributesProps<AT>,\n ref: React.Ref<ET>\n ) => {\n const Tag = tag;\n\n const processedAttributes = processAttributes<ET, AT>(rest, nativeAttributes, componentName, skipWarnings);\n\n return (\n <Tag {...processedAttributes} ref={ref}>\n {children}\n </Tag>\n );\n }\n) as ForwardRefType;\n"]}
package/package.json CHANGED
@@ -151,7 +151,7 @@
151
151
  "./internal/base-component/index.js",
152
152
  "./internal/base-component/styles.css.js"
153
153
  ],
154
- "version": "3.0.1085",
154
+ "version": "3.0.1086",
155
155
  "repository": {
156
156
  "type": "git",
157
157
  "url": "https://github.com/cloudscape-design/components.git"
@@ -9,7 +9,7 @@ import { validateProps } from '@cloudscape-design/component-toolkit/internal';
9
9
 
10
10
 
11
11
  const PromptInput = React.forwardRef((props, ref) => {
12
- validateProps('PromptInput', props, ["customPrimaryAction"], {}, 'console');
12
+ validateProps('PromptInput', props, ["nativeTextareaAttributes","customPrimaryAction"], {}, 'console');
13
13
  return React.createElement(CoreComponent, {ref,...props});
14
14
  });
15
15
 
@@ -4,7 +4,11 @@ import { BaseChangeDetail, BaseInputProps, InputAutoComplete, InputAutoCorrect,
4
4
  import { BaseComponentProps } from '../internal/base-component';
5
5
  import { FormFieldValidationControlProps } from '../internal/context/form-field-context';
6
6
  import { BaseKeyDetail, NonCancelableEventHandler } from '../internal/events';
7
- export interface PromptInputProps extends BaseInputProps, InputKeyEvents, InputAutoCorrect, InputAutoComplete, InputSpellcheck, BaseComponentProps, FormFieldValidationControlProps {
7
+ /**
8
+ * @awsuiSystem core
9
+ */
10
+
11
+ export interface PromptInputProps extends Omit<BaseInputProps, 'nativeInputAttributes'>, InputKeyEvents, InputAutoCorrect, InputAutoComplete, InputSpellcheck, BaseComponentProps, FormFieldValidationControlProps {
8
12
  /**
9
13
  * Called whenever a user clicks the action button or presses the "Enter" key.
10
14
  * The event `detail` contains the current value of the field.
@@ -89,6 +93,16 @@ export interface PromptInputProps extends BaseInputProps, InputKeyEvents, InputA
89
93
  * Determines whether the secondary content area of the input has padding. If true, removes the default padding from the secondary content area.
90
94
  */
91
95
  disableSecondaryContentPaddings?: boolean;
96
+ /**
97
+ * Attributes to add to the native `textarea` element.
98
+ * Some attributes will be automatically combined with internal attribute values:
99
+ * - `className` will be appended.
100
+ * - Event handlers will be chained, unless the default is prevented.
101
+ *
102
+ * We do not support using this attribute to apply custom styling.
103
+ *
104
+ * @awsuiSystem core
105
+ */
92
106
  }
93
107
  export declare namespace PromptInputProps {
94
108
  type KeyDetail = BaseKeyDetail;
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/prompt-input/interfaces.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE9E,MAAM,WAAW,gBACf,SAAQ,cAAc,EACpB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,+BAA+B;IACjC;;;OAGG;IACH,QAAQ,CAAC,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACpE;;OAEG;IACH,oBAAoB,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC;IACtC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9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tC,KAAY,YAAY,GAAG,gBAAgB,CAAC;IAE5C,UAAiB,GAAG;QAClB;;WAEG;QACH,KAAK,IAAI,IAAI,CAAC;QAEd;;WAEG;QACH,MAAM,IAAI,IAAI,CAAC;QAEf;;;;;;WAMG;QACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC;KAChH;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/prompt-input/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { IconProps } from '../icon/interfaces';\nimport {\n BaseChangeDetail,\n BaseInputProps,\n InputAutoComplete,\n InputAutoCorrect,\n InputKeyEvents,\n InputSpellcheck,\n} from '../input/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { BaseKeyDetail, NonCancelableEventHandler } from '../internal/events';\n\nexport interface PromptInputProps\n extends BaseInputProps,\n InputKeyEvents,\n InputAutoCorrect,\n InputAutoComplete,\n InputSpellcheck,\n BaseComponentProps,\n FormFieldValidationControlProps {\n /**\n * Called whenever a user clicks the action button or presses the \"Enter\" key.\n * The event `detail` contains the current value of the field.\n */\n onAction?: NonCancelableEventHandler<PromptInputProps.ActionDetail>;\n /**\n * Determines what icon to display in the action button.\n */\n actionButtonIconName?: IconProps.Name;\n /**\n * Specifies the URL of a custom icon. Use this property if the icon you want isn't available.\n *\n * If you set both `actionButtonIconUrl` and `actionButtonIconSvg`, `actionButtonIconSvg` will take precedence.\n */\n actionButtonIconUrl?: string;\n /**\n * Specifies the SVG of a custom icon.\n *\n * Use this property if you want your custom icon to inherit colors dictated by variant or hover states.\n * When this property is set, the component will be decorated with `aria-hidden=\"true\"`. Ensure that the `svg` element:\n * - has attribute `focusable=\"false\"`.\n * - has `viewBox=\"0 0 16 16\"`.\n *\n * If you set the `svg` element as the root node of the slot, the component will automatically\n * - set `stroke=\"currentColor\"`, `fill=\"none\"`, and `vertical-align=\"top\"`.\n * - set the stroke width based on the size of the icon.\n * - set the width and height of the SVG element based on the size of the icon.\n *\n * If you don't want these styles to be automatically set, wrap the `svg` element into a `span`.\n * You can still set the stroke to `currentColor` to inherit the color of the surrounding elements.\n *\n * If you set both `actionButtonIconUrl` and `actionButtonIconSvg`, `iconSvg` will take precedence.\n *\n * *Note:* Remember to remove any additional elements (for example: `defs`) and related CSS classes from SVG files exported from design software.\n * In most cases, they aren't needed, as the `svg` element inherits styles from the icon component.\n */\n actionButtonIconSvg?: React.ReactNode;\n /**\n * Specifies alternate text for a custom icon. We recommend that you provide this for accessibility.\n * This property is ignored if you use a predefined icon or if you set your custom icon using the `iconSvg` slot.\n */\n actionButtonIconAlt?: string;\n /**\n * Adds an aria-label to the action button.\n * @i18n\n */\n actionButtonAriaLabel?: string;\n\n /**\n * Specifies whether to disable the action button.\n */\n disableActionButton?: boolean;\n\n /**\n * Specifies the minimum number of lines of text to set the height to.\n */\n minRows?: number;\n\n /**\n * Specifies the maximum number of lines of text the textarea will expand to.\n * Defaults to 3. Use -1 for infinite rows.\n */\n maxRows?: number;\n\n /**\n * Use this to replace the primary action.\n * If this is provided then any other `actionButton*` properties will be ignored.\n * Note that you should still provide an `onAction` function in order to handle keyboard submission.\n *\n * @awsuiSystem core\n */\n customPrimaryAction?: React.ReactNode;\n\n /**\n * Use this slot to add secondary actions to the prompt input.\n */\n secondaryActions?: React.ReactNode;\n\n /**\n * Use this slot to add secondary content, such as file attachments, to the prompt input.\n */\n secondaryContent?: React.ReactNode;\n\n /**\n * Determines whether the secondary actions area of the input has padding. If true, removes the default padding from the secondary actions area.\n */\n disableSecondaryActionsPaddings?: boolean;\n\n /**\n * Determines whether the secondary content area of the input has padding. If true, removes the default padding from the secondary content area.\n */\n disableSecondaryContentPaddings?: boolean;\n}\n\nexport namespace PromptInputProps {\n export type KeyDetail = BaseKeyDetail;\n export type ActionDetail = BaseChangeDetail;\n\n export interface Ref {\n /**\n * Sets input focus on the textarea control.\n */\n focus(): void;\n\n /**\n * Selects all text in the textarea control.\n */\n select(): void;\n\n /**\n * Selects a range of text in the textarea control.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement/setSelectionRange\n * for more details on this method. Be aware that using this method in React has some\n * common pitfalls: https://stackoverflow.com/questions/60129605/is-javascripts-setselectionrange-incompatible-with-react-hooks\n */\n setSelectionRange(start: number | null, end: number | null, direction?: 'forward' | 'backward' | 'none'): void;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/prompt-input/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { IconProps } from '../icon/interfaces';\nimport {\n BaseChangeDetail,\n BaseInputProps,\n InputAutoComplete,\n InputAutoCorrect,\n InputKeyEvents,\n InputSpellcheck,\n} from '../input/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { BaseKeyDetail, NonCancelableEventHandler } from '../internal/events';\n/**\n * @awsuiSystem core\n */\nimport { NativeAttributes } from '../internal/utils/with-native-attributes';\n\nexport interface PromptInputProps\n extends Omit<BaseInputProps, 'nativeInputAttributes'>,\n InputKeyEvents,\n InputAutoCorrect,\n InputAutoComplete,\n InputSpellcheck,\n BaseComponentProps,\n FormFieldValidationControlProps {\n /**\n * Called whenever a user clicks the action button or presses the \"Enter\" key.\n * The event `detail` contains the current value of the field.\n */\n onAction?: NonCancelableEventHandler<PromptInputProps.ActionDetail>;\n /**\n * Determines what icon to display in the action button.\n */\n actionButtonIconName?: IconProps.Name;\n /**\n * Specifies the URL of a custom icon. Use this property if the icon you want isn't available.\n *\n * If you set both `actionButtonIconUrl` and `actionButtonIconSvg`, `actionButtonIconSvg` will take precedence.\n */\n actionButtonIconUrl?: string;\n /**\n * Specifies the SVG of a custom icon.\n *\n * Use this property if you want your custom icon to inherit colors dictated by variant or hover states.\n * When this property is set, the component will be decorated with `aria-hidden=\"true\"`. Ensure that the `svg` element:\n * - has attribute `focusable=\"false\"`.\n * - has `viewBox=\"0 0 16 16\"`.\n *\n * If you set the `svg` element as the root node of the slot, the component will automatically\n * - set `stroke=\"currentColor\"`, `fill=\"none\"`, and `vertical-align=\"top\"`.\n * - set the stroke width based on the size of the icon.\n * - set the width and height of the SVG element based on the size of the icon.\n *\n * If you don't want these styles to be automatically set, wrap the `svg` element into a `span`.\n * You can still set the stroke to `currentColor` to inherit the color of the surrounding elements.\n *\n * If you set both `actionButtonIconUrl` and `actionButtonIconSvg`, `iconSvg` will take precedence.\n *\n * *Note:* Remember to remove any additional elements (for example: `defs`) and related CSS classes from SVG files exported from design software.\n * In most cases, they aren't needed, as the `svg` element inherits styles from the icon component.\n */\n actionButtonIconSvg?: React.ReactNode;\n /**\n * Specifies alternate text for a custom icon. We recommend that you provide this for accessibility.\n * This property is ignored if you use a predefined icon or if you set your custom icon using the `iconSvg` slot.\n */\n actionButtonIconAlt?: string;\n /**\n * Adds an aria-label to the action button.\n * @i18n\n */\n actionButtonAriaLabel?: string;\n\n /**\n * Specifies whether to disable the action button.\n */\n disableActionButton?: boolean;\n\n /**\n * Specifies the minimum number of lines of text to set the height to.\n */\n minRows?: number;\n\n /**\n * Specifies the maximum number of lines of text the textarea will expand to.\n * Defaults to 3. Use -1 for infinite rows.\n */\n maxRows?: number;\n\n /**\n * Use this to replace the primary action.\n * If this is provided then any other `actionButton*` properties will be ignored.\n * Note that you should still provide an `onAction` function in order to handle keyboard submission.\n *\n * @awsuiSystem core\n */\n customPrimaryAction?: React.ReactNode;\n\n /**\n * Use this slot to add secondary actions to the prompt input.\n */\n secondaryActions?: React.ReactNode;\n\n /**\n * Use this slot to add secondary content, such as file attachments, to the prompt input.\n */\n secondaryContent?: React.ReactNode;\n\n /**\n * Determines whether the secondary actions area of the input has padding. If true, removes the default padding from the secondary actions area.\n */\n disableSecondaryActionsPaddings?: boolean;\n\n /**\n * Determines whether the secondary content area of the input has padding. If true, removes the default padding from the secondary content area.\n */\n disableSecondaryContentPaddings?: boolean;\n\n /**\n * Attributes to add to the native `textarea` 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 nativeTextareaAttributes?: NativeAttributes<React.TextareaHTMLAttributes<HTMLTextAreaElement>>;\n}\n\nexport namespace PromptInputProps {\n export type KeyDetail = BaseKeyDetail;\n export type ActionDetail = BaseChangeDetail;\n\n export interface Ref {\n /**\n * Sets input focus on the textarea control.\n */\n focus(): void;\n\n /**\n * Selects all text in the textarea control.\n */\n select(): void;\n\n /**\n * Selects a range of text in the textarea control.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement/setSelectionRange\n * for more details on this method. Be aware that using this method in React has some\n * common pitfalls: https://stackoverflow.com/questions/60129605/is-javascripts-setselectionrange-incompatible-with-react-hooks\n */\n setSelectionRange(start: number | null, end: number | null, direction?: 'forward' | 'backward' | 'none'): void;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/prompt-input/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAWxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKhD,UAAU,wBACR,SAAQ,YAAY,CAAC,gBAAgB,EAAE,SAAS,GAAG,SAAS,CAAC,EAC3D,0BAA0B;CAAG;AAEjC,QAAA,MAAM,mBAAmB,uGA6NxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/prompt-input/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAWxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKhD,UAAU,wBACR,SAAQ,YAAY,CAAC,gBAAgB,EAAE,SAAS,GAAG,SAAS,CAAC,EAC3D,0BAA0B;CAAG;AAEjC,QAAA,MAAM,mBAAmB,uGAqOxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -11,10 +11,11 @@ import { useFormFieldContext } from '../internal/context/form-field-context';
11
11
  import { fireKeyboardEvent, fireNonCancelableEvent } from '../internal/events';
12
12
  import * as tokens from '../internal/generated/styles/tokens';
13
13
  import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
14
+ import WithNativeAttributes from '../internal/utils/with-native-attributes';
14
15
  import styles from './styles.css.js';
15
16
  import testutilStyles from './test-classes/styles.css.js';
16
17
  const InternalPromptInput = React.forwardRef((_a, ref) => {
17
- var { value, actionButtonAriaLabel, actionButtonIconName, actionButtonIconUrl, actionButtonIconSvg, actionButtonIconAlt, ariaLabel, autoComplete, autoFocus, disableActionButton, disableBrowserAutocorrect, disabled, maxRows, minRows, name, onAction, onBlur, onChange, onFocus, onKeyDown, onKeyUp, placeholder, readOnly, spellcheck, customPrimaryAction, secondaryActions, secondaryContent, disableSecondaryActionsPaddings, disableSecondaryContentPaddings, __internalRootRef } = _a, rest = __rest(_a, ["value", "actionButtonAriaLabel", "actionButtonIconName", "actionButtonIconUrl", "actionButtonIconSvg", "actionButtonIconAlt", "ariaLabel", "autoComplete", "autoFocus", "disableActionButton", "disableBrowserAutocorrect", "disabled", "maxRows", "minRows", "name", "onAction", "onBlur", "onChange", "onFocus", "onKeyDown", "onKeyUp", "placeholder", "readOnly", "spellcheck", "customPrimaryAction", "secondaryActions", "secondaryContent", "disableSecondaryActionsPaddings", "disableSecondaryContentPaddings", "__internalRootRef"]);
18
+ var { value, actionButtonAriaLabel, actionButtonIconName, actionButtonIconUrl, actionButtonIconSvg, actionButtonIconAlt, ariaLabel, autoComplete, autoFocus, disableActionButton, disableBrowserAutocorrect, disabled, maxRows, minRows, name, onAction, onBlur, onChange, onFocus, onKeyDown, onKeyUp, placeholder, readOnly, spellcheck, customPrimaryAction, secondaryActions, secondaryContent, disableSecondaryActionsPaddings, disableSecondaryContentPaddings, nativeTextareaAttributes, __internalRootRef } = _a, rest = __rest(_a, ["value", "actionButtonAriaLabel", "actionButtonIconName", "actionButtonIconUrl", "actionButtonIconSvg", "actionButtonIconAlt", "ariaLabel", "autoComplete", "autoFocus", "disableActionButton", "disableBrowserAutocorrect", "disabled", "maxRows", "minRows", "name", "onAction", "onBlur", "onChange", "onFocus", "onKeyDown", "onKeyUp", "placeholder", "readOnly", "spellcheck", "customPrimaryAction", "secondaryActions", "secondaryContent", "disableSecondaryActionsPaddings", "disableSecondaryContentPaddings", "nativeTextareaAttributes", "__internalRootRef"]);
18
19
  const { ariaLabelledby, ariaDescribedby, controlId, invalid, warning } = useFormFieldContext(rest);
19
20
  const baseProps = getBaseProps(rest);
20
21
  const textareaRef = useRef(null);
@@ -122,7 +123,7 @@ const InternalPromptInput = React.forwardRef((_a, ref) => {
122
123
  [styles.warning]: warning,
123
124
  }) }, secondaryContent)),
124
125
  React.createElement("div", { className: styles['textarea-wrapper'] },
125
- React.createElement("textarea", Object.assign({ ref: textareaRef, id: controlId }, attributes)),
126
+ React.createElement(WithNativeAttributes, Object.assign({}, attributes, { tag: "textarea", componentName: "PromptInput", nativeAttributes: nativeTextareaAttributes, ref: textareaRef, id: controlId })),
126
127
  hasActionButton && !secondaryActions && action),
127
128
  secondaryActions && (React.createElement("div", { className: clsx(styles['action-stripe'], {
128
129
  [styles.invalid]: invalid,
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/prompt-input/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACxF,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAE/E,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAIrE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,8BAA8B,CAAC;AAM1D,MAAM,mBAAmB,GAAG,KAAK,CAAC,UAAU,CAC1C,CACE,EAgC2B,EAC3B,GAA8B,EAC9B,EAAE;QAlCF,EACE,KAAK,EACL,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EACT,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,yBAAyB,EACzB,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,EACP,SAAS,EACT,OAAO,EACP,WAAW,EACX,QAAQ,EACR,UAAU,EACV,mBAAmB,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C,EAAE,cAAc,CAAC,mBAAmB,CAAC,EAAE;oBAChF,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,+BAA+B;oBAC3D,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC,EAAE,CAAC,+BAA+B,IAAI,eAAe;oBAC1F,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO;oBACzB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO;iBAC1B,CAAC,IAED,gBAAgB,CACb;YACN,6BAAK,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,WAAW,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAA,EAAA,GAAI;YAC7E,eAAe,IAAI,MAAM,CACtB,CACP,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useCallback, useEffect, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useDensityMode } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalButton from '../button/internal';\nimport { convertAutoComplete } from '../input/utils';\nimport { getBaseProps } from '../internal/base-component';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { fireKeyboardEvent, fireNonCancelableEvent } from '../internal/events';\nimport * as tokens from '../internal/generated/styles/tokens';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { SomeRequired } from '../internal/types';\nimport { PromptInputProps } from './interfaces';\n\nimport styles from './styles.css.js';\nimport testutilStyles from './test-classes/styles.css.js';\n\ninterface InternalPromptInputProps\n extends SomeRequired<PromptInputProps, 'maxRows' | 'minRows'>,\n InternalBaseComponentProps {}\n\nconst InternalPromptInput = React.forwardRef(\n (\n {\n value,\n actionButtonAriaLabel,\n actionButtonIconName,\n actionButtonIconUrl,\n actionButtonIconSvg,\n actionButtonIconAlt,\n ariaLabel,\n autoComplete,\n autoFocus,\n disableActionButton,\n disableBrowserAutocorrect,\n disabled,\n maxRows,\n minRows,\n name,\n onAction,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n onKeyUp,\n placeholder,\n readOnly,\n spellcheck,\n customPrimaryAction,\n secondaryActions,\n secondaryContent,\n disableSecondaryActionsPaddings,\n disableSecondaryContentPaddings,\n __internalRootRef,\n ...rest\n }: InternalPromptInputProps,\n ref: Ref<PromptInputProps.Ref>\n ) => {\n const { ariaLabelledby, ariaDescribedby, controlId, invalid, warning } = useFormFieldContext(rest);\n\n const baseProps = getBaseProps(rest);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const isRefresh = useVisualRefresh();\n const isCompactMode = useDensityMode(textareaRef) === 'compact';\n\n const PADDING = isRefresh ? tokens.spaceXxs : tokens.spaceXxxs;\n const LINE_HEIGHT = tokens.lineHeightBodyM;\n const DEFAULT_MAX_ROWS = 3;\n\n useImperativeHandle(\n ref,\n () => ({\n focus(...args: Parameters<HTMLElement['focus']>) {\n textareaRef.current?.focus(...args);\n },\n select() {\n textareaRef.current?.select();\n },\n setSelectionRange(...args: Parameters<HTMLTextAreaElement['setSelectionRange']>) {\n textareaRef.current?.setSelectionRange(...args);\n },\n }),\n [textareaRef]\n );\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n fireKeyboardEvent(onKeyDown, event);\n\n if (event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing) {\n if (event.currentTarget.form && !event.isDefaultPrevented()) {\n event.currentTarget.form.requestSubmit();\n }\n event.preventDefault();\n fireNonCancelableEvent(onAction, { value });\n }\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n fireNonCancelableEvent(onChange, { value: event.target.value });\n adjustTextareaHeight();\n };\n\n const hasActionButton = actionButtonIconName || actionButtonIconSvg || actionButtonIconUrl || customPrimaryAction;\n\n const adjustTextareaHeight = useCallback(() => {\n if (textareaRef.current) {\n // this is required so the scrollHeight becomes dynamic, otherwise it will be locked at the highest value for the size it reached e.g. 500px\n textareaRef.current.style.height = 'auto';\n\n const minTextareaHeight = `calc(${LINE_HEIGHT} + ${tokens.spaceScaledXxs} * 2)`; // the min height of Textarea with 1 row\n\n if (maxRows === -1) {\n const scrollHeight = `calc(${textareaRef.current.scrollHeight}px)`;\n textareaRef.current.style.height = `max(${scrollHeight}, ${minTextareaHeight})`;\n } else {\n const maxRowsHeight = `calc(${maxRows <= 0 ? DEFAULT_MAX_ROWS : maxRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})`;\n const scrollHeight = `calc(${textareaRef.current.scrollHeight}px)`;\n textareaRef.current.style.height = `min(max(${scrollHeight}, ${minTextareaHeight}), ${maxRowsHeight})`;\n }\n }\n }, [maxRows, LINE_HEIGHT, PADDING]);\n\n useEffect(() => {\n const handleResize = () => {\n adjustTextareaHeight();\n };\n\n window.addEventListener('resize', handleResize);\n\n return () => {\n window.removeEventListener('resize', handleResize);\n };\n }, [adjustTextareaHeight]);\n\n useEffect(() => {\n adjustTextareaHeight();\n }, [value, adjustTextareaHeight, maxRows, isCompactMode]);\n\n const attributes: React.TextareaHTMLAttributes<HTMLTextAreaElement> = {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n 'aria-describedby': ariaDescribedby,\n 'aria-invalid': invalid ? 'true' : undefined,\n name,\n placeholder,\n autoFocus,\n className: clsx(styles.textarea, testutilStyles.textarea, {\n [styles.invalid]: invalid,\n [styles.warning]: warning,\n }),\n autoComplete: convertAutoComplete(autoComplete),\n spellCheck: spellcheck,\n disabled,\n readOnly: readOnly ? true : undefined,\n rows: minRows,\n onKeyDown: handleKeyDown,\n onKeyUp: onKeyUp && (event => fireKeyboardEvent(onKeyUp, event)),\n // We set a default value on the component in order to force it into the controlled mode.\n value: value || '',\n onChange: handleChange,\n onBlur: onBlur && (() => fireNonCancelableEvent(onBlur)),\n onFocus: onFocus && (() => fireNonCancelableEvent(onFocus)),\n };\n\n if (disableBrowserAutocorrect) {\n attributes.autoCorrect = 'off';\n attributes.autoCapitalize = 'off';\n }\n\n const action = (\n <div className={clsx(styles['primary-action'], testutilStyles['primary-action'])}>\n {customPrimaryAction ?? (\n <InternalButton\n className={clsx(styles['action-button'], testutilStyles['action-button'])}\n ariaLabel={actionButtonAriaLabel}\n disabled={disabled || readOnly || disableActionButton}\n __focusable={readOnly}\n iconName={actionButtonIconName}\n iconUrl={actionButtonIconUrl}\n iconSvg={actionButtonIconSvg}\n iconAlt={actionButtonIconAlt}\n onClick={() => fireNonCancelableEvent(onAction, { value })}\n variant=\"icon\"\n />\n )}\n </div>\n );\n\n return (\n <div\n {...baseProps}\n aria-label={ariaLabel}\n className={clsx(styles.root, testutilStyles.root, baseProps.className, {\n [styles['textarea-readonly']]: readOnly,\n [styles['textarea-invalid']]: invalid,\n [styles['textarea-warning']]: warning && !invalid,\n [styles.disabled]: disabled,\n })}\n ref={__internalRootRef}\n role=\"region\"\n >\n {secondaryContent && (\n <div\n className={clsx(styles['secondary-content'], testutilStyles['secondary-content'], {\n [styles['with-paddings']]: !disableSecondaryContentPaddings,\n [styles.invalid]: invalid,\n [styles.warning]: warning,\n })}\n >\n {secondaryContent}\n </div>\n )}\n <div className={styles['textarea-wrapper']}>\n <textarea ref={textareaRef} id={controlId} {...attributes} />\n {hasActionButton && !secondaryActions && action}\n </div>\n {secondaryActions && (\n <div\n className={clsx(styles['action-stripe'], {\n [styles.invalid]: invalid,\n [styles.warning]: warning,\n })}\n >\n <div\n className={clsx(styles['secondary-actions'], testutilStyles['secondary-actions'], {\n [styles['with-paddings']]: !disableSecondaryActionsPaddings,\n [styles['with-paddings-and-actions']]: !disableSecondaryActionsPaddings && hasActionButton,\n [styles.invalid]: invalid,\n [styles.warning]: warning,\n })}\n >\n {secondaryActions}\n </div>\n <div className={styles.buffer} onClick={() => textareaRef.current?.focus()} />\n {hasActionButton && action}\n </div>\n )}\n </div>\n );\n }\n);\n\nexport default InternalPromptInput;\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/prompt-input/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACxF,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAE/E,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAG5E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,8BAA8B,CAAC;AAM1D,MAAM,mBAAmB,GAAG,KAAK,CAAC,UAAU,CAC1C,CACE,EAiC2B,EAC3B,GAA8B,EAC9B,EAAE;QAnCF,EACE,KAAK,EACL,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EACT,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,yBAAyB,EACzB,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,EACP,SAAS,EACT,OAAO,EACP,WAA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CAAC,EAAE,OAAO;gBACzB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO;aAC1B,CAAC;YAEF,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,cAAc,CAAC,mBAAmB,CAAC,EAAE;oBAChF,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,+BAA+B;oBAC3D,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC,EAAE,CAAC,+BAA+B,IAAI,eAAe;oBAC1F,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO;oBACzB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO;iBAC1B,CAAC,IAED,gBAAgB,CACb;YACN,6BAAK,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,WAAW,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAA,EAAA,GAAI;YAC7E,eAAe,IAAI,MAAM,CACtB,CACP,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useCallback, useEffect, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useDensityMode } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalButton from '../button/internal';\nimport { convertAutoComplete } from '../input/utils';\nimport { getBaseProps } from '../internal/base-component';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { fireKeyboardEvent, fireNonCancelableEvent } from '../internal/events';\nimport * as tokens from '../internal/generated/styles/tokens';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { SomeRequired } from '../internal/types';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport { PromptInputProps } from './interfaces';\n\nimport styles from './styles.css.js';\nimport testutilStyles from './test-classes/styles.css.js';\n\ninterface InternalPromptInputProps\n extends SomeRequired<PromptInputProps, 'maxRows' | 'minRows'>,\n InternalBaseComponentProps {}\n\nconst InternalPromptInput = React.forwardRef(\n (\n {\n value,\n actionButtonAriaLabel,\n actionButtonIconName,\n actionButtonIconUrl,\n actionButtonIconSvg,\n actionButtonIconAlt,\n ariaLabel,\n autoComplete,\n autoFocus,\n disableActionButton,\n disableBrowserAutocorrect,\n disabled,\n maxRows,\n minRows,\n name,\n onAction,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n onKeyUp,\n placeholder,\n readOnly,\n spellcheck,\n customPrimaryAction,\n secondaryActions,\n secondaryContent,\n disableSecondaryActionsPaddings,\n disableSecondaryContentPaddings,\n nativeTextareaAttributes,\n __internalRootRef,\n ...rest\n }: InternalPromptInputProps,\n ref: Ref<PromptInputProps.Ref>\n ) => {\n const { ariaLabelledby, ariaDescribedby, controlId, invalid, warning } = useFormFieldContext(rest);\n\n const baseProps = getBaseProps(rest);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const isRefresh = useVisualRefresh();\n const isCompactMode = useDensityMode(textareaRef) === 'compact';\n\n const PADDING = isRefresh ? tokens.spaceXxs : tokens.spaceXxxs;\n const LINE_HEIGHT = tokens.lineHeightBodyM;\n const DEFAULT_MAX_ROWS = 3;\n\n useImperativeHandle(\n ref,\n () => ({\n focus(...args: Parameters<HTMLElement['focus']>) {\n textareaRef.current?.focus(...args);\n },\n select() {\n textareaRef.current?.select();\n },\n setSelectionRange(...args: Parameters<HTMLTextAreaElement['setSelectionRange']>) {\n textareaRef.current?.setSelectionRange(...args);\n },\n }),\n [textareaRef]\n );\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n fireKeyboardEvent(onKeyDown, event);\n\n if (event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing) {\n if (event.currentTarget.form && !event.isDefaultPrevented()) {\n event.currentTarget.form.requestSubmit();\n }\n event.preventDefault();\n fireNonCancelableEvent(onAction, { value });\n }\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n fireNonCancelableEvent(onChange, { value: event.target.value });\n adjustTextareaHeight();\n };\n\n const hasActionButton = actionButtonIconName || actionButtonIconSvg || actionButtonIconUrl || customPrimaryAction;\n\n const adjustTextareaHeight = useCallback(() => {\n if (textareaRef.current) {\n // this is required so the scrollHeight becomes dynamic, otherwise it will be locked at the highest value for the size it reached e.g. 500px\n textareaRef.current.style.height = 'auto';\n\n const minTextareaHeight = `calc(${LINE_HEIGHT} + ${tokens.spaceScaledXxs} * 2)`; // the min height of Textarea with 1 row\n\n if (maxRows === -1) {\n const scrollHeight = `calc(${textareaRef.current.scrollHeight}px)`;\n textareaRef.current.style.height = `max(${scrollHeight}, ${minTextareaHeight})`;\n } else {\n const maxRowsHeight = `calc(${maxRows <= 0 ? DEFAULT_MAX_ROWS : maxRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})`;\n const scrollHeight = `calc(${textareaRef.current.scrollHeight}px)`;\n textareaRef.current.style.height = `min(max(${scrollHeight}, ${minTextareaHeight}), ${maxRowsHeight})`;\n }\n }\n }, [maxRows, LINE_HEIGHT, PADDING]);\n\n useEffect(() => {\n const handleResize = () => {\n adjustTextareaHeight();\n };\n\n window.addEventListener('resize', handleResize);\n\n return () => {\n window.removeEventListener('resize', handleResize);\n };\n }, [adjustTextareaHeight]);\n\n useEffect(() => {\n adjustTextareaHeight();\n }, [value, adjustTextareaHeight, maxRows, isCompactMode]);\n\n const attributes: React.TextareaHTMLAttributes<HTMLTextAreaElement> = {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n 'aria-describedby': ariaDescribedby,\n 'aria-invalid': invalid ? 'true' : undefined,\n name,\n placeholder,\n autoFocus,\n className: clsx(styles.textarea, testutilStyles.textarea, {\n [styles.invalid]: invalid,\n [styles.warning]: warning,\n }),\n autoComplete: convertAutoComplete(autoComplete),\n spellCheck: spellcheck,\n disabled,\n readOnly: readOnly ? true : undefined,\n rows: minRows,\n onKeyDown: handleKeyDown,\n onKeyUp: onKeyUp && (event => fireKeyboardEvent(onKeyUp, event)),\n // We set a default value on the component in order to force it into the controlled mode.\n value: value || '',\n onChange: handleChange,\n onBlur: onBlur && (() => fireNonCancelableEvent(onBlur)),\n onFocus: onFocus && (() => fireNonCancelableEvent(onFocus)),\n };\n\n if (disableBrowserAutocorrect) {\n attributes.autoCorrect = 'off';\n attributes.autoCapitalize = 'off';\n }\n\n const action = (\n <div className={clsx(styles['primary-action'], testutilStyles['primary-action'])}>\n {customPrimaryAction ?? (\n <InternalButton\n className={clsx(styles['action-button'], testutilStyles['action-button'])}\n ariaLabel={actionButtonAriaLabel}\n disabled={disabled || readOnly || disableActionButton}\n __focusable={readOnly}\n iconName={actionButtonIconName}\n iconUrl={actionButtonIconUrl}\n iconSvg={actionButtonIconSvg}\n iconAlt={actionButtonIconAlt}\n onClick={() => fireNonCancelableEvent(onAction, { value })}\n variant=\"icon\"\n />\n )}\n </div>\n );\n\n return (\n <div\n {...baseProps}\n aria-label={ariaLabel}\n className={clsx(styles.root, testutilStyles.root, baseProps.className, {\n [styles['textarea-readonly']]: readOnly,\n [styles['textarea-invalid']]: invalid,\n [styles['textarea-warning']]: warning && !invalid,\n [styles.disabled]: disabled,\n })}\n ref={__internalRootRef}\n role=\"region\"\n >\n {secondaryContent && (\n <div\n className={clsx(styles['secondary-content'], testutilStyles['secondary-content'], {\n [styles['with-paddings']]: !disableSecondaryContentPaddings,\n [styles.invalid]: invalid,\n [styles.warning]: warning,\n })}\n >\n {secondaryContent}\n </div>\n )}\n <div className={styles['textarea-wrapper']}>\n <WithNativeAttributes\n {...attributes}\n tag=\"textarea\"\n componentName=\"PromptInput\"\n nativeAttributes={nativeTextareaAttributes}\n ref={textareaRef}\n id={controlId}\n />\n {hasActionButton && !secondaryActions && action}\n </div>\n {secondaryActions && (\n <div\n className={clsx(styles['action-stripe'], {\n [styles.invalid]: invalid,\n [styles.warning]: warning,\n })}\n >\n <div\n className={clsx(styles['secondary-actions'], testutilStyles['secondary-actions'], {\n [styles['with-paddings']]: !disableSecondaryActionsPaddings,\n [styles['with-paddings-and-actions']]: !disableSecondaryActionsPaddings && hasActionButton,\n [styles.invalid]: invalid,\n [styles.warning]: warning,\n })}\n >\n {secondaryActions}\n </div>\n <div className={styles.buffer} onClick={() => textareaRef.current?.focus()} />\n {hasActionButton && action}\n </div>\n )}\n </div>\n );\n }\n);\n\nexport default InternalPromptInput;\n"]}
@@ -5,5 +5,5 @@ export interface FilterProps extends InternalInputProps {
5
5
  ref?: React.Ref<HTMLInputElement>;
6
6
  filteringType: SelectProps.FilteringType;
7
7
  }
8
- declare const Filter: React.ForwardRefExoticComponent<Pick<FilterProps, "disabled" | "autoComplete" | "autoFocus" | "name" | "className" | "id" | "placeholder" | "inputMode" | "type" | "readOnly" | "step" | "value" | "onFocus" | "onBlur" | "onChange" | "onKeyDown" | "onKeyUp" | "warning" | "clearAriaLabel" | "ariaLabel" | "__internalRootRef" | "ariaLabelledby" | "ariaDescribedby" | "__injectAnalyticsComponentMetadata" | "invalid" | "controlId" | "filteringType" | "ariaRequired" | "disableBrowserAutocorrect" | "spellcheck" | "__leftIcon" | "__leftIconVariant" | "__onLeftIconClick" | "__rightIcon" | "__onRightIconClick" | "__nativeAttributes" | "__noBorderRadius" | "__onDelayedInput" | "__onBlurWithDetail" | "__inheritFormFieldProps"> & React.RefAttributes<HTMLInputElement>>;
8
+ declare const Filter: React.ForwardRefExoticComponent<Pick<FilterProps, "disabled" | "autoComplete" | "autoFocus" | "name" | "className" | "id" | "placeholder" | "inputMode" | "type" | "readOnly" | "step" | "value" | "onFocus" | "onBlur" | "onChange" | "onKeyDown" | "onKeyUp" | "warning" | "clearAriaLabel" | "ariaLabel" | "__internalRootRef" | "ariaLabelledby" | "ariaDescribedby" | "__injectAnalyticsComponentMetadata" | "__skipNativeAttributesWarnings" | "invalid" | "controlId" | "filteringType" | "ariaRequired" | "nativeInputAttributes" | "disableBrowserAutocorrect" | "spellcheck" | "__leftIcon" | "__leftIconVariant" | "__onLeftIconClick" | "__rightIcon" | "__onRightIconClick" | "__noBorderRadius" | "__onDelayedInput" | "__onBlurWithDetail" | "__inheritFormFieldProps"> & React.RefAttributes<HTMLInputElement>>;
9
9
  export default Filter;
@@ -1 +1 @@
1
- {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../../src/select/parts/filter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAsB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,MAAM,WAAW,WAAY,SAAQ,kBAAkB;IACrD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClC,aAAa,EAAE,WAAW,CAAC,aAAa,CAAC;CAC1C;AAED,QAAA,MAAM,MAAM,2vBAyBV,CAAC;AAEH,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../../src/select/parts/filter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAsB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,MAAM,WAAW,WAAY,SAAQ,kBAAkB;IACrD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClC,aAAa,EAAE,WAAW,CAAC,aAAa,CAAC;CAC1C;AAED,QAAA,MAAM,MAAM,iyBA0BV,CAAC;AAEH,eAAe,MAAM,CAAC"}