@aws-amplify/ui-react 1.2.26-unstable.2 → 2.0.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.
Files changed (164) hide show
  1. package/dist/esm/index.css +1 -0
  2. package/dist/esm/index.css.map +7 -0
  3. package/dist/esm/index.js +1 -0
  4. package/dist/esm/index.js.map +7 -0
  5. package/dist/esm/legacy.js +1 -0
  6. package/dist/esm/legacy.js.map +7 -0
  7. package/dist/index.css +1 -0
  8. package/dist/index.css.map +7 -0
  9. package/dist/index.d.ts +7533 -0
  10. package/dist/index.js +1 -0
  11. package/dist/index.js.map +7 -0
  12. package/dist/legacy.d.ts +1 -0
  13. package/dist/legacy.js +1 -0
  14. package/dist/legacy.js.map +7 -0
  15. package/dist/primitives.json +22168 -0
  16. package/legacy/package.json +7 -0
  17. package/package.json +82 -40
  18. package/CHANGELOG.md +0 -339
  19. package/README.md +0 -1
  20. package/build.js +0 -5
  21. package/dist/0.js +0 -269
  22. package/dist/0.js.map +0 -1
  23. package/dist/1.js +0 -2111
  24. package/dist/1.js.map +0 -1
  25. package/dist/10.js +0 -707
  26. package/dist/10.js.map +0 -1
  27. package/dist/11.js +0 -45
  28. package/dist/11.js.map +0 -1
  29. package/dist/12.js +0 -1152
  30. package/dist/12.js.map +0 -1
  31. package/dist/13.js +0 -114
  32. package/dist/13.js.map +0 -1
  33. package/dist/14.js +0 -1194
  34. package/dist/14.js.map +0 -1
  35. package/dist/15.js +0 -61
  36. package/dist/15.js.map +0 -1
  37. package/dist/16.js +0 -37
  38. package/dist/16.js.map +0 -1
  39. package/dist/17.js +0 -127
  40. package/dist/17.js.map +0 -1
  41. package/dist/18.js +0 -90
  42. package/dist/18.js.map +0 -1
  43. package/dist/19.js +0 -267
  44. package/dist/19.js.map +0 -1
  45. package/dist/2.js +0 -766
  46. package/dist/2.js.map +0 -1
  47. package/dist/20.js +0 -74
  48. package/dist/20.js.map +0 -1
  49. package/dist/21.js +0 -50
  50. package/dist/21.js.map +0 -1
  51. package/dist/22.js +0 -57
  52. package/dist/22.js.map +0 -1
  53. package/dist/23.js +0 -50
  54. package/dist/23.js.map +0 -1
  55. package/dist/24.js +0 -271
  56. package/dist/24.js.map +0 -1
  57. package/dist/25.js +0 -102
  58. package/dist/25.js.map +0 -1
  59. package/dist/26.js +0 -64
  60. package/dist/26.js.map +0 -1
  61. package/dist/27.js +0 -379
  62. package/dist/27.js.map +0 -1
  63. package/dist/28.js +0 -47
  64. package/dist/28.js.map +0 -1
  65. package/dist/29.js +0 -46
  66. package/dist/29.js.map +0 -1
  67. package/dist/3.js +0 -2787
  68. package/dist/3.js.map +0 -1
  69. package/dist/30.js +0 -503
  70. package/dist/30.js.map +0 -1
  71. package/dist/31.js +0 -2
  72. package/dist/31.js.map +0 -1
  73. package/dist/32.js +0 -2
  74. package/dist/32.js.map +0 -1
  75. package/dist/33.js +0 -13
  76. package/dist/33.js.map +0 -1
  77. package/dist/4.js +0 -4126
  78. package/dist/4.js.map +0 -1
  79. package/dist/5.js +0 -817
  80. package/dist/5.js.map +0 -1
  81. package/dist/6.js +0 -619
  82. package/dist/6.js.map +0 -1
  83. package/dist/7.js +0 -662
  84. package/dist/7.js.map +0 -1
  85. package/dist/8.js +0 -614
  86. package/dist/8.js.map +0 -1
  87. package/dist/9.js +0 -665
  88. package/dist/9.js.map +0 -1
  89. package/dist/@aws-amplify/ui-react.js +0 -31875
  90. package/dist/@aws-amplify/ui-react.js.map +0 -1
  91. package/dist/aws-amplify-react.min.js +0 -28
  92. package/dist/aws-amplify-react.min.js.map +0 -1
  93. package/dist/polyfills-core-js.js +0 -5211
  94. package/dist/polyfills-core-js.js.map +0 -1
  95. package/dist/polyfills-css-shim.js +0 -467
  96. package/dist/polyfills-css-shim.js.map +0 -1
  97. package/dist/polyfills-dom.js +0 -2098
  98. package/dist/polyfills-dom.js.map +0 -1
  99. package/jest.config.js +0 -12
  100. package/lib/components.d.ts +0 -56
  101. package/lib/components.js +0 -64
  102. package/lib/components.js.map +0 -1
  103. package/lib/index.d.ts +0 -2
  104. package/lib/index.js +0 -9
  105. package/lib/index.js.map +0 -1
  106. package/lib/react-component-lib/createComponent.d.ts +0 -2
  107. package/lib/react-component-lib/createComponent.js +0 -91
  108. package/lib/react-component-lib/createComponent.js.map +0 -1
  109. package/lib/react-component-lib/createControllerComponent.d.ts +0 -43
  110. package/lib/react-component-lib/createControllerComponent.js +0 -152
  111. package/lib/react-component-lib/createControllerComponent.js.map +0 -1
  112. package/lib/react-component-lib/createOverlayComponent.d.ts +0 -45
  113. package/lib/react-component-lib/createOverlayComponent.js +0 -148
  114. package/lib/react-component-lib/createOverlayComponent.js.map +0 -1
  115. package/lib/react-component-lib/index.d.ts +0 -3
  116. package/lib/react-component-lib/index.js +0 -9
  117. package/lib/react-component-lib/index.js.map +0 -1
  118. package/lib/react-component-lib/utils/attachEventProps.d.ts +0 -8
  119. package/lib/react-component-lib/utils/attachEventProps.js +0 -85
  120. package/lib/react-component-lib/utils/attachEventProps.js.map +0 -1
  121. package/lib/react-component-lib/utils/index.d.ts +0 -8
  122. package/lib/react-component-lib/utils/index.js +0 -36
  123. package/lib/react-component-lib/utils/index.js.map +0 -1
  124. package/lib/withAuthenticator.d.ts +0 -3
  125. package/lib/withAuthenticator.js +0 -127
  126. package/lib/withAuthenticator.js.map +0 -1
  127. package/lib-esm/components.d.ts +0 -56
  128. package/lib-esm/components.js +0 -62
  129. package/lib-esm/components.js.map +0 -1
  130. package/lib-esm/index.d.ts +0 -2
  131. package/lib-esm/index.js +0 -3
  132. package/lib-esm/index.js.map +0 -1
  133. package/lib-esm/react-component-lib/createComponent.d.ts +0 -2
  134. package/lib-esm/react-component-lib/createComponent.js +0 -86
  135. package/lib-esm/react-component-lib/createComponent.js.map +0 -1
  136. package/lib-esm/react-component-lib/createControllerComponent.d.ts +0 -43
  137. package/lib-esm/react-component-lib/createControllerComponent.js +0 -146
  138. package/lib-esm/react-component-lib/createControllerComponent.js.map +0 -1
  139. package/lib-esm/react-component-lib/createOverlayComponent.d.ts +0 -45
  140. package/lib-esm/react-component-lib/createOverlayComponent.js +0 -142
  141. package/lib-esm/react-component-lib/createOverlayComponent.js.map +0 -1
  142. package/lib-esm/react-component-lib/index.d.ts +0 -3
  143. package/lib-esm/react-component-lib/index.js +0 -4
  144. package/lib-esm/react-component-lib/index.js.map +0 -1
  145. package/lib-esm/react-component-lib/utils/attachEventProps.d.ts +0 -8
  146. package/lib-esm/react-component-lib/utils/attachEventProps.js +0 -79
  147. package/lib-esm/react-component-lib/utils/attachEventProps.js.map +0 -1
  148. package/lib-esm/react-component-lib/utils/index.d.ts +0 -8
  149. package/lib-esm/react-component-lib/utils/index.js +0 -28
  150. package/lib-esm/react-component-lib/utils/index.js.map +0 -1
  151. package/lib-esm/withAuthenticator.d.ts +0 -3
  152. package/lib-esm/withAuthenticator.js +0 -121
  153. package/lib-esm/withAuthenticator.js.map +0 -1
  154. package/src/components.ts +0 -65
  155. package/src/index.ts +0 -3
  156. package/src/react-component-lib/createComponent.tsx +0 -69
  157. package/src/react-component-lib/createControllerComponent.tsx +0 -71
  158. package/src/react-component-lib/createOverlayComponent.tsx +0 -79
  159. package/src/react-component-lib/index.ts +0 -3
  160. package/src/react-component-lib/utils/attachEventProps.ts +0 -87
  161. package/src/react-component-lib/utils/index.tsx +0 -31
  162. package/src/withAuthenticator.tsx +0 -62
  163. package/webpack.config.dev.js +0 -6
  164. package/webpack.config.js +0 -56
