@aws-amplify/ui-react 6.5.0 → 6.5.2
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-4b189104.js → Field-CIQvkMkM.js} +25 -106
- package/dist/{ThemeStyle-1fee4302.js → ThemeStyle-CgfvQJ7V.js} +10 -13
- package/dist/esm/components/ThemeProvider/ComponentStyle.mjs +6 -8
- package/dist/esm/components/ThemeProvider/GlobalStyle.mjs +18 -0
- package/dist/esm/components/ThemeProvider/Style.mjs +6 -8
- package/dist/esm/components/ThemeProvider/ThemeStyle.mjs +6 -8
- package/dist/esm/internal.mjs +1 -1
- package/dist/esm/primitives/Accordion/AccordionTrigger.mjs +2 -2
- package/dist/esm/primitives/DropZone/DropZone.mjs +1 -1
- package/dist/esm/primitives/Tabs/TabsItem.mjs +2 -2
- package/dist/esm/primitives/shared/responsive/getMediaQueries.mjs +1 -0
- package/dist/esm/primitives/shared/responsive/useBreakpoint.mjs +1 -0
- package/dist/esm/server.mjs +1 -0
- package/dist/esm/version.mjs +1 -1
- package/dist/index.js +295 -297
- package/dist/internal.js +6 -7
- package/dist/server.js +23 -11
- package/dist/types/components/ThemeProvider/ComponentStyle.d.ts +6 -4
- package/dist/types/components/ThemeProvider/GlobalStyle.d.ts +20 -0
- package/dist/types/components/ThemeProvider/Style.d.ts +6 -4
- package/dist/types/components/ThemeProvider/ThemeStyle.d.ts +6 -4
- package/dist/types/internal.d.ts +1 -1
- package/dist/types/primitives/DropZone/DropZoneProvider.d.ts +1 -1
- package/dist/types/primitives/DropZone/types.d.ts +2 -17
- package/dist/types/primitives/shared/responsive/utils.d.ts +1 -1
- package/dist/types/server.d.ts +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -5
- package/dist/esm/primitives/DropZone/filterAllowedFiles.mjs +0 -34
- package/dist/esm/primitives/DropZone/useDropZone.mjs +0 -65
- package/dist/primitiveWithForwardRef-7e929242.js +0 -36
- package/dist/types/primitives/Card/__test__/Card.test.d.ts +0 -1
- package/dist/types/primitives/DropZone/filterAllowedFiles.d.ts +0 -10
- package/dist/types/primitives/DropZone/useDropZone.d.ts +0 -2
|
@@ -5,7 +5,6 @@ var core = require('@aws-amplify/core');
|
|
|
5
5
|
var auth = require('aws-amplify/auth');
|
|
6
6
|
var uiReactCore = require('@aws-amplify/ui-react-core');
|
|
7
7
|
var ui = require('@aws-amplify/ui');
|
|
8
|
-
var primitiveWithForwardRef = require('./primitiveWithForwardRef-7e929242.js');
|
|
9
8
|
|
|
10
9
|
function _interopNamespace(e) {
|
|
11
10
|
if (e && e.__esModule) return e;
|
|
@@ -281,6 +280,7 @@ const getCSSVariableIfValueIsThemeKey = (propKey, value, tokens) => {
|
|
|
281
280
|
};
|
|
282
281
|
|
|
283
282
|
// Inspiration for getMediaQueries and useBreakpoint
|
|
283
|
+
// comes from https://github.com/iiroj/use-breakpoint/
|
|
284
284
|
const getMediaQueries = ({ breakpoints }) => {
|
|
285
285
|
const sortedBreakpoints = objectKeys(breakpoints).sort((a, b) => breakpoints[b] - breakpoints[a]);
|
|
286
286
|
return sortedBreakpoints.map((breakpoint, index) => {
|
|
@@ -307,6 +307,7 @@ const getMediaQueries = ({ breakpoints }) => {
|
|
|
307
307
|
};
|
|
308
308
|
|
|
309
309
|
// Inspiration for getMediaQueries and useBreakpoint
|
|
310
|
+
// comes from https://github.com/iiroj/use-breakpoint/
|
|
310
311
|
const useIsomorphicEffect = typeof window === 'undefined' ? React__namespace.useEffect : React__namespace.useLayoutEffect;
|
|
311
312
|
const useBreakpoint = ({ breakpoints, defaultBreakpoint, }) => {
|
|
312
313
|
const supportMatchMedia = typeof window !== 'undefined' && typeof window.matchMedia !== 'undefined';
|
|
@@ -636,6 +637,17 @@ const useStyles = (props, style) => {
|
|
|
636
637
|
}), [propStyles, style, breakpoints, breakpoint, tokens]);
|
|
637
638
|
};
|
|
638
639
|
|
|
640
|
+
/**
|
|
641
|
+
* Updates the return type for primitives wrapped in `React.forwardRef` to
|
|
642
|
+
* `React.ReactElement`. In React 18 the return type of `React.ExoticComponent`
|
|
643
|
+
* was changed from `React.ReactElement` to `React.ReactNode`, which breaks
|
|
644
|
+
* clients using React 16 and 17.
|
|
645
|
+
*
|
|
646
|
+
* @param primitive UI Primitive to be wrapped with `React.forwardRef`
|
|
647
|
+
* @returns ForwaredRef wrapped UI Primitive
|
|
648
|
+
*/
|
|
649
|
+
const primitiveWithForwardRef = (primitive) => React__namespace.forwardRef(primitive);
|
|
650
|
+
|
|
639
651
|
const ViewPrimitive = ({ as = 'div', children, testId, ariaLabel, isDisabled, style, inert, ...rest }, ref) => {
|
|
640
652
|
const { propStyles, nonStyleProps } = useStyles(rest, style);
|
|
641
653
|
return React__namespace.createElement(as, {
|
|
@@ -651,7 +663,7 @@ const ViewPrimitive = ({ as = 'div', children, testId, ariaLabel, isDisabled, st
|
|
|
651
663
|
/**
|
|
652
664
|
* [📖 Docs](https://ui.docs.amplify.aws/react/components/view)
|
|
653
665
|
*/
|
|
654
|
-
const View = primitiveWithForwardRef
|
|
666
|
+
const View = primitiveWithForwardRef(ViewPrimitive);
|
|
655
667
|
View.displayName = 'View';
|
|
656
668
|
|
|
657
669
|
const defaultViewBox = { minX: 0, minY: 0, width: 24, height: 24 };
|
|
@@ -681,7 +693,7 @@ as = 'svg', fill = 'currentColor', pathData, viewBox = defaultViewBox, children,
|
|
|
681
693
|
/**
|
|
682
694
|
* [📖 Docs](https://ui.docs.amplify.aws/react/components/icon)
|
|
683
695
|
*/
|
|
684
|
-
const Icon = primitiveWithForwardRef
|
|
696
|
+
const Icon = primitiveWithForwardRef(IconPrimitive);
|
|
685
697
|
Icon.displayName = 'Icon';
|
|
686
698
|
|
|
687
699
|
const IconsContext = React__namespace.createContext({});
|
|
@@ -898,103 +910,10 @@ const AlertIcon = ({ variation, ariaHidden, ariaLabel, role, }) => {
|
|
|
898
910
|
};
|
|
899
911
|
AlertIcon.displayName = 'AlertIcon';
|
|
900
912
|
|
|
901
|
-
function filterAllowedFiles(files, acceptedFileTypes) {
|
|
902
|
-
// Allow any files if acceptedFileTypes is undefined, empty array, or contains '*'
|
|
903
|
-
if (!acceptedFileTypes ||
|
|
904
|
-
acceptedFileTypes.length === 0 ||
|
|
905
|
-
acceptedFileTypes.includes('*')) {
|
|
906
|
-
return { acceptedFiles: files, rejectedFiles: [] };
|
|
907
|
-
}
|
|
908
|
-
const acceptedFiles = [];
|
|
909
|
-
const rejectedFiles = [];
|
|
910
|
-
function filterFile(file) {
|
|
911
|
-
const { type = '', name = '' } = file;
|
|
912
|
-
const mimeType = type.toLowerCase();
|
|
913
|
-
const baseMimeType = mimeType.split('/')[0];
|
|
914
|
-
return acceptedFileTypes.some((type) => {
|
|
915
|
-
const validType = type.trim().toLowerCase();
|
|
916
|
-
// if the accepted file type is a file extension
|
|
917
|
-
// it will start with '.', check against the file name
|
|
918
|
-
if (validType.charAt(0) === '.') {
|
|
919
|
-
return name.toLowerCase().endsWith(validType);
|
|
920
|
-
}
|
|
921
|
-
// This is something like a image/* mime type
|
|
922
|
-
if (validType.endsWith('/*')) {
|
|
923
|
-
return baseMimeType === validType.split('/')[0];
|
|
924
|
-
}
|
|
925
|
-
return mimeType === validType;
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
files.forEach((file) => {
|
|
929
|
-
(filterFile(file) ? acceptedFiles : rejectedFiles).push(file);
|
|
930
|
-
});
|
|
931
|
-
return { acceptedFiles, rejectedFiles };
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
function useDropZone({ onDropComplete, onDragEnter: _onDragEnter, onDragLeave: _onDragLeave, onDragOver: _onDragOver, onDragStart: _onDragStart, onDrop: _onDrop, acceptedFileTypes = [], }) {
|
|
935
|
-
const [dragState, setDragState] = React.useState('inactive');
|
|
936
|
-
const onDragStart = (event) => {
|
|
937
|
-
event.dataTransfer.clearData();
|
|
938
|
-
if (ui.isFunction(_onDragStart)) {
|
|
939
|
-
_onDragStart(event);
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
const onDragEnter = (event) => {
|
|
943
|
-
event.preventDefault();
|
|
944
|
-
event.stopPropagation();
|
|
945
|
-
if (ui.isFunction(_onDragEnter)) {
|
|
946
|
-
_onDragEnter(event);
|
|
947
|
-
}
|
|
948
|
-
};
|
|
949
|
-
const onDragLeave = (event) => {
|
|
950
|
-
event.preventDefault();
|
|
951
|
-
event.stopPropagation();
|
|
952
|
-
setDragState('inactive');
|
|
953
|
-
if (ui.isFunction(_onDragLeave)) {
|
|
954
|
-
_onDragLeave(event);
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
|
-
const onDragOver = (event) => {
|
|
958
|
-
event.preventDefault();
|
|
959
|
-
event.stopPropagation();
|
|
960
|
-
event.dataTransfer.dropEffect = 'copy';
|
|
961
|
-
if (ui.isFunction(_onDragOver)) {
|
|
962
|
-
_onDragOver(event);
|
|
963
|
-
}
|
|
964
|
-
const files = Array.from(event.dataTransfer.items).map(({ kind, type }) => ({
|
|
965
|
-
kind,
|
|
966
|
-
type,
|
|
967
|
-
}));
|
|
968
|
-
const { rejectedFiles } = filterAllowedFiles(files, acceptedFileTypes);
|
|
969
|
-
setDragState(rejectedFiles.length > 0 ? 'reject' : 'accept');
|
|
970
|
-
};
|
|
971
|
-
const onDrop = (event) => {
|
|
972
|
-
event.preventDefault();
|
|
973
|
-
event.stopPropagation();
|
|
974
|
-
setDragState('inactive');
|
|
975
|
-
const files = Array.from(event.dataTransfer.files);
|
|
976
|
-
const { acceptedFiles, rejectedFiles } = filterAllowedFiles(files, acceptedFileTypes);
|
|
977
|
-
if (ui.isFunction(_onDrop)) {
|
|
978
|
-
_onDrop(event);
|
|
979
|
-
}
|
|
980
|
-
if (ui.isFunction(onDropComplete)) {
|
|
981
|
-
onDropComplete({ acceptedFiles, rejectedFiles });
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
return {
|
|
985
|
-
onDragStart,
|
|
986
|
-
onDragEnter,
|
|
987
|
-
onDragLeave,
|
|
988
|
-
onDragOver,
|
|
989
|
-
onDrop,
|
|
990
|
-
dragState,
|
|
991
|
-
};
|
|
992
|
-
}
|
|
993
|
-
|
|
994
913
|
const FieldGroupIconPrimitive = ({ className, children, isVisible = true, excludeFromTabOrder = false, ...rest }, ref) => {
|
|
995
914
|
return isVisible ? (React__namespace.createElement(View, { className: ui.classNames(ui.ComponentClassName.FieldGroupIcon, className), ref: ref, tabIndex: excludeFromTabOrder ? -1 : undefined, ...rest }, children)) : null;
|
|
996
915
|
};
|
|
997
|
-
const FieldGroupIcon = primitiveWithForwardRef
|
|
916
|
+
const FieldGroupIcon = primitiveWithForwardRef(FieldGroupIconPrimitive);
|
|
998
917
|
FieldGroupIcon.displayName = 'FieldGroupIcon';
|
|
999
918
|
|
|
1000
919
|
const FieldsetContext = React__namespace.createContext({
|
|
@@ -1011,7 +930,7 @@ const FlexPrimitive = ({ className, children, ...rest }, ref) => (React__namespa
|
|
|
1011
930
|
/**
|
|
1012
931
|
* [📖 Docs](https://ui.docs.amplify.aws/react/components/flex)
|
|
1013
932
|
*/
|
|
1014
|
-
const Flex = primitiveWithForwardRef
|
|
933
|
+
const Flex = primitiveWithForwardRef(FlexPrimitive);
|
|
1015
934
|
Flex.displayName = 'Flex';
|
|
1016
935
|
|
|
1017
936
|
const LINEAR_EMPTY = 'linear-empty';
|
|
@@ -1061,7 +980,7 @@ const LoaderPrimitive = ({ className, filledColor, emptyColor, size, variation,
|
|
|
1061
980
|
/**
|
|
1062
981
|
* [📖 Docs](https://ui.docs.amplify.aws/react/components/loader)
|
|
1063
982
|
*/
|
|
1064
|
-
const Loader = primitiveWithForwardRef
|
|
983
|
+
const Loader = primitiveWithForwardRef(LoaderPrimitive);
|
|
1065
984
|
Loader.displayName = 'Loader';
|
|
1066
985
|
|
|
1067
986
|
// These variations support colorThemes. 'undefined' accounts for our
|
|
@@ -1085,11 +1004,11 @@ const ButtonPrimitive = ({ className, children, colorTheme, isFullWidth = false,
|
|
|
1085
1004
|
/**
|
|
1086
1005
|
* [📖 Docs](https://ui.docs.amplify.aws/react/components/button)
|
|
1087
1006
|
*/
|
|
1088
|
-
const Button = primitiveWithForwardRef
|
|
1007
|
+
const Button = primitiveWithForwardRef(ButtonPrimitive);
|
|
1089
1008
|
Button.displayName = 'Button';
|
|
1090
1009
|
|
|
1091
1010
|
const FieldGroupIconButtonPrimitive = ({ children, className, ...rest }, ref) => (React__namespace.createElement(FieldGroupIcon, { as: Button, className: ui.classNames(ui.ComponentClassName.FieldGroupIconButton, className), ref: ref, ...rest }, children));
|
|
1092
|
-
const FieldGroupIconButton = primitiveWithForwardRef
|
|
1011
|
+
const FieldGroupIconButton = primitiveWithForwardRef(FieldGroupIconButtonPrimitive);
|
|
1093
1012
|
FieldGroupIconButton.displayName = 'FieldGroupIconButton';
|
|
1094
1013
|
|
|
1095
1014
|
const ariaLabelText = ComponentText.Fields.clearButtonLabel;
|
|
@@ -1097,7 +1016,7 @@ const FieldClearButtonPrimitive = ({ ariaLabel = ariaLabelText, size, ...rest },
|
|
|
1097
1016
|
const icons = useIcons('field');
|
|
1098
1017
|
return (React__namespace.createElement(FieldGroupIconButton, { ariaLabel: ariaLabel, size: size, ref: ref, ...rest }, icons?.clear ?? React__namespace.createElement(IconClose, null)));
|
|
1099
1018
|
};
|
|
1100
|
-
const FieldClearButton = primitiveWithForwardRef
|
|
1019
|
+
const FieldClearButton = primitiveWithForwardRef(FieldClearButtonPrimitive);
|
|
1101
1020
|
FieldClearButton.displayName = 'FieldClearButton';
|
|
1102
1021
|
|
|
1103
1022
|
const TextPrimitive = ({ as = 'p', className, children, isTruncated, variation, ...rest }, ref) => {
|
|
@@ -1107,7 +1026,7 @@ const TextPrimitive = ({ as = 'p', className, children, isTruncated, variation,
|
|
|
1107
1026
|
/**
|
|
1108
1027
|
* [📖 Docs](https://ui.docs.amplify.aws/react/components/text)
|
|
1109
1028
|
*/
|
|
1110
|
-
const Text = primitiveWithForwardRef
|
|
1029
|
+
const Text = primitiveWithForwardRef(TextPrimitive);
|
|
1111
1030
|
Text.displayName = 'Text';
|
|
1112
1031
|
|
|
1113
1032
|
const QA_FIELD_DESCRIPTION = 'qa-field-description';
|
|
@@ -1126,7 +1045,7 @@ const LabelPrimitive = ({ children, className, visuallyHidden, ...rest }, ref) =
|
|
|
1126
1045
|
[ui.ComponentClassName.VisuallyHidden]: visuallyHidden,
|
|
1127
1046
|
}), ref: ref, ...rest }, children));
|
|
1128
1047
|
};
|
|
1129
|
-
const Label = primitiveWithForwardRef
|
|
1048
|
+
const Label = primitiveWithForwardRef(LabelPrimitive);
|
|
1130
1049
|
Label.displayName = 'Label';
|
|
1131
1050
|
|
|
1132
1051
|
const FieldPrimitive = (props, ref) => {
|
|
@@ -1137,7 +1056,7 @@ const FieldPrimitive = (props, ref) => {
|
|
|
1137
1056
|
children,
|
|
1138
1057
|
errorMessage ? (React__namespace.createElement(FieldErrorMessage, { hasError: hasError, errorMessage: errorMessage })) : null));
|
|
1139
1058
|
};
|
|
1140
|
-
const Field = primitiveWithForwardRef
|
|
1059
|
+
const Field = primitiveWithForwardRef(FieldPrimitive);
|
|
1141
1060
|
Field.displayName = 'Field';
|
|
1142
1061
|
|
|
1143
1062
|
exports.ARROW_DOWN = ARROW_DOWN;
|
|
@@ -1185,12 +1104,12 @@ exports.View = View;
|
|
|
1185
1104
|
exports.getConsecutiveIntArray = getConsecutiveIntArray;
|
|
1186
1105
|
exports.getStyleValue = getStyleValue;
|
|
1187
1106
|
exports.getValueAtCurrentBreakpoint = getValueAtCurrentBreakpoint;
|
|
1107
|
+
exports.primitiveWithForwardRef = primitiveWithForwardRef;
|
|
1188
1108
|
exports.strHasLength = strHasLength;
|
|
1189
1109
|
exports.useAuth = useAuth;
|
|
1190
1110
|
exports.useBreakpoint = useBreakpoint;
|
|
1191
1111
|
exports.useColorMode = useColorMode;
|
|
1192
1112
|
exports.useDeprecationWarning = useDeprecationWarning;
|
|
1193
|
-
exports.useDropZone = useDropZone;
|
|
1194
1113
|
exports.useFieldset = useFieldset;
|
|
1195
1114
|
exports.useIcons = useIcons;
|
|
1196
1115
|
exports.useStyles = useStyles;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var primitiveWithForwardRef = require('./primitiveWithForwardRef-7e929242.js');
|
|
5
4
|
|
|
6
5
|
function _interopNamespace(e) {
|
|
7
6
|
if (e && e.__esModule) return e;
|
|
@@ -23,7 +22,11 @@ function _interopNamespace(e) {
|
|
|
23
22
|
|
|
24
23
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* @experimental
|
|
27
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
28
|
+
*/
|
|
29
|
+
const Style = ({ cssText, ...rest }) => {
|
|
27
30
|
/*
|
|
28
31
|
Only inject theme CSS variables if given a theme.
|
|
29
32
|
The CSS file users import already has the default theme variables in it.
|
|
@@ -72,28 +75,22 @@ const StylePrimitive = ({ cssText, ...rest }, ref) => {
|
|
|
72
75
|
if (cssText === undefined || /<\/style/i.test(cssText)) {
|
|
73
76
|
return null;
|
|
74
77
|
}
|
|
75
|
-
return (React__namespace.createElement("style", { ...rest,
|
|
78
|
+
return (React__namespace.createElement("style", { ...rest,
|
|
76
79
|
// eslint-disable-next-line react/no-danger
|
|
77
80
|
dangerouslySetInnerHTML: { __html: cssText } }));
|
|
78
81
|
};
|
|
82
|
+
Style.displayName = 'Style';
|
|
83
|
+
|
|
79
84
|
/**
|
|
80
85
|
* @experimental
|
|
81
86
|
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
82
87
|
*/
|
|
83
|
-
const
|
|
84
|
-
Style.displayName = 'Style';
|
|
85
|
-
|
|
86
|
-
const ThemeStylePrimitive = ({ theme, nonce, ...rest }, ref) => {
|
|
88
|
+
const ThemeStyle = ({ theme, ...rest }) => {
|
|
87
89
|
if (!theme)
|
|
88
90
|
return null;
|
|
89
91
|
const { name, cssText } = theme;
|
|
90
|
-
return
|
|
92
|
+
return React__namespace.createElement(Style, { ...rest, cssText: cssText, id: `amplify-theme-${name}` });
|
|
91
93
|
};
|
|
92
|
-
/**
|
|
93
|
-
* @experimental
|
|
94
|
-
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
95
|
-
*/
|
|
96
|
-
const ThemeStyle = primitiveWithForwardRef.primitiveWithForwardRef(ThemeStylePrimitive);
|
|
97
94
|
ThemeStyle.displayName = 'ThemeStyle';
|
|
98
95
|
|
|
99
96
|
exports.Style = Style;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { createComponentCSS } from '@aws-amplify/ui';
|
|
3
|
-
import { primitiveWithForwardRef } from '../../primitives/utils/primitiveWithForwardRef.mjs';
|
|
4
3
|
import { Style } from './Style.mjs';
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @experimental
|
|
7
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
8
|
+
*/
|
|
9
|
+
const ComponentStyle = ({ theme, componentThemes = [], ...rest }) => {
|
|
7
10
|
if (!theme || !componentThemes.length) {
|
|
8
11
|
return null;
|
|
9
12
|
}
|
|
@@ -11,13 +14,8 @@ const ComponentStylePrimitive = ({ theme, componentThemes = [], ...rest }, ref)
|
|
|
11
14
|
theme,
|
|
12
15
|
components: componentThemes,
|
|
13
16
|
});
|
|
14
|
-
return React.createElement(Style, { ...rest,
|
|
17
|
+
return React.createElement(Style, { ...rest, cssText: cssText });
|
|
15
18
|
};
|
|
16
|
-
/**
|
|
17
|
-
* @experimental
|
|
18
|
-
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
19
|
-
*/
|
|
20
|
-
const ComponentStyle = primitiveWithForwardRef(ComponentStylePrimitive);
|
|
21
19
|
ComponentStyle.displayName = 'ComponentStyle';
|
|
22
20
|
|
|
23
21
|
export { ComponentStyle };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createGlobalCSS } from '@aws-amplify/ui';
|
|
3
|
+
import { Style } from './Style.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @experimental
|
|
7
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
8
|
+
*/
|
|
9
|
+
const GlobalStyle = ({ styles, ...rest }) => {
|
|
10
|
+
if (!styles) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const cssText = createGlobalCSS(styles);
|
|
14
|
+
return React.createElement(Style, { ...rest, cssText: cssText });
|
|
15
|
+
};
|
|
16
|
+
GlobalStyle.displayName = 'GlobalStyle';
|
|
17
|
+
|
|
18
|
+
export { GlobalStyle };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { primitiveWithForwardRef } from '../../primitives/utils/primitiveWithForwardRef.mjs';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @experimental
|
|
5
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
6
|
+
*/
|
|
7
|
+
const Style = ({ cssText, ...rest }) => {
|
|
5
8
|
/*
|
|
6
9
|
Only inject theme CSS variables if given a theme.
|
|
7
10
|
The CSS file users import already has the default theme variables in it.
|
|
@@ -50,15 +53,10 @@ const StylePrimitive = ({ cssText, ...rest }, ref) => {
|
|
|
50
53
|
if (cssText === undefined || /<\/style/i.test(cssText)) {
|
|
51
54
|
return null;
|
|
52
55
|
}
|
|
53
|
-
return (React.createElement("style", { ...rest,
|
|
56
|
+
return (React.createElement("style", { ...rest,
|
|
54
57
|
// eslint-disable-next-line react/no-danger
|
|
55
58
|
dangerouslySetInnerHTML: { __html: cssText } }));
|
|
56
59
|
};
|
|
57
|
-
/**
|
|
58
|
-
* @experimental
|
|
59
|
-
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
60
|
-
*/
|
|
61
|
-
const Style = primitiveWithForwardRef(StylePrimitive);
|
|
62
60
|
Style.displayName = 'Style';
|
|
63
61
|
|
|
64
62
|
export { Style };
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { primitiveWithForwardRef } from '../../primitives/utils/primitiveWithForwardRef.mjs';
|
|
3
2
|
import { Style } from './Style.mjs';
|
|
4
3
|
|
|
5
|
-
const ThemeStylePrimitive = ({ theme, nonce, ...rest }, ref) => {
|
|
6
|
-
if (!theme)
|
|
7
|
-
return null;
|
|
8
|
-
const { name, cssText } = theme;
|
|
9
|
-
return (React.createElement(Style, { ...rest, ref: ref, cssText: cssText, nonce: nonce, id: `amplify-theme-${name}` }));
|
|
10
|
-
};
|
|
11
4
|
/**
|
|
12
5
|
* @experimental
|
|
13
6
|
* [📖 Docs](https://ui.docs.amplify.aws/react/components/theme)
|
|
14
7
|
*/
|
|
15
|
-
const ThemeStyle =
|
|
8
|
+
const ThemeStyle = ({ theme, ...rest }) => {
|
|
9
|
+
if (!theme)
|
|
10
|
+
return null;
|
|
11
|
+
const { name, cssText } = theme;
|
|
12
|
+
return React.createElement(Style, { ...rest, cssText: cssText, id: `amplify-theme-${name}` });
|
|
13
|
+
};
|
|
16
14
|
ThemeStyle.displayName = 'ThemeStyle';
|
|
17
15
|
|
|
18
16
|
export { ThemeStyle };
|
package/dist/esm/internal.mjs
CHANGED
|
@@ -3,6 +3,7 @@ export { useStorageURL } from './hooks/useStorageURL.mjs';
|
|
|
3
3
|
export { useThemeBreakpoint } from './hooks/useThemeBreakpoint.mjs';
|
|
4
4
|
export { useDeprecationWarning } from './hooks/useDeprecationWarning.mjs';
|
|
5
5
|
export { useColorMode } from './hooks/useTheme.mjs';
|
|
6
|
+
export { useDropZone } from '@aws-amplify/ui-react-core';
|
|
6
7
|
export { FilterChildren } from './components/FilterChildren/FilterChildren.mjs';
|
|
7
8
|
export { AlertIcon } from './primitives/Alert/AlertIcon.mjs';
|
|
8
9
|
export { IconAdd } from './primitives/Icon/icons/IconAdd.mjs';
|
|
@@ -31,7 +32,6 @@ export { IconVisibilityOff } from './primitives/Icon/icons/IconVisibilityOff.mjs
|
|
|
31
32
|
export { IconVisibility } from './primitives/Icon/icons/IconVisibility.mjs';
|
|
32
33
|
export { IconWarning } from './primitives/Icon/icons/IconWarning.mjs';
|
|
33
34
|
export { useIcons } from './primitives/Icon/context/useIcons.mjs';
|
|
34
|
-
export { useDropZone } from './primitives/DropZone/useDropZone.mjs';
|
|
35
35
|
import './primitives/Field/FieldClearButton.mjs';
|
|
36
36
|
import './primitives/Field/FieldDescription.mjs';
|
|
37
37
|
import './primitives/Field/FieldErrorMessage.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { classNames, ComponentClassName,
|
|
2
|
+
import { classNames, ComponentClassName, isFunction } from '@aws-amplify/ui';
|
|
3
3
|
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
4
4
|
import { View } from '../View/View.mjs';
|
|
5
5
|
import { AccordionContext, AccordionItemContext } from './AccordionContext.mjs';
|
|
@@ -8,7 +8,7 @@ const AccordionTriggerPrimitive = ({ children, className, ...rest }, ref) => {
|
|
|
8
8
|
const context = React.useContext(AccordionContext);
|
|
9
9
|
const value = React.useContext(AccordionItemContext);
|
|
10
10
|
const handleOnClick = (e) => {
|
|
11
|
-
if (
|
|
11
|
+
if (isFunction(rest.onClick)) {
|
|
12
12
|
rest.onClick(e);
|
|
13
13
|
}
|
|
14
14
|
if (context?.setValue && value) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useDropZone } from '
|
|
2
|
+
import { useDropZone } from '@aws-amplify/ui-react-core';
|
|
3
3
|
import { DropZoneProvider } from './DropZoneProvider.mjs';
|
|
4
4
|
import { DropZoneContainer } from './DropZoneContainer.mjs';
|
|
5
5
|
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { classNames, ComponentClassName, classNameModifierByFlag,
|
|
2
|
+
import { classNames, ComponentClassName, classNameModifierByFlag, isFunction } from '@aws-amplify/ui';
|
|
3
3
|
import { View } from '../View/View.mjs';
|
|
4
4
|
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
5
5
|
import { TabsContext } from './TabsContext.mjs';
|
|
@@ -13,7 +13,7 @@ const TabsItemPrimitive = ({ className, value, children, onClick, as = 'button',
|
|
|
13
13
|
}
|
|
14
14
|
const isActive = activeTab === value;
|
|
15
15
|
const handleOnClick = (e) => {
|
|
16
|
-
if (
|
|
16
|
+
if (isFunction(onClick)) {
|
|
17
17
|
onClick?.(e);
|
|
18
18
|
}
|
|
19
19
|
setActiveTab(value);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { objectKeys } from '../utils.mjs';
|
|
2
2
|
|
|
3
3
|
// Inspiration for getMediaQueries and useBreakpoint
|
|
4
|
+
// comes from https://github.com/iiroj/use-breakpoint/
|
|
4
5
|
const getMediaQueries = ({ breakpoints }) => {
|
|
5
6
|
const sortedBreakpoints = objectKeys(breakpoints).sort((a, b) => breakpoints[b] - breakpoints[a]);
|
|
6
7
|
return sortedBreakpoints.map((breakpoint, index) => {
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { getMediaQueries } from './getMediaQueries.mjs';
|
|
3
3
|
|
|
4
4
|
// Inspiration for getMediaQueries and useBreakpoint
|
|
5
|
+
// comes from https://github.com/iiroj/use-breakpoint/
|
|
5
6
|
const useIsomorphicEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;
|
|
6
7
|
const useBreakpoint = ({ breakpoints, defaultBreakpoint, }) => {
|
|
7
8
|
const supportMatchMedia = typeof window !== 'undefined' && typeof window.matchMedia !== 'undefined';
|
package/dist/esm/server.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ThemeStyle } from './components/ThemeProvider/ThemeStyle.mjs';
|
|
2
2
|
export { ComponentStyle } from './components/ThemeProvider/ComponentStyle.mjs';
|
|
3
|
+
export { GlobalStyle } from './components/ThemeProvider/GlobalStyle.mjs';
|
|
3
4
|
export { createComponentClasses, createTheme, defaultDarkModeOverride, defaultTheme, defineComponentTheme } from '@aws-amplify/ui';
|
package/dist/esm/version.mjs
CHANGED