@aws-amplify/ui-react 6.2.2 → 6.3.0
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.
- package/dist/{Field-d47a49dc.js → Field-4b189104.js} +11 -0
- package/dist/esm/PrimitiveCatalog.mjs +285 -17
- package/dist/esm/components/AccountSettings/ChangePassword/ChangePassword.mjs +1 -0
- package/dist/esm/components/AccountSettings/ChangePassword/defaults.mjs +1 -0
- package/dist/esm/components/AccountSettings/DeleteUser/DeleteUser.mjs +1 -0
- package/dist/esm/components/AccountSettings/DeleteUser/defaults.mjs +1 -0
- package/dist/esm/components/AccountSettings/shared/Defaults.mjs +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/internal.mjs +4 -0
- package/dist/esm/primitives/Avatar/Avatar.mjs +23 -0
- package/dist/esm/primitives/Icon/icons/IconAssistant.mjs +15 -0
- package/dist/esm/primitives/Icon/icons/IconAttach.mjs +15 -0
- package/dist/esm/primitives/Icon/icons/IconSend.mjs +15 -0
- package/dist/esm/primitives/Icon/icons/IconUser.mjs +15 -0
- package/dist/esm/primitives/ScrollView/ScrollView.mjs +21 -1
- package/dist/esm/primitives/TextArea/AutoresizeTextarea.mjs +19 -0
- package/dist/esm/primitives/TextArea/useAutoresizeTextarea.mjs +28 -0
- package/dist/esm/primitives/TextAreaField/TextAreaField.mjs +3 -2
- package/dist/esm/primitives/index.mjs +1 -0
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +98 -28
- package/dist/internal.js +320 -18
- package/dist/styles/AIConversation.css +108 -0
- package/dist/styles/AIConversation.layer.css +110 -0
- package/dist/styles/avatar.css +111 -0
- package/dist/styles/avatar.layer.css +113 -0
- package/dist/styles/base.css +29 -0
- package/dist/styles/base.layer.css +29 -0
- package/dist/styles.css +250 -0
- package/dist/styles.layer.css +250 -0
- package/dist/types/primitives/Avatar/Avatar.d.ts +6 -0
- package/dist/types/primitives/Avatar/index.d.ts +2 -0
- package/dist/types/primitives/Avatar/types.d.ts +36 -0
- package/dist/types/primitives/Icon/context/IconsContext.d.ts +2 -0
- package/dist/types/primitives/Icon/icons/IconAssistant.d.ts +5 -0
- package/dist/types/primitives/Icon/icons/IconAttach.d.ts +5 -0
- package/dist/types/primitives/Icon/icons/IconSend.d.ts +5 -0
- package/dist/types/primitives/Icon/icons/IconUser.d.ts +5 -0
- package/dist/types/primitives/Icon/icons/index.d.ts +4 -0
- package/dist/types/primitives/TextArea/AutoresizeTextarea.d.ts +3 -0
- package/dist/types/primitives/TextArea/index.d.ts +1 -0
- package/dist/types/primitives/TextArea/useAutoresizeTextarea.d.ts +1 -0
- package/dist/types/primitives/components.d.ts +1 -0
- package/dist/types/primitives/types/scrollView.d.ts +5 -0
- package/dist/types/primitives/types/textAreaField.d.ts +7 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// Updates the height of a <textarea> when the value changes.
|
|
4
|
+
const useAutoresizeTextArea = (textAreaRef, value) => {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const resizeTextArea = () => {
|
|
7
|
+
if (textAreaRef && value) {
|
|
8
|
+
// We need to reset the height momentarily to get the correct scrollHeight for the textarea
|
|
9
|
+
textAreaRef.style.height = 'auto';
|
|
10
|
+
const { scrollHeight } = textAreaRef;
|
|
11
|
+
// We then set the height directly, outside of the render loop
|
|
12
|
+
// Trying to set this with state or a ref will product an incorrect value.
|
|
13
|
+
textAreaRef.style.height = `${scrollHeight}px`;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
resizeTextArea();
|
|
17
|
+
window.addEventListener('resize', resizeTextArea);
|
|
18
|
+
return () => {
|
|
19
|
+
window.removeEventListener('resize', resizeTextArea);
|
|
20
|
+
};
|
|
21
|
+
}, [
|
|
22
|
+
textAreaRef,
|
|
23
|
+
// Trigger the effect if the value changes
|
|
24
|
+
value,
|
|
25
|
+
]);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { useAutoresizeTextArea };
|
|
@@ -8,6 +8,7 @@ import { Flex } from '../Flex/Flex.mjs';
|
|
|
8
8
|
import { Label } from '../Label/Label.mjs';
|
|
9
9
|
import { splitPrimitiveProps } from '../utils/splitPrimitiveProps.mjs';
|
|
10
10
|
import { TextArea } from '../TextArea/TextArea.mjs';
|
|
11
|
+
import { AutoresizeTextArea } from '../TextArea/AutoresizeTextarea.mjs';
|
|
11
12
|
import { useStableId } from '../utils/useStableId.mjs';
|
|
12
13
|
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
13
14
|
import { createSpaceSeparatedIds } from '../utils/createSpaceSeparatedIds.mjs';
|
|
@@ -16,7 +17,7 @@ import { getUniqueComponentId } from '../utils/getUniqueComponentId.mjs';
|
|
|
16
17
|
|
|
17
18
|
const DEFAULT_ROW_COUNT = 3;
|
|
18
19
|
const TextAreaFieldPrimitive = (props, ref) => {
|
|
19
|
-
const { className, descriptiveText, errorMessage, hasError = false, id, label, labelHidden = false, rows, size, testId, inputStyles,
|
|
20
|
+
const { className, descriptiveText, errorMessage, hasError = false, id, label, labelHidden = false, rows, size, testId, inputStyles, autoResize,
|
|
20
21
|
// Destructuring the 'resize' style prop because while it is a style prop
|
|
21
22
|
// it should go on the textarea element and not the wrapper div.
|
|
22
23
|
resize, ..._rest } = props;
|
|
@@ -33,7 +34,7 @@ const TextAreaFieldPrimitive = (props, ref) => {
|
|
|
33
34
|
return (React.createElement(Flex, { className: classNames(ComponentClassName.Field, classNameModifier(ComponentClassName.Field, size), ComponentClassName.TextAreaField, className), testId: testId, ...styleProps },
|
|
34
35
|
React.createElement(Label, { htmlFor: fieldId, visuallyHidden: labelHidden }, label),
|
|
35
36
|
React.createElement(FieldDescription, { id: descriptionId, labelHidden: labelHidden, descriptiveText: descriptiveText }),
|
|
36
|
-
React.createElement(TextArea, { "aria-describedby": ariaDescribedBy, hasError: hasError, id: fieldId, ref: ref, rows: rows ?? DEFAULT_ROW_COUNT, size: size, resize: resize, ...rest, ...inputStyles }),
|
|
37
|
+
autoResize ? (React.createElement(AutoresizeTextArea, { "aria-describedby": ariaDescribedBy, hasError: hasError, id: fieldId, ref: ref, rows: rows ?? DEFAULT_ROW_COUNT, size: size, resize: resize, ...rest, ...inputStyles })) : (React.createElement(TextArea, { "aria-describedby": ariaDescribedBy, hasError: hasError, id: fieldId, ref: ref, rows: rows ?? DEFAULT_ROW_COUNT, size: size, resize: resize, ...rest, ...inputStyles })),
|
|
37
38
|
React.createElement(FieldErrorMessage, { id: errorId, hasError: hasError, errorMessage: errorMessage })));
|
|
38
39
|
};
|
|
39
40
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Alert } from './Alert/Alert.mjs';
|
|
2
2
|
export { Autocomplete } from './Autocomplete/Autocomplete.mjs';
|
|
3
|
+
export { Avatar } from './Avatar/Avatar.mjs';
|
|
3
4
|
export { Badge } from './Badge/Badge.mjs';
|
|
4
5
|
export { Breadcrumbs } from './Breadcrumbs/Breadcrumbs.mjs';
|
|
5
6
|
export { Button } from './Button/Button.mjs';
|
package/dist/esm/version.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var React = require('react');
|
|
|
6
6
|
var isEqual = require('lodash/isEqual.js');
|
|
7
7
|
var uiReactCore = require('@aws-amplify/ui-react-core');
|
|
8
8
|
var ui = require('@aws-amplify/ui');
|
|
9
|
-
var Field = require('./Field-
|
|
9
|
+
var Field = require('./Field-4b189104.js');
|
|
10
10
|
require('aws-amplify/storage');
|
|
11
11
|
var primitiveWithForwardRef = require('./primitiveWithForwardRef-7e929242.js');
|
|
12
12
|
var debounce = require('lodash/debounce.js');
|
|
@@ -102,7 +102,42 @@ const AutocompleteOptionPrimitive = ({ children, className, isActive, ...rest },
|
|
|
102
102
|
const AutocompleteOption = primitiveWithForwardRef.primitiveWithForwardRef(AutocompleteOptionPrimitive);
|
|
103
103
|
AutocompleteOption.displayName = 'AutocompleteOption';
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Creates ref callback to compose together external and internal refs
|
|
107
|
+
*/
|
|
108
|
+
function useComposeRefsCallback({ externalRef, internalRef, }) {
|
|
109
|
+
return React__namespace.useCallback((node) => {
|
|
110
|
+
// Handle callback ref
|
|
111
|
+
if (ui.isFunction(externalRef)) {
|
|
112
|
+
externalRef(node);
|
|
113
|
+
}
|
|
114
|
+
else if (externalRef) {
|
|
115
|
+
externalRef.current = node;
|
|
116
|
+
}
|
|
117
|
+
internalRef.current = node;
|
|
118
|
+
}, [externalRef, internalRef]);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const ScrollViewPrimitive = ({ children, className, orientation, autoScroll, ...rest }, externalRef) => {
|
|
122
|
+
const internalRef = React__namespace.useRef(null);
|
|
123
|
+
const composedRefs = useComposeRefsCallback({
|
|
124
|
+
externalRef,
|
|
125
|
+
internalRef,
|
|
126
|
+
});
|
|
127
|
+
React__namespace.useEffect(() => {
|
|
128
|
+
if (autoScroll) {
|
|
129
|
+
internalRef.current?.scrollTo({
|
|
130
|
+
top: internalRef.current?.scrollHeight,
|
|
131
|
+
left: internalRef.current?.scrollWidth,
|
|
132
|
+
behavior: autoScroll,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}, [
|
|
136
|
+
children,
|
|
137
|
+
autoScroll,
|
|
138
|
+
]);
|
|
139
|
+
return (React__namespace.createElement(Field.View, { className: ui.classNames(ui.ComponentClassName.ScrollView, ui.classNameModifier(ui.ComponentClassName.ScrollView, orientation), className), ref: composedRefs, ...rest }, children));
|
|
140
|
+
};
|
|
106
141
|
/**
|
|
107
142
|
* [📖 Docs](https://ui.docs.amplify.aws/react/components/scrollview)
|
|
108
143
|
*/
|
|
@@ -493,22 +528,6 @@ const TextFieldPrimitive = (props, ref) => {
|
|
|
493
528
|
const TextField = primitiveWithForwardRef.primitiveWithForwardRef(TextFieldPrimitive);
|
|
494
529
|
TextField.displayName = 'TextField';
|
|
495
530
|
|
|
496
|
-
/**
|
|
497
|
-
* Creates ref callback to compose together external and internal refs
|
|
498
|
-
*/
|
|
499
|
-
function useComposeRefsCallback({ externalRef, internalRef, }) {
|
|
500
|
-
return React__namespace.useCallback((node) => {
|
|
501
|
-
// Handle callback ref
|
|
502
|
-
if (ui.isFunction(externalRef)) {
|
|
503
|
-
externalRef(node);
|
|
504
|
-
}
|
|
505
|
-
else if (externalRef) {
|
|
506
|
-
externalRef.current = node;
|
|
507
|
-
}
|
|
508
|
-
internalRef.current = node;
|
|
509
|
-
}, [externalRef, internalRef]);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
531
|
const DEFAULT_KEYS = new Set([Field.ESCAPE_KEY, Field.ENTER_KEY]);
|
|
513
532
|
const useSearchField = ({ defaultValue = '', value, onChange, onClear, onSubmit, externalRef, }) => {
|
|
514
533
|
const isControlled = value !== undefined;
|
|
@@ -643,6 +662,25 @@ const AutocompletePrimitive = ({ className, defaultValue, value, isLoading = fal
|
|
|
643
662
|
const Autocomplete = primitiveWithForwardRef.primitiveWithForwardRef(AutocompletePrimitive);
|
|
644
663
|
Autocomplete.displayName = 'Autocomplete';
|
|
645
664
|
|
|
665
|
+
const ImagePrimitive = ({ className, ...rest }, ref) => (React__namespace.createElement(Field.View, { as: "img", ref: ref, className: ui.classNames(ui.ComponentClassName.Image, className), ...rest }));
|
|
666
|
+
/**
|
|
667
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/image)
|
|
668
|
+
*/
|
|
669
|
+
const Image = primitiveWithForwardRef.primitiveWithForwardRef(ImagePrimitive);
|
|
670
|
+
Image.displayName = 'Image';
|
|
671
|
+
|
|
672
|
+
const AvatarPrimitive = ({ className, children, variation, colorTheme, size, src, alt, ...rest }, ref) => {
|
|
673
|
+
const icons = Field.useIcons('avatar');
|
|
674
|
+
const icon = icons?.user ?? React__namespace.createElement(Field.IconUser, null);
|
|
675
|
+
const componentClasses = ui.classNames(ui.ComponentClassName.Avatar, className, ui.classNameModifier(ui.ComponentClassName.Avatar, variation), ui.classNameModifier(ui.ComponentClassName.Avatar, size), ui.classNameModifier(ui.ComponentClassName.Avatar, colorTheme));
|
|
676
|
+
return (React__namespace.createElement(Field.View, { as: "span", className: componentClasses, ref: ref, ...rest }, src ? (React__namespace.createElement(Image, { className: ui.ComponentClassName.AvatarImage, src: src, alt: alt })) : (children ?? (React__namespace.createElement(Field.View, { as: "span", className: ui.ComponentClassName.AvatarIcon, "aria-hidden": "true" }, icon)))));
|
|
677
|
+
};
|
|
678
|
+
/**
|
|
679
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/avatar)
|
|
680
|
+
*/
|
|
681
|
+
const Avatar = primitiveWithForwardRef.primitiveWithForwardRef(AvatarPrimitive);
|
|
682
|
+
Avatar.displayName = 'Avatar';
|
|
683
|
+
|
|
646
684
|
const BadgePrimitive = ({ className, children, variation, size, ...rest }, ref) => {
|
|
647
685
|
const componentClasses = ui.classNames(ui.ComponentClassName.Badge, className, ui.classNameModifier(ui.ComponentClassName.Badge, variation), ui.classNameModifier(ui.ComponentClassName.Badge, size));
|
|
648
686
|
return (React__namespace.createElement(Field.View, { as: "span", className: componentClasses, ref: ref, ...rest }, children));
|
|
@@ -1345,13 +1383,6 @@ const HeadingPrimitive = ({ className, children, isTruncated, level = 6, ...rest
|
|
|
1345
1383
|
const Heading = primitiveWithForwardRef.primitiveWithForwardRef(HeadingPrimitive);
|
|
1346
1384
|
Heading.displayName = 'Heading';
|
|
1347
1385
|
|
|
1348
|
-
const ImagePrimitive = ({ className, ...rest }, ref) => (React__namespace.createElement(Field.View, { as: "img", ref: ref, className: ui.classNames(ui.ComponentClassName.Image, className), ...rest }));
|
|
1349
|
-
/**
|
|
1350
|
-
* [📖 Docs](https://ui.docs.amplify.aws/react/components/image)
|
|
1351
|
-
*/
|
|
1352
|
-
const Image = primitiveWithForwardRef.primitiveWithForwardRef(ImagePrimitive);
|
|
1353
|
-
Image.displayName = 'Image';
|
|
1354
|
-
|
|
1355
1386
|
/**
|
|
1356
1387
|
* [📖 Docs](https://ui.docs.amplify.aws/react/components/menu)
|
|
1357
1388
|
*/
|
|
@@ -2219,9 +2250,46 @@ const TextAreaPrimitive = ({ className, isDisabled, isReadOnly, isRequired, size
|
|
|
2219
2250
|
const TextArea = primitiveWithForwardRef.primitiveWithForwardRef(TextAreaPrimitive);
|
|
2220
2251
|
TextArea.displayName = 'TextArea';
|
|
2221
2252
|
|
|
2253
|
+
// Updates the height of a <textarea> when the value changes.
|
|
2254
|
+
const useAutoresizeTextArea = (textAreaRef, value) => {
|
|
2255
|
+
React.useEffect(() => {
|
|
2256
|
+
const resizeTextArea = () => {
|
|
2257
|
+
if (textAreaRef && value) {
|
|
2258
|
+
// We need to reset the height momentarily to get the correct scrollHeight for the textarea
|
|
2259
|
+
textAreaRef.style.height = 'auto';
|
|
2260
|
+
const { scrollHeight } = textAreaRef;
|
|
2261
|
+
// We then set the height directly, outside of the render loop
|
|
2262
|
+
// Trying to set this with state or a ref will product an incorrect value.
|
|
2263
|
+
textAreaRef.style.height = `${scrollHeight}px`;
|
|
2264
|
+
}
|
|
2265
|
+
};
|
|
2266
|
+
resizeTextArea();
|
|
2267
|
+
window.addEventListener('resize', resizeTextArea);
|
|
2268
|
+
return () => {
|
|
2269
|
+
window.removeEventListener('resize', resizeTextArea);
|
|
2270
|
+
};
|
|
2271
|
+
}, [
|
|
2272
|
+
textAreaRef,
|
|
2273
|
+
// Trigger the effect if the value changes
|
|
2274
|
+
value,
|
|
2275
|
+
]);
|
|
2276
|
+
};
|
|
2277
|
+
|
|
2278
|
+
const AutoresizeTextAreaPrimitive = ({ value, ...rest }, externalRef) => {
|
|
2279
|
+
const internalRef = React__namespace.useRef(null);
|
|
2280
|
+
useAutoresizeTextArea(internalRef.current, value);
|
|
2281
|
+
const composedRef = useComposeRefsCallback({
|
|
2282
|
+
externalRef,
|
|
2283
|
+
internalRef,
|
|
2284
|
+
});
|
|
2285
|
+
return React__namespace.createElement(TextArea, { ...rest, ref: composedRef, value: value });
|
|
2286
|
+
};
|
|
2287
|
+
const AutoresizeTextArea = primitiveWithForwardRef.primitiveWithForwardRef(AutoresizeTextAreaPrimitive);
|
|
2288
|
+
AutoresizeTextArea.displayName = 'AutoresizeTextArea';
|
|
2289
|
+
|
|
2222
2290
|
const DEFAULT_ROW_COUNT = 3;
|
|
2223
2291
|
const TextAreaFieldPrimitive = (props, ref) => {
|
|
2224
|
-
const { className, descriptiveText, errorMessage, hasError = false, id, label, labelHidden = false, rows, size, testId, inputStyles,
|
|
2292
|
+
const { className, descriptiveText, errorMessage, hasError = false, id, label, labelHidden = false, rows, size, testId, inputStyles, autoResize,
|
|
2225
2293
|
// Destructuring the 'resize' style prop because while it is a style prop
|
|
2226
2294
|
// it should go on the textarea element and not the wrapper div.
|
|
2227
2295
|
resize, ..._rest } = props;
|
|
@@ -2238,7 +2306,7 @@ const TextAreaFieldPrimitive = (props, ref) => {
|
|
|
2238
2306
|
return (React__namespace.createElement(Field.Flex, { className: ui.classNames(ui.ComponentClassName.Field, ui.classNameModifier(ui.ComponentClassName.Field, size), ui.ComponentClassName.TextAreaField, className), testId: testId, ...styleProps },
|
|
2239
2307
|
React__namespace.createElement(Field.Label, { htmlFor: fieldId, visuallyHidden: labelHidden }, label),
|
|
2240
2308
|
React__namespace.createElement(Field.FieldDescription, { id: descriptionId, labelHidden: labelHidden, descriptiveText: descriptiveText }),
|
|
2241
|
-
React__namespace.createElement(TextArea, { "aria-describedby": ariaDescribedBy, hasError: hasError, id: fieldId, ref: ref, rows: rows ?? DEFAULT_ROW_COUNT, size: size, resize: resize, ...rest, ...inputStyles }),
|
|
2309
|
+
autoResize ? (React__namespace.createElement(AutoresizeTextArea, { "aria-describedby": ariaDescribedBy, hasError: hasError, id: fieldId, ref: ref, rows: rows ?? DEFAULT_ROW_COUNT, size: size, resize: resize, ...rest, ...inputStyles })) : (React__namespace.createElement(TextArea, { "aria-describedby": ariaDescribedBy, hasError: hasError, id: fieldId, ref: ref, rows: rows ?? DEFAULT_ROW_COUNT, size: size, resize: resize, ...rest, ...inputStyles })),
|
|
2242
2310
|
React__namespace.createElement(Field.FieldErrorMessage, { id: errorId, hasError: hasError, errorMessage: errorMessage })));
|
|
2243
2311
|
};
|
|
2244
2312
|
/**
|
|
@@ -2348,6 +2416,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
2348
2416
|
IconsProvider: IconsProvider,
|
|
2349
2417
|
Alert: Alert,
|
|
2350
2418
|
Autocomplete: Autocomplete,
|
|
2419
|
+
Avatar: Avatar,
|
|
2351
2420
|
Badge: Badge,
|
|
2352
2421
|
Breadcrumbs: Breadcrumbs,
|
|
2353
2422
|
Button: Field.Button,
|
|
@@ -2452,7 +2521,7 @@ const defaultDeleteUserDisplayText = {
|
|
|
2452
2521
|
warningText: 'Deleting your account is not reversible. You will lose access to your account and all data associated with it.',
|
|
2453
2522
|
};
|
|
2454
2523
|
|
|
2455
|
-
const VERSION = '6.
|
|
2524
|
+
const VERSION = '6.3.0';
|
|
2456
2525
|
|
|
2457
2526
|
const logger$2 = ui.getLogger('AccountSettings');
|
|
2458
2527
|
const getIsDisabled = (formValues, validationError) => {
|
|
@@ -3481,6 +3550,7 @@ exports.AccountSettings = AccountSettings;
|
|
|
3481
3550
|
exports.Alert = Alert;
|
|
3482
3551
|
exports.Authenticator = Authenticator;
|
|
3483
3552
|
exports.Autocomplete = Autocomplete;
|
|
3553
|
+
exports.Avatar = Avatar;
|
|
3484
3554
|
exports.Badge = Badge;
|
|
3485
3555
|
exports.Breadcrumbs = Breadcrumbs;
|
|
3486
3556
|
exports.ButtonGroup = ButtonGroup;
|