@cloudscape-design/components 3.0.685 → 3.0.687

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 (114) hide show
  1. package/annotation-context/annotation/styles.css.js +24 -24
  2. package/annotation-context/annotation/styles.scoped.css +31 -31
  3. package/annotation-context/annotation/styles.selectors.js +24 -24
  4. package/app-layout/notifications/styles.css.js +3 -3
  5. package/app-layout/notifications/styles.scoped.css +7 -7
  6. package/app-layout/notifications/styles.selectors.js +3 -3
  7. package/app-layout/visual-refresh/styles.css.js +82 -82
  8. package/app-layout/visual-refresh/styles.scoped.css +255 -255
  9. package/app-layout/visual-refresh/styles.selectors.js +82 -82
  10. package/app-layout/visual-refresh-toolbar/drawer/index.d.ts.map +1 -1
  11. package/app-layout/visual-refresh-toolbar/drawer/index.js +2 -1
  12. package/app-layout/visual-refresh-toolbar/drawer/index.js.map +1 -1
  13. package/app-layout/visual-refresh-toolbar/navigation/styles.css.js +6 -6
  14. package/app-layout/visual-refresh-toolbar/navigation/styles.scoped.css +13 -13
  15. package/app-layout/visual-refresh-toolbar/navigation/styles.selectors.js +6 -6
  16. package/app-layout/visual-refresh-toolbar/skeleton/styles.css.js +16 -16
  17. package/app-layout/visual-refresh-toolbar/skeleton/styles.scoped.css +37 -37
  18. package/app-layout/visual-refresh-toolbar/skeleton/styles.selectors.js +16 -16
  19. package/app-layout/visual-refresh-toolbar/toolbar/index.js +1 -1
  20. package/app-layout/visual-refresh-toolbar/toolbar/index.js.map +1 -1
  21. package/button/interfaces.d.ts +1 -1
  22. package/button/interfaces.js.map +1 -1
  23. package/button-dropdown/item-element/index.js +1 -1
  24. package/button-dropdown/item-element/index.js.map +1 -1
  25. package/button-dropdown/item-element/styles.css.js +12 -11
  26. package/button-dropdown/item-element/styles.scoped.css +14 -14
  27. package/button-dropdown/item-element/styles.selectors.js +12 -11
  28. package/button-dropdown/tooltip.d.ts +2 -1
  29. package/button-dropdown/tooltip.d.ts.map +1 -1
  30. package/button-dropdown/tooltip.js +2 -2
  31. package/button-dropdown/tooltip.js.map +1 -1
  32. package/container/internal.d.ts.map +1 -1
  33. package/container/internal.js +0 -3
  34. package/container/internal.js.map +1 -1
  35. package/container/styles.css.js +30 -31
  36. package/container/styles.scoped.css +54 -57
  37. package/container/styles.selectors.js +30 -31
  38. package/content-layout/styles.css.js +14 -14
  39. package/content-layout/styles.scoped.css +27 -27
  40. package/content-layout/styles.selectors.js +14 -14
  41. package/flashbar/styles.css.js +47 -47
  42. package/flashbar/styles.scoped.css +171 -171
  43. package/flashbar/styles.selectors.js +47 -47
  44. package/icon/styles.css.js +38 -37
  45. package/icon/styles.scoped.css +82 -80
  46. package/icon/styles.selectors.js +38 -37
  47. package/index.d.ts +1 -0
  48. package/index.d.ts.map +1 -1
  49. package/index.js +1 -0
  50. package/index.js.map +1 -1
  51. package/internal/components/dropdown/styles.css.js +20 -20
  52. package/internal/components/dropdown/styles.scoped.css +40 -40
  53. package/internal/components/dropdown/styles.selectors.js +20 -20
  54. package/internal/environment.js +1 -1
  55. package/internal/environment.json +1 -1
  56. package/internal/generated/custom-css-properties/index.d.ts +2 -0
  57. package/internal/generated/custom-css-properties/index.d.ts.map +1 -1
  58. package/internal/generated/custom-css-properties/index.js +57 -55
  59. package/internal/generated/custom-css-properties/index.js.map +1 -1
  60. package/internal/manifest.json +1 -1
  61. package/key-value-pairs/index.d.ts +1 -1
  62. package/key-value-pairs/index.d.ts.map +1 -1
  63. package/key-value-pairs/index.js +2 -2
  64. package/key-value-pairs/index.js.map +1 -1
  65. package/key-value-pairs/interfaces.d.ts +11 -0
  66. package/key-value-pairs/interfaces.d.ts.map +1 -1
  67. package/key-value-pairs/interfaces.js.map +1 -1
  68. package/key-value-pairs/internal.d.ts.map +1 -1
  69. package/key-value-pairs/internal.js +2 -2
  70. package/key-value-pairs/internal.js.map +1 -1
  71. package/package.json +2 -1
  72. package/prompt-input/index.d.ts +6 -0
  73. package/prompt-input/index.d.ts.map +1 -0
  74. package/prompt-input/index.js +27 -0
  75. package/prompt-input/index.js.map +1 -0
  76. package/prompt-input/interfaces.d.ts +82 -0
  77. package/prompt-input/interfaces.d.ts.map +1 -0
  78. package/prompt-input/interfaces.js +2 -0
  79. package/prompt-input/interfaces.js.map +1 -0
  80. package/prompt-input/internal.d.ts +8 -0
  81. package/prompt-input/internal.d.ts.map +1 -0
  82. package/prompt-input/internal.js +109 -0
  83. package/prompt-input/internal.js.map +1 -0
  84. package/prompt-input/styles.css.js +13 -0
  85. package/prompt-input/styles.scoped.css +248 -0
  86. package/prompt-input/styles.selectors.js +14 -0
  87. package/prompt-input/test-classes/styles.css.js +8 -0
  88. package/prompt-input/test-classes/styles.scoped.css +15 -0
  89. package/prompt-input/test-classes/styles.selectors.js +9 -0
  90. package/slider/styles.css.js +26 -26
  91. package/slider/styles.scoped.css +86 -86
  92. package/slider/styles.selectors.js +26 -26
  93. package/spinner/styles.css.js +13 -13
  94. package/spinner/styles.scoped.css +39 -39
  95. package/spinner/styles.selectors.js +13 -13
  96. package/split-panel/bottom.d.ts.map +1 -1
  97. package/split-panel/bottom.js +3 -0
  98. package/split-panel/bottom.js.map +1 -1
  99. package/split-panel/styles.css.js +27 -26
  100. package/split-panel/styles.scoped.css +44 -41
  101. package/split-panel/styles.selectors.js +27 -26
  102. package/test-utils/dom/index.d.ts +3 -0
  103. package/test-utils/dom/index.js +10 -2
  104. package/test-utils/dom/index.js.map +1 -1
  105. package/test-utils/dom/prompt-input/index.d.ts +18 -0
  106. package/test-utils/dom/prompt-input/index.js +49 -0
  107. package/test-utils/dom/prompt-input/index.js.map +1 -0
  108. package/test-utils/selectors/index.d.ts +3 -0
  109. package/test-utils/selectors/index.js +10 -2
  110. package/test-utils/selectors/index.js.map +1 -1
  111. package/test-utils/selectors/prompt-input/index.d.ts +6 -0
  112. package/test-utils/selectors/prompt-input/index.js +15 -0
  113. package/test-utils/selectors/prompt-input/index.js.map +1 -0
  114. package/test-utils/tsconfig.tsbuildinfo +1 -1
