@cloudscape-design/components-themeable 3.0.951 → 3.0.952

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.
@@ -1113,6 +1113,10 @@ export var preset = {
1113
1113
  "light": "{colorBlue100}",
1114
1114
  "dark": "{colorBlue900}"
1115
1115
  },
1116
+ "colorBackgroundDialog": {
1117
+ "light": "{colorBackgroundStatusInfo}",
1118
+ "dark": "{colorBackgroundStatusInfo}"
1119
+ },
1116
1120
  "colorBackgroundStatusSuccess": {
1117
1121
  "light": "{colorGreen100}",
1118
1122
  "dark": "{colorGreen900}"
@@ -1373,6 +1377,10 @@ export var preset = {
1373
1377
  "light": "{colorYellow800}",
1374
1378
  "dark": "{colorYellow700}"
1375
1379
  },
1380
+ "colorBorderDialog": {
1381
+ "light": "{colorBorderStatusInfo}",
1382
+ "dark": "{colorBorderStatusInfo}"
1383
+ },
1376
1384
  "colorBorderDividerInteractiveDefault": {
1377
1385
  "light": "{colorGrey500}",
1378
1386
  "dark": "{colorGrey300}"
@@ -1928,8 +1936,11 @@ export var preset = {
1928
1936
  "borderLinkFocusRingOutline": "0",
1929
1937
  "borderLinkFocusRingShadowSpread": "2px",
1930
1938
  "borderWidthAlert": "2px",
1939
+ "borderWidthButton": "2px",
1940
+ "borderWidthDropdown": "2px",
1931
1941
  "borderWidthField": "2px",
1932
1942
  "borderWidthPopover": "2px",
1943
+ "borderWidthToken": "2px",
1933
1944
  "motionDurationExtraFast": {
1934
1945
  "default": "45ms",
1935
1946
  "disabled": "0ms"
@@ -3358,6 +3369,10 @@ export var preset = {
3358
3369
  "light": "{colorBlue900}",
3359
3370
  "dark": "{colorBlue900}"
3360
3371
  },
3372
+ "colorBackgroundDialog": {
3373
+ "light": "{colorBackgroundStatusInfo}",
3374
+ "dark": "{colorBackgroundStatusInfo}"
3375
+ },
3361
3376
  "colorBackgroundStatusSuccess": {
3362
3377
  "light": "{colorGreen900}",
3363
3378
  "dark": "{colorGreen900}"
@@ -3618,6 +3633,10 @@ export var preset = {
3618
3633
  "light": "{colorYellow700}",
3619
3634
  "dark": "{colorYellow700}"
3620
3635
  },
3636
+ "colorBorderDialog": {
3637
+ "light": "{colorBorderStatusInfo}",
3638
+ "dark": "{colorBorderStatusInfo}"
3639
+ },
3621
3640
  "colorBorderDividerInteractiveDefault": {
3622
3641
  "light": "{colorGrey300}",
3623
3642
  "dark": "{colorGrey300}"
@@ -4504,6 +4523,10 @@ export var preset = {
4504
4523
  "light": "{colorBlue900}",
4505
4524
  "dark": "{colorBlue900}"
4506
4525
  },
4526
+ "colorBackgroundDialog": {
4527
+ "light": "{colorBackgroundStatusInfo}",
4528
+ "dark": "{colorBackgroundStatusInfo}"
4529
+ },
4507
4530
  "colorBackgroundStatusSuccess": {
4508
4531
  "light": "{colorGreen900}",
4509
4532
  "dark": "{colorGreen900}"
@@ -4764,6 +4787,10 @@ export var preset = {
4764
4787
  "light": "{colorYellow700}",
4765
4788
  "dark": "{colorYellow700}"
4766
4789
  },
4790
+ "colorBorderDialog": {
4791
+ "light": "{colorBorderStatusInfo}",
4792
+ "dark": "{colorBorderStatusInfo}"
4793
+ },
4767
4794
  "colorBorderDividerInteractiveDefault": {
4768
4795
  "light": "{colorGrey300}",
4769
4796
  "dark": "{colorGrey300}"
@@ -5582,6 +5609,10 @@ export var preset = {
5582
5609
  "light": "{colorBlue100}",
5583
5610
  "dark": "{colorBlue900}"
5584
5611
  },
5612
+ "colorBackgroundDialog": {
5613
+ "light": "{colorBackgroundStatusInfo}",
5614
+ "dark": "{colorBackgroundStatusInfo}"
5615
+ },
5585
5616
  "colorBackgroundStatusSuccess": {
5586
5617
  "light": "{colorGreen100}",
5587
5618
  "dark": "{colorGreen900}"
@@ -5842,6 +5873,10 @@ export var preset = {
5842
5873
  "light": "{colorYellow800}",
5843
5874
  "dark": "{colorYellow700}"
5844
5875
  },
5876
+ "colorBorderDialog": {
5877
+ "light": "{colorBorderStatusInfo}",
5878
+ "dark": "{colorBorderStatusInfo}"
5879
+ },
5845
5880
  "colorBorderDividerInteractiveDefault": {
5846
5881
  "light": "{colorGrey500}",
5847
5882
  "dark": "{colorGrey300}"
@@ -6660,6 +6695,10 @@ export var preset = {
6660
6695
  "light": "{colorBlue100}",
6661
6696
  "dark": "{colorBlue900}"
6662
6697
  },
6698
+ "colorBackgroundDialog": {
6699
+ "light": "{colorBackgroundStatusInfo}",
6700
+ "dark": "{colorBackgroundStatusInfo}"
6701
+ },
6663
6702
  "colorBackgroundStatusSuccess": {
6664
6703
  "light": "{colorGreen100}",
6665
6704
  "dark": "{colorGreen900}"
@@ -6920,6 +6959,10 @@ export var preset = {
6920
6959
  "light": "{colorYellow800}",
6921
6960
  "dark": "{colorYellow700}"
6922
6961
  },
6962
+ "colorBorderDialog": {
6963
+ "light": "{colorBorderStatusInfo}",
6964
+ "dark": "{colorBorderStatusInfo}"
6965
+ },
6923
6966
  "colorBorderDividerInteractiveDefault": {
6924
6967
  "light": "{colorGrey500}",
6925
6968
  "dark": "{colorGrey300}"
@@ -7738,6 +7781,10 @@ export var preset = {
7738
7781
  "light": "{colorBlue100}",
7739
7782
  "dark": "{colorBlue900}"
7740
7783
  },
7784
+ "colorBackgroundDialog": {
7785
+ "light": "{colorBackgroundStatusInfo}",
7786
+ "dark": "{colorBackgroundStatusInfo}"
7787
+ },
7741
7788
  "colorBackgroundStatusSuccess": {
7742
7789
  "light": "{colorGreen100}",
7743
7790
  "dark": "{colorGreen900}"
@@ -7998,6 +8045,10 @@ export var preset = {
7998
8045
  "light": "{colorYellow800}",
7999
8046
  "dark": "{colorYellow700}"
8000
8047
  },
8048
+ "colorBorderDialog": {
8049
+ "light": "{colorBorderStatusInfo}",
8050
+ "dark": "{colorBorderStatusInfo}"
8051
+ },
8001
8052
  "colorBorderDividerInteractiveDefault": {
8002
8053
  "light": "{colorGrey500}",
8003
8054
  "dark": "{colorGrey300}"
@@ -8818,6 +8869,10 @@ export var preset = {
8818
8869
  "light": "{colorBlue900}",
8819
8870
  "dark": "{colorBlue900}"
8820
8871
  },
8872
+ "colorBackgroundDialog": {
8873
+ "light": "{colorBackgroundStatusInfo}",
8874
+ "dark": "{colorBackgroundStatusInfo}"
8875
+ },
8821
8876
  "colorBackgroundStatusSuccess": {
8822
8877
  "light": "{colorGreen900}",
8823
8878
  "dark": "{colorGreen900}"
@@ -9078,6 +9133,10 @@ export var preset = {
9078
9133
  "light": "{colorYellow700}",
9079
9134
  "dark": "{colorYellow700}"
9080
9135
  },
9136
+ "colorBorderDialog": {
9137
+ "light": "{colorBorderStatusInfo}",
9138
+ "dark": "{colorBorderStatusInfo}"
9139
+ },
9081
9140
  "colorBorderDividerInteractiveDefault": {
9082
9141
  "light": "{colorGrey300}",
9083
9142
  "dark": "{colorGrey300}"
@@ -9805,6 +9864,7 @@ export var preset = {
9805
9864
  "colorBackgroundSliderWarningPressed": "color",
9806
9865
  "colorBackgroundStatusError": "color",
9807
9866
  "colorBackgroundStatusInfo": "color",
9867
+ "colorBackgroundDialog": "color",
9808
9868
  "colorBackgroundStatusSuccess": "color",
9809
9869
  "colorBackgroundStatusWarning": "color",
9810
9870
  "colorBackgroundTableHeader": "color",
@@ -9870,6 +9930,7 @@ export var preset = {
9870
9930
  "colorBorderStatusInfo": "color",
9871
9931
  "colorBorderStatusSuccess": "color",
9872
9932
  "colorBorderStatusWarning": "color",
9933
+ "colorBorderDialog": "color",
9873
9934
  "colorBorderDividerInteractiveDefault": "color",
9874
9935
  "colorBorderTabsDivider": "color",
9875
9936
  "colorBorderTabsShadow": "color",
@@ -10270,6 +10331,7 @@ export var preset = {
10270
10331
  "colorBackgroundSegmentHover",
10271
10332
  "colorBackgroundStatusError",
10272
10333
  "colorBackgroundStatusInfo",
10334
+ "colorBackgroundDialog",
10273
10335
  "colorBackgroundStatusSuccess",
10274
10336
  "colorBackgroundStatusWarning",
10275
10337
  "colorBackgroundToggleCheckedDisabled",
@@ -10303,6 +10365,7 @@ export var preset = {
10303
10365
  "colorBorderStatusInfo",
10304
10366
  "colorBorderStatusSuccess",
10305
10367
  "colorBorderStatusWarning",
10368
+ "colorBorderDialog",
10306
10369
  "colorForegroundControlDefault",
10307
10370
  "colorForegroundControlDisabled",
10308
10371
  "colorForegroundControlReadOnly",
@@ -10401,8 +10464,11 @@ export var preset = {
10401
10464
  "borderRadiusToken",
10402
10465
  "borderRadiusTutorialPanelItem",
10403
10466
  "borderWidthAlert",
10467
+ "borderWidthButton",
10468
+ "borderWidthDropdown",
10404
10469
  "borderWidthField",
10405
- "borderWidthPopover"
10470
+ "borderWidthPopover",
10471
+ "borderWidthToken"
10406
10472
  ],
10407
10473
  "exposed": [
10408
10474
  "colorChartsRed300",
@@ -10610,6 +10676,7 @@ export var preset = {
10610
10676
  "colorBackgroundSegmentHover",
10611
10677
  "colorBackgroundStatusError",
10612
10678
  "colorBackgroundStatusInfo",
10679
+ "colorBackgroundDialog",
10613
10680
  "colorBackgroundStatusSuccess",
10614
10681
  "colorBackgroundStatusWarning",
10615
10682
  "colorBackgroundToggleCheckedDisabled",
@@ -10647,6 +10714,7 @@ export var preset = {
10647
10714
  "colorBorderStatusInfo",
10648
10715
  "colorBorderStatusSuccess",
10649
10716
  "colorBorderStatusWarning",
10717
+ "colorBorderDialog",
10650
10718
  "colorForegroundControlDefault",
10651
10719
  "colorForegroundControlDisabled",
10652
10720
  "colorForegroundControlReadOnly",
@@ -10748,8 +10816,11 @@ export var preset = {
10748
10816
  "borderRadiusChatBubble",
10749
10817
  "borderRadiusTutorialPanelItem",
10750
10818
  "borderWidthAlert",
10819
+ "borderWidthButton",
10820
+ "borderWidthDropdown",
10751
10821
  "borderWidthField",
10752
10822
  "borderWidthPopover",
10823
+ "borderWidthToken",
10753
10824
  "motionDurationAvatarGenAiGradient",
10754
10825
  "motionDurationAvatarLoadingDots",
10755
10826
  "motionEasingAvatarGenAiGradient",
@@ -11095,6 +11166,7 @@ export var preset = {
11095
11166
  "colorBackgroundSliderWarningPressed": "color-background-slider-warning-pressed",
11096
11167
  "colorBackgroundStatusError": "color-background-status-error",
11097
11168
  "colorBackgroundStatusInfo": "color-background-status-info",
11169
+ "colorBackgroundDialog": "color-background-dialog",
11098
11170
  "colorBackgroundStatusSuccess": "color-background-status-success",
11099
11171
  "colorBackgroundStatusWarning": "color-background-status-warning",
11100
11172
  "colorBackgroundTableHeader": "color-background-table-header",
@@ -11160,6 +11232,7 @@ export var preset = {
11160
11232
  "colorBorderStatusInfo": "color-border-status-info",
11161
11233
  "colorBorderStatusSuccess": "color-border-status-success",
11162
11234
  "colorBorderStatusWarning": "color-border-status-warning",
11235
+ "colorBorderDialog": "color-border-dialog",
11163
11236
  "colorBorderDividerInteractiveDefault": "color-border-divider-interactive-default",
11164
11237
  "colorBorderTabsDivider": "color-border-tabs-divider",
11165
11238
  "colorBorderTabsShadow": "color-border-tabs-shadow",
@@ -11364,8 +11437,11 @@ export var preset = {
11364
11437
  "borderLinkFocusRingOutline": "border-link-focus-ring-outline",
11365
11438
  "borderLinkFocusRingShadowSpread": "border-link-focus-ring-shadow-spread",
11366
11439
  "borderWidthAlert": "border-width-alert",
11440
+ "borderWidthButton": "border-width-button",
11441
+ "borderWidthDropdown": "border-width-dropdown",
11367
11442
  "borderWidthField": "border-width-field",
11368
11443
  "borderWidthPopover": "border-width-popover",
11444
+ "borderWidthToken": "border-width-token",
11369
11445
  "motionDurationExtraFast": "motion-duration-extra-fast",
11370
11446
  "motionDurationExtraSlow": "motion-duration-extra-slow",
11371
11447
  "motionDurationFast": "motion-duration-fast",
@@ -11844,6 +11920,7 @@ export var preset = {
11844
11920
  "colorBackgroundSliderWarningPressed": "--color-background-slider-warning-pressed-pg5aih",
11845
11921
  "colorBackgroundStatusError": "--color-background-status-error-5fz45j",
11846
11922
  "colorBackgroundStatusInfo": "--color-background-status-info-gflgo4",
11923
+ "colorBackgroundDialog": "--color-background-dialog-wtz1wl",
11847
11924
  "colorBackgroundStatusSuccess": "--color-background-status-success-ua29ej",
11848
11925
  "colorBackgroundStatusWarning": "--color-background-status-warning-03nxlw",
11849
11926
  "colorBackgroundTableHeader": "--color-background-table-header-inc72b",
@@ -11909,6 +11986,7 @@ export var preset = {
11909
11986
  "colorBorderStatusInfo": "--color-border-status-info-z6pwqy",
11910
11987
  "colorBorderStatusSuccess": "--color-border-status-success-4x6srk",
11911
11988
  "colorBorderStatusWarning": "--color-border-status-warning-3feumr",
11989
+ "colorBorderDialog": "--color-border-dialog-u915ow",
11912
11990
  "colorBorderDividerInteractiveDefault": "--color-border-divider-interactive-default-0c10au",
11913
11991
  "colorBorderTabsDivider": "--color-border-tabs-divider-djfdfj",
11914
11992
  "colorBorderTabsShadow": "--color-border-tabs-shadow-enjrr2",
@@ -12113,8 +12191,11 @@ export var preset = {
12113
12191
  "borderLinkFocusRingOutline": "--border-link-focus-ring-outline-kkfop6",
12114
12192
  "borderLinkFocusRingShadowSpread": "--border-link-focus-ring-shadow-spread-v8hkrl",
12115
12193
  "borderWidthAlert": "--border-width-alert-t0f3yn",
12194
+ "borderWidthButton": "--border-width-button-ru6lbi",
12195
+ "borderWidthDropdown": "--border-width-dropdown-hh98qt",
12116
12196
  "borderWidthField": "--border-width-field-h1g7tw",
12117
12197
  "borderWidthPopover": "--border-width-popover-h2a419",
12198
+ "borderWidthToken": "--border-width-token-zo28pf",
12118
12199
  "motionDurationExtraFast": "--motion-duration-extra-fast-3huyux",
12119
12200
  "motionDurationExtraSlow": "--motion-duration-extra-slow-ngjb9g",
12120
12201
  "motionDurationFast": "--motion-duration-fast-sbm3r7",
@@ -62,6 +62,7 @@ export interface PromptInputProps extends BaseInputProps, InputKeyEvents, InputA
62
62
  minRows?: number;
63
63
  /**
64
64
  * Specifies the maximum number of lines of text the textarea will expand to.
65
+ * Defaults to 3. Use -1 for infinite rows.
65
66
  */
66
67
  maxRows?: number;
67
68
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/prompt-input/interfaces.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,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AC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEnC;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEnC;;OAEG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAC;IAE1C;;OAEG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAC;CAC3C;AAED,yBAAiB,gBAAgB,CAAC;IAChC,KAAY,SAAS,GAAG,aAAa,CAAC;IACtC,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 */\n maxRows?: number;\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\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 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 +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,uGA0MxB,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;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,uGAmNxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -22,6 +22,7 @@ const InternalPromptInput = React.forwardRef((_a, ref) => {
22
22
  const isCompactMode = useDensityMode(textareaRef) === 'compact';
23
23
  const PADDING = isRefresh ? tokens.spaceXxs : tokens.spaceXxxs;
24
24
  const LINE_HEIGHT = tokens.lineHeightBodyM;
25
+ const DEFAULT_MAX_ROWS = 3;
25
26
  useImperativeHandle(ref, () => ({
26
27
  focus(...args) {
27
28
  var _a;
@@ -53,11 +54,18 @@ const InternalPromptInput = React.forwardRef((_a, ref) => {
53
54
  const hasActionButton = actionButtonIconName || actionButtonIconSvg || actionButtonIconUrl;
54
55
  const adjustTextareaHeight = useCallback(() => {
55
56
  if (textareaRef.current) {
57
+ // 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
56
58
  textareaRef.current.style.height = 'auto';
57
- const maxRowsHeight = `calc(${maxRows <= 0 ? 3 : maxRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})`;
58
- const scrollHeight = `calc(${textareaRef.current.scrollHeight}px)`;
59
59
  const minTextareaHeight = `calc(${LINE_HEIGHT} + ${tokens.spaceScaledXxs} * 2)`; // the min height of Textarea with 1 row
60
- textareaRef.current.style.height = `min(max(${scrollHeight}, ${minTextareaHeight}), ${maxRowsHeight})`;
60
+ if (maxRows === -1) {
61
+ const scrollHeight = `calc(${textareaRef.current.scrollHeight}px)`;
62
+ textareaRef.current.style.height = `max(${scrollHeight}, ${minTextareaHeight})`;
63
+ }
64
+ else {
65
+ const maxRowsHeight = `calc(${maxRows <= 0 ? DEFAULT_MAX_ROWS : maxRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})`;
66
+ const scrollHeight = `calc(${textareaRef.current.scrollHeight}px)`;
67
+ textareaRef.current.style.height = `min(max(${scrollHeight}, ${minTextareaHeight}), ${maxRowsHeight})`;
68
+ }
61
69
  }
62
70
  }, [maxRows, LINE_HEIGHT, PADDING]);
63
71
  useEffect(() => {
@@ -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,CA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AAgB;YACjB,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 secondaryActions,\n secondaryContent,\n disableSecondaryActionsPaddings,\n disableSecondaryContentPaddings,\n __internalRootRef = null,\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\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) {\n if ('form' in event.target && event.target.form !== null && !event.isDefaultPrevented()) {\n (event.target.form as HTMLFormElement).requestSubmit();\n }\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;\n\n const adjustTextareaHeight = useCallback(() => {\n if (textareaRef.current) {\n textareaRef.current.style.height = 'auto';\n const maxRowsHeight = `calc(${maxRows <= 0 ? 3 : maxRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})`;\n const scrollHeight = `calc(${textareaRef.current.scrollHeight}px)`;\n const minTextareaHeight = `calc(${LINE_HEIGHT} + ${tokens.spaceScaledXxs} * 2)`; // the min height of Textarea with 1 row\n textareaRef.current.style.height = `min(max(${scrollHeight}, ${minTextareaHeight}), ${maxRowsHeight})`;\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={styles.button}>\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 </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['secondary-actions'], testutilStyles['secondary-actions'], {\n [styles['with-paddings']]: !disableSecondaryActionsPaddings,\n [styles.invalid]: invalid,\n [styles.warning]: warning,\n })}\n >\n {secondaryActions}\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,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DAAU,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,IAAM,UAAU,EAAI;YAC5D,eAAe,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAC3C;QACL,gBAAgB,IAAI,CACnB,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,cAAc,CAAC,mBAAmB,CAAC,EAAE;gBAChF,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,+BAA+B;gBAC3D,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO;gBACzB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO;aAC1B,CAAC;YAED,gBAAgB;YACjB,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 secondaryActions,\n secondaryContent,\n disableSecondaryActionsPaddings,\n disableSecondaryContentPaddings,\n __internalRootRef = null,\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) {\n if ('form' in event.target && event.target.form !== null && !event.isDefaultPrevented()) {\n (event.target.form as HTMLFormElement).requestSubmit();\n }\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;\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={styles.button}>\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 </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['secondary-actions'], testutilStyles['secondary-actions'], {\n [styles['with-paddings']]: !disableSecondaryActionsPaddings,\n [styles.invalid]: invalid,\n [styles.warning]: warning,\n })}\n >\n {secondaryActions}\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudscape-design/components-themeable",
3
- "version": "3.0.951",
3
+ "version": "3.0.952",
4
4
  "files": [
5
5
  "lib"
6
6
  ],