@@ -1,71 +0,0 @@
1
- import React from 'react';
2
- import { attachEventProps } from './utils/attachEventProps';
3
-
4
- interface LoadingElement {
5
- present: () => any;
6
- dismiss: () => any;
7
- }
8
-
9
- interface ReactControllerProps<E> {
10
- isOpen: boolean;
11
- onDidDismiss: (event: CustomEvent<E>) => void;
12
- }
13
-
14
- export function createControllerComponent<
15
- OptionsType extends object,
16
- LoadingElementType extends LoadingElement,
17
- OverlayEventDetail
18
- >(displayName: string, controller: { create: (options: any) => Promise<LoadingElementType> }) {
19
- const dismissEventName = `on${displayName}DidDismiss`;
20
-
21
- type Props = OptionsType & ReactControllerProps<OverlayEventDetail>;
22
-
23
- return class ReactControllerComponent extends React.Component<Props> {
24
- controller?: LoadingElementType;
25
-
26
- constructor(props: Props) {
27
- super(props);
28
- }
29
-
30
- static get displayName() {
31
- return displayName;
32
- }
33
-
34
- async componentDidMount() {
35
- const { isOpen } = this.props;
36
- if (isOpen) {
37
- this.present();
38
- }
39
- }
40
-
41
- async componentDidUpdate(prevProps: Props) {
42
- if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
43
- this.present(prevProps);
44
- }
45
- if (
46
- this.controller &&
47
- prevProps.isOpen !== this.props.isOpen &&
48
- this.props.isOpen === false
49
- ) {
50
- await this.controller.dismiss();
51
- }
52
- }
53
-
54
- async present(prevProps?: Props) {
55
- const { isOpen, onDidDismiss, ...cProps } = this.props;
56
- const elementProps = {
57
- ...cProps,
58
- [dismissEventName]: onDidDismiss,
59
- };
60
- this.controller = await controller.create({
61
- ...elementProps,
62
- });
63
- attachEventProps(this.controller as any, elementProps, prevProps);
64
- this.controller.present();
65
- }
66
-
67
- render(): null {
68
- return null;
69
- }
70
- };
71
- }
@@ -1,79 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom';
3
- import { attachEventProps } from './utils/attachEventProps';
4
-
5
- interface LoadingElement {
6
- present: () => any;
7
- dismiss: () => any;
8
- }
9
- interface ReactOverlayProps<E> {
10
- children?: React.ReactNode;
11
- isOpen: boolean;
12
- onDidDismiss?: (event: CustomEvent<E>) => void;
13
- }
14
-
15
- export function createOverlayComponent<
16
- T extends object,
17
- LoadingElementType extends LoadingElement,
18
- OverlayEventDetail
19
- >(displayName: string, controller: { create: (options: any) => Promise<LoadingElementType> }) {
20
- const dismissEventName = `on${displayName}DidDismiss`;
21
-
22
- type Props = T & ReactOverlayProps<OverlayEventDetail>;
23
-
24
- return class ReactOverlayComponent extends React.Component<Props> {
25
- controller?: LoadingElementType;
26
- el: HTMLDivElement;
27
-
28
- constructor(props: Props) {
29
- super(props);
30
- this.el = document.createElement('div');
31
- }
32
-
33
- static get displayName() {
34
- return displayName;
35
- }
36
-
37
- componentDidMount() {
38
- if (this.props.isOpen) {
39
- this.present();
40
- }
41
- }
42
-
43
- async componentDidUpdate(prevProps: Props) {
44
- if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
45
- this.present(prevProps);
46
- }
47
- if (
48
- this.controller &&
49
- prevProps.isOpen !== this.props.isOpen &&
50
- this.props.isOpen === false
51
- ) {
52
- await this.controller.dismiss();
53
- }
54
- }
55
-
56
- async present(prevProps?: Props) {
57
- // tslint:disable-next-line:no-empty
58
- const { children, isOpen, onDidDismiss = () => {}, ...cProps } = this.props;
59
- const elementProps = {
60
- ...cProps,
61
- [dismissEventName]: onDidDismiss,
62
- };
63
-
64
- this.controller = await controller.create({
65
- ...elementProps,
66
- component: this.el,
67
- componentProps: {},
68
- });
69
-
70
- attachEventProps(this.controller as any, elementProps, prevProps);
71
-
72
- this.controller.present();
73
- }
74
-
75
- render() {
76
- return ReactDOM.createPortal(this.props.children, this.el);
77
- }
78
- };
79
- }
@@ -1,3 +0,0 @@
1
- export { createReactComponent } from './createComponent';
2
- export { createControllerComponent } from './createControllerComponent';
3
- export { createOverlayComponent } from './createOverlayComponent';
@@ -1,87 +0,0 @@
1
- export function attachEventProps(node: HTMLElement, newProps: any, oldProps: any = {}) {
2
- const className = getClassName(node.classList, newProps, oldProps);
3
- if (className) {
4
- node.className = className;
5
- }
6
-
7
- Object.keys(newProps).forEach(name => {
8
- if (name === 'children' || name === 'style' || name === 'ref' || name === 'className') {
9
- return;
10
- }
11
- if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
12
- const eventName = name.substring(2);
13
- const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
14
-
15
- if (!isCoveredByReact(eventNameLc)) {
16
- syncEvent(node, eventNameLc, newProps[name]);
17
- }
18
- } else {
19
- (node as any)[name] = newProps[name];
20
- }
21
- });
22
- }
23
-
24
- export function getClassName(classList: DOMTokenList, newProps: any, oldProps: any) {
25
- // map the classes to Maps for performance
26
- const currentClasses = arrayToMap(classList);
27
- const incomingPropClasses = arrayToMap(newProps.className ? newProps.className.split(' ') : []);
28
- const oldPropClasses = arrayToMap(oldProps.className ? oldProps.className.split(' ') : []);
29
- const finalClassNames: string[] = [];
30
- // loop through each of the current classes on the component
31
- // to see if it should be a part of the classNames added
32
- currentClasses.forEach(currentClass => {
33
- if (incomingPropClasses.has(currentClass)) {
34
- // add it as its already included in classnames coming in from newProps
35
- finalClassNames.push(currentClass);
36
- incomingPropClasses.delete(currentClass);
37
- } else if (!oldPropClasses.has(currentClass)) {
38
- // add it as it has NOT been removed by user
39
- finalClassNames.push(currentClass);
40
- }
41
- });
42
- incomingPropClasses.forEach(s => finalClassNames.push(s));
43
- return finalClassNames.join(' ');
44
- }
45
-
46
- /**
47
- * Checks if an event is supported in the current execution environment.
48
- * @license Modernizr 3.0.0pre (Custom Build) | MIT
49
- */
50
- export function isCoveredByReact(eventNameSuffix: string, doc: Document = document) {
51
- const eventName = 'on' + eventNameSuffix;
52
- let isSupported = eventName in doc;
53
-
54
- if (!isSupported) {
55
- const element = doc.createElement('div');
56
- element.setAttribute(eventName, 'return;');
57
- isSupported = typeof (element as any)[eventName] === 'function';
58
- }
59
-
60
- return isSupported;
61
- }
62
-
63
- export function syncEvent(node: Element, eventName: string, newEventHandler: (e: Event) => any) {
64
- const eventStore = (node as any).__events || ((node as any).__events = {});
65
- const oldEventHandler = eventStore[eventName];
66
-
67
- // Remove old listener so they don't double up.
68
- if (oldEventHandler) {
69
- node.removeEventListener(eventName, oldEventHandler);
70
- }
71
-
72
- if (newEventHandler != null) {
73
- // Bind new listener.
74
- node.addEventListener(
75
- eventName,
76
- (eventStore[eventName] = function handler(e: Event) {
77
- newEventHandler.call(this, e);
78
- }),
79
- );
80
- }
81
- }
82
-
83
- function arrayToMap(arr: string[] | DOMTokenList) {
84
- const map = new Map<string, string>();
85
- (arr as string[]).forEach((s: string) => map.set(s, s));
86
- return map;
87
- }
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
-
3
- export const dashToPascalCase = (str: string) =>
4
- str
5
- .toLowerCase()
6
- .split('-')
7
- .map(segment => segment.charAt(0).toUpperCase() + segment.slice(1))
8
- .join('');
9
-
10
- export interface ReactProps {
11
- class?: string;
12
- }
13
-
14
- export type IonicReactExternalProps<PropType, ElementType> = PropType & React.HTMLAttributes<ElementType> & ReactProps;
15
-
16
- export const createForwardRef = <PropType, ElementType>(
17
- ReactComponent: any,
18
- displayName: string,
19
- ) => {
20
- const forwardRef = (
21
- props: IonicReactExternalProps<PropType, ElementType>,
22
- ref: React.Ref<ElementType>,
23
- ) => {
24
- return <ReactComponent {...props} forwardedRef={ref} />;
25
- };
26
- forwardRef.displayName = displayName;
27
-
28
- return React.forwardRef(forwardRef);
29
- };
30
-
31
- export * from './attachEventProps';
@@ -1,62 +0,0 @@
1
- import React, {
2
- ComponentType,
3
- ComponentPropsWithRef,
4
- FunctionComponent,
5
- } from 'react';
6
- import { Auth, appendToCognitoUserAgent } from '@aws-amplify/auth';
7
- import { AmplifyContainer, AmplifyAuthenticator, AmplifyAuthContainer } from './';
8
- import { onAuthUIStateChange, AuthState } from '@aws-amplify/ui-components';
9
- import { Logger } from '@aws-amplify/core';
10
-
11
- const logger = new Logger('withAuthenticator');
12
-
13
- export function withAuthenticator<T extends object>(
14
- Component: ComponentType<T>,
15
- authenticatorProps?: ComponentPropsWithRef<typeof AmplifyAuthenticator>
16
- ) {
17
- const AppWithAuthenticator: FunctionComponent<T> = props => {
18
- const [signedIn, setSignedIn] = React.useState(false);
19
-
20
- React.useEffect(() => {
21
- appendToCognitoUserAgent('withAuthenticator');
22
-
23
- // checkUser returns an "unsubscribe" function to stop side-effects
24
- return checkUser();
25
- }, []);
26
-
27
- function checkUser() {
28
- setUser();
29
-
30
- return onAuthUIStateChange(authState => {
31
- if (authState === AuthState.SignedIn) {
32
- setSignedIn(true);
33
- } else if (authState === AuthState.SignedOut) {
34
- setSignedIn(false);
35
- }
36
- });
37
- }
38
-
39
- async function setUser() {
40
- try {
41
- const user = await Auth.currentAuthenticatedUser();
42
- if (user) setSignedIn(true);
43
- } catch (err) {
44
- logger.debug(err);
45
- }
46
- };
47
-
48
- if (!signedIn) {
49
- return (
50
- <AmplifyContainer>
51
- <AmplifyAuthContainer>
52
- <AmplifyAuthenticator {...authenticatorProps} {...props} />
53
- </AmplifyAuthContainer>
54
- </AmplifyContainer>
55
- );
56
- }
57
-
58
- return <Component {...props} />;
59
- };
60
-
61
- return AppWithAuthenticator;
62
- }
@@ -1,6 +0,0 @@
1
- var config = require('./webpack.config.js');
2
-
3
- var entry = {
4
- '@aws-amplify/ui-react': './lib/index.js',
5
- };
6
- module.exports = Object.assign(config, { entry, mode: 'development' });
package/webpack.config.js DELETED
@@ -1,56 +0,0 @@
1
- module.exports = {
2
- entry: {
3
- 'aws-amplify-react.min': './lib/index.js',
4
- },
5
- externals: [
6
- '@aws-amplify/auth',
7
- '@aws-amplify/analytics',
8
- '@aws-amplify/api',
9
- '@aws-amplify/core',
10
- '@aws-amplify/interactions',
11
- '@aws-amplify/storage',
12
- '@aws-amplify/ui',
13
- '@aws-amplify/ui/dist/style.css',
14
- '@aws-amplify/xr',
15
- 'aws-amplify',
16
- 'react',
17
- ],
18
- output: {
19
- filename: '[name].js',
20
- path: __dirname + '/dist',
21
- library: 'aws_amplify_react',
22
- libraryTarget: 'umd',
23
- umdNamedDefine: true,
24
- globalObject: 'this',
25
- devtoolModuleFilenameTemplate: require('../aws-amplify/webpack-utils')
26
- .devtoolModuleFilenameTemplate,
27
- },
28
- // Enable sourcemaps for debugging webpack's output.
29
- devtool: 'source-map',
30
- resolve: {
31
- extensions: ['.js', '.json'],
32
- },
33
- mode: 'production',
34
- module: {
35
- rules: [
36
- // All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
37
- //{ enforce: 'pre', test: /\.js$/, loader: 'source-map-loader' },
38
- {
39
- test: /\.js?$/,
40
- exclude: /node_modules/,
41
- use: [
42
- 'babel-loader',
43
- {
44
- loader: 'babel-loader',
45
- options: {
46
- presets: ['@babel/preset-env'],
47
- },
48
- },
49
- ],
50
- },
51
- ],
52
- },
53
- node: {
54
- fs: 'empty',
55
- },
56
- };