@@ -24,6 +24,17 @@ export interface KeyValuePairsProps extends BaseComponentProps {
24
24
  * key-value pair items.
25
25
  */
26
26
  items: ReadonlyArray<KeyValuePairsProps.Item>;
27
+ /**
28
+ * Provides an `aria-label` to the Key-value pairs container.
29
+ * Don't use `ariaLabel` and `ariaLabelledby` at the same time.
30
+ */
31
+ ariaLabel?: string;
32
+ /**
33
+ * Sets the `aria-labelledby` property on the Key-value pairs container.
34
+ * If there's a visible label element that you can reference, use this instead of `ariaLabel`.
35
+ * Don't use `ariaLabel` and `ariaLabelledby` at the same time.
36
+ */
37
+ ariaLabelledby?: string;
27
38
  }
28
39
  export declare namespace KeyValuePairsProps {
29
40
  type Item = Group | Pair;
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/key-value-pairs/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,EAAE,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED,yBAAiB,kBAAkB,CAAC;IAClC,KAAY,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC;IAEhC,UAAiB,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;KAC5B;IAED,UAAiB,IAAK,SAAQ,kBAAkB;QAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;QACvB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;KACxB;CACF"}
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/key-value-pairs/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,EAAE,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC9C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,yBAAiB,kBAAkB,CAAC;IAClC,KAAY,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC;IAEhC,UAAiB,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;KAC5B;IAED,UAAiB,IAAK,SAAQ,kBAAkB;QAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;QACvB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;KACxB;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/key-value-pairs/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport React from 'react';\n\nexport interface KeyValuePairsProps extends BaseComponentProps {\n /**\n * Specifies the number of columns in each grid row.\n * Valid values are any integer between 1 and 4. It defaults to 1.\n */\n columns?: number;\n /**\n * An array of either key-value pairs individual items or groups.\n * They could be combined.\n * Each item has `type` prop, which might be either `group` or `pair`. Defaults to `pair` if not specified.\n *\n * Each key-value pair definition has the following properties:\n * * `type` (string) - (Optional) Item type (pair).\n * * `label` (string) - The key label.\n * * `info` (React.ReactNode) - (Optional) Area next to the key to display an info link.\n * * `value` (React.ReactNode) - The corresponding value for the key.\n *\n * Each group definition has the following properties:\n * * `type` (string) - Item type (group).\n * * `title` (string) - (Optional) An optional title for this column.\n * * `items` (ReadonlyArray<KeyValuePairProps.KeyValuePair>) - An array of\n * key-value pair items.\n */\n items: ReadonlyArray<KeyValuePairsProps.Item>;\n}\n\nexport namespace KeyValuePairsProps {\n export type Item = Group | Pair;\n\n export interface Group {\n type: 'group';\n title?: string;\n items: ReadonlyArray<Pair>;\n }\n\n export interface Pair extends BaseComponentProps {\n type?: 'pair';\n label: string;\n value: React.ReactNode;\n info?: React.ReactNode;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/key-value-pairs/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport React from 'react';\n\nexport interface KeyValuePairsProps extends BaseComponentProps {\n /**\n * Specifies the number of columns in each grid row.\n * Valid values are any integer between 1 and 4. It defaults to 1.\n */\n columns?: number;\n /**\n * An array of either key-value pairs individual items or groups.\n * They could be combined.\n * Each item has `type` prop, which might be either `group` or `pair`. Defaults to `pair` if not specified.\n *\n * Each key-value pair definition has the following properties:\n * * `type` (string) - (Optional) Item type (pair).\n * * `label` (string) - The key label.\n * * `info` (React.ReactNode) - (Optional) Area next to the key to display an info link.\n * * `value` (React.ReactNode) - The corresponding value for the key.\n *\n * Each group definition has the following properties:\n * * `type` (string) - Item type (group).\n * * `title` (string) - (Optional) An optional title for this column.\n * * `items` (ReadonlyArray<KeyValuePairProps.KeyValuePair>) - An array of\n * key-value pair items.\n */\n items: ReadonlyArray<KeyValuePairsProps.Item>;\n /**\n * Provides an `aria-label` to the Key-value pairs container.\n * Don't use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabel?: string;\n /**\n * Sets the `aria-labelledby` property on the Key-value pairs container.\n * If there's a visible label element that you can reference, use this instead of `ariaLabel`.\n * Don't use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabelledby?: string;\n}\n\nexport namespace KeyValuePairsProps {\n export type Item = Group | Pair;\n\n export interface Group {\n type: 'group';\n title?: string;\n items: ReadonlyArray<Pair>;\n }\n\n export interface Pair extends BaseComponentProps {\n type?: 'pair';\n label: string;\n value: React.ReactNode;\n info?: React.ReactNode;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/key-value-pairs/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAgClD,QAAA,MAAM,qBAAqB,2IAiD1B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/key-value-pairs/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAgClD,QAAA,MAAM,qBAAqB,2IA8D1B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -21,9 +21,9 @@ const InternalKeyValuePairGroup = ({ label, value }) => (React.createElement(Rea
21
21
  label && React.createElement("dt", { className: styles['group-title'] }, label),
22
22
  React.createElement("dd", { className: styles.detail }, value)));
23
23
  const InternalKeyValuePairs = React.forwardRef((_a, ref) => {
24
- var { columns, items, className } = _a, rest = __rest(_a, ["columns", "items", "className"]);
24
+ var { columns, items, className, ariaLabel, ariaLabelledby } = _a, rest = __rest(_a, ["columns", "items", "className", "ariaLabel", "ariaLabelledby"]);
25
25
  return (React.createElement(LinkDefaultVariantContext.Provider, { value: { defaultVariant: 'primary' } },
26
- React.createElement("div", Object.assign({}, rest, { className: clsx(styles['key-value-pairs'], className), ref: ref }),
26
+ React.createElement("div", Object.assign({}, rest, { className: clsx(styles['key-value-pairs'], className), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ref: ref }),
27
27
  React.createElement(ColumnLayout, { __tagOverride: "dl", columns: Math.min(columns, 4), variant: "text-grid", minColumnWidth: 150 }, items.map((pair, index) => {
28
28
  if (pair.type === 'group') {
29
29
  return (
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/key-value-pairs/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,YAAY,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,MAAM,oBAAoB,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAA2B,EAAE,EAAE;IACnF,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAEzC,OAAO,CACL;QACE,4BAAI,SAAS,EAAE,MAAM,CAAC,IAAI;YACxB,+BAAO,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,QAAQ,IACtD,KAAK,CACA;YACR,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,IAAI,QAAQ,IACjD,IAA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AC,IAAI,EAAC,OAAO,EAAC,GAAG,IAC1B,IAAI,CAAC,KAAK,CACP,CACP,EAEH,KAAK,EACH,4BAAI,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,IAChC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CACnC,6BAAK,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC;4BACvD,oBAAC,oBAAoB,oBAAK,IAAI,EAAI,CAC9B,CACP,CAAC,CACC,GAEP,CACH,CAAC;iBACH;gBAED,OAAO,oBAAC,oBAAoB,kBAAC,GAAG,EAAE,KAAK,IAAM,IAAI,EAAI,CAAC;YACxD,CAAC,CAAC,CACW,CACX,CAC6B,CACtC,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,qBAAqB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport { KeyValuePairsProps } from './interfaces';\nimport { InfoLinkLabelContext } from '../internal/context/info-link-label-context';\nimport ColumnLayout from '../column-layout/internal';\nimport { LinkDefaultVariantContext } from '../internal/context/link-default-variant-context';\nimport Box from '../box/internal';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\n\nconst InternalKeyValuePair = ({ label, info, value, id }: KeyValuePairsProps.Pair) => {\n const kvPairId = useUniqueId('kv-pair-');\n\n return (\n <>\n <dt className={styles.term}>\n <label className={styles['key-label']} id={id || kvPairId}>\n {label}\n </label>\n <InfoLinkLabelContext.Provider value={id || kvPairId}>\n {info && <span className={styles.info}>{info}</span>}\n </InfoLinkLabelContext.Provider>\n </dt>\n <dd className={styles.detail}>{value}</dd>\n </>\n );\n};\n\nconst InternalKeyValuePairGroup = ({ label, value }: { label?: React.ReactNode; value: React.ReactNode }) => (\n <>\n {label && <dt className={styles['group-title']}>{label}</dt>}\n <dd className={styles.detail}>{value}</dd>\n </>\n);\n\nconst InternalKeyValuePairs = React.forwardRef(\n (\n { columns, items, className, ...rest }: KeyValuePairsProps & Required<Pick<KeyValuePairsProps, 'columns'>>,\n ref: React.Ref<HTMLDivElement>\n ) => {\n return (\n <LinkDefaultVariantContext.Provider value={{ defaultVariant: 'primary' }}>\n <div {...rest} className={clsx(styles['key-value-pairs'], className)} ref={ref}>\n {/*\n minColumnWidth={150} is set to use FlexibleColumnLayout which has only 1 nested div wrapper for column items,\n otherwise GridColumnLayout will be used, which has 2 nested div, therefore it is not a11y compatible for dl -> dt/dd relationship\n */}\n <ColumnLayout __tagOverride=\"dl\" columns={Math.min(columns, 4)} variant=\"text-grid\" minColumnWidth={150}>\n {items.map((pair, index) => {\n if (pair.type === 'group') {\n return (\n /* InternalKeyValuePairGroup tells react to treat the dt-dd pair as an individual layout item.\n * Otherwise, without this component, they will be rendered as a list, which ruins the html structure.\n * InternalKeyValuePairGroup is not wrapped by div tag, because it ruins a11y compatibility for dl -> dt/dd\n * */\n <InternalKeyValuePairGroup\n key={index}\n label={\n pair.title && (\n <Box variant=\"h3\" padding=\"n\">\n {pair.title}\n </Box>\n )\n }\n value={\n <dl className={styles['group-list']}>\n {pair.items.map((item, itemIndex) => (\n <div key={itemIndex} className={styles['group-list-item']}>\n <InternalKeyValuePair {...item} />\n </div>\n ))}\n </dl>\n }\n />\n );\n }\n\n return <InternalKeyValuePair key={index} {...pair} />;\n })}\n </ColumnLayout>\n </div>\n </LinkDefaultVariantContext.Provider>\n );\n }\n);\n\nexport default InternalKeyValuePairs;\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/key-value-pairs/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,E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inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport { KeyValuePairsProps } from './interfaces';\nimport { InfoLinkLabelContext } from '../internal/context/info-link-label-context';\nimport ColumnLayout from '../column-layout/internal';\nimport { LinkDefaultVariantContext } from '../internal/context/link-default-variant-context';\nimport Box from '../box/internal';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\n\nconst InternalKeyValuePair = ({ label, info, value, id }: KeyValuePairsProps.Pair) => {\n const kvPairId = useUniqueId('kv-pair-');\n\n return (\n <>\n <dt className={styles.term}>\n <label className={styles['key-label']} id={id || kvPairId}>\n {label}\n </label>\n <InfoLinkLabelContext.Provider value={id || kvPairId}>\n {info && <span className={styles.info}>{info}</span>}\n </InfoLinkLabelContext.Provider>\n </dt>\n <dd className={styles.detail}>{value}</dd>\n </>\n );\n};\n\nconst InternalKeyValuePairGroup = ({ label, value }: { label?: React.ReactNode; value: React.ReactNode }) => (\n <>\n {label && <dt className={styles['group-title']}>{label}</dt>}\n <dd className={styles.detail}>{value}</dd>\n </>\n);\n\nconst InternalKeyValuePairs = React.forwardRef(\n (\n {\n columns,\n items,\n className,\n ariaLabel,\n ariaLabelledby,\n ...rest\n }: KeyValuePairsProps & Required<Pick<KeyValuePairsProps, 'columns'>>,\n ref: React.Ref<HTMLDivElement>\n ) => {\n return (\n <LinkDefaultVariantContext.Provider value={{ defaultVariant: 'primary' }}>\n <div\n {...rest}\n className={clsx(styles['key-value-pairs'], className)}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n ref={ref}\n >\n {/*\n minColumnWidth={150} is set to use FlexibleColumnLayout which has only 1 nested div wrapper for column items,\n otherwise GridColumnLayout will be used, which has 2 nested div, therefore it is not a11y compatible for dl -> dt/dd relationship\n */}\n <ColumnLayout __tagOverride=\"dl\" columns={Math.min(columns, 4)} variant=\"text-grid\" minColumnWidth={150}>\n {items.map((pair, index) => {\n if (pair.type === 'group') {\n return (\n /* InternalKeyValuePairGroup tells react to treat the dt-dd pair as an individual layout item.\n * Otherwise, without this component, they will be rendered as a list, which ruins the html structure.\n * InternalKeyValuePairGroup is not wrapped by div tag, because it ruins a11y compatibility for dl -> dt/dd\n * */\n <InternalKeyValuePairGroup\n key={index}\n label={\n pair.title && (\n <Box variant=\"h3\" padding=\"n\">\n {pair.title}\n </Box>\n )\n }\n value={\n <dl className={styles['group-list']}>\n {pair.items.map((item, itemIndex) => (\n <div key={itemIndex} className={styles['group-list-item']}>\n <InternalKeyValuePair {...item} />\n </div>\n ))}\n </dl>\n }\n />\n );\n }\n\n return <InternalKeyValuePair key={index} {...pair} />;\n })}\n </ColumnLayout>\n </div>\n </LinkDefaultVariantContext.Provider>\n );\n }\n);\n\nexport default InternalKeyValuePairs;\n"]}
package/package.json CHANGED
@@ -59,6 +59,7 @@
59
59
  "./pie-chart": "./pie-chart/index.js",
60
60
  "./popover": "./popover/index.js",
61
61
  "./progress-bar": "./progress-bar/index.js",
62
+ "./prompt-input": "./prompt-input/index.js",
62
63
  "./property-filter": "./property-filter/index.js",
63
64
  "./radio-group": "./radio-group/index.js",
64
65
  "./s3-resource-selector": "./s3-resource-selector/index.js",
@@ -123,7 +124,7 @@
123
124
  "./internal/base-component/index.js",
124
125
  "./internal/base-component/styles.css.js"
125
126
  ],
126
- "version": "3.0.685",
127
+ "version": "3.0.687",
127
128
  "repository": {
128
129
  "type": "git",
129
130
  "url": "https://github.com/cloudscape-design/components.git"
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { PromptInputProps } from './interfaces';
3
+ export { PromptInputProps };
4
+ declare const PromptInput: React.ForwardRefExoticComponent<PromptInputProps & React.RefAttributes<PromptInputProps.Ref>>;
5
+ export default PromptInput;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/prompt-input/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKhD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,QAAA,MAAM,WAAW,+FA8ChB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { __rest } from "tslib";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import React from 'react';
5
+ import { applyDisplayName } from '../internal/utils/apply-display-name';
6
+ import InternalPromptInput from './internal';
7
+ import useBaseComponent from '../internal/hooks/use-base-component';
8
+ const PromptInput = React.forwardRef((_a, ref) => {
9
+ var { autoComplete, autoFocus, disableBrowserAutocorrect, disableActionButton, spellcheck, readOnly, actionButtonIconName, minRows, maxRows } = _a, props = __rest(_a, ["autoComplete", "autoFocus", "disableBrowserAutocorrect", "disableActionButton", "spellcheck", "readOnly", "actionButtonIconName", "minRows", "maxRows"]);
10
+ const baseComponentProps = useBaseComponent('PromptInput', {
11
+ props: {
12
+ readOnly,
13
+ autoComplete,
14
+ autoFocus,
15
+ disableBrowserAutocorrect,
16
+ disableActionButton,
17
+ spellcheck,
18
+ actionButtonIconName,
19
+ minRows,
20
+ maxRows,
21
+ },
22
+ });
23
+ return (React.createElement(InternalPromptInput, Object.assign({ readOnly: readOnly, autoComplete: autoComplete, autoFocus: autoFocus, disableBrowserAutocorrect: disableBrowserAutocorrect, disableActionButton: disableActionButton, spellcheck: spellcheck, actionButtonIconName: actionButtonIconName, minRows: minRows, maxRows: maxRows }, props, baseComponentProps, { ref: ref })));
24
+ });
25
+ applyDisplayName(PromptInput, 'PromptInput');
26
+ export default PromptInput;
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/prompt-input/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,mBAAmB,MAAM,YAAY,CAAC;AAC7C,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAIpE,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAClC,CACE,EAWmB,EACnB,GAAoC,EACpC,EAAE;QAbF,EACE,YAAY,EACZ,SAAS,EACT,yBAAyB,EACzB,mBAAmB,EACnB,UAAU,EACV,QAAQ,EACR,oBAAoB,EACpB,OAAO,EACP,OAAO,OAEU,EADd,KAAK,cAVV,yJAWC,CADS;IAIV,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,aAAa,EAAE;QACzD,KAAK,EAAE;YACL,QAAQ;YACR,YAAY;YACZ,SAAS;YACT,yBAAyB;YACzB,mBAAmB;YACnB,UAAU;YACV,oBAAoB;YACpB,OAAO;YACP,OAAO;SACR;KACF,CAAC,CAAC;IACH,OAAO,CACL,oBAAC,mBAAmB,kBAClB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,yBAAyB,EAAE,yBAAyB,EACpD,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,oBAAoB,EAC1C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,IACZ,KAAK,EACL,kBAAkB,IACtB,GAAG,EAAE,GAAG,IACR,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AACF,gBAAgB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAC7C,eAAe,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { PromptInputProps } from './interfaces';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport InternalPromptInput from './internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\n\nexport { PromptInputProps };\n\nconst PromptInput = React.forwardRef(\n (\n {\n autoComplete,\n autoFocus,\n disableBrowserAutocorrect,\n disableActionButton,\n spellcheck,\n readOnly,\n actionButtonIconName,\n minRows,\n maxRows,\n ...props\n }: PromptInputProps,\n ref: React.Ref<PromptInputProps.Ref>\n ) => {\n const baseComponentProps = useBaseComponent('PromptInput', {\n props: {\n readOnly,\n autoComplete,\n autoFocus,\n disableBrowserAutocorrect,\n disableActionButton,\n spellcheck,\n actionButtonIconName,\n minRows,\n maxRows,\n },\n });\n return (\n <InternalPromptInput\n readOnly={readOnly}\n autoComplete={autoComplete}\n autoFocus={autoFocus}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n disableActionButton={disableActionButton}\n spellcheck={spellcheck}\n actionButtonIconName={actionButtonIconName}\n minRows={minRows}\n maxRows={maxRows}\n {...props}\n {...baseComponentProps}\n ref={ref}\n />\n );\n }\n);\napplyDisplayName(PromptInput, 'PromptInput');\nexport default PromptInput;\n"]}
@@ -0,0 +1,82 @@
1
+ /// <reference types="react" />
2
+ import { BaseComponentProps } from '../internal/base-component';
3
+ import { BaseKeyDetail, NonCancelableEventHandler } from '../internal/events';
4
+ import { BaseInputProps, InputAutoCorrect, InputAutoComplete, InputKeyEvents, InputSpellcheck, BaseChangeDetail } from '../input/interfaces';
5
+ import { FormFieldValidationControlProps } from '../internal/context/form-field-context';
6
+ import { IconProps } from '../icon/interfaces';
7
+ export interface PromptInputProps extends BaseInputProps, InputKeyEvents, InputAutoCorrect, InputAutoComplete, InputSpellcheck, BaseComponentProps, FormFieldValidationControlProps {
8
+ /**
9
+ * Called whenever a user clicks the action button or presses the "Enter" key.
10
+ * The event `detail` contains the current value of the field.
11
+ */
12
+ onAction?: NonCancelableEventHandler<PromptInputProps.ActionDetail>;
13
+ /**
14
+ * Determines what icon to display in the action button.
15
+ */
16
+ actionButtonIconName?: IconProps.Name;
17
+ /**
18
+ * Specifies the URL of a custom icon. Use this property if the icon you want isn't available.
19
+ *
20
+ * If you set both `actionButtonIconUrl` and `actionButtonIconSvg`, `actionButtonIconSvg` will take precedence.
21
+ */
22
+ actionButtonIconUrl?: string;
23
+ /**
24
+ * Specifies the SVG of a custom icon.
25
+ *
26
+ * Use this property if you want your custom icon to inherit colors dictated by variant or hover states.
27
+ * When this property is set, the component will be decorated with `aria-hidden="true"`. Ensure that the `svg` element:
28
+ * - has attribute `focusable="false"`.
29
+ * - has `viewBox="0 0 16 16"`.
30
+ *
31
+ * If you set the `svg` element as the root node of the slot, the component will automatically
32
+ * - set `stroke="currentColor"`, `fill="none"`, and `vertical-align="top"`.
33
+ * - set the stroke width based on the size of the icon.
34
+ * - set the width and height of the SVG element based on the size of the icon.
35
+ *
36
+ * If you don't want these styles to be automatically set, wrap the `svg` element into a `span`.
37
+ * You can still set the stroke to `currentColor` to inherit the color of the surrounding elements.
38
+ *
39
+ * If you set both `actionButtonIconUrl` and `actionButtonIconSvg`, `iconSvg` will take precedence.
40
+ *
41
+ * *Note:* Remember to remove any additional elements (for example: `defs`) and related CSS classes from SVG files exported from design software.
42
+ * In most cases, they aren't needed, as the `svg` element inherits styles from the icon component.
43
+ */
44
+ actionButtonIconSvg?: React.ReactNode;
45
+ /**
46
+ * Specifies alternate text for a custom icon. We recommend that you provide this for accessibility.
47
+ * This property is ignored if you use a predefined icon or if you set your custom icon using the `iconSvg` slot.
48
+ */
49
+ actionButtonIconAlt?: string;
50
+ /**
51
+ * Adds an aria-label to the action button.
52
+ * @i18n
53
+ */
54
+ actionButtonAriaLabel?: string;
55
+ /**
56
+ * Specifies whether to disable the action button.
57
+ */
58
+ disableActionButton?: boolean;
59
+ /**
60
+ * Specifies the minimum number of lines of text to set the height to.
61
+ */
62
+ minRows?: number;
63
+ /**
64
+ * Specifies the maximum number of lines of text the textarea will expand to.
65
+ */
66
+ maxRows?: number;
67
+ }
68
+ export declare namespace PromptInputProps {
69
+ type KeyDetail = BaseKeyDetail;
70
+ type ActionDetail = BaseChangeDetail;
71
+ interface Ref {
72
+ /**
73
+ * Sets input focus on the textarea control.
74
+ */
75
+ focus(): void;
76
+ /**
77
+ * Selects all text in the textarea control.
78
+ */
79
+ select(): void;
80
+ }
81
+ }
82
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/prompt-input/interfaces.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,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;IAE9B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;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;KAChB;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +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 { BaseComponentProps } from '../internal/base-component';\nimport { BaseKeyDetail, NonCancelableEventHandler } from '../internal/events';\nimport {\n BaseInputProps,\n InputAutoCorrect,\n InputAutoComplete,\n InputKeyEvents,\n InputSpellcheck,\n BaseChangeDetail,\n} from '../input/interfaces';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { IconProps } from '../icon/interfaces';\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\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"]}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { PromptInputProps } from './interfaces';
3
+ import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
4
+ export interface InternalPromptInputProps extends PromptInputProps, InternalBaseComponentProps {
5
+ }
6
+ declare const InternalPromptInput: React.ForwardRefExoticComponent<InternalPromptInputProps & React.RefAttributes<PromptInputProps.Ref>>;
7
+ export default InternalPromptInput;
8
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/prompt-input/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAIxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAMlF,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB,EAAE,0BAA0B;CAAG;AAEjG,QAAA,MAAM,mBAAmB,uGAkKxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { __rest } from "tslib";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import React, { useCallback, useEffect, useImperativeHandle, useRef } from 'react';
5
+ import { getBaseProps } from '../internal/base-component';
6
+ import InternalButton from '../button/internal';
7
+ import { fireKeyboardEvent, fireNonCancelableEvent } from '../internal/events';
8
+ import { useFormFieldContext } from '../internal/context/form-field-context';
9
+ import clsx from 'clsx';
10
+ import styles from './styles.css.js';
11
+ import testutilStyles from './test-classes/styles.css.js';
12
+ import { convertAutoComplete } from '../input/utils';
13
+ import { useDensityMode } from '@cloudscape-design/component-toolkit/internal';
14
+ import * as tokens from '../internal/generated/styles/tokens';
15
+ import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
16
+ const InternalPromptInput = React.forwardRef((_a, ref) => {
17
+ var { value, actionButtonAriaLabel, actionButtonIconName, actionButtonIconUrl, actionButtonIconSvg, actionButtonIconAlt, ariaLabel, autoComplete, autoFocus, disableActionButton, disableBrowserAutocorrect, disabled, maxRows = 3, minRows, name, onAction, onBlur, onChange, onFocus, onKeyDown, onKeyUp, placeholder, readOnly, spellcheck, __internalRootRef = null } = _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", "__internalRootRef"]);
18
+ const { ariaLabelledby, ariaDescribedby, controlId, invalid, warning } = useFormFieldContext(rest);
19
+ const baseProps = getBaseProps(rest);
20
+ const textareaRef = useRef(null);
21
+ const isRefresh = useVisualRefresh();
22
+ const isCompactMode = useDensityMode(textareaRef) === 'compact';
23
+ const PADDING = isRefresh ? tokens.spaceXxs : tokens.spaceXxxs;
24
+ const LINE_HEIGHT = tokens.lineHeightBodyM;
25
+ useImperativeHandle(ref, () => ({
26
+ focus(...args) {
27
+ var _a;
28
+ (_a = textareaRef.current) === null || _a === void 0 ? void 0 : _a.focus(...args);
29
+ },
30
+ select() {
31
+ var _a;
32
+ (_a = textareaRef.current) === null || _a === void 0 ? void 0 : _a.select();
33
+ },
34
+ }), [textareaRef]);
35
+ const handleKeyDown = (event) => {
36
+ if (onKeyDown) {
37
+ fireKeyboardEvent(onKeyDown, event);
38
+ }
39
+ if (event.key === 'Enter' && !event.shiftKey) {
40
+ if ('form' in event.target && event.target.form !== null && !event.isDefaultPrevented()) {
41
+ event.target.form.requestSubmit();
42
+ }
43
+ event.preventDefault();
44
+ fireNonCancelableEvent(onAction, { value });
45
+ }
46
+ };
47
+ const handleChange = (event) => {
48
+ fireNonCancelableEvent(onChange, { value: event.target.value });
49
+ adjustTextareaHeight();
50
+ };
51
+ const adjustTextareaHeight = useCallback(() => {
52
+ if (textareaRef.current) {
53
+ textareaRef.current.style.height = 'auto';
54
+ const maxRowsHeight = `calc(${maxRows <= 0 ? 3 : maxRows} * (${LINE_HEIGHT} + ${PADDING} / 2) + ${PADDING})`;
55
+ const scrollHeight = `calc(${textareaRef.current.scrollHeight}px + ${PADDING})`;
56
+ textareaRef.current.style.height = `min(${scrollHeight}, ${maxRowsHeight})`;
57
+ }
58
+ }, [maxRows, LINE_HEIGHT, PADDING]);
59
+ useEffect(() => {
60
+ const handleResize = () => {
61
+ adjustTextareaHeight();
62
+ };
63
+ window.addEventListener('resize', handleResize);
64
+ return () => {
65
+ window.removeEventListener('resize', handleResize);
66
+ };
67
+ }, [adjustTextareaHeight]);
68
+ useEffect(() => {
69
+ adjustTextareaHeight();
70
+ }, [value, adjustTextareaHeight, maxRows, isCompactMode]);
71
+ const attributes = {
72
+ 'aria-label': ariaLabel,
73
+ 'aria-labelledby': ariaLabelledby,
74
+ 'aria-describedby': ariaDescribedby,
75
+ 'aria-invalid': invalid ? 'true' : undefined,
76
+ name,
77
+ placeholder,
78
+ autoFocus,
79
+ className: clsx(styles.textarea, testutilStyles.textarea, {
80
+ [styles['textarea-readonly']]: readOnly,
81
+ [styles['textarea-invalid']]: invalid,
82
+ [styles['textarea-warning']]: warning && !invalid,
83
+ [styles['textarea-with-button']]: actionButtonIconName,
84
+ }),
85
+ autoComplete: convertAutoComplete(autoComplete),
86
+ spellCheck: spellcheck,
87
+ disabled,
88
+ readOnly: readOnly ? true : undefined,
89
+ rows: minRows || 1,
90
+ onKeyDown: handleKeyDown,
91
+ onKeyUp: onKeyUp && (event => fireKeyboardEvent(onKeyUp, event)),
92
+ // We set a default value on the component in order to force it into the controlled mode.
93
+ value: value || '',
94
+ onChange: handleChange,
95
+ onBlur: onBlur && (() => fireNonCancelableEvent(onBlur)),
96
+ onFocus: onFocus && (() => fireNonCancelableEvent(onFocus)),
97
+ };
98
+ const hasActionButton = actionButtonIconName || actionButtonIconSvg || actionButtonIconUrl;
99
+ if (disableBrowserAutocorrect) {
100
+ attributes.autoCorrect = 'off';
101
+ attributes.autoCapitalize = 'off';
102
+ }
103
+ return (React.createElement("div", Object.assign({}, baseProps, { className: clsx(styles.root, testutilStyles.root, baseProps.className), ref: __internalRootRef }),
104
+ React.createElement("textarea", Object.assign({ ref: textareaRef, id: controlId }, attributes)),
105
+ hasActionButton && (React.createElement("div", { className: styles.button },
106
+ React.createElement(InternalButton, { className: clsx(styles['action-button'], testutilStyles['action-button']), ariaLabel: actionButtonAriaLabel, disabled: disabled || readOnly || disableActionButton, iconName: actionButtonIconName, iconUrl: actionButtonIconUrl, iconSvg: actionButtonIconSvg, iconAlt: actionButtonIconAlt, onClick: () => fireNonCancelableEvent(onAction, { value }), variant: "icon" })))));
107
+ });
108
+ export default InternalPromptInput;
109
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +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,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAC/E,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAIrE,MAAM,mBAAmB,GAAG,KAAK,CAAC,UAAU,CAC1C,CACE,EA2B2B,EAC3B,GAA8B,EAC9B,EAAE;QA7BF,EACE,KAAK,EACL,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EACT,YAAY,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","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 { getBaseProps } from '../internal/base-component';\nimport InternalButton from '../button/internal';\nimport { fireKeyboardEvent, fireNonCancelableEvent } from '../internal/events';\nimport { PromptInputProps } from './interfaces';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport testutilStyles from './test-classes/styles.css.js';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { convertAutoComplete } from '../input/utils';\nimport { useDensityMode } from '@cloudscape-design/component-toolkit/internal';\nimport * as tokens from '../internal/generated/styles/tokens';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nexport interface InternalPromptInputProps extends PromptInputProps, 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 = 3,\n minRows,\n name,\n onAction,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n onKeyUp,\n placeholder,\n readOnly,\n spellcheck,\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 }),\n [textareaRef]\n );\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (onKeyDown) {\n fireKeyboardEvent(onKeyDown, event);\n }\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 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 + ${PADDING})`;\n textareaRef.current.style.height = `min(${scrollHeight}, ${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['textarea-readonly']]: readOnly,\n [styles['textarea-invalid']]: invalid,\n [styles['textarea-warning']]: warning && !invalid,\n [styles['textarea-with-button']]: actionButtonIconName,\n }),\n autoComplete: convertAutoComplete(autoComplete),\n spellCheck: spellcheck,\n disabled,\n readOnly: readOnly ? true : undefined,\n rows: minRows || 1,\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 const hasActionButton = actionButtonIconName || actionButtonIconSvg || actionButtonIconUrl;\n\n if (disableBrowserAutocorrect) {\n attributes.autoCorrect = 'off';\n attributes.autoCapitalize = 'off';\n }\n\n return (\n <div\n {...baseProps}\n className={clsx(styles.root, testutilStyles.root, baseProps.className)}\n ref={__internalRootRef}\n >\n <textarea ref={textareaRef} id={controlId} {...attributes} />\n {hasActionButton && (\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 iconName={actionButtonIconName}\n iconUrl={actionButtonIconUrl}\n iconSvg={actionButtonIconSvg}\n iconAlt={actionButtonIconAlt}\n onClick={() => fireNonCancelableEvent(onAction, { value })}\n variant=\"icon\"\n />\n </div>\n )}\n </div>\n );\n }\n);\n\nexport default InternalPromptInput;\n"]}
@@ -0,0 +1,13 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "root": "awsui_root_55fkh_v0e3_98",
5
+ "button": "awsui_button_55fkh_v0e3_101",
6
+ "action-button": "awsui_action-button_55fkh_v0e3_106",
7
+ "textarea": "awsui_textarea_55fkh_v0e3_128",
8
+ "textarea-readonly": "awsui_textarea-readonly_55fkh_v0e3_181",
9
+ "textarea-invalid": "awsui_textarea-invalid_55fkh_v0e3_223",
10
+ "textarea-warning": "awsui_textarea-warning_55fkh_v0e3_234",
11
+ "textarea-with-button": "awsui_textarea-with-button_55fkh_v0e3_245"
12
+ };
13